91 Commits
v2.6 ... v2.7

Author SHA1 Message Date
Petri Lehtinen
ee27b7e3dd jansson 2.7 2014-10-02 13:10:45 +03:00
Petri Lehtinen
391d9101a8 Update CHANGES for 2.7 2014-10-02 08:57:07 +03:00
Petri Lehtinen
2137e0c895 Add AppVeyor badge to README.rst 2014-09-25 07:51:55 +03:00
Petri Lehtinen
5fc44e10aa Merge pull request #205 from JoakimSoderberg/appveyor
Added Windows CI support with appveyor
2014-09-25 07:45:24 +03:00
Joakim Soderberg
b94d767f86 Added Windows CI support with appveyor
Added support for http://www.appveyor.com/ (login via github account).

This will build the project and run the unit tests on Windows as well.
Possible to add a badge like with Travis in the README.md as well.
2014-09-24 18:08:45 +02:00
Petri Lehtinen
43f17d010a Merge pull request #204 from bgoglin/master
Don't use GNU-make specific export for global AM_CFLAGS
2014-08-27 08:02:59 +03:00
Petri Lehtinen
fa20e80860 Parse subnormal numbers correctly
Fixes #202.
2014-08-27 07:59:52 +03:00
Brice Goglin
485c7640a1 Don't use GNU-make specific export for global AM_CFLAGS
Just define it at configure time, it's automatically set in all makefiles.

Fixes #203.
2014-08-26 15:01:13 +02:00
Petri Lehtinen
d4a7de7c11 Android.mk: Add -DHAVE_STDINT_H to LOCAL_CFLAGS
See #200.
2014-07-31 07:50:31 +03:00
Petri Lehtinen
a6229a2d3e doc: Enhance string overview 2014-07-21 08:15:34 +03:00
Petri Lehtinen
abd151f5d7 Merge pull request #198 from Smilex/mem_fix
Fixed cases where file would be opened, but not closed.
2014-07-21 08:09:18 +03:00
Ian T. Jacobsen
4f1238af71 Fix whitespace issues 2014-07-16 00:21:16 +01:00
Ian T. Jacobsen
122a1e2af9 Fixed cases where file would be opened, but not closed. And small realloc memory issue. 2014-07-16 00:16:32 +01:00
Petri Lehtinen
c8d017bd88 Merge branch '2.6' 2014-07-12 06:43:07 +03:00
Petri Lehtinen
23b1b7ba9a Document JANSSON_BUILD_SHARED_LIBS CMake option
Fixes #187.
2014-07-12 06:42:36 +03:00
Petri Lehtinen
88943b64e3 Define JSON_MAX_INDENT
Fixes #191.
2014-07-07 11:34:50 +03:00
Petri Lehtinen
348401e7b8 CMake: Use add_definitions for compiler flags
Fixes #193.
2014-07-02 22:04:34 +03:00
Petri Lehtinen
df248712a5 Include android config in tarballs
Issue #166.
2014-06-28 22:41:48 +03:00
Petri Lehtinen
de1b5db70e Fix autoreconf on Debian
For some reason, Automake doesn't search the current directory correctly
when searching for helper scripts.

Fixes #182.
2014-05-14 16:03:22 +03:00
Petri Lehtinen
4debe8e567 Add missing tests for JSON_REAL_PRECISION 2014-05-07 08:19:39 +03:00
Petri Lehtinen
28d362cf28 Merge pull request #180 from Sannis/master
Enable usage of AddressSanitizer to check Jansson
2014-05-05 14:45:09 +03:00
Oleg Efimov
541cdf5960 Remove unneeded undef 2014-05-05 15:40:41 +04:00
Oleg Efimov
fc6e314498 Enable usage of AddressSanitizer to check Jansson 2014-05-04 00:34:08 +04:00
Petri Lehtinen
17b5fdd94b Add JSON_REAL_PRECISION
Fixes #178.
2014-04-30 12:46:34 +03:00
Petri Lehtinen
5b88cc5ded Merge branch '2.6' 2014-04-30 12:06:03 +03:00
Petri Lehtinen
db285b3764 Check uint16_t and uint8_t support correctly
Fixes #177.
2014-04-30 12:05:51 +03:00
Petri Lehtinen
a425f8c650 Rename variables to work aroung a GCC bug on Solaris
Fixes #175.
2014-04-23 12:17:14 +03:00
Petri Lehtinen
96f8916e50 Merge pull request #174 from KimJeongYeon/master
fix build error for android
2014-04-14 08:32:47 +03:00
KimJeongYeon
dd2bf2971e fix build error for android 2014-04-11 23:14:34 +09:00
Petri Lehtinen
34a64cfe53 Merge pull request #171 from firepick1/master
Solaris build fix
2014-04-08 20:39:46 +03:00
Karl Lew
571617ebfc use __sun instead of sun 2014-04-08 15:57:58 +00:00
Karl Lew
3bd8a5729d Merge remote-tracking branch 'refs/remotes/origin/master' 2014-04-06 04:31:34 +00:00
Karl Lew
33e4988180 SmartOS build fix 2014-04-06 04:28:52 +00:00
firepick1
663fbfb7a4 SmartOS (Solaris) build 2014-04-04 17:28:08 -07:00
Petri Lehtinen
88aa6a9e30 Remove VS2010 project files, CMake should be used on Windows instead
Fixes #165.
2014-03-04 08:28:52 +02:00
Petri Lehtinen
92e2588d6e Merge branch '2.6' 2014-02-16 22:22:14 +02:00
Petri Lehtinen
960ead07f2 Merge pull request #164 from vincentbernat/fix/gitignore
Add new autotools-generated files to .gitignore
2014-02-16 22:20:25 +02:00
Petri Lehtinen
78da1de021 Merge pull request #163 from vincentbernat/fix/unpack-mix-optional-and-strict
Fix unpack when mixing strict mode and optional keys
2014-02-16 22:20:02 +02:00
Petri Lehtinen
946531bd7b Merge pull request #162 from nmlgc/master
Three fixes for hashtable seeding on Windows
2014-02-16 22:19:37 +02:00
Petri Lehtinen
10009d61a7 Merge pull request #164 from vincentbernat/fix/gitignore
Add new autotools-generated files to .gitignore
2014-02-16 22:10:16 +02:00
Petri Lehtinen
49fc6b1194 Merge pull request #163 from vincentbernat/fix/unpack-mix-optional-and-strict
Fix unpack when mixing strict mode and optional keys
2014-02-16 22:09:41 +02:00
Petri Lehtinen
6e8b2e161a Merge pull request #162 from nmlgc/master
Three fixes for hashtable seeding on Windows
2014-02-16 22:09:09 +02:00
Vincent Bernat
3922f84a2f Add new autotools-generated files to .gitignore
Additionally, `/jansson_private_config.h.in` is also added as well as
"build" directory for those of us who like to use an out-of-tree build
system.
2014-02-15 17:47:48 +01:00
Vincent Bernat
56a50e147d Micro-optimization for JSON_STRICT when no optional key is used
The previous commit introduced a loop on all input keys to check the
strict mode. We can avoid this if we don't expect an optional key. In
this case, we fallback to the previous method to compare the length of
the set of expected keys and the length of the parsed keys.
2014-02-15 17:44:02 +01:00
Vincent Bernat
7a0b9af662 Allow to mix JSON_STRICT with optional keys
On unpack, one may want to mix `JSON_STRICT` and optional keys by using
a format like `{s:i,s?o!}`. Unfortunately, this fails the stric test
with `-1 object item(s) left unpacked` error when the second key is not
specified.

To fix that, we iter on each key and we check if we have successfully
unpacked them. This is less efficient than the previous method but it
brings correctness.
2014-02-15 17:40:22 +01:00
nmlgc
4fbe44605b Three fixes for hashtable seeding on Windows
First, wrap "advapi32.dll" into the TEXT() macro. If UNICODE is defined,
GetModuleHandle() redirects to GetModuleHandleW(), which excepts a wchar_t*
UTF-16 parameter, thus causing a compile error. TEXT() prefixes the string
literal with L in this case, and does nothing otherwise.

Second, make sure that CryptGenRandom() is actually called through the function
pointer retrieved by the call to GetProcAddress() above.

And third, replace _getpid() with the equivalent and more ubiquitous Win32 API
function GetCurrentProcessId(). Since _getpid() is not exported by all C
runtimes on Windows (most notably the Driver Development Kit), using it might
introduce previously unneeded runtime dependencies. GetCurrentProcessId(), on
the other hand, has been available in kernel32.dll since at least Windows 95,
just like the other API functions used in this code (GetModuleHandle() and
GetProcAddress()).
2014-02-15 17:11:11 +01:00
Petri Lehtinen
ea7a77236c Merge branch '2.6' 2014-02-12 08:56:17 +02:00
Petri Lehtinen
4bbb53a25d Make valgrind happy 2014-02-12 08:54:06 +02:00
Petri Lehtinen
569295fe30 Fix feature checks to use correct __ATOMIC flags 2014-02-12 08:44:29 +02:00
Petri Lehtinen
3f5acaa3fb Merge branch '2.6' 2014-02-11 15:15:00 +02:00
Petri Lehtinen
17ec22f514 Merge branch '2.6' 2014-02-11 14:49:15 +02:00
Petri Lehtinen
a721d36f41 Merge pull request #161 from JoakimSoderberg/cmake_travis
Add CMake build to Travis config.
2014-01-28 06:02:17 -08:00
Petri Lehtinen
eee85cd53c Merge pull request #160 from JoakimSoderberg/cmake_memcheck_fix
Fix so that valgrind checks actually works with CMake.
2014-01-28 06:01:03 -08:00
Joakim Soderberg
7c80778827 Fix so that valgrind checks actually works with CMake.
The valgrind tests where not run on the suites.

And valgrind was always returning 0 so set an explicit exit code on exit. I also had forgotten to change the name of TEST_WITH_VALGRIND to JANSSON_TEST_WITH_VALGRIND so that the tests would never use valgrind.
2014-01-28 13:07:59 +00:00
Joakim Soderberg
4c2cc0e36c Add CMake build to Travis config. 2014-01-28 14:06:43 +01:00
Petri Lehtinen
a630e226ba Merge pull request #159 from JoakimSoderberg/config_fix
Make sure the private config is included.
2014-01-28 01:11:57 -08:00
Joakim Soderberg
0c95a22888 Make sure the private config is included. 2014-01-28 09:59:43 +01:00
Petri Lehtinen
30fdf6067e Update copyrights for 2014 2014-01-28 09:16:05 +02:00
Petri Lehtinen
cffc5df600 Merge pull request #157 from JoakimSoderberg/cmake_config_new
Cmake config
2014-01-27 23:10:55 -08:00
Joakim Soderberg
3fe8f74e7f Renamed config.h -> jansson_private_config.h
This is because it's really easy to get a name collission if compiling
Jansson as a subproject in a larger CMake project. If one project includes
several subprojects each having their own config.h, this will cause the
wrong file to be loaded.
2014-01-27 12:48:52 +01:00
Joakim Soderberg
913937c98d Added CMake config files.
This will simplify linking against the lib, both from the build-tree and
install-tree from other CMake projects.

CMakes find_package command uses these configs to locate the exported
targets for the library.

* Also changed so that all CMake options for the project are prepended
  with JANSSON_ so that there is no ambiguity when including this as a
  subdirectory in another CMake project.
2014-01-24 14:13:02 +01:00
Petri Lehtinen
b21cd65d30 Fix CMake build flags for MinGW 2014-01-16 08:03:05 +02:00
Petri Lehtinen
c89638d73c Merge pull request #151 from nmlgc/master
Check for key == NULL in json_object_get and json_object_del
2013-12-28 02:56:35 -08:00
nmlgc
98610bfcec Check for key == NULL in json_object_get and json_object_del 2013-12-28 06:11:49 +01:00
Petri Lehtinen
9c8b3c833f Merge branch '2.5' 2013-12-27 08:55:52 +02:00
Petri Lehtinen
4e8c4bfbd2 Merge branch '2.5' 2013-12-13 09:27:42 +02:00
Petri Lehtinen
3347679d8f Merge branch '2.5' 2013-12-13 09:22:50 +02:00
Petri Lehtinen
05f7d30e5a Add json_boolean_value as alias for json_is_true
Fixes #146.
2013-12-04 09:14:19 +02:00
Petri Lehtinen
34d8b92dce Merge branch '2.5' 2013-11-14 08:49:24 +02:00
Petri Lehtinen
30a4c88843 Fix an off-by-one error 2013-10-15 08:49:40 +03:00
Petri Lehtinen
08be94e8e6 Don't call strlen twice
Oops.
2013-10-15 08:46:17 +03:00
Petri Lehtinen
d544852ff6 Avoid integer overflows with very long strings 2013-10-15 08:44:04 +03:00
Petri Lehtinen
8dc3233f3b Merge pull request #143 from chipdude/master
paper bag bug: json_string_set* functions should set the length too
2013-10-03 22:36:34 -07:00
Chip Salzenberg
c7d479c740 in simple string tests, always check lengths too 2013-10-03 19:07:50 -07:00
Chip Salzenberg
a76dc45512 paper bag bug: json_string_set* functions should set the length too 2013-10-03 19:07:20 -07:00
Petri Lehtinen
9bb5a266dd Merge pull request #142 from chipdude/master
fix type mismatch anywhere int != int32 (Vorne)
2013-09-30 22:41:25 -07:00
Chip Salzenberg
6ebd0bc7a6 fix type mismatch anywhere int != int32 (Vorne) 2013-09-30 16:56:01 -07:00
Petri Lehtinen
f8d8d524cf Document JSON_ALLOW_NUL and clarify NUL byte handling 2013-09-30 10:55:34 +03:00
Petri Lehtinen
1bfc33362e Add JSON_ALLOW_NUL decoding flag for enabling NUL byte support 2013-09-30 10:45:02 +03:00
Petri Lehtinen
5744468c99 Clarify json_string_length doc 2013-09-30 10:45:02 +03:00
Petri Lehtinen
4d5aead31c Fix NUL byte check for object keys 2013-09-30 10:45:02 +03:00
Petri Lehtinen
78a80b8899 load.c: Change an error message 2013-09-30 09:24:36 +03:00
Petri Lehtinen
b961e8101e Add Chip's changes to release notes 2013-09-30 08:56:39 +03:00
Petri Lehtinen
7876125a22 Document s% and s# for json_pack, s% for json_unpack 2013-09-30 08:47:05 +03:00
Petri Lehtinen
e2dcf94598 Merge pull request #141 from chipdude/nuls
add new public functions to jansson.def
2013-09-29 22:31:15 -07:00
Chip Salzenberg
6c1ce27095 add new public functions to jansson.def 2013-09-29 16:57:23 -07:00
Petri Lehtinen
46e27ae6d5 Merge pull request #140 from chipdude/nuls
Support "\u0000" in strings
2013-09-29 11:57:57 -07:00
Chip Salzenberg
0be5c959da document new null-friendly functions 2013-09-27 19:10:32 -07:00
Chip Salzenberg
face43929d expect "export" in test configs 2013-09-27 17:32:25 -07:00
Chip Salzenberg
dcaa90d21e dump \u sequences as upper case for readability (just like error messages) 2013-09-27 17:32:25 -07:00
Chip Salzenberg
9c259c07aa Support \u0000 - add size_t string lengths to API, load and dump \u000, etc.
Also:
  Steal strings during parsing for half the mallocs!
  Change all input-caused assertions to errors.  No crashes please, we're programmers.
2013-09-27 17:32:06 -07:00
76 changed files with 1060 additions and 580 deletions

5
.gitignore vendored
View File

@@ -19,10 +19,15 @@ install-sh
libtool
ltmain.sh
missing
compile
test-driver
*.lo
*.la
stamp-h1
*.pyc
*.pc
/src/jansson_config.h
/jansson_private_config.h.in
/jansson_private_config.h
/build
*.exe

View File

@@ -1,5 +1,14 @@
env:
matrix:
- JANSSON_BUILD_METHOD=cmake JANSSON_CMAKE_OPTIONS="-DJANSSON_TEST_WITH_VALGRIND=ON" JANSSON_EXTRA_INSTALL="valgrind"
- JANSSON_BUILD_METHOD=autotools
language: c
compiler:
- gcc
- clang
script: autoreconf -f -i && CFLAGS=-Werror ./configure && make check
install:
- sudo apt-get update -qq
- sudo apt-get install -y -qq cmake $JANSSON_EXTRA_INSTALL
script:
- if [ "$JANSSON_BUILD_METHOD" = "autotools" ]; then autoreconf -f -i && CFLAGS=-Werror ./configure && make check; fi
- if [ "$JANSSON_BUILD_METHOD" = "cmake" ]; then mkdir build && cd build && cmake .. $JANSSON_CMAKE_OPTIONS && cmake --build . && ctest --output-on-failure; fi

View File

@@ -7,6 +7,7 @@ LOCAL_SRC_FILES := \
src/dump.c \
src/error.c \
src/hashtable.c \
src/hashtable_seed.c \
src/load.c \
src/memory.c \
src/pack_unpack.c \
@@ -22,7 +23,7 @@ LOCAL_C_INCLUDES += \
LOCAL_MODULE_TAGS := optional
LOCAL_SHARED_LIBRARIES := libc
LOCAL_CFLAGS += -O3
LOCAL_CFLAGS += -O3 -DHAVE_STDINT_H=1
LOCAL_MODULE:= libjansson

96
CHANGES
View File

@@ -1,3 +1,99 @@
Version 2.7
===========
Released 2014-10-02
* New features:
- `json_pack()` and friends: Add format specifiers ``s%`` and ``+%``
for a size_t string length (#141).
- `json_unpack()` and friends: Add format specifier ``s%`` for
unpacking the string length along with the string itself (#141).
- Add length-aware string constructors `json_stringn()` and
`json_stringn_nocheck()`, length-aware string mutators
`json_string_setn()` and `json_string_setn_nocheck()`, and a
function for getting string's length `json_string_length()` (#141,
#143).
- Support ``\u0000`` escapes in the decoder. The support can be
enabled by using the ``JSON_ALLOW_NUL`` decoding flag (#141).
- Add `json_boolean_value()` as an alias for `json_is_true()`
(#146).
- Add JSON_REAL_PRECISION encoding flag/macro for controlling real
number precision (#178).
- Define the maximum indentation as JSON_MAX_INDENT (#191).
* Bug fixes:
- Some malformed ``\uNNNN`` escapes could crash the decoder with an
assertion failure.
- Avoid integer overflows with very long strings in UTF-8 decoder and
hashtable.
- Check for *NULL* key in `json_object_get()` and
`json_object_del()` (#151).
- Enhance hashtable seeding on Windows (#162).
- `json_unpack()`: Allow mixing JSON_STRICT with optional keys
(#162, #163).
- Fix int/int32 mismatch (#142).
- Parse subnormal numbers correctly (#202).
* Build:
- Remove VS2010 build files. CMake should be used on Windows instead
(#165).
- Fix CMake build flags for MinGW (#193).
- Add CMake config files for find_package. Rename config.h to
jansson_private_config.h (#157, #159).
- Make Valgrind checks work with CMake (#160).
- Fix feature checks to use correct __ATOMIC flags.
- Fix CMake checks for uint16_t and uint8_t support (#177).
- Make Jansson build on SmartOS/Solaris (#171).
- Work around a GCC bug on Solaris (#175).
- Fix autoreconf on Debian (#182).
- Don't use GNU make specific export for global AM_CFLAGS (#203,
#204).
- Fix building on Android using the supplied Android.mk (#166,
#174).
- Android.mk: Add -DHAVE_STDINT_H to LOCAL_CFLAGS (#200).
* Documentation:
- Document JANSSON_BUILD_SHARED_LIBS CMake option (#187).
* Tests:
- Close file handles correctly (#198).
* Other changes:
- ``\uNNNN`` escapes are now encoded in upper case for better
readability.
- Enable usage of AddressSanitizer (#180).
Version 2.6
===========

View File

@@ -51,26 +51,26 @@ cmake_minimum_required (VERSION 2.8)
project (jansson C)
# Options
OPTION (BUILD_SHARED_LIBS "Build shared libraries." OFF)
OPTION (USE_URANDOM "Use /dev/urandom to seed the hash function." ON)
OPTION (USE_WINDOWS_CRYPTOAPI "Use CryptGenRandom to seed the hash function." ON)
option(JANSSON_BUILD_SHARED_LIBS "Build shared libraries." OFF)
option(USE_URANDOM "Use /dev/urandom to seed the hash function." ON)
option(USE_WINDOWS_CRYPTOAPI "Use CryptGenRandom to seed the hash function." ON)
if (MSVC)
# This option must match the settings used in your program, in particular if you
# are linking statically
OPTION( STATIC_CRT "Link the static CRT libraries" OFF )
option(JANSSON_STATIC_CRT "Link the static CRT libraries" OFF )
endif ()
# Set some nicer output dirs.
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
# Give the debug version a different postfix for windows,
# so both the debug and release version can be built in the
# same build-tree on Windows (MSVC).
if (WIN32)
SET (CMAKE_DEBUG_POSTFIX "_d")
set(CMAKE_DEBUG_POSTFIX "_d")
else (WIN32)
endif (WIN32)
@@ -78,16 +78,16 @@ endif (WIN32)
# set (JANSSON_VERSION "2.3.1")
# set (JANSSON_SOVERSION 2)
set(JANSSON_DISPLAY_VERSION "2.6")
set(JANSSON_DISPLAY_VERSION "2.7")
# This is what is required to match the same numbers as automake's
set (JANSSON_VERSION "4.6.0")
set (JANSSON_SOVERSION 4)
set(JANSSON_VERSION "4.7.0")
set(JANSSON_SOVERSION 4)
# for CheckFunctionKeywords
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
INCLUDE (CheckCSourceCompiles)
include (CheckCSourceCompiles)
include (CheckFunctionExists)
include (CheckFunctionKeywords)
include (CheckIncludeFiles)
@@ -104,8 +104,8 @@ if (MSVC)
endif()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_C_FLAGS "-fPIC")
if (NOT WIN32 AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX))
add_definitions("-fPIC")
endif()
check_include_files (endian.h HAVE_ENDIAN_H)
@@ -149,10 +149,12 @@ else ()
message (FATAL_ERROR "Could not detect a valid 32-bit integer type")
endif ()
check_type_size (uint32_t UINT32_T)
check_type_size (__uint32 __UINT32)
check_type_size ("unsigned long" UNSIGNED_LONG_INT)
check_type_size ("unsigned int" UNSIGNED_INT)
check_type_size ("unsigned short" UNSIGNED_SHORT)
check_type_size (uint32_t UINT32_T)
check_type_size (__uint32 __UINT32)
if (HAVE_UINT32_T)
set (JSON_UINT32 uint32_t)
elseif (HAVE___UINT32)
@@ -165,6 +167,30 @@ else ()
message (FATAL_ERROR "Could not detect a valid unsigned 32-bit integer type")
endif ()
check_type_size (uint16_t UINT16_T)
check_type_size (__uint16 __UINT16)
if (HAVE_UINT16_T)
set (JSON_UINT16 uint16_t)
elseif (HAVE___UINT16)
set (JSON_UINT16 __uint16)
elseif (HAVE_UNSIGNED_INT AND (${UNSIGNED_INT} EQUAL 2))
set (JSON_UINT16 "unsigned int")
elseif (HAVE_UNSIGNED_SHORT AND (${UNSIGNED_SHORT} EQUAL 2))
set (JSON_UINT16 "unsigned short")
else ()
message (FATAL_ERROR "Could not detect a valid unsigned 16-bit integer type")
endif ()
check_type_size (uint8_t UINT8_T)
check_type_size (__uint8 __UINT8)
if (HAVE_UINT8_T)
set (JSON_UINT8 uint8_t)
elseif (HAVE___UINT8)
set (JSON_UINT8 __uint8)
else ()
set (JSON_UINT8 "unsigned char")
endif ()
# Check for ssize_t and SSIZE_T existance.
check_type_size(ssize_t SSIZE_T)
check_type_size(SSIZE_T UPPERCASE_SSIZE_T)
@@ -232,10 +258,10 @@ if (HAVE_LOCALECONV AND HAVE_LOCALE_H)
set (JSON_HAVE_LOCALECONV 1)
else ()
set (JSON_HAVE_LOCALECONV 0)
endif ()
endif()
# check if we have setlocale
check_function_exists (setlocale HAVE_SETLOCALE)
check_function_exists(setlocale HAVE_SETLOCALE)
# Check what the inline keyword is.
# Note that the original JSON_INLINE was always set to just 'inline', so this goes further.
@@ -244,25 +270,25 @@ check_function_keywords("__inline")
check_function_keywords("__inline__")
if (HAVE_INLINE)
set (JSON_INLINE inline)
set(JSON_INLINE inline)
elseif (HAVE___INLINE)
set (JSON_INLINE __inline)
set(JSON_INLINE __inline)
elseif (HAVE___INLINE__)
set (JSON_INLINE __inline__)
else (HAVE_INLINE)
set(JSON_INLINE __inline__)
else()
# no inline on this platform
set (JSON_INLINE)
endif (HAVE_INLINE)
endif()
# Find our snprintf
check_function_exists (snprintf HAVE_SNPRINTF)
check_function_exists (_snprintf HAVE__SNPRINTF)
if (HAVE_SNPRINTF)
set (JSON_SNPRINTF snprintf)
set(JSON_SNPRINTF snprintf)
elseif (HAVE__SNPRINTF)
set (JSON_SNPRINTF _snprintf)
endif ()
set(JSON_SNPRINTF _snprintf)
endif ()
check_c_source_compiles ("int main() { unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1); return 0; } " HAVE_SYNC_BUILTINS)
check_c_source_compiles ("int main() { char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_RELEASE); __atomic_load_n(&v, __ATOMIC_ACQUIRE); return 0; }" HAVE_ATOMIC_BUILTINS)
@@ -288,59 +314,62 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/)
add_definitions(-DJANSSON_USING_CMAKE)
# configure the private config file
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/private_include/config.h)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_private_config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h)
# and tell the source code to include it
add_definitions (-DHAVE_CONFIG_H)
add_definitions(-DHAVE_CONFIG_H)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/private_include)
# Add the lib sources.
file (GLOB C_FILES src/*.c)
file(GLOB JANSSON_SRC src/*.c)
if (BUILD_SHARED_LIBS)
set(JANSSON_HDR_PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/hashtable.h
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson_private.h
${CMAKE_CURRENT_SOURCE_DIR}/src/strbuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/src/utf.h
${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h)
add_library (jansson SHARED ${C_FILES} src/jansson.def)
set(JANSSON_HDR_PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h)
set_target_properties (jansson PROPERTIES
source_group("Library Sources" FILES ${JANSSON_SRC})
source_group("Library Private Headers" FILES ${JANSSON_HDR_PRIVATE})
source_group("Library Public Headers" FILES ${JANSSON_HDR_PUBLIC})
if(JANSSON_BUILD_SHARED_LIBS)
add_library(jansson SHARED
${JANSSON_SRC}
${JANSSON_HDR_PRIVATE}
${JANSSON_HDR_PUBLIC}
src/jansson.def)
set_target_properties(jansson PROPERTIES
VERSION ${JANSSON_VERSION}
SOVERSION ${JANSSON_SOVERSION})
else()
add_library(jansson
${JANSSON_SRC}
${JANSSON_HDR_PRIVATE}
${JANSSON_HDR_PUBLIC})
endif()
else ()
add_library (jansson ${C_FILES})
endif ()
# LIBRARY for linux
# RUNTIME for windows (when building shared)
install (TARGETS jansson
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION bin
)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
DESTINATION include)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/jansson.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
# For building Documentation (uses Sphinx)
OPTION (BUILD_DOCS "Build documentation (uses python-sphinx)." ON)
if (BUILD_DOCS)
option(JANSSON_BUILD_DOCS "Build documentation (uses python-sphinx)." ON)
if (JANSSON_BUILD_DOCS)
find_package(Sphinx)
if (NOT SPHINX_FOUND)
message(WARNING "Sphinx not found. Cannot generate documentation!
Set -DBUILD_DOCS=0 to get rid of this message.")
Set -DJANSSON_BUILD_DOCS=OFF to get rid of this message.")
else()
if (Sphinx_VERSION_STRING VERSION_LESS 1.0)
message(WARNING "Your Sphinx version is too old!
@@ -375,9 +404,9 @@ if (BUILD_DOCS)
# Add documentation targets.
set(DOC_TARGETS html)
OPTION(BUILD_MAN "Create a target for building man pages." ON)
option(JANSSON_BUILD_MAN "Create a target for building man pages." ON)
if (BUILD_MAN)
if (JANSSON_BUILD_MAN)
if (Sphinx_VERSION_STRING VERSION_LESS 1.0)
message(WARNING "Sphinx version 1.0 > is required to build man pages. You have v${Sphinx_VERSION_STRING}.")
else()
@@ -385,9 +414,9 @@ if (BUILD_DOCS)
endif()
endif()
OPTION(BUILD_LATEX "Create a target for building latex docs (to create PDF)." OFF)
option(JANSSON_BUILD_LATEX "Create a target for building latex docs (to create PDF)." OFF)
if (BUILD_LATEX)
if (JANSSON_BUILD_LATEX)
find_package(LATEX)
if (NOT LATEX_COMPILER)
@@ -420,14 +449,14 @@ if (BUILD_DOCS)
endif ()
OPTION (WITHOUT_TESTS "Don't build tests ('make test' to execute tests)" OFF)
option(JANSSON_WITHOUT_TESTS "Don't build tests ('make test' to execute tests)" OFF)
if (NOT WITHOUT_TESTS)
OPTION (TEST_WITH_VALGRIND "Enable valgrind tests." OFF)
if (NOT JANSSON_WITHOUT_TESTS)
option(JANSSON_TEST_WITH_VALGRIND "Enable valgrind tests." OFF)
ENABLE_TESTING()
if (TEST_WITH_VALGRIND)
if (JANSSON_TEST_WITH_VALGRIND)
# TODO: Add FindValgrind.cmake instead of having a hardcoded path.
add_definitions(-DVALGRIND)
@@ -435,7 +464,7 @@ if (NOT WITHOUT_TESTS)
# enable valgrind
set(CMAKE_MEMORYCHECK_COMMAND valgrind)
set(CMAKE_MEMORYCHECK_COMMAND_OPTIONS
"--leak-check=full --show-reachable=yes --track-origins=yes -q")
"--error-exitcode=1 --leak-check=full --show-reachable=yes --track-origins=yes -q")
set(MEMCHECK_COMMAND
"${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
@@ -446,7 +475,7 @@ if (NOT WITHOUT_TESTS)
# Test suites.
#
if (CMAKE_COMPILER_IS_GNUCC)
add_definitions(-Wall -Wextra -Wdeclaration-after-statement -Werror)
add_definitions(-Wall -Wextra -Wdeclaration-after-statement)
endif ()
set(api_tests
@@ -479,11 +508,12 @@ if (NOT WITHOUT_TESTS)
# Create executables and tests/valgrind tests for API tests.
foreach (test ${api_tests})
build_testprog(${test} ${PROJECT_SOURCE_DIR}/test/suites/api)
add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
if (TEST_WITH_VALGRIND)
add_test(memcheck_${test} ${MEMCHECK_COMMAND}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
if (JANSSON_TEST_WITH_VALGRIND)
add_test(memcheck__${test}
${MEMCHECK_COMMAND} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
else()
add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
endif ()
endforeach ()
@@ -493,14 +523,29 @@ if (NOT WITHOUT_TESTS)
set(SUITES encoding-flags valid invalid invalid-unicode)
foreach (SUITE ${SUITES})
file(GLOB TESTDIRS ${jansson_SOURCE_DIR}/test/suites/${SUITE}/*)
foreach (TESTDIR ${TESTDIRS})
if (IS_DIRECTORY ${TESTDIR})
get_filename_component(TNAME ${TESTDIR} NAME)
add_test(${SUITE}__${TNAME}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process ${TESTDIR})
set(SUITE_TEST_CMD ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process)
if (JANSSON_TEST_WITH_VALGRIND)
add_test(memcheck__${SUITE}__${TNAME}
${MEMCHECK_COMMAND} ${SUITE_TEST_CMD} ${TESTDIR})
else()
add_test(${SUITE}__${TNAME}
${SUITE_TEST_CMD} ${TESTDIR})
endif()
if ((${SUITE} STREQUAL "valid" OR ${SUITE} STREQUAL "invalid") AND NOT EXISTS ${TESTDIR}/nostrip)
add_test(${SUITE}__${TNAME}__strip
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process --strip ${TESTDIR})
if (JANSSON_TEST_WITH_VALGRIND)
add_test(memcheck__${SUITE}__${TNAME}__strip
${MEMCHECK_COMMAND} ${SUITE_TEST_CMD} --strip ${TESTDIR})
else()
add_test(${SUITE}__${TNAME}__strip
${SUITE_TEST_CMD} --strip ${TESTDIR})
endif()
endif ()
endif ()
endforeach ()
@@ -510,3 +555,104 @@ if (NOT WITHOUT_TESTS)
DEPENDS json_process ${api_tests})
endif ()
#
# Installation preparation.
#
# Allow the user to override installation directories.
set(JANSSON_INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(JANSSON_INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
set(JANSSON_INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR cmake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/cmake/jansson)
endif()
set(JANSSON_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
# Make sure the paths are absolute.
foreach(p LIB BIN INCLUDE CMAKE)
set(var JANSSON_INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
endforeach()
# Export targets (This is used for other CMake projects to easily find the libraries and include files).
export(TARGETS jansson
FILE "${PROJECT_BINARY_DIR}/JanssonTargets.cmake")
export(PACKAGE jansson)
# Generate the config file for the build-tree.
set(JANSSON__INCLUDE_DIRS
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include")
set(JANSSON_INCLUDE_DIRS ${JANSSON__INCLUDE_DIRS} CACHE PATH "Jansson include directories")
configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in
${PROJECT_BINARY_DIR}/JanssonConfig.cmake
@ONLY)
# Generate the config file for the installation tree.
file(RELATIVE_PATH
REL_INCLUDE_DIR
"${JANSSON_INSTALL_CMAKE_DIR}"
"${JANSSON_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir.
# Note the EVENT_CMAKE_DIR is defined in JanssonConfig.cmake.in,
# we escape it here so it's evaluated when it is included instead
# so that the include dirs are given relative to where the
# config file is located.
set(JANSSON__INCLUDE_DIRS
"\${JANSSON_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in
${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/JanssonConfig.cmake
@ONLY)
# Generate version info for both build-tree and install-tree.
configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfigVersion.cmake.in
${PROJECT_BINARY_DIR}/JanssonConfigVersion.cmake
@ONLY)
# Define the public headers.
set_target_properties(jansson PROPERTIES PUBLIC_HEADER "${JANSSON_HDR_PUBLIC}")
#TODO: fix this.
# Create pkg-conf file.
# (We use the same files as ./configure does, so we
# have to defined the same variables used there).
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/${JANSSON_INSTALL_LIB_DIR})
set(VERSION ${JANSSON_DISPLAY_VERSION})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jansson.pc.in
${CMAKE_CURRENT_BINARY_DIR}/jansson.pc @ONLY)
#
# Install targets.
#
install(TARGETS jansson
EXPORT JanssonTargets
LIBRARY DESTINATION "${JANSSON_INSTALL_LIB_DIR}" COMPONENT lib
ARCHIVE DESTINATION "${JANSSON_INSTALL_LIB_DIR}" COMPONENT lib
RUNTIME DESTINATION "${JANSSON_INSTALL_BIN_DIR}" COMPONENT lib # Windows DLLs
PUBLIC_HEADER DESTINATION "${JANSSON_INSTALL_INCLUDE_DIR}" COMPONENT dev)
# Install the pkg-config.
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/jansson.pc
DESTINATION ${JANSSON_INSTALL_LIB_DIR}/pkgconfig COMPONENT dev)
# Install the configs.
install(FILES
${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/JanssonConfig.cmake
${PROJECT_BINARY_DIR}/JanssonConfigVersion.cmake
DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev)
# Install exports for the install-tree.
install(EXPORT JanssonTargets
DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev)
# For use when simply using add_library from a parent project to build jansson.
set(JANSSON_LIBRARIES jansson CACHE STRING "Jansson libraries")

View File

@@ -1,4 +1,4 @@
Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,4 +1,4 @@
EXTRA_DIST = CHANGES LICENSE README.rst win32 CMakeLists.txt cmake
EXTRA_DIST = CHANGES LICENSE README.rst CMakeLists.txt cmake android
SUBDIRS = doc src test
# "make distcheck" builds the dvi target, so use it to check that the
@@ -8,8 +8,3 @@ dvi:
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = jansson.pc
if GCC
# These flags are gcc specific
export AM_CFLAGS = -Wall -Wextra -Wdeclaration-after-statement
endif

View File

@@ -2,8 +2,10 @@ Jansson README
==============
.. image:: https://travis-ci.org/akheron/jansson.png
:alt: Build status
:target: https://travis-ci.org/akheron/jansson
.. image:: https://ci.appveyor.com/api/projects/status/lmhkkc4q8cwc65ko
:target: https://ci.appveyor.com/project/akheron/jansson
Jansson_ is a C library for encoding, decoding and manipulating JSON
data. Its main features and design principles are:

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2010-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

6
appveyor.yml Normal file
View File

@@ -0,0 +1,6 @@
build_script:
- md build
- cd build
- cmake ..
- cmake --build . --config Release
- ctest --output-on-failure

View File

@@ -0,0 +1,17 @@
# - Config file for the jansson package
# It defines the following variables
# JANSSON_INCLUDE_DIRS - include directories for FooBar
# JANSSON_LIBRARIES - libraries to link against
# Get the path of the current file.
get_filename_component(JANSSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
# Set the include directories.
set(JANSSON_INCLUDE_DIRS "@JANSSON__INCLUDE_DIRS@")
# Include the project Targets file, this contains definitions for IMPORTED targets.
include(${JANSSON_CMAKE_DIR}/JanssonTargets.cmake)
# IMPORTED targets from JanssonTargets.cmake
set(JANSSON_LIBRARIES jansson)

View File

@@ -0,0 +1,11 @@
set(PACKAGE_VERSION "@JANSSON_DISPLAY_VERSION@")
# Check whether the requested PACKAGE_FIND_VERSION is compatible
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2010-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -17,7 +17,9 @@
#define JANSSON_CONFIG_H
/* Define this so that we can disable scattered automake configuration in source files */
#ifndef JANSSON_USING_CMAKE
#define JANSSON_USING_CMAKE
#endif
/* Note: when using cmake, JSON_INTEGER_IS_LONG_LONG is not defined nor used,
* as we will also check for __int64 etc types.

View File

@@ -31,6 +31,16 @@
# define uint32_t @JSON_UINT32@
#endif
#cmakedefine HAVE_UINT16_T 1
#ifndef HAVE_UINT16_T
# define uint16_t @JSON_UINT16@
#endif
#cmakedefine HAVE_UINT8_T 1
#ifndef HAVE_UINT8_T
# define uint8_t @JSON_UINT8@
#endif
#cmakedefine HAVE_SSIZE_T 1
#ifndef HAVE_SSIZE_T

View File

@@ -1,10 +1,11 @@
AC_PREREQ([2.60])
AC_INIT([jansson], [2.6], [petri@digip.org])
AC_INIT([jansson], [2.7], [petri@digip.org])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([1.10 foreign])
AC_CONFIG_SRCDIR([src/value.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_HEADERS([jansson_private_config.h])
# Checks for programs.
AC_PROG_CC
@@ -19,6 +20,8 @@ AC_CHECK_HEADERS([endian.h fcntl.h locale.h sched.h unistd.h sys/param.h sys/sta
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_INT32_T
AC_TYPE_UINT32_T
AC_TYPE_UINT16_T
AC_TYPE_UINT8_T
AC_TYPE_LONG_LONG_INT
AC_C_INLINE
@@ -89,6 +92,11 @@ AC_DEFINE([USE_WINDOWS_CRYPTOAPI], [1],
[Define to 1 if CryptGenRandom should be used for seeding the hash function])
fi
if test x$GCC = xyes; then
AM_CFLAGS="-Wall -Wextra -Wdeclaration-after-statement"
fi
AC_SUBST([AM_CFLAGS])
AC_CONFIG_FILES([
jansson.pc
Makefile

View File

@@ -150,6 +150,13 @@ functions:
Returns true for types ``JSON_TRUE`` and ``JSON_FALSE``, and false
for values of other types and for *NULL*.
.. function:: json_boolean_value(const json_t *json)
Alias of :func:`json_is_true()`, i.e. returns 1 for ``JSON_TRUE``
and 0 otherwise.
.. versionadded:: 2.7
.. _apiref-reference-count:
@@ -292,17 +299,23 @@ String
======
Jansson uses UTF-8 as the character encoding. All JSON strings must be
valid UTF-8 (or ASCII, as it's a subset of UTF-8). Normal null
terminated C strings are used, so JSON strings may not contain
embedded null characters. All other Unicode codepoints U+0001 through
U+10FFFF are allowed.
valid UTF-8 (or ASCII, as it's a subset of UTF-8). All Unicode
codepoints U+0000 through U+10FFFF are allowed, but you must use
length-aware functions if you wish to embed NUL bytes in strings.
.. function:: json_t *json_string(const char *value)
.. refcounting:: new
Returns a new JSON string, or *NULL* on error. *value* must be a
valid UTF-8 encoded Unicode string.
valid null terminated UTF-8 encoded Unicode string.
.. function:: json_t *json_stringn(const char *value, size_t len)
.. refcounting:: new
Like :func:`json_string`, but with explicit length, so *value* may
contain null characters or not be null terminated.
.. function:: json_t *json_string_nocheck(const char *value)
@@ -312,6 +325,13 @@ U+10FFFF are allowed.
UTF-8. Use this function only if you are certain that this really
is the case (e.g. you have already checked it by other means).
.. function:: json_t *json_stringn_nocheck(const char *value, size_t len)
.. refcounting:: new
Like :func:`json_string_nocheck`, but with explicit length, so
*value* may contain null characters or not be null terminated.
.. function:: const char *json_string_value(const json_t *string)
Returns the associated value of *string* as a null terminated UTF-8
@@ -321,12 +341,22 @@ U+10FFFF are allowed.
the user. It is valid as long as *string* exists, i.e. as long as
its reference count has not dropped to zero.
.. function:: size_t json_string_length(const json_t *string)
Returns the length of *string* in its UTF-8 presentation, or zero
if *string* is not a JSON string.
.. function:: int json_string_set(const json_t *string, const char *value)
Sets the associated value of *string* to *value*. *value* must be a
valid UTF-8 encoded Unicode string. Returns 0 on success and -1 on
error.
.. function:: int json_string_setn(json_t *string, const char *value, size_t len)
Like :func:`json_string_set`, but with explicit length, so *value*
may contain null characters or not be null terminated.
.. function:: int json_string_set_nocheck(const json_t *string, const char *value)
Like :func:`json_string_set`, but doesn't check that *value* is
@@ -334,6 +364,11 @@ U+10FFFF are allowed.
really is the case (e.g. you have already checked it by other
means).
.. function:: int json_string_setn_nocheck(json_t *string, const char *value, size_t len)
Like :func:`json_string_set_nocheck`, but with explicit length,
so *value* may contain null characters or not be null terminated.
Number
======
@@ -539,6 +574,9 @@ Object
A JSON object is a dictionary of key-value pairs, where the key is a
Unicode string and the value is any JSON value.
Even though NUL bytes are allowed in string values, they are not
allowed in object keys.
.. function:: json_t *json_object(void)
.. refcounting:: new
@@ -828,6 +866,12 @@ can be ORed together to obtain *flags*.
output. If ``JSON_INDENT`` is not used or *n* is 0, no newlines are
inserted between array and object items.
The ``JSON_MAX_INDENT`` constant defines the maximum indentation
that can be used, and its value is 31.
.. versionchanged:: 2.7
Added ``JSON_MAX_INDENT``.
``JSON_COMPACT``
This flag enables a compact representation, i.e. sets the separator
between array and object items to ``","`` and between object keys
@@ -867,6 +911,16 @@ can be ORed together to obtain *flags*.
.. versionadded:: 2.4
``JSON_REAL_PRECISION(n)``
Output all real numbers with at most *n* digits of precision. The
valid range for *n* is between 0 and 31 (inclusive), and other
values result in an undefined behavior.
By default, the precision is 17, to correctly and losslessly encode
all IEEE 754 double precision floating point numbers.
.. versionadded:: 2.7
The following functions perform the actual JSON encoding. The result
is in UTF-8.
@@ -984,6 +1038,19 @@ macros can be ORed together to obtain *flags*.
.. versionadded:: 2.5
``JSON_ALLOW_NUL``
Allow ``\u0000`` escape inside string values. This is a safety
measure; If you know your input can contain NUL bytes, use this
flag. If you don't use this flag, you don't have to worry about NUL
bytes inside strings unless you explicitly create themselves by
using e.g. :func:`json_stringn()` or ``s#`` format specifier for
:func:`json_pack()`.
Object keys cannot have embedded NUL bytes even if this flag is
used.
.. versionadded:: 2.6
Each function also takes an optional :type:`json_error_t` parameter
that is filled with error information if decoding fails. It's also
updated on success; the number of bytes of input read is written to
@@ -1110,6 +1177,11 @@ arguments.
.. versionadded:: 2.5
``s%`` (string) [const char \*, size_t]
Like ``s#`` but the length argument is of type :type:`size_t`.
.. versionadded:: 2.6
``+`` [const char \*]
Like ``s``, but concatenate to the previous string. Only valid
after ``s``, ``s#``, ``+`` or ``+#``.
@@ -1122,6 +1194,11 @@ arguments.
.. versionadded:: 2.5
``+%`` (string) [const char \*, size_t]
Like ``+#`` but the length argument is of type :type:`size_t`.
.. versionadded:: 2.6
``n`` (null)
Output a JSON null value. No argument is consumed.
@@ -1236,6 +1313,12 @@ type whose address should be passed.
:func:`json_string_value()` internally, so it exists as long as
there are still references to the corresponding JSON string.
``s%`` (string) [const char \*, size_t \*]
Convert a JSON string to a pointer to a NULL terminated UTF-8
string and its length.
.. versionadded:: 2.6
``n`` (null)
Expect a JSON null value. Nothing is extracted.

View File

@@ -41,14 +41,14 @@ master_doc = 'index'
# General information about the project.
project = u'Jansson'
copyright = u'2009-2013, Petri Lehtinen'
copyright = u'2009-2014, Petri Lehtinen'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2.6'
version = '2.7'
# The full version, including alpha/beta/rc tags.
release = version

View File

@@ -19,15 +19,11 @@ Strings
=======
JSON strings are mapped to C-style null-terminated character arrays,
and UTF-8 encoding is used internally. Strings may not contain
embedded null characters, not even escaped ones.
and UTF-8 encoding is used internally.
For example, trying to decode the following JSON text leads to a parse
error::
["this string contains the null character: \u0000"]
All other Unicode codepoints U+0001 through U+10FFFF are allowed.
All Unicode codepoints U+0000 through U+10FFFF are allowed in string
values. However, U+0000 is not allowed in object keys because of API
restrictions.
Unicode normalization or any other transformation is never performed
on any strings (string values or object keys). When checking for

View File

@@ -19,7 +19,7 @@
<description of the json_object function>
:copyright: Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
:copyright: Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
:license: MIT, see LICENSE for details.
"""

View File

@@ -140,7 +140,7 @@ By default the CMake_ project will generate build files for building the
static library. To build the shared version use::
...
cmake -DBUILD_SHARED=1 ..
cmake -DJANSSON_BUILD_SHARED_LIBS=1 ..
Changing install directory (same as autoconf --prefix)
""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -154,6 +154,7 @@ in CMake_ is::
.. _CMake: http://www.cmake.org
Android
-------
@@ -162,17 +163,6 @@ source root directory. The configuration header file is located in the
``android`` directory in the source distribution.
Windows
-------
**This method is deprecated**. Using :ref:`CMake <build-cmake>` is now
preferred.
Jansson can be built with Visual Studio 2010 (and probably newer
versions, too). The solution and project files are in the
``win32/vs2010/`` directory in the source distribution.
Other Systems
-------------

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -23,4 +23,4 @@ libjansson_la_SOURCES = \
libjansson_la_LDFLAGS = \
-no-undefined \
-export-symbols-regex '^json_' \
-version-info 10:0:6
-version-info 11:0:7

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -22,6 +22,9 @@
#define MAX_INTEGER_STR_LENGTH 100
#define MAX_REAL_STR_LENGTH 100
#define FLAGS_TO_INDENT(f) ((f) & 0x1F)
#define FLAGS_TO_PRECISION(f) (((f) >> 11) & 0x1F)
struct object_key {
size_t serial;
const char *key;
@@ -45,9 +48,9 @@ static const char whitespace[] = " ";
static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t dump, void *data)
{
if(JSON_INDENT(flags) > 0)
if(FLAGS_TO_INDENT(flags) > 0)
{
int i, ws_count = JSON_INDENT(flags);
int i, ws_count = FLAGS_TO_INDENT(flags);
if(dump("\n", 1, data))
return -1;
@@ -65,24 +68,25 @@ static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t
return 0;
}
static int dump_string(const char *str, json_dump_callback_t dump, void *data, size_t flags)
static int dump_string(const char *str, size_t len, json_dump_callback_t dump, void *data, size_t flags)
{
const char *pos, *end;
const char *pos, *end, *lim;
int32_t codepoint;
if(dump("\"", 1, data))
return -1;
end = pos = str;
lim = str + len;
while(1)
{
const char *text;
char seq[13];
int length;
while(*end)
while(end < lim)
{
end = utf8_iterate(pos, &codepoint);
end = utf8_iterate(pos, lim - pos, &codepoint);
if(!end)
return -1;
@@ -126,7 +130,7 @@ static int dump_string(const char *str, json_dump_callback_t dump, void *data, s
/* codepoint is in BMP */
if(codepoint < 0x10000)
{
sprintf(seq, "\\u%04x", codepoint);
sprintf(seq, "\\u%04X", codepoint);
length = 6;
}
@@ -139,7 +143,7 @@ static int dump_string(const char *str, json_dump_callback_t dump, void *data, s
first = 0xD800 | ((codepoint & 0xffc00) >> 10);
last = 0xDC00 | (codepoint & 0x003ff);
sprintf(seq, "\\u%04x\\u%04x", first, last);
sprintf(seq, "\\u%04X\\u%04X", first, last);
length = 12;
}
@@ -207,7 +211,8 @@ static int do_dump(const json_t *json, size_t flags, int depth,
int size;
double value = json_real_value(json);
size = jsonp_dtostr(buffer, MAX_REAL_STR_LENGTH, value);
size = jsonp_dtostr(buffer, MAX_REAL_STR_LENGTH, value,
FLAGS_TO_PRECISION(flags));
if(size < 0)
return -1;
@@ -215,7 +220,7 @@ static int do_dump(const json_t *json, size_t flags, int depth,
}
case JSON_STRING:
return dump_string(json_string_value(json), dump, data, flags);
return dump_string(json_string_value(json), json_string_length(json), dump, data, flags);
case JSON_ARRAY:
{
@@ -336,7 +341,7 @@ static int do_dump(const json_t *json, size_t flags, int depth,
value = json_object_get(json, key);
assert(value);
dump_string(key, dump, data, flags);
dump_string(key, strlen(key), dump, data, flags);
if(dump(separator, separator_length, data) ||
do_dump(value, flags, depth + 1, dump, data))
{
@@ -372,8 +377,9 @@ static int do_dump(const json_t *json, size_t flags, int depth,
while(iter)
{
void *next = json_object_iter_next((json_t *)json, iter);
const char *key = json_object_iter_key(iter);
dump_string(json_object_iter_key(iter), dump, data, flags);
dump_string(key, strlen(key), dump, data, flags);
if(dump(separator, separator_length, data) ||
do_dump(json_object_iter_value(iter), flags, depth + 1,
dump, data))

View File

@@ -1,12 +1,12 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#if HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#include <stdlib.h>
@@ -234,7 +234,14 @@ int hashtable_set(hashtable_t *hashtable,
/* offsetof(...) returns the size of pair_t without the last,
flexible member. This way, the correct amount is
allocated. */
pair = jsonp_malloc(offsetof(pair_t, key) + strlen(key) + 1);
size_t len = strlen(key);
if(len >= (size_t)-1 - offsetof(pair_t, key)) {
/* Avoid an overflow if the key is very long */
return -1;
}
pair = jsonp_malloc(offsetof(pair_t, key) + len + 1);
if(!pair)
return -1;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -3,7 +3,7 @@
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#include <stdio.h>
@@ -38,8 +38,8 @@
#endif
#if defined(_WIN32)
/* For _getpid() */
#include <process.h>
/* For GetModuleHandle(), GetProcAddress() and GetCurrentProcessId() */
#include <windows.h>
#endif
#include "jansson.h"
@@ -95,7 +95,6 @@ static int seed_from_urandom(uint32_t *seed) {
/* Windows Crypto API */
#if defined(_WIN32) && defined(USE_WINDOWS_CRYPTOAPI)
#include <windows.h>
#include <wincrypt.h>
typedef BOOL (WINAPI *CRYPTACQUIRECONTEXTA)(HCRYPTPROV *phProv, LPCSTR pszContainer, LPCSTR pszProvider, DWORD dwProvType, DWORD dwFlags);
@@ -112,7 +111,7 @@ static int seed_from_windows_cryptoapi(uint32_t *seed)
BYTE data[sizeof(uint32_t)];
int ok;
hAdvAPI32 = GetModuleHandle("advapi32.dll");
hAdvAPI32 = GetModuleHandle(TEXT("advapi32.dll"));
if(hAdvAPI32 == NULL)
return 1;
@@ -131,7 +130,7 @@ static int seed_from_windows_cryptoapi(uint32_t *seed)
if (!pCryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
return 1;
ok = CryptGenRandom(hCryptProv, sizeof(uint32_t), data);
ok = pCryptGenRandom(hCryptProv, sizeof(uint32_t), data);
pCryptReleaseContext(hCryptProv, 0);
if (!ok)
@@ -156,7 +155,7 @@ static int seed_from_timestamp_and_pid(uint32_t *seed) {
/* XOR with PID for more randomness */
#if defined(_WIN32)
*seed ^= (uint32_t)_getpid();
*seed ^= (uint32_t)GetCurrentProcessId();
#elif defined(HAVE_GETPID)
*seed ^= (uint32_t)getpid();
#endif

View File

@@ -4,10 +4,15 @@ EXPORTS
json_false
json_null
json_string
json_stringn
json_string_nocheck
json_stringn_nocheck
json_string_value
json_string_length
json_string_set
json_string_setn
json_string_set_nocheck
json_string_setn_nocheck
json_integer
json_integer_value
json_integer_set

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -21,11 +21,11 @@ extern "C" {
/* version */
#define JANSSON_MAJOR_VERSION 2
#define JANSSON_MINOR_VERSION 6
#define JANSSON_MINOR_VERSION 7
#define JANSSON_MICRO_VERSION 0
/* Micro version is omitted if it's 0 */
#define JANSSON_VERSION "2.6"
#define JANSSON_VERSION "2.7"
/* Version as a 3-byte hex number, e.g. 0x010201 == 1.2.1. Use this
for numeric comparisons, e.g. #if JANSSON_VERSION_HEX >= ... */
@@ -67,23 +67,26 @@ typedef long json_int_t;
#endif
#define json_typeof(json) ((json)->type)
#define json_is_object(json) (json && json_typeof(json) == JSON_OBJECT)
#define json_is_array(json) (json && json_typeof(json) == JSON_ARRAY)
#define json_is_string(json) (json && json_typeof(json) == JSON_STRING)
#define json_is_integer(json) (json && json_typeof(json) == JSON_INTEGER)
#define json_is_real(json) (json && json_typeof(json) == JSON_REAL)
#define json_is_object(json) ((json) && json_typeof(json) == JSON_OBJECT)
#define json_is_array(json) ((json) && json_typeof(json) == JSON_ARRAY)
#define json_is_string(json) ((json) && json_typeof(json) == JSON_STRING)
#define json_is_integer(json) ((json) && json_typeof(json) == JSON_INTEGER)
#define json_is_real(json) ((json) && json_typeof(json) == JSON_REAL)
#define json_is_number(json) (json_is_integer(json) || json_is_real(json))
#define json_is_true(json) (json && json_typeof(json) == JSON_TRUE)
#define json_is_false(json) (json && json_typeof(json) == JSON_FALSE)
#define json_is_true(json) ((json) && json_typeof(json) == JSON_TRUE)
#define json_is_false(json) ((json) && json_typeof(json) == JSON_FALSE)
#define json_boolean_value json_is_true
#define json_is_boolean(json) (json_is_true(json) || json_is_false(json))
#define json_is_null(json) (json && json_typeof(json) == JSON_NULL)
#define json_is_null(json) ((json) && json_typeof(json) == JSON_NULL)
/* construction, destruction, reference counting */
json_t *json_object(void);
json_t *json_array(void);
json_t *json_string(const char *value);
json_t *json_stringn(const char *value, size_t len);
json_t *json_string_nocheck(const char *value);
json_t *json_stringn_nocheck(const char *value, size_t len);
json_t *json_integer(json_int_t value);
json_t *json_real(double value);
json_t *json_true(void);
@@ -200,16 +203,18 @@ int json_array_insert(json_t *array, size_t ind, json_t *value)
}
const char *json_string_value(const json_t *string);
size_t json_string_length(const json_t *string);
json_int_t json_integer_value(const json_t *integer);
double json_real_value(const json_t *real);
double json_number_value(const json_t *json);
int json_string_set(json_t *string, const char *value);
int json_string_setn(json_t *string, const char *value, size_t len);
int json_string_set_nocheck(json_t *string, const char *value);
int json_string_setn_nocheck(json_t *string, const char *value, size_t len);
int json_integer_set(json_t *integer, json_int_t value);
int json_real_set(json_t *real, double value);
/* pack, unpack */
json_t *json_pack(const char *fmt, ...);
@@ -241,6 +246,7 @@ json_t *json_deep_copy(const json_t *value);
#define JSON_DISABLE_EOF_CHECK 0x2
#define JSON_DECODE_ANY 0x4
#define JSON_DECODE_INT_AS_REAL 0x8
#define JSON_ALLOW_NUL 0x10
typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data);
@@ -253,13 +259,15 @@ json_t *json_load_callback(json_load_callback_t callback, void *data, size_t fla
/* encoding */
#define JSON_INDENT(n) (n & 0x1F)
#define JSON_COMPACT 0x20
#define JSON_ENSURE_ASCII 0x40
#define JSON_SORT_KEYS 0x80
#define JSON_PRESERVE_ORDER 0x100
#define JSON_ENCODE_ANY 0x200
#define JSON_ESCAPE_SLASH 0x400
#define JSON_MAX_INDENT 0x1F
#define JSON_INDENT(n) ((n) & JSON_MAX_INDENT)
#define JSON_COMPACT 0x20
#define JSON_ENSURE_ASCII 0x40
#define JSON_SORT_KEYS 0x80
#define JSON_PRESERVE_ORDER 0x100
#define JSON_ENCODE_ANY 0x200
#define JSON_ESCAPE_SLASH 0x400
#define JSON_REAL_PRECISION(n) (((n) & 0x1F) << 11)
typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2010-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -49,6 +49,7 @@ typedef struct {
typedef struct {
json_t json;
char *value;
size_t length;
} json_string_t;
typedef struct {
@@ -64,9 +65,13 @@ typedef struct {
#define json_to_object(json_) container_of(json_, json_object_t, json)
#define json_to_array(json_) container_of(json_, json_array_t, json)
#define json_to_string(json_) container_of(json_, json_string_t, json)
#define json_to_real(json_) container_of(json_, json_real_t, json)
#define json_to_real(json_) container_of(json_, json_real_t, json)
#define json_to_integer(json_) container_of(json_, json_integer_t, json)
/* Create a string by taking ownership of an existing buffer */
json_t *jsonp_stringn_nocheck_own(const char *value, size_t len);
/* Error message formatting */
void jsonp_error_init(json_error_t *error, const char *source);
void jsonp_error_set_source(json_error_t *error, const char *source);
void jsonp_error_set(json_error_t *error, int line, int column,
@@ -76,13 +81,14 @@ void jsonp_error_vset(json_error_t *error, int line, int column,
/* Locale independent string<->double conversions */
int jsonp_strtod(strbuffer_t *strbuffer, double *out);
int jsonp_dtostr(char *buffer, size_t size, double value);
int jsonp_dtostr(char *buffer, size_t size, double value, int prec);
/* Wrappers for custom memory functions */
void* jsonp_malloc(size_t size);
void jsonp_free(void *ptr);
char *jsonp_strndup(const char *str, size_t length);
char *jsonp_strdup(const char *str);
char *jsonp_strndup(const char *str, size_t len);
/* Windows compatibility */
#ifdef _WIN32

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -63,7 +63,10 @@ typedef struct {
strbuffer_t saved_text;
int token;
union {
char *string;
struct {
char *val;
size_t len;
} string;
json_int_t integer;
double real;
} value;
@@ -279,6 +282,13 @@ static void lex_save_cached(lex_t *lex)
}
}
static void lex_free_string(lex_t *lex)
{
jsonp_free(lex->value.string.val);
lex->value.string.val = NULL;
lex->value.string.len = 0;
}
/* assumes that str points to 'u' plus at least 4 valid hex digits */
static int32_t decode_unicode_escape(const char *str)
{
@@ -297,7 +307,7 @@ static int32_t decode_unicode_escape(const char *str)
else if(l_isupper(c))
value += c - 'A' + 10;
else
assert(0);
return -1;
}
return value;
@@ -310,7 +320,7 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
char *t;
int i;
lex->value.string = NULL;
lex->value.string.val = NULL;
lex->token = TOKEN_INVALID;
c = lex_get_save(lex, error);
@@ -365,14 +375,12 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
- two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair
are converted to 4 bytes
*/
lex->value.string = jsonp_malloc(lex->saved_text.length + 1);
if(!lex->value.string) {
t = jsonp_malloc(lex->saved_text.length + 1);
if(!t) {
/* this is not very nice, since TOKEN_INVALID is returned */
goto out;
}
/* the target */
t = lex->value.string;
lex->value.string.val = t;
/* + 1 to skip the " */
p = strbuffer_value(&lex->saved_text) + 1;
@@ -381,17 +389,24 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
if(*p == '\\') {
p++;
if(*p == 'u') {
char buffer[4];
int length;
size_t length;
int32_t value;
value = decode_unicode_escape(p);
if(value < 0) {
error_set(error, lex, "invalid Unicode escape '%.6s'", p - 1);
goto out;
}
p += 5;
if(0xD800 <= value && value <= 0xDBFF) {
/* surrogate pair */
if(*p == '\\' && *(p + 1) == 'u') {
int32_t value2 = decode_unicode_escape(++p);
if(value2 < 0) {
error_set(error, lex, "invalid Unicode escape '%.6s'", p - 1);
goto out;
}
p += 5;
if(0xDC00 <= value2 && value2 <= 0xDFFF) {
@@ -420,16 +435,9 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
error_set(error, lex, "invalid Unicode '\\u%04X'", value);
goto out;
}
else if(value == 0)
{
error_set(error, lex, "\\u0000 is not allowed");
goto out;
}
if(utf8_encode(value, buffer, &length))
if(utf8_encode(value, t, &length))
assert(0);
memcpy(t, buffer, length);
t += length;
}
else {
@@ -451,11 +459,12 @@ static void lex_scan_string(lex_t *lex, json_error_t *error)
*(t++) = *(p++);
}
*t = '\0';
lex->value.string.len = t - lex->value.string.val;
lex->token = TOKEN_STRING;
return;
out:
jsonp_free(lex->value.string);
lex_free_string(lex);
}
#ifndef JANSSON_USING_CMAKE /* disabled if using cmake */
@@ -474,7 +483,7 @@ static int lex_scan_number(lex_t *lex, int c, json_error_t *error)
{
const char *saved_text;
char *end;
double value;
double doubleval;
lex->token = TOKEN_INVALID;
@@ -499,16 +508,16 @@ static int lex_scan_number(lex_t *lex, int c, json_error_t *error)
}
if(c != '.' && c != 'E' && c != 'e') {
json_int_t value;
json_int_t intval;
lex_unget_unsave(lex, c);
saved_text = strbuffer_value(&lex->saved_text);
errno = 0;
value = json_strtoint(saved_text, &end, 10);
intval = json_strtoint(saved_text, &end, 10);
if(errno == ERANGE) {
if(value < 0)
if(intval < 0)
error_set(error, lex, "too big negative integer");
else
error_set(error, lex, "too big integer");
@@ -518,7 +527,7 @@ static int lex_scan_number(lex_t *lex, int c, json_error_t *error)
assert(end == saved_text + lex->saved_text.length);
lex->token = TOKEN_INTEGER;
lex->value.integer = value;
lex->value.integer = intval;
return 0;
}
@@ -552,13 +561,13 @@ static int lex_scan_number(lex_t *lex, int c, json_error_t *error)
lex_unget_unsave(lex, c);
if(jsonp_strtod(&lex->saved_text, &value)) {
if(jsonp_strtod(&lex->saved_text, &doubleval)) {
error_set(error, lex, "real number overflow");
goto out;
}
lex->token = TOKEN_REAL;
lex->value.real = value;
lex->value.real = doubleval;
return 0;
out:
@@ -571,10 +580,8 @@ static int lex_scan(lex_t *lex, json_error_t *error)
strbuffer_clear(&lex->saved_text);
if(lex->token == TOKEN_STRING) {
jsonp_free(lex->value.string);
lex->value.string = NULL;
}
if(lex->token == TOKEN_STRING)
lex_free_string(lex);
c = lex_get(lex, error);
while(c == ' ' || c == '\t' || c == '\n' || c == '\r')
@@ -635,13 +642,14 @@ out:
return lex->token;
}
static char *lex_steal_string(lex_t *lex)
static char *lex_steal_string(lex_t *lex, size_t *out_len)
{
char *result = NULL;
if(lex->token == TOKEN_STRING)
{
result = lex->value.string;
lex->value.string = NULL;
if(lex->token == TOKEN_STRING) {
result = lex->value.string.val;
*out_len = lex->value.string.len;
lex->value.string.val = NULL;
lex->value.string.len = 0;
}
return result;
}
@@ -659,7 +667,7 @@ static int lex_init(lex_t *lex, get_func get, void *data)
static void lex_close(lex_t *lex)
{
if(lex->token == TOKEN_STRING)
jsonp_free(lex->value.string);
lex_free_string(lex);
strbuffer_close(&lex->saved_text);
}
@@ -680,6 +688,7 @@ static json_t *parse_object(lex_t *lex, size_t flags, json_error_t *error)
while(1) {
char *key;
size_t len;
json_t *value;
if(lex->token != TOKEN_STRING) {
@@ -687,9 +696,14 @@ static json_t *parse_object(lex_t *lex, size_t flags, json_error_t *error)
goto error;
}
key = lex_steal_string(lex);
key = lex_steal_string(lex, &len);
if(!key)
return NULL;
if (memchr(key, '\0', len)) {
jsonp_free(key);
error_set(error, lex, "NUL byte in object key not supported");
goto error;
}
if(flags & JSON_REJECT_DUPLICATES) {
if(json_object_get(object, key)) {
@@ -788,7 +802,21 @@ static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error)
switch(lex->token) {
case TOKEN_STRING: {
json = json_string_nocheck(lex->value.string);
const char *value = lex->value.string.val;
size_t len = lex->value.string.len;
if(!(flags & JSON_ALLOW_NUL)) {
if(memchr(value, '\0', len)) {
error_set(error, lex, "\\u0000 is not allowed without JSON_ALLOW_NUL");
return NULL;
}
}
json = jsonp_stringn_nocheck_own(value, len);
if(json) {
lex->value.string.val = NULL;
lex->value.string.len = 0;
}
break;
}

View File

@@ -37,7 +37,7 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#ifdef HAVE_STDINT_H
@@ -205,7 +205,22 @@ static uint32_t hashlittle(const void *key, size_t length, uint32_t initval)
if (HASH_LITTLE_ENDIAN && ((u.i & 0x3) == 0)) {
const uint32_t *k = (const uint32_t *)key; /* read 32-bit chunks */
/* Detect Valgrind or AddressSanitizer */
#ifdef VALGRIND
# define NO_MASKING_TRICK 1
#else
# if defined(__has_feature) /* Clang */
# if __has_feature(address_sanitizer) /* is ASAN enabled? */
# define NO_MASKING_TRICK 1
# endif
# else
# if defined(__SANITIZE_ADDRESS__) /* GCC 4.8.x, is ASAN enabled? */
# define NO_MASKING_TRICK 1
# endif
# endif
#endif
#ifdef NO_MASKING_TRICK
const uint8_t *k8;
#endif
@@ -230,7 +245,7 @@ static uint32_t hashlittle(const void *key, size_t length, uint32_t initval)
* still catch it and complain. The masking trick does make the hash
* noticably faster for short strings (like English words).
*/
#ifndef VALGRIND
#ifndef NO_MASKING_TRICK
switch(length)
{

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2011-2012 Basile Starynkevitch <basile@starynkevitch.net>
*
* Jansson is free software; you can redistribute it and/or modify it
@@ -12,6 +12,10 @@
#include "jansson.h"
#include "jansson_private.h"
/* C89 allows these to be macros */
#undef malloc
#undef free
/* memory function pointers */
static json_malloc_t do_malloc = malloc;
static json_free_t do_free = free;
@@ -34,18 +38,19 @@ void jsonp_free(void *ptr)
char *jsonp_strdup(const char *str)
{
char *new_str;
size_t len;
return jsonp_strndup(str, strlen(str));
}
len = strlen(str);
if(len == (size_t)-1)
return NULL;
char *jsonp_strndup(const char *str, size_t len)
{
char *new_str;
new_str = jsonp_malloc(len + 1);
if(!new_str)
return NULL;
memcpy(new_str, str, len + 1);
memcpy(new_str, str, len);
new_str[len] = '\0';
return new_str;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2011-2012 Graeme Smecher <graeme.smecher@mail.mcgill.ca>
*
* Jansson is free software; you can redistribute it and/or modify
@@ -125,19 +125,18 @@ static json_t *pack(scanner_t *s, va_list *ap);
/* ours will be set to 1 if jsonp_free() must be called for the result
afterwards */
static char *read_string(scanner_t *s, va_list *ap,
const char *purpose, int *ours)
const char *purpose, size_t *out_len, int *ours)
{
char t;
strbuffer_t strbuff;
const char *str;
size_t length;
char *result;
next_token(s);
t = token(s);
prev_token(s);
if(t != '#' && t != '+') {
if(t != '#' && t != '%' && t != '+') {
/* Optimize the simple case */
str = va_arg(*ap, const char *);
@@ -146,11 +145,14 @@ static char *read_string(scanner_t *s, va_list *ap,
return NULL;
}
if(!utf8_check_string(str, -1)) {
length = strlen(str);
if(!utf8_check_string(str, length)) {
set_error(s, "<args>", "Invalid UTF-8 %s", purpose);
return NULL;
}
*out_len = length;
*ours = 0;
return (char *)str;
}
@@ -170,6 +172,9 @@ static char *read_string(scanner_t *s, va_list *ap,
if(token(s) == '#') {
length = va_arg(*ap, int);
}
else if(token(s) == '%') {
length = va_arg(*ap, size_t);
}
else {
prev_token(s);
length = strlen(str);
@@ -188,15 +193,15 @@ static char *read_string(scanner_t *s, va_list *ap,
}
}
result = strbuffer_steal_value(&strbuff);
if(!utf8_check_string(result, -1)) {
if(!utf8_check_string(strbuff.value, strbuff.length)) {
set_error(s, "<args>", "Invalid UTF-8 %s", purpose);
strbuffer_close(&strbuff);
return NULL;
}
*out_len = strbuff.length;
*ours = 1;
return result;
return strbuffer_steal_value(&strbuff);
}
static json_t *pack_object(scanner_t *s, va_list *ap)
@@ -206,6 +211,7 @@ static json_t *pack_object(scanner_t *s, va_list *ap)
while(token(s) != '}') {
char *key;
size_t len;
int ours;
json_t *value;
@@ -219,15 +225,19 @@ static json_t *pack_object(scanner_t *s, va_list *ap)
goto error;
}
key = read_string(s, ap, "object key", &ours);
key = read_string(s, ap, "object key", &len, &ours);
if(!key)
goto error;
next_token(s);
value = pack(s, ap);
if(!value)
if(!value) {
if(ours)
jsonp_free(key);
goto error;
}
if(json_object_set_new_nocheck(object, key, value)) {
if(ours)
@@ -290,20 +300,20 @@ static json_t *pack(scanner_t *s, va_list *ap)
case '[':
return pack_array(s, ap);
case 's': { /* string */
case 's': /* string */
{
char *str;
size_t len;
int ours;
json_t *result;
str = read_string(s, ap, "string", &ours);
str = read_string(s, ap, "string", &len, &ours);
if(!str)
return NULL;
result = json_string_nocheck(str);
if(ours)
jsonp_free(str);
return result;
if (ours)
return jsonp_stringn_nocheck_own(str, len);
else
return json_stringn_nocheck(str, len);
}
case 'n': /* null */
@@ -340,6 +350,7 @@ static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
{
int ret = -1;
int strict = 0;
int gotopt = 0;
/* Use a set (emulated by a hashtable) to check that all object
keys are accessed. Checking that the correct number of keys
@@ -396,7 +407,7 @@ static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
next_token(s);
if(token(s) == '?') {
opt = 1;
opt = gotopt = 1;
next_token(s);
}
@@ -422,10 +433,26 @@ static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
if(strict == 0 && (s->flags & JSON_STRICT))
strict = 1;
if(root && strict == 1 && key_set.size != json_object_size(root)) {
long diff = (long)json_object_size(root) - (long)key_set.size;
set_error(s, "<validation>", "%li object item(s) left unpacked", diff);
goto out;
if(root && strict == 1) {
/* We need to check that all non optional items have been parsed */
const char *key;
json_t *value;
long unpacked = 0;
if (gotopt) {
/* We have optional keys, we need to iter on each key */
json_object_foreach(root, key, value) {
if(!hashtable_get(&key_set, key)) {
unpacked++;
}
}
} else {
/* No optional keys, we can just compare the number of items */
unpacked = (long)json_object_size(root) - (long)key_set.size;
}
if (unpacked) {
set_error(s, "<validation>", "%li object item(s) left unpacked", unpacked);
goto out;
}
}
ret = 0;
@@ -523,16 +550,32 @@ static int unpack(scanner_t *s, json_t *root, va_list *ap)
}
if(!(s->flags & JSON_VALIDATE_ONLY)) {
const char **target;
const char **str_target;
size_t *len_target = NULL;
target = va_arg(*ap, const char **);
if(!target) {
str_target = va_arg(*ap, const char **);
if(!str_target) {
set_error(s, "<args>", "NULL string argument");
return -1;
}
if(root)
*target = json_string_value(root);
next_token(s);
if(token(s) == '%') {
len_target = va_arg(*ap, size_t *);
if(!len_target) {
set_error(s, "<args>", "NULL string length argument");
return -1;
}
}
else
prev_token(s);
if(root) {
*str_target = json_string_value(root);
if(len_target)
*len_target = json_string_length(root);
}
}
return 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -2,12 +2,13 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "jansson_private.h"
#include "strbuffer.h"
/* need config.h to get the correct snprintf */
/* need jansson_private_config.h to get the correct snprintf */
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#if JSON_HAVE_LOCALECONV
@@ -69,7 +70,7 @@ int jsonp_strtod(strbuffer_t *strbuffer, double *out)
value = strtod(strbuffer->value, &end);
assert(end == strbuffer->value + strbuffer->length);
if(errno == ERANGE && value != 0) {
if((value == HUGE_VAL || value == -HUGE_VAL) && errno == ERANGE) {
/* Overflow */
return -1;
}
@@ -78,13 +79,16 @@ int jsonp_strtod(strbuffer_t *strbuffer, double *out)
return 0;
}
int jsonp_dtostr(char *buffer, size_t size, double value)
int jsonp_dtostr(char *buffer, size_t size, double value, int precision)
{
int ret;
char *start, *end;
size_t length;
ret = snprintf(buffer, size, "%.17g", value);
if (precision == 0)
precision = 17;
ret = snprintf(buffer, size, "%.*g", precision, value);
if(ret < 0)
return -1;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -8,7 +8,7 @@
#include <string.h>
#include "utf.h"
int utf8_encode(int32_t codepoint, char *buffer, int *size)
int utf8_encode(int32_t codepoint, char *buffer, size_t *size)
{
if(codepoint < 0)
return -1;
@@ -44,7 +44,7 @@ int utf8_encode(int32_t codepoint, char *buffer, int *size)
return 0;
}
int utf8_check_first(char byte)
size_t utf8_check_first(char byte)
{
unsigned char u = (unsigned char)byte;
@@ -80,9 +80,9 @@ int utf8_check_first(char byte)
}
}
int utf8_check_full(const char *buffer, int size, int32_t *codepoint)
size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint)
{
int i;
size_t i;
int32_t value = 0;
unsigned char u = (unsigned char)buffer[0];
@@ -136,12 +136,12 @@ int utf8_check_full(const char *buffer, int size, int32_t *codepoint)
return 1;
}
const char *utf8_iterate(const char *buffer, int32_t *codepoint)
const char *utf8_iterate(const char *buffer, size_t bufsize, int32_t *codepoint)
{
int count;
size_t count;
int32_t value;
if(!*buffer)
if(!bufsize)
return buffer;
count = utf8_check_first(buffer[0]);
@@ -152,7 +152,7 @@ const char *utf8_iterate(const char *buffer, int32_t *codepoint)
value = (unsigned char)buffer[0];
else
{
if(!utf8_check_full(buffer, count, &value))
if(count > bufsize || !utf8_check_full(buffer, count, &value))
return NULL;
}
@@ -162,21 +162,18 @@ const char *utf8_iterate(const char *buffer, int32_t *codepoint)
return buffer + count;
}
int utf8_check_string(const char *string, int length)
int utf8_check_string(const char *string, size_t length)
{
int i;
if(length == -1)
length = strlen(string);
size_t i;
for(i = 0; i < length; i++)
{
int count = utf8_check_first(string[i]);
size_t count = utf8_check_first(string[i]);
if(count == 0)
return 0;
else if(count > 1)
{
if(i + count > length)
if(count > length - i)
return 0;
if(!utf8_check_full(&string[i], count, NULL))

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -9,19 +9,19 @@
#define UTF_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
int utf8_encode(int codepoint, char *buffer, int *size);
int utf8_encode(int32_t codepoint, char *buffer, size_t *size);
int utf8_check_first(char byte);
int utf8_check_full(const char *buffer, int size, int32_t *codepoint);
const char *utf8_iterate(const char *buffer, int32_t *codepoint);
size_t utf8_check_first(char byte);
size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint);
const char *utf8_iterate(const char *buffer, size_t size, int32_t *codepoint);
int utf8_check_string(const char *string, int length);
int utf8_check_string(const char *string, size_t length);
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -10,7 +10,7 @@
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#include <stddef.h>
@@ -29,8 +29,10 @@
/* Work around nonstandard isnan() and isinf() implementations */
#ifndef isnan
#ifndef __sun
static JSON_INLINE int isnan(double x) { return x != x; }
#endif
#endif
#ifndef isinf
static JSON_INLINE int isinf(double x) { return !isnan(x) && isnan(x - x); }
#endif
@@ -92,7 +94,7 @@ json_t *json_object_get(const json_t *json, const char *key)
{
json_object_t *object;
if(!json_is_object(json))
if(!key || !json_is_object(json))
return NULL;
object = json_to_object(json);
@@ -124,7 +126,7 @@ int json_object_set_new_nocheck(json_t *json, const char *key, json_t *value)
int json_object_set_new(json_t *json, const char *key, json_t *value)
{
if(!key || !utf8_check_string(key, -1))
if(!key || !utf8_check_string(key, strlen(key)))
{
json_decref(value);
return -1;
@@ -137,7 +139,7 @@ int json_object_del(json_t *json, const char *key)
{
json_object_t *object;
if(!json_is_object(json))
if(!key || !json_is_object(json))
return -1;
object = json_to_object(json);
@@ -636,33 +638,68 @@ static json_t *json_array_deep_copy(const json_t *array)
/*** string ***/
json_t *json_string_nocheck(const char *value)
static json_t *string_create(const char *value, size_t len, int own)
{
char *v;
json_string_t *string;
if(!value)
return NULL;
string = jsonp_malloc(sizeof(json_string_t));
if(!string)
return NULL;
json_init(&string->json, JSON_STRING);
if(own)
v = (char *)value;
else {
v = jsonp_strndup(value, len);
if(!v)
return NULL;
}
string->value = jsonp_strdup(value);
if(!string->value) {
jsonp_free(string);
string = jsonp_malloc(sizeof(json_string_t));
if(!string) {
if(!own)
jsonp_free(v);
return NULL;
}
json_init(&string->json, JSON_STRING);
string->value = v;
string->length = len;
return &string->json;
}
json_t *json_string(const char *value)
json_t *json_string_nocheck(const char *value)
{
if(!value || !utf8_check_string(value, -1))
if(!value)
return NULL;
return json_string_nocheck(value);
return string_create(value, strlen(value), 0);
}
json_t *json_stringn_nocheck(const char *value, size_t len)
{
return string_create(value, len, 0);
}
/* this is private; "steal" is not a public API concept */
json_t *jsonp_stringn_nocheck_own(const char *value, size_t len)
{
return string_create(value, len, 1);
}
json_t *json_string(const char *value)
{
if(!value)
return NULL;
return json_stringn(value, strlen(value));
}
json_t *json_stringn(const char *value, size_t len)
{
if(!value || !utf8_check_string(value, len))
return NULL;
return json_stringn_nocheck(value, len);
}
const char *json_string_value(const json_t *json)
@@ -673,7 +710,23 @@ const char *json_string_value(const json_t *json)
return json_to_string(json)->value;
}
size_t json_string_length(const json_t *json)
{
if(!json_is_string(json))
return 0;
return json_to_string(json)->length;
}
int json_string_set_nocheck(json_t *json, const char *value)
{
if(!value)
return -1;
return json_string_setn_nocheck(json, value, strlen(value));
}
int json_string_setn_nocheck(json_t *json, const char *value, size_t len)
{
char *dup;
json_string_t *string;
@@ -681,23 +734,32 @@ int json_string_set_nocheck(json_t *json, const char *value)
if(!json_is_string(json) || !value)
return -1;
dup = jsonp_strdup(value);
dup = jsonp_strndup(value, len);
if(!dup)
return -1;
string = json_to_string(json);
jsonp_free(string->value);
string->value = dup;
string->length = len;
return 0;
}
int json_string_set(json_t *json, const char *value)
{
if(!value || !utf8_check_string(value, -1))
if(!value)
return -1;
return json_string_set_nocheck(json, value);
return json_string_setn(json, value, strlen(value));
}
int json_string_setn(json_t *json, const char *value, size_t len)
{
if(!value || !utf8_check_string(value, len))
return -1;
return json_string_setn_nocheck(json, value, len);
}
static void json_delete_string(json_string_t *string)
@@ -708,12 +770,25 @@ static void json_delete_string(json_string_t *string)
static int json_string_equal(json_t *string1, json_t *string2)
{
return strcmp(json_string_value(string1), json_string_value(string2)) == 0;
json_string_t *s1, *s2;
if(!json_is_string(string1) || !json_is_string(string2))
return 0;
s1 = json_to_string(string1);
s2 = json_to_string(string2);
return s1->length == s2->length && !memcmp(s1->value, s2->value, s1->length);
}
static json_t *json_string_copy(const json_t *string)
{
return json_string_nocheck(json_string_value(string));
json_string_t *s;
if(!json_is_string(string))
return NULL;
s = json_to_string(string);
return json_stringn_nocheck(s->value, s->length);
}

View File

@@ -1,12 +1,12 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#include <stdio.h>
@@ -39,6 +39,7 @@ struct config {
int use_env;
int have_hashseed;
int hashseed;
int precision;
} conf;
#define l_isspace(c) ((c) == ' ' || (c) == '\n' || (c) == '\r' || (c) == '\t')
@@ -108,6 +109,8 @@ static void read_conf(FILE *conffile)
conf.preserve_order = atoi(val);
if (!strcmp(line, "JSON_SORT_KEYS"))
conf.sort_keys = atoi(val);
if (!strcmp(line, "JSON_REAL_PRECISION"))
conf.precision = atoi(val);
if (!strcmp(line, "STRIP"))
conf.strip = atoi(val);
if (!strcmp(line, "HASHSEED")) {
@@ -176,11 +179,11 @@ int use_conf(char *test_path)
fclose(conffile);
}
if (conf.indent < 0 || conf.indent > 255) {
if (conf.indent < 0 || conf.indent > 31) {
fprintf(stderr, "invalid value for JSON_INDENT: %d\n", conf.indent);
fclose(infile);
return 2;
}
if (conf.indent)
flags |= JSON_INDENT(conf.indent);
@@ -196,6 +199,15 @@ int use_conf(char *test_path)
if (conf.sort_keys)
flags |= JSON_SORT_KEYS;
if (conf.precision < 0 || conf.precision > 31) {
fprintf(stderr, "invalid value for JSON_REAL_PRECISION: %d\n",
conf.precision);
fclose(infile);
return 2;
}
if (conf.precision)
flags |= JSON_REAL_PRECISION(conf.precision);
if (conf.have_hashseed)
json_object_seed(conf.hashseed);
@@ -245,7 +257,7 @@ static int getenv_int(const char *name)
int use_env()
{
int indent;
int indent, precision;
size_t flags = 0;
json_t *json;
json_error_t error;
@@ -258,11 +270,10 @@ int use_env()
#endif
indent = getenv_int("JSON_INDENT");
if(indent < 0 || indent > 255) {
if(indent < 0 || indent > 31) {
fprintf(stderr, "invalid value for JSON_INDENT: %d\n", indent);
return 2;
}
if(indent > 0)
flags |= JSON_INDENT(indent);
@@ -278,23 +289,35 @@ int use_env()
if(getenv_int("JSON_SORT_KEYS"))
flags |= JSON_SORT_KEYS;
precision = getenv_int("JSON_REAL_PRECISION");
if(precision < 0 || precision > 31) {
fprintf(stderr, "invalid value for JSON_REAL_PRECISION: %d\n",
precision);
return 2;
}
if(getenv("HASHSEED"))
json_object_seed(getenv_int("HASHSEED"));
if(precision > 0)
flags |= JSON_REAL_PRECISION(precision);
if(getenv_int("STRIP")) {
/* Load to memory, strip leading and trailing whitespace */
size_t size = 0, used = 0;
char *buffer = NULL;
char *buffer = NULL, *buf_ck = NULL;
while(1) {
size_t count;
size = (size == 0 ? 128 : size * 2);
buffer = realloc(buffer, size);
if(!buffer) {
buf_ck = realloc(buffer, size);
if(!buf_ck) {
fprintf(stderr, "Unable to allocate %d bytes\n", (int)size);
free(buffer);
return 1;
}
buffer = buf_ck;
count = fread(buffer + used, 1, size - used, stdin);
if(count < size - used) {

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
# Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
#
# Jansson is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
# Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
#
# Jansson is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
# Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
#
# Jansson is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -180,6 +180,20 @@ static void escape_slashes()
json_decref(json);
}
static void encode_nul_byte()
{
json_t *json;
char *result;
json = json_stringn("nul byte \0 in string", 20);
result = json_dumps(json, JSON_ENCODE_ANY);
if(!result || memcmp(result, "\"nul byte \\u0000 in string\"", 27))
fail("json_dumps failed to dump an embedded NUL byte");
free(result);
json_decref(json);
}
static void run_tests()
{
encode_null();
@@ -187,4 +201,5 @@ static void run_tests()
circular_references();
encode_other_than_array_or_object();
escape_slashes();
encode_nul_byte();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -115,6 +115,26 @@ static void decode_int_as_real()
#endif
}
static void allow_nul()
{
const char *text = "\"nul byte \\u0000 in string\"";
const char *expected = "nul byte \0 in string";
size_t len = 20;
json_t *json;
json = json_loads(text, JSON_ALLOW_NUL | JSON_DECODE_ANY, NULL);
if(!json || !json_is_string(json))
fail("unable to decode embedded NUL byte");
if(json_string_length(json) != len)
fail("decoder returned wrong string length");
if(memcmp(json_string_value(json), expected, len + 1))
fail("decoder returned wrong string content");
json_decref(json);
}
static void load_wrong_args()
{
json_t *json;
@@ -161,6 +181,7 @@ static void run_tests()
disable_eof_check();
decode_any();
decode_int_as_real();
allow_nul();
load_wrong_args();
position();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2010-2012 Graeme Smecher <graeme.smecher@mail.mcgill.ca>
*
* Jansson is free software; you can redistribute it and/or modify
@@ -7,7 +7,7 @@
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#include <jansson_config.h>
@@ -83,7 +83,7 @@ static void run_tests()
fail("json_pack string refcount failed");
json_decref(value);
/* string and length */
/* string and length (int) */
value = json_pack("s#", "test asdf", 4);
if(!json_is_string(value) || strcmp("test", json_string_value(value)))
fail("json_pack string and length failed");
@@ -91,14 +91,30 @@ static void run_tests()
fail("json_pack string and length refcount failed");
json_decref(value);
/* string and length, non-NUL terminated string */
value = json_pack("s#", buffer, 4);
/* string and length (size_t) */
value = json_pack("s%", "test asdf", (size_t)4);
if(!json_is_string(value) || strcmp("test", json_string_value(value)))
fail("json_pack string and length failed");
if(value->refcount != (size_t)1)
fail("json_pack string and length refcount failed");
json_decref(value);
/* string and length (int), non-NUL terminated string */
value = json_pack("s#", buffer, 4);
if(!json_is_string(value) || strcmp("test", json_string_value(value)))
fail("json_pack string and length (int) failed");
if(value->refcount != (size_t)1)
fail("json_pack string and length (int) refcount failed");
json_decref(value);
/* string and length (size_t), non-NUL terminated string */
value = json_pack("s%", buffer, (size_t)4);
if(!json_is_string(value) || strcmp("test", json_string_value(value)))
fail("json_pack string and length (size_t) failed");
if(value->refcount != (size_t)1)
fail("json_pack string and length (size_t) refcount failed");
json_decref(value);
/* string concatenation */
value = json_pack("s++", "te", "st", "ing");
if(!json_is_string(value) || strcmp("testing", json_string_value(value)))
@@ -107,12 +123,20 @@ static void run_tests()
fail("json_pack string concatenation refcount failed");
json_decref(value);
/* string concatenation and length */
/* string concatenation and length (int) */
value = json_pack("s#+#+", "test", 1, "test", 2, "test");
if(!json_is_string(value) || strcmp("ttetest", json_string_value(value)))
fail("json_pack string concatenation and length failed");
fail("json_pack string concatenation and length (int) failed");
if(value->refcount != (size_t)1)
fail("json_pack string concatenation and length refcount failed");
fail("json_pack string concatenation and length (int) refcount failed");
json_decref(value);
/* string concatenation and length (size_t) */
value = json_pack("s%+%+", "test", (size_t)1, "test", (size_t)2, "test");
if(!json_is_string(value) || strcmp("ttetest", json_string_value(value)))
fail("json_pack string concatenation and length (size_t) failed");
if(value->refcount != (size_t)1)
fail("json_pack string concatenation and length (size_t) refcount failed");
json_decref(value);
/* empty object */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -27,6 +27,8 @@ static void run_tests()
value = json_boolean(0);
if(!json_is_false(value))
fail("json_boolean(0) failed");
if(json_boolean_value(value) != 0)
fail("json_boolean_value failed");
json_decref(value);
@@ -72,11 +74,22 @@ static void run_tests()
fail("json_string failed");
if(strcmp(json_string_value(value), "foo"))
fail("invalid string value");
if (json_string_length(value) != 3)
fail("invalid string length");
if(json_string_set(value, "bar"))
if(json_string_set(value, "barr"))
fail("json_string_set failed");
if(strcmp(json_string_value(value), "bar"))
if(strcmp(json_string_value(value), "barr"))
fail("invalid string value");
if (json_string_length(value) != 4)
fail("invalid string length");
if(json_string_setn(value, "hi\0ho", 5))
fail("json_string_set failed");
if(memcmp(json_string_value(value), "hi\0ho\0", 6))
fail("invalid string value");
if (json_string_length(value) != 5)
fail("invalid string length");
json_decref(value);
@@ -94,11 +107,22 @@ static void run_tests()
fail("json_string_nocheck failed");
if(strcmp(json_string_value(value), "foo"))
fail("invalid string value");
if (json_string_length(value) != 3)
fail("invalid string length");
if(json_string_set_nocheck(value, "bar"))
if(json_string_set_nocheck(value, "barr"))
fail("json_string_set_nocheck failed");
if(strcmp(json_string_value(value), "bar"))
if(strcmp(json_string_value(value), "barr"))
fail("invalid string value");
if (json_string_length(value) != 4)
fail("invalid string length");
if(json_string_setn_nocheck(value, "hi\0ho", 5))
fail("json_string_set failed");
if(memcmp(json_string_value(value), "hi\0ho\0", 6))
fail("invalid string value");
if (json_string_length(value) != 5)
fail("invalid string length");
json_decref(value);
@@ -108,11 +132,15 @@ static void run_tests()
fail("json_string_nocheck failed");
if(strcmp(json_string_value(value), "qu\xff"))
fail("invalid string value");
if (json_string_length(value) != 3)
fail("invalid string length");
if(json_string_set_nocheck(value, "\xfd\xfe\xff"))
fail("json_string_set_nocheck failed");
if(strcmp(json_string_value(value), "\xfd\xfe\xff"))
fail("invalid string value");
if (json_string_length(value) != 3)
fail("invalid string length");
json_decref(value);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2010-2012 Graeme Smecher <graeme.smecher@mail.mcgill.ca>
*
* Jansson is free software; you can redistribute it and/or modify
@@ -17,6 +17,7 @@ static void run_tests()
int i1, i2, i3;
json_int_t I1;
int rv;
size_t z;
double f;
char *s;
@@ -81,6 +82,13 @@ static void run_tests()
fail("json_unpack string failed");
json_decref(j);
/* string with length (size_t) */
j = json_string("foo");
rv = json_unpack(j, "s%", &s, &z);
if(rv || strcmp(s, "foo") || z != 3)
fail("json_unpack string with length (size_t) failed");
json_decref(j);
/* empty object */
j = json_object();
if(json_unpack(j, "{}"))
@@ -370,4 +378,23 @@ static void run_tests()
if(i1 != 42)
fail("json_unpack failed to unpack");
json_decref(j);
/* Combine ? and ! */
j = json_pack("{si}", "foo", 42);
i1 = i2 = 0;
if(json_unpack(j, "{sis?i!}", "foo", &i1, "bar", &i2))
fail("json_unpack failed for optional values with strict mode");
if(i1 != 42)
fail("json_unpack failed to unpack");
if(i2 != 0)
fail("json_unpack failed to unpack");
json_decref(j);
/* But don't compensate a missing key with an optional one. */
j = json_pack("{sisi}", "foo", 42, "baz", 43);
i1 = i2 = i3 = 0;
if(!json_unpack_ex(j, &error, 0, "{sis?i!}", "foo", &i1, "bar", &i2))
fail("json_unpack failed for optional values with strict mode and compensation");
check_error("1 object item(s) left unpacked", "<validation>", 1, 8, 8);
json_decref(j);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
* Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
@@ -9,7 +9,7 @@
#define UTIL_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#include <jansson_private_config.h>
#endif
#include <stdio.h>

View File

@@ -1 +1 @@
["foo", "\u00e5 \u00e4 \u00f6", "foo \u00e5\u00e4", "\u00e5\u00e4 foo", "\u00e5 foo \u00e4", "clef g: \ud834\udd1e"]
["foo", "\u00E5 \u00E4 \u00F6", "foo \u00E5\u00E4", "\u00E5\u00E4 foo", "\u00E5 foo \u00E4", "clef g: \uD834\uDD1E"]

View File

@@ -0,0 +1,2 @@
JSON_REAL_PRECISION=4
export JSON_REAL_PRECISION

View File

@@ -0,0 +1 @@
[1.23456789, 1.0, 1.0000000000000002]

View File

@@ -0,0 +1 @@
[1.235, 1.0, 1.0]

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
# Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
#
# Jansson is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
# Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
#
# Jansson is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,2 +0,0 @@
1 33 33
\u0000 is not allowed

View File

@@ -1 +0,0 @@
["\u0000 (null byte not allowed)"]

View File

@@ -0,0 +1,2 @@
1 15 15
NUL byte in object key not supported near '"foo\u0000bar"'

View File

@@ -0,0 +1 @@
{"foo\u0000bar": 42}

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
# Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
#
# Jansson is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
# Copyright (c) 2009-2014 Petri Lehtinen <petri@digip.org>
#
# Jansson is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.

View File

@@ -1,39 +0,0 @@
/*
* Copyright (c) 2010-2013 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*
*
* This file specifies a part of the site-specific configuration for
* Jansson, namely those things that affect the public API in
* jansson.h.
*
* The configure script copies this file to jansson_config.h and
* replaces @var@ substitutions by values that fit your system. If you
* cannot run the configure script, you can do the value substitution
* by hand.
*/
#ifndef JANSSON_CONFIG_H
#define JANSSON_CONFIG_H
/* If your compiler supports the inline keyword in C, JSON_INLINE is
defined to `inline', otherwise empty. In C++, the inline is always
supported. */
#ifdef __cplusplus
#define JSON_INLINE inline
#else
#define JSON_INLINE __inline
#endif
/* If your compiler supports the `long long` type and the strtoll()
library function, JSON_INTEGER_IS_LONG_LONG is defined to 1,
otherwise to 0. */
#define JSON_INTEGER_IS_LONG_LONG 1
/* If locale.h and localeconv() are available, define to 1,
otherwise to 0. */
#define JSON_HAVE_LOCALECONV 1
#endif

View File

@@ -1,20 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jansson", "jansson.vcxproj", "{76226D20-1972-4789-A595-EDACC7A76DC3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|Win32.ActiveCfg = Debug|Win32
{76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|Win32.Build.0 = Debug|Win32
{76226D20-1972-4789-A595-EDACC7A76DC3}.Release|Win32.ActiveCfg = Release|Win32
{76226D20-1972-4789-A595-EDACC7A76DC3}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,108 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\dump.c" />
<ClCompile Include="..\..\src\error.c" />
<ClCompile Include="..\..\src\hashtable.c" />
<ClCompile Include="..\..\src\load.c" />
<ClCompile Include="..\..\src\memory.c" />
<ClCompile Include="..\..\src\pack_unpack.c" />
<ClCompile Include="..\..\src\strbuffer.c" />
<ClCompile Include="..\..\src\strconv.c" />
<ClCompile Include="..\..\src\utf.c" />
<ClCompile Include="..\..\src\value.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\hashtable.h" />
<ClInclude Include="..\..\src\jansson.h" />
<ClInclude Include="..\..\src\jansson_private.h" />
<ClInclude Include="..\..\src\strbuffer.h" />
<ClInclude Include="..\..\src\utf.h" />
<ClInclude Include="..\jansson_config.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{76226D20-1972-4789-A595-EDACC7A76DC3}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>jansson_dll</RootNamespace>
<ProjectName>jansson</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>Output\$(Configuration)\</OutDir>
<IntDir>Build\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>Output\$(Configuration)\</OutDir>
<IntDir>Build\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;JANSSON_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ModuleDefinitionFile>../../src/jansson.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;JANSSON_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<ModuleDefinitionFile>../../src/jansson.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\dump.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\error.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\hashtable.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\load.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\memory.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\pack_unpack.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\strbuffer.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\strconv.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\utf.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\value.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\hashtable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\jansson.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\jansson_private.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\strbuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\utf.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\jansson_config.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>