pax_global_header00006660000000000000000000000064123122217650014513gustar00rootroot0000000000000052 comment=a0ecdde0c042b9256170f2f8890dd9451a4240aa yajl-2.1.0/000077500000000000000000000000001231222176500124525ustar00rootroot00000000000000yajl-2.1.0/.gitignore000066400000000000000000000000331231222176500144360ustar00rootroot00000000000000.DS_Store Makefile /build/ yajl-2.1.0/BUILDING000066400000000000000000000007401231222176500135730ustar00rootroot00000000000000Short story (If you already have ruby and cmake): ./configure && make install When things go wrong: attain CMake (http://www.cmake.org) and ruby (http://ruby-lang.org) and try again. OR, attain CMake and build by hand: 1. mkdir build 2. cd build 3. cmake .. 4. make 5. build output left in yajl-X.Y.Z NOTE: for 64-bit systems where lib64 is used you can pass the cmake variable LIB_SUFFIX to cause installation into the system's 'lib64' directory. best, lloyd yajl-2.1.0/BUILDING.win32000066400000000000000000000020021231222176500145250ustar00rootroot00000000000000YAJL has been successfully built using Visual Studio 8. CMake, a build file generator, is used to build the software. CMake supports several different build environments, so you may either build YAJL using the IDE via the following steps: 1. acquire cmake (http://www.cmake.org) 2. mkdir build 3. cd build 4. cmake .. 5. devenv YetAnotherJSONParser.sln /project ALL_BUILD /build Release 6. build output is left in build/yajl-X.Y.Z Or you can build from the command line using nmake: 1. Click Start > Programs > Microsoft Visual Studio > Visual Studio Tools > Visual Studio Command Prompt -- for your version of Visual Studio, which will open a command prompt. You may verify that the compiler is in your path by typing "cl /?" at the prompt. 2. cd C:\path\to\yajl\source\ 3. mkdir build 4. cd build 5. cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release .. 6. nmake 7. nmake install Earlier versions of visual studio and other build generators haven't been thoroughly tested, but should work without any major issues. yajl-2.1.0/CMakeLists.txt000066400000000000000000000061521231222176500152160ustar00rootroot00000000000000# Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(YetAnotherJSONParser C) SET (YAJL_MAJOR 2) SET (YAJL_MINOR 1) SET (YAJL_MICRO 0) SET (YAJL_DIST_NAME "yajl-${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}") IF (NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE "Release") ENDIF (NOT CMAKE_BUILD_TYPE) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") IF (WIN32) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") ADD_DEFINITIONS(-DWIN32) SET(linkFlags "/PDB:NONE /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF") SET(CMAKE_EXE_LINKER_FLAGS "${linkFlags}" CACHE STRING "YAJL linker flags" FORCE) SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "" CACHE STRING "YAJL debug linker flags" FORCE) SET(CMAKE_EXE_LINKER_FLAGS_RELEASE CACHE STRING "YAJL release linker flags" FORCE) SET(CMAKE_SHARED_LINKER_FLAGS "${linkFlags}" CACHE STRING "YAJL shared linker flags" FORCE) SET(CMAKE_MODULE_LINKER_FLAGS "${linkFlags}" CACHE STRING "YAJL module linker flags" FORCE) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /wd4255 /wd4130 /wd4100 /wd4711") SET(CMAKE_C_FLAGS_DEBUG "/D DEBUG /Od /Z7") SET(CMAKE_C_FLAGS_RELEASE "/D NDEBUG /O2") ELSE (WIN32) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") IF(CMAKE_COMPILER_IS_GNUCC) INCLUDE(CheckCCompilerFlag) CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_GCC_VISIBILITY) IF(HAVE_GCC_VISIBILITY) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") ENDIF(HAVE_GCC_VISIBILITY) ENDIF(CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic -Wpointer-arith -Wno-format-y2k -Wstrict-prototypes -Wmissing-declarations -Wnested-externs -Wextra -Wundef -Wwrite-strings -Wold-style-definition -Wredundant-decls -Wno-unused-parameter -Wno-sign-compare -Wmissing-prototypes") SET(CMAKE_C_FLAGS_DEBUG "-DDEBUG -g") SET(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 -Wuninitialized") ENDIF (WIN32) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(test) ADD_SUBDIRECTORY(reformatter) ADD_SUBDIRECTORY(verify) ADD_SUBDIRECTORY(example) ADD_SUBDIRECTORY(perf) INCLUDE(YAJLDoc.cmake) # a test target ADD_CUSTOM_TARGET(test ./run_tests.sh ${CMAKE_CURRENT_BINARY_DIR}/test/parsing/yajl_test WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/parsing) ADD_CUSTOM_TARGET(test-api ${CMAKE_CURRENT_SOURCE_DIR}/test/api/run_tests.sh WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test/api) yajl-2.1.0/COPYING000066400000000000000000000013571231222176500135130ustar00rootroot00000000000000Copyright (c) 2007-2014, Lloyd Hilaiel Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. yajl-2.1.0/ChangeLog000066400000000000000000000167561231222176500142430ustar00rootroot000000000000002.1.0 * @nonodename, @patperry - fixed some compiler warnings * @yep, @emaste - documentation improvements * @sgravrock - build fix for NetBSD (and whenever sh != bash) * @rotty, @brimstone3, @lloyd - allow client to reset generator * @sgravrock - remove bash dependencies * @lloyd - add api tests * @rflynn - remove ruby dependency * @cloderic - nmake install works on windows * @shahbag - build fix for qnx * @breese - debugging improvements * @lloyd - json_verify supports -s flag for stream processing * @lloyd - json_reformat supports -s flag for stream processing 2.0.4 * @jcekstrom - additional checking in integer parsing * @jcekstrom - fix a bug in yajl_tree that would cause valid json integersto fail to parse * @plaguemorin - fix a memory leak in yajl_tree (error strings were being leaked) * @7AC - reset errno * @ConradIrwin - include flags to reformatter to allow toggling of escape solidus option 2.0.3 * John Stamp generation of a pkgconfig file at build time. * @robzuber bugfix in yajl_tree_get() * @lloyd - fix for compilation on 64 bit windows 2.0.2 * lth fix typos in yajl_tree.h macros YAJL_IS_INTEGER and YAJL_IS_DOUBLE, contributed by Artem S Vybornov. * lth add #ifdef __cplusplus wrappers to yajl_tree to allow proper usage from many populer C++ compilers. 2.0.1 * lth generator flag to allow client to specify they want escaped solidi '/'. issue #28 * lth crash fix when yajl_parse() is never called. issue #27 2.0.0 * lth YAJL is now ISC licensed: http://en.wikipedia.org/wiki/ISC_license * lth 20-35% (osx and linux respectively) parsing performance improvement attained by tweaking string scanning (idea: @michaelrhanson). * Florian Forster & lth - yajl_tree interface introduced as a higher level interface to the parser (eats JSON, poops a memory representation) * lth require a C99 compiler * lth integers are now represented with long long (64bit+) on all platforms. * lth size_t now used throughout to represent buffer lengths, so you can safely manage buffers greater than 4GB. * gno semantic improvements to yajl's API regarding partial value parsing and trailing garbage * lth new configuration mechanism for yajl, see yajl_config() and yajl_gen_config() * gno more allocation checking in more places * gno remove usage of strtol, replace with custom implementation that cares not about your locale. * lth yajl_parse_complete renamed to yajl_complete_parse. * lth add a switch to validate utf8 strings as they are generated. * lth tests are a lot quieter in their output. * lth addition of a little in tree performance benchmark, `perftest` in perf/perftest.c 1.0.12 * Conrad Irwin - Parse null bytes correctly * Mirek Rusin - fix LLVM warnings * gno - Don't generate numbers for keys. closes #13 * lth - various win32 fixes, including build documentation improvements * John Stamp - Don't export private symbols. * John Stamp - Install yajl_version.h, not the template. * John Stamp - Don't use -fPIC for static lib. Cmake will automatically add it for the shared. * lth 0 fix paths embedded in dylib upon installation on osx. closes #11 1.0.11 * lth remove -Wno-missing-field-initializers for greater gcc compat (3.4.6) 1.0.10 * Brian Maher - yajl is now buildable without a c++ compiler present * Brian Maher - fix header installation on OSX with cmake 2.8.0 installed * lth & vitali - allow builder to specify alternate lib directory for installation (i.e. lib64) * Vitali Lovich - yajl version number now programatically accessible * lth - prevent cmake from embedding rpaths in binaries. Static linking makes this unneccesary. 1.0.9 * lth - fix inverted logic causing yajl_gen_double() to always fail on win32 (thanks to Fredrik Kihlander for the report) 1.0.8 * Randall E. Barker - move dllexport defnitions so dlls with proper exports can again be generated on windows * lth - add yajl_get_bytes_consumed() which allows the client to determine the offset as an error, as well as determine how many bytes of an input buffer were consumed. * lth - fixes to keep "error offset" up to date (like when the client callback returns 0) * Brian Maher - allow client to specify a printing function in generation 1.0.7 * lth fix win32 build (isinf and isnan) 1.0.6 * lth fix several compiler warnings * lth fix generation of invalid json from yajl_gen_double (NaN is not JSON) * jstamp support for combining short options in tools * jstamp exit properly on errors from tools * octo test success no longer depends on integer size * max fix configure --prefix 1.0.5 * lth several performance improvements related to function inlinin' 1.0.4 * lth fix broken utf8 validation for three & four byte represenations. thanks to http://github.com/brianmario and http://github.com/technoweenie 1.0.3 * lth fix syntax error in cplusplus extern "C" statements for wider compiler support 1.0.2 * lth update doxygen documentation with new sample code, passing NULL for allocation functions added in 1.0.0 1.0.1 * lth resolve crash in json_reformatter due to incorrectly ordered parameters. 1.0.0 * lth add 'make install' rules, thaks to Andrei Soroker for the contribution. * lth client may override allocation routines at generator or parser allocation time * tjw add yajl_parse_complete routine to allow client to explicitly specify end-of-input, solving the "lonely number" case, where json text consists only of an element with no explicit syntactic end. * tjw many new test cases * tjw cleanup of code for symmetry and ease of reading * lth integration of patches from Robert Varga which cleanup compilation warnings on 64 bit linux 0.4.0 * lth buffer overflow bug in yajl_gen_double s/%lf/%g/ - thanks to Eric Bergstrome * lth yajl_number callback to allow passthrough of arbitrary precision numbers to client. Thanks to Hatem Nassrat. * lth yajl_integer now deals in long, instead of long long. This combined with yajl_number improves compiler compatibility while maintaining precision. * lth better ./configure && make experience (still requires cmake and ruby) * lth fix handling of special characters hex 0F and 1F in yajl_encode (thanks to Robert Geiger) * lth allow leading zeros in exponents (thanks to Hatem Nassrat) 0.3.0 * lth doxygen documentation (html & man) generated as part of the build * lth many documentation updates. * lth fix to work with older versions of cmake (don't use LOOSE_LOOP constructs) * lth work around different behavior of freebsd 4 scanf. initialize parameter to scanf to zero. * lth all tests run 32x with ranging buffer sizes to stress stream parsing * lth yajl_test accepts -b option to allow read buffer size to be set * lth option to validate UTF8 added to parser (argument in yajl_parser_cfg) * lth fix buffer overrun when chunk ends inside \u escaped text * lth support client cancelation 0.2.2 * lth on windows build debug with C7 symbols and no pdb files. 0.2.1 * fix yajl_reformat and yajl_verify to work on arbitrarily sized inputs. * fix win32 build break, clean up all errors and warnings. * fix optimized build flags. 0.2.0 * optionally support comments in input text 0.1.0 * Initial release yajl-2.1.0/README000066400000000000000000000053611231222176500133370ustar00rootroot00000000000000********************************************************************** This is YAJL 2. For the legacy version of YAJL see https://github.com/lloyd/yajl/tree/1.x ********************************************************************** Welcome to Yet Another JSON Library (YAJL) ## Why does the world need another C library for parsing JSON? Good question. In a review of current C JSON parsing libraries I was unable to find one that satisfies my requirements. Those are, 0. written in C 1. portable 2. robust -- as close to "crash proof" as possible 3. data representation independent 4. fast 5. generates verbose, useful error messages including context of where the error occurs in the input text. 6. can parse JSON data off a stream, incrementally 7. simple to use 8. tiny Numbers 3, 5, 6, and 7 were particularly hard to find, and were what caused me to ultimately create YAJL. This document is a tour of some of the more important aspects of YAJL. ## YAJL is Free. Permissive licensing means you can use it in open source and commercial products alike without any fees. My request beyond the licensing is that if you find bugs drop me a email, or better yet, fork and fix. Porting YAJL should be trivial, the implementation is ANSI C. If you port to new systems I'd love to hear of it and integrate your patches. ## YAJL is data representation independent. BYODR! Many JSON libraries impose a structure based data representation on you. This is a benefit in some cases and a drawback in others. YAJL uses callbacks to remain agnostic of the in-memory representation. So if you wish to build up an in-memory representation, you may do so using YAJL, but you must bring the code that defines and populates the in memory structure. This also means that YAJL can be used by other (higher level) JSON libraries if so desired. ## YAJL supports stream parsing This means you do not need to hold the whole JSON representation in textual form in memory. This makes YAJL ideal for filtering projects, where you're converting YAJL from one form to another (i.e. XML). The included JSON pretty printer is an example of such a filter program. ## YAJL is fast Minimal memory copying is performed. YAJL, when possible, returns pointers into the client provided text (i.e. for strings that have no embedded escape chars, hopefully the common case). I've put a lot of effort into profiling and tuning performance, but I have ignored a couple possible performance improvements to keep the interface clean, small, and flexible. My hope is that YAJL will perform comparably to the fastest JSON parser out there. YAJL should impose both minimal CPU and memory requirements on your application. ## YAJL is tiny. Fat free. No whip. enjoy, Lloyd - July, 2007 yajl-2.1.0/TODO000066400000000000000000000005141231222176500131420ustar00rootroot00000000000000* add a test for 0x1F bug * numeric overflow in integers and double * line and char offsets in the lexer and in error messages * testing: a. the permuter b. some performance comparison against json_checker. * investigate pull instead of push parsing * Handle memory allocation failures gracefully * cygwin/msys support on win32 yajl-2.1.0/YAJLDoc.cmake000066400000000000000000000015161231222176500146440ustar00rootroot00000000000000FIND_PROGRAM(doxygenPath doxygen) IF (doxygenPath) SET (YAJL_VERSION ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}) SET(yajlDirName yajl-${YAJL_VERSION}) SET(docPath "${CMAKE_CURRENT_BINARY_DIR}/${yajlDirName}/share/doc/${yajlDirName}") MESSAGE("** using doxygen at: ${doxygenPath}") MESSAGE("** documentation output to: ${docPath}") CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/YAJL.dxy ${CMAKE_CURRENT_BINARY_DIR}/YAJL.dxy @ONLY) FILE(MAKE_DIRECTORY "${docPath}") ADD_CUSTOM_TARGET(doc ${doxygenPath} YAJL.dxy WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) ELSE (doxygenPath) MESSAGE("!! doxygen not found, not generating documentation") ADD_CUSTOM_TARGET( doc echo doxygen not installed, not generating documentation ) ENDIF (doxygenPath) yajl-2.1.0/configure000077500000000000000000000040431231222176500143620ustar00rootroot00000000000000#!/bin/sh # # Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. prefix="/usr/local" if [ "$1" = "--help" ] then cat < ./Makefile < # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. SET (SRCS parse_config.c) # use the library we build, duh. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include) LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib) ADD_EXECUTABLE(parse_config ${SRCS}) TARGET_LINK_LIBRARIES(parse_config yajl_s) yajl-2.1.0/example/README.md000066400000000000000000000005401231222176500153630ustar00rootroot00000000000000This directory holds an example of how one might use yajl in the simplest possible way, to do something like parse and extract values from a configuration file. Note that use of the yajl_tree.h utility is completely optional, and yajl_parse.h offers a lower level stream parsing API that is more efficient and flexible at the cost of some complexity. yajl-2.1.0/example/parse_config.c000066400000000000000000000042611231222176500167130ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include "yajl/yajl_tree.h" static unsigned char fileData[65536]; int main(void) { size_t rd; yajl_val node; char errbuf[1024]; /* null plug buffers */ fileData[0] = errbuf[0] = 0; /* read the entire config file */ rd = fread((void *) fileData, 1, sizeof(fileData) - 1, stdin); /* file read error handling */ if (rd == 0 && !feof(stdin)) { fprintf(stderr, "error encountered on file read\n"); return 1; } else if (rd >= sizeof(fileData) - 1) { fprintf(stderr, "config file too big\n"); return 1; } /* we have the whole config file in memory. let's parse it ... */ node = yajl_tree_parse((const char *) fileData, errbuf, sizeof(errbuf)); /* parse error handling */ if (node == NULL) { fprintf(stderr, "parse_error: "); if (strlen(errbuf)) fprintf(stderr, " %s", errbuf); else fprintf(stderr, "unknown error"); fprintf(stderr, "\n"); return 1; } /* ... and extract a nested value from the config file */ { const char * path[] = { "Logging", "timeFormat", (const char *) 0 }; yajl_val v = yajl_tree_get(node, path, yajl_t_string); if (v) printf("%s/%s: %s\n", path[0], path[1], YAJL_GET_STRING(v)); else printf("no such node: %s/%s\n", path[0], path[1]); } yajl_tree_free(node); return 0; } yajl-2.1.0/example/sample.config000066400000000000000000000076521231222176500165670ustar00rootroot00000000000000/* * The configuration file for Yahoo! BrowserPlus, included in the YAJL * tree as a sample configuration file for parsing. * * This is the configuration file for BrowserPlus */ { // The type of build this is, which is accessible to JavaScript via // BrowserPlus.getPlatformInfo(); // Different build types should only differ in signatures accepted // (BrowserPlus.crt) and configured distribution servers. "BuildType": "ephemeral", // the base url for the "primary" distribution server. This server will // be the single source of truth for Permissions, and will used to // attain services "DistServer": "http://browserplus.yahoo.com", // An array of "secondary" distribution servers, which will be checked // in order for services if the primary server has no components // available which match an issued require statement. "SecondaryDistServers": [ "http://first.fictional.server", "http://second.fictional.server" ], // Logging Setup "Logging" : { // Log level. Values: "debug"|"info"|"warn"|"error"|"fatal"|"off" "level": "BP_LOG_LEVEL", // Destination. Values: "file"|"console"|"win32" "dest": "BP_LOG_DEST", // Log message layout. Values: "standard"|"source"|"raw" "layout": "standard", // Time format. Values: "utc"|"local"|"msec" "timeFormat": "utc", // File size in KB which will trigger a rollover "fileRolloverKB": 2048, // Whether to send file logging from each service to a distinct file. // Values: "combined"|"separate" "serviceLogMode": "combined" }, // Daemon setup // Syntax: "Options": "option1 option2 etc" // -fg run in foreground, log to console "Options":"", // Auto-shutdown daemon if idle for this time. Use 0 for no auto-shutdown. "MaxIdleSecs": 5, // At the end of each BrowserPlus session a small web request is made // to yahoo to indicate that BrowserPlus was used. This report includes // * information about the browser being used // * an "installation id", which is a unique token that's generated // the first time BrowserPlus runs. // // By design, there is *no information* in this request that gives // Yahoo! information about: // a) the site that the user is visiting (see, "url": false) // b) who the user is (the installation token cannot be tracked to a // specific user). // // This information is primarily captured to help Yahoo! understand // adoption and usage of the BrowserPlus platform. "UsageReporting": { "enabled": true, "url": false, "id": true }, // "Breakpoints" is an array of strings holding named breakpoints. // Platform code checks for specific entries at certain key points, and if // a matching entry is found here a DebugBreak will be performed. // For developers with Visual Studio installed, the DebugBreak will cause an // opportunity to perform just-in-time attachment of an existing or new // debugger instance. // The currently-defined breakpoints are listed below: // runServiceProcess - A DebugBreak is performed in the service // "harness" just prior to service load. // ax.FinalConstruct - A DebugBreak is performed at entry to // FinalConstruct of the ActiveX plugin. // PluginInit - Very early in the NPAPI plugin initialization. // A wonderful spot to stop and set more // breakpoints. //"Breakpoints": ["runServiceProcess"], // How often we check for service updates. We guarantee at least this // much time will pass between checks, though the true time may be // much more if sites which use browserplus are not visited. // The time is in seconds. "ServiceUpdatePollPeriod": 86400 } yajl-2.1.0/perf/000077500000000000000000000000001231222176500134065ustar00rootroot00000000000000yajl-2.1.0/perf/CMakeLists.txt000066400000000000000000000020671231222176500161530ustar00rootroot00000000000000# Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. SET (SRCS perftest.c documents.c documents.h) # use the library we build, duh. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include) LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib) ADD_EXECUTABLE(perftest ${SRCS}) TARGET_LINK_LIBRARIES(perftest yajl_s) yajl-2.1.0/perf/documents.c000066400000000000000000003115571231222176500155670ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "documents.h" #include #include /* latest twitter tweets from easter day */ const char * doc1[] = { "[{\"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:48 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143455073280000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Good morning! Happy Easter! Hopefully c u later!\",\n" " \"id\": 62143455073280000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"David\",\n" " \"profile_sidebar_border_color\": \"C0DEED\",\n" " \"profile_background_tile\": false,\n" " \"profile_sidebar_fill_color\": \"DDEEF6\",\n" " \"profile_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_images\\/1313918274\\/image_normal.jpg\",\n" " \"created_at\": \"Sat Apr 16 12:10:50 +0000 2011\",\n" " \"location\": null,\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"0084B4\",\n" " \"id_str\": \"283022296\",\n" " \"url\": null,\n" " \"default_profile\": true,\n" " \"contributors_enabled\": false,\n" " \"favourites_count\": 0,\n" " \"utc_offset\": null,\n" " \"id\": 283022296,\n" " \"listed_count\": 0,\n" " \"profile_use_background_image\": true,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 7,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"C0DEED\",\n" " \"geo_enabled\": false,\n" " \"time_zone\": null,\n" " \"notifications\": null,\n" " \"description\": null,\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/a\\/1302724321\\/images\\/themes\\/theme1\\/bg.png\",\n", " \"statuses_count\": 46,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 28,\n" " \"show_all_inline_media\": false,\n" " \"screen_name\": \"djstump440\",\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/twitter.com\\/\\\" rel=\\\"nofollow\\\"\\u003ETwitter for iPhone\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:48 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143454767104000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"haloo hihihi -_-\",\n" " \"id\": 62143454767104000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Riva \\u01aa(\\u02c7\\u25bc\\u02c7)\\u00ac\",\n" " \"profile_sidebar_border_color\": \"eeeeee\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"efefef\",\n" " \"profile_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_images\\/1323509905\\/cats_normal.jpg\",\n" " \"created_at\": \"Sat Oct 16 05:07:18 +0000 2010\",\n" " \"location\": \"\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"009999\",\n" " \"id_str\": \"203398982\",\n" " \"url\": null,\n" " \"default_profile\": false,\n" " \"contributors_enabled\": false,\n" " \"favourites_count\": 0,\n" " \"utc_offset\": -28800,\n" " \"id\": 203398982,\n" " \"listed_count\": 0,\n", " \"profile_use_background_image\": true,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 16,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"131516\",\n" " \"geo_enabled\": false,\n" " \"time_zone\": \"Pacific Time (US & Canada)\",\n" " \"notifications\": null,\n" " \"description\": \"I'm single\\u01aa(\\u02c7\\u25bc\\u02c7)\\u00ac, pin: 26B49EFA , keep follow me\\u01aa(\\u02c7\\u25bc\\u02c7)\\u00ac\\u01aa(\\u02c7\\u25bc\\u02c7)\\u00ac follback? just mention, thanks\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a2.twimg.com\\/profile_background_images\\/238078679\\/5496743274_fb1f9c9bea_z_large.jpg\",\n" " \"statuses_count\": 899,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 14,\n" " \"show_all_inline_media\": false,\n" " \"screen_name\": \"IntaaanRvall\",\n" " \"following\": null\n" " },\n" " \"source\": \"web\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:48 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143452560896000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"\\u3042\\u3042\\u3042\\u3042\\u3042\\u3042\\u3042\\u3001\\u4eca\\u65e5\\u306e\\u30d7\\u30ea\\u30ad\\u30e5\\u30a2\\u30de\\u30b8\\u6700\\u9ad8\\u3060\\u3063\\u305f\\u3002\\u3082\\u3046\\u30c6\\u30f3\\u30b7\\u30e7\\u30f3\\u4e0b\\u304c\\u3089\\u306d\\u30fc\\u3088\\u3002\\u8272\\u3005\\u8a9e\\u308a\\u305f\\u3044\\u3051\\u3069\\u30c4\\u30a4\\u30c3\\u30bf\\u30fc\\u3058\\u3083\\u4f55\\u56de\\u30c4\\u30a4\\u30fc\\u30c8\\u3057\\u305f\\u3089\\u3044\\u3044\\u306e\\uff1f\\u3063\\u3066\\u611f\\u3058\\u3068\\u308a\\u3042\\u3048\\u305a\\u98a8\\u5442\\u5165\\u3063\\u3066\\u982d\\u6574\\u7406\\u3057\\u3066\\u30d0\\u30ec\\u30b9\\u30ec\\uff06\\u30b3\\u30df\\u30e5\\u898b\\u3066\\u305d\\u308c\\u304b\\u3089\\u65e5\\u8a18\\u66f8\\u304f\",\n" " \"id\": 62143452560896000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n", " \"name\": \"\\u5929\\u5bae\\u3000\\u5948\\u6f84\",\n" " \"profile_sidebar_border_color\": \"db5ecc\",\n" " \"profile_background_tile\": false,\n" " \"profile_sidebar_fill_color\": \"ffcced\",\n" " \"profile_image_url\": \"http:\\/\\/a1.twimg.com\\/profile_images\\/1260667542\\/kanon2_normal.jpg\",\n" " \"created_at\": \"Tue Dec 29 11:35:38 +0000 2009\",\n" " \"location\": \"\\u8679\\u306e\\u5712\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"5109eb\",\n" " \"id_str\": \"100203655\",\n" " \"url\": \"http:\\/\\/pudding-tension.cocolog-nifty.com\\/blog\\/\",\n" " \"default_profile\": false,\n" " \"contributors_enabled\": false,\n" " \"favourites_count\": 0,\n" " \"utc_offset\": 32400,\n" " \"id\": 100203655,\n" " \"listed_count\": 3,\n" " \"profile_use_background_image\": true,\n" " \"lang\": \"ja\",\n" " \"protected\": false,\n" " \"followers_count\": 32,\n" " \"profile_text_color\": \"372c47\",\n" " \"profile_background_color\": \"a18eed\",\n" " \"geo_enabled\": false,\n" " \"time_zone\": \"Tokyo\",\n" " \"notifications\": null,\n" " \"description\": \"\\u73fe\\u5728\\u8133\\u5185\\u306f\\u305d\\u306e\\u6b86\\u3069\\u304c\\u300c\\u30d7\\u30ea\\u30ad\\u30e5\\u30a2\\u300d\\u3068\\u300c\\u3046\\u307f\\u306d\\u3053\\u306e\\u306a\\u304f\\u9803\\u306b\\u300d\\u3068\\u300c\\u795e\\u306e\\u307f\\u305e\\u77e5\\u308b\\u30bb\\u30ab\\u30a4\\u300d\\u3067\\u69cb\\u6210\\u3055\\u308c\\u3066\\u307e\\u3059\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_background_images\\/183152065\\/haikei.png\",\n" " \"statuses_count\": 4404,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 26,\n" " \"show_all_inline_media\": false,\n" " \"screen_name\": \"amamiya_nasumi\",\n" " \"following\": null\n" " },\n" " \"source\": \"web\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:48 +0000 2011\",\n" " \"favorited\": false,\n", " \"truncated\": false,\n" " \"id_str\": \"62143451512320000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"\\/\\/BRB..shower time!! :)\",\n" " \"id\": 62143451512320000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"narcissa malfoy\",\n" " \"profile_sidebar_border_color\": \"eb1d57\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"ff70d2\",\n" " \"profile_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_images\\/1240524583\\/8156217_normal.gif\",\n" " \"created_at\": \"Thu Feb 10 18:25:02 +0000 2011\",\n" " \"location\": \"~*Malfoy Manor*~\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"b30098\",\n" " \"id_str\": \"250247515\",\n" " \"url\": \"http:\\/\\/www.harrypottercookbook-amanda.blogspot.com\\/\",\n" " \"default_profile\": false,\n" " \"favourites_count\": 167,\n" " \"contributors_enabled\": false,\n" " \"utc_offset\": null,\n" " \"id\": 250247515,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 10,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 219,\n" " \"profile_text_color\": \"8f178f\",\n" " \"profile_background_color\": \"f70f5c\",\n" " \"time_zone\": null,\n" " \"geo_enabled\": false,\n" " \"notifications\": null,\n" " \"description\": \"Spoiled pureblood fanatic, wife of Lucius Malfoy, mother of Draco,eve, lisa,&chasity. Pregnant and in love with yaxley_death (muilti-rp 18+) Life is good!\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_background_images\\/203844238\\/aslongasyourmine.jpg\",\n" " \"statuses_count\": 4128,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 100,\n" " \"screen_name\": \"Mrs_N_Malfoy\",\n" " \"show_all_inline_media\": false,\n", " \"following\": null\n" " },\n" " \"source\": \"web\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:47 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143451097088000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"\\u3066\\u304b\\u3001\\u4eca\\u65e5\\u306e\\u85e4\\u5d0e\\u53f0\\u30b4\\u30df\\u7f6e\\u3044\\u3066\\u304f\\u4eba\\u591a\\u3059\\u304e( *\\uff40\\u03c9\\u00b4) \\u30d3\\u30cb\\u30fc\\u30eb\\u30b7\\u30fc\\u30c8\\u3068\\u304b\\u3001\\u304a\\u5f01\\u5f53\\u3068\\u304b\\uff01\\uff01\\u81ea\\u5206\\u3067\\u51fa\\u3057\\u305f\\u30b4\\u30df\\u3050\\u3089\\u3044\\u81ea\\u5206\\u3067\\u6368\\u3066\\u3093\\u304b\\u3044( *\\uff40\\u03c9\\u00b4) ( *\\uff40\\u03c9\\u00b4) \\u6368\\u3066\\u3089\\u308c\\u3093\\u306e\\u306a\\u3089\\u3001\\u4f55\\u3082\\u6301\\u3063\\u3066\\u304f\\u3093\\u306a\\u3057\\uff01\\uff01\",\n" " \"id\": 62143451097088000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"misa62@\\u30d1\\u30f3\\u796d\\u308a\\u30c0\\uff01\\uff01\",\n" " \"profile_sidebar_border_color\": \"5ED4DC\",\n" " \"profile_background_tile\": false,\n" " \"profile_sidebar_fill_color\": \"95E8EC\",\n" " \"profile_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_images\\/1270879463\\/3264b67a-f15f-499e-9c0c-0fb3bbbac7e1_normal.png\",\n" " \"created_at\": \"Mon May 03 15:36:08 +0000 2010\",\n" " \"location\": \"\\u798f\\u5ca1\\u770c\\u798f\\u5ca1\\u5e02\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"0099B9\",\n" " \"id_str\": \"139753239\",\n" " \"url\": null,\n" " \"default_profile\": false,\n" " \"favourites_count\": 56,\n" " \"contributors_enabled\": false,\n" " \"utc_offset\": -36000,\n" " \"id\": 139753239,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 44,\n" " \"lang\": \"ja\",\n", " \"protected\": false,\n" " \"followers_count\": 260,\n" " \"profile_text_color\": \"3C3940\",\n" " \"profile_background_color\": \"0099B9\",\n" " \"time_zone\": \"Hawaii\",\n" " \"geo_enabled\": false,\n" " \"notifications\": null,\n" " \"description\": \"\\u9e7f\\u5150\\u5cf6\\u770c\\u85a9\\u6469\\u5ddd\\u5185\\u5e02\\u51fa\\u8eab\\u3002\\n\\u73fe\\u5728\\u798f\\u5ca1\\u5e02\\u535a\\u591a\\u533a\\u5728\\u4f4f\\u3002\\n\\u91ce\\u7403\\u306f\\u9df9\\u515a(\\u5fdc\\u63f4\\u306f\\u58f0\\u51fa\\u3057\\u6d3e)\\u3002\\n\\u97f3\\u697d\\u306f\\u3086\\u305a(\\u6ce3\\u304d\\u307c\\u304f\\u308d\\u6d3e)\\u3002\\n\\u30ea\\u30a2\\u30eb\\u30a2\\u30e9\\u30b5\\u30fc(\\u672c\\u6c17\\u3067\\u30ea\\u30a2\\u30eb)\\u3002\\n\\u53cc\\u5b50(\\u591a\\u5206\\u4e8c\\u5375\\u6027)\\u3002\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/a\\/1302646548\\/images\\/themes\\/theme4\\/bg.gif\",\n" " \"statuses_count\": 10218,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 189,\n" " \"screen_name\": \"umeimouto\",\n" " \"show_all_inline_media\": false,\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/twipple.jp\\/\\\" rel=\\\"nofollow\\\"\\u003E\\u3064\\u3044\\u3063\\u3077\\u308b for iPhone\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:47 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143450660864000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Good luck buat semua angkatan 2011,semoga lulus 100% amin!\",\n" " \"id\": 62143450660864000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Rifqi Agata Fadillah\",\n" " \"profile_sidebar_border_color\": \"C0DEED\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"DDEEF6\",\n" " \"profile_image_url\": \"http:\\/\\/a2.twimg.com\\/profile_images\\/1318083009\\/286099563_normal.jpg\",\n", " \"created_at\": \"Sat Nov 27 07:42:50 +0000 2010\",\n" " \"location\": \"\\u00dcT: -6.201772,106.766764\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"0084B4\",\n" " \"id_str\": \"220266344\",\n" " \"url\": null,\n" " \"default_profile\": false,\n" " \"favourites_count\": 32,\n" " \"contributors_enabled\": false,\n" " \"utc_offset\": -28800,\n" " \"id\": 220266344,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 0,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 145,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"C0DEED\",\n" " \"time_zone\": \"Pacific Time (US & Canada)\",\n" " \"geo_enabled\": false,\n" " \"notifications\": null,\n" " \"description\": \"SQZ 75 2011| WANTED family| @JumpToHigh - bassist|F5BF\\r|S.O.W|\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_background_images\\/228932382\\/asasasasas.jpg\",\n" " \"statuses_count\": 2906,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 139,\n" " \"screen_name\": \"rifqifadilah\",\n" " \"show_all_inline_media\": false,\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/www.snaptu.com\\\" rel=\\\"nofollow\\\"\\u003ESnaptu\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:47 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143449721344000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Sip insyaaloh yam haha RT @IyamSitiPurnama: @ayusucia yu besok bareng yaaah!! Jam 8an aja. Plgnya kita main. Okay?\",\n" " \"id\": 62143449721344000,\n", " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Ayu Sucianti Pratiwi\",\n" " \"profile_sidebar_border_color\": \"000000\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"33c7cc\",\n" " \"profile_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_images\\/1261651576\\/Photo005_normal.jpg\",\n" " \"created_at\": \"Fri Aug 28 11:31:34 +0000 2009\",\n" " \"location\": \"Bandung, Indonesia\",\n" " \"profile_link_color\": \"ae2ccf\",\n" " \"is_translator\": false,\n" " \"id_str\": \"69565800\",\n" " \"follow_request_sent\": null,\n" " \"url\": null,\n" " \"contributors_enabled\": false,\n" " \"default_profile\": false,\n" " \"favourites_count\": 0,\n" " \"utc_offset\": -25200,\n" " \"id\": 69565800,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 1,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 141,\n" " \"profile_text_color\": \"143d42\",\n" " \"profile_background_color\": \"352726\",\n" " \"geo_enabled\": true,\n" " \"time_zone\": \"Mountain Time (US & Canada)\",\n" " \"notifications\": null,\n" " \"description\": \"SMAN 1 BANDUNG '11\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a0.twimg.com\\/profile_background_images\\/228896383\\/Face_In_The_Crowd_by_smashmethod.jpg\",\n" " \"default_profile_image\": false,\n" " \"friends_count\": 82,\n" " \"statuses_count\": 1885,\n" " \"show_all_inline_media\": false,\n" " \"screen_name\": \"ayusucia\",\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/www.snaptu.com\\\" rel=\\\"nofollow\\\"\\u003ESnaptu\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " }, ", " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:46 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143443954176000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Fuck youuuuuu very much.\",\n" " \"id\": 62143443954176000,\n" " \"in_reply_to_status_id_str\": null,\n", " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"MayJ Tumulak\",\n" " \"profile_sidebar_border_color\": \"FFFFFF\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"a1908f\",\n" " \"profile_image_url\": \"http:\\/\\/a0.twimg.com\\/profile_images\\/1248744054\\/182023_1696887156113_1655881256_1550554_2790545_n_normal.jpg\",\n" " \"created_at\": \"Wed Mar 31 15:20:30 +0000 2010\",\n" " \"location\": \"Cebu, Philippines.\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"e8dc33\",\n" " \"id_str\": \"128247577\",\n" " \"url\": \"http:\\/\\/mayjornerd.tumblr.com\\/\",\n" " \"default_profile\": false,\n" " \"contributors_enabled\": false,\n" " \"favourites_count\": 23,\n" " \"utc_offset\": 28800,\n" " \"id\": 128247577,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 5,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 200,\n" " \"profile_text_color\": \"db048c\",\n" " \"profile_background_color\": \"000000\",\n" " \"time_zone\": \"Hong Kong\",\n" " \"geo_enabled\": false,\n" " \"notifications\": null,\n" " \"description\": \"Josh Duhamel, Emmanuelle Vaugier, Eddie Cahill, Paget Brewster and Thomas Gibson. Stana Katic. I LOVE THEM. \\u2665\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a2.twimg.com\\/profile_background_images\\/124406615\\/AAB1408.jpg\",\n" " \"statuses_count\": 4811,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 275,\n" " \"screen_name\": \"MayJT17\",\n" " \"show_all_inline_media\": false,\n" " \"following\": null\n" " },\n" " \"source\": \"web\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n", " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:45 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143439344640000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Menurutmuuuuuu emememRT @ariesgbgn: Masak di makanin..ckck RT @rindagustina: Emg makan sendiriRT @ariesgbgn: Makan aja sendiri..haha R\",\n" " \"id\": 62143439344640000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Rinda Citra Avanti\",\n" " \"profile_sidebar_border_color\": \"f20938\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"d3dee8\",\n" " \"profile_image_url\": \"http:\\/\\/a0.twimg.com\\/profile_images\\/1318218525\\/phpJYyKtG_normal\",\n" " \"created_at\": \"Tue Nov 23 12:19:01 +0000 2010\",\n" " \"location\": \"Pasadena, Semarang \",\n" " \"profile_link_color\": \"090a09\",\n" " \"is_translator\": false,\n" " \"id_str\": \"218856519\",\n" " \"follow_request_sent\": null,\n" " \"url\": \"http:\\/\\/m.facebook.com\\/profile.php?id=1850197456&refid=17\",\n" " \"contributors_enabled\": false,\n" " \"default_profile\": false,\n" " \"favourites_count\": 122,\n" " \"utc_offset\": -28800,\n" " \"id\": 218856519,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 1,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 301,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"f03046\",\n" " \"geo_enabled\": false,\n" " \"time_zone\": \"Pacific Time (US & Canada)\",\n" " \"notifications\": null,\n" " \"description\": \"Low profile | Simple | o2 December 2o1o \\u2665\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_background_images\\/199969730\\/76456_105694036168812_100001846488330_42447_4503930_n.jpg\",\n", " \"default_profile_image\": false,\n" " \"friends_count\": 202,\n" " \"statuses_count\": 11353,\n" " \"show_all_inline_media\": false,\n" " \"screen_name\": \"rindagustina\",\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/ubersocial.com\\\" rel=\\\"nofollow\\\"\\u003E\\u00dcberSocial\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:45 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143439235584000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Hate wearing dresses, now I gotta sit with my legs shut.\",\n" " \"id\": 62143439235584000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Alexis Sparrow\",\n" " \"profile_sidebar_border_color\": \"eb157d\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"ff8ae4\",\n" " \"profile_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_images\\/1285784046\\/110324-160733_normal.jpg\",\n" " \"created_at\": \"Thu Feb 10 03:34:07 +0000 2011\",\n" " \"location\": \"four one two.\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"6b1f58\",\n" " \"id_str\": \"249956435\",\n" " \"url\": null,\n" " \"contributors_enabled\": false,\n" " \"default_profile\": false,\n" " \"favourites_count\": 0,\n" " \"utc_offset\": -21600,\n" " \"id\": 249956435,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 0,\n", " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 52,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"f099c5\",\n" " \"geo_enabled\": false,\n" " \"time_zone\": \"Central Time (US & Canada)\",\n" " \"notifications\": null,\n" " \"description\": \"#iup #teamblackberry #sixburgh (:\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a1.twimg.com\\/profile_background_images\\/236015295\\/pink.gif\",\n" " \"statuses_count\": 971,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 56,\n" " \"screen_name\": \"alexis_sparrow\",\n" " \"show_all_inline_media\": false,\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/twitter.com\\/devices\\\" rel=\\\"nofollow\\\"\\u003Etxt\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:44 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143437247488000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Net ppas wakker:o ZONDE!!\",\n" " \"id\": 62143437247488000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Rohit\",\n" " \"profile_sidebar_border_color\": \"C0DEED\",\n" " \"profile_background_tile\": false,\n" " \"profile_sidebar_fill_color\": \"DDEEF6\",\n" " \"profile_image_url\": \"http:\\/\\/a0.twimg.com\\/profile_images\\/1305531627\\/IMG-20110404-00125_normal.jpg\",\n" " \"created_at\": \"Sun Feb 06 16:34:11 +0000 2011\",\n" " \"location\": \"The Hague\",\n", " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"0084B4\",\n" " \"id_str\": \"248263091\",\n" " \"is_translator\": false,\n" " \"url\": \"http:\\/\\/www.roo11.hyves.nl\",\n" " \"contributors_enabled\": false,\n" " \"favourites_count\": 0,\n" " \"default_profile\": true,\n" " \"utc_offset\": null,\n" " \"id\": 248263091,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 0,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 17,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"C0DEED\",\n" " \"geo_enabled\": false,\n" " \"time_zone\": null,\n" " \"notifications\": null,\n" " \"description\": \"Bb ping, just ask! X\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/a\\/1302724321\\/images\\/themes\\/theme1\\/bg.png\",\n" " \"default_profile_image\": false,\n" " \"friends_count\": 102,\n" " \"statuses_count\": 257,\n" " \"show_all_inline_media\": false,\n" " \"screen_name\": \"prince__ro\",\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/blackberry.com\\/twitter\\\" rel=\\\"nofollow\\\"\\u003ETwitter for BlackBerry\\u00ae\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:44 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143434932224000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"HaPpY eAsTeR pEePs!!!\",\n" " \"id\": 62143434932224000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n", " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Chris Curzon\",\n" " \"profile_sidebar_border_color\": \"65B0DA\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"7AC3EE\",\n" " \"profile_image_url\": \"http:\\/\\/a2.twimg.com\\/profile_images\\/1239641260\\/image_normal.jpg\",\n" " \"created_at\": \"Wed Jun 17 15:35:33 +0000 2009\",\n" " \"location\": \"Wilmslow, Cheshire, U.K\",\n" " \"is_translator\": false,\n" " \"profile_link_color\": \"FF0000\",\n" " \"follow_request_sent\": null,\n" " \"id_str\": \"47998574\",\n" " \"url\": \"http:\\/\\/www.chriscurzon.co.uk\",\n" " \"default_profile\": false,\n" " \"contributors_enabled\": false,\n" " \"favourites_count\": 2,\n" " \"utc_offset\": 0,\n" " \"id\": 47998574,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 0,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 16,\n" " \"profile_text_color\": \"3D1957\",\n" " \"profile_background_color\": \"642D8B\",\n" " \"time_zone\": \"London\",\n" " \"geo_enabled\": false,\n" " \"notifications\": null,\n" " \"description\": \"\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a2.twimg.com\\/a\\/1302214109\\/images\\/themes\\/theme10\\/bg.gif\",\n" " \"statuses_count\": 186,\n" " \"friends_count\": 72,\n" " \"default_profile_image\": false,\n" " \"screen_name\": \"ChrisCurzon\",\n" " \"show_all_inline_media\": false,\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/twitter.com\\/\\\" rel=\\\"nofollow\\\"\\u003ETwitter for iPhone\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n", " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:43 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143434101760000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"sadaaaapp...jawaban yg bijak *salut* hahahaha RT @ade_agus_rahman: Biar waktu yg menjawabna hahahahaRT @CSuhendra:... http:\\/\\/mtw.tl\\/lqdn3si\",\n" " \"id\": 62143434101760000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"christian suhendra\",\n" " \"profile_sidebar_border_color\": \"ffef0f\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"efefef\",\n" " \"profile_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_images\\/1306502119\\/172657_1754759681733_1621188498_1678640_1734292_o_normal.jpg\",\n" " \"created_at\": \"Tue Jul 14 14:02:20 +0000 2009\",\n" " \"location\": \"\",\n" " \"is_translator\": false,\n" " \"profile_link_color\": \"ba7309\",\n" " \"follow_request_sent\": null,\n" " \"id_str\": \"56700895\",\n" " \"url\": \"http:\\/\\/www.facebook.com\\/?ref=home#!\\/christian.suhendra\",\n" " \"default_profile\": false,\n" " \"contributors_enabled\": false,\n" " \"favourites_count\": 0,\n" " \"utc_offset\": -36000,\n" " \"id\": 56700895,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 9,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 225,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"131516\",\n" " \"time_zone\": \"Hawaii\",\n" " \"geo_enabled\": true,\n" " \"notifications\": null,\n" " \"description\": \"it's not about me , it's all about style..HAHA\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a1.twimg.com\\/profile_background_images\\/166923240\\/maryPraying1024.jpg\",\n" " \"statuses_count\": 5705,\n", " \"friends_count\": 256,\n" " \"default_profile_image\": false,\n" " \"screen_name\": \"CSuhendra\",\n" " \"show_all_inline_media\": false,\n" " \"following\": null\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/m.tweete.net\\\" rel=\\\"nofollow\\\"\\u003Em.tweete.net\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:43 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143433577472000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Feliz ressurrei\\u00e7\\u00e3o de Jesus Cristo. http:\\/\\/tumblr.com\\/xye28y8fgp\",\n" " \"id\": 62143433577472000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Elisa\",\n" " \"profile_sidebar_border_color\": \"ffffff\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"ffffff\",\n" " \"profile_image_url\": \"http:\\/\\/a0.twimg.com\\/profile_images\\/1245238667\\/DSC03818_normal.JPG\",\n" " \"created_at\": \"Sat Apr 03 20:55:57 +0000 2010\",\n" " \"location\": \"\",\n" " \"follow_request_sent\": null,\n" " \"profile_link_color\": \"ff5c82\",\n" " \"id_str\": \"129297077\",\n" " \"is_translator\": false,\n" " \"url\": null,\n" " \"contributors_enabled\": false,\n" " \"favourites_count\": 0,\n" " \"default_profile\": false,\n" " \"utc_offset\": -10800,\n" " \"id\": 129297077,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 1,\n", " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 61,\n" " \"profile_text_color\": \"ff4c76\",\n" " \"profile_background_color\": \"ffffff\",\n" " \"time_zone\": \"Brasilia\",\n" " \"notifications\": null,\n" " \"description\": \"eu fa\\u00e7o da dificuldade a minha motiva\\u00e7\\u00e3o.\",\n" " \"geo_enabled\": false,\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a1.twimg.com\\/profile_background_images\\/230245704\\/tumblr_lj97wofglY1qb67gho1_500_large.jpg\",\n" " \"statuses_count\": 1287,\n" " \"default_profile_image\": false,\n" " \"friends_count\": 175,\n" " \"screen_name\": \"eliisarocha\",\n" " \"following\": null,\n" " \"show_all_inline_media\": false\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/www.tumblr.com\\/\\\" rel=\\\"nofollow\\\"\\u003ETumblr\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:43 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143432310784000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"\\u3053\\u308c\\u3067\\u30e9\\u30b9\\u67a0\\u304b\\u306a\\uff5e\",\n" " \"id\": 62143432310784000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"\\u30b7\\u30ab\\u30c8\\uff20Mr.\\u5668\\u7528\\u8ca7\\u4e4f\",\n" " \"profile_sidebar_border_color\": \"C0DEED\",\n" " \"profile_background_tile\": false,\n" " \"profile_sidebar_fill_color\": \"DDEEF6\",\n" " \"profile_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_images\\/1204747446\\/100819_1913_010001_normal.jpg\",\n" " \"created_at\": \"Sat Nov 13 02:55:41 +0000 2010\",\n" " \"location\": \"\\u30b7\\u30ab\\u30c8\\u306e\\u306a\\u3093\\u3068\\u306a\\u304f\\u30cb\\u30b3\\u751f(\\u6c5a)\",\n", " \"profile_link_color\": \"0084B4\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"id_str\": \"215139533\",\n" " \"url\": \"http:\\/\\/com.nicovideo.jp\\/community\\/co568211\",\n" " \"default_profile\": true,\n" " \"favourites_count\": 0,\n" " \"contributors_enabled\": false,\n" " \"utc_offset\": 32400,\n" " \"id\": 215139533,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 1,\n" " \"lang\": \"ja\",\n" " \"protected\": false,\n" " \"followers_count\": 17,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"C0DEED\",\n" " \"time_zone\": \"Tokyo\",\n" " \"geo_enabled\": false,\n" " \"notifications\": null,\n" " \"description\": \"\\u4e00\\u822c\\u5927\\u5b66\\u751f\\u517c\\u3001\\u30a2\\u30cb\\u30b2\\u30fc\\u30fb\\u30e1\\u30bf\\u30eb\\u30d0\\u30f3\\u30c9\\u30c9\\u30e9\\u30de\\u30fc\\u517cAO\\u52e2\\u3084\\u3063\\u3066\\u307e\\u3059\\u2605 \\u30b3\\u30df\\u30e5\\u3067\\u306fAO\\u52e2\\u6d3e\\u751f\\u30d7\\u30ed\\u30b8\\u30a7\\u30af\\u30c8\\u3068\\u3057\\u3066\\u3001\\u79c1\\u3092\\u542b\\u3081\\u30e1\\u30f3\\u30d0\\u30fc\\u306e\\u65b9\\u3005\\u304c\\u751f\\u653e\\u9001\\u3092\\u884c\\u3063\\u3066\\u304a\\u308a\\u307e\\u3059\\u266a \\u79c1\\u306e\\u653e\\u9001\\u3067\\u306f\\u3001\\u30e9\\u30b8\\u30aa\\u7684\\u30ea\\u30b9\\u30ca\\u30fc\\u53c2\\u52a0\\u578b\\u306e\\u30b9\\u30bf\\u30a4\\u30eb\\u3067\\u653e\\u9001\\u4e2d\\u3067\\u3059\\u2605 \\u8a71\\u984c\\u306b\\u95a2\\u3057\\u3066\\u306f\\u30b8\\u30e3\\u30f3\\u30eb\\u554f\\u308f\\u305a\\u3001\\u5668\\u7528\\u8ca7\\u4e4f\\u3092\\u767a\\u63ee\\u3057\\u3066\\u307e\\u3059\\u266a\\u266a\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/a\\/1303316982\\/images\\/themes\\/theme1\\/bg.png\",\n" " \"default_profile_image\": false,\n" " \"statuses_count\": 526,\n" " \"friends_count\": 10,\n" " \"screen_name\": \"Shikato_Drs_AO\",\n" " \"following\": null,\n" " \"show_all_inline_media\": false\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/twtr.jp\\\" rel=\\\"nofollow\\\"\\u003EKeitai Web\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:43 +0000 2011\",\n" " \"favorited\": false,\n", " \"truncated\": false,\n" " \"id_str\": \"62143431262208000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"casa da v\\u00f3, vo fika vo cel\",\n" " \"id\": 62143431262208000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Lucas Murbach Pierin\",\n" " \"profile_sidebar_border_color\": \"eeeeee\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"efefef\",\n" " \"profile_image_url\": \"http:\\/\\/a0.twimg.com\\/profile_images\\/1321857197\\/Twitter_normal.jpg\",\n" " \"created_at\": \"Tue Oct 12 02:14:40 +0000 2010\",\n" " \"location\": \"Lapa\\/Ctba\",\n" " \"profile_link_color\": \"009999\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"id_str\": \"201538116\",\n" " \"url\": \"http:\\/\\/xenedapuc.tumblr.com\",\n" " \"default_profile\": false,\n" " \"favourites_count\": 8,\n" " \"contributors_enabled\": false,\n" " \"utc_offset\": -10800,\n" " \"id\": 201538116,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 22,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 68,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"131516\",\n" " \"time_zone\": \"Brasilia\",\n" " \"geo_enabled\": true,\n" " \"notifications\": null,\n" " \"description\": \"So um Pi\\u00e1 bm gnt boa, de gosto musical ecl\\u00e9tico + prefiro um bom Rock n' Roll, Curto anda de Bike e joga um futeba d veiz incuando e Atleticano com orgulho. =D \",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/profile_background_images\\/206676494\\/twitter_pattern_background_by_ainon.jpg\",\n" " \"default_profile_image\": false,\n" " \"statuses_count\": 5470,\n" " \"friends_count\": 145,\n", " \"screen_name\": \"Xeneral\",\n" " \"following\": null,\n" " \"show_all_inline_media\": false\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/www.tweetdeck.com\\\" rel=\\\"nofollow\\\"\\u003ETweetDeck\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:43 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143430956032000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"ATSUSHI\\u75e9\\u305b\\u305f\\uff1f\",\n" " \"id\": 62143430956032000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"yui\",\n" " \"profile_sidebar_border_color\": \"CC3366\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"E5507E\",\n" " \"profile_image_url\": \"http:\\/\\/a0.twimg.com\\/profile_images\\/1210885986\\/image_normal.jpg\",\n" " \"created_at\": \"Tue Oct 20 04:16:52 +0000 2009\",\n" " \"location\": \"MEGURO TOKYO\",\n" " \"profile_link_color\": \"B40B43\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"id_str\": \"83766274\",\n" " \"url\": \"http:\\/\\/ameblo.jp\\/yuikame61\\/\",\n" " \"default_profile\": false,\n" " \"favourites_count\": 16,\n" " \"contributors_enabled\": false,\n" " \"utc_offset\": -36000,\n" " \"id\": 83766274,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 6,\n" " \"lang\": \"ja\",\n" " \"protected\": false,\n" " \"followers_count\": 175,\n", " \"profile_text_color\": \"362720\",\n" " \"profile_background_color\": \"FF6699\",\n" " \"time_zone\": \"Hawaii\",\n" " \"geo_enabled\": false,\n" " \"notifications\": null,\n" " \"description\": \"I'm stylist's assistant^^ \\/ I love fashion,japanese reggae and hiphop\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/a\\/1302724321\\/images\\/themes\\/theme11\\/bg.gif\",\n" " \"default_profile_image\": false,\n" " \"statuses_count\": 4048,\n" " \"friends_count\": 184,\n" " \"screen_name\": \"kamewada\",\n" " \"following\": null,\n" " \"show_all_inline_media\": false\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/twitter.com\\/\\\" rel=\\\"nofollow\\\"\\u003ETwitter for iPhone\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:43 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143430540800000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"Well that's the last time I eat chocolate because of #EASTER\",\n" " \"id\": 62143430540800000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n" " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"TheRabbitsToldMe\",\n" " \"profile_sidebar_border_color\": \"C0DEED\",\n" " \"profile_background_tile\": false,\n" " \"profile_sidebar_fill_color\": \"DDEEF6\",\n" " \"profile_image_url\": \"http:\\/\\/a1.twimg.com\\/profile_images\\/1314186122\\/image_normal.jpg\",\n" " \"created_at\": \"Fri Mar 18 23:27:45 +0000 2011\",\n" " \"location\": \"Bat Country bitch!!!! :D\",\n" " \"profile_link_color\": \"0084B4\",\n" " \"is_translator\": false,\n", " \"follow_request_sent\": null,\n" " \"id_str\": \"268522712\",\n" " \"url\": null,\n" " \"default_profile\": true,\n" " \"favourites_count\": 0,\n" " \"contributors_enabled\": false,\n" " \"utc_offset\": null,\n" " \"id\": 268522712,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 0,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 33,\n" " \"profile_text_color\": \"333333\",\n" " \"profile_background_color\": \"C0DEED\",\n" " \"time_zone\": null,\n" " \"geo_enabled\": true,\n" " \"notifications\": null,\n" " \"description\": \"Sup! I am the back up singer and electric guitarist in the band Your Broken Innocence. U jealous? ps. i luv Short Stack!\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a3.twimg.com\\/a\\/1303425044\\/images\\/themes\\/theme1\\/bg.png\",\n" " \"default_profile_image\": false,\n" " \"statuses_count\": 115,\n" " \"friends_count\": 57,\n" " \"screen_name\": \"GraceShortStack\",\n" " \"following\": null,\n" " \"show_all_inline_media\": false\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/twitter.com\\/\\\" rel=\\\"nofollow\\\"\\u003ETwitter for iPhone\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " },\n" " {\n" " \n" " \"coordinates\": null,\n" " \"created_at\": \"Sun Apr 24 13:18:42 +0000 2011\",\n" " \"favorited\": false,\n" " \"truncated\": false,\n" " \"id_str\": \"62143429689344000\",\n" " \"in_reply_to_user_id_str\": null,\n" " \"contributors\": null,\n" " \"text\": \"RT @eireen37: Abis makan sop+sate kambing di kedai Ahmad Dani,recomended :q\",\n" " \"id\": 62143429689344000,\n" " \"in_reply_to_status_id_str\": null,\n" " \"retweet_count\": 0,\n" " \"geo\": null,\n", " \"retweeted\": false,\n" " \"in_reply_to_user_id\": null,\n" " \"place\": null,\n" " \"user\": {\n" " \"name\": \"Yuki Endah\",\n" " \"profile_sidebar_border_color\": \"ffadff\",\n" " \"profile_background_tile\": true,\n" " \"profile_sidebar_fill_color\": \"e645db\",\n" " \"profile_image_url\": \"http:\\/\\/a2.twimg.com\\/profile_images\\/1308637078\\/Copy_of_Copy_of_DSC01894_normal.jpg\",\n" " \"created_at\": \"Wed Jul 15 04:39:42 +0000 2009\",\n" " \"location\": \"Samarinda, Indonesia\",\n" " \"profile_link_color\": \"94039c\",\n" " \"is_translator\": false,\n" " \"follow_request_sent\": null,\n" " \"id_str\": \"56926527\",\n" " \"url\": \"http:\\/\\/id-id.facebook.com\\/people\\/Yuki-Endah\\/1646561051\",\n" " \"default_profile\": false,\n" " \"favourites_count\": 39,\n" " \"contributors_enabled\": false,\n" " \"utc_offset\": 28800,\n" " \"id\": 56926527,\n" " \"profile_use_background_image\": true,\n" " \"listed_count\": 2,\n" " \"lang\": \"en\",\n" " \"protected\": false,\n" " \"followers_count\": 377,\n" " \"profile_text_color\": \"a30c64\",\n" " \"profile_background_color\": \"fafafa\",\n" " \"time_zone\": \"Kuala Lumpur\",\n" " \"geo_enabled\": true,\n" " \"notifications\": null,\n" " \"description\": \"I LOVE MUSIC. Anytime I want, I will take my time & I will take my earphone to listening my favourite songs..\\r\\n\",\n" " \"verified\": false,\n" " \"profile_background_image_url\": \"http:\\/\\/a1.twimg.com\\/profile_background_images\\/175641717\\/Sakura_1.jpg\",\n" " \"default_profile_image\": false,\n" " \"statuses_count\": 5731,\n" " \"friends_count\": 197,\n" " \"screen_name\": \"yuki_endah\",\n" " \"following\": null,\n" " \"show_all_inline_media\": true\n" " },\n" " \"source\": \"\\u003Ca href=\\\"http:\\/\\/www.snaptu.com\\\" rel=\\\"nofollow\\\"\\u003ESnaptu\\u003C\\/a\\u003E\",\n" " \"in_reply_to_screen_name\": null,\n" " \"in_reply_to_status_id\": null\n" " }\n" "]\n", NULL }; /* recent flickr photos on monday morning */ const char * doc2[] = { "{\n" " \"title\": \"Uploads from everyone\",\n" " \"link\": \"http://www.flickr.com/photos/\",\n" " \"description\": \"\",\n" " \"modified\": \"2011-04-25T11:41:03Z\",\n" " \"generator\": \"http://www.flickr.com/\",\n" " \"items\": [\n" " {\n" " \"title\": \"sylhet 963\",\n" " \"link\": \"http://www.flickr.com/photos/saifmanna/5652906125/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5268/5652906125_c113213248_m.jpg\"},\n" " \"date_taken\": \"2011-04-09T04:31:45-08:00\",\n" " \"description\": \"

saifmanna<\\/a> posted a photo:<\\/p>

\\\"sylhet<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:03Z\",\n" " \"author\": \"nobody@flickr.com (saifmanna)\",\n" " \"author_id\": \"9712792@N05\",\n" " \"tags\": \"sylhet\"\n" " },\n" " {\n" " \"title\": \"DSCN7238\",\n" " \"link\": \"http://www.flickr.com/photos/54062330@N03/5652906139/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5182/5652906139_550aa6702f_m.jpg\"},\n" " \"date_taken\": \"2011-04-25T12:26:17-08:00\",\n" " \"description\": \"

acvаrelium<\\/a> posted a photo:<\\/p>

\\\"DSCN7238\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:03Z\",\n" " \"author\": \"nobody@flickr.com (acvаrelium)\",\n" " \"author_id\": \"54062330@N03\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"Siena-014\",\n" " \"link\": \"http://www.flickr.com/photos/katharinaegarter/5652906201/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5062/5652906201_c7307b23e1_m.jpg\"},\n" " \"date_taken\": \"2011-04-22T12:51:58-08:00\",\n" " \"description\": \"

Katharina Egarter<\\/a> posted a photo:<\\/p>

\\\"Siena-014\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:05Z\",\n" " \"author\": \"nobody@flickr.com (Katharina Egarter)\",\n", " \"author_id\": \"51712997@N04\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"avd-1.jpg\",\n" " \"link\": \"http://www.flickr.com/photos/arjanvandam/5652906213/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5066/5652906213_9ed963d069_m.jpg\"},\n" " \"date_taken\": \"2011-04-25T13:41:06-08:00\",\n" " \"description\": \"

Arjan van Dam<\\/a> posted a photo:<\\/p>

\\\"avd-1.jpg\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:06Z\",\n" " \"author\": \"nobody@flickr.com (Arjan van Dam)\",\n" " \"author_id\": \"44451778@N06\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"IMG_4146\",\n" " \"link\": \"http://www.flickr.com/photos/14414603@N08/5652906245/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5148/5652906245_8e9717e8c3_m.jpg\"},\n" " \"date_taken\": \"2011-04-13T03:53:52-08:00\",\n" " \"description\": \"

A :-)<\\/a> posted a photo:<\\/p>

\\\"IMG_4146\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:06Z\",\n" " \"author\": \"nobody@flickr.com (A :-))\",\n" " \"author_id\": \"14414603@N08\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"550907i20020624_13\",\n" " \"link\": \"http://www.flickr.com/photos/ltppims/5652906275/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5022/5652906275_467d6f36ed_m.jpg\"},\n" " \"date_taken\": \"2003-02-06T09:14:11-08:00\",\n" " \"description\": \"

ltppims<\\/a> posted a photo:<\\/p>

\\\"550907i20020624_13\\\"<\\/a><\\/p>

550907i20020624_13<\\/p>\",\n" " \"published\": \"2011-04-25T11:41:08Z\",\n" " \"author\": \"nobody@flickr.com (ltppims)\",\n" " \"author_id\": \"61401047@N03\",\n" " \"tags\": \"550907i2002062413\"\n" " },\n" " {\n" " \"title\": \"P4193424\",\n" " \"link\": \"http://www.flickr.com/photos/aifromla/5652906305/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5266/5652906305_a72c1050c4_m.jpg\"},\n" " \"date_taken\": \"2011-04-25T04:41:08-08:00\",\n", " \"description\": \"

愛 from LA<\\/a> posted a photo:<\\/p>

\\\"P4193424\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:08Z\",\n" " \"author\": \"nobody@flickr.com (愛 from LA)\",\n" " \"author_id\": \"60647869@N06\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"In need of a wash but not on the last day Midland Red D9 on the last day of service 31,Dec,1979, in Leicester photo lifted from a super 8 film\",\n" " \"link\": \"http://www.flickr.com/photos/transport_photos/5652906307/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5189/5652906307_e5da6d2d29_m.jpg\"},\n" " \"date_taken\": \"2011-04-25T12:41:08-08:00\",\n" " \"description\": \"

Horsencart<\\/a> posted a photo:<\\/p>

\\\"In<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:08Z\",\n" " \"author\": \"nobody@flickr.com (Horsencart)\",\n" " \"author_id\": \"36803579@N07\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"11182862509\",\n" " \"link\": \"http://www.flickr.com/photos/58240971@N06/5652906329/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5188/5652906329_0cebae6d65_m.jpg\"},\n" " \"date_taken\": \"2011-04-25T04:41:09-08:00\",\n" " \"description\": \"

caciousclei<\\/a> posted a photo:<\\/p>

\\\"11182862509\\\"<\\/a><\\/p>

ღneslyluka ni kennethocuteღ<\\/p>\",\n" " \"published\": \"2011-04-25T11:41:09Z\",\n" " \"author\": \"nobody@flickr.com (caciousclei)\",\n" " \"author_id\": \"58240971@N06\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"Resting in the woods\",\n" " \"link\": \"http://www.flickr.com/photos/benrobson2999/5653475856/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5301/5653475856_550aa6702f_m.jpg\"},\n" " \"date_taken\": \"2011-04-24T14:23:43-08:00\",\n" " \"description\": \"

benrobson2999<\\/a> posted a photo:<\\/p>

\\\"Resting<\\/a><\\/p> \",\n", " \"published\": \"2011-04-25T11:41:03Z\",\n" " \"author\": \"nobody@flickr.com (benrobson2999)\",\n" " \"author_id\": \"59245229@N04\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"IMG_4696\",\n" " \"link\": \"http://www.flickr.com/photos/feltedpleasure/5653475918/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5188/5653475918_a06fd2400c_m.jpg\"},\n" " \"date_taken\": \"2011-04-25T08:05:11-08:00\",\n" " \"description\": \"

FeltedPleasure<\\/a> posted a photo:<\\/p>

\\\"IMG_4696\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:04Z\",\n" " \"author\": \"nobody@flickr.com (FeltedPleasure)\",\n" " \"author_id\": \"41967161@N03\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"DSC04271\",\n" " \"link\": \"http://www.flickr.com/photos/ze_ero/5653475956/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5144/5653475956_31da27478a_m.jpg\"},\n" " \"date_taken\": \"2011-04-17T09:45:21-08:00\",\n" " \"description\": \"

ze_ero<\\/a> posted a photo:<\\/p>

\\\"DSC04271\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:05Z\",\n" " \"author\": \"nobody@flickr.com (ze_ero)\",\n" " \"author_id\": \"49631749@N06\",\n" " \"tags\": \"japan kyoto arashiyama 京都 日本 嵐山 kansai 関西\"\n" " },\n" " {\n" " \"title\": \"DSC07923\",\n" " \"link\": \"http://www.flickr.com/photos/lamolda/5653475962/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5063/5653475962_8fc2b9f460_m.jpg\"},\n" " \"date_taken\": \"2011-04-24T22:44:50-08:00\",\n" " \"description\": \"

lamolda<\\/a> posted a photo:<\\/p>

\\\"DSC07923\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:05Z\",\n" " \"author\": \"nobody@flickr.com (lamolda)\",\n" " \"author_id\": \"60466736@N02\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"DSC00773\",\n", " \"link\": \"http://www.flickr.com/photos/zhanghao/5653475998/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5141/5653475998_ef1ee0de1e_m.jpg\"},\n" " \"date_taken\": \"2006-12-23T15:36:57-08:00\",\n" " \"description\": \"

贰月<\\/a> posted a photo:<\\/p>

\\\"DSC00773\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:06Z\",\n" " \"author\": \"nobody@flickr.com (贰月)\",\n" " \"author_id\": \"32806588@N00\",\n" " \"tags\": \"日本 新宿御苑 東京 出差\"\n" " },\n" " {\n" " \"title\": \"DSCF3051\",\n" " \"link\": \"http://www.flickr.com/photos/30045765@N07/5653476064/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5305/5653476064_c55cd687a1_m.jpg\"},\n" " \"date_taken\": \"2011-04-25T23:58:27-08:00\",\n" " \"description\": \"

jamerco<\\/a> posted a photo:<\\/p>

\\\"DSCF3051\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:08Z\",\n" " \"author\": \"nobody@flickr.com (jamerco)\",\n" " \"author_id\": \"30045765@N07\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"DSC_0440\",\n" " \"link\": \"http://www.flickr.com/photos/carolineteselle/5653476082/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5023/5653476082_3884a09f91_m.jpg\"},\n" " \"date_taken\": \"2011-04-20T19:29:33-08:00\",\n" " \"description\": \"

ecteselle<\\/a> posted a photo:<\\/p>

\\\"DSC_0440\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:08Z\",\n" " \"author\": \"nobody@flickr.com (ecteselle)\",\n" " \"author_id\": \"57944678@N08\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"IMG_2301\",\n" " \"link\": \"http://www.flickr.com/photos/marcolympics/5653476084/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5307/5653476084_00abc74e08_m.jpg\"},\n" " \"date_taken\": \"2010-12-14T11:52:23-08:00\",\n" " \"description\": \"

mbk28<\\/a> posted a photo:<\\/p>

\\\"IMG_2301\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:08Z\",\n", " \"author\": \"nobody@flickr.com (mbk28)\",\n" " \"author_id\": \"16181899@N00\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"shot_1303650234358\",\n" " \"link\": \"http://www.flickr.com/photos/mirtedevries/5653476086/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5145/5653476086_cb998056eb_m.jpg\"},\n" " \"date_taken\": \"2011-04-24T15:03:54-08:00\",\n" " \"description\": \"

Krullenbol1987<\\/a> posted a photo:<\\/p>

\\\"shot_1303650234358\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:08Z\",\n" " \"author\": \"nobody@flickr.com (Krullenbol1987)\",\n" " \"author_id\": \"61985194@N03\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"GWP Rochefort 2011 De Leerboom (602) (Small)\",\n" " \"link\": \"http://www.flickr.com/photos/26703364@N05/5653476088/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5307/5653476088_3fc497eea8_m.jpg\"},\n" " \"date_taken\": \"2011-03-28T09:05:21-08:00\",\n" " \"description\": \"

bertrand.demiddeleer<\\/a> posted a photo:<\\/p>

\\\"GWP<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:09Z\",\n" " \"author\": \"nobody@flickr.com (bertrand.demiddeleer)\",\n" " \"author_id\": \"26703364@N05\",\n" " \"tags\": \"\"\n" " },\n" " {\n" " \"title\": \"IMG_3650\",\n" " \"link\": \"http://www.flickr.com/photos/fatpoppadaddys/5653476104/\",\n" " \"media\": {\"m\":\"http://farm6.static.flickr.com/5183/5653476104_462f44a3e5_m.jpg\"},\n" " \"date_taken\": \"2011-04-22T00:26:40-08:00\",\n" " \"description\": \"

fatpoppadaddys<\\/a> posted a photo:<\\/p>

\\\"IMG_3650\\\"<\\/a><\\/p> \",\n" " \"published\": \"2011-04-25T11:41:09Z\",\n" " \"author\": \"nobody@flickr.com (fatpoppadaddys)\",\n" " \"author_id\": \"28382183@N04\",\n" " \"tags\": \"efs1855mmf3556\"\n" " }\n" " ]\n" "}\n", NULL }; /* commits on the yajl 2.x branch */ const char * doc3[] = { "{\"commits\":[{\"parents\":[{\"id\":\"1b9995a0a341096afdf3e13a70f2185e438c4452\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/0d5000f0ad0ef9d94bd2bbcf2188b813a60d452a\",\"id\":\"0d5000f0ad0ef9d94bd2bbcf2188b813a60d452a\",\"committed_date\":\"2011-04-24T11:48:34-07:00\",\"authored_date\":\"2011-04-24T11:48:34-07:00\",\"message\":\"update docs for perf gains with yajl_dont_validate_strings\",\"tree\":\"af70481aad00b4ce9e2f23cdd23e58d735c50072\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"453aa706cc86425bea35195e454f80941a7fbc4a\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/1b9995a0a341096afdf3e13a70f2185e438c4452\",\"id\":\"1b9995a0a341096afdf3e13a70f2185e438c4452\",\"committed_date\":\"2011-04-24T07:10:58-07:00\",\"authored_date\":\"2011-04-24T07:10:58-07:00\",\"message\":\"first pass at a little in-tree perf test for a stable way to quantify optimization efforts\",\"tree\":\"39884f09d59312dbeea4a7ab7d46a56320cb986c\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"25133e5508b979fdf6814832d4355f46bd26db43\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/453aa706cc86425bea35195e454f80941a7fbc4a\",\"id\":\"453aa706cc86425bea35195e454f80941a7fbc4a\",\"committed_date\":\"2011-04-24T07:06:14-07:00\",\"authored_date\":\"2011-04-24T07:06:14-07:00\",\"message\":\"fix debug compile error\",\"tree\":\"e10ab42ec2577bc19163222f445532958fe51f3b\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"b36a8bd294cbeeaab7149402f369fdd9be95aec1\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/25133e5508b979fdf6814832d4355f46bd26db43\",\"id\":\"25133e5508b979fdf6814832d4355f46bd26db43\",\"committed_date\":\"2011-04-23T12:42:19-07:00\",\"authored_date\":\"2011-04-23T12:42:19-07:00\",\"message\":\"documentation updates\",\"tree\":\"e49e7296c1f82f78f359636ce6aa600e7c3ef73a\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"9bf2ad882bb98710949b1e3262bddff67845bb87\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/b36a8bd294cbeeaab7149402f369fdd9be95aec1\",\"id\":\"b36a8bd294cbeeaab7149402f369fdd9be95aec1\",\"committed_date\":\"2011-04-23T10:17:35-07:00\",\"authored_date\":\"2011-04-23T10:17:35-07:00\",\"message\":\"update documentation and tighten API for yajl_tree.h, inline several structures so a reader can grok the structure in hopefully one pass without jumping all over the file.\",\"tree\":\"7e2ab759926148ad03d1931c8a768abe5301bff9\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"69a9c263b5e3c2019dc258d3e75c95ad7267ea16\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/9bf2ad882bb98710949b1e3262bddff67845bb87\",\"id\":\"9bf2ad882bb98710949b1e3262bddff67845bb87\",\"committed_date\":\"2011-04-22T18:21:52-07:00\",\"authored_date\":\"2011-04-22T18:21:52-07:00\",\"message\":\"move unnec. includes out of public api, more yajl_type propogation\",\"tree\":\"f30c2f4962abb020a64d0bc4773db1b704053b1d\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"d24690ee5cc09ea2cf6bbd152f2627e8ee1986e7\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/69a9c263b5e3c2019dc258d3e75c95ad7267ea16\",\"id\":\"69a9c263b5e3c2019dc258d3e75c95ad7267ea16\",\"committed_date\":\"2011-04-22T18:17:44-07:00\",\"authored_date\":\"2011", "-04-22T18:17:44-07:00\",\"message\":\"change types from preprocessor macros to an enum, add yajl_t_any for use with yajl_tree_get()\",\"tree\":\"46f88aa049c3016e68a93463ff265fcdd38d879a\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"8e5d0b15415c6422365f6ececff5190499b43bd5\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/d24690ee5cc09ea2cf6bbd152f2627e8ee1986e7\",\"id\":\"d24690ee5cc09ea2cf6bbd152f2627e8ee1986e7\",\"committed_date\":\"2011-04-22T18:11:55-07:00\",\"authored_date\":\"2011-04-22T18:11:55-07:00\",\"message\":\"reduce output noise during testing\",\"tree\":\"c92162f0875998309e33af415510db3ecd592559\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"dd18f6182e58bb81368b30d33262e58fca7a532c\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/8e5d0b15415c6422365f6ececff5190499b43bd5\",\"id\":\"8e5d0b15415c6422365f6ececff5190499b43bd5\",\"committed_date\":\"2011-04-22T16:05:38-07:00\",\"authored_date\":\"2011-04-22T16:05:38-07:00\",\"message\":\"fix compiler warning. he's right.\",\"tree\":\"b7350153b2d9ba99e83540a0caaca73b6ac8367f\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"aedaa9e449e03af866c0e594014cd7e78dc7c98b\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/dd18f6182e58bb81368b30d33262e58fca7a532c\",\"id\":\"dd18f6182e58bb81368b30d33262e58fca7a532c\",\"committed_date\":\"2011-04-22T15:52:23-07:00\",\"authored_date\":\"2011-04-22T15:52:23-07:00\",\"message\":\"add a couple convenience routines for dealing with numbers, more copious yajl_tree reformatting\",\"tree\":\"e7767ad0ded6924ee6d9af4b59842148f9409cd6\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"baf9c39797fce24b89398a3e94ff27ae4074867a\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/aedaa9e449e03af866c0e594014cd7e78dc7c98b\",\"id\":\"aedaa9e449e03af866c0e594014cd7e78dc7c98b\",\"committed_date\":\"2011-04-22T15:38:55-07:00\",\"authored_date\":\"2011-04-22T15:38:55-07:00\",\"message\":\"object keys should just be bare strings, the indirection is useless\",\"tree\":\"73dc7fb46872a78d6516fadb2197519d8d6ac3f0\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"742a1cd7c66d64d45e25a016e506d555834f087b\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/baf9c39797fce24b89398a3e94ff27ae4074867a\",\"id\":\"baf9c39797fce24b89398a3e94ff27ae4074867a\",\"committed_date\":\"2011-04-22T15:32:59-07:00\",\"authored_date\":\"2011-04-22T15:32:59-07:00\",\"message\":\"be terse & piss all over that tree.\",\"tree\":\"6103a99867b21a5d844bb84eb49e84c4f393d1ec\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"86f5093024d434eb989c4d6c7ad657a31f5f4bf1\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/742a1cd7c66d64d45e25a016e506d555834f087b\",\"id\":\"742a1cd7c66d64d45e25a016e506d555834f087b\",\"committed_date\":\"2011-04-22T14:53:32-07:00\",\"authored_date\":\"2011-04-22T14:53:32-07:00\",\"message\":\"cosmetic, indention and code formatting for yajl_tree\",\"tree\":\"0c883d58cfd69bfaba84a54be4912dd2edb86095\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"b53a6cb3ee91d2a7765bff88e41089ce17ec7b4a\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/86f509302", "4d434eb989c4d6c7ad657a31f5f4bf1\",\"id\":\"86f5093024d434eb989c4d6c7ad657a31f5f4bf1\",\"committed_date\":\"2011-04-22T14:47:44-07:00\",\"authored_date\":\"2011-04-22T14:47:44-07:00\",\"message\":\"remove a useless level of indirection for strings\",\"tree\":\"f734163b55a78c41ca157cc90096fe0db3152737\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"e976b21748c5fd8b6ca4d28470d8a70f69890ecd\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/b53a6cb3ee91d2a7765bff88e41089ce17ec7b4a\",\"id\":\"b53a6cb3ee91d2a7765bff88e41089ce17ec7b4a\",\"committed_date\":\"2011-04-22T14:43:29-07:00\",\"authored_date\":\"2011-04-22T14:43:29-07:00\",\"message\":\"ISC license the configuration file parser example\",\"tree\":\"fe9bea332cf4a1ea8c3843035abddf64ba2a501d\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"a03bd0c9c61092f664c97a51b1b0262f8499e21b\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/e976b21748c5fd8b6ca4d28470d8a70f69890ecd\",\"id\":\"e976b21748c5fd8b6ca4d28470d8a70f69890ecd\",\"committed_date\":\"2011-04-22T14:43:13-07:00\",\"authored_date\":\"2011-04-22T14:43:13-07:00\",\"message\":\"relicense florian's contribution ISC, (still pending his approval, but I'm an optimist)\",\"tree\":\"1b4fbbf98af3ee641692e6f0ba045e8343ac2386\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"668e787b1cdba118d73efc233e8a48306c2033d6\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/a03bd0c9c61092f664c97a51b1b0262f8499e21b\",\"id\":\"a03bd0c9c61092f664c97a51b1b0262f8499e21b\",\"committed_date\":\"2011-04-22T14:40:45-07:00\",\"authored_date\":\"2011-04-22T14:40:45-07:00\",\"message\":\"talk a little bit more about this yajl_tree.h example\",\"tree\":\"e297fd14812d926f005919a1d3a28d8ad427521c\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"d2ec58b70b429b908d9f395ef378443b6101153b\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/668e787b1cdba118d73efc233e8a48306c2033d6\",\"id\":\"668e787b1cdba118d73efc233e8a48306c2033d6\",\"committed_date\":\"2011-04-22T14:39:40-07:00\",\"authored_date\":\"2011-04-22T14:39:40-07:00\",\"message\":\"initial merge/port of Florian Forster's yajl_tree implementation, along with a new utility routine yajl_tree_get() and an example\",\"tree\":\"38488d9afe9d58c47e1c6ed5c6f7ad1cbed5cd45\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"9538bda17bef60642f2ed3ff2f6bfd29785c36df\"},{\"id\":\"a7ab7633a603c6c3e31bb54a45da2afbb54a98c9\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/d2ec58b70b429b908d9f395ef378443b6101153b\",\"id\":\"d2ec58b70b429b908d9f395ef378443b6101153b\",\"committed_date\":\"2011-04-22T13:11:24-07:00\",\"authored_date\":\"2011-04-22T13:11:24-07:00\",\"message\":\"Merge branch 'parsetree' of https://github.com/octo/yajl into parsetree\",\"tree\":\"207162f20d8d97eafe0c9e899d9ffad32c36c0c2\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"bb21bcdb4ced287e7aea8285904ad3540560558a\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/9538bda17bef60642f2ed3ff2f6bfd29785c36df\",\"id\":\"9538bda17bef60642f2ed3ff2f6bfd29785c36df\",\"committed_date\":\"2011-04-22T12:17:29-07:00\",\"authored_date\":\"2011-04-22T12:17:29-07:00\",\"message\":\"Add a generator feature to validate UTF8 strings as they are written to output. closes #25\",\"tree\":\"24ebb57", "3fadebcf0387f73b3feb9a83ac2bf080d\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"9813127163116b7f928c383f14bb8618675a9694\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/bb21bcdb4ced287e7aea8285904ad3540560558a\",\"id\":\"bb21bcdb4ced287e7aea8285904ad3540560558a\",\"committed_date\":\"2011-04-22T11:37:04-07:00\",\"authored_date\":\"2011-04-22T11:37:04-07:00\",\"message\":\"use new configuration features to simplify the json verifier\",\"tree\":\"9450c43b683056391b936c05ec88dad1333fa628\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"0858bb341280956947df1cfae33eb5ac6ecfe6f7\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/9813127163116b7f928c383f14bb8618675a9694\",\"id\":\"9813127163116b7f928c383f14bb8618675a9694\",\"committed_date\":\"2011-04-21T12:58:28-07:00\",\"authored_date\":\"2011-04-21T09:56:51-07:00\",\"message\":\"rename yajl_parse_complete to yajl_complete_parse. the latter is correctly an imperative, while the former might be confused for a question.\",\"tree\":\"66fbf6ebf56d9bbe75095f5b97bab7fc22b2115e\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"6aefdaab38d81f33c46e33353c5a156884ea022d\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/0858bb341280956947df1cfae33eb5ac6ecfe6f7\",\"id\":\"0858bb341280956947df1cfae33eb5ac6ecfe6f7\",\"committed_date\":\"2011-04-21T12:55:45-07:00\",\"authored_date\":\"2011-04-21T08:36:26-07:00\",\"message\":\"rework programmatic configuration of yajl. both generator and parser now have a yajl_XXX_config() function that accepts varargs so that configuration is simple, and new config options can be added in the future that preserve backwards binary compatibility. closes #23.\",\"tree\":\"2f61e004f7a892f00f6f34d38a8a194618400b59\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"b6b44127f23d70231156a8d20fa7d437cac1588f\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/6aefdaab38d81f33c46e33353c5a156884ea022d\",\"id\":\"6aefdaab38d81f33c46e33353c5a156884ea022d\",\"committed_date\":\"2011-04-20T15:25:43-07:00\",\"authored_date\":\"2011-04-20T15:25:43-07:00\",\"message\":\"oh, ok. osx ld doesn't like more than two digits in shared lib version numbers. weenies.\",\"tree\":\"8b13d0a2e7870253be11fe6ba20e73dc64f2586e\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"f542280579e0a98a172e38631e972acbd6dc1195\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/b6b44127f23d70231156a8d20fa7d437cac1588f\",\"id\":\"b6b44127f23d70231156a8d20fa7d437cac1588f\",\"committed_date\":\"2011-04-20T15:23:09-07:00\",\"authored_date\":\"2011-04-20T15:23:09-07:00\",\"message\":\"add tests cases for partial value config\",\"tree\":\"52392b3b62a212d17b9e6b4fa865620d3603d7b6\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"de81b1fcd22b29b152f921f23faab759c79da7e1\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/f542280579e0a98a172e38631e972acbd6dc1195\",\"id\":\"f542280579e0a98a172e38631e972acbd6dc1195\",\"committed_date\":\"2011-04-20T14:57:42-07:00\",\"authored_date\":\"2011-04-20T14:57:42-07:00\",\"message\":\"cosmetic, indentation and whitespace\",\"tree\":\"736c631155d85e83b0cbede9223d4ea1a98d43fa\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"7852c0a19", "70b67c22b7b7bfeb29095bcc21ca12f\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/de81b1fcd22b29b152f921f23faab759c79da7e1\",\"id\":\"de81b1fcd22b29b152f921f23faab759c79da7e1\",\"committed_date\":\"2011-04-20T14:48:36-07:00\",\"authored_date\":\"2011-04-20T14:48:36-07:00\",\"message\":\"yajl 2 will be relicensed under the ISC license. same idea, fewer bytes.\",\"tree\":\"4cc7e0c2d9bde7f1c739fda71bec6491b381b6d2\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"986516e15b7b331a19fe317e2c828c5352d5b72e\"}],\"author\":{\"name\":\"Greg Olszewski\",\"login\":\"gno\",\"email\":\"gno@gropeep.org\"},\"url\":\"/lloyd/yajl/commit/7852c0a1970b67c22b7b7bfeb29095bcc21ca12f\",\"id\":\"7852c0a1970b67c22b7b7bfeb29095bcc21ca12f\",\"committed_date\":\"2011-04-20T14:24:19-07:00\",\"authored_date\":\"2010-10-17T17:05:01-07:00\",\"message\":\"o closes #5 - replace strtol with own implementation, uses pascal strings.\\no issue #6 - check a few malloc error cases.\\n\\nSigned-off-by: Lloyd Hilaiel \",\"tree\":\"6c5ee341a57ddc31ea920eae720083d50b55436c\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"9b88b94429985a8579161ea99754cfa5e66a54bb\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/986516e15b7b331a19fe317e2c828c5352d5b72e\",\"id\":\"986516e15b7b331a19fe317e2c828c5352d5b72e\",\"committed_date\":\"2011-04-20T11:22:50-07:00\",\"authored_date\":\"2011-04-20T11:22:50-07:00\",\"message\":\"add a test case which demonstrates how new parsing configuration in yajl 2.x closes #7\",\"tree\":\"274bf0c359ff4a30cc913c8614beed0b68ef615e\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"888d390f4e3642f2bafff7e5489810cc695843d1\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/9b88b94429985a8579161ea99754cfa5e66a54bb\",\"id\":\"9b88b94429985a8579161ea99754cfa5e66a54bb\",\"committed_date\":\"2011-04-20T11:20:45-07:00\",\"authored_date\":\"2011-04-20T11:20:45-07:00\",\"message\":\"fixes to testing system. allowGarbage is misnamed, it actually means *forbid* garbage\",\"tree\":\"6a165f8af10271b6b3605ef9a78bc6d88a73184a\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"ecd8008a32677f4d03f8c9231ece27732a248404\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/888d390f4e3642f2bafff7e5489810cc695843d1\",\"id\":\"888d390f4e3642f2bafff7e5489810cc695843d1\",\"committed_date\":\"2011-04-20T11:08:15-07:00\",\"authored_date\":\"2011-04-20T11:08:15-07:00\",\"message\":\"add a missing test case - multiple integers in a stream\",\"tree\":\"206438ff65252b1a77e4301688ce025cabf13c70\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"b9e91a37f7132bf7f5b91de895b766db06ae3072\"}],\"author\":{\"name\":\"Conrad Irwin\",\"login\":\"ConradIrwin\",\"email\":\"conrad.irwin@gmail.com\"},\"url\":\"/lloyd/yajl/commit/ecd8008a32677f4d03f8c9231ece27732a248404\",\"id\":\"ecd8008a32677f4d03f8c9231ece27732a248404\",\"committed_date\":\"2011-04-20T10:17:40-07:00\",\"authored_date\":\"2011-03-19T18:32:21-07:00\",\"message\":\"Parse null bytes correctly.\\n\\nSigned-off-by: Lloyd Hilaiel \",\"tree\":\"f88244c16383ca4377e9cbadc4e5a7fb0ab1324a\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"dc206cf75b8489b4cdcc8ff0cdbe94cbcc61a551\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/b9e91a37f7132bf7f5b91de895b766db06ae3072\",\"id\":\"b9e91a37f7132bf7f5b91de895b76", "6db06ae3072\",\"committed_date\":\"2011-04-20T09:41:14-07:00\",\"authored_date\":\"2011-04-20T09:41:14-07:00\",\"message\":\"o rework yajl api\\n - remove yajl_status_parse_incomplete, replace with three\\n flag settings\\n - yajl_allow_multiple_values\\n - yajl_forbid_trailing_garbage\\n - yajl_forbid_partial_values\\n\\n In the new model, callers must consistently call yajl_parse_complete\\n and check it's return. Two new parse errors have been introduced:\\n \\\"premature EOF\\\" and \\\"trailing garbage\\\".\\n\\n yajl_test.c demonstrates the simplifying effect on calling code.\\n\\n adds 3 flags to yajl_test\\n -g forbids trailing garbage\\n -p forbids partial values\\n -m allows multiple values to be parsed.\\n\\n and complementary tests.\\n\\nlth: Addresses the majority of issue #24. gno is awesomesauce.\\n\\nSigned-off-by: Lloyd Hilaiel \",\"tree\":\"a2f006d686e40502ebc74be858992db52ba2204b\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"1ecfbc0b3458420feba033cd2c25a4f5e9bac0b4\"},{\"id\":\"49116c941312b78ca6768b916fd0d247147f1f47\"}],\"author\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"},\"url\":\"/lloyd/yajl/commit/dc206cf75b8489b4cdcc8ff0cdbe94cbcc61a551\",\"id\":\"dc206cf75b8489b4cdcc8ff0cdbe94cbcc61a551\",\"committed_date\":\"2011-04-20T09:27:46-07:00\",\"authored_date\":\"2011-04-20T09:27:46-07:00\",\"message\":\"Merge branch 'master' into 2.x\",\"tree\":\"e9d6f3873dfe530e11009bbf0fa1e858f27d968b\",\"committer\":{\"name\":\"Lloyd Hilaiel\",\"login\":\"lloyd\",\"email\":\"lloyd@hilaiel.com\"}},{\"parents\":[{\"id\":\"0d9e3589bc8d59ce963937587f634c8c9cc61643\"}],\"author\":{\"name\":\"Mirek Rusin\",\"login\":\"mirek\",\"email\":\"mirek@me.com\"},\"url\":\"/lloyd/yajl/commit/49116c941312b78ca6768b916fd0d247147f1f47\",\"id\":\"49116c941312b78ca6768b916fd0d247147f1f47\",\"committed_date\":\"2011-04-19T04:46:52-07:00\",\"authored_date\":\"2011-04-19T04:46:52-07:00\",\"message\":\"LLVM warnings\",\"tree\":\"57eac7400e476299277490f9253e059e4d00085b\",\"committer\":{\"name\":\"Mirek Rusin\",\"login\":\"mirek\",\"email\":\"mirek@me.com\"}}]}", NULL }; const char ** g_documents[] = { doc1, doc2, doc3, NULL }; int num_docs(void) { int i = 0; for (i=0;g_documents[i];i++); return i; } const char ** get_doc(int i) { return g_documents[i]; } unsigned int doc_size(int i) { int sz = 0; const char ** p = get_doc(i); do { sz += strlen(*p); } while(*(++p)); return sz; } yajl-2.1.0/perf/documents.h000066400000000000000000000021561231222176500155640ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __DOCUMENTS_H__ #define __DOCUMENTS_H__ /* a header that provides access to several json documents broken into chunks of * less than 4k, cause C99 says that's what we should do and YAJL likes streams */ extern const char ** g_documents[]; int num_docs(void); const char ** get_doc(int i); unsigned int doc_size(int i); #endif yajl-2.1.0/perf/perftest.c000066400000000000000000000071251231222176500154130ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include "documents.h" /* a platform specific defn' of a function to get a high res time in a * portable format */ #ifndef WIN32 #include static double mygettime(void) { struct timeval now; gettimeofday(&now, NULL); return now.tv_sec + (now.tv_usec / 1000000.0); } #else #define _WIN32 1 #include static double mygettime(void) { long long tval; FILETIME ft; GetSystemTimeAsFileTime(&ft); tval = ft.dwHighDateTime; tval <<=32; tval |= ft.dwLowDateTime; return tval / 10000000.00; } #endif #define PARSE_TIME_SECS 3 static int run(int validate_utf8) { long long times = 0; double starttime; starttime = mygettime(); /* allocate a parser */ for (;;) { int i; { double now = mygettime(); if (now - starttime >= PARSE_TIME_SECS) break; } for (i = 0; i < 100; i++) { yajl_handle hand = yajl_alloc(NULL, NULL, NULL); yajl_status stat; const char ** d; yajl_config(hand, yajl_dont_validate_strings, validate_utf8 ? 0 : 1); for (d = get_doc(times % num_docs()); *d; d++) { stat = yajl_parse(hand, (unsigned char *) *d, strlen(*d)); if (stat != yajl_status_ok) break; } stat = yajl_complete_parse(hand); if (stat != yajl_status_ok) { unsigned char * str = yajl_get_error(hand, 1, (unsigned char *) *d, (*d ? strlen(*d) : 0)); fprintf(stderr, "%s", (const char *) str); yajl_free_error(hand, str); return 1; } yajl_free(hand); times++; } } /* parsed doc 'times' times */ { double throughput; double now; const char * all_units[] = { "B/s", "KB/s", "MB/s", (char *) 0 }; const char ** units = all_units; int i, avg_doc_size = 0; now = mygettime(); for (i = 0; i < num_docs(); i++) avg_doc_size += doc_size(i); avg_doc_size /= num_docs(); throughput = (times * avg_doc_size) / (now - starttime); while (*(units + 1) && throughput > 1024) { throughput /= 1024; units++; } printf("Parsing speed: %g %s\n", throughput, *units); } return 0; } int main(void) { int rv = 0; printf("-- speed tests determine parsing throughput given %d different sample documents --\n", num_docs()); printf("With UTF8 validation:\n"); rv = run(1); if (rv != 0) return rv; printf("Without UTF8 validation:\n"); rv = run(0); return rv; } yajl-2.1.0/reformatter/000077500000000000000000000000001231222176500150045ustar00rootroot00000000000000yajl-2.1.0/reformatter/CMakeLists.txt000066400000000000000000000031561231222176500175510ustar00rootroot00000000000000# Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # set up a paths SET (binDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/bin) # create a directories FILE(MAKE_DIRECTORY ${binDir}) SET (SRCS json_reformat.c) # use the library we build, duh. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include) LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib) ADD_EXECUTABLE(json_reformat ${SRCS}) TARGET_LINK_LIBRARIES(json_reformat yajl_s) # In some environments, we must explicitly link libm (like qnx, # thanks @shahbag) IF (NOT WIN32) TARGET_LINK_LIBRARIES(json_reformat m) ENDIF (NOT WIN32) # copy the binary into the output directory GET_TARGET_PROPERTY(binPath json_reformat LOCATION) ADD_CUSTOM_COMMAND(TARGET json_reformat POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${binPath} ${binDir}) INSTALL(TARGETS json_reformat RUNTIME DESTINATION bin) yajl-2.1.0/reformatter/json_reformat.c000066400000000000000000000136401231222176500200240ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include /* non-zero when we're reformatting a stream */ static int s_streamReformat = 0; #define GEN_AND_RETURN(func) \ { \ yajl_gen_status __stat = func; \ if (__stat == yajl_gen_generation_complete && s_streamReformat) { \ yajl_gen_reset(g, "\n"); \ __stat = func; \ } \ return __stat == yajl_gen_status_ok; } static int reformat_null(void * ctx) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_null(g)); } static int reformat_boolean(void * ctx, int boolean) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_bool(g, boolean)); } static int reformat_number(void * ctx, const char * s, size_t l) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_number(g, s, l)); } static int reformat_string(void * ctx, const unsigned char * stringVal, size_t stringLen) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_string(g, stringVal, stringLen)); } static int reformat_map_key(void * ctx, const unsigned char * stringVal, size_t stringLen) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_string(g, stringVal, stringLen)); } static int reformat_start_map(void * ctx) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_map_open(g)); } static int reformat_end_map(void * ctx) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_map_close(g)); } static int reformat_start_array(void * ctx) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_array_open(g)); } static int reformat_end_array(void * ctx) { yajl_gen g = (yajl_gen) ctx; GEN_AND_RETURN(yajl_gen_array_close(g)); } static yajl_callbacks callbacks = { reformat_null, reformat_boolean, NULL, NULL, reformat_number, reformat_string, reformat_start_map, reformat_map_key, reformat_end_map, reformat_start_array, reformat_end_array }; static void usage(const char * progname) { fprintf(stderr, "%s: reformat json from stdin\n" "usage: json_reformat [options]\n" " -e escape any forward slashes (for embedding in HTML)\n" " -m minimize json rather than beautify (default)\n" " -s reformat a stream of multiple json entites\n" " -u allow invalid UTF8 inside strings during parsing\n", progname); exit(1); } int main(int argc, char ** argv) { yajl_handle hand; static unsigned char fileData[65536]; /* generator config */ yajl_gen g; yajl_status stat; size_t rd; int retval = 0; int a = 1; g = yajl_gen_alloc(NULL); yajl_gen_config(g, yajl_gen_beautify, 1); yajl_gen_config(g, yajl_gen_validate_utf8, 1); /* ok. open file. let's read and parse */ hand = yajl_alloc(&callbacks, NULL, (void *) g); /* and let's allow comments by default */ yajl_config(hand, yajl_allow_comments, 1); /* check arguments.*/ while ((a < argc) && (argv[a][0] == '-') && (strlen(argv[a]) > 1)) { unsigned int i; for ( i=1; i < strlen(argv[a]); i++) { switch (argv[a][i]) { case 'm': yajl_gen_config(g, yajl_gen_beautify, 0); break; case 's': yajl_config(hand, yajl_allow_multiple_values, 1); s_streamReformat = 1; break; case 'u': yajl_config(hand, yajl_dont_validate_strings, 1); break; case 'e': yajl_gen_config(g, yajl_gen_escape_solidus, 1); break; default: fprintf(stderr, "unrecognized option: '%c'\n\n", argv[a][i]); usage(argv[0]); } } ++a; } if (a < argc) { usage(argv[0]); } for (;;) { rd = fread((void *) fileData, 1, sizeof(fileData) - 1, stdin); if (rd == 0) { if (!feof(stdin)) { fprintf(stderr, "error on file read.\n"); retval = 1; } break; } fileData[rd] = 0; stat = yajl_parse(hand, fileData, rd); if (stat != yajl_status_ok) break; { const unsigned char * buf; size_t len; yajl_gen_get_buf(g, &buf, &len); fwrite(buf, 1, len, stdout); yajl_gen_clear(g); } } stat = yajl_complete_parse(hand); if (stat != yajl_status_ok) { unsigned char * str = yajl_get_error(hand, 1, fileData, rd); fprintf(stderr, "%s", (const char *) str); yajl_free_error(hand, str); retval = 1; } yajl_gen_free(g); yajl_free(hand); return retval; } yajl-2.1.0/src/000077500000000000000000000000001231222176500132415ustar00rootroot00000000000000yajl-2.1.0/src/CMakeLists.txt000066400000000000000000000066041231222176500160070ustar00rootroot00000000000000# Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. SET (SRCS yajl.c yajl_lex.c yajl_parser.c yajl_buf.c yajl_encode.c yajl_gen.c yajl_alloc.c yajl_tree.c yajl_version.c ) SET (HDRS yajl_parser.h yajl_lex.h yajl_buf.h yajl_encode.h yajl_alloc.h) SET (PUB_HDRS api/yajl_parse.h api/yajl_gen.h api/yajl_common.h api/yajl_tree.h) # useful when fixing lexer bugs. #ADD_DEFINITIONS(-DYAJL_LEXER_DEBUG) # Ensure defined when building YAJL (as opposed to using it from # another project). Used to ensure correct function export when # building win32 DLL. ADD_DEFINITIONS(-DYAJL_BUILD) # set up some paths SET (libDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib) SET (incDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include/yajl) SET (shareDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/share/pkgconfig) # set the output path for libraries SET(LIBRARY_OUTPUT_PATH ${libDir}) ADD_LIBRARY(yajl_s STATIC ${SRCS} ${HDRS} ${PUB_HDRS}) ADD_LIBRARY(yajl SHARED ${SRCS} ${HDRS} ${PUB_HDRS}) #### setup shared library version number SET_TARGET_PROPERTIES(yajl PROPERTIES DEFINE_SYMBOL YAJL_SHARED SOVERSION ${YAJL_MAJOR} VERSION ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO}) #### ensure a .dylib has correct absolute installation paths upon installation IF(APPLE) MESSAGE("INSTALL_NAME_DIR: ${CMAKE_INSTALL_PREFIX}/lib") SET_TARGET_PROPERTIES(yajl PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") ENDIF(APPLE) #### build up an sdk as a post build step # create some directories FILE(MAKE_DIRECTORY ${libDir}) FILE(MAKE_DIRECTORY ${incDir}) # generate build-time source SET(dollar $) CONFIGURE_FILE(api/yajl_version.h.cmake ${incDir}/yajl_version.h) CONFIGURE_FILE(yajl.pc.cmake ${shareDir}/yajl.pc) # copy public headers to output directory FOREACH (header ${PUB_HDRS}) SET (header ${CMAKE_CURRENT_SOURCE_DIR}/${header}) EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E copy_if_different ${header} ${incDir}) ADD_CUSTOM_COMMAND(TARGET yajl_s POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${header} ${incDir}) ENDFOREACH (header ${PUB_HDRS}) INCLUDE_DIRECTORIES(${incDir}/..) # at build time you may specify the cmake variable LIB_SUFFIX to handle # 64-bit systems which use 'lib64' INSTALL(TARGETS yajl RUNTIME DESTINATION lib${LIB_SUFFIX} LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(TARGETS yajl_s ARCHIVE DESTINATION lib${LIB_SUFFIX}) INSTALL(FILES ${PUB_HDRS} DESTINATION include/yajl) INSTALL(FILES ${incDir}/yajl_version.h DESTINATION include/yajl) INSTALL(FILES ${shareDir}/yajl.pc DESTINATION share/pkgconfig) yajl-2.1.0/src/YAJL.dxy000066400000000000000000001455701231222176500145420ustar00rootroot00000000000000# Doxyfile 1.5.2 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file that # follow. The default is UTF-8 which is also the encoding used for all text before # the first occurrence of this tag. Doxygen uses libiconv (or the iconv built into # libc) for the transcoding. See http://www.gnu.org/software/libiconv for the list of # possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = YAJL # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @YAJL_VERSION@ # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = yajl-@YAJL_VERSION@/share # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Finnish, French, German, Greek, Hungarian, # Italian, Japanese, Japanese-en (Japanese with English messages), Korean, # Korean-en, Lithuanian, Norwegian, Polish, Portuguese, Romanian, Russian, # Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like the Qt-style comments (thus requiring an # explicit @brief command for a brief description. JAVADOC_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. # DETAILS_AT_TOP = YES # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to # include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = NO #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = YES # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from the # version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = YES # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ../src/yajl ../src/api # This tag can be used to specify the character encoding of the source files that # doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default # input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding. # See http://www.gnu.org/software/libiconv for the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py FILE_PATTERNS = *.h # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the output. # The symbol name can be a fully qualified name, a word, or if the wildcard * is used, # a substring. Examples: ANamespace, AClass, AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = .. # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentstion. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = doc/yajl-@YAJL_VERSION@ # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compressed HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = YES # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to # produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to # specify the directory where the mscgen tool resides. If left empty the tool is assumed to # be found in the default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a call dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable call graphs for selected # functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will # generate a caller dependency graph for every global function or class method. # Note that enabling this option will significantly increase the time of a run. # So in most cases it will be better to enable caller graphs for selected # functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen will always # show the root nodes and its direct children regardless of this setting. DOT_GRAPH_MAX_NODES = 50 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, which results in a white background. # Warning: Depending on the platform used, enabling this option may lead to # badly anti-aliased labels on the edges of a graph (i.e. they become hard to # read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO yajl-2.1.0/src/api/000077500000000000000000000000001231222176500140125ustar00rootroot00000000000000yajl-2.1.0/src/api/yajl_common.h000066400000000000000000000050141231222176500164720ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __YAJL_COMMON_H__ #define __YAJL_COMMON_H__ #include #ifdef __cplusplus extern "C" { #endif #define YAJL_MAX_DEPTH 128 /* msft dll export gunk. To build a DLL on windows, you * must define WIN32, YAJL_SHARED, and YAJL_BUILD. To use a shared * DLL, you must define YAJL_SHARED and WIN32 */ #if (defined(_WIN32) || defined(WIN32)) && defined(YAJL_SHARED) # ifdef YAJL_BUILD # define YAJL_API __declspec(dllexport) # else # define YAJL_API __declspec(dllimport) # endif #else # if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 # define YAJL_API __attribute__ ((visibility("default"))) # else # define YAJL_API # endif #endif /** pointer to a malloc function, supporting client overriding memory * allocation routines */ typedef void * (*yajl_malloc_func)(void *ctx, size_t sz); /** pointer to a free function, supporting client overriding memory * allocation routines */ typedef void (*yajl_free_func)(void *ctx, void * ptr); /** pointer to a realloc function which can resize an allocation. */ typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, size_t sz); /** A structure which can be passed to yajl_*_alloc routines to allow the * client to specify memory allocation functions to be used. */ typedef struct { /** pointer to a function that can allocate uninitialized memory */ yajl_malloc_func malloc; /** pointer to a function that can resize memory allocations */ yajl_realloc_func realloc; /** pointer to a function that can free memory allocated using * reallocFunction or mallocFunction */ yajl_free_func free; /** a context pointer that will be passed to above allocation routines */ void * ctx; } yajl_alloc_funcs; #ifdef __cplusplus } #endif #endif yajl-2.1.0/src/api/yajl_gen.h000066400000000000000000000156241231222176500157630ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /** * \file yajl_gen.h * Interface to YAJL's JSON generation facilities. */ #include #ifndef __YAJL_GEN_H__ #define __YAJL_GEN_H__ #include #ifdef __cplusplus extern "C" { #endif /** generator status codes */ typedef enum { /** no error */ yajl_gen_status_ok = 0, /** at a point where a map key is generated, a function other than * yajl_gen_string was called */ yajl_gen_keys_must_be_strings, /** YAJL's maximum generation depth was exceeded. see * YAJL_MAX_DEPTH */ yajl_max_depth_exceeded, /** A generator function (yajl_gen_XXX) was called while in an error * state */ yajl_gen_in_error_state, /** A complete JSON document has been generated */ yajl_gen_generation_complete, /** yajl_gen_double was passed an invalid floating point value * (infinity or NaN). */ yajl_gen_invalid_number, /** A print callback was passed in, so there is no internal * buffer to get from */ yajl_gen_no_buf, /** returned from yajl_gen_string() when the yajl_gen_validate_utf8 * option is enabled and an invalid was passed by client code. */ yajl_gen_invalid_string } yajl_gen_status; /** an opaque handle to a generator */ typedef struct yajl_gen_t * yajl_gen; /** a callback used for "printing" the results. */ typedef void (*yajl_print_t)(void * ctx, const char * str, size_t len); /** configuration parameters for the parser, these may be passed to * yajl_gen_config() along with option specific argument(s). In general, * all configuration parameters default to *off*. */ typedef enum { /** generate indented (beautiful) output */ yajl_gen_beautify = 0x01, /** * Set an indent string which is used when yajl_gen_beautify * is enabled. Maybe something like \\t or some number of * spaces. The default is four spaces ' '. */ yajl_gen_indent_string = 0x02, /** * Set a function and context argument that should be used to * output generated json. the function should conform to the * yajl_print_t prototype while the context argument is a * void * of your choosing. * * example: * yajl_gen_config(g, yajl_gen_print_callback, myFunc, myVoidPtr); */ yajl_gen_print_callback = 0x04, /** * Normally the generator does not validate that strings you * pass to it via yajl_gen_string() are valid UTF8. Enabling * this option will cause it to do so. */ yajl_gen_validate_utf8 = 0x08, /** * the forward solidus (slash or '/' in human) is not required to be * escaped in json text. By default, YAJL will not escape it in the * iterest of saving bytes. Setting this flag will cause YAJL to * always escape '/' in generated JSON strings. */ yajl_gen_escape_solidus = 0x10 } yajl_gen_option; /** allow the modification of generator options subsequent to handle * allocation (via yajl_alloc) * \returns zero in case of errors, non-zero otherwise */ YAJL_API int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...); /** allocate a generator handle * \param allocFuncs an optional pointer to a structure which allows * the client to overide the memory allocation * used by yajl. May be NULL, in which case * malloc/free/realloc will be used. * * \returns an allocated handle on success, NULL on failure (bad params) */ YAJL_API yajl_gen yajl_gen_alloc(const yajl_alloc_funcs * allocFuncs); /** free a generator handle */ YAJL_API void yajl_gen_free(yajl_gen handle); YAJL_API yajl_gen_status yajl_gen_integer(yajl_gen hand, long long int number); /** generate a floating point number. number may not be infinity or * NaN, as these have no representation in JSON. In these cases the * generator will return 'yajl_gen_invalid_number' */ YAJL_API yajl_gen_status yajl_gen_double(yajl_gen hand, double number); YAJL_API yajl_gen_status yajl_gen_number(yajl_gen hand, const char * num, size_t len); YAJL_API yajl_gen_status yajl_gen_string(yajl_gen hand, const unsigned char * str, size_t len); YAJL_API yajl_gen_status yajl_gen_null(yajl_gen hand); YAJL_API yajl_gen_status yajl_gen_bool(yajl_gen hand, int boolean); YAJL_API yajl_gen_status yajl_gen_map_open(yajl_gen hand); YAJL_API yajl_gen_status yajl_gen_map_close(yajl_gen hand); YAJL_API yajl_gen_status yajl_gen_array_open(yajl_gen hand); YAJL_API yajl_gen_status yajl_gen_array_close(yajl_gen hand); /** access the null terminated generator buffer. If incrementally * outputing JSON, one should call yajl_gen_clear to clear the * buffer. This allows stream generation. */ YAJL_API yajl_gen_status yajl_gen_get_buf(yajl_gen hand, const unsigned char ** buf, size_t * len); /** clear yajl's output buffer, but maintain all internal generation * state. This function will not "reset" the generator state, and is * intended to enable incremental JSON outputing. */ YAJL_API void yajl_gen_clear(yajl_gen hand); /** Reset the generator state. Allows a client to generate multiple * json entities in a stream. The "sep" string will be inserted to * separate the previously generated entity from the current, * NULL means *no separation* of entites (clients beware, generating * multiple JSON numbers, for instance, will result in inscrutable * output) */ YAJL_API void yajl_gen_reset(yajl_gen hand, const char * sep); #ifdef __cplusplus } #endif #endif yajl-2.1.0/src/api/yajl_parse.h000066400000000000000000000231351231222176500163200ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /** * \file yajl_parse.h * Interface to YAJL's JSON stream parsing facilities. */ #include #ifndef __YAJL_PARSE_H__ #define __YAJL_PARSE_H__ #include #ifdef __cplusplus extern "C" { #endif /** error codes returned from this interface */ typedef enum { /** no error was encountered */ yajl_status_ok, /** a client callback returned zero, stopping the parse */ yajl_status_client_canceled, /** An error occured during the parse. Call yajl_get_error for * more information about the encountered error */ yajl_status_error } yajl_status; /** attain a human readable, english, string for an error */ YAJL_API const char * yajl_status_to_string(yajl_status code); /** an opaque handle to a parser */ typedef struct yajl_handle_t * yajl_handle; /** yajl is an event driven parser. this means as json elements are * parsed, you are called back to do something with the data. The * functions in this table indicate the various events for which * you will be called back. Each callback accepts a "context" * pointer, this is a void * that is passed into the yajl_parse * function which the client code may use to pass around context. * * All callbacks return an integer. If non-zero, the parse will * continue. If zero, the parse will be canceled and * yajl_status_client_canceled will be returned from the parse. * * \attention { * A note about the handling of numbers: * * yajl will only convert numbers that can be represented in a * double or a 64 bit (long long) int. All other numbers will * be passed to the client in string form using the yajl_number * callback. Furthermore, if yajl_number is not NULL, it will * always be used to return numbers, that is yajl_integer and * yajl_double will be ignored. If yajl_number is NULL but one * of yajl_integer or yajl_double are defined, parsing of a * number larger than is representable in a double or 64 bit * integer will result in a parse error. * } */ typedef struct { int (* yajl_null)(void * ctx); int (* yajl_boolean)(void * ctx, int boolVal); int (* yajl_integer)(void * ctx, long long integerVal); int (* yajl_double)(void * ctx, double doubleVal); /** A callback which passes the string representation of the number * back to the client. Will be used for all numbers when present */ int (* yajl_number)(void * ctx, const char * numberVal, size_t numberLen); /** strings are returned as pointers into the JSON text when, * possible, as a result, they are _not_ null padded */ int (* yajl_string)(void * ctx, const unsigned char * stringVal, size_t stringLen); int (* yajl_start_map)(void * ctx); int (* yajl_map_key)(void * ctx, const unsigned char * key, size_t stringLen); int (* yajl_end_map)(void * ctx); int (* yajl_start_array)(void * ctx); int (* yajl_end_array)(void * ctx); } yajl_callbacks; /** allocate a parser handle * \param callbacks a yajl callbacks structure specifying the * functions to call when different JSON entities * are encountered in the input text. May be NULL, * which is only useful for validation. * \param afs memory allocation functions, may be NULL for to use * C runtime library routines (malloc and friends) * \param ctx a context pointer that will be passed to callbacks. */ YAJL_API yajl_handle yajl_alloc(const yajl_callbacks * callbacks, yajl_alloc_funcs * afs, void * ctx); /** configuration parameters for the parser, these may be passed to * yajl_config() along with option specific argument(s). In general, * all configuration parameters default to *off*. */ typedef enum { /** Ignore javascript style comments present in * JSON input. Non-standard, but rather fun * arguments: toggled off with integer zero, on otherwise. * * example: * yajl_config(h, yajl_allow_comments, 1); // turn comment support on */ yajl_allow_comments = 0x01, /** * When set the parser will verify that all strings in JSON input are * valid UTF8 and will emit a parse error if this is not so. When set, * this option makes parsing slightly more expensive (~7% depending * on processor and compiler in use) * * example: * yajl_config(h, yajl_dont_validate_strings, 1); // disable utf8 checking */ yajl_dont_validate_strings = 0x02, /** * By default, upon calls to yajl_complete_parse(), yajl will * ensure the entire input text was consumed and will raise an error * otherwise. Enabling this flag will cause yajl to disable this * check. This can be useful when parsing json out of a that contains more * than a single JSON document. */ yajl_allow_trailing_garbage = 0x04, /** * Allow multiple values to be parsed by a single handle. The * entire text must be valid JSON, and values can be seperated * by any kind of whitespace. This flag will change the * behavior of the parser, and cause it continue parsing after * a value is parsed, rather than transitioning into a * complete state. This option can be useful when parsing multiple * values from an input stream. */ yajl_allow_multiple_values = 0x08, /** * When yajl_complete_parse() is called the parser will * check that the top level value was completely consumed. I.E., * if called whilst in the middle of parsing a value * yajl will enter an error state (premature EOF). Setting this * flag suppresses that check and the corresponding error. */ yajl_allow_partial_values = 0x10 } yajl_option; /** allow the modification of parser options subsequent to handle * allocation (via yajl_alloc) * \returns zero in case of errors, non-zero otherwise */ YAJL_API int yajl_config(yajl_handle h, yajl_option opt, ...); /** free a parser handle */ YAJL_API void yajl_free(yajl_handle handle); /** Parse some json! * \param hand - a handle to the json parser allocated with yajl_alloc * \param jsonText - a pointer to the UTF8 json text to be parsed * \param jsonTextLength - the length, in bytes, of input text */ YAJL_API yajl_status yajl_parse(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLength); /** Parse any remaining buffered json. * Since yajl is a stream-based parser, without an explicit end of * input, yajl sometimes can't decide if content at the end of the * stream is valid or not. For example, if "1" has been fed in, * yajl can't know whether another digit is next or some character * that would terminate the integer token. * * \param hand - a handle to the json parser allocated with yajl_alloc */ YAJL_API yajl_status yajl_complete_parse(yajl_handle hand); /** get an error string describing the state of the * parse. * * If verbose is non-zero, the message will include the JSON * text where the error occured, along with an arrow pointing to * the specific char. * * \returns A dynamically allocated string will be returned which should * be freed with yajl_free_error */ YAJL_API unsigned char * yajl_get_error(yajl_handle hand, int verbose, const unsigned char * jsonText, size_t jsonTextLength); /** * get the amount of data consumed from the last chunk passed to YAJL. * * In the case of a successful parse this can help you understand if * the entire buffer was consumed (which will allow you to handle * "junk at end of input"). * * In the event an error is encountered during parsing, this function * affords the client a way to get the offset into the most recent * chunk where the error occured. 0 will be returned if no error * was encountered. */ YAJL_API size_t yajl_get_bytes_consumed(yajl_handle hand); /** free an error returned from yajl_get_error */ YAJL_API void yajl_free_error(yajl_handle hand, unsigned char * str); #ifdef __cplusplus } #endif #endif yajl-2.1.0/src/api/yajl_tree.h000066400000000000000000000160031231222176500161410ustar00rootroot00000000000000/* * Copyright (c) 2010-2011 Florian Forster * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /** * \file yajl_tree.h * * Parses JSON data and returns the data in tree form. * * \author Florian Forster * \date August 2010 * * This interface makes quick parsing and extraction of * smallish JSON docs trivial: * * \include example/parse_config.c */ #ifndef YAJL_TREE_H #define YAJL_TREE_H 1 #include #ifdef __cplusplus extern "C" { #endif /** possible data types that a yajl_val_s can hold */ typedef enum { yajl_t_string = 1, yajl_t_number = 2, yajl_t_object = 3, yajl_t_array = 4, yajl_t_true = 5, yajl_t_false = 6, yajl_t_null = 7, /** The any type isn't valid for yajl_val_s.type, but can be * used as an argument to routines like yajl_tree_get(). */ yajl_t_any = 8 } yajl_type; #define YAJL_NUMBER_INT_VALID 0x01 #define YAJL_NUMBER_DOUBLE_VALID 0x02 /** A pointer to a node in the parse tree */ typedef struct yajl_val_s * yajl_val; /** * A JSON value representation capable of holding one of the seven * types above. For "string", "number", "object", and "array" * additional data is available in the union. The "YAJL_IS_*" * and "YAJL_GET_*" macros below allow type checking and convenient * value extraction. */ struct yajl_val_s { /** Type of the value contained. Use the "YAJL_IS_*" macros to check for a * specific type. */ yajl_type type; /** Type-specific data. You may use the "YAJL_GET_*" macros to access these * members. */ union { char * string; struct { long long i; /*< integer value, if representable. */ double d; /*< double value, if representable. */ char *r; /*< unparsed number in string form. */ /** Signals whether the \em i and \em d members are * valid. See \c YAJL_NUMBER_INT_VALID and * \c YAJL_NUMBER_DOUBLE_VALID. */ unsigned int flags; } number; struct { const char **keys; /*< Array of keys */ yajl_val *values; /*< Array of values. */ size_t len; /*< Number of key-value-pairs. */ } object; struct { yajl_val *values; /*< Array of elements. */ size_t len; /*< Number of elements. */ } array; } u; }; /** * Parse a string. * * Parses an null-terminated string containing JSON data and returns a pointer * to the top-level value (root of the parse tree). * * \param input Pointer to a null-terminated utf8 string containing * JSON data. * \param error_buffer Pointer to a buffer in which an error message will * be stored if \em yajl_tree_parse fails, or * \c NULL. The buffer will be initialized before * parsing, so its content will be destroyed even if * \em yajl_tree_parse succeeds. * \param error_buffer_size Size of the memory area pointed to by * \em error_buffer_size. If \em error_buffer_size is * \c NULL, this argument is ignored. * * \returns Pointer to the top-level value or \c NULL on error. The memory * pointed to must be freed using \em yajl_tree_free. In case of an error, a * null terminated message describing the error in more detail is stored in * \em error_buffer if it is not \c NULL. */ YAJL_API yajl_val yajl_tree_parse (const char *input, char *error_buffer, size_t error_buffer_size); /** * Free a parse tree returned by "yajl_tree_parse". * * \param v Pointer to a JSON value returned by "yajl_tree_parse". Passing NULL * is valid and results in a no-op. */ YAJL_API void yajl_tree_free (yajl_val v); /** * Access a nested value inside a tree. * * \param parent the node under which you'd like to extract values. * \param path A null terminated array of strings, each the name of an object key * \param type the yajl_type of the object you seek, or yajl_t_any if any will do. * * \returns a pointer to the found value, or NULL if we came up empty. * * Future Ideas: it'd be nice to move path to a string and implement support for * a teeny tiny micro language here, so you can extract array elements, do things * like .first and .last, even .length. Inspiration from JSONPath and css selectors? * No it wouldn't be fast, but that's not what this API is about. */ YAJL_API yajl_val yajl_tree_get(yajl_val parent, const char ** path, yajl_type type); /* Various convenience macros to check the type of a `yajl_val` */ #define YAJL_IS_STRING(v) (((v) != NULL) && ((v)->type == yajl_t_string)) #define YAJL_IS_NUMBER(v) (((v) != NULL) && ((v)->type == yajl_t_number)) #define YAJL_IS_INTEGER(v) (YAJL_IS_NUMBER(v) && ((v)->u.number.flags & YAJL_NUMBER_INT_VALID)) #define YAJL_IS_DOUBLE(v) (YAJL_IS_NUMBER(v) && ((v)->u.number.flags & YAJL_NUMBER_DOUBLE_VALID)) #define YAJL_IS_OBJECT(v) (((v) != NULL) && ((v)->type == yajl_t_object)) #define YAJL_IS_ARRAY(v) (((v) != NULL) && ((v)->type == yajl_t_array )) #define YAJL_IS_TRUE(v) (((v) != NULL) && ((v)->type == yajl_t_true )) #define YAJL_IS_FALSE(v) (((v) != NULL) && ((v)->type == yajl_t_false )) #define YAJL_IS_NULL(v) (((v) != NULL) && ((v)->type == yajl_t_null )) /** Given a yajl_val_string return a ptr to the bare string it contains, * or NULL if the value is not a string. */ #define YAJL_GET_STRING(v) (YAJL_IS_STRING(v) ? (v)->u.string : NULL) /** Get the string representation of a number. You should check type first, * perhaps using YAJL_IS_NUMBER */ #define YAJL_GET_NUMBER(v) ((v)->u.number.r) /** Get the double representation of a number. You should check type first, * perhaps using YAJL_IS_DOUBLE */ #define YAJL_GET_DOUBLE(v) ((v)->u.number.d) /** Get the 64bit (long long) integer representation of a number. You should * check type first, perhaps using YAJL_IS_INTEGER */ #define YAJL_GET_INTEGER(v) ((v)->u.number.i) /** Get a pointer to a yajl_val_object or NULL if the value is not an object. */ #define YAJL_GET_OBJECT(v) (YAJL_IS_OBJECT(v) ? &(v)->u.object : NULL) /** Get a pointer to a yajl_val_array or NULL if the value is not an object. */ #define YAJL_GET_ARRAY(v) (YAJL_IS_ARRAY(v) ? &(v)->u.array : NULL) #ifdef __cplusplus } #endif #endif /* YAJL_TREE_H */ yajl-2.1.0/src/api/yajl_version.h.cmake000066400000000000000000000006171231222176500177520ustar00rootroot00000000000000#ifndef YAJL_VERSION_H_ #define YAJL_VERSION_H_ #include #define YAJL_MAJOR ${YAJL_MAJOR} #define YAJL_MINOR ${YAJL_MINOR} #define YAJL_MICRO ${YAJL_MICRO} #define YAJL_VERSION ((YAJL_MAJOR * 10000) + (YAJL_MINOR * 100) + YAJL_MICRO) #ifdef __cplusplus extern "C" { #endif extern int YAJL_API yajl_version(void); #ifdef __cplusplus } #endif #endif /* YAJL_VERSION_H_ */ yajl-2.1.0/src/yajl000066400000000000000000000020061231222176500141210ustar00rootroot00000000000000/** \example reformatter/json_reformat.c \example example/parse_config.c */ /*! \mainpage Yet Another JSON Library (YAJL) \author Lloyd Hilaiel \date 2007-2014 Yet Another JSON Library (YAJL) is a small event-driven (SAX-style) JSON parser written in ANSI C, and a small validating JSON generator. YAJL is released under the permissive ISC license. \section features Features -# Stream (incremental) parsing and generation of JSON -# ANSI C -# Human readable error messages with context -# tiny -# event driven -# support for generating "beautified" JSON -# includes It also includes a small simplified tree interface for simplified parsing and extraction of data from smallish JSON documents. \section usage Usage See json_reformat.c for a complete example of stream based parsing and generation of JSON. See parse_config.c for an example of the simplified tree interface. */ yajl-2.1.0/src/yajl.c000066400000000000000000000115241231222176500143470ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "api/yajl_parse.h" #include "yajl_lex.h" #include "yajl_parser.h" #include "yajl_alloc.h" #include #include #include #include const char * yajl_status_to_string(yajl_status stat) { const char * statStr = "unknown"; switch (stat) { case yajl_status_ok: statStr = "ok, no error"; break; case yajl_status_client_canceled: statStr = "client canceled parse"; break; case yajl_status_error: statStr = "parse error"; break; } return statStr; } yajl_handle yajl_alloc(const yajl_callbacks * callbacks, yajl_alloc_funcs * afs, void * ctx) { yajl_handle hand = NULL; yajl_alloc_funcs afsBuffer; /* first order of business is to set up memory allocation routines */ if (afs != NULL) { if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL) { return NULL; } } else { yajl_set_default_alloc_funcs(&afsBuffer); afs = &afsBuffer; } hand = (yajl_handle) YA_MALLOC(afs, sizeof(struct yajl_handle_t)); /* copy in pointers to allocation routines */ memcpy((void *) &(hand->alloc), (void *) afs, sizeof(yajl_alloc_funcs)); hand->callbacks = callbacks; hand->ctx = ctx; hand->lexer = NULL; hand->bytesConsumed = 0; hand->decodeBuf = yajl_buf_alloc(&(hand->alloc)); hand->flags = 0; yajl_bs_init(hand->stateStack, &(hand->alloc)); yajl_bs_push(hand->stateStack, yajl_state_start); return hand; } int yajl_config(yajl_handle h, yajl_option opt, ...) { int rv = 1; va_list ap; va_start(ap, opt); switch(opt) { case yajl_allow_comments: case yajl_dont_validate_strings: case yajl_allow_trailing_garbage: case yajl_allow_multiple_values: case yajl_allow_partial_values: if (va_arg(ap, int)) h->flags |= opt; else h->flags &= ~opt; break; default: rv = 0; } va_end(ap); return rv; } void yajl_free(yajl_handle handle) { yajl_bs_free(handle->stateStack); yajl_buf_free(handle->decodeBuf); if (handle->lexer) { yajl_lex_free(handle->lexer); handle->lexer = NULL; } YA_FREE(&(handle->alloc), handle); } yajl_status yajl_parse(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLen) { yajl_status status; /* lazy allocation of the lexer */ if (hand->lexer == NULL) { hand->lexer = yajl_lex_alloc(&(hand->alloc), hand->flags & yajl_allow_comments, !(hand->flags & yajl_dont_validate_strings)); } status = yajl_do_parse(hand, jsonText, jsonTextLen); return status; } yajl_status yajl_complete_parse(yajl_handle hand) { /* The lexer is lazy allocated in the first call to parse. if parse is * never called, then no data was provided to parse at all. This is a * "premature EOF" error unless yajl_allow_partial_values is specified. * allocating the lexer now is the simplest possible way to handle this * case while preserving all the other semantics of the parser * (multiple values, partial values, etc). */ if (hand->lexer == NULL) { hand->lexer = yajl_lex_alloc(&(hand->alloc), hand->flags & yajl_allow_comments, !(hand->flags & yajl_dont_validate_strings)); } return yajl_do_finish(hand); } unsigned char * yajl_get_error(yajl_handle hand, int verbose, const unsigned char * jsonText, size_t jsonTextLen) { return yajl_render_error_string(hand, jsonText, jsonTextLen, verbose); } size_t yajl_get_bytes_consumed(yajl_handle hand) { if (!hand) return 0; else return hand->bytesConsumed; } void yajl_free_error(yajl_handle hand, unsigned char * str) { /* use memory allocation functions if set */ YA_FREE(&(hand->alloc), str); } /* XXX: add utility routines to parse from file */ yajl-2.1.0/src/yajl.pc.cmake000066400000000000000000000005201231222176500156000ustar00rootroot00000000000000prefix=${CMAKE_INSTALL_PREFIX} libdir=${dollar}{prefix}/lib${LIB_SUFFIX} includedir=${dollar}{prefix}/include/yajl Name: Yet Another JSON Library Description: A Portable JSON parsing and serialization library in ANSI C Version: ${YAJL_MAJOR}.${YAJL_MINOR}.${YAJL_MICRO} Cflags: -I${dollar}{includedir} Libs: -L${dollar}{libdir} -lyajl yajl-2.1.0/src/yajl_alloc.c000066400000000000000000000027501231222176500155220ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /** * \file yajl_alloc.h * default memory allocation routines for yajl which use malloc/realloc and * free */ #include "yajl_alloc.h" #include static void * yajl_internal_malloc(void *ctx, size_t sz) { (void)ctx; return malloc(sz); } static void * yajl_internal_realloc(void *ctx, void * previous, size_t sz) { (void)ctx; return realloc(previous, sz); } static void yajl_internal_free(void *ctx, void * ptr) { (void)ctx; free(ptr); } void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf) { yaf->malloc = yajl_internal_malloc; yaf->free = yajl_internal_free; yaf->realloc = yajl_internal_realloc; yaf->ctx = NULL; } yajl-2.1.0/src/yajl_alloc.h000066400000000000000000000023411231222176500155230ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /** * \file yajl_alloc.h * default memory allocation routines for yajl which use malloc/realloc and * free */ #ifndef __YAJL_ALLOC_H__ #define __YAJL_ALLOC_H__ #include "api/yajl_common.h" #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz)) #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr)) #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz)) void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf); #endif yajl-2.1.0/src/yajl_buf.c000066400000000000000000000047321231222176500152060ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "yajl_buf.h" #include #include #include #define YAJL_BUF_INIT_SIZE 2048 struct yajl_buf_t { size_t len; size_t used; unsigned char * data; yajl_alloc_funcs * alloc; }; static void yajl_buf_ensure_available(yajl_buf buf, size_t want) { size_t need; assert(buf != NULL); /* first call */ if (buf->data == NULL) { buf->len = YAJL_BUF_INIT_SIZE; buf->data = (unsigned char *) YA_MALLOC(buf->alloc, buf->len); buf->data[0] = 0; } need = buf->len; while (want >= (need - buf->used)) need <<= 1; if (need != buf->len) { buf->data = (unsigned char *) YA_REALLOC(buf->alloc, buf->data, need); buf->len = need; } } yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc) { yajl_buf b = YA_MALLOC(alloc, sizeof(struct yajl_buf_t)); memset((void *) b, 0, sizeof(struct yajl_buf_t)); b->alloc = alloc; return b; } void yajl_buf_free(yajl_buf buf) { assert(buf != NULL); if (buf->data) YA_FREE(buf->alloc, buf->data); YA_FREE(buf->alloc, buf); } void yajl_buf_append(yajl_buf buf, const void * data, size_t len) { yajl_buf_ensure_available(buf, len); if (len > 0) { assert(data != NULL); memcpy(buf->data + buf->used, data, len); buf->used += len; buf->data[buf->used] = 0; } } void yajl_buf_clear(yajl_buf buf) { buf->used = 0; if (buf->data) buf->data[buf->used] = 0; } const unsigned char * yajl_buf_data(yajl_buf buf) { return buf->data; } size_t yajl_buf_len(yajl_buf buf) { return buf->used; } void yajl_buf_truncate(yajl_buf buf, size_t len) { assert(len <= buf->used); buf->used = len; } yajl-2.1.0/src/yajl_buf.h000066400000000000000000000035031231222176500152060ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __YAJL_BUF_H__ #define __YAJL_BUF_H__ #include "api/yajl_common.h" #include "yajl_alloc.h" /* * Implementation/performance notes. If this were moved to a header * only implementation using #define's where possible we might be * able to sqeeze a little performance out of the guy by killing function * call overhead. YMMV. */ /** * yajl_buf is a buffer with exponential growth. the buffer ensures that * you are always null padded. */ typedef struct yajl_buf_t * yajl_buf; /* allocate a new buffer */ yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc); /* free the buffer */ void yajl_buf_free(yajl_buf buf); /* append a number of bytes to the buffer */ void yajl_buf_append(yajl_buf buf, const void * data, size_t len); /* empty the buffer */ void yajl_buf_clear(yajl_buf buf); /* get a pointer to the beginning of the buffer */ const unsigned char * yajl_buf_data(yajl_buf buf); /* get the length of the buffer */ size_t yajl_buf_len(yajl_buf buf); /* truncate the buffer */ void yajl_buf_truncate(yajl_buf buf, size_t len); #endif yajl-2.1.0/src/yajl_bytestack.h000066400000000000000000000045131231222176500164250ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* * A header only implementation of a simple stack of bytes, used in YAJL * to maintain parse state. */ #ifndef __YAJL_BYTESTACK_H__ #define __YAJL_BYTESTACK_H__ #include "api/yajl_common.h" #define YAJL_BS_INC 128 typedef struct yajl_bytestack_t { unsigned char * stack; size_t size; size_t used; yajl_alloc_funcs * yaf; } yajl_bytestack; /* initialize a bytestack */ #define yajl_bs_init(obs, _yaf) { \ (obs).stack = NULL; \ (obs).size = 0; \ (obs).used = 0; \ (obs).yaf = (_yaf); \ } \ /* initialize a bytestack */ #define yajl_bs_free(obs) \ if ((obs).stack) (obs).yaf->free((obs).yaf->ctx, (obs).stack); #define yajl_bs_current(obs) \ (assert((obs).used > 0), (obs).stack[(obs).used - 1]) #define yajl_bs_push(obs, byte) { \ if (((obs).size - (obs).used) == 0) { \ (obs).size += YAJL_BS_INC; \ (obs).stack = (obs).yaf->realloc((obs).yaf->ctx,\ (void *) (obs).stack, (obs).size);\ } \ (obs).stack[((obs).used)++] = (byte); \ } /* removes the top item of the stack, returns nothing */ #define yajl_bs_pop(obs) { ((obs).used)--; } #define yajl_bs_set(obs, byte) \ (obs).stack[((obs).used) - 1] = (byte); #endif yajl-2.1.0/src/yajl_encode.c000066400000000000000000000161501231222176500156640ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "yajl_encode.h" #include #include #include #include static void CharToHex(unsigned char c, char * hexBuf) { const char * hexchar = "0123456789ABCDEF"; hexBuf[0] = hexchar[c >> 4]; hexBuf[1] = hexchar[c & 0x0F]; } void yajl_string_encode(const yajl_print_t print, void * ctx, const unsigned char * str, size_t len, int escape_solidus) { size_t beg = 0; size_t end = 0; char hexBuf[7]; hexBuf[0] = '\\'; hexBuf[1] = 'u'; hexBuf[2] = '0'; hexBuf[3] = '0'; hexBuf[6] = 0; while (end < len) { const char * escaped = NULL; switch (str[end]) { case '\r': escaped = "\\r"; break; case '\n': escaped = "\\n"; break; case '\\': escaped = "\\\\"; break; /* it is not required to escape a solidus in JSON: * read sec. 2.5: http://www.ietf.org/rfc/rfc4627.txt * specifically, this production from the grammar: * unescaped = %x20-21 / %x23-5B / %x5D-10FFFF */ case '/': if (escape_solidus) escaped = "\\/"; break; case '"': escaped = "\\\""; break; case '\f': escaped = "\\f"; break; case '\b': escaped = "\\b"; break; case '\t': escaped = "\\t"; break; default: if ((unsigned char) str[end] < 32) { CharToHex(str[end], hexBuf + 4); escaped = hexBuf; } break; } if (escaped != NULL) { print(ctx, (const char *) (str + beg), end - beg); print(ctx, escaped, (unsigned int)strlen(escaped)); beg = ++end; } else { ++end; } } print(ctx, (const char *) (str + beg), end - beg); } static void hexToDigit(unsigned int * val, const unsigned char * hex) { unsigned int i; for (i=0;i<4;i++) { unsigned char c = hex[i]; if (c >= 'A') c = (c & ~0x20) - 7; c -= '0'; assert(!(c & 0xF0)); *val = (*val << 4) | c; } } static void Utf32toUtf8(unsigned int codepoint, char * utf8Buf) { if (codepoint < 0x80) { utf8Buf[0] = (char) codepoint; utf8Buf[1] = 0; } else if (codepoint < 0x0800) { utf8Buf[0] = (char) ((codepoint >> 6) | 0xC0); utf8Buf[1] = (char) ((codepoint & 0x3F) | 0x80); utf8Buf[2] = 0; } else if (codepoint < 0x10000) { utf8Buf[0] = (char) ((codepoint >> 12) | 0xE0); utf8Buf[1] = (char) (((codepoint >> 6) & 0x3F) | 0x80); utf8Buf[2] = (char) ((codepoint & 0x3F) | 0x80); utf8Buf[3] = 0; } else if (codepoint < 0x200000) { utf8Buf[0] =(char)((codepoint >> 18) | 0xF0); utf8Buf[1] =(char)(((codepoint >> 12) & 0x3F) | 0x80); utf8Buf[2] =(char)(((codepoint >> 6) & 0x3F) | 0x80); utf8Buf[3] =(char)((codepoint & 0x3F) | 0x80); utf8Buf[4] = 0; } else { utf8Buf[0] = '?'; utf8Buf[1] = 0; } } void yajl_string_decode(yajl_buf buf, const unsigned char * str, size_t len) { size_t beg = 0; size_t end = 0; while (end < len) { if (str[end] == '\\') { char utf8Buf[5]; const char * unescaped = "?"; yajl_buf_append(buf, str + beg, end - beg); switch (str[++end]) { case 'r': unescaped = "\r"; break; case 'n': unescaped = "\n"; break; case '\\': unescaped = "\\"; break; case '/': unescaped = "/"; break; case '"': unescaped = "\""; break; case 'f': unescaped = "\f"; break; case 'b': unescaped = "\b"; break; case 't': unescaped = "\t"; break; case 'u': { unsigned int codepoint = 0; hexToDigit(&codepoint, str + ++end); end+=3; /* check if this is a surrogate */ if ((codepoint & 0xFC00) == 0xD800) { end++; if (str[end] == '\\' && str[end + 1] == 'u') { unsigned int surrogate = 0; hexToDigit(&surrogate, str + end + 2); codepoint = (((codepoint & 0x3F) << 10) | ((((codepoint >> 6) & 0xF) + 1) << 16) | (surrogate & 0x3FF)); end += 5; } else { unescaped = "?"; break; } } Utf32toUtf8(codepoint, utf8Buf); unescaped = utf8Buf; if (codepoint == 0) { yajl_buf_append(buf, unescaped, 1); beg = ++end; continue; } break; } default: assert("this should never happen" == NULL); } yajl_buf_append(buf, unescaped, (unsigned int)strlen(unescaped)); beg = ++end; } else { end++; } } yajl_buf_append(buf, str + beg, end - beg); } #define ADV_PTR s++; if (!(len--)) return 0; int yajl_string_validate_utf8(const unsigned char * s, size_t len) { if (!len) return 1; if (!s) return 0; while (len--) { /* single byte */ if (*s <= 0x7f) { /* noop */ } /* two byte */ else if ((*s >> 5) == 0x6) { ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; } /* three byte */ else if ((*s >> 4) == 0x0e) { ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; } /* four byte */ else if ((*s >> 3) == 0x1e) { ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; ADV_PTR; if (!((*s >> 6) == 0x2)) return 0; } else { return 0; } s++; } return 1; } yajl-2.1.0/src/yajl_encode.h000066400000000000000000000024301231222176500156650ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __YAJL_ENCODE_H__ #define __YAJL_ENCODE_H__ #include "yajl_buf.h" #include "api/yajl_gen.h" void yajl_string_encode(const yajl_print_t printer, void * ctx, const unsigned char * str, size_t length, int escape_solidus); void yajl_string_decode(yajl_buf buf, const unsigned char * str, size_t length); int yajl_string_validate_utf8(const unsigned char * s, size_t len); #endif yajl-2.1.0/src/yajl_gen.c000066400000000000000000000253471231222176500152100ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "api/yajl_gen.h" #include "yajl_buf.h" #include "yajl_encode.h" #include #include #include #include #include typedef enum { yajl_gen_start, yajl_gen_map_start, yajl_gen_map_key, yajl_gen_map_val, yajl_gen_array_start, yajl_gen_in_array, yajl_gen_complete, yajl_gen_error } yajl_gen_state; struct yajl_gen_t { unsigned int flags; unsigned int depth; const char * indentString; yajl_gen_state state[YAJL_MAX_DEPTH]; yajl_print_t print; void * ctx; /* yajl_buf */ /* memory allocation routines */ yajl_alloc_funcs alloc; }; int yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...) { int rv = 1; va_list ap; va_start(ap, opt); switch(opt) { case yajl_gen_beautify: case yajl_gen_validate_utf8: case yajl_gen_escape_solidus: if (va_arg(ap, int)) g->flags |= opt; else g->flags &= ~opt; break; case yajl_gen_indent_string: { const char *indent = va_arg(ap, const char *); g->indentString = indent; for (; *indent; indent++) { if (*indent != '\n' && *indent != '\v' && *indent != '\f' && *indent != '\t' && *indent != '\r' && *indent != ' ') { g->indentString = NULL; rv = 0; } } break; } case yajl_gen_print_callback: yajl_buf_free(g->ctx); g->print = va_arg(ap, const yajl_print_t); g->ctx = va_arg(ap, void *); break; default: rv = 0; } va_end(ap); return rv; } yajl_gen yajl_gen_alloc(const yajl_alloc_funcs * afs) { yajl_gen g = NULL; yajl_alloc_funcs afsBuffer; /* first order of business is to set up memory allocation routines */ if (afs != NULL) { if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL) { return NULL; } } else { yajl_set_default_alloc_funcs(&afsBuffer); afs = &afsBuffer; } g = (yajl_gen) YA_MALLOC(afs, sizeof(struct yajl_gen_t)); if (!g) return NULL; memset((void *) g, 0, sizeof(struct yajl_gen_t)); /* copy in pointers to allocation routines */ memcpy((void *) &(g->alloc), (void *) afs, sizeof(yajl_alloc_funcs)); g->print = (yajl_print_t)&yajl_buf_append; g->ctx = yajl_buf_alloc(&(g->alloc)); g->indentString = " "; return g; } void yajl_gen_reset(yajl_gen g, const char * sep) { g->depth = 0; memset((void *) &(g->state), 0, sizeof(g->state)); if (sep != NULL) g->print(g->ctx, sep, strlen(sep)); } void yajl_gen_free(yajl_gen g) { if (g->print == (yajl_print_t)&yajl_buf_append) yajl_buf_free((yajl_buf)g->ctx); YA_FREE(&(g->alloc), g); } #define INSERT_SEP \ if (g->state[g->depth] == yajl_gen_map_key || \ g->state[g->depth] == yajl_gen_in_array) { \ g->print(g->ctx, ",", 1); \ if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); \ } else if (g->state[g->depth] == yajl_gen_map_val) { \ g->print(g->ctx, ":", 1); \ if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, " ", 1); \ } #define INSERT_WHITESPACE \ if ((g->flags & yajl_gen_beautify)) { \ if (g->state[g->depth] != yajl_gen_map_val) { \ unsigned int _i; \ for (_i=0;_idepth;_i++) \ g->print(g->ctx, \ g->indentString, \ (unsigned int)strlen(g->indentString)); \ } \ } #define ENSURE_NOT_KEY \ if (g->state[g->depth] == yajl_gen_map_key || \ g->state[g->depth] == yajl_gen_map_start) { \ return yajl_gen_keys_must_be_strings; \ } \ /* check that we're not complete, or in error state. in a valid state * to be generating */ #define ENSURE_VALID_STATE \ if (g->state[g->depth] == yajl_gen_error) { \ return yajl_gen_in_error_state;\ } else if (g->state[g->depth] == yajl_gen_complete) { \ return yajl_gen_generation_complete; \ } #define INCREMENT_DEPTH \ if (++(g->depth) >= YAJL_MAX_DEPTH) return yajl_max_depth_exceeded; #define DECREMENT_DEPTH \ if (--(g->depth) >= YAJL_MAX_DEPTH) return yajl_gen_generation_complete; #define APPENDED_ATOM \ switch (g->state[g->depth]) { \ case yajl_gen_start: \ g->state[g->depth] = yajl_gen_complete; \ break; \ case yajl_gen_map_start: \ case yajl_gen_map_key: \ g->state[g->depth] = yajl_gen_map_val; \ break; \ case yajl_gen_array_start: \ g->state[g->depth] = yajl_gen_in_array; \ break; \ case yajl_gen_map_val: \ g->state[g->depth] = yajl_gen_map_key; \ break; \ default: \ break; \ } \ #define FINAL_NEWLINE \ if ((g->flags & yajl_gen_beautify) && g->state[g->depth] == yajl_gen_complete) \ g->print(g->ctx, "\n", 1); yajl_gen_status yajl_gen_integer(yajl_gen g, long long int number) { char i[32]; ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; sprintf(i, "%lld", number); g->print(g->ctx, i, (unsigned int)strlen(i)); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } #if defined(_WIN32) || defined(WIN32) #include #define isnan _isnan #define isinf !_finite #endif yajl_gen_status yajl_gen_double(yajl_gen g, double number) { char i[32]; ENSURE_VALID_STATE; ENSURE_NOT_KEY; if (isnan(number) || isinf(number)) return yajl_gen_invalid_number; INSERT_SEP; INSERT_WHITESPACE; sprintf(i, "%.20g", number); if (strspn(i, "0123456789-") == strlen(i)) { strcat(i, ".0"); } g->print(g->ctx, i, (unsigned int)strlen(i)); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_number(yajl_gen g, const char * s, size_t l) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; g->print(g->ctx, s, l); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_string(yajl_gen g, const unsigned char * str, size_t len) { // if validation is enabled, check that the string is valid utf8 // XXX: This checking could be done a little faster, in the same pass as // the string encoding if (g->flags & yajl_gen_validate_utf8) { if (!yajl_string_validate_utf8(str, len)) { return yajl_gen_invalid_string; } } ENSURE_VALID_STATE; INSERT_SEP; INSERT_WHITESPACE; g->print(g->ctx, "\"", 1); yajl_string_encode(g->print, g->ctx, str, len, g->flags & yajl_gen_escape_solidus); g->print(g->ctx, "\"", 1); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_null(yajl_gen g) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; g->print(g->ctx, "null", strlen("null")); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_bool(yajl_gen g, int boolean) { const char * val = boolean ? "true" : "false"; ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; g->print(g->ctx, val, (unsigned int)strlen(val)); APPENDED_ATOM; FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_map_open(yajl_gen g) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; INCREMENT_DEPTH; g->state[g->depth] = yajl_gen_map_start; g->print(g->ctx, "{", 1); if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_map_close(yajl_gen g) { ENSURE_VALID_STATE; DECREMENT_DEPTH; if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); APPENDED_ATOM; INSERT_WHITESPACE; g->print(g->ctx, "}", 1); FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_array_open(yajl_gen g) { ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; INCREMENT_DEPTH; g->state[g->depth] = yajl_gen_array_start; g->print(g->ctx, "[", 1); if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_array_close(yajl_gen g) { ENSURE_VALID_STATE; DECREMENT_DEPTH; if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); APPENDED_ATOM; INSERT_WHITESPACE; g->print(g->ctx, "]", 1); FINAL_NEWLINE; return yajl_gen_status_ok; } yajl_gen_status yajl_gen_get_buf(yajl_gen g, const unsigned char ** buf, size_t * len) { if (g->print != (yajl_print_t)&yajl_buf_append) return yajl_gen_no_buf; *buf = yajl_buf_data((yajl_buf)g->ctx); *len = yajl_buf_len((yajl_buf)g->ctx); return yajl_gen_status_ok; } void yajl_gen_clear(yajl_gen g) { if (g->print == (yajl_print_t)&yajl_buf_append) yajl_buf_clear((yajl_buf)g->ctx); } yajl-2.1.0/src/yajl_lex.c000066400000000000000000000631301231222176500152170ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "yajl_lex.h" #include "yajl_buf.h" #include #include #include #include #ifdef YAJL_LEXER_DEBUG static const char * tokToStr(yajl_tok tok) { switch (tok) { case yajl_tok_bool: return "bool"; case yajl_tok_colon: return "colon"; case yajl_tok_comma: return "comma"; case yajl_tok_eof: return "eof"; case yajl_tok_error: return "error"; case yajl_tok_left_brace: return "brace"; case yajl_tok_left_bracket: return "bracket"; case yajl_tok_null: return "null"; case yajl_tok_integer: return "integer"; case yajl_tok_double: return "double"; case yajl_tok_right_brace: return "brace"; case yajl_tok_right_bracket: return "bracket"; case yajl_tok_string: return "string"; case yajl_tok_string_with_escapes: return "string_with_escapes"; } return "unknown"; } #endif /* Impact of the stream parsing feature on the lexer: * * YAJL support stream parsing. That is, the ability to parse the first * bits of a chunk of JSON before the last bits are available (still on * the network or disk). This makes the lexer more complex. The * responsibility of the lexer is to handle transparently the case where * a chunk boundary falls in the middle of a token. This is * accomplished is via a buffer and a character reading abstraction. * * Overview of implementation * * When we lex to end of input string before end of token is hit, we * copy all of the input text composing the token into our lexBuf. * * Every time we read a character, we do so through the readChar function. * readChar's responsibility is to handle pulling all chars from the buffer * before pulling chars from input text */ struct yajl_lexer_t { /* the overal line and char offset into the data */ size_t lineOff; size_t charOff; /* error */ yajl_lex_error error; /* a input buffer to handle the case where a token is spread over * multiple chunks */ yajl_buf buf; /* in the case where we have data in the lexBuf, bufOff holds * the current offset into the lexBuf. */ size_t bufOff; /* are we using the lex buf? */ unsigned int bufInUse; /* shall we allow comments? */ unsigned int allowComments; /* shall we validate utf8 inside strings? */ unsigned int validateUTF8; yajl_alloc_funcs * alloc; }; #define readChar(lxr, txt, off) \ (((lxr)->bufInUse && yajl_buf_len((lxr)->buf) && lxr->bufOff < yajl_buf_len((lxr)->buf)) ? \ (*((const unsigned char *) yajl_buf_data((lxr)->buf) + ((lxr)->bufOff)++)) : \ ((txt)[(*(off))++])) #define unreadChar(lxr, off) ((*(off) > 0) ? (*(off))-- : ((lxr)->bufOff--)) yajl_lexer yajl_lex_alloc(yajl_alloc_funcs * alloc, unsigned int allowComments, unsigned int validateUTF8) { yajl_lexer lxr = (yajl_lexer) YA_MALLOC(alloc, sizeof(struct yajl_lexer_t)); memset((void *) lxr, 0, sizeof(struct yajl_lexer_t)); lxr->buf = yajl_buf_alloc(alloc); lxr->allowComments = allowComments; lxr->validateUTF8 = validateUTF8; lxr->alloc = alloc; return lxr; } void yajl_lex_free(yajl_lexer lxr) { yajl_buf_free(lxr->buf); YA_FREE(lxr->alloc, lxr); return; } /* a lookup table which lets us quickly determine three things: * VEC - valid escaped control char * note. the solidus '/' may be escaped or not. * IJC - invalid json char * VHC - valid hex char * NFP - needs further processing (from a string scanning perspective) * NUC - needs utf8 checking when enabled (from a string scanning perspective) */ #define VEC 0x01 #define IJC 0x02 #define VHC 0x04 #define NFP 0x08 #define NUC 0x10 static const char charLookupTable[256] = { /*00*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC , /*08*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC , /*10*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC , /*18*/ IJC , IJC , IJC , IJC , IJC , IJC , IJC , IJC , /*20*/ 0 , 0 , NFP|VEC|IJC, 0 , 0 , 0 , 0 , 0 , /*28*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , VEC , /*30*/ VHC , VHC , VHC , VHC , VHC , VHC , VHC , VHC , /*38*/ VHC , VHC , 0 , 0 , 0 , 0 , 0 , 0 , /*40*/ 0 , VHC , VHC , VHC , VHC , VHC , VHC , 0 , /*48*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /*50*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , /*58*/ 0 , 0 , 0 , 0 , NFP|VEC|IJC, 0 , 0 , 0 , /*60*/ 0 , VHC , VEC|VHC, VHC , VHC , VHC , VEC|VHC, 0 , /*68*/ 0 , 0 , 0 , 0 , 0 , 0 , VEC , 0 , /*70*/ 0 , 0 , VEC , 0 , VEC , 0 , 0 , 0 , /*78*/ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC , NUC }; /** process a variable length utf8 encoded codepoint. * * returns: * yajl_tok_string - if valid utf8 char was parsed and offset was * advanced * yajl_tok_eof - if end of input was hit before validation could * complete * yajl_tok_error - if invalid utf8 was encountered * * NOTE: on error the offset will point to the first char of the * invalid utf8 */ #define UTF8_CHECK_EOF if (*offset >= jsonTextLen) { return yajl_tok_eof; } static yajl_tok yajl_lex_utf8_char(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset, unsigned char curChar) { if (curChar <= 0x7f) { /* single byte */ return yajl_tok_string; } else if ((curChar >> 5) == 0x6) { /* two byte */ UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) return yajl_tok_string; } else if ((curChar >> 4) == 0x0e) { /* three byte */ UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) { UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) return yajl_tok_string; } } else if ((curChar >> 3) == 0x1e) { /* four byte */ UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) { UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) { UTF8_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if ((curChar >> 6) == 0x2) return yajl_tok_string; } } } return yajl_tok_error; } /* lex a string. input is the lexer, pointer to beginning of * json text, and start of string (offset). * a token is returned which has the following meanings: * yajl_tok_string: lex of string was successful. offset points to * terminating '"'. * yajl_tok_eof: end of text was encountered before we could complete * the lex. * yajl_tok_error: embedded in the string were unallowable chars. offset * points to the offending char */ #define STR_CHECK_EOF \ if (*offset >= jsonTextLen) { \ tok = yajl_tok_eof; \ goto finish_string_lex; \ } /** scan a string for interesting characters that might need further * review. return the number of chars that are uninteresting and can * be skipped. * (lth) hi world, any thoughts on how to make this routine faster? */ static size_t yajl_string_scan(const unsigned char * buf, size_t len, int utf8check) { unsigned char mask = IJC|NFP|(utf8check ? NUC : 0); size_t skip = 0; while (skip < len && !(charLookupTable[*buf] & mask)) { skip++; buf++; } return skip; } static yajl_tok yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset) { yajl_tok tok = yajl_tok_error; int hasEscapes = 0; for (;;) { unsigned char curChar; /* now jump into a faster scanning routine to skip as much * of the buffers as possible */ { const unsigned char * p; size_t len; if ((lexer->bufInUse && yajl_buf_len(lexer->buf) && lexer->bufOff < yajl_buf_len(lexer->buf))) { p = ((const unsigned char *) yajl_buf_data(lexer->buf) + (lexer->bufOff)); len = yajl_buf_len(lexer->buf) - lexer->bufOff; lexer->bufOff += yajl_string_scan(p, len, lexer->validateUTF8); } else if (*offset < jsonTextLen) { p = jsonText + *offset; len = jsonTextLen - *offset; *offset += yajl_string_scan(p, len, lexer->validateUTF8); } } STR_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); /* quote terminates */ if (curChar == '"') { tok = yajl_tok_string; break; } /* backslash escapes a set of control chars, */ else if (curChar == '\\') { hasEscapes = 1; STR_CHECK_EOF; /* special case \u */ curChar = readChar(lexer, jsonText, offset); if (curChar == 'u') { unsigned int i = 0; for (i=0;i<4;i++) { STR_CHECK_EOF; curChar = readChar(lexer, jsonText, offset); if (!(charLookupTable[curChar] & VHC)) { /* back up to offending char */ unreadChar(lexer, offset); lexer->error = yajl_lex_string_invalid_hex_char; goto finish_string_lex; } } } else if (!(charLookupTable[curChar] & VEC)) { /* back up to offending char */ unreadChar(lexer, offset); lexer->error = yajl_lex_string_invalid_escaped_char; goto finish_string_lex; } } /* when not validating UTF8 it's a simple table lookup to determine * if the present character is invalid */ else if(charLookupTable[curChar] & IJC) { /* back up to offending char */ unreadChar(lexer, offset); lexer->error = yajl_lex_string_invalid_json_char; goto finish_string_lex; } /* when in validate UTF8 mode we need to do some extra work */ else if (lexer->validateUTF8) { yajl_tok t = yajl_lex_utf8_char(lexer, jsonText, jsonTextLen, offset, curChar); if (t == yajl_tok_eof) { tok = yajl_tok_eof; goto finish_string_lex; } else if (t == yajl_tok_error) { lexer->error = yajl_lex_string_invalid_utf8; goto finish_string_lex; } } /* accept it, and move on */ } finish_string_lex: /* tell our buddy, the parser, wether he needs to process this string * again */ if (hasEscapes && tok == yajl_tok_string) { tok = yajl_tok_string_with_escapes; } return tok; } #define RETURN_IF_EOF if (*offset >= jsonTextLen) return yajl_tok_eof; static yajl_tok yajl_lex_number(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset) { /** XXX: numbers are the only entities in json that we must lex * _beyond_ in order to know that they are complete. There * is an ambiguous case for integers at EOF. */ unsigned char c; yajl_tok tok = yajl_tok_integer; RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); /* optional leading minus */ if (c == '-') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } /* a single zero, or a series of integers */ if (c == '0') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } else if (c >= '1' && c <= '9') { do { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } while (c >= '0' && c <= '9'); } else { unreadChar(lexer, offset); lexer->error = yajl_lex_missing_integer_after_minus; return yajl_tok_error; } /* optional fraction (indicates this is floating point) */ if (c == '.') { int numRd = 0; RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); while (c >= '0' && c <= '9') { numRd++; RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } if (!numRd) { unreadChar(lexer, offset); lexer->error = yajl_lex_missing_integer_after_decimal; return yajl_tok_error; } tok = yajl_tok_double; } /* optional exponent (indicates this is floating point) */ if (c == 'e' || c == 'E') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); /* optional sign */ if (c == '+' || c == '-') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } if (c >= '0' && c <= '9') { do { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } while (c >= '0' && c <= '9'); } else { unreadChar(lexer, offset); lexer->error = yajl_lex_missing_integer_after_exponent; return yajl_tok_error; } tok = yajl_tok_double; } /* we always go "one too far" */ unreadChar(lexer, offset); return tok; } static yajl_tok yajl_lex_comment(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset) { unsigned char c; yajl_tok tok = yajl_tok_comment; RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); /* either slash or star expected */ if (c == '/') { /* now we throw away until end of line */ do { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); } while (c != '\n'); } else if (c == '*') { /* now we throw away until end of comment */ for (;;) { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); if (c == '*') { RETURN_IF_EOF; c = readChar(lexer, jsonText, offset); if (c == '/') { break; } else { unreadChar(lexer, offset); } } } } else { lexer->error = yajl_lex_invalid_char; tok = yajl_tok_error; } return tok; } yajl_tok yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset, const unsigned char ** outBuf, size_t * outLen) { yajl_tok tok = yajl_tok_error; unsigned char c; size_t startOffset = *offset; *outBuf = NULL; *outLen = 0; for (;;) { assert(*offset <= jsonTextLen); if (*offset >= jsonTextLen) { tok = yajl_tok_eof; goto lexed; } c = readChar(lexer, jsonText, offset); switch (c) { case '{': tok = yajl_tok_left_bracket; goto lexed; case '}': tok = yajl_tok_right_bracket; goto lexed; case '[': tok = yajl_tok_left_brace; goto lexed; case ']': tok = yajl_tok_right_brace; goto lexed; case ',': tok = yajl_tok_comma; goto lexed; case ':': tok = yajl_tok_colon; goto lexed; case '\t': case '\n': case '\v': case '\f': case '\r': case ' ': startOffset++; break; case 't': { const char * want = "rue"; do { if (*offset >= jsonTextLen) { tok = yajl_tok_eof; goto lexed; } c = readChar(lexer, jsonText, offset); if (c != *want) { unreadChar(lexer, offset); lexer->error = yajl_lex_invalid_string; tok = yajl_tok_error; goto lexed; } } while (*(++want)); tok = yajl_tok_bool; goto lexed; } case 'f': { const char * want = "alse"; do { if (*offset >= jsonTextLen) { tok = yajl_tok_eof; goto lexed; } c = readChar(lexer, jsonText, offset); if (c != *want) { unreadChar(lexer, offset); lexer->error = yajl_lex_invalid_string; tok = yajl_tok_error; goto lexed; } } while (*(++want)); tok = yajl_tok_bool; goto lexed; } case 'n': { const char * want = "ull"; do { if (*offset >= jsonTextLen) { tok = yajl_tok_eof; goto lexed; } c = readChar(lexer, jsonText, offset); if (c != *want) { unreadChar(lexer, offset); lexer->error = yajl_lex_invalid_string; tok = yajl_tok_error; goto lexed; } } while (*(++want)); tok = yajl_tok_null; goto lexed; } case '"': { tok = yajl_lex_string(lexer, (const unsigned char *) jsonText, jsonTextLen, offset); goto lexed; } case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { /* integer parsing wants to start from the beginning */ unreadChar(lexer, offset); tok = yajl_lex_number(lexer, (const unsigned char *) jsonText, jsonTextLen, offset); goto lexed; } case '/': /* hey, look, a probable comment! If comments are disabled * it's an error. */ if (!lexer->allowComments) { unreadChar(lexer, offset); lexer->error = yajl_lex_unallowed_comment; tok = yajl_tok_error; goto lexed; } /* if comments are enabled, then we should try to lex * the thing. possible outcomes are * - successful lex (tok_comment, which means continue), * - malformed comment opening (slash not followed by * '*' or '/') (tok_error) * - eof hit. (tok_eof) */ tok = yajl_lex_comment(lexer, (const unsigned char *) jsonText, jsonTextLen, offset); if (tok == yajl_tok_comment) { /* "error" is silly, but that's the initial * state of tok. guilty until proven innocent. */ tok = yajl_tok_error; yajl_buf_clear(lexer->buf); lexer->bufInUse = 0; startOffset = *offset; break; } /* hit error or eof, bail */ goto lexed; default: lexer->error = yajl_lex_invalid_char; tok = yajl_tok_error; goto lexed; } } lexed: /* need to append to buffer if the buffer is in use or * if it's an EOF token */ if (tok == yajl_tok_eof || lexer->bufInUse) { if (!lexer->bufInUse) yajl_buf_clear(lexer->buf); lexer->bufInUse = 1; yajl_buf_append(lexer->buf, jsonText + startOffset, *offset - startOffset); lexer->bufOff = 0; if (tok != yajl_tok_eof) { *outBuf = yajl_buf_data(lexer->buf); *outLen = yajl_buf_len(lexer->buf); lexer->bufInUse = 0; } } else if (tok != yajl_tok_error) { *outBuf = jsonText + startOffset; *outLen = *offset - startOffset; } /* special case for strings. skip the quotes. */ if (tok == yajl_tok_string || tok == yajl_tok_string_with_escapes) { assert(*outLen >= 2); (*outBuf)++; *outLen -= 2; } #ifdef YAJL_LEXER_DEBUG if (tok == yajl_tok_error) { printf("lexical error: %s\n", yajl_lex_error_to_string(yajl_lex_get_error(lexer))); } else if (tok == yajl_tok_eof) { printf("EOF hit\n"); } else { printf("lexed %s: '", tokToStr(tok)); fwrite(*outBuf, 1, *outLen, stdout); printf("'\n"); } #endif return tok; } const char * yajl_lex_error_to_string(yajl_lex_error error) { switch (error) { case yajl_lex_e_ok: return "ok, no error"; case yajl_lex_string_invalid_utf8: return "invalid bytes in UTF8 string."; case yajl_lex_string_invalid_escaped_char: return "inside a string, '\\' occurs before a character " "which it may not."; case yajl_lex_string_invalid_json_char: return "invalid character inside string."; case yajl_lex_string_invalid_hex_char: return "invalid (non-hex) character occurs after '\\u' inside " "string."; case yajl_lex_invalid_char: return "invalid char in json text."; case yajl_lex_invalid_string: return "invalid string in json text."; case yajl_lex_missing_integer_after_exponent: return "malformed number, a digit is required after the exponent."; case yajl_lex_missing_integer_after_decimal: return "malformed number, a digit is required after the " "decimal point."; case yajl_lex_missing_integer_after_minus: return "malformed number, a digit is required after the " "minus sign."; case yajl_lex_unallowed_comment: return "probable comment found in input text, comments are " "not enabled."; } return "unknown error code"; } /** allows access to more specific information about the lexical * error when yajl_lex_lex returns yajl_tok_error. */ yajl_lex_error yajl_lex_get_error(yajl_lexer lexer) { if (lexer == NULL) return (yajl_lex_error) -1; return lexer->error; } size_t yajl_lex_current_line(yajl_lexer lexer) { return lexer->lineOff; } size_t yajl_lex_current_char(yajl_lexer lexer) { return lexer->charOff; } yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t offset) { const unsigned char * outBuf; size_t outLen; size_t bufLen = yajl_buf_len(lexer->buf); size_t bufOff = lexer->bufOff; unsigned int bufInUse = lexer->bufInUse; yajl_tok tok; tok = yajl_lex_lex(lexer, jsonText, jsonTextLen, &offset, &outBuf, &outLen); lexer->bufOff = bufOff; lexer->bufInUse = bufInUse; yajl_buf_truncate(lexer->buf, bufLen); return tok; } yajl-2.1.0/src/yajl_lex.h000066400000000000000000000101261231222176500152210ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __YAJL_LEX_H__ #define __YAJL_LEX_H__ #include "api/yajl_common.h" typedef enum { yajl_tok_bool, yajl_tok_colon, yajl_tok_comma, yajl_tok_eof, yajl_tok_error, yajl_tok_left_brace, yajl_tok_left_bracket, yajl_tok_null, yajl_tok_right_brace, yajl_tok_right_bracket, /* we differentiate between integers and doubles to allow the * parser to interpret the number without re-scanning */ yajl_tok_integer, yajl_tok_double, /* we differentiate between strings which require further processing, * and strings that do not */ yajl_tok_string, yajl_tok_string_with_escapes, /* comment tokens are not currently returned to the parser, ever */ yajl_tok_comment } yajl_tok; typedef struct yajl_lexer_t * yajl_lexer; yajl_lexer yajl_lex_alloc(yajl_alloc_funcs * alloc, unsigned int allowComments, unsigned int validateUTF8); void yajl_lex_free(yajl_lexer lexer); /** * run/continue a lex. "offset" is an input/output parameter. * It should be initialized to zero for a * new chunk of target text, and upon subsetquent calls with the same * target text should passed with the value of the previous invocation. * * the client may be interested in the value of offset when an error is * returned from the lexer. This allows the client to render useful * error messages. * * When you pass the next chunk of data, context should be reinitialized * to zero. * * Finally, the output buffer is usually just a pointer into the jsonText, * however in cases where the entity being lexed spans multiple chunks, * the lexer will buffer the entity and the data returned will be * a pointer into that buffer. * * This behavior is abstracted from client code except for the performance * implications which require that the client choose a reasonable chunk * size to get adequate performance. */ yajl_tok yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t * offset, const unsigned char ** outBuf, size_t * outLen); /** have a peek at the next token, but don't move the lexer forward */ yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText, size_t jsonTextLen, size_t offset); typedef enum { yajl_lex_e_ok = 0, yajl_lex_string_invalid_utf8, yajl_lex_string_invalid_escaped_char, yajl_lex_string_invalid_json_char, yajl_lex_string_invalid_hex_char, yajl_lex_invalid_char, yajl_lex_invalid_string, yajl_lex_missing_integer_after_decimal, yajl_lex_missing_integer_after_exponent, yajl_lex_missing_integer_after_minus, yajl_lex_unallowed_comment } yajl_lex_error; const char * yajl_lex_error_to_string(yajl_lex_error error); /** allows access to more specific information about the lexical * error when yajl_lex_lex returns yajl_tok_error. */ yajl_lex_error yajl_lex_get_error(yajl_lexer lexer); /** get the current offset into the most recently lexed json string. */ size_t yajl_lex_current_offset(yajl_lexer lexer); /** get the number of lines lexed by this lexer instance */ size_t yajl_lex_current_line(yajl_lexer lexer); /** get the number of chars lexed by this lexer instance since the last * \n or \r */ size_t yajl_lex_current_char(yajl_lexer lexer); #endif yajl-2.1.0/src/yajl_parser.c000066400000000000000000000502171231222176500157250ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "api/yajl_parse.h" #include "yajl_lex.h" #include "yajl_parser.h" #include "yajl_encode.h" #include "yajl_bytestack.h" #include #include #include #include #include #include #include #include #define MAX_VALUE_TO_MULTIPLY ((LLONG_MAX / 10) + (LLONG_MAX % 10)) /* same semantics as strtol */ long long yajl_parse_integer(const unsigned char *number, unsigned int length) { long long ret = 0; long sign = 1; const unsigned char *pos = number; if (*pos == '-') { pos++; sign = -1; } if (*pos == '+') { pos++; } while (pos < number + length) { if ( ret > MAX_VALUE_TO_MULTIPLY ) { errno = ERANGE; return sign == 1 ? LLONG_MAX : LLONG_MIN; } ret *= 10; if (LLONG_MAX - ret < (*pos - '0')) { errno = ERANGE; return sign == 1 ? LLONG_MAX : LLONG_MIN; } if (*pos < '0' || *pos > '9') { errno = ERANGE; return sign == 1 ? LLONG_MAX : LLONG_MIN; } ret += (*pos++ - '0'); } return sign * ret; } unsigned char * yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLen, int verbose) { size_t offset = hand->bytesConsumed; unsigned char * str; const char * errorType = NULL; const char * errorText = NULL; char text[72]; const char * arrow = " (right here) ------^\n"; if (yajl_bs_current(hand->stateStack) == yajl_state_parse_error) { errorType = "parse"; errorText = hand->parseError; } else if (yajl_bs_current(hand->stateStack) == yajl_state_lexical_error) { errorType = "lexical"; errorText = yajl_lex_error_to_string(yajl_lex_get_error(hand->lexer)); } else { errorType = "unknown"; } { size_t memneeded = 0; memneeded += strlen(errorType); memneeded += strlen(" error"); if (errorText != NULL) { memneeded += strlen(": "); memneeded += strlen(errorText); } str = (unsigned char *) YA_MALLOC(&(hand->alloc), memneeded + 2); if (!str) return NULL; str[0] = 0; strcat((char *) str, errorType); strcat((char *) str, " error"); if (errorText != NULL) { strcat((char *) str, ": "); strcat((char *) str, errorText); } strcat((char *) str, "\n"); } /* now we append as many spaces as needed to make sure the error * falls at char 41, if verbose was specified */ if (verbose) { size_t start, end, i; size_t spacesNeeded; spacesNeeded = (offset < 30 ? 40 - offset : 10); start = (offset >= 30 ? offset - 30 : 0); end = (offset + 30 > jsonTextLen ? jsonTextLen : offset + 30); for (i=0;ialloc), (unsigned int)(strlen((char *) str) + strlen((char *) text) + strlen(arrow) + 1)); if (newStr) { newStr[0] = 0; strcat((char *) newStr, (char *) str); strcat((char *) newStr, text); strcat((char *) newStr, arrow); } YA_FREE(&(hand->alloc), str); str = (unsigned char *) newStr; } } return str; } /* check for client cancelation */ #define _CC_CHK(x) \ if (!(x)) { \ yajl_bs_set(hand->stateStack, yajl_state_parse_error); \ hand->parseError = \ "client cancelled parse via callback return value"; \ return yajl_status_client_canceled; \ } yajl_status yajl_do_finish(yajl_handle hand) { yajl_status stat; stat = yajl_do_parse(hand,(const unsigned char *) " ",1); if (stat != yajl_status_ok) return stat; switch(yajl_bs_current(hand->stateStack)) { case yajl_state_parse_error: case yajl_state_lexical_error: return yajl_status_error; case yajl_state_got_value: case yajl_state_parse_complete: return yajl_status_ok; default: if (!(hand->flags & yajl_allow_partial_values)) { yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "premature EOF"; return yajl_status_error; } return yajl_status_ok; } } yajl_status yajl_do_parse(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLen) { yajl_tok tok; const unsigned char * buf; size_t bufLen; size_t * offset = &(hand->bytesConsumed); *offset = 0; around_again: switch (yajl_bs_current(hand->stateStack)) { case yajl_state_parse_complete: if (hand->flags & yajl_allow_multiple_values) { yajl_bs_set(hand->stateStack, yajl_state_got_value); goto around_again; } if (!(hand->flags & yajl_allow_trailing_garbage)) { if (*offset != jsonTextLen) { tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); if (tok != yajl_tok_eof) { yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "trailing garbage"; } goto around_again; } } return yajl_status_ok; case yajl_state_lexical_error: case yajl_state_parse_error: return yajl_status_error; case yajl_state_start: case yajl_state_got_value: case yajl_state_map_need_val: case yajl_state_array_need_val: case yajl_state_array_start: { /* for arrays and maps, we advance the state for this * depth, then push the state of the next depth. * If an error occurs during the parsing of the nesting * enitity, the state at this level will not matter. * a state that needs pushing will be anything other * than state_start */ yajl_state stateToPush = yajl_state_start; tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; case yajl_tok_string: if (hand->callbacks && hand->callbacks->yajl_string) { _CC_CHK(hand->callbacks->yajl_string(hand->ctx, buf, bufLen)); } break; case yajl_tok_string_with_escapes: if (hand->callbacks && hand->callbacks->yajl_string) { yajl_buf_clear(hand->decodeBuf); yajl_string_decode(hand->decodeBuf, buf, bufLen); _CC_CHK(hand->callbacks->yajl_string( hand->ctx, yajl_buf_data(hand->decodeBuf), yajl_buf_len(hand->decodeBuf))); } break; case yajl_tok_bool: if (hand->callbacks && hand->callbacks->yajl_boolean) { _CC_CHK(hand->callbacks->yajl_boolean(hand->ctx, *buf == 't')); } break; case yajl_tok_null: if (hand->callbacks && hand->callbacks->yajl_null) { _CC_CHK(hand->callbacks->yajl_null(hand->ctx)); } break; case yajl_tok_left_bracket: if (hand->callbacks && hand->callbacks->yajl_start_map) { _CC_CHK(hand->callbacks->yajl_start_map(hand->ctx)); } stateToPush = yajl_state_map_start; break; case yajl_tok_left_brace: if (hand->callbacks && hand->callbacks->yajl_start_array) { _CC_CHK(hand->callbacks->yajl_start_array(hand->ctx)); } stateToPush = yajl_state_array_start; break; case yajl_tok_integer: if (hand->callbacks) { if (hand->callbacks->yajl_number) { _CC_CHK(hand->callbacks->yajl_number( hand->ctx,(const char *) buf, bufLen)); } else if (hand->callbacks->yajl_integer) { long long int i = 0; errno = 0; i = yajl_parse_integer(buf, bufLen); if ((i == LLONG_MIN || i == LLONG_MAX) && errno == ERANGE) { yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "integer overflow" ; /* try to restore error offset */ if (*offset >= bufLen) *offset -= bufLen; else *offset = 0; goto around_again; } _CC_CHK(hand->callbacks->yajl_integer(hand->ctx, i)); } } break; case yajl_tok_double: if (hand->callbacks) { if (hand->callbacks->yajl_number) { _CC_CHK(hand->callbacks->yajl_number( hand->ctx, (const char *) buf, bufLen)); } else if (hand->callbacks->yajl_double) { double d = 0.0; yajl_buf_clear(hand->decodeBuf); yajl_buf_append(hand->decodeBuf, buf, bufLen); buf = yajl_buf_data(hand->decodeBuf); errno = 0; d = strtod((char *) buf, NULL); if ((d == HUGE_VAL || d == -HUGE_VAL) && errno == ERANGE) { yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "numeric (floating point) " "overflow"; /* try to restore error offset */ if (*offset >= bufLen) *offset -= bufLen; else *offset = 0; goto around_again; } _CC_CHK(hand->callbacks->yajl_double(hand->ctx, d)); } } break; case yajl_tok_right_brace: { if (yajl_bs_current(hand->stateStack) == yajl_state_array_start) { if (hand->callbacks && hand->callbacks->yajl_end_array) { _CC_CHK(hand->callbacks->yajl_end_array(hand->ctx)); } yajl_bs_pop(hand->stateStack); goto around_again; } /* intentional fall-through */ } case yajl_tok_colon: case yajl_tok_comma: case yajl_tok_right_bracket: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "unallowed token at this point in JSON text"; goto around_again; default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "invalid token, internal error"; goto around_again; } /* got a value. transition depends on the state we're in. */ { yajl_state s = yajl_bs_current(hand->stateStack); if (s == yajl_state_start || s == yajl_state_got_value) { yajl_bs_set(hand->stateStack, yajl_state_parse_complete); } else if (s == yajl_state_map_need_val) { yajl_bs_set(hand->stateStack, yajl_state_map_got_val); } else { yajl_bs_set(hand->stateStack, yajl_state_array_got_val); } } if (stateToPush != yajl_state_start) { yajl_bs_push(hand->stateStack, stateToPush); } goto around_again; } case yajl_state_map_start: case yajl_state_map_need_key: { /* only difference between these two states is that in * start '}' is valid, whereas in need_key, we've parsed * a comma, and a string key _must_ follow */ tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; case yajl_tok_string_with_escapes: if (hand->callbacks && hand->callbacks->yajl_map_key) { yajl_buf_clear(hand->decodeBuf); yajl_string_decode(hand->decodeBuf, buf, bufLen); buf = yajl_buf_data(hand->decodeBuf); bufLen = yajl_buf_len(hand->decodeBuf); } /* intentional fall-through */ case yajl_tok_string: if (hand->callbacks && hand->callbacks->yajl_map_key) { _CC_CHK(hand->callbacks->yajl_map_key(hand->ctx, buf, bufLen)); } yajl_bs_set(hand->stateStack, yajl_state_map_sep); goto around_again; case yajl_tok_right_bracket: if (yajl_bs_current(hand->stateStack) == yajl_state_map_start) { if (hand->callbacks && hand->callbacks->yajl_end_map) { _CC_CHK(hand->callbacks->yajl_end_map(hand->ctx)); } yajl_bs_pop(hand->stateStack); goto around_again; } default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "invalid object key (must be a string)"; goto around_again; } } case yajl_state_map_sep: { tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_colon: yajl_bs_set(hand->stateStack, yajl_state_map_need_val); goto around_again; case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "object key and value must " "be separated by a colon (':')"; goto around_again; } } case yajl_state_map_got_val: { tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_right_bracket: if (hand->callbacks && hand->callbacks->yajl_end_map) { _CC_CHK(hand->callbacks->yajl_end_map(hand->ctx)); } yajl_bs_pop(hand->stateStack); goto around_again; case yajl_tok_comma: yajl_bs_set(hand->stateStack, yajl_state_map_need_key); goto around_again; case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "after key and value, inside map, " "I expect ',' or '}'"; /* try to restore error offset */ if (*offset >= bufLen) *offset -= bufLen; else *offset = 0; goto around_again; } } case yajl_state_array_got_val: { tok = yajl_lex_lex(hand->lexer, jsonText, jsonTextLen, offset, &buf, &bufLen); switch (tok) { case yajl_tok_right_brace: if (hand->callbacks && hand->callbacks->yajl_end_array) { _CC_CHK(hand->callbacks->yajl_end_array(hand->ctx)); } yajl_bs_pop(hand->stateStack); goto around_again; case yajl_tok_comma: yajl_bs_set(hand->stateStack, yajl_state_array_need_val); goto around_again; case yajl_tok_eof: return yajl_status_ok; case yajl_tok_error: yajl_bs_set(hand->stateStack, yajl_state_lexical_error); goto around_again; default: yajl_bs_set(hand->stateStack, yajl_state_parse_error); hand->parseError = "after array element, I expect ',' or ']'"; goto around_again; } } } abort(); return yajl_status_error; } yajl-2.1.0/src/yajl_parser.h000066400000000000000000000047001231222176500157260ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef __YAJL_PARSER_H__ #define __YAJL_PARSER_H__ #include "api/yajl_parse.h" #include "yajl_bytestack.h" #include "yajl_buf.h" #include "yajl_lex.h" typedef enum { yajl_state_start = 0, yajl_state_parse_complete, yajl_state_parse_error, yajl_state_lexical_error, yajl_state_map_start, yajl_state_map_sep, yajl_state_map_need_val, yajl_state_map_got_val, yajl_state_map_need_key, yajl_state_array_start, yajl_state_array_got_val, yajl_state_array_need_val, yajl_state_got_value, } yajl_state; struct yajl_handle_t { const yajl_callbacks * callbacks; void * ctx; yajl_lexer lexer; const char * parseError; /* the number of bytes consumed from the last client buffer, * in the case of an error this will be an error offset, in the * case of an error this can be used as the error offset */ size_t bytesConsumed; /* temporary storage for decoded strings */ yajl_buf decodeBuf; /* a stack of states. access with yajl_state_XXX routines */ yajl_bytestack stateStack; /* memory allocation routines */ yajl_alloc_funcs alloc; /* bitfield */ unsigned int flags; }; yajl_status yajl_do_parse(yajl_handle handle, const unsigned char * jsonText, size_t jsonTextLen); yajl_status yajl_do_finish(yajl_handle handle); unsigned char * yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText, size_t jsonTextLen, int verbose); /* A little built in integer parsing routine with the same semantics as strtol * that's unaffected by LOCALE. */ long long yajl_parse_integer(const unsigned char *number, unsigned int length); #endif yajl-2.1.0/src/yajl_tree.c000066400000000000000000000325771231222176500154010ustar00rootroot00000000000000/* * Copyright (c) 2010-2011 Florian Forster * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include "api/yajl_tree.h" #include "api/yajl_parse.h" #include "yajl_parser.h" #if defined(_WIN32) || defined(WIN32) #define snprintf sprintf_s #endif #define STATUS_CONTINUE 1 #define STATUS_ABORT 0 struct stack_elem_s; typedef struct stack_elem_s stack_elem_t; struct stack_elem_s { char * key; yajl_val value; stack_elem_t *next; }; struct context_s { stack_elem_t *stack; yajl_val root; char *errbuf; size_t errbuf_size; }; typedef struct context_s context_t; #define RETURN_ERROR(ctx,retval,...) { \ if ((ctx)->errbuf != NULL) \ snprintf ((ctx)->errbuf, (ctx)->errbuf_size, __VA_ARGS__); \ return (retval); \ } static yajl_val value_alloc (yajl_type type) { yajl_val v; v = malloc (sizeof (*v)); if (v == NULL) return (NULL); memset (v, 0, sizeof (*v)); v->type = type; return (v); } static void yajl_object_free (yajl_val v) { size_t i; if (!YAJL_IS_OBJECT(v)) return; for (i = 0; i < v->u.object.len; i++) { free((char *) v->u.object.keys[i]); v->u.object.keys[i] = NULL; yajl_tree_free (v->u.object.values[i]); v->u.object.values[i] = NULL; } free((void*) v->u.object.keys); free(v->u.object.values); free(v); } static void yajl_array_free (yajl_val v) { size_t i; if (!YAJL_IS_ARRAY(v)) return; for (i = 0; i < v->u.array.len; i++) { yajl_tree_free (v->u.array.values[i]); v->u.array.values[i] = NULL; } free(v->u.array.values); free(v); } /* * Parsing nested objects and arrays is implemented using a stack. When a new * object or array starts (a curly or a square opening bracket is read), an * appropriate value is pushed on the stack. When the end of the object is * reached (an appropriate closing bracket has been read), the value is popped * off the stack and added to the enclosing object using "context_add_value". */ static int context_push(context_t *ctx, yajl_val v) { stack_elem_t *stack; stack = malloc (sizeof (*stack)); if (stack == NULL) RETURN_ERROR (ctx, ENOMEM, "Out of memory"); memset (stack, 0, sizeof (*stack)); assert ((ctx->stack == NULL) || YAJL_IS_OBJECT (v) || YAJL_IS_ARRAY (v)); stack->value = v; stack->next = ctx->stack; ctx->stack = stack; return (0); } static yajl_val context_pop(context_t *ctx) { stack_elem_t *stack; yajl_val v; if (ctx->stack == NULL) RETURN_ERROR (ctx, NULL, "context_pop: " "Bottom of stack reached prematurely"); stack = ctx->stack; ctx->stack = stack->next; v = stack->value; free (stack); return (v); } static int object_add_keyval(context_t *ctx, yajl_val obj, char *key, yajl_val value) { const char **tmpk; yajl_val *tmpv; /* We're checking for NULL in "context_add_value" or its callers. */ assert (ctx != NULL); assert (obj != NULL); assert (key != NULL); assert (value != NULL); /* We're assuring that "obj" is an object in "context_add_value". */ assert(YAJL_IS_OBJECT(obj)); tmpk = realloc((void *) obj->u.object.keys, sizeof(*(obj->u.object.keys)) * (obj->u.object.len + 1)); if (tmpk == NULL) RETURN_ERROR(ctx, ENOMEM, "Out of memory"); obj->u.object.keys = tmpk; tmpv = realloc(obj->u.object.values, sizeof (*obj->u.object.values) * (obj->u.object.len + 1)); if (tmpv == NULL) RETURN_ERROR(ctx, ENOMEM, "Out of memory"); obj->u.object.values = tmpv; obj->u.object.keys[obj->u.object.len] = key; obj->u.object.values[obj->u.object.len] = value; obj->u.object.len++; return (0); } static int array_add_value (context_t *ctx, yajl_val array, yajl_val value) { yajl_val *tmp; /* We're checking for NULL pointers in "context_add_value" or its * callers. */ assert (ctx != NULL); assert (array != NULL); assert (value != NULL); /* "context_add_value" will only call us with array values. */ assert(YAJL_IS_ARRAY(array)); tmp = realloc(array->u.array.values, sizeof(*(array->u.array.values)) * (array->u.array.len + 1)); if (tmp == NULL) RETURN_ERROR(ctx, ENOMEM, "Out of memory"); array->u.array.values = tmp; array->u.array.values[array->u.array.len] = value; array->u.array.len++; return 0; } /* * Add a value to the value on top of the stack or the "root" member in the * context if the end of the parsing process is reached. */ static int context_add_value (context_t *ctx, yajl_val v) { /* We're checking for NULL values in all the calling functions. */ assert (ctx != NULL); assert (v != NULL); /* * There are three valid states in which this function may be called: * - There is no value on the stack => This is the only value. This is the * last step done when parsing a document. We assign the value to the * "root" member and return. * - The value on the stack is an object. In this case store the key on the * stack or, if the key has already been read, add key and value to the * object. * - The value on the stack is an array. In this case simply add the value * and return. */ if (ctx->stack == NULL) { assert (ctx->root == NULL); ctx->root = v; return (0); } else if (YAJL_IS_OBJECT (ctx->stack->value)) { if (ctx->stack->key == NULL) { if (!YAJL_IS_STRING (v)) RETURN_ERROR (ctx, EINVAL, "context_add_value: " "Object key is not a string (%#04x)", v->type); ctx->stack->key = v->u.string; v->u.string = NULL; free(v); return (0); } else /* if (ctx->key != NULL) */ { char * key; key = ctx->stack->key; ctx->stack->key = NULL; return (object_add_keyval (ctx, ctx->stack->value, key, v)); } } else if (YAJL_IS_ARRAY (ctx->stack->value)) { return (array_add_value (ctx, ctx->stack->value, v)); } else { RETURN_ERROR (ctx, EINVAL, "context_add_value: Cannot add value to " "a value of type %#04x (not a composite type)", ctx->stack->value->type); } } static int handle_string (void *ctx, const unsigned char *string, size_t string_length) { yajl_val v; v = value_alloc (yajl_t_string); if (v == NULL) RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory"); v->u.string = malloc (string_length + 1); if (v->u.string == NULL) { free (v); RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory"); } memcpy(v->u.string, string, string_length); v->u.string[string_length] = 0; return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT); } static int handle_number (void *ctx, const char *string, size_t string_length) { yajl_val v; char *endptr; v = value_alloc(yajl_t_number); if (v == NULL) RETURN_ERROR((context_t *) ctx, STATUS_ABORT, "Out of memory"); v->u.number.r = malloc(string_length + 1); if (v->u.number.r == NULL) { free(v); RETURN_ERROR((context_t *) ctx, STATUS_ABORT, "Out of memory"); } memcpy(v->u.number.r, string, string_length); v->u.number.r[string_length] = 0; v->u.number.flags = 0; errno = 0; v->u.number.i = yajl_parse_integer((const unsigned char *) v->u.number.r, strlen(v->u.number.r)); if (errno == 0) v->u.number.flags |= YAJL_NUMBER_INT_VALID; endptr = NULL; errno = 0; v->u.number.d = strtod(v->u.number.r, &endptr); if ((errno == 0) && (endptr != NULL) && (*endptr == 0)) v->u.number.flags |= YAJL_NUMBER_DOUBLE_VALID; return ((context_add_value(ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT); } static int handle_start_map (void *ctx) { yajl_val v; v = value_alloc(yajl_t_object); if (v == NULL) RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory"); v->u.object.keys = NULL; v->u.object.values = NULL; v->u.object.len = 0; return ((context_push (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT); } static int handle_end_map (void *ctx) { yajl_val v; v = context_pop (ctx); if (v == NULL) return (STATUS_ABORT); return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT); } static int handle_start_array (void *ctx) { yajl_val v; v = value_alloc(yajl_t_array); if (v == NULL) RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory"); v->u.array.values = NULL; v->u.array.len = 0; return ((context_push (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT); } static int handle_end_array (void *ctx) { yajl_val v; v = context_pop (ctx); if (v == NULL) return (STATUS_ABORT); return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT); } static int handle_boolean (void *ctx, int boolean_value) { yajl_val v; v = value_alloc (boolean_value ? yajl_t_true : yajl_t_false); if (v == NULL) RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory"); return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT); } static int handle_null (void *ctx) { yajl_val v; v = value_alloc (yajl_t_null); if (v == NULL) RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory"); return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT); } /* * Public functions */ yajl_val yajl_tree_parse (const char *input, char *error_buffer, size_t error_buffer_size) { static const yajl_callbacks callbacks = { /* null = */ handle_null, /* boolean = */ handle_boolean, /* integer = */ NULL, /* double = */ NULL, /* number = */ handle_number, /* string = */ handle_string, /* start map = */ handle_start_map, /* map key = */ handle_string, /* end map = */ handle_end_map, /* start array = */ handle_start_array, /* end array = */ handle_end_array }; yajl_handle handle; yajl_status status; char * internal_err_str; context_t ctx = { NULL, NULL, NULL, 0 }; ctx.errbuf = error_buffer; ctx.errbuf_size = error_buffer_size; if (error_buffer != NULL) memset (error_buffer, 0, error_buffer_size); handle = yajl_alloc (&callbacks, NULL, &ctx); yajl_config(handle, yajl_allow_comments, 1); status = yajl_parse(handle, (unsigned char *) input, strlen (input)); status = yajl_complete_parse (handle); if (status != yajl_status_ok) { if (error_buffer != NULL && error_buffer_size > 0) { internal_err_str = (char *) yajl_get_error(handle, 1, (const unsigned char *) input, strlen(input)); snprintf(error_buffer, error_buffer_size, "%s", internal_err_str); YA_FREE(&(handle->alloc), internal_err_str); } yajl_free (handle); return NULL; } yajl_free (handle); return (ctx.root); } yajl_val yajl_tree_get(yajl_val n, const char ** path, yajl_type type) { if (!path) return NULL; while (n && *path) { size_t i; size_t len; if (n->type != yajl_t_object) return NULL; len = n->u.object.len; for (i = 0; i < len; i++) { if (!strcmp(*path, n->u.object.keys[i])) { n = n->u.object.values[i]; break; } } if (i == len) return NULL; path++; } if (n && type != yajl_t_any && type != n->type) n = NULL; return n; } void yajl_tree_free (yajl_val v) { if (v == NULL) return; if (YAJL_IS_STRING(v)) { free(v->u.string); free(v); } else if (YAJL_IS_NUMBER(v)) { free(v->u.number.r); free(v); } else if (YAJL_GET_OBJECT(v)) { yajl_object_free(v); } else if (YAJL_GET_ARRAY(v)) { yajl_array_free(v); } else /* if (yajl_t_true or yajl_t_false or yajl_t_null) */ { free(v); } } yajl-2.1.0/src/yajl_version.c000066400000000000000000000001221231222176500161040ustar00rootroot00000000000000#include int yajl_version(void) { return YAJL_VERSION; } yajl-2.1.0/test/000077500000000000000000000000001231222176500134315ustar00rootroot00000000000000yajl-2.1.0/test/CMakeLists.txt000066400000000000000000000014701231222176500161730ustar00rootroot00000000000000# Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADD_SUBDIRECTORY(parsing) ADD_SUBDIRECTORY(api) yajl-2.1.0/test/api/000077500000000000000000000000001231222176500142025ustar00rootroot00000000000000yajl-2.1.0/test/api/CMakeLists.txt000066400000000000000000000022761231222176500167510ustar00rootroot00000000000000# Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. SET (TESTS gen-extra-close.c ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/include) LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib) # for each test, we'll create a target, and make the api-tests target depend on it FOREACH (test ${TESTS}) GET_FILENAME_COMPONENT(testProg ${test} NAME_WE) ADD_EXECUTABLE(${testProg} ${test}) TARGET_LINK_LIBRARIES(${testProg} yajl) ENDFOREACH() yajl-2.1.0/test/api/gen-extra-close.c000066400000000000000000000006421231222176500173450ustar00rootroot00000000000000/* ensure that if we try to generate an extra closing brace * we get the expected error */ #include #include #define CHK(x) if (x != yajl_gen_status_ok) return 1; int main(void) { yajl_gen yg; yajl_gen_status s; yg = yajl_gen_alloc(NULL); CHK(yajl_gen_map_open(yg)); CHK(yajl_gen_map_close(yg)); s = yajl_gen_map_close(yg); return (yajl_gen_generation_complete == s); } yajl-2.1.0/test/api/run_tests.sh000077500000000000000000000005461231222176500165740ustar00rootroot00000000000000#!/bin/sh echo Running api tests: tests=0 passed=0 for file in `ls`; do [ ! -x $file -o -d $file ] && continue tests=`expr 1 + $tests` printf " test(%s): " $file ./$file if [ $? ]; then passed=`expr 1 + $passed` echo 'SUCCESS' else echo 'FAILURE' fi done echo "$passed/$tests tests successful" exit 0 yajl-2.1.0/test/parsing/000077500000000000000000000000001231222176500150745ustar00rootroot00000000000000yajl-2.1.0/test/parsing/CMakeLists.txt000066400000000000000000000020501231222176500176310ustar00rootroot00000000000000# Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. SET (SRCS yajl_test.c) # use the library we build, duh. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/include) LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../../${YAJL_DIST_NAME}/lib) ADD_EXECUTABLE(yajl_test ${SRCS}) TARGET_LINK_LIBRARIES(yajl_test yajl_s) yajl-2.1.0/test/parsing/cases/000077500000000000000000000000001231222176500161725ustar00rootroot00000000000000yajl-2.1.0/test/parsing/cases/ac_difficult_json_c_test_case_with_comments.json000066400000000000000000000010361231222176500300260ustar00rootroot00000000000000{ "glossary": { /* you */ "title": /**/ "example glossary", /*should*/"GlossDiv": { "title": /*never*/"S", /*ever*/"GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", /*see*/"GlossSeeAlso"/*this*/:/*coming*/[/*out*/"GML"/*of*/,/*the*/"XML"/*parser!*/, "markup"] /*hey*/}/*ho*/]/*hey*/}/*ho*/} } // and the parser won't even get this far, so chill. /* hah! yajl-2.1.0/test/parsing/cases/ac_difficult_json_c_test_case_with_comments.json.gold000066400000000000000000000012121231222176500307460ustar00rootroot00000000000000map open '{' key: 'glossary' map open '{' key: 'title' string: 'example glossary' key: 'GlossDiv' map open '{' key: 'title' string: 'S' key: 'GlossList' array open '[' map open '{' key: 'ID' string: 'SGML' key: 'SortAs' string: 'SGML' key: 'GlossTerm' string: 'Standard Generalized Markup Language' key: 'Acronym' string: 'SGML' key: 'Abbrev' string: 'ISO 8879:1986' key: 'GlossDef' string: 'A meta-markup language, used to create markup languages such as DocBook.' key: 'GlossSeeAlso' array open '[' string: 'GML' string: 'XML' string: 'markup' array close ']' map close '}' array close ']' map close '}' map close '}' map close '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/ac_simple_with_comments.json000066400000000000000000000001671231222176500237650ustar00rootroot00000000000000{ "this": "is", // ignore this "really": "simple", /* ignore this too * / ** // (/ ******/ "json": "right?" } yajl-2.1.0/test/parsing/cases/ac_simple_with_comments.json.gold000066400000000000000000000002001231222176500246750ustar00rootroot00000000000000map open '{' key: 'this' string: 'is' key: 'really' string: 'simple' key: 'json' string: 'right?' map close '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/ag_false_then_garbage.json000066400000000000000000000000061231222176500233100ustar00rootroot00000000000000falsexyajl-2.1.0/test/parsing/cases/ag_false_then_garbage.json.gold000066400000000000000000000000341231222176500242350ustar00rootroot00000000000000bool: false memory leaks: 0 yajl-2.1.0/test/parsing/cases/ag_null_then_garbage.json000066400000000000000000000000061231222176500231700ustar00rootroot00000000000000nullx yajl-2.1.0/test/parsing/cases/ag_null_then_garbage.json.gold000066400000000000000000000000251231222176500241150ustar00rootroot00000000000000null memory leaks: 0 yajl-2.1.0/test/parsing/cases/ag_true_then_garbage.json000066400000000000000000000000051231222176500231740ustar00rootroot00000000000000truexyajl-2.1.0/test/parsing/cases/ag_true_then_garbage.json.gold000066400000000000000000000000331231222176500241210ustar00rootroot00000000000000bool: true memory leaks: 0 yajl-2.1.0/test/parsing/cases/am_eof.json000066400000000000000000000000111231222176500203030ustar00rootroot00000000000000{ "123": yajl-2.1.0/test/parsing/cases/am_eof.json.gold000066400000000000000000000001031231222176500212310ustar00rootroot00000000000000map open '{' key: '123' parse error: premature EOF memory leaks: 0 yajl-2.1.0/test/parsing/cases/am_integers.json000066400000000000000000000000101231222176500213510ustar00rootroot000000000000001221 21 yajl-2.1.0/test/parsing/cases/am_integers.json.gold000066400000000000000000000000521231222176500223030ustar00rootroot00000000000000integer: 1221 integer: 21 memory leaks: 0 yajl-2.1.0/test/parsing/cases/am_multiple.json000066400000000000000000000000071231222176500213720ustar00rootroot00000000000000 {} {} yajl-2.1.0/test/parsing/cases/am_multiple.json.gold000066400000000000000000000001061231222176500223160ustar00rootroot00000000000000map open '{' map close '}' map open '{' map close '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/am_stuff.json000066400000000000000000000000561231222176500206720ustar00rootroot00000000000000{} [] [] "sdfasd" 123 { "123" : 123 } 3.1e124 yajl-2.1.0/test/parsing/cases/am_stuff.json.gold000066400000000000000000000003131231222176500216120ustar00rootroot00000000000000map open '{' map close '}' array open '[' array close ']' array open '[' array close ']' string: 'sdfasd' integer: 123 map open '{' key: '123' integer: 123 map close '}' double: 3.1e+124 memory leaks: 0 yajl-2.1.0/test/parsing/cases/ap_array_open.json000066400000000000000000000000021231222176500216740ustar00rootroot00000000000000[ yajl-2.1.0/test/parsing/cases/ap_array_open.json.gold000066400000000000000000000000371231222176500226300ustar00rootroot00000000000000array open '[' memory leaks: 0 yajl-2.1.0/test/parsing/cases/ap_eof_str.json000066400000000000000000000000041231222176500212000ustar00rootroot00000000000000"abcyajl-2.1.0/test/parsing/cases/ap_eof_str.json.gold000066400000000000000000000000201231222176500221220ustar00rootroot00000000000000memory leaks: 0 yajl-2.1.0/test/parsing/cases/ap_map_open.json000066400000000000000000000000021231222176500213330ustar00rootroot00000000000000{ yajl-2.1.0/test/parsing/cases/ap_map_open.json.gold000066400000000000000000000000351231222176500222650ustar00rootroot00000000000000map open '{' memory leaks: 0 yajl-2.1.0/test/parsing/cases/ap_partial_ok.json000066400000000000000000000000171231222176500216700ustar00rootroot00000000000000[ "foo", "bar" yajl-2.1.0/test/parsing/cases/ap_partial_ok.json.gold000066400000000000000000000000731231222176500226160ustar00rootroot00000000000000array open '[' string: 'foo' string: 'bar' memory leaks: 0 yajl-2.1.0/test/parsing/cases/array.json000066400000000000000000000001331231222176500202000ustar00rootroot00000000000000["foo", "bar", "baz", true,false,null,{"key":"value"}, [null,null,null,[]], "\n\r\\" ] yajl-2.1.0/test/parsing/cases/array.json.gold000066400000000000000000000004061231222176500211270ustar00rootroot00000000000000array open '[' string: 'foo' string: 'bar' string: 'baz' bool: true bool: false null map open '{' key: 'key' string: 'value' map close '}' array open '[' null null null array open '[' array close ']' array close ']' string: ' \' array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/array_close.json000066400000000000000000000000021231222176500213600ustar00rootroot00000000000000] yajl-2.1.0/test/parsing/cases/array_close.json.gold000066400000000000000000000001101231222176500223040ustar00rootroot00000000000000parse error: unallowed token at this point in JSON text memory leaks: 0 yajl-2.1.0/test/parsing/cases/bignums.json000066400000000000000000000000561231222176500205320ustar00rootroot00000000000000[ 9223372036854775807, -9223372036854775807 ] yajl-2.1.0/test/parsing/cases/bignums.json.gold000066400000000000000000000001521231222176500214530ustar00rootroot00000000000000array open '[' integer: 9223372036854775807 integer: -9223372036854775807 array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/bogus_char.json000066400000000000000000000002301231222176500211740ustar00rootroot00000000000000["this","is","what","should","be", "a happy bit of json", "but someone, misspelled \"true\"", ture, "who says JSON is easy for humans to generate?"] yajl-2.1.0/test/parsing/cases/bogus_char.json.gold000066400000000000000000000003331231222176500221240ustar00rootroot00000000000000array open '[' string: 'this' string: 'is' string: 'what' string: 'should' string: 'be' string: 'a happy bit of json' string: 'but someone, misspelled "true"' lexical error: invalid string in json text. memory leaks: 0 yajl-2.1.0/test/parsing/cases/codepoints_from_unicode_org.json000066400000000000000000000000411231222176500246270ustar00rootroot00000000000000"\u004d\u0430\u4e8c\ud800\udf02" yajl-2.1.0/test/parsing/cases/codepoints_from_unicode_org.json.gold000066400000000000000000000000451231222176500255570ustar00rootroot00000000000000string: 'Mа二𐌂' memory leaks: 0 yajl-2.1.0/test/parsing/cases/deep_arrays.json000066400000000000000000000040001231222176500213550ustar00rootroot00000000000000[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]yajl-2.1.0/test/parsing/cases/deep_arrays.json.gold000066400000000000000000000760201231222176500223140ustar00rootroot00000000000000array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array open '[' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/difficult_json_c_test_case.json000066400000000000000000000005501231222176500244230ustar00rootroot00000000000000{ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": [ { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": ["GML", "XML", "markup"] } ] } } } yajl-2.1.0/test/parsing/cases/difficult_json_c_test_case.json.gold000066400000000000000000000012121231222176500253430ustar00rootroot00000000000000map open '{' key: 'glossary' map open '{' key: 'title' string: 'example glossary' key: 'GlossDiv' map open '{' key: 'title' string: 'S' key: 'GlossList' array open '[' map open '{' key: 'ID' string: 'SGML' key: 'SortAs' string: 'SGML' key: 'GlossTerm' string: 'Standard Generalized Markup Language' key: 'Acronym' string: 'SGML' key: 'Abbrev' string: 'ISO 8879:1986' key: 'GlossDef' string: 'A meta-markup language, used to create markup languages such as DocBook.' key: 'GlossSeeAlso' array open '[' string: 'GML' string: 'XML' string: 'markup' array close ']' map close '}' array close ']' map close '}' map close '}' map close '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/doubles.json000066400000000000000000000000541231222176500205210ustar00rootroot00000000000000[ 0.1e2, 1e1, 3.141569, 10000000000000e-10] yajl-2.1.0/test/parsing/cases/doubles.json.gold000066400000000000000000000001421231222176500214430ustar00rootroot00000000000000array open '[' double: 10 double: 10 double: 3.14157 double: 1000 array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/doubles_in_array.json000066400000000000000000000000651231222176500224070ustar00rootroot00000000000000[0.00011999999999999999, 6E-06, 6E-06, 1E-06, 1E-06] yajl-2.1.0/test/parsing/cases/doubles_in_array.json.gold000066400000000000000000000001671231222176500233360ustar00rootroot00000000000000array open '[' double: 0.00012 double: 6e-06 double: 6e-06 double: 1e-06 double: 1e-06 array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/empty_array.json000066400000000000000000000000021231222176500214110ustar00rootroot00000000000000[]yajl-2.1.0/test/parsing/cases/empty_array.json.gold000066400000000000000000000000571231222176500223470ustar00rootroot00000000000000array open '[' array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/empty_string.json000066400000000000000000000000031231222176500216020ustar00rootroot00000000000000"" yajl-2.1.0/test/parsing/cases/empty_string.json.gold000066400000000000000000000000331231222176500225310ustar00rootroot00000000000000string: '' memory leaks: 0 yajl-2.1.0/test/parsing/cases/escaped_bulgarian.json000066400000000000000000000001501231222176500225110ustar00rootroot00000000000000["\u0414\u0430", "\u041c\u0443", "\u0415\u0431\u0430", "\u041c\u0430\u0439\u043a\u0430\u0442\u0430"] yajl-2.1.0/test/parsing/cases/escaped_bulgarian.json.gold000066400000000000000000000001671231222176500234450ustar00rootroot00000000000000array open '[' string: 'Да' string: 'Му' string: 'Еба' string: 'Майката' array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/escaped_foobar.json000066400000000000000000000000471231222176500220220ustar00rootroot00000000000000"\u0066\u006f\u006f\u0062\u0061\u0072" yajl-2.1.0/test/parsing/cases/escaped_foobar.json.gold000066400000000000000000000000411231222176500227400ustar00rootroot00000000000000string: 'foobar' memory leaks: 0 yajl-2.1.0/test/parsing/cases/false.json000066400000000000000000000000061231222176500201530ustar00rootroot00000000000000false yajl-2.1.0/test/parsing/cases/false.json.gold000066400000000000000000000000341231222176500211000ustar00rootroot00000000000000bool: false memory leaks: 0 yajl-2.1.0/test/parsing/cases/fg_false_then_garbage.json000066400000000000000000000000061231222176500233150ustar00rootroot00000000000000falsexyajl-2.1.0/test/parsing/cases/fg_false_then_garbage.json.gold000066400000000000000000000000721231222176500242440ustar00rootroot00000000000000bool: false parse error: trailing garbage memory leaks: 0 yajl-2.1.0/test/parsing/cases/fg_issue_7.json000066400000000000000000000000331231222176500211130ustar00rootroot000000000000002009-10-20@20:38:21.539575 yajl-2.1.0/test/parsing/cases/fg_issue_7.json.gold000066400000000000000000000000741231222176500220440ustar00rootroot00000000000000integer: 2009 parse error: trailing garbage memory leaks: 0 yajl-2.1.0/test/parsing/cases/fg_null_then_garbage.json000066400000000000000000000000061231222176500231750ustar00rootroot00000000000000nullx yajl-2.1.0/test/parsing/cases/fg_null_then_garbage.json.gold000066400000000000000000000000631231222176500241240ustar00rootroot00000000000000null parse error: trailing garbage memory leaks: 0 yajl-2.1.0/test/parsing/cases/fg_true_then_garbage.json000066400000000000000000000000061231222176500232020ustar00rootroot00000000000000truex yajl-2.1.0/test/parsing/cases/fg_true_then_garbage.json.gold000066400000000000000000000000711231222176500241300ustar00rootroot00000000000000bool: true parse error: trailing garbage memory leaks: 0 yajl-2.1.0/test/parsing/cases/four_byte_utf8.json000066400000000000000000000000301231222176500220220ustar00rootroot00000000000000{ "U+10ABCD": "􊯍" } yajl-2.1.0/test/parsing/cases/four_byte_utf8.json.gold000066400000000000000000000001121231222176500227470ustar00rootroot00000000000000map open '{' key: 'U+10ABCD' string: '􊯍' map close '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/high_overflow.json000066400000000000000000000000231231222176500217220ustar00rootroot000000000000009223372036854775808yajl-2.1.0/test/parsing/cases/high_overflow.json.gold000066400000000000000000000000561231222176500226540ustar00rootroot00000000000000parse error: integer overflow memory leaks: 0 yajl-2.1.0/test/parsing/cases/integers.json000066400000000000000000000001071231222176500207030ustar00rootroot00000000000000[ 1,2,3,4,5,6,7, 123456789 , -123456789, 2147483647, -2147483647 ] yajl-2.1.0/test/parsing/cases/integers.json.gold000066400000000000000000000003141231222176500216270ustar00rootroot00000000000000array open '[' integer: 1 integer: 2 integer: 3 integer: 4 integer: 5 integer: 6 integer: 7 integer: 123456789 integer: -123456789 integer: 2147483647 integer: -2147483647 array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/invalid_utf8.json000066400000000000000000000000431231222176500214560ustar00rootroot00000000000000["Да М Еба Майката"] yajl-2.1.0/test/parsing/cases/invalid_utf8.json.gold000066400000000000000000000001141231222176500224010ustar00rootroot00000000000000array open '[' lexical error: invalid bytes in UTF8 string. memory leaks: 0 yajl-2.1.0/test/parsing/cases/isolated_surrogate_marker.json000066400000000000000000000000111231222176500243150ustar00rootroot00000000000000"\ud800" yajl-2.1.0/test/parsing/cases/isolated_surrogate_marker.json.gold000066400000000000000000000000341231222176500252460ustar00rootroot00000000000000string: '?' memory leaks: 0 yajl-2.1.0/test/parsing/cases/leading_zero_in_number.json000066400000000000000000000000241231222176500235610ustar00rootroot00000000000000{ "bad thing": 01 } yajl-2.1.0/test/parsing/cases/leading_zero_in_number.json.gold000066400000000000000000000001731231222176500245120ustar00rootroot00000000000000map open '{' key: 'bad thing' integer: 0 parse error: after key and value, inside map, I expect ',' or '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/lonely_minus_sign.json000066400000000000000000000001271231222176500226220ustar00rootroot00000000000000[ "foo", true, true, "blue", "baby where are you?", "oh boo hoo!", - ] yajl-2.1.0/test/parsing/cases/lonely_minus_sign.json.gold000066400000000000000000000003211231222176500235420ustar00rootroot00000000000000array open '[' string: 'foo' bool: true bool: true string: 'blue' string: 'baby where are you?' string: 'oh boo hoo!' lexical error: malformed number, a digit is required after the minus sign. memory leaks: 0 yajl-2.1.0/test/parsing/cases/lonely_number.json000066400000000000000000000000111231222176500217270ustar00rootroot00000000000000123456789yajl-2.1.0/test/parsing/cases/lonely_number.json.gold000066400000000000000000000000431231222176500226600ustar00rootroot00000000000000integer: 123456789 memory leaks: 0 yajl-2.1.0/test/parsing/cases/low_overflow.json000066400000000000000000000000241231222176500216050ustar00rootroot00000000000000-9223372036854775808yajl-2.1.0/test/parsing/cases/low_overflow.json.gold000066400000000000000000000000561231222176500225360ustar00rootroot00000000000000parse error: integer overflow memory leaks: 0 yajl-2.1.0/test/parsing/cases/map_close.json000066400000000000000000000000021231222176500210170ustar00rootroot00000000000000} yajl-2.1.0/test/parsing/cases/map_close.json.gold000066400000000000000000000001101231222176500217430ustar00rootroot00000000000000parse error: unallowed token at this point in JSON text memory leaks: 0 yajl-2.1.0/test/parsing/cases/missing_integer_after_decimal_point.json000066400000000000000000000000061231222176500263170ustar00rootroot0000000000000010.e2 yajl-2.1.0/test/parsing/cases/missing_integer_after_decimal_point.json.gold000066400000000000000000000001361231222176500272470ustar00rootroot00000000000000lexical error: malformed number, a digit is required after the decimal point. memory leaks: 0 yajl-2.1.0/test/parsing/cases/missing_integer_after_exponent.json000066400000000000000000000000041231222176500253460ustar00rootroot0000000000000010e yajl-2.1.0/test/parsing/cases/missing_integer_after_exponent.json.gold000066400000000000000000000001311231222176500262730ustar00rootroot00000000000000lexical error: malformed number, a digit is required after the exponent. memory leaks: 0 yajl-2.1.0/test/parsing/cases/multiple.json000066400000000000000000000000071231222176500207150ustar00rootroot00000000000000 {} {} yajl-2.1.0/test/parsing/cases/multiple.json.gold000066400000000000000000000001111231222176500216350ustar00rootroot00000000000000map open '{' map close '}' parse error: trailing garbage memory leaks: 0 yajl-2.1.0/test/parsing/cases/non_utf8_char_in_string.json000066400000000000000000000030771231222176500237050ustar00rootroot00000000000000{"CoreletAPIVersion":2,"CoreletType":"standalone","documentation":"A corelet that provides the capability to upload a folders contents into a users locker.","functions":[{"documentation":"Displays a dialog box that allows user to select a folder on the local system.","name":"ShowBrowseDialog","parameters":[{"documentation":"The callback function for results.","name":"callback","required":true,"type":"callback"}]},{"documentation":"Uploads all mp3 files in the folder provided.","name":"UploadFolder","parameters":[{"documentation":"The path to upload mp3 files from.","name":"path","required":true,"type":"string"},{"documentation":"The callback function for progress.","name":"callback","required":true,"type":"callback"}]},{"documentation":"Returns the server name to the current locker service.","name":"GetLockerService","parameters":[]},{"documentation":"Changes the name of the locker service.","name":"SetLockerService","parameters":[{"documentation":"The value of the locker service to set active.","name":"LockerService","required":true,"type":"string"}]},{"documentation":"Downloads locker files to the suggested folder.","name":"DownloadFile","parameters":[{"documentation":"The origin path of the locker file.","name":"path","required":true,"type":"string"},{"documentation":"The Window destination path of the locker file.","name":"destination","required":true,"type":"integer"},{"documentation":"The callback function for progress.","name":"callback","required":true,"type":"callback"}]}],"name":"LockerUploader","version":{"major":0,"micro":1,"minor":0},"versionString":"0.0.1"}yajl-2.1.0/test/parsing/cases/non_utf8_char_in_string.json.gold000066400000000000000000000002531231222176500246220ustar00rootroot00000000000000map open '{' key: 'CoreletAPIVersion' integer: 2 key: 'CoreletType' string: 'standalone' key: 'documentation' lexical error: invalid bytes in UTF8 string. memory leaks: 0 yajl-2.1.0/test/parsing/cases/np_partial_bad.json000066400000000000000000000000171231222176500220220ustar00rootroot00000000000000[ "foo", "bar" yajl-2.1.0/test/parsing/cases/np_partial_bad.json.gold000066400000000000000000000001261231222176500227470ustar00rootroot00000000000000array open '[' string: 'foo' string: 'bar' parse error: premature EOF memory leaks: 0 yajl-2.1.0/test/parsing/cases/null.json000066400000000000000000000000051231222176500200320ustar00rootroot00000000000000null yajl-2.1.0/test/parsing/cases/null.json.gold000066400000000000000000000000251231222176500207600ustar00rootroot00000000000000null memory leaks: 0 yajl-2.1.0/test/parsing/cases/nulls_and_bools.json000066400000000000000000000001041231222176500222350ustar00rootroot00000000000000{ "boolean, true": true, "boolean, false": false, "null": null } yajl-2.1.0/test/parsing/cases/nulls_and_bools.json.gold000066400000000000000000000001761231222176500231720ustar00rootroot00000000000000map open '{' key: 'boolean, true' bool: true key: 'boolean, false' bool: false key: 'null' null map close '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/simple.json000066400000000000000000000000751231222176500203600ustar00rootroot00000000000000{ "this": "is", "really": "simple", "json": "right?" } yajl-2.1.0/test/parsing/cases/simple.json.gold000066400000000000000000000002001231222176500212720ustar00rootroot00000000000000map open '{' key: 'this' string: 'is' key: 'really' string: 'simple' key: 'json' string: 'right?' map close '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/simple_with_comments.json000066400000000000000000000001671231222176500233220ustar00rootroot00000000000000{ "this": "is", // ignore this "really": "simple", /* ignore this too * / ** // (/ ******/ "json": "right?" } yajl-2.1.0/test/parsing/cases/simple_with_comments.json.gold000066400000000000000000000002051231222176500242370ustar00rootroot00000000000000map open '{' key: 'this' string: 'is' lexical error: probable comment found in input text, comments are not enabled. memory leaks: 0 yajl-2.1.0/test/parsing/cases/string_invalid_escape.json000066400000000000000000000001021231222176500234120ustar00rootroot00000000000000["\n foo \/ bar \r\f\\\uffff\t\b\"\\ and you can't escape thi\s"] yajl-2.1.0/test/parsing/cases/string_invalid_escape.json.gold000066400000000000000000000001571231222176500243500ustar00rootroot00000000000000array open '[' lexical error: inside a string, '\' occurs before a character which it may not. memory leaks: 0 yajl-2.1.0/test/parsing/cases/string_invalid_hex_char.json000066400000000000000000000001141231222176500237360ustar00rootroot00000000000000"foo foo, blah blah \u0123 \u4567 \u89ab \uc/ef \uABCD \uEFFE bar baz bing" yajl-2.1.0/test/parsing/cases/string_invalid_hex_char.json.gold000066400000000000000000000001341231222176500246640ustar00rootroot00000000000000lexical error: invalid (non-hex) character occurs after '\u' inside string. memory leaks: 0 yajl-2.1.0/test/parsing/cases/string_with_escapes.json000066400000000000000000000002001231222176500231210ustar00rootroot00000000000000["\n foo \/ bar \r\f\\\uffff\t\b\"\\", "\"and this string has an escape at the beginning", "and this string has no escapes" ] yajl-2.1.0/test/parsing/cases/string_with_escapes.json.gold000066400000000000000000000002631231222176500240560ustar00rootroot00000000000000array open '[' string: ' foo / bar \￿ "\' string: '"and this string has an escape at the beginning' string: 'and this string has no escapes' array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/string_with_invalid_newline.json000066400000000000000000000001051231222176500246510ustar00rootroot00000000000000"la di dah. this is a string, and I can do this, \n, but not this " yajl-2.1.0/test/parsing/cases/string_with_invalid_newline.json.gold000066400000000000000000000001001231222176500255700ustar00rootroot00000000000000lexical error: invalid character inside string. memory leaks: 0 yajl-2.1.0/test/parsing/cases/three_byte_utf8.json000066400000000000000000000000521231222176500221620ustar00rootroot00000000000000{"matzue": "松江", "asakusa": "浅草"} yajl-2.1.0/test/parsing/cases/three_byte_utf8.json.gold000066400000000000000000000001521231222176500231070ustar00rootroot00000000000000map open '{' key: 'matzue' string: '松江' key: 'asakusa' string: '浅草' map close '}' memory leaks: 0 yajl-2.1.0/test/parsing/cases/true.json000066400000000000000000000000051231222176500200370ustar00rootroot00000000000000true yajl-2.1.0/test/parsing/cases/true.json.gold000066400000000000000000000000331231222176500207640ustar00rootroot00000000000000bool: true memory leaks: 0 yajl-2.1.0/test/parsing/cases/unescaped_bulgarian.json000066400000000000000000000000441231222176500230560ustar00rootroot00000000000000["Да Му Еба Майката"] yajl-2.1.0/test/parsing/cases/unescaped_bulgarian.json.gold000066400000000000000000000001311231222176500237770ustar00rootroot00000000000000array open '[' string: 'Да Му Еба Майката' array close ']' memory leaks: 0 yajl-2.1.0/test/parsing/cases/zerobyte.json000066400000000000000000000000111231222176500207200ustar00rootroot00000000000000"\u0000" yajl-2.1.0/test/parsing/cases/zerobyte.json.gold000066400000000000000000000000341231222176500216510ustar00rootroot00000000000000string: '' memory leaks: 0 yajl-2.1.0/test/parsing/run_tests.sh000077500000000000000000000042761231222176500174720ustar00rootroot00000000000000#!/bin/sh ECHO=`which echo` DIFF_FLAGS="-u" case "$(uname)" in *W32*) DIFF_FLAGS="-wu" ;; esac if [ -z "$testBin" ]; then testBin="$1" fi # find test binary on both platforms. allow the caller to force a # particular test binary (useful for non-cmake build systems). if [ -z "$testBin" ]; then testBin="../build/test/parsing/Release/yajl_test.exe" if [ ! -x $testBin ] ; then testBin="../build/test/parsing/Debug/yajl_test.exe" if [ ! -x $testBin ] ; then testBin="../build/test/parsing/yajl_test" if [ ! -x $testBin ] ; then ${ECHO} "cannot execute test binary: '$testBin'" exit 1; fi fi fi fi ${ECHO} "using test binary: $testBin" testBinShort=`basename $testBin` testsSucceeded=0 testsTotal=0 for file in cases/*.json ; do allowComments="" allowGarbage="" allowMultiple="" allowPartials="" # if the filename starts with dc_, we disallow comments for this test case $(basename $file) in ac_*) allowComments="-c " ;; ag_*) allowGarbage="-g " ;; am_*) allowMultiple="-m "; ;; ap_*) allowPartials="-p "; ;; esac fileShort=`basename $file` testName=`echo $fileShort | sed -e 's/\.json$//'` ${ECHO} -n " test ($testName): " iter=1 success="SUCCESS" # ${ECHO} -n "$testBinShort $allowPartials$allowComments$allowGarbage$allowMultiple-b $iter < $fileShort > ${fileShort}.test : " # parse with a read buffer size ranging from 1-31 to stress stream parsing while [ $iter -lt 32 ] && [ $success = "SUCCESS" ] ; do $testBin $allowPartials $allowComments $allowGarbage $allowMultiple -b $iter < $file > ${file}.test 2>&1 diff ${DIFF_FLAGS} ${file}.gold ${file}.test > ${file}.out if [ $? -eq 0 ] ; then if [ $iter -eq 31 ] ; then testsSucceeded=$(( $testsSucceeded + 1 )) ; fi else success="FAILURE" iter=32 ${ECHO} cat ${file}.out fi iter=$(( iter + 1 )) rm ${file}.test ${file}.out done ${ECHO} $success testsTotal=$(( testsTotal + 1 )) done ${ECHO} $testsSucceeded/$testsTotal tests successful if [ $testsSucceeded != $testsTotal ] ; then exit 1 fi exit 0 yajl-2.1.0/test/parsing/yajl_test.c000066400000000000000000000165271231222176500172510ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include /* memory debugging routines */ typedef struct { unsigned int numFrees; unsigned int numMallocs; /* XXX: we really need a hash table here with per-allocation * information */ } yajlTestMemoryContext; /* cast void * into context */ #define TEST_CTX(vptr) ((yajlTestMemoryContext *) (vptr)) static void yajlTestFree(void * ctx, void * ptr) { assert(ptr != NULL); TEST_CTX(ctx)->numFrees++; free(ptr); } static void * yajlTestMalloc(void * ctx, size_t sz) { assert(sz != 0); TEST_CTX(ctx)->numMallocs++; return malloc(sz); } static void * yajlTestRealloc(void * ctx, void * ptr, size_t sz) { if (ptr == NULL) { assert(sz != 0); TEST_CTX(ctx)->numMallocs++; } else if (sz == 0) { TEST_CTX(ctx)->numFrees++; } return realloc(ptr, sz); } /* begin parsing callback routines */ #define BUF_SIZE 2048 static int test_yajl_null(void *ctx) { printf("null\n"); return 1; } static int test_yajl_boolean(void * ctx, int boolVal) { printf("bool: %s\n", boolVal ? "true" : "false"); return 1; } static int test_yajl_integer(void *ctx, long long integerVal) { printf("integer: %lld\n", integerVal); return 1; } static int test_yajl_double(void *ctx, double doubleVal) { printf("double: %g\n", doubleVal); return 1; } static int test_yajl_string(void *ctx, const unsigned char * stringVal, size_t stringLen) { printf("string: '"); fwrite(stringVal, 1, stringLen, stdout); printf("'\n"); return 1; } static int test_yajl_map_key(void *ctx, const unsigned char * stringVal, size_t stringLen) { char * str = (char *) malloc(stringLen + 1); str[stringLen] = 0; memcpy(str, stringVal, stringLen); printf("key: '%s'\n", str); free(str); return 1; } static int test_yajl_start_map(void *ctx) { printf("map open '{'\n"); return 1; } static int test_yajl_end_map(void *ctx) { printf("map close '}'\n"); return 1; } static int test_yajl_start_array(void *ctx) { printf("array open '['\n"); return 1; } static int test_yajl_end_array(void *ctx) { printf("array close ']'\n"); return 1; } static yajl_callbacks callbacks = { test_yajl_null, test_yajl_boolean, test_yajl_integer, test_yajl_double, NULL, test_yajl_string, test_yajl_start_map, test_yajl_map_key, test_yajl_end_map, test_yajl_start_array, test_yajl_end_array }; static void usage(const char * progname) { fprintf(stderr, "usage: %s [options]\n" "Parse input from stdin as JSON and ouput parsing details " "to stdout\n" " -b set the read buffer size\n" " -c allow comments\n" " -g allow *g*arbage after valid JSON text\n" " -m allows the parser to consume multiple JSON values\n" " from a single string separated by whitespace\n" " -p partial JSON documents should not cause errors\n", progname); exit(1); } int main(int argc, char ** argv) { yajl_handle hand; const char * fileName = NULL; static unsigned char * fileData = NULL; FILE *file; size_t bufSize = BUF_SIZE; yajl_status stat; size_t rd; int i, j; /* memory allocation debugging: allocate a structure which collects * statistics */ yajlTestMemoryContext memCtx = { 0,0 }; /* memory allocation debugging: allocate a structure which holds * allocation routines */ yajl_alloc_funcs allocFuncs = { yajlTestMalloc, yajlTestRealloc, yajlTestFree, (void *) NULL }; allocFuncs.ctx = (void *) &memCtx; /* allocate the parser */ hand = yajl_alloc(&callbacks, &allocFuncs, NULL); /* check arguments. We expect exactly one! */ for (i=1;i= argc) usage(argv[0]); /* validate integer */ for (j=0;j<(int)strlen(argv[i]);j++) { if (argv[i][j] <= '9' && argv[i][j] >= '0') continue; fprintf(stderr, "-b requires an integer argument. '%s' " "is invalid\n", argv[i]); usage(argv[0]); } bufSize = atoi(argv[i]); if (!bufSize) { fprintf(stderr, "%zu is an invalid buffer size\n", bufSize); } } else if (!strcmp("-g", argv[i])) { yajl_config(hand, yajl_allow_trailing_garbage, 1); } else if (!strcmp("-m", argv[i])) { yajl_config(hand, yajl_allow_multiple_values, 1); } else if (!strcmp("-p", argv[i])) { yajl_config(hand, yajl_allow_partial_values, 1); } else { fileName = argv[i]; break; } } fileData = (unsigned char *) malloc(bufSize); if (fileData == NULL) { fprintf(stderr, "failed to allocate read buffer of %zu bytes, exiting.", bufSize); yajl_free(hand); exit(2); } if (fileName) { file = fopen(fileName, "r"); } else { file = stdin; } for (;;) { rd = fread((void *) fileData, 1, bufSize, file); if (rd == 0) { if (!feof(stdin)) { fprintf(stderr, "error reading from '%s'\n", fileName); } break; } /* read file data, now pass to parser */ stat = yajl_parse(hand, fileData, rd); if (stat != yajl_status_ok) break; } stat = yajl_complete_parse(hand); if (stat != yajl_status_ok) { unsigned char * str = yajl_get_error(hand, 0, fileData, rd); fflush(stdout); fprintf(stderr, "%s", (char *) str); yajl_free_error(hand, str); } yajl_free(hand); free(fileData); if (fileName) { fclose(file); } /* finally, print out some memory statistics */ /* (lth) only print leaks here, as allocations and frees may vary depending * on read buffer size, causing false failures. * * printf("allocations:\t%u\n", memCtx.numMallocs); * printf("frees:\t\t%u\n", memCtx.numFrees); */ fflush(stderr); fflush(stdout); printf("memory leaks:\t%u\n", memCtx.numMallocs - memCtx.numFrees); return 0; } yajl-2.1.0/verify/000077500000000000000000000000001231222176500137565ustar00rootroot00000000000000yajl-2.1.0/verify/CMakeLists.txt000066400000000000000000000026611231222176500165230ustar00rootroot00000000000000# Copyright (c) 2007-2014, Lloyd Hilaiel # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # set up some paths SET (binDir ${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/bin) # create some directories FILE(MAKE_DIRECTORY ${binDir}) SET (SRCS json_verify.c) # use the library we build, duh. INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/include) LINK_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/../${YAJL_DIST_NAME}/lib) ADD_EXECUTABLE(json_verify ${SRCS}) TARGET_LINK_LIBRARIES(json_verify yajl_s) # copy in the binary GET_TARGET_PROPERTY(binPath json_verify LOCATION) ADD_CUSTOM_COMMAND(TARGET json_verify POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${binPath} ${binDir}) INSTALL(TARGETS json_verify RUNTIME DESTINATION bin) yajl-2.1.0/verify/json_verify.c000066400000000000000000000065741231222176500164730ustar00rootroot00000000000000/* * Copyright (c) 2007-2014, Lloyd Hilaiel * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include static void usage(const char * progname) { fprintf(stderr, "%s: validate json from stdin\n" "usage: json_verify [options]\n" " -c allow comments\n" " -q quiet mode\n" " -s verify a stream of multiple json entities\n" " -u allow invalid utf8 inside strings\n", progname); exit(1); } int main(int argc, char ** argv) { yajl_status stat; size_t rd; yajl_handle hand; static unsigned char fileData[65536]; int quiet = 0; int retval = 0; int a = 1; /* allocate a parser */ hand = yajl_alloc(NULL, NULL, NULL); /* check arguments.*/ while ((a < argc) && (argv[a][0] == '-') && (strlen(argv[a]) > 1)) { unsigned int i; for ( i=1; i < strlen(argv[a]); i++) { switch (argv[a][i]) { case 'q': quiet = 1; break; case 'c': yajl_config(hand, yajl_allow_comments, 1); break; case 'u': yajl_config(hand, yajl_dont_validate_strings, 1); break; case 's': yajl_config(hand, yajl_allow_multiple_values, 1); break; default: fprintf(stderr, "unrecognized option: '%c'\n\n", argv[a][i]); usage(argv[0]); } } ++a; } if (a < argc) { usage(argv[0]); } for (;;) { rd = fread((void *) fileData, 1, sizeof(fileData) - 1, stdin); retval = 0; if (rd == 0) { if (!feof(stdin)) { if (!quiet) { fprintf(stderr, "error encountered on file read\n"); } retval = 1; } break; } fileData[rd] = 0; /* read file data, pass to parser */ stat = yajl_parse(hand, fileData, rd); if (stat != yajl_status_ok) break; } /* parse any remaining buffered data */ stat = yajl_complete_parse(hand); if (stat != yajl_status_ok) { if (!quiet) { unsigned char * str = yajl_get_error(hand, 1, fileData, rd); fprintf(stderr, "%s", (const char *) str); yajl_free_error(hand, str); } retval = 1; } yajl_free(hand); if (!quiet) { printf("JSON is %s\n", retval ? "invalid" : "valid"); } return retval; }