Skip to content

Commit 2f9f082

Browse files
committed
Squashed 'src/univalue/' content from commit 87d9045
git-subtree-dir: src/univalue git-subtree-split: 87d9045
0 parents  commit 2f9f082

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1994
-0
lines changed

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.deps/
2+
INSTALL
3+
Makefile
4+
Makefile.in
5+
aclocal.m4
6+
autom4te.cache/
7+
compile
8+
config.log
9+
config.status
10+
config.guess
11+
config.sub
12+
configure
13+
depcomp
14+
install-sh
15+
missing
16+
stamp-h1
17+
univalue-config.h*
18+
test-driver
19+
libtool
20+
ltmain.sh
21+
22+
*.o

.travis.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
language: cpp
3+
4+
compiler:
5+
- clang
6+
- gcc
7+
8+
os:
9+
- linux
10+
- osx
11+
12+
sudo: false
13+
14+
env:
15+
global:
16+
- MAKEJOBS=-j3
17+
- RUN_TESTS=true
18+
- BASE_OUTDIR=$TRAVIS_BUILD_DIR/out
19+
20+
cache:
21+
apt: true
22+
23+
addons:
24+
apt:
25+
packages:
26+
- pkg-config
27+
28+
before_script:
29+
- if [ -n "$USE_SHELL" ]; then export CONFIG_SHELL="$USE_SHELL"; fi
30+
- test -n "$USE_SHELL" && eval '"$USE_SHELL" -c "./autogen.sh"' || ./autogen.sh
31+
32+
script:
33+
- if [ -n "$UNIVALUE_CONFIG" ]; then unset CC; unset CXX; fi
34+
- OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST
35+
- UNIVALUE_CONFIG_ALL="--prefix=$TRAVIS_BUILD_DIR/depends/$HOST --bindir=$OUTDIR/bin --libdir=$OUTDIR/lib"
36+
- ./configure --cache-file=config.cache $UNIVALUE_CONFIG_ALL $UNIVALUE_CONFIG || ( cat config.log && false)
37+
- make -s $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL ; false )
38+
- export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib
39+
- if [ "$RUN_TESTS" = "true" ]; then make check; fi
40+
41+
matrix:
42+
fast_finish: true
43+
include:
44+
- os: linux
45+
compiler: gcc
46+
env: UNIVALUE_CONFIG=--host=x86_64-w64-mingw32 RUN_TESTS=false
47+
addons:
48+
apt:
49+
packages:
50+
- g++-mingw-w64-x86-64
51+
- gcc-mingw-w64-x86-64
52+
- binutils-mingw-w64-x86-64

COPYING

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
Permission is hereby granted, free of charge, to any person obtaining a copy
3+
of this software and associated documentation files (the "Software"), to deal
4+
in the Software without restriction, including without limitation the rights
5+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6+
copies of the Software, and to permit persons to whom the Software is
7+
furnished to do so, subject to the following conditions:
8+
9+
The above copyright notice and this permission notice shall be included in
10+
all copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18+
THE SOFTWARE.
19+

Makefile.am

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
ACLOCAL_AMFLAGS = -I build-aux/m4
2+
.PHONY: gen
3+
.INTERMEDIATE: $(GENBIN)
4+
5+
include_HEADERS = include/univalue.h
6+
noinst_HEADERS = lib/univalue_escapes.h
7+
8+
lib_LTLIBRARIES = lib/libunivalue.la
9+
10+
pkgconfigdir = $(libdir)/pkgconfig
11+
pkgconfig_DATA = pc/libunivalue.pc
12+
13+
lib_libunivalue_la_SOURCES = \
14+
lib/univalue.cpp \
15+
lib/univalue_read.cpp \
16+
lib/univalue_write.cpp
17+
18+
lib_libunivalue_la_LDFLAGS = \
19+
-version-info $(LIBUNIVALUE_CURRENT):$(LIBUNIVALUE_REVISION):$(LIBUNIVALUE_AGE) \
20+
-no-undefined
21+
lib_libunivalue_la_CXXFLAGS = -I$(top_srcdir)/include
22+
23+
TESTS = test/unitester
24+
25+
GENBIN = gen/gen$(BUILD_EXEEXT)
26+
GEN_SRCS = gen/gen.cpp
27+
28+
$(GENBIN): $(GEN_SRCS)
29+
@echo Building $@
30+
$(AM_V_at)c++ -I$(top_srcdir)/include -o $@ $<
31+
32+
gen: lib/univalue_escapes.h $(GENBIN)
33+
@echo Updating $<
34+
$(AM_V_at)$(GENBIN) > lib/univalue_escapes.h
35+
36+
noinst_PROGRAMS = $(TESTS)
37+
38+
TEST_DATA_DIR=test
39+
40+
test_unitester_SOURCES = test/unitester.cpp
41+
test_unitester_LDADD = lib/libunivalue.la
42+
test_unitester_CXXFLAGS = -I$(top_srcdir)/include -DJSON_TEST_SRC=\"$(srcdir)/$(TEST_DATA_DIR)\"
43+
test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
44+
45+
TEST_FILES = \
46+
$(TEST_DATA_DIR)/fail10.json \
47+
$(TEST_DATA_DIR)/fail11.json \
48+
$(TEST_DATA_DIR)/fail12.json \
49+
$(TEST_DATA_DIR)/fail13.json \
50+
$(TEST_DATA_DIR)/fail14.json \
51+
$(TEST_DATA_DIR)/fail15.json \
52+
$(TEST_DATA_DIR)/fail16.json \
53+
$(TEST_DATA_DIR)/fail17.json \
54+
$(TEST_DATA_DIR)/fail18.json \
55+
$(TEST_DATA_DIR)/fail19.json \
56+
$(TEST_DATA_DIR)/fail1.json \
57+
$(TEST_DATA_DIR)/fail20.json \
58+
$(TEST_DATA_DIR)/fail21.json \
59+
$(TEST_DATA_DIR)/fail22.json \
60+
$(TEST_DATA_DIR)/fail23.json \
61+
$(TEST_DATA_DIR)/fail24.json \
62+
$(TEST_DATA_DIR)/fail25.json \
63+
$(TEST_DATA_DIR)/fail26.json \
64+
$(TEST_DATA_DIR)/fail27.json \
65+
$(TEST_DATA_DIR)/fail28.json \
66+
$(TEST_DATA_DIR)/fail29.json \
67+
$(TEST_DATA_DIR)/fail2.json \
68+
$(TEST_DATA_DIR)/fail30.json \
69+
$(TEST_DATA_DIR)/fail31.json \
70+
$(TEST_DATA_DIR)/fail32.json \
71+
$(TEST_DATA_DIR)/fail33.json \
72+
$(TEST_DATA_DIR)/fail34.json \
73+
$(TEST_DATA_DIR)/fail3.json \
74+
$(TEST_DATA_DIR)/fail4.json \
75+
$(TEST_DATA_DIR)/fail5.json \
76+
$(TEST_DATA_DIR)/fail6.json \
77+
$(TEST_DATA_DIR)/fail7.json \
78+
$(TEST_DATA_DIR)/fail8.json \
79+
$(TEST_DATA_DIR)/fail9.json \
80+
$(TEST_DATA_DIR)/pass1.json \
81+
$(TEST_DATA_DIR)/pass2.json \
82+
$(TEST_DATA_DIR)/pass3.json
83+
84+
EXTRA_DIST=$(TEST_FILES) $(GEN_SRCS)

README

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
UniValue
3+
4+
A universal value object, with JSON encoding (output) and decoding (input).
5+
6+
Built as a single dynamic RAII C++ object class, and no templates.
7+

TODO

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
Rearrange tree for easier 'git subtree' style use
3+
4+
Move towards C++11 etc.
5+
6+
Namespace support - must come up with useful shorthand, avoiding
7+
long Univalue::Univalue::Univalue usages forced upon library users.
8+
9+
Improve test suite
10+

autogen.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -e
3+
srcdir="$(dirname $0)"
4+
cd "$srcdir"
5+
if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="`which glibtoolize 2>/dev/null`"; then
6+
LIBTOOLIZE="${GLIBTOOLIZE}"
7+
export LIBTOOLIZE
8+
fi
9+
autoreconf --install --force

build-aux/m4/.empty

Whitespace-only changes.

configure.ac

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
m4_define([libunivalue_major_version], [1])
2+
m4_define([libunivalue_minor_version], [1])
3+
m4_define([libunivalue_micro_version], [1])
4+
m4_define([libunivalue_interface_age], [1])
5+
# If you need a modifier for the version number.
6+
# Normally empty, but can be used to make "fixup" releases.
7+
m4_define([libunivalue_extraversion], [])
8+
9+
dnl libtool versioning from libunivalue
10+
m4_define([libunivalue_current], [m4_eval(100 * libunivalue_minor_version + libunivalue_micro_version - libunivalue_interface_age)])
11+
m4_define([libunivalue_binary_age], [m4_eval(100 * libunivalue_minor_version + libunivalue_micro_version)])
12+
m4_define([libunivalue_revision], [libunivalue_interface_age])
13+
m4_define([libunivalue_age], [m4_eval(libunivalue_binary_age - libunivalue_interface_age)])
14+
m4_define([libunivalue_version], [libunivalue_major_version().libunivalue_minor_version().libunivalue_micro_version()libunivalue_extraversion()])
15+
16+
17+
AC_INIT([univalue], [1.0.0],
18+
[http://github.com/jgarzik/univalue/])
19+
20+
dnl make the compilation flags quiet unless V=1 is used
21+
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
22+
23+
AC_PREREQ(2.60)
24+
AC_CONFIG_SRCDIR([lib/univalue.cpp])
25+
AC_CONFIG_AUX_DIR([build-aux])
26+
AC_CONFIG_MACRO_DIR([build-aux/m4])
27+
AC_CONFIG_HEADERS([univalue-config.h])
28+
AM_INIT_AUTOMAKE([subdir-objects foreign])
29+
30+
LIBUNIVALUE_MAJOR_VERSION=libunivalue_major_version
31+
LIBUNIVALUE_MINOR_VERSION=libunivalue_minor_version
32+
LIBUNIVALUE_MICRO_VERSION=libunivalue_micro_version
33+
LIBUNIVALUE_INTERFACE_AGE=libunivalue_interface_age
34+
35+
# ABI version
36+
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
37+
LIBUNIVALUE_CURRENT=libunivalue_current
38+
LIBUNIVALUE_REVISION=libunivalue_revision
39+
LIBUNIVALUE_AGE=libunivalue_age
40+
41+
AC_SUBST(LIBUNIVALUE_CURRENT)
42+
AC_SUBST(LIBUNIVALUE_REVISION)
43+
AC_SUBST(LIBUNIVALUE_AGE)
44+
45+
LT_INIT
46+
LT_LANG([C++])
47+
48+
case $host in
49+
*mingw*)
50+
LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"
51+
;;
52+
esac
53+
54+
BUILD_EXEEXT=
55+
case $build in
56+
*mingw*)
57+
BUILD_EXEEXT=".exe"
58+
;;
59+
esac
60+
61+
AC_CONFIG_FILES([
62+
Makefile
63+
pc/libunivalue.pc
64+
pc/libunivalue-uninstalled.pc])
65+
66+
AC_SUBST(LIBTOOL_APP_LDFLAGS)
67+
AC_SUBST(BUILD_EXEEXT)
68+
AC_OUTPUT
69+

gen/gen.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Copyright 2014 BitPay Inc.
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
//
6+
// To re-create univalue_escapes.h:
7+
// $ g++ -o gen gen.cpp
8+
// $ ./gen > univalue_escapes.h
9+
//
10+
11+
#include <ctype.h>
12+
#include <stdio.h>
13+
#include <string.h>
14+
#include "univalue.h"
15+
16+
using namespace std;
17+
18+
static bool initEscapes;
19+
static const char *escapes[256];
20+
21+
static void initJsonEscape()
22+
{
23+
escapes[(int)'"'] = "\\\"";
24+
escapes[(int)'\\'] = "\\\\";
25+
escapes[(int)'\b'] = "\\b";
26+
escapes[(int)'\f'] = "\\f";
27+
escapes[(int)'\n'] = "\\n";
28+
escapes[(int)'\r'] = "\\r";
29+
escapes[(int)'\t'] = "\\t";
30+
31+
initEscapes = true;
32+
}
33+
34+
static void outputEscape()
35+
{
36+
printf( "// Automatically generated file. Do not modify.\n"
37+
"#ifndef BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n"
38+
"#define BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n"
39+
"static const char *escapes[256] = {\n");
40+
41+
for (unsigned int i = 0; i < 256; i++) {
42+
if (!escapes[i]) {
43+
printf("\tNULL,\n");
44+
} else {
45+
printf("\t\"");
46+
47+
unsigned int si;
48+
for (si = 0; si < strlen(escapes[i]); si++) {
49+
char ch = escapes[i][si];
50+
switch (ch) {
51+
case '"':
52+
printf("\\\"");
53+
break;
54+
case '\\':
55+
printf("\\\\");
56+
break;
57+
default:
58+
printf("%c", escapes[i][si]);
59+
break;
60+
}
61+
}
62+
63+
printf("\",\n");
64+
}
65+
}
66+
67+
printf( "};\n"
68+
"#endif // BITCOIN_UNIVALUE_UNIVALUE_ESCAPES_H\n");
69+
}
70+
71+
int main (int argc, char *argv[])
72+
{
73+
initJsonEscape();
74+
outputEscape();
75+
return 0;
76+
}
77+

0 commit comments

Comments
 (0)