Browse Source

Merge pull request #6637

95acf3c remove $(@F) and subdirs from univalue make (Jonas Schnelli)
9623e93 [Univalue] add univalue over subtree (Jonas Schnelli)
2f9f082 Squashed 'src/univalue/' content from commit 87d9045 (Jonas Schnelli)
0917306 remove univalue, prepare for subtree (Jonas Schnelli)
0.13
Wladimir J. van der Laan 9 years ago
parent
commit
f297042cae
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 2
      configure.ac
  2. 23
      src/Makefile.am
  3. 2
      src/Makefile.qt.include
  4. 2
      src/Makefile.qttest.include
  5. 3
      src/Makefile.test.include
  6. 2
      src/bitcoin-cli.cpp
  7. 2
      src/bitcoin-tx.cpp
  8. 2
      src/core_read.cpp
  9. 2
      src/core_write.cpp
  10. 2
      src/qt/rpcconsole.cpp
  11. 2
      src/rest.cpp
  12. 2
      src/rpcblockchain.cpp
  13. 2
      src/rpcclient.cpp
  14. 2
      src/rpcclient.h
  15. 2
      src/rpcmining.cpp
  16. 2
      src/rpcmisc.cpp
  17. 2
      src/rpcnet.cpp
  18. 2
      src/rpcprotocol.h
  19. 2
      src/rpcrawtransaction.cpp
  20. 2
      src/rpcserver.cpp
  21. 2
      src/rpcserver.h
  22. 2
      src/test/base58_tests.cpp
  23. 2
      src/test/rpc_tests.cpp
  24. 2
      src/test/rpc_wallet_tests.cpp
  25. 2
      src/test/script_tests.cpp
  26. 2
      src/test/sighash_tests.cpp
  27. 2
      src/test/transaction_tests.cpp
  28. 2
      src/test/univalue_tests.cpp
  29. 22
      src/univalue/.gitignore
  30. 52
      src/univalue/.travis.yml
  31. 19
      src/univalue/COPYING
  32. 84
      src/univalue/Makefile.am
  33. 7
      src/univalue/README
  34. 10
      src/univalue/TODO
  35. 9
      src/univalue/autogen.sh
  36. 0
      src/univalue/build-aux/m4/.empty
  37. 69
      src/univalue/configure.ac
  38. 0
      src/univalue/gen/gen.cpp
  39. 8
      src/univalue/include/univalue.h
  40. 10
      src/univalue/lib/.gitignore
  41. 66
      src/univalue/lib/univalue.cpp
  42. 0
      src/univalue/lib/univalue_escapes.h
  43. 0
      src/univalue/lib/univalue_read.cpp
  44. 0
      src/univalue/lib/univalue_write.cpp
  45. 9
      src/univalue/pc/libunivalue-uninstalled.pc.in
  46. 10
      src/univalue/pc/libunivalue.pc.in
  47. 7
      src/univalue/test/.gitignore
  48. 1
      src/univalue/test/fail1.json
  49. 1
      src/univalue/test/fail10.json
  50. 1
      src/univalue/test/fail11.json
  51. 1
      src/univalue/test/fail12.json
  52. 1
      src/univalue/test/fail13.json
  53. 1
      src/univalue/test/fail14.json
  54. 1
      src/univalue/test/fail15.json
  55. 1
      src/univalue/test/fail16.json
  56. 1
      src/univalue/test/fail17.json
  57. 1
      src/univalue/test/fail18.json
  58. 1
      src/univalue/test/fail19.json
  59. 1
      src/univalue/test/fail2.json
  60. 1
      src/univalue/test/fail20.json
  61. 1
      src/univalue/test/fail21.json
  62. 1
      src/univalue/test/fail22.json
  63. 1
      src/univalue/test/fail23.json
  64. 1
      src/univalue/test/fail24.json
  65. 1
      src/univalue/test/fail25.json
  66. 1
      src/univalue/test/fail26.json
  67. 2
      src/univalue/test/fail27.json
  68. 2
      src/univalue/test/fail28.json
  69. 1
      src/univalue/test/fail29.json
  70. 1
      src/univalue/test/fail3.json
  71. 1
      src/univalue/test/fail30.json
  72. 1
      src/univalue/test/fail31.json
  73. 1
      src/univalue/test/fail32.json
  74. 1
      src/univalue/test/fail33.json
  75. 1
      src/univalue/test/fail34.json
  76. 1
      src/univalue/test/fail4.json
  77. 1
      src/univalue/test/fail5.json
  78. 1
      src/univalue/test/fail6.json
  79. 1
      src/univalue/test/fail7.json
  80. 1
      src/univalue/test/fail8.json
  81. 1
      src/univalue/test/fail9.json
  82. 58
      src/univalue/test/pass1.json
  83. 1
      src/univalue/test/pass2.json
  84. 6
      src/univalue/test/pass3.json
  85. 115
      src/univalue/test/unitester.cpp
  86. 2
      src/wallet/rpcdump.cpp
  87. 2
      src/wallet/rpcwallet.cpp

2
configure.ac

@ -940,7 +940,7 @@ unset PKG_CONFIG_LIBDIR @@ -940,7 +940,7 @@ unset PKG_CONFIG_LIBDIR
PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP"
ac_configure_args="${ac_configure_args} --disable-shared --with-pic --with-bignum=no"
AC_CONFIG_SUBDIRS([src/secp256k1])
AC_CONFIG_SUBDIRS([src/secp256k1 src/univalue])
AC_OUTPUT

23
src/Makefile.am

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
DIST_SUBDIRS = secp256k1
DIST_SUBDIRS = secp256k1 univalue
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS)
@ -21,6 +21,7 @@ BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config @@ -21,6 +21,7 @@ BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config
BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS)
BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include
BITCOIN_INCLUDES += -I$(srcdir)/univalue/include
LIBBITCOIN_SERVER=libbitcoin_server.a
LIBBITCOIN_WALLET=libbitcoin_wallet.a
@ -28,20 +29,22 @@ LIBBITCOIN_COMMON=libbitcoin_common.a @@ -28,20 +29,22 @@ LIBBITCOIN_COMMON=libbitcoin_common.a
LIBBITCOIN_CLI=libbitcoin_cli.a
LIBBITCOIN_UTIL=libbitcoin_util.a
LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
LIBBITCOIN_UNIVALUE=univalue/libbitcoin_univalue.a
LIBBITCOINQT=qt/libbitcoinqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la
LIBUNIVALUE=univalue/lib/libunivalue.la
$(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*)
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
$(LIBUNIVALUE): $(wildcard univalue/lib/*)
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue/
# Make is not made aware of per-object dependencies to avoid limiting building parallelization
# But to build the less dependent modules first, we manually select their order here:
EXTRA_LIBRARIES = \
crypto/libbitcoin_crypto.a \
libbitcoin_util.a \
libbitcoin_common.a \
univalue/libbitcoin_univalue.a \
libbitcoin_server.a \
libbitcoin_cli.a
if ENABLE_WALLET
@ -248,14 +251,6 @@ crypto_libbitcoin_crypto_a_SOURCES = \ @@ -248,14 +251,6 @@ crypto_libbitcoin_crypto_a_SOURCES = \
crypto/sha512.cpp \
crypto/sha512.h
# univalue JSON library
univalue_libbitcoin_univalue_a_SOURCES = \
univalue/univalue.cpp \
univalue/univalue.h \
univalue/univalue_escapes.h \
univalue/univalue_read.cpp \
univalue/univalue_write.cpp
# common: shared between bitcoind, and bitcoin-qt and non-server tools
libbitcoin_common_a_CPPFLAGS = $(BITCOIN_INCLUDES)
libbitcoin_common_a_SOURCES = \
@ -332,7 +327,7 @@ endif @@ -332,7 +327,7 @@ endif
bitcoind_LDADD = \
$(LIBBITCOIN_SERVER) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UNIVALUE) \
$(LIBUNIVALUE) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CRYPTO) \
$(LIBLEVELDB) \
@ -360,7 +355,7 @@ endif @@ -360,7 +355,7 @@ endif
bitcoin_cli_LDADD = \
$(LIBBITCOIN_CLI) \
$(LIBBITCOIN_UNIVALUE) \
$(LIBUNIVALUE) \
$(LIBBITCOIN_UTIL)
bitcoin_cli_LDADD += $(BOOST_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_LIBS)
@ -376,7 +371,7 @@ bitcoin_tx_SOURCES += bitcoin-tx-res.rc @@ -376,7 +371,7 @@ bitcoin_tx_SOURCES += bitcoin-tx-res.rc
endif
bitcoin_tx_LDADD = \
$(LIBBITCOIN_UNIVALUE) \
$(LIBUNIVALUE) \
$(LIBBITCOIN_COMMON) \
$(LIBBITCOIN_UTIL) \
$(LIBBITCOIN_CRYPTO) \

2
src/Makefile.qt.include

@ -367,7 +367,7 @@ endif @@ -367,7 +367,7 @@ endif
if ENABLE_ZMQ
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)

2
src/Makefile.qttest.include

@ -33,7 +33,7 @@ endif @@ -33,7 +33,7 @@ endif
if ENABLE_ZMQ
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
endif
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) \
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \
$(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)

3
src/Makefile.test.include

@ -91,7 +91,7 @@ endif @@ -91,7 +91,7 @@ endif
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
test_test_bitcoin_CPPFLAGS = $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS)
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1)
if ENABLE_WALLET
test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
@ -124,6 +124,7 @@ check-local: @@ -124,6 +124,7 @@ check-local:
@echo "Running test/bitcoin-util-test.py..."
$(AM_V_at)srcdir=$(srcdir) PYTHONPATH=$(builddir)/test $(srcdir)/test/bitcoin-util-test.py
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check
%.json.h: %.json
@$(MKDIR_P) $(@D)

2
src/bitcoin-cli.cpp

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
#include <event2/buffer.h>
#include <event2/keyvalq_struct.h>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/bitcoin-tx.cpp

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
#include "primitives/transaction.h"
#include "script/script.h"
#include "script/sign.h"
#include "univalue/univalue.h"
#include <univalue.h>
#include "util.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"

2
src/core_read.cpp

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
#include "script/script.h"
#include "serialize.h"
#include "streams.h"
#include "univalue/univalue.h"
#include <univalue.h>
#include "util.h"
#include "utilstrencodings.h"
#include "version.h"

2
src/core_write.cpp

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
#include "script/standard.h"
#include "serialize.h"
#include "streams.h"
#include "univalue/univalue.h"
#include <univalue.h>
#include "util.h"
#include "utilmoneystr.h"
#include "utilstrencodings.h"

2
src/qt/rpcconsole.cpp

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
#include <openssl/crypto.h>
#include "univalue/univalue.h"
#include <univalue.h>
#ifdef ENABLE_WALLET
#include <db_cxx.h>

2
src/rest.cpp

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/dynamic_bitset.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/rpcblockchain.cpp

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
#include <stdint.h>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/rpcclient.cpp

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
#include <stdint.h>
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/rpcclient.h

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
#ifndef BITCOIN_RPCCLIENT_H
#define BITCOIN_RPCCLIENT_H
#include "univalue/univalue.h"
#include <univalue.h>
UniValue RPCConvertValues(const std::string& strMethod, const std::vector<std::string>& strParams);
/** Non-RFC4627 JSON parser, accepts internal values (such as numbers, true, false, null)

2
src/rpcmining.cpp

@ -25,7 +25,7 @@ @@ -25,7 +25,7 @@
#include <boost/assign/list_of.hpp>
#include <boost/shared_ptr.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/rpcmisc.cpp

@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
#include <boost/assign/list_of.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/rpcnet.cpp

@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
#include <boost/foreach.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/rpcprotocol.h

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
#include <string>
#include <boost/filesystem.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
//! HTTP status codes
enum HTTPStatusCode

2
src/rpcrawtransaction.cpp

@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
#include <boost/assign/list_of.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/rpcserver.cpp

@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
#include "util.h"
#include "utilstrencodings.h"
#include "univalue/univalue.h"
#include <univalue.h>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>

2
src/rpcserver.h

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
#include <boost/function.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
class CRPCCommand;

2
src/test/base58_tests.cpp

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
extern UniValue read_json(const std::string& jsondata);

2
src/test/rpc_tests.cpp

@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/test/rpc_wallet_tests.cpp

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/test/script_tests.cpp

@ -27,7 +27,7 @@ @@ -27,7 +27,7 @@
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/test/sighash_tests.cpp

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
#include <boost/test/unit_test.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
extern UniValue read_json(const std::string& jsondata);

2
src/test/transaction_tests.cpp

@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
#include <boost/test/unit_test.hpp>
#include <boost/assign/list_of.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

2
src/test/univalue_tests.cpp

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
#include <vector>
#include <string>
#include <map>
#include "univalue/univalue.h"
#include <univalue.h>
#include "test/test_bitcoin.h"
#include <boost/test/unit_test.hpp>

22
src/univalue/.gitignore vendored

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
.deps/
INSTALL
Makefile
Makefile.in
aclocal.m4
autom4te.cache/
compile
config.log
config.status
config.guess
config.sub
configure
depcomp
install-sh
missing
stamp-h1
univalue-config.h*
test-driver
libtool
ltmain.sh
*.o

52
src/univalue/.travis.yml

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
language: cpp
compiler:
- clang
- gcc
os:
- linux
- osx
sudo: false
env:
global:
- MAKEJOBS=-j3
- RUN_TESTS=true
- BASE_OUTDIR=$TRAVIS_BUILD_DIR/out
cache:
apt: true
addons:
apt:
packages:
- pkg-config
before_script:
- if [ -n "$USE_SHELL" ]; then export CONFIG_SHELL="$USE_SHELL"; fi
- test -n "$USE_SHELL" && eval '"$USE_SHELL" -c "./autogen.sh"' || ./autogen.sh
script:
- if [ -n "$UNIVALUE_CONFIG" ]; then unset CC; unset CXX; fi
- OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST
- UNIVALUE_CONFIG_ALL="--prefix=$TRAVIS_BUILD_DIR/depends/$HOST --bindir=$OUTDIR/bin --libdir=$OUTDIR/lib"
- ./configure --cache-file=config.cache $UNIVALUE_CONFIG_ALL $UNIVALUE_CONFIG || ( cat config.log && false)
- make -s $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && make $GOAL ; false )
- export LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib
- if [ "$RUN_TESTS" = "true" ]; then make check; fi
matrix:
fast_finish: true
include:
- os: linux
compiler: gcc
env: UNIVALUE_CONFIG=--host=x86_64-w64-mingw32 RUN_TESTS=false
addons:
apt:
packages:
- g++-mingw-w64-x86-64
- gcc-mingw-w64-x86-64
- binutils-mingw-w64-x86-64

19
src/univalue/COPYING

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

84
src/univalue/Makefile.am

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
ACLOCAL_AMFLAGS = -I build-aux/m4
.PHONY: gen
.INTERMEDIATE: $(GENBIN)
include_HEADERS = include/univalue.h
noinst_HEADERS = lib/univalue_escapes.h
lib_LTLIBRARIES = lib/libunivalue.la
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = pc/libunivalue.pc
lib_libunivalue_la_SOURCES = \
lib/univalue.cpp \
lib/univalue_read.cpp \
lib/univalue_write.cpp
lib_libunivalue_la_LDFLAGS = \
-version-info $(LIBUNIVALUE_CURRENT):$(LIBUNIVALUE_REVISION):$(LIBUNIVALUE_AGE) \
-no-undefined
lib_libunivalue_la_CXXFLAGS = -I$(top_srcdir)/include
TESTS = test/unitester
GENBIN = gen/gen$(BUILD_EXEEXT)
GEN_SRCS = gen/gen.cpp
$(GENBIN): $(GEN_SRCS)
@echo Building $@
$(AM_V_at)c++ -I$(top_srcdir)/include -o $@ $<
gen: lib/univalue_escapes.h $(GENBIN)
@echo Updating $<
$(AM_V_at)$(GENBIN) > lib/univalue_escapes.h
noinst_PROGRAMS = $(TESTS)
TEST_DATA_DIR=test
test_unitester_SOURCES = test/unitester.cpp
test_unitester_LDADD = lib/libunivalue.la
test_unitester_CXXFLAGS = -I$(top_srcdir)/include -DJSON_TEST_SRC=\"$(srcdir)/$(TEST_DATA_DIR)\"
test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS)
TEST_FILES = \
$(TEST_DATA_DIR)/fail10.json \
$(TEST_DATA_DIR)/fail11.json \
$(TEST_DATA_DIR)/fail12.json \
$(TEST_DATA_DIR)/fail13.json \
$(TEST_DATA_DIR)/fail14.json \
$(TEST_DATA_DIR)/fail15.json \
$(TEST_DATA_DIR)/fail16.json \
$(TEST_DATA_DIR)/fail17.json \
$(TEST_DATA_DIR)/fail18.json \
$(TEST_DATA_DIR)/fail19.json \
$(TEST_DATA_DIR)/fail1.json \
$(TEST_DATA_DIR)/fail20.json \
$(TEST_DATA_DIR)/fail21.json \
$(TEST_DATA_DIR)/fail22.json \
$(TEST_DATA_DIR)/fail23.json \
$(TEST_DATA_DIR)/fail24.json \
$(TEST_DATA_DIR)/fail25.json \
$(TEST_DATA_DIR)/fail26.json \
$(TEST_DATA_DIR)/fail27.json \
$(TEST_DATA_DIR)/fail28.json \
$(TEST_DATA_DIR)/fail29.json \
$(TEST_DATA_DIR)/fail2.json \
$(TEST_DATA_DIR)/fail30.json \
$(TEST_DATA_DIR)/fail31.json \
$(TEST_DATA_DIR)/fail32.json \
$(TEST_DATA_DIR)/fail33.json \
$(TEST_DATA_DIR)/fail34.json \
$(TEST_DATA_DIR)/fail3.json \
$(TEST_DATA_DIR)/fail4.json \
$(TEST_DATA_DIR)/fail5.json \
$(TEST_DATA_DIR)/fail6.json \
$(TEST_DATA_DIR)/fail7.json \
$(TEST_DATA_DIR)/fail8.json \
$(TEST_DATA_DIR)/fail9.json \
$(TEST_DATA_DIR)/pass1.json \
$(TEST_DATA_DIR)/pass2.json \
$(TEST_DATA_DIR)/pass3.json
EXTRA_DIST=$(TEST_FILES) $(GEN_SRCS)

7
src/univalue/README

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
UniValue
A universal value object, with JSON encoding (output) and decoding (input).
Built as a single dynamic RAII C++ object class, and no templates.

10
src/univalue/TODO

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
Rearrange tree for easier 'git subtree' style use
Move towards C++11 etc.
Namespace support - must come up with useful shorthand, avoiding
long Univalue::Univalue::Univalue usages forced upon library users.
Improve test suite

9
src/univalue/autogen.sh

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
#!/bin/sh
set -e
srcdir="$(dirname $0)"
cd "$srcdir"
if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="`which glibtoolize 2>/dev/null`"; then
LIBTOOLIZE="${GLIBTOOLIZE}"
export LIBTOOLIZE
fi
autoreconf --install --force

0
src/univalue/build-aux/m4/.empty

69
src/univalue/configure.ac

@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
m4_define([libunivalue_major_version], [1])
m4_define([libunivalue_minor_version], [1])
m4_define([libunivalue_micro_version], [1])
m4_define([libunivalue_interface_age], [1])
# If you need a modifier for the version number.
# Normally empty, but can be used to make "fixup" releases.
m4_define([libunivalue_extraversion], [])
dnl libtool versioning from libunivalue
m4_define([libunivalue_current], [m4_eval(100 * libunivalue_minor_version + libunivalue_micro_version - libunivalue_interface_age)])
m4_define([libunivalue_binary_age], [m4_eval(100 * libunivalue_minor_version + libunivalue_micro_version)])
m4_define([libunivalue_revision], [libunivalue_interface_age])
m4_define([libunivalue_age], [m4_eval(libunivalue_binary_age - libunivalue_interface_age)])
m4_define([libunivalue_version], [libunivalue_major_version().libunivalue_minor_version().libunivalue_micro_version()libunivalue_extraversion()])
AC_INIT([univalue], [1.0.0],
[http://github.com/jgarzik/univalue/])
dnl make the compilation flags quiet unless V=1 is used
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_PREREQ(2.60)
AC_CONFIG_SRCDIR([lib/univalue.cpp])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([build-aux/m4])
AC_CONFIG_HEADERS([univalue-config.h])
AM_INIT_AUTOMAKE([subdir-objects foreign])
LIBUNIVALUE_MAJOR_VERSION=libunivalue_major_version
LIBUNIVALUE_MINOR_VERSION=libunivalue_minor_version
LIBUNIVALUE_MICRO_VERSION=libunivalue_micro_version
LIBUNIVALUE_INTERFACE_AGE=libunivalue_interface_age
# ABI version
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
LIBUNIVALUE_CURRENT=libunivalue_current
LIBUNIVALUE_REVISION=libunivalue_revision
LIBUNIVALUE_AGE=libunivalue_age
AC_SUBST(LIBUNIVALUE_CURRENT)
AC_SUBST(LIBUNIVALUE_REVISION)
AC_SUBST(LIBUNIVALUE_AGE)
LT_INIT
LT_LANG([C++])
case $host in
*mingw*)
LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"
;;
esac
BUILD_EXEEXT=
case $build in
*mingw*)
BUILD_EXEEXT=".exe"
;;
esac
AC_CONFIG_FILES([
Makefile
pc/libunivalue.pc
pc/libunivalue-uninstalled.pc])
AC_SUBST(LIBTOOL_APP_LDFLAGS)
AC_SUBST(BUILD_EXEEXT)
AC_OUTPUT

0
src/univalue/gen.cpp → src/univalue/gen/gen.cpp

8
src/univalue/univalue.h → src/univalue/include/univalue.h

@ -1,11 +1,13 @@ @@ -1,11 +1,13 @@
// Copyright 2014 BitPay Inc.
// Copyright 2015 Bitcoin Core Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_UNIVALUE_UNIVALUE_H
#define BITCOIN_UNIVALUE_UNIVALUE_H
#ifndef __UNIVALUE_H__
#define __UNIVALUE_H__
#include <stdint.h>
#include <string>
#include <vector>
#include <map>
@ -245,4 +247,4 @@ extern const UniValue NullUniValue; @@ -245,4 +247,4 @@ extern const UniValue NullUniValue;
const UniValue& find_value( const UniValue& obj, const std::string& name);
#endif // BITCOIN_UNIVALUE_UNIVALUE_H
#endif // __UNIVALUE_H__

10
src/univalue/lib/.gitignore vendored

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
libunivalue-uninstalled.pc
libunivalue.pc
libunivalue.a
gen
.libs
*.lo
*.la

66
src/univalue/univalue.cpp → src/univalue/lib/univalue.cpp

@ -1,16 +1,78 @@ @@ -1,16 +1,78 @@
// Copyright 2014 BitPay Inc.
// Copyright 2015 Bitcoin Core Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <stdint.h>
#include <ctype.h>
#include <errno.h>
#include <iomanip>
#include <limits>
#include <sstream>
#include <stdexcept> // std::runtime_error
#include <stdexcept>
#include <stdlib.h>
#include <string.h>
#include "univalue.h"
#include "utilstrencodings.h" // ParseXX
namespace
{
static bool ParsePrechecks(const std::string& str)
{
if (str.empty()) // No empty string allowed
return false;
if (str.size() >= 1 && (isspace(str[0]) || isspace(str[str.size()-1]))) // No padding allowed
return false;
if (str.size() != strlen(str.c_str())) // No embedded NUL characters allowed
return false;
return true;
}
bool ParseInt32(const std::string& str, int32_t *out)
{
if (!ParsePrechecks(str))
return false;
char *endp = NULL;
errno = 0; // strtol will not set errno if valid
long int n = strtol(str.c_str(), &endp, 10);
if(out) *out = (int32_t)n;
// Note that strtol returns a *long int*, so even if strtol doesn't report a over/underflow
// we still have to check that the returned value is within the range of an *int32_t*. On 64-bit
// platforms the size of these types may be different.
return endp && *endp == 0 && !errno &&
n >= std::numeric_limits<int32_t>::min() &&
n <= std::numeric_limits<int32_t>::max();
}
bool ParseInt64(const std::string& str, int64_t *out)
{
if (!ParsePrechecks(str))
return false;
char *endp = NULL;
errno = 0; // strtoll will not set errno if valid
long long int n = strtoll(str.c_str(), &endp, 10);
if(out) *out = (int64_t)n;
// Note that strtoll returns a *long long int*, so even if strtol doesn't report a over/underflow
// we still have to check that the returned value is within the range of an *int64_t*.
return endp && *endp == 0 && !errno &&
n >= std::numeric_limits<int64_t>::min() &&
n <= std::numeric_limits<int64_t>::max();
}
bool ParseDouble(const std::string& str, double *out)
{
if (!ParsePrechecks(str))
return false;
if (str.size() >= 2 && str[0] == '0' && str[1] == 'x') // No hexadecimal floats allowed
return false;
std::istringstream text(str);
text.imbue(std::locale::classic());
double result;
text >> result;
if(out) *out = result;
return text.eof() && !text.fail();
}
}
using namespace std;

0
src/univalue/univalue_escapes.h → src/univalue/lib/univalue_escapes.h

0
src/univalue/univalue_read.cpp → src/univalue/lib/univalue_read.cpp

0
src/univalue/univalue_write.cpp → src/univalue/lib/univalue_write.cpp

9
src/univalue/pc/libunivalue-uninstalled.pc.in

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libunivalue
Description: libunivalue, C++ universal value object and JSON library
Version: @VERSION@
Libs: ${pc_top_builddir}/${pcfiledir}/libunivalue.la

10
src/univalue/pc/libunivalue.pc.in

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: libunivalue
Description: libunivalue, C++ universal value object and JSON library
Version: @VERSION@
Libs: -L${libdir} -lunivalue
Cflags: -I${includedir}

7
src/univalue/test/.gitignore vendored

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
unitester
*.log
*.trs
.libs

1
src/univalue/test/fail1.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
"A JSON payload should be an object or array, not a string."

1
src/univalue/test/fail10.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Extra value after close": true} "misplaced quoted value"

1
src/univalue/test/fail11.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Illegal expression": 1 + 2}

1
src/univalue/test/fail12.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Illegal invocation": alert()}

1
src/univalue/test/fail13.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Numbers cannot have leading zeroes": 013}

1
src/univalue/test/fail14.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Numbers cannot be hex": 0x14}

1
src/univalue/test/fail15.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["Illegal backslash escape: \x15"]

1
src/univalue/test/fail16.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
[\naked]

1
src/univalue/test/fail17.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["Illegal backslash escape: \017"]

1
src/univalue/test/fail18.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]

1
src/univalue/test/fail19.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Missing colon" null}

1
src/univalue/test/fail2.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["Unclosed array"

1
src/univalue/test/fail20.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Double colon":: null}

1
src/univalue/test/fail21.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Comma instead of colon", null}

1
src/univalue/test/fail22.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["Colon instead of comma": false]

1
src/univalue/test/fail23.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["Bad value", truth]

1
src/univalue/test/fail24.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
['single quote']

1
src/univalue/test/fail25.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
[" tab character in string "]

1
src/univalue/test/fail26.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["tab\ character\ in\ string\ "]

2
src/univalue/test/fail27.json

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
["line
break"]

2
src/univalue/test/fail28.json

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
["line\
break"]

1
src/univalue/test/fail29.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
[0e]

1
src/univalue/test/fail3.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{unquoted_key: "keys must be quoted"}

1
src/univalue/test/fail30.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
[0e+]

1
src/univalue/test/fail31.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
[0e+-1]

1
src/univalue/test/fail32.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Comma instead if closing brace": true,

1
src/univalue/test/fail33.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["mismatch"}

1
src/univalue/test/fail34.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{} garbage

1
src/univalue/test/fail4.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["extra comma",]

1
src/univalue/test/fail5.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["double extra comma",,]

1
src/univalue/test/fail6.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
[ , "<-- missing value"]

1
src/univalue/test/fail7.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["Comma after the close"],

1
src/univalue/test/fail8.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
["Extra close"]]

1
src/univalue/test/fail9.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
{"Extra comma": true,}

58
src/univalue/test/pass1.json

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
[
"JSON Test Pattern pass1",
{"object with 1 member":["array with 1 element"]},
{},
[],
-42,
true,
false,
null,
{
"integer": 1234567890,
"real": -9876.543210,
"e": 0.123456789e-12,
"E": 1.234567890E+34,
"": 23456789012E66,
"zero": 0,
"one": 1,
"space": " ",
"quote": "\"",
"backslash": "\\",
"controls": "\b\f\n\r\t",
"slash": "/ & \/",
"alpha": "abcdefghijklmnopqrstuvwyz",
"ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
"digit": "0123456789",
"0123456789": "digit",
"special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
"hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
"true": true,
"false": false,
"null": null,
"array":[ ],
"object":{ },
"address": "50 St. James Street",
"url": "http://www.JSON.org/",
"comment": "// /* <!-- --",
"# -- --> */": " ",
" s p a c e d " :[1,2 , 3
,
4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7],
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
"quotes": "&#34; \u0022 %22 0x22 034 &#x22;",
"\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
: "A key can be any string"
},
0.5 ,98.6
,
99.44
,
1066,
1e1,
0.1e1,
1e-1,
1e00,2e+00,2e-00
,"rosebud"]

1
src/univalue/test/pass2.json

@ -0,0 +1 @@ @@ -0,0 +1 @@
[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]

6
src/univalue/test/pass3.json

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
{
"JSON Test Pattern pass3": {
"The outermost value": "must be an object or array.",
"In this test": "It is an object."
}
}

115
src/univalue/test/unitester.cpp

@ -0,0 +1,115 @@ @@ -0,0 +1,115 @@
// Copyright 2014 BitPay Inc.
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <cassert>
#include <string>
#include "univalue.h"
#ifndef JSON_TEST_SRC
#error JSON_TEST_SRC must point to test source directory
#endif
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
using namespace std;
string srcdir(JSON_TEST_SRC);
static void runtest(string filename, const string& jdata)
{
fprintf(stderr, "test %s\n", filename.c_str());
string prefix = filename.substr(0, 4);
bool wantPass = (prefix == "pass");
bool wantFail = (prefix == "fail");
assert(wantPass || wantFail);
UniValue val;
bool testResult = val.read(jdata);
if (wantPass) {
assert(testResult == true);
} else {
assert(testResult == false);
}
}
static void runtest_file(const char *filename_)
{
string basename(filename_);
string filename = srcdir + "/" + basename;
FILE *f = fopen(filename.c_str(), "r");
assert(f != NULL);
string jdata;
char buf[4096];
while (!feof(f)) {
int bread = fread(buf, 1, sizeof(buf), f);
assert(!ferror(f));
string s(buf, bread);
jdata += s;
}
assert(!ferror(f));
fclose(f);
runtest(basename, jdata);
}
static const char *filenames[] = {
"fail10.json",
"fail11.json",
"fail12.json",
"fail13.json",
"fail14.json",
"fail15.json",
"fail16.json",
"fail17.json",
//"fail18.json", // investigate
"fail19.json",
"fail1.json",
"fail20.json",
"fail21.json",
"fail22.json",
"fail23.json",
"fail24.json",
"fail25.json",
"fail26.json",
"fail27.json",
"fail28.json",
"fail29.json",
"fail2.json",
"fail30.json",
"fail31.json",
"fail32.json",
"fail33.json",
"fail34.json",
"fail3.json",
"fail4.json", // extra comma
"fail5.json",
"fail6.json",
"fail7.json",
"fail8.json",
"fail9.json", // extra comma
"pass1.json",
"pass2.json",
"pass3.json",
};
int main (int argc, char *argv[])
{
for (unsigned int fidx = 0; fidx < ARRAY_SIZE(filenames); fidx++) {
runtest_file(filenames[fidx]);
}
return 0;
}

2
src/wallet/rpcdump.cpp

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
#include <boost/foreach.hpp>

2
src/wallet/rpcwallet.cpp

@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
#include <boost/assign/list_of.hpp>
#include "univalue/univalue.h"
#include <univalue.h>
using namespace std;

Loading…
Cancel
Save