mirror of
https://github.com/Evolution-X-Devices/device_google_walleye
synced 2026-01-31 17:22:17 +00:00
6f9c02d Merge "libjson: Initial version with support for android" d322b2a Merge "Merge remote-tracking branch 'remotes/origin/caf/json-c/master'" abb4d87 libjson: Initial version with support for android 81bb78e Merge remote-tracking branch 'remotes/origin/caf/json-c/master' 4822b32 Initial empty repository ec4879a Merge pull request #153 from LeSpocky/doc 6ec6fda Merge pull request #151 from mjchinn/json_type-comma 2c72227 Merge pull request #150 from ams-cs/master f88db70 Merge pull request #141 from AlexandruCostache/master 37f5d86 improve doc for json_object_to_json_string() 048dcf2 Remove json_type enum trailing comma ca0ebe0 Fix build using MinGW. 4841c48 Removed duplicate check in random_seed test - bug #140 d4e81f9 Move the json_min() and json_max() macros to json_util.h and mark everything else in bits.h deprecated. Eliminate all uses of bits.h within the json-c code. 1da0599 Fix the definition of the error_description() macro in bits.h now that json_tokener_errors[] is not exported. 2149a04 Check for failures when allocating memory; return NULL and set errno=ENOMEM in a few of those cases. Thanks to Susant Sahani for pointing out some of these. 92a7740 Reformat some code in json_object.c 795e915 Add an empty README file to placate autoconf. 4569e3e Fix minor typo in README file. 40aab4c Merge pull request #133 from haneefmubarak/patch-1 332a594 Merge pull request #132 from pkoretic/master 7870978 Update README.md 23620b8 Update and rename README to README.md fa54bd5 Update the release checklist to include calculating the tarball checksums and updating the wiki. 259c5c0 Remove unused variable 'size' 515ba0d Bump versions up to 0.12.99 since a 0.12 release was just created. f84d9c5 Update the ChangeLog with the changes for the 0.12 release. Bump the version in the release checklist. 64e3690 Patch to address the following issues: 784534a Eliminate the deprecated mc_abort() function and MC_ABORT macro. f9136f6 Make the json_tokener_errors array local. It has been deprecated for a while, and json_tokener_error_desc() should be used instead. 936d036 Simplify the tests Makefile to avoid repeating the name of each test. e2bbb56 Rename the "test_case" test to "test_charcase" to make it slightly less confusing. 9f26d96 Fix warnings from autoconf about "...no AC_LANG_SOURCE call detected..." by adding that call within the AC_LINK_IFELSE call. 05da316 Issue #103: allow Infinity and -Infinity to be parsed. 217bc29 Merge pull request #123 from fingon/use-NAN-if-available a1c8991 nan function requires -lm on some platforms; use of NAN is better, if available. 0eedf38 Issue#102 - add support for parsing "NaN". e6f1322 Issue#114: check for the presence of isnan and isinf, and provide compat macros on MSCV where _isnan and _finite exist instead. db117ca Merge pull request #121 from TazeTSchnitzel/LowercaseLiterals cf23e75 Merge branch 'master' into LowercaseLiterals 1d6f914 Missing tests 4c086df Merge commit '89535bb' 020fa65 Merge pull request #112 from TazeTSchnitzel/LowercaseLiterals 56df93d Fix Issue #111: Fix off-by-one error when range checking the input to json_tokener_error_desc(). ceeaf42 Merge pull request #109 from kdopen/use_strtod b821f0e Merge branch 'ebassi-master' c8e0497 Merge branch 'master' of https://github.com/ebassi/json-c into ebassi-master 295bea2 Ignore and cleanup a few more files that automake creates. a2c078f Issue#105: Rename configure.in to configure.ac c8ee919 Remove the old libjson.so name compatibility support. The library is only created as libjson-c.so now and headers are only installed into the ${prefix}/json-c directory. 89535bb build: call AM_PROG_CC_C_O as requested by autoreconf bda0540 Only allow lowercase literals in STRICT mode c51b88d Avoid potential overflow in json_object_get_double 311686f Add a check for the -Bsymbolic-functions linker flag 0645020 Issue #59: change the floating point output format to %.17g so values with more than 6 digits show up in the output. a23caf6 Use sizeof instead of hard coded values when calling snprintf. 51993c2 Added a json_object_new_double_s() convenience function to allow an exact string representation of a double to be specified when creating the object and use it in json_tokener_parse_ex() so a re-serialized object more exactly matches the input. Add json_object_free_userdata() and json_object_userdata_to_json_string() too. b83e0f1 Ignore the test-driver script that is now created, and the script for the test_locale test. 60e4990 The updated test driver creates .log and .trs files; ignore them. 8d18815 strndup is gone, remove it from the README file. b939bd3 Merge pull request #97 from pascal-bach/master ef43fe3 Merge pull request #96 from rouault/remove_strdnup a030120 Merge pull request #95 from rouault/extern_json_object_set_serializer 02aa6f0 Merge pull request #94 from remicollet/issue-strict2 8356ecc Merge pull request #93 from tmielika/master bd42b83 Merge pull request #104 from rouault/fix_json_tokener_error_desc_out_of_bounds_read 86dd55a Fix potential out-of-bounds read in json_tokener_error_desc 4039f91 trailing char not allowed in strict mode 87fa32d no comment in strict mode 20e4708 Update json_util 1a957c2 Remove redefinition of strndup() which is no longer used in the codebase 6c4bb38 Add extern to json_object_set_serializer so that it gets exported (Windows fix) a07ef3d no single-quote string in strict mode c5523a1 fixing problem that isinf(-Inf) can be 1 or -1 b3bce4d Eliminate use of MC_ABORT in json-c code, and mark MC_ABORT/mc_abort deprecated. Also adjust an error message in json_util to make it unique. Fixes #87. be002fb Issue#84: explicitly remove old headers and include/json directory so creating the compat symlink can work. c629656 Fix the _MSC_VER check so it compiles on non-windows compilers. Issue#91 5e8df40 Mention that libtoolize is needed if you're not using a release tarball. d032aad Minor spell check. 8b1bdbb Merge pull request #90 from remicollet/issue-strict 98a62a7 Merge pull request #89 from ayanes/master b6539d6 Merge pull request #88 from weltling/master e9ee4ae in strick mode, number must not start with 0 d086e20 Fixes for Infinity and NaN 990fa8e Fix C89 compat needed by MSVC ed819fb snprintf definition is needed here, too 48ba6b8 fixe int32_t definition for VC11 e48a25c Issue #76: use old style comment to allow json_object_iterator.h to build in ansi mode. e843616 Fill in the instructions for update the gh-pages branch. 4207147 Bump the versions for the non-release branch; add a placeholder section to the change log. 20db5a4 Fill in a number of missing steps in the release process. 7ca1e52 Merge branch 'master' of https://github.com/json-c/json-c 0e81b21 Bump up the version in the release checklist to 0.11 eee744c Update the changelog with changes since the 0.10 release. f1b6849 Update config.h.in to add the HAVE_SETLOCALE and HAVE_LOCALE_H lines. e8161a1 Issue #15: add a way to set a JSON_TOKENER_STRICT flag to forbid commas at the end of arrays and objects. 889400d Merge pull request #73 from ghazel/master 88bf1c9 one definition of json_object_object_foreach only works on c99 and later 5ec65e4 Merge pull request #71 from WillDignazio/master 32eddd6 Fix broken build by using ADVANCE_CHAR macro return. bb492d4 Rename misnomer POP_CHAR to PEEK_CHAR. While parsing token data, we use the POP_CHAR macro to 'peek' at character data. This behaviour is noted in the comments for the macro, yet the definition is left as 'pop'. Changing to PEEK_CHAR does not imply that the character being observed is removed. b64d5ab Merge pull request #70 from tg--/master 1aa29b6 Issue #68: use -std=gnu99 because some versions of gcc seem to think that -std=c99 also implies -ansi, which causes warnings and build breakage. 36ec47d configure.in: mv AM_CONFIG_HEADER to AC_CONFIG_HEADER 94aeed2 Include the test_locale test in the tests that run. 5b36a43 Merge branch 'remicollet-issue-float' 9b64c05 Mark the "val" variable in json_object_object_foreach as unused so the compiler doesn't complain. Fix warnings in the testReplaceExisting test. bfb3292 Add a runtime check to see if parse_int64 needs to workaround sscanf bugs. If that workaround is not needed parsing is nearly twice as fast. ca8b27d Enable -Werror and fix a number of minor warnings that existed. 92d289f Add a comment briefly describing json_object_object_length() c6b3991 Merge pull request #62 from ghazel/master ebeb6a4 Merge pull request #66 from ichernev/fix-test-parse 78b089b Fixed test_parse for \f cca74c6 add json_object_object_length 3ae296f Merge pull request #60 from ghazel/master 77d0493 rename _errno 85da28c Merge pull request #58 from Abioy/master 7eaa849 escape '\f' in json_escape_str fcc768e Bump the version up to 0.10.99 to make it clear that the master branch is beyond anything on the 0.10 branch. 2943691 Merge branch 'master' of https://github.com/json-c/json-c 1461b49 Add a json_c_version.h header (included from json.h), and several macros and functions for retrieving the json-c version at compile-time and run-time. 56166e2 Merge pull request #51 from remicollet/issue-dyndepth d7de3aa Update the release checklist to include the INSTALL file, and adjust the git command to add the doc directory. 2e9fef3 Revert the test_null test back to emitted to stdout, and update the expected output to match. 86aedc2 Merge pull request #56 from TheCount/develop 18abf6e More warnings, fewer errors, C99 024d86c Prepend DESTDIR to paths for staged installs 57f36ed Write additional test info to stderr instead of stdout so as not to mar the expected output 827a4a9 Fixed memory leak in testReplaceExisting beb12d4 Make macro json_object_object_foreach multiple-use safe 20ef1bd Remove and ignore autogenerated installation instructions 8f58f09 Ignore editor swap files 54d551c Ignore doc dir for now b1d61d1 Library is now called libjson-c a3a0f5b Need to explicitly remove include/json-c directory b670f6f -d test is useless as symlinks are dereferenced e176965 Ignore valgrind output files 32d149c probably worth an option for this 8c84796 Save space, drop unuseful trailing zeroes 4014fe8 Simple fix to double encode a01b659 move locale change to be global for perf 4e4af93 Fix issue #53 - ensure explicit length string are still NUL terminated, and fix json_tokener_parse() to work properly with embedded unicode \u0000 values in strings. Adjust test_null to check for this case. See also http://bugs.debian.org/687269 7a4506d Remove configure as part of maintainer-clean instead of distclean. Addresses issue #48. 7653d49 Add PACKAGE_URL to config.h.in aec8763 Add a missing json_object_get() so we don't try to use a freed object in test1. 447b88a Fix a memory leak in the test_printbuf test. 23461c7 Include json_object_iterator.c in the list of sources. 16a4a32 float parsing must be locale independent 197cb1d Make maximum recursion depth a runtime option f6b27cb Make it safe to delete keys while iterating with the json_object_object_foreach macro. 5abc0ea Reformat the json_object_object_foreach macro so it is readable, and document what is allowed to be done with the object while iterating. e36e562 Reformat json_object_object_get() and json_object_object_get_ex(). 5450bed Fix json_object_object_get() so it returns NULL if the incoming json_object is NULL. 5f4739e Change json_object_put to return 1 if the object passed was actually freed. (or 0 if only the reference count was decremented) c3d1d59 Fix a memory leak in test1 with respect to how json_object_object_del was used. c3068bf Reformat the test sources. No functional change. d1f237e Fix the home page in the README, and add a list of prerequisites. 059e8f4 Merge pull request #44 from lastquestion/fix_gnu_macosx e7e0600 Add an autoconf test to test whether the .section .gnu<warning> works with the linker on the system, and define _warn_references to nothing if not. 4b1a066 Update the set_serializer test to match the actual output. 38f421a Add a json_set_serializer() function to allow the string output of a json_object to be customized. f74e8f8 Add my copyright. d305cae Ignore the tests/testReplaceExisting binary. 8ce53f9 Note the rename in the ChangeLog, and update the instructions in the README file. 2f2180b Take a guess as to the rename changes changes needed to the Android part of the build. I think this should work, but I can't test it. 1f9d199 Re-add the "json" pkg-config file as a compatibility shim. Also rename the json-c-uninstalled.pc file. 9f16e25 Bump the version of the new library since programs will need to be re-linked to use it. 943b7a4 Add a compatibility symlink json->json-c in the include directory. 075b783 Add a --disable-oldname-compat option to configure to turn off the creation of the libjson.so library, and only include libjson-c.so c7a2120 Ignore a couple more generated files. 082419e Fix the Libs line in json-uninstalled.pc to use -ljson-c b98aa6e Create an additional libjson.so library that simply links against libjson-c, but emits a warning encouraging the use of the new library. eb37094 Check for the sys/cdefs.h header which on some systems defines the __warn_references macro. ba1c381 Remove test_parse from the top level directory. (accidentally re-introduced with the last merge) c2d3ccf Merge branch 'rename_library' of https://github.com/kdopen/json-c into kdopen-rename_library 92f31bd Handle the \f escape sequence (the two characters: backslash followed by an f, not a literal formfeed) and extend the test_parse test to check all valid escape sequences. 8fcfeb6 Default autogen.sh to not running configure, unless some command line options are specified. 77c6239 Initialize errno before calling sscanf in json_parse_int64() so parsing valid numbers after parsing an out of range number works. 2da148d Merge pull request #37 from cgwalters/master 6988f53 Rewrite json_object_object_add to replace just the value if the key already exists so keys remain valid. This is particularly useful when replacing values in a loop, since it allows the key used by json_object_object_foreach to continue to be used. 6d94377 autogen.sh: Add /bin/sh interpreter, honor NOCONFIGURE=1 381f77c Merge pull request #26 from ford-prefect/master 4154c55 Add json_object_iterator.h to installed headers. 9791c38 Fix git commands for tagging a release. eead1a7 Remove unnecessary comment from json_util.c 7bd49df Merge pull request #33 from mloskot/master 984303d Added a bunch of missing HAVE_* defines tested with ./configure script to fix compilation on Linux with GCC 4.7.1. The issue likely caused by my previous commits related to Visual C++ port of the code. a789601 Merge pull request #27 from OBI-1/master c58386f Merge pull request #29 from mloskot/msvc-port 837d685 Use "nodoc", not "doc", for the name of the tarball w/o docs. 271c53e Missing explicit casts from void* to specific pointers required. Added #define strcasecmp for Visual C++. a6f39a3 Replaced #if HAVE_X with #ifdef HAVE_X as the former test is troublemaker with #define HAVE_X where #define HAVE_X 1|0 is meant. b6ff1c2 array_list_expand_internal needs length, not index. (The current implementation will fail when adding index 65.) 1abaaee Update the ChangeLog with the rest of the changes that will be included in the 0.10 release. e7bd2e9 Fill in the missing pieces of the release checklist. 0cc1db6 Change the format used for sprintbuf (but not scanf) to use %f instead of %lf because the "l" is unnecessary and some compilers behave differently with it present (e.g. MinGW). Thanks for Mateusz Loskot for the fix. 31faa49 Ignore the new test1Formatted and test2Formatted executables. 4c7f38e Extend test1 and test2 to run using json_object_to_json_string_ext() based on an additional command line parameter. Extend the run_output_test() function so we actually can pass command line parameters and so we can support different output files for the same test executable. Also provide some hints about what to do if a test fails (i.e. set VERBOSE=1). 3fcffe1 Add a json_object_to_json_string_ext() function to allow the formatting of output to be selected. There are now three options: JSON_C_TO_STRING_SPACED, JSON_C_TO_STRING_PLAIN and JSON_C_TO_STRING_PRETTY. This also add a json_object_to_file_ext() that takes the same flags. Existing output of json_object_to_json_string() is unchanged, and uses JSON_C_TO_STRING_SPACED. Thanks fo Grant Edwards for the initial patches. a1221eb Add an Android-friendly build system 17caddc Run configure in the autogen.sh script cb29a77 Add a pkgconfig file for uninstalled builds f931f61 Fixed parsing numbers in E notation. ` 4e000a6 Since we already use a local json_bool type, replace any stdbool.h usage with that, since not all environments actually have a stdbool.h to use. 0f8c534 Merge pull request #25 from kdopen/doc_cleanup ded667a Clean up documentation and correct sample code ec7ce26 Merge pull request #23 from mloskot/mloskot-msvc-fixes 8409dc0 Fix missing inttypes.h definitions for Visual Studio 2010 and earliers. Related to issue #22. 178a4b0 Merge pull request #21 from kdopen/add_iterator 7502b37 Merge branch 'master' of https://github.com/json-c/json-c 3d88179 Actually save the expected output for the test_printbuf test so it passes. 37cfe6b Update the list of files to ignore. e5c1e87 Add a test for the printbuf functions. b80772a Use a different variable when referring to the json.la file, since the original lib_LTLIBRARIES means something special to automake. c1b8891 Move the rest of the tests into the tests subdirectory. 1e89ba6 Create a tests subdirectory and move one of the test to there. 020ed64 Merge pull request #20 from kdopen/master bcfd1f5 Add alternative iterator implementation 6917586 Add NULL-safe get object method 4a2cd96 Add NULL-safe lookup function 74d830d Add JASSERT macro to guarantee aborts ca519fb Added explanatory notes to documentation. 65f649b Ignoring additional build products 30dd367 Modify install names for library and include files 21d3706 Added explanatory notes to documentation. e0fa94b Fix some bugs with how buffer sizes were being calcuated in printbuf_memset and an off-by-one error in printbuf_memappend. 7f3298d Remove the "#undef PRINTBUF_DEBUG" from printbuf.h so it can be more easily turned on in the Makefile. 8310d36 Add a printbuf_memset() function to provide an effecient way to set and append things like whitespace indentation. 0d79b53 Fix some bugs with how buffer sizes were being calcuated in printbuf_memset and an off-by-one error in printbuf_memappend. 61a154e Remove the "#undef PRINTBUF_DEBUG" from printbuf.h so it can be more easily turned on in the Makefile. 2d48543 Add a printbuf_memset() function to provide an effecient way to set and append things like whitespace indentation. 2b5929b Direct people to send bug reports to the json-c google group. a7bd85c Remove a few more things in the distclean target to get rid of *all* generated files. f30a9ac Fix a bug in json_tokener_parse_ex when re-using the same tokener to parse multiple objects. Now, json_tokener_reset() does not need to be called after a valid object is parsed. 30c6c4a Split the json_tokener_parse tests off from test1 into their own test and add several more cases to check various incremental parsing situations. bb7978c For the prototype for json_tokener_error_desc(). 23d0da5 Mention json_type_to_name() in the docs for json_object_get_type(). 7c4a964 Define a LH_LOAD_FACTOR constant and note the range that it can be set to. Change the resize check from "count > size" to "count >= size" to avoid a potential infinite loop with high load factors and a full hash table. e6668b1 Adjust json_object_is_type and json_object_get_type so they return json_type_null for NULL objects. d7db7e8 Ignore several more files, include .o's, .lo's, etc... 9885b30 Perform better error checking in json_tokener_parse_verbose and rewrite json_tokener_parse to use that instead of json_tokener_parse_ex. Fix a typo in the string represenations of the json_tokener_error_depth error (s/to deep/too deep/) 781798c Direct people to send bug reports to the json-c google group. fbd207b Remove a few more things in the distclean target to get rid of *all* generated files. d809fa6 Fix a bug in json_tokener_parse_ex when re-using the same tokener to parse multiple objects. Now, json_tokener_reset() does not need to be called after a valid object is parsed. c5c623a Split the json_tokener_parse tests off from test1 into their own test and add several more cases to check various incremental parsing situations. 1489b08 For the prototype for json_tokener_error_desc(). 6ff0817 Mention json_type_to_name() in the docs for json_object_get_type(). 64c0ca3 Define a LH_LOAD_FACTOR constant and note the range that it can be set to. Change the resize check from "count > size" to "count >= size" to avoid a potential infinite loop with high load factors and a full hash table. aef439a Adjust json_object_is_type and json_object_get_type so they return json_type_null for NULL objects. 7e57d63 Merge pull request #16 from kdopen/master d3c37b8 Ignore several more files, include .o's, .lo's, etc... 3620cba Perform better error checking in json_tokener_parse_verbose and rewrite json_tokener_parse to use that instead of json_tokener_parse_ex. Fix a typo in the string represenations of the json_tokener_error_depth error (s/to deep/too deep/) 37e7467 Rename boolean type to json_bool 2f9091f Add json_tokener_get_error() and json_tokener_error_desc() to better encapsulate the process of retrieving errors while parsing. Add documentation for the json_tokener_parse_ex() function. b21b137 Include json_inttypes.h in json_object.h since we use types like int32_t in the API and some systems need that header to compile. As part of this create a public json_config.h with a custom define to decide whether to include inttypes.h to avoid conflicting with other projects config.h header. 15db937 Merge branch 'master' of https://github.com/json-c/json-c 44f0f62 Issue#10: add some const qualifiers so test1 compiles again. 0bc84fc Merge pull request #12 from jameinel/win32-project 6a231e4 Some updates to make the code compatible with VC 9 (2008) faa5353 Merge pull request #11 from deweerdt/master db05090 json_tokener_parse(): avoid possible NULL deref 393085a Merge pull request #7 from federicoculloca/master fc3d211 Merge pull request #8 from mstorsjo/mingw a577ba3 Add -no-undefined to the libtool flags 7ec34c9 Added capitalized charaters to json_hex_chars fbae8ad Merge pull request #4 from deweerdt/master c43871c Add new json_object_array_sort function a8ffbe9 Add an initial (incomplete) release checklist. 06e52ab Add Jehiah and myself to the list of authors. e6c76da Update README files with pointers to new github repo and googlegroups mailing list 276123e handle NULL passed to json_objct_object_get 43d2f41 move definition of json_object_iter to public header to enable external use of json_object_object_foreachC 1910225 Set the svn:executable property so running the test_null test works properly. a37ddcf Note the json-c home page in the README file. 20707f4 Note a few recent changes in the ChangeLog. 7a593a0 Bump up the libtool library version to "1:0:1" (aka libjson.0.1.0) since the API has been extended, but is still backwards compatible.. 0354e19 Bump the version to 0.10, since that's what we were at. 41e67d0 Add a test_cast test case. This checks that the casting that is implied when calling the various json_object_get_FOO() functions on a differently typed object works correctly. 886c4fb Add a json_type_to_name() function which returns a string that describes the type. Useful for logging. e2e1601 Fix a bug in json_object_get_int() where calling it on a string type object would always return 0, instead of the actual numerical value of the string. d1342d6 Add a dummy "NEWS" file to automake doesn't complain. c096f5a readme updates ac601b5 update json_object_new_string_len, json_escape_str (internal). Writer handles \x00 correctly a503ee8 add json_tokener_parse_verbose, and return NULL on parser errors 5644272 set svn:ignore and .gitignore to skip intermediate build files 252669c Simplify things by storing integer values only as int64_t's internally, and omit the range check during parsing since we already have the checks when accessing the value. There is no longer a json_type_int64, only json_type_int. Fix some problems with parsing 0 and -0 values, and add a couple of tests. Fix some minor compile issues on HPUX environments. f1ae67d * Fix file descriptor leak if memory allocation fails in json_util Zachary Blair, zack_blair at hotmail dot com bd0a567 * Fix file descriptor leak if memory allocation fails in json_util Zachary Blair, zack_blair at hotmail dot com d34701e Update executable properties c4dceae * Add int64 support. Two new functions json_object_net_int64 and json_object_get_int64. Binary compatibility preserved. Eric Haszlakiewicz, EHASZLA at transunion com Rui Miguel Silva Seabra, rms at 1407 dot org 88ded9c * Make json_object_from_file take const char *filename Spotted by Vikram Raj V, vsagar at attinteractive dot com f5dd43a * Fix subtle bug in linkhash where lookup could hang after all slots were filled then successively freed. Spotted by Jean-Marc Naud, j dash m at newtraxtech dot com 126ad95 * Add handling of surrogate pairs f8663fc * Correct comment describing printbuf_memappend in printbuf.h 5165885 Add json-c.vcproj to EXTRA_DIST 50626cd Add mailing lists to README.html 09abeff Add note about autoconf README changes to ChangeLog db92cc0 Add README.html, README-WIN32.html and config.h.win32 to EXTRA_DIST in Makefile.am 1363df0 Update version to 0.9 b22565d Update changelog c80ba8d typo fix 7fb9b03 * Rename min and max so we can never clash with C or C++ std library Ian Atha, thatha at yahoo-inc dot com b1a22ac Add const qualifier to the json_tokener_parse functions Eric Haszlakiewicz, EHASZLA at transunion dot com 543bb14 Erik Hovland (3): Fix any noticeable spelling or grammar errors. Make sure every va_start has a va_end. Check all pointers for validity. c5cbf82 Disable REFCOUNT_DEBUG by default in json_object.c ffa742a Ooops. remove literal ^M (copy and paste problem) 9bc863e Change note about CVS repository to point to subversion repos 24ea8c0 update changelog for json_object_get_boolean fix 6f70e44 Fix json_object_get_boolean to return false for empty string Spotted by Vitaly Kruglikov, Vitaly dot Kruglikov at palm dot com 95f55a7 optimizations to json_tokener_parse_ex(), printbuf_memappend() -- Brent Miller, bdmiller at yahoo dash inc dot com aaec1ef * Don't use this as a variable, so we can compile with a C++ compiler * Add casts from void* to type of assignment when using malloc * Add #ifdef __cplusplus guards to all of the headers * Add typedefs for json_object, json_tokener, array_list, printbuf, lh_table Michael Clark, <michael@metaparadigm.com> 266a3fd * Don't use this as a variable, so we can compile with a C++ compiler Michael Clark, <michael@metaparadigm.com> 22dee7c * Null pointer dereference fix. Fix json_object_get_boolean strlen test to not return TRUE for zero length string. Remove redundant includes. Erik Hovland, erik at hovland dot org e8de078 * Fixed warning reported by adding -Wstrict-prototypes -Wold-style-definition to the compilatin flags. Dotan Barak, dotanba at gmail dot com 75d0f12 fix typo e6548a3 fix typo in json_object.h 68cafad Add const correctness to public interfaces Gerard Krol, g dot c dot krol at student dot tudelft dot nl 436aa98 update auto generated files 4b831c3 Update version to 0.8 80a6007 changes to make 'make dist' work properly 8cdac64 Add va_end for every va_start. Dotan Barak, dotanba at gmail dot com a0d35c7 change version to 0.8 a327254 fix to allow compile with -Werror -- Geoffrey Young, geoff at modperlcookbook dot org 14862b1 Patch allows for json-c compile with -Werror and not fail due to -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations Geoffrey Young, geoff at modperlcookbook dot org c8f4a6e * Fix bug with use of capital E in numbers with exponents Mateusz Loskot, mateusz at loskot dot net * Add stddef.h include dfaf670 * Add macros to enable compiling out debug code Geoffrey Young, geoff at modperlcookbook dot org ecf2c9b Update version number to 0.7 a850f8e * Add escaping of backslash to json output * Add escaping of foward slash on tokenizing and output * Changes to internal tokenizer from using recursion to using a depth state structure to allow incremental parsing 837240f * Fix bug in escaping of control characters Johan Bj�rklund, johbjo09 at kth dot se * Remove include "config.h" from headers (should only be included from .c files) Michael Clark <michael@metaparadigm.com> f6a6e48 * Make headers C++ compatible by change *this to *obj * Add ifdef C++ extern "C" to headers * Use simpler definition of min and max in bits.h Larry Lansing, llansing at fuzzynerd dot com 0370baa * Fix additional error case in object parsing * Add back sign reversal in nested object parse as error pointer value is negative, while error value is positive. Michael Clark <michael@metaparadigm.com> 7b899b6 * fix pointer arithmetic bug for error pointer check in is_error() macro * fix type passed to printbuf_memappend in json_tokener * update autotools bootstrap instructions in README Michael Clark <michael@metaparadigm.com> 4504df7 * printbuf.c - C. Watford (christopher dot watford at gmail dot com) Added a Win32/Win64 compliant implementation of vasprintf * debug.c - C. Watford (christopher dot watford at gmail dot com) Removed usage of vsyslog on Win32/Win64 systems, needs to be handled by a configure script * json_object.c - C. Watford (christopher dot watford at gmail dot com) Added scope operator to wrap usage of json_object_object_foreach, this needs to be rethought to be more ANSI C friendly * json_object.h - C. Watford (christopher dot watford at gmail dot com) Added Microsoft C friendly version of json_object_object_foreach * json_tokener.c - C. Watford (christopher dot watford at gmail dot com) Added a Win32/Win64 compliant implementation of strndup * json_util.c - C. Watford (christopher dot watford at gmail dot com) Added cast and mask to suffice size_t v. unsigned int conversion correctness * json_tokener.c - sign reversal issue on error info for nested object parse spotted by Johan Bj�rklund (johbjo09 at kth.se) * json_object.c - escape " in json_escape_str * Change to automake and libtool to build shared and static library Michael Clark <michael@metaparadigm.com> f0d0888 import of version 0.1 6d59966 create new svn project Bug: 33156943 Change-Id: I1f5615a1cdf600641fcfb43ddb70ae369c206e0a
238 lines
4.3 KiB
C
238 lines
4.3 KiB
C
/*
|
|
* random_seed.c
|
|
*
|
|
* Copyright (c) 2013 Metaparadigm Pte. Ltd.
|
|
* Michael Clark <michael@metaparadigm.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See COPYING for details.
|
|
*
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include "config.h"
|
|
|
|
#define DEBUG_SEED(s)
|
|
|
|
|
|
#if defined ENABLE_RDRAND
|
|
|
|
/* cpuid */
|
|
|
|
#if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
|
|
#define HAS_X86_CPUID 1
|
|
|
|
static void do_cpuid(int regs[], int h)
|
|
{
|
|
__asm__ __volatile__(
|
|
#if defined __x86_64__
|
|
"pushq %%rbx;\n"
|
|
#else
|
|
"pushl %%ebx;\n"
|
|
#endif
|
|
"cpuid;\n"
|
|
#if defined __x86_64__
|
|
"popq %%rbx;\n"
|
|
#else
|
|
"popl %%ebx;\n"
|
|
#endif
|
|
: "=a"(regs[0]), [ebx] "=r"(regs[1]), "=c"(regs[2]), "=d"(regs[3])
|
|
: "a"(h));
|
|
}
|
|
|
|
#elif defined _MSC_VER
|
|
|
|
#define HAS_X86_CPUID 1
|
|
#define do_cpuid __cpuid
|
|
|
|
#endif
|
|
|
|
/* has_rdrand */
|
|
|
|
#if HAS_X86_CPUID
|
|
|
|
static int has_rdrand()
|
|
{
|
|
// CPUID.01H:ECX.RDRAND[bit 30] == 1
|
|
int regs[4];
|
|
do_cpuid(regs, 1);
|
|
return (regs[2] & (1 << 30)) != 0;
|
|
}
|
|
|
|
#endif
|
|
|
|
/* get_rdrand_seed - GCC x86 and X64 */
|
|
|
|
#if defined __GNUC__ && (defined __i386__ || defined __x86_64__)
|
|
|
|
#define HAVE_RDRAND 1
|
|
|
|
static int get_rdrand_seed()
|
|
{
|
|
DEBUG_SEED("get_rdrand_seed");
|
|
int _eax;
|
|
// rdrand eax
|
|
__asm__ __volatile__("1: .byte 0x0F\n"
|
|
" .byte 0xC7\n"
|
|
" .byte 0xF0\n"
|
|
" jnc 1b;\n"
|
|
: "=a" (_eax));
|
|
return _eax;
|
|
}
|
|
|
|
#endif
|
|
|
|
#if defined _MSC_VER
|
|
|
|
#if _MSC_VER >= 1700
|
|
#define HAVE_RDRAND 1
|
|
|
|
/* get_rdrand_seed - Visual Studio 2012 and above */
|
|
|
|
static int get_rdrand_seed()
|
|
{
|
|
DEBUG_SEED("get_rdrand_seed");
|
|
int r;
|
|
while (_rdrand32_step(&r) == 0);
|
|
return r;
|
|
}
|
|
|
|
#elif defined _M_IX86
|
|
#define HAVE_RDRAND 1
|
|
|
|
/* get_rdrand_seed - Visual Studio 2010 and below - x86 only */
|
|
|
|
static int get_rdrand_seed()
|
|
{
|
|
DEBUG_SEED("get_rdrand_seed");
|
|
int _eax;
|
|
retry:
|
|
// rdrand eax
|
|
__asm _emit 0x0F __asm _emit 0xC7 __asm _emit 0xF0
|
|
__asm jnc retry
|
|
__asm mov _eax, eax
|
|
return _eax;
|
|
}
|
|
|
|
#endif
|
|
#endif
|
|
|
|
#endif /* defined ENABLE_RDRAND */
|
|
|
|
|
|
/* has_dev_urandom */
|
|
|
|
#if defined (__APPLE__) || defined(__unix__) || defined(__linux__)
|
|
|
|
#include <string.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <sys/stat.h>
|
|
|
|
#define HAVE_DEV_RANDOM 1
|
|
|
|
static const char *dev_random_file = "/dev/urandom";
|
|
|
|
static int has_dev_urandom()
|
|
{
|
|
struct stat buf;
|
|
if (stat(dev_random_file, &buf)) {
|
|
return 0;
|
|
}
|
|
return ((buf.st_mode & S_IFCHR) != 0);
|
|
}
|
|
|
|
|
|
/* get_dev_random_seed */
|
|
|
|
static int get_dev_random_seed()
|
|
{
|
|
DEBUG_SEED("get_dev_random_seed");
|
|
|
|
int fd = open(dev_random_file, O_RDONLY);
|
|
if (fd < 0) {
|
|
fprintf(stderr, "error opening %s: %s", dev_random_file, strerror(errno));
|
|
exit(1);
|
|
}
|
|
|
|
int r;
|
|
ssize_t nread = read(fd, &r, sizeof(r));
|
|
if (nread != sizeof(r)) {
|
|
fprintf(stderr, "error short read %s: %s", dev_random_file, strerror(errno));
|
|
exit(1);
|
|
}
|
|
|
|
close(fd);
|
|
return r;
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
/* get_cryptgenrandom_seed */
|
|
|
|
#ifdef WIN32
|
|
|
|
#define HAVE_CRYPTGENRANDOM 1
|
|
|
|
#include <windows.h>
|
|
#include <wincrypt.h>
|
|
#ifndef __GNUC__
|
|
#pragma comment(lib, "advapi32.lib")
|
|
#endif
|
|
|
|
static int get_cryptgenrandom_seed()
|
|
{
|
|
DEBUG_SEED("get_cryptgenrandom_seed");
|
|
|
|
HCRYPTPROV hProvider = 0;
|
|
int r;
|
|
|
|
if (!CryptAcquireContextW(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
|
|
fprintf(stderr, "error CryptAcquireContextW");
|
|
exit(1);
|
|
}
|
|
|
|
if (!CryptGenRandom(hProvider, sizeof(r), (BYTE*)&r)) {
|
|
fprintf(stderr, "error CryptGenRandom");
|
|
exit(1);
|
|
}
|
|
|
|
CryptReleaseContext(hProvider, 0);
|
|
|
|
return r;
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
/* get_time_seed */
|
|
|
|
#include <time.h>
|
|
|
|
static int get_time_seed()
|
|
{
|
|
DEBUG_SEED("get_time_seed");
|
|
|
|
return (int)time(NULL) * 433494437;
|
|
}
|
|
|
|
|
|
/* json_c_get_random_seed */
|
|
|
|
int json_c_get_random_seed()
|
|
{
|
|
#if HAVE_RDRAND
|
|
if (has_rdrand()) return get_rdrand_seed();
|
|
#endif
|
|
#if HAVE_DEV_RANDOM
|
|
if (has_dev_urandom()) return get_dev_random_seed();
|
|
#endif
|
|
#if HAVE_CRYPTGENRANDOM
|
|
return get_cryptgenrandom_seed();
|
|
#endif
|
|
return get_time_seed();
|
|
}
|