diff --git a/Modules/Parsers/RKJSONParserNXJSON.h b/Modules/Parsers/RKJSONParserNXJSON.h deleted file mode 100644 index afd1c61596..0000000000 --- a/Modules/Parsers/RKJSONParserNXJSON.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// RKJSONParserNXJSON.h -// RestKit -// -// Created by Evan Cordell on 7/26/11. -// Copyright 2011 Two Toasters. All rights reserved. -// - -#import - -#import "../../RKParser.h" - -@interface RKJSONParserNXJSON : NSObject { - -} - -@end diff --git a/Modules/Parsers/RKJSONParserNXJSON.m b/Modules/Parsers/RKJSONParserNXJSON.m deleted file mode 100644 index 6a7f37841d..0000000000 --- a/Modules/Parsers/RKJSONParserNXJSON.m +++ /dev/null @@ -1,23 +0,0 @@ -// -// RKJSONParserNXJSON.m -// RestKit -// -// Created by Evan Cordell on 7/26/11. -// Copyright 2011 Two Toasters. All rights reserved. -// - -#import "RKJSONParserNXJSON.h" -#import "NXJsonParser.h" -#import "NXJsonSerializer.h" - -@implementation RKJSONParserNXJSON - -- (NSDictionary*)objectFromString:(NSString*)string error:(NSError**)error { - return [NXJsonParser parseString:string error:error ignoreNulls:YES]; -} - -- (NSString*)stringFromObject:(id)object error:(NSError**)error { - return [NXJsonSerializer serialize:object]; -} - -@end diff --git a/Modules/Parsers/RKJSONParserSBJSON.h b/Modules/Parsers/RKJSONParserSBJSON.h deleted file mode 100644 index af541cf72d..0000000000 --- a/Modules/Parsers/RKJSONParserSBJSON.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// RKJSONParserSBJSON.h -// RestKit -// -// Created by Blake Watters on 5/14/11. -// Copyright 2011 Two Toasters -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#import "../../RKParser.h" - -@interface RKJSONParserSBJSON : NSObject { -} - -@end diff --git a/Modules/Parsers/RKJSONParserSBJSON.m b/Modules/Parsers/RKJSONParserSBJSON.m deleted file mode 100644 index 946893229f..0000000000 --- a/Modules/Parsers/RKJSONParserSBJSON.m +++ /dev/null @@ -1,48 +0,0 @@ -// -// RKJSONParserSBJSON.m -// RestKit -// -// Created by Blake Watters on 3/4/10. -// Copyright 2010 Two Toasters -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#import "RKJSONParserSBJSON.h" -#import "SBJsonParser.h" -#import "SBJsonWriter.h" - -@implementation RKJSONParserSBJSON - -- (NSDictionary*)objectFromString:(NSString*)string error:(NSError **)error { - SBJsonParser* parser = [[SBJsonParser alloc] init]; - id result = [parser objectWithString:string]; - if (nil == result) { - if (error) *error = [[parser errorTrace] lastObject]; - } - [parser release]; - - return result; -} - -- (NSString*)stringFromObject:(id)object error:(NSError **)error { - SBJsonWriter *jsonWriter = [SBJsonWriter new]; - NSString *json = [jsonWriter stringWithObject:object]; - if (!json) { - if (error) *error = [[jsonWriter errorTrace] lastObject]; - } - [jsonWriter release]; - return json; -} - -@end diff --git a/Modules/Parsers/RKJSONParserYAJL.h b/Modules/Parsers/RKJSONParserYAJL.h deleted file mode 100644 index 3f07054729..0000000000 --- a/Modules/Parsers/RKJSONParserYAJL.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// RKJSONParserYAJL.h -// RestKit -// -// Created by Blake Watters on 5/14/11. -// Copyright 2011 Two Toasters -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#import "../../RKParser.h" - -@interface RKJSONParserYAJL : NSObject { -} - -@end diff --git a/Modules/Parsers/RKJSONParserYAJL.m b/Modules/Parsers/RKJSONParserYAJL.m deleted file mode 100644 index 720d7beeca..0000000000 --- a/Modules/Parsers/RKJSONParserYAJL.m +++ /dev/null @@ -1,34 +0,0 @@ -// -// RKMappingFormatJSONParserYAJL.m -// RestKit -// -// Created by Blake Watters on 9/28/10. -// Copyright 2010 Two Toasters -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#import "RKJSONParserYAJL.h" -#import "YAJL.h" - -@implementation RKJSONParserYAJL - -- (NSDictionary*)objectFromString:(NSString*)string error:(NSError **)error { - return [string yajl_JSON:error]; -} - -- (NSString*)stringFromObject:(id)object error:(NSError **)error { - return [object yajl_JSONStringWithOptions:YAJLGenOptionsIncludeUnsupportedTypes indentString:@" "]; -} - -@end diff --git a/Vendor/NXJSON/NSError+Extensions.h b/Vendor/NXJSON/NSError+Extensions.h deleted file mode 100644 index b8ed109a92..0000000000 --- a/Vendor/NXJSON/NSError+Extensions.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - -#import -#import "NXDebug.h" - -/** - Extensions to simplfy common tasks with `NSError` - */ -@interface NSError (Extensions) - -/** - Does all the dirty work of creating a simple NSError object. - @param domain The error domain. - @param code The error code for the error - @param description A NSString containing the description of the error - @return Returns an NSError object for domain with the specified error code and description - */ -+(NSError*)errorWithDomain:(NSString*)domain code:(NSInteger)code description:(NSString*)description NOTNULL(1, 3); - -@end diff --git a/Vendor/NXJSON/NSError+Extensions.m b/Vendor/NXJSON/NSError+Extensions.m deleted file mode 100644 index 72f471ef1c..0000000000 --- a/Vendor/NXJSON/NSError+Extensions.m +++ /dev/null @@ -1,46 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - -#import "NSError+Extensions.h" -#import "RKFixCategoryBug.h" - -RK_FIX_CATEGORY_BUG(NSError_Extensions) - -@implementation NSError(Extensions) -+(NSError*)errorWithDomain:(NSString*)domain code:(NSInteger)code description:(NSString*)description -{ - - ASSERT(domain); - ASSERT(description); - ASSERT_CLASS(domain, NSString); - ASSERT_CLASS(description, NSString); - ASSERT([domain length] > 0); - ASSERT([description length] > 0); - ASSERT(code != 0); - - NSMutableDictionary* errorDict = [NSMutableDictionary dictionary]; - [errorDict setObject:description forKey:NSLocalizedDescriptionKey]; - return [NSError errorWithDomain:domain code:code userInfo:errorDict]; -} - -@end diff --git a/Vendor/NXJSON/NXDebug.h b/Vendor/NXJSON/NXDebug.h deleted file mode 100644 index bbf9601d58..0000000000 --- a/Vendor/NXJSON/NXDebug.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - -#import - -/** - - Small class with helper methods, only useful for debugging. - - */ -@interface NXDebug : NSObject -{ - -} -/// Prints the call stack up to the call. only in supported platforms. -+(void)printCallStack; - -@end - - -#ifdef __clang__ - #define NOTNULL(...) __attribute__((nonnull (__VA_ARGS__))) - #define NORETURN __attribute__((analyzer_noreturn)) -#else - #define NOTNULL(...) - #define NORETURN -#endif - - -// Prints a message and the call stack to the console, and calls NXDebugBreak -// INTERNAL. Do not use directly. -void _NXAssert(NSString *message, const char *filename, int lineNumber, const char *functionName) NOTNULL(1, 2, 4) NORETURN; - -// Prints a formatted string to the console. -// INTERNAL. Do not use directly. -void _NXTrace(NSString *format, ...) NOTNULL(1); - -// INTERNAL. Do not use directly. -void _NXDie(NSString *reason, const char *filename, int line, const char *function) NOTNULL(1, 2, 4) NORETURN; - - -/* - Use this when you have a variable that is only used on certain configurations (tipically DEBUG). - It has zero runtime cost. - - Example: - - ---------------------------- - int length = [string length]; - ASSERT(length > 0); - // If we never use length again, the compiler will complain in release builds. - UNUSED(variable); - ---------------------------- - - Another use is to shut up the compiler when we don't use a parameter. - - */ -#define UNUSED(variable) ((void)variable) - - -/* - ASSERT is a nicer version of NSAssertX, with the added benefit that it does nothing on release builds. - Oh, one more thing. If you're running on the debugger, you can continue. Yep, it's like a good old conditional breakpoint. - */ -#ifndef DEBUG - #define ASSERT(condition) do { } while (0); -#else - #define ASSERT(condition) do { if(!(condition)) { _NXAssert([NSString stringWithCString:#condition encoding:NSUTF8StringEncoding], __FILE__, __LINE__, __PRETTY_FUNCTION__); } } while (0); -#endif - -/* - TRACE is a nicer version of NSLog, with the added benefit that it does nothing on release builds. - - Usage: - - TRACE(); - TRACE(@"Hello world"); - TRACE(@"The value is: %d", value); - TRACE("The value is: %d", value); - - */ -#ifndef DEBUG -#define TRACE(...) do { } while (0); -#else -#define TRACE(format, ...) do { _NXTrace((@"%s:%d:1 [%s] " format), __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); } while (0); -#endif - -// Use this when you want to signal an impossible or unexpected situation. -// It's similar to ASSERT, but it remains on release builds. -// Prints the reason, the location of the failure, and the call stack to the console. -// If its running under a debugger, it breaks. Else, it exits. -// NOTE: it only prints the call stack on iOS4+ -#define DIE(reason) do { _NXDie(reason, __FILE__, __LINE__, __PRETTY_FUNCTION__); } while (0); - - -// Short and clear way to make sure a variable is of the expected type. -#define ASSERT_CLASS(x, y) ASSERT([x isKindOfClass:[y class]]) -#define ASSERT_CLASS_OR_NULL(x, y) ASSERT(x == nil || [(id)x isKindOfClass:[y class]]) -#define ASSERT_PROTOCOL(x, y) ASSERT([x conformsToProtocol:@protocol(y)]); - -// Release and set to nil in a single line. -#define NXReleaseAndNil(x) { [x release], x = nil; } - - diff --git a/Vendor/NXJSON/NXDebug.m b/Vendor/NXJSON/NXDebug.m deleted file mode 100644 index 20bd4a8a3b..0000000000 --- a/Vendor/NXJSON/NXDebug.m +++ /dev/null @@ -1,131 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - -#import "NXDebug.h" -#include -#include - -bool _NXAmIBeingDebugged(void); -void _NXDebugBreak(void); - - -// Returns true if the current process is being debugged (either -// running under the debugger or has a debugger attached post facto). -// From http://developer.apple.com/mac/library/qa/qa2004/qa1361.html, midly edited for style. -bool _NXAmIBeingDebugged(void) -{ - int mib[4]; - struct kinfo_proc info; - - // Initialize the flags so that, if sysctl fails for some bizarre - // reason, we get a predictable result. - - info.kp_proc.p_flag = 0; - - // Initialize mib, which tells sysctl the info we want, in this case - // we're looking for information about a specific process ID. - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - - // Call sysctl. - - size_t size = sizeof(info); - int junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); - ASSERT(junk == 0); - UNUSED(junk); - - // We're being debugged if the P_TRACED flag is set. - return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); -} - -// If the app is running attached to a debugger, it breaks. If not, it crashes. -void _NXDebugBreak(void) -{ - if (!_NXAmIBeingDebugged()) - { - abort(); - } - kill(getpid(), SIGINT); -} - -void _NXAssert(NSString* message, const char* filename, int lineNumber, const char* functionName) -{ - NSLog(@"***************************************************************************"); - NSLog(@"Assertion failed at %s: %@", functionName, message); - NSLog(@"%s:%d", filename, lineNumber); - NSLog(@"***************************************************************************"); - [NXDebug printCallStack]; - NSLog(@"***************************************************************************"); - _NXDebugBreak(); -} - -//TODO: research __attribute__ ((format (printf, 1, 2))) -void _NXTrace(NSString* format, ...) -{ - va_list ap; - - va_start (ap, format); - format = [format stringByAppendingString: @"\n"]; - NSString* body = [[NSString alloc] initWithFormat:format arguments:ap]; - va_end (ap); - - fprintf(stderr, "%s", [body UTF8String]); - - NXReleaseAndNil(body); -} - -void _NXDie(NSString* reason, const char* filename, int line, const char* functionName) -{ - NSLog(@"Impossible situation: %@", reason); - NSLog(@"%s:%d:1 [%s]", filename, line, functionName); - [NXDebug printCallStack]; - _NXDebugBreak(); -} - - - -@implementation NXDebug - -+(void)printCallStack -{ - // callStackSymbols is available on iOS4+ only - if ([[NSThread class] respondsToSelector:@selector(callStackSymbols)]) - { - NSArray *stack = [[NSThread class] performSelector:@selector(callStackSymbols)]; - - for (NSString* line in stack) - { - NSLog(@"%@", line); - } - - } - else - { - NSLog(@"Stack trace unavailable"); - } -} - -@end diff --git a/Vendor/NXJSON/NXJsonParser.h b/Vendor/NXJSON/NXJsonParser.h deleted file mode 100644 index 241274f427..0000000000 --- a/Vendor/NXJSON/NXJsonParser.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - - -#import -#import "NXDebug.h" - -/// The error domain for all errors of this class. -extern NSString* const kNextiveJsonParserErrorDomain; - - -/* - - TODO: - - Optimize the unicode escape sequence code ("\u00ae"). It works but it's slow. And ugly. And kicks puppies. - - */ -/** - - Implements a fast JSON parser according to the spec in http://www.json.org/ - Also has support for C style comments. - - *Note:* null values are represented as `NSNull` objects instead of nil unless ignoreNulls is YES. In that case - nil values are not added to dictionaries or arrays; if the JSON string is "null", nil is returned. - - @warning *Important:* a malformed JSON might wrek havoc. - - */ -@interface NXJsonParser : NSObject -{ -@private - NSData* _data; - char* _bytes; - size_t _current; - size_t _length; - - NSNull* _null; // Much faster than calling [NSNull null] hundreds of times. - - // I keep a buffer for strings to avoid creating it and tearing it down every time. - char* _stringBuffer; - size_t _stringBufferSize; - - BOOL _ignoreNulls; -} - -/** - Encodes the jsonString to data and calls [NXJsonParser parseData:error:ignoreNulls:] - @param jsonString The string to parse - @param error The parsing error - @param ignoreNulls If YES null values will be ignored in the parsing process - @return Returns the parsed data - */ -+(id)parseString:(NSString*)jsonString error:(NSError**)error ignoreNulls:(BOOL)ignoreNulls; -/** - Parse the provided data. - - @param jsonData The data to parse - @param error The parsing error - @param ignoreNulls If YES null values will be ignored in the parsing process - @return Returns the parsed data - - */ -+(id)parseData:(NSData*)jsonData error:(NSError**)error ignoreNulls:(BOOL)ignoreNulls; -/** - Used to parse a specific file. Calls [NXJsonParser parseData:error:ignoreNulls:] with the given path for the file - @param path The file's path to parse - @param error The parsing error - @param ignoreNulls If YES null values will be ignored in the parsing process - @return Returns the parsed file - */ -+(id)parseFileAtPath:(NSString*)path error:(NSError**)error ignoreNulls:(BOOL)ignoreNulls; -/** - Initializes a new data object - @param data The data to parse - @return Returns the initialized data object - */ --(id)initWithData:(NSData*)data NOTNULL(1); -/** - Parsing of passed data occurs here - @param error The parsing error - @param ignoreNulls If YES null values will be ignored in the parsing process - @return Returns the parsed data - */ --(id)parse:(NSError**)error ignoreNulls:(BOOL)ignoreNulls; - -@end diff --git a/Vendor/NXJSON/NXJsonParser.m b/Vendor/NXJSON/NXJsonParser.m deleted file mode 100644 index 9e5b5c76fc..0000000000 --- a/Vendor/NXJSON/NXJsonParser.m +++ /dev/null @@ -1,873 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - -#import "NXJsonParser.h" -#import "NSError+Extensions.h" - -NSString* const kUnexpectedCharException = @"UnexpectedCharException"; -NSString* const kUnexpectedControlCharException = @"UnexpectedControlCharException"; -NSString* const kUnexpectedEndOfFileException = @"UnexpectedEndOfFileException"; -NSString* const kUnexpectedHexCharException = @"UnexpectedHexCharException"; - -NSString* const kNextiveJsonParserErrorDomain = @"com.nextive.NXJsonParser"; - -@interface NXJsonParser() --(void)skipWhitespace; --(NSDictionary*)newDictionary; --(NSArray*)newArray; --(NSString*)newString; --(NSNumber*)newNumber; --(NSNumber*)newBoolean; --(NSNull*)newNull; --(id)newObject; - -// Deprecated. Replaced with the inline macros below. -//-(BOOL)hasData; -//-(char)currentChar; -//-(char)nextChar; -@end - -#define currentChar() (_bytes[_current]) -#define hasData() (_current < _length) -#define nextChar() (_bytes[_current + 1]) -#define skip() (_current++) - -@implementation NXJsonParser - --(void)dealloc -{ - NXReleaseAndNil(_data); - NXReleaseAndNil(_null); - - free(_stringBuffer); - - [super dealloc]; -} - -+ (id)parseString:(NSString *)jsonString error:(NSError **)error ignoreNulls:(BOOL)ignoreNulls -{ - return [NXJsonParser parseData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] error:error ignoreNulls:ignoreNulls]; -} - -+ (id)parseData:(NSData*)jsonData error:(NSError **)error ignoreNulls:(BOOL)ignoreNulls -{ - NXJsonParser* parser = [[NXJsonParser alloc] initWithData:jsonData]; - id retval = [parser parse:error ignoreNulls:ignoreNulls]; - NXReleaseAndNil(parser); - return retval; -} - -+(id)parseFileAtPath:(NSString*)path error:(NSError**)error ignoreNulls:(BOOL)ignoreNulls -{ - ASSERT_CLASS(path, NSString); - - NSString* string = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:error]; - - if(error && *error) - { - NXReleaseAndNil(string); - TRACE(@"Reading JSON file failed with %@", *error); - return nil; - } - - id retval = [NXJsonParser parseString:string error:error ignoreNulls:ignoreNulls]; - - NXReleaseAndNil(string); - - return retval; -} --(id)initWithData:(NSData*)data -{ - ASSERT(data); - ASSERT_CLASS(data, NSData); - - if ((self = [super init])) - { - _data = [data retain]; - _bytes = (char*)[data bytes]; - _current = 0; - _length = [data length]; - _null = [[NSNull null] retain]; - - _stringBufferSize = 10 * 1024; - _stringBuffer = (char*)malloc(_stringBufferSize * sizeof(char)); - } - - return self; -} - --(id)parse:(NSError**)error ignoreNulls:(BOOL)ignoreNulls -{ - _ignoreNulls = ignoreNulls; - - id retval = nil; - @try - { - retval = [self newObject]; - } - @catch (NSException* e) - { - retval = nil; - if(error) - { - *error = [NSError errorWithDomain:kNextiveJsonParserErrorDomain code:100 description:[e reason]]; - } - } - @finally - { - return [retval autorelease]; - } -} - --(id)newObject -{ - id retval = nil; - - [self skipWhitespace]; - - if(hasData()) - { - char c = currentChar(); - - switch (c) - { - case '{': - retval = [self newDictionary]; - break; - case '[': - retval = [self newArray]; - break; - case '\"': - retval = [self newString]; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - case '.': - retval = [self newNumber]; - break; - case 't': - case 'f': - retval = [self newBoolean]; - break; - case 'n': - retval = [self newNull]; - break; - case '\0': - [NSException raise:kUnexpectedEndOfFileException format:@"Unexpected EOF"]; - break; - default: - [NSException raise:kUnexpectedCharException format:@"Expecting a dictionary, array, string, number, boolean, null, anything but a \"%c\"", currentChar()]; - break; - } - } - - return retval; -} - --(void)skipWhitespace -{ - BOOL intoComment = NO; - BOOL end = NO; - while (!end && hasData()) - { - char c = currentChar(); - - switch (c) - { - case ' ': - case '\t': - case '\n': - skip(); - break; - case '/': - if (nextChar() == '*') - { - // skip both the '/' and the '*' - skip(); - skip(); - intoComment = YES; - } - else - { - end = YES; - } - break; - case '*': - if (intoComment) - { - skip(); // skip the '*' - if(currentChar() == '/') - { - skip(); // skip the '/' - intoComment = NO; - } - } - else - { - end = YES; - } - break; - default: - if (intoComment) - { - skip(); - } - else - { - end = YES; - } - break; - } - } -} - --(NSDictionary*)newDictionary -{ - ASSERT(_bytes); - ASSERT(hasData()); - ASSERT(currentChar() == '{'); - - skip(); // skip the '{' - - size_t size = 100; - id* keys = (id*)malloc(sizeof(id) * size); - ASSERT(keys); - id* values = (id*)malloc(sizeof(id) * size); - ASSERT(values); - NSUInteger count = 0; - - @try - { - BOOL intoDictionary = YES; - [self skipWhitespace]; - if(currentChar() == '}') - { - intoDictionary = NO; - } - - while (intoDictionary) - { - [self skipWhitespace]; - - id key = [self newObject]; - ASSERT(key); - - [self skipWhitespace]; - - if(currentChar() != ':') - { - [NSException raise:kUnexpectedCharException format:@"Expecting ':', found \"%c\"", currentChar()]; - } - skip(); - - [self skipWhitespace]; - - id value = [self newObject]; - - if (!(_ignoreNulls && !value)) - { - ASSERT(value); - - if (count == size) - { - size *= 2; - keys = (id*)realloc(keys, size * sizeof(id)); - ASSERT(keys); - values = (id*)realloc(values, size * sizeof(id)); - ASSERT(values); - } - keys[count] = key; - values[count] = value; - count++; - } - - [self skipWhitespace]; - - char c = currentChar(); - switch (c) - { - case ',': - // skip and keep going - skip(); - break; - case '}': - intoDictionary = NO; - break; - case '\0': - [NSException raise:kUnexpectedEndOfFileException format:@"Unexpected EOF"]; - break; - default: - [NSException raise:kUnexpectedCharException format:@"Expecting \",\" or \"}\", found \"%c\"", c]; - break; - } - } - - skip(); //skip the "}" - - [self skipWhitespace]; - } - @catch (NSException * e) - { - for (NSUInteger i = 0; i < count; i++) - { - [keys[i] release]; - [values[i] release]; - } - free(keys); - free(values); - - [e raise]; - } - @finally - { - - // Creating a dictionary from arrays of keys and values is much much faster than adding them one item at a time. - NSDictionary* dict = (NSDictionary*)CFDictionaryCreate(kCFAllocatorDefault, (const void**) keys, (const void**) values, count, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - - for (NSUInteger i = 0; i < count; i++) - { - [keys[i] release]; - [values[i] release]; - } - free(keys); - free(values); - - return dict; - } -} - --(NSNumber*)newBoolean -{ - ASSERT(_bytes); - ASSERT(hasData()); - - BOOL value = NO; - - static char true_chars[] = {'r', 'u', 'e', '\0'}; - static char false_chars[] = {'a', 'l', 's', 'e', '\0'}; - - char* array = NULL; - switch (currentChar()) - { - case 't': - array = true_chars; - value = YES; - break; - case 'f': - array = false_chars; - value = NO; - break; - default: - ASSERT(@"I should never be here. Fault the calling function." != nil ? 1 : 0); - break; - } - - ASSERT(array); - - skip(); // Skip the 't' or 'f' to compare a little less. Anal retentive, me? Nah. - - int pos = 0; - char expected = array[pos]; - - while (expected != '\0') - { - if (currentChar() != expected) - { - [NSException raise:kUnexpectedCharException format:@"Invalid char in a boolean: %c", currentChar()]; - } - else - { - skip(); - expected = array[++pos]; - } - } - - return [[NSNumber alloc] initWithBool:value]; -} - --(NSNull*)newNull -{ - ASSERT(_bytes); - ASSERT(hasData()); - - static char expected[] = {'u', 'l', 'l', '\0'}; - - skip(); // skip the 'n' - - int pos = 0; - while (expected[pos] != '\0') - { - if (currentChar() != expected[pos]) - { - [NSException raise:kUnexpectedCharException format:@"Expecting '%c' (of 'null'), found %c", expected[pos], currentChar()]; - } - else - { - skip(); - pos++; - } - } - - if (_ignoreNulls) - { - return nil; - } - else - { - return _null; - } - -} - --(NSNumber*)newNumber -{ - //NOTE: this function is a mess. But it's the only way I found to make it fast. - ASSERT(_bytes); - ASSERT(hasData()); - - BOOL end = NO; - BOOL isNegative = NO; - BOOL hasDecimal = NO; - BOOL hasDigits = NO; - BOOL hasExponent = NO; - BOOL positiveExponent = NO; - int exponent = 0; - - long long integer = 0; - long long decimal = 0; - double divisor = 10; - - while(!end) - { - char c = currentChar(); - - switch (c) - { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - hasDigits = YES; - if(hasDecimal) - { - decimal *= 10; - decimal += c - '0'; - divisor *= 10; - } - else - { - integer *= 10; - integer += c - '0'; - } - skip(); - break; - case '-': - if(hasDigits) - { - [NSException raise:kUnexpectedCharException format:@"- after a digit?"]; - } - if(hasDecimal) - { - [NSException raise:kUnexpectedCharException format:@"- after '.'?"]; - } - if(isNegative) - { - [NSException raise:kUnexpectedCharException format:@"Two negatives one number?"]; - } - isNegative = YES; - skip(); - break; - case '.': - if(hasDecimal) - { - [NSException raise:kUnexpectedCharException format:@"Two decimal points one number?"]; - } - hasDecimal = YES; - skip(); - break; - case 'e': - case 'E': - if (hasExponent) - { - [NSException raise:kUnexpectedCharException format:@"Two exponents one number?"]; - } - hasExponent = YES; - skip(); - switch (currentChar()) - { - case '+': - positiveExponent = YES; - break; - case '-': - positiveExponent = NO; - break; - default: - [NSException raise:kUnexpectedCharException format:@"e should be followed by '+' or '-', not '%c'", currentChar()]; - break; - } - skip(); - while (!end) - { - char e = currentChar(); - if (e >= '0' && e <= '9') - { - exponent *= 10; - exponent += e - '0'; - skip(); - } - else - { - end = YES; - } - } - - - default: - end = YES; - break; - } - } - - if(!hasDigits) - { - [NSException raise:kUnexpectedCharException format:@"No digits in a number?"]; - } - - if (hasExponent) - { - exponent = positiveExponent ? exponent : -exponent; - unsigned long long mantissa = (integer * divisor / 10) + decimal; - while (divisor > 10) - { - exponent --; - divisor /= 10; - } - return [[NSDecimalNumber alloc] initWithMantissa:mantissa exponent:exponent isNegative:isNegative]; - } - else - { - int sign = isNegative ? -1 : 1; - if(hasDecimal) - { - divisor /= 10; - return [[NSNumber alloc] initWithDouble:sign * (integer + (decimal / divisor))]; - } - else - { - return [[NSNumber alloc] initWithLongLong:sign * integer]; - } - } - -} - --(NSString*)newString -{ - //NOTE: this function is a mess. But it's the only way I found to make it fast. - - ASSERT(_bytes); - ASSERT(hasData()); - ASSERT(currentChar() == '\"'); - - skip(); // skip the '"' - - BOOL end = NO; - BOOL intoEscape = NO; - - size_t len = 0; - -#define resizeIfNeeded(newSize) \ -if(newSize > _stringBufferSize) \ -{ \ - while(newSize > _stringBufferSize) \ - { \ - _stringBufferSize *= 2; \ - } \ - _stringBuffer = (char*)realloc(_stringBuffer, _stringBufferSize * sizeof(char)); \ -} \ - - while(!end) - { - char c = currentChar(); - - resizeIfNeeded(len); - - switch (c) - { - case '\\': - if (intoEscape) - { - _stringBuffer[len++] = c; - } - intoEscape = !intoEscape; - skip(); - break; - case '\"': - if(intoEscape) - { - intoEscape = NO; - skip(); - _stringBuffer[len++] = c; - } - else - { - end = YES; - } - break; - case '\0': - [NSException raise:kUnexpectedEndOfFileException format:@"Unexpected EOF"]; - break; - default: - if(intoEscape) - { - intoEscape = NO; - switch (c) - { - case '/': - c = '/'; - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'u': - skip(); - - unichar uc = 0; - for (int i = 0; i < 4; i++) - { - c = currentChar(); - skip(); - - uc *= 16; - - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - uc += c - '0'; - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - uc += c - 'a' + 10; - break; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - uc += c - 'A' + 10; - break; - default: - [NSException raise:kUnexpectedHexCharException format:@"Unexpected hex char: '\\%c'", c]; - break; - } - } - - // Ugly code - // The code sequence for, for example "®", is \u00ae. In UTF8 is encoded as 0xC2 0xAE. - // There's probably a better way to do this with some bit twiddling, but I'm tired and this works for now. - // Feel free to fix it. - NSString* utf16 = [[NSString alloc] initWithBytes:&uc length:sizeof(uc) encoding:NSASCIIStringEncoding]; - char ubuffer[10] = {0}; // 10 is more than enough. - NSUInteger size = 0; - NSRange range = {0, 1}; - [utf16 getBytes:&ubuffer maxLength:10 usedLength:&size encoding:NSUTF8StringEncoding options:NSStringEncodingConversionAllowLossy range:range remainingRange:NULL]; - - resizeIfNeeded(len + size); - - for (size_t i = 0; i < size; i++) - { - _stringBuffer[len++] = ubuffer[i]; - } - NXReleaseAndNil(utf16); - - continue; - - break; - default: - [NSException raise:kUnexpectedControlCharException format:@"Unexpected control char: '\\%c'", c]; - break; - } - } - - _stringBuffer[len++] = c; - - skip(); - break; - } - } - - // The great thing about using CFStrings instead of NSStrings is that (besides it's a tiny bit faster to create) - // the [string copy] message simply retains it. As the string is immutable the effect is the same, - // only that is faster and in some cases it will use less memory. - NSString* retval = (NSString*)CFStringCreateWithBytes(kCFAllocatorDefault, (unsigned char*)_stringBuffer, len, kCFStringEncodingUTF8, false); - - skip(); //skip the '"' - ASSERT(retval); - return retval; -} - --(NSArray*)newArray -{ - ASSERT(_bytes); - ASSERT(hasData()); - ASSERT(currentChar() == '['); - - size_t size = 100; - id* values = (id*)malloc(sizeof(id) * size); - ASSERT(values); - NSUInteger count = 0; - @try - { - skip(); // skip the '"' - - BOOL intoArray = YES; - [self skipWhitespace]; - if(currentChar() == ']') - { - intoArray = NO; - } - while (intoArray) - { - [self skipWhitespace]; - - - id value = [self newObject]; - - if (!(_ignoreNulls && !value)) - { - ASSERT(value); - - if (count == size) - { - size *= 2; - values = (id*)realloc(values, size * sizeof(id)); - ASSERT(values); - } - values[count] = value; - count++; - } - - [self skipWhitespace]; - - char c = currentChar(); - switch (c) - { - case ',': - // skip and keep going - skip(); - break; - case ']': - intoArray = NO; - break; - case '\0': - [NSException raise:kUnexpectedEndOfFileException format:@"Unexpected EOF"]; - break; - default: - [NSException raise:kUnexpectedCharException format:@"Expecting ',' or ']', found '%c'", c]; - break; - } - } - - skip(); //skip the "]" - - [self skipWhitespace]; - } - @catch (NSException * e) - { - for (NSUInteger i = 0; i < count; i++) - { - [values[i] release]; - } - free(values); - - [e raise]; - } - @finally - { - NSArray* array = (NSArray*)CFArrayCreate(kCFAllocatorDefault, (const void**) values, count, &kCFTypeArrayCallBacks); - for (NSUInteger i = 0; i < count; i++) - { - [values[i] release]; - } - free(values); - - return array; - } - -} - - -// Deprecated, replaced by the inline versions. Kept just in case we want to debug it. - -//-(BOOL)hasData -//{ -// return _current < _length; -//} - -//-(char)currentChar -//{ -// ASSERT(_bytes); -// ASSERT(_current < _length); -// return _bytes[_current]; -//} - -//-(char)nextChar -//{ -// ASSERT(_bytes); -// ASSERT(_current + 1 < _length); -// return _bytes[_current + 1]; -//} - -@end diff --git a/Vendor/NXJSON/NXJsonSerializer.h b/Vendor/NXJSON/NXJsonSerializer.h deleted file mode 100644 index c352670ef5..0000000000 --- a/Vendor/NXJSON/NXJsonSerializer.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - - - -#import - -/** - - Serializes an object structure to Json, according to the spec in http://www.json.org/ - - Supports NSDictionary, NSArray, NSString, NSNumber, NSNull and its subclasses. - If you implement the NXSerializable protocol, just serialize yourself to a dictionary - (or array, or any JSON compatible type) and we'll do our best. - - @warning *Important*: Do NOT try to serialize a recursive structure. - - */ -@interface NXJsonSerializer : NSObject -{ -@private - // We keep references to [XX class] here for performance reasons. Yes. Really. Calling - // [XX class] thousands of times is expensive. - Class _nullClass; - Class _dictClass; - Class _arraClass; - Class _numbClass; - Class _striClass; - - Class _nullClassCached; - Class _dictClassCached; - Class _arraClassCached; - Class _numbClassCached; - Class _striClassCached; - - char* _buffer; - size_t _length; - size_t _current; - - UniChar* _stringBuffer; - CFIndex _stringBufferLength; -} -/** - Serializes the specified object, such as NSDictionary, NSNumber, NSString, NSArray, NSNull - @param object the object to serialize - @return Returns a serialized object - */ -+(NSString*)serialize:(id)object; -/** - Serializes the specified object, such as NSDictionary, NSNumber, NSString, NSArray, NSNull - @param object the object to serialize - @return Returns a serialized object - */ --(NSString*)serialize:(id)object; -/** - Serializes the object and writes serialized object's contents to a specific file. - @param object The object to serialize - @param path The destination path of the serialized data's newly created file - @return Returns YES on success, NO on error. - */ -+(BOOL)serialize:(id)object toFile:(NSString*)path error:(NSError**)error; - -@end diff --git a/Vendor/NXJSON/NXJsonSerializer.m b/Vendor/NXJSON/NXJsonSerializer.m deleted file mode 100644 index 22b37fc8b7..0000000000 --- a/Vendor/NXJSON/NXJsonSerializer.m +++ /dev/null @@ -1,704 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - -#import "NXJsonSerializer.h" -#import -#import -#import "NXDebug.h" -//#import "NSString+Extensions.h" -#import "NXSerializable.h" - -#define EXCEPTION_NUMBER_TYPE @"Unexpected NSNumber type" - -/** \brief convert an signed long integer to char buffer - * - * \param[in] value - * \param[out] buf the output buffer. Should be 24 chars or more. - */ -static void modp_litoa10(signed long long value, char* buf); -/** \brief convert an unsigned long integer to char buffer - * - * \param[in] value - * \param[out] buf The output buffer, should be 24 chars or more. - */ -static void modp_ulitoa10(unsigned long long value, char* buf); -static void strreverse(char* begin, char* end); -/** \brief convert a floating point number to char buffer with - * fixed-precision format - * - * This is similar to "%.[0-9]f" in the printf style. It will include - * trailing zeros - * - * If the input value is greater than 1<<31, then the output format - * will be switched exponential format. - * - * \param[in] value - * \param[out] buf The allocated output buffer. Should be 32 chars or more. - * \param[in] precision Number of digits to the right of the decimal point. - * Can only be 0-9. - */ -static void modp_dtoa(double value, char* buf, int precision); - - - - -#define resizeIfNeeded(length) \ -{ \ - if(_current + length > _length) \ - { \ - while (_current + length > _length) \ - { \ - _length *= 2; \ - } \ - _buffer = (char*)realloc(_buffer, _length); \ - }\ -} -#define appendBytes(bytes, length) \ -{ \ - if(_current + length > _length) \ - { \ - while (_current + length > _length) \ - { \ - _length *= 2; \ - } \ - _buffer = (char*)realloc(_buffer, _length); \ - }\ - memcpy(_buffer + _current, bytes, length); \ - _current += length; \ -} -#define appendChar(c) \ -{ \ - if(_current + 1 > _length) \ - { \ - _length *= 2; \ - _buffer = (char*)realloc(_buffer, _length); \ - }\ - _buffer[_current++] = c; \ -} -#define appendCharNoResize(c) {_buffer[_current++] = c;} - -@interface NXJsonSerializer() --(void)serializeObject:(id)object; - --(void)serializeNull; --(void)serializeDictionary:(NSDictionary*)object NOTNULL(1); --(void)serializeArray:(NSArray*)object NOTNULL(1); --(void)serializeNumber:(NSNumber*)object NOTNULL(1); --(void)serializeString:(NSString*)object NOTNULL(1); -@end - - -@implementation NXJsonSerializer - --(void)dealloc -{ - NXReleaseAndNil(_nullClass); - NXReleaseAndNil(_dictClass); - NXReleaseAndNil(_arraClass); - NXReleaseAndNil(_numbClass); - NXReleaseAndNil(_striClass); - - free(_buffer); - free(_stringBuffer); - [super dealloc]; -} - --(id)init -{ - if ((self = [super init])) - { - _nullClass = [[NSNull class] retain]; - _dictClass = [[NSDictionary class] retain]; - _arraClass = [[NSArray class] retain]; - _numbClass = [[NSNumber class] retain]; - _striClass = [[NSString class] retain]; - } - - return self; -} - -+(NSString*)serialize:(id)object -{ - NXJsonSerializer* serializer = [[NXJsonSerializer alloc] init]; - NSString* retval = [serializer serialize:object]; - NXReleaseAndNil(serializer); - return retval; -} - -+(BOOL)serialize:(id)object toFile:(NSString*)path error:(NSError**)error -{ - ASSERT_CLASS(path, NSString); - ASSERT(object); - - NSString* json = [NXJsonSerializer serialize:object]; - ASSERT_CLASS(json, NSString); - return [json writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:error]; -} - --(NSString*)serialize:(id)object -{ - // If we call this a few times in a row, it makes no sense to free and malloc the buffer. - if (!_buffer) - { - _length = 10 * 1024; - _buffer = (char*)malloc(_length * sizeof(char)); - } - _current = 0; - - if (!_stringBuffer) - { - _stringBufferLength = 10 * 1024; - _stringBuffer = (UniChar*)malloc(_stringBufferLength * sizeof(UniChar)); - } - - [self serializeObject:object]; - - return [[[NSString alloc] initWithBytes:_buffer length:_current encoding:NSUTF8StringEncoding] autorelease]; -} - --(void)serializeObject:(id)object -{ - - - if(!object) - { - [self serializeNull]; - } - - /* - - Fast lookups logic: - isKindOfClass looks at the whole hierarchy chain. It takes a while. - Most of the time, all the subclasses of a certain type will be the same in a given dictionary (or array, or whatever). - We cache the last subclass (or implementation, in the case of class clusters) for each class and test it with pointer equality. - The difference is huge. 30% or more. - - Possible optimization: we could run a few tests and reorganize the order of the comparisons. But it's very dependant on the - source structure, so you never really know. - - */ - // BEGIN FAST LOOKUPS - else if (object->isa == _dictClassCached) - { - [self serializeDictionary:(NSDictionary*)object]; - } - else if (object->isa == _arraClassCached) - { - [self serializeArray:(NSArray*)object]; - } - else if (object->isa == _striClassCached) - { - [self serializeString:(NSString*)object]; - } - else if (object->isa == _numbClassCached) - { - [self serializeNumber:(NSNumber*)object]; - } - else if (object->isa == _nullClassCached) - { - [self serializeNull]; - } - // END FAST LOOKUPS. From now on we check for subclasses too. - else if ([object isKindOfClass:_dictClass]) - { - _dictClassCached = object->isa; - [self serializeDictionary:(NSDictionary*)object]; - } - else if ([object isKindOfClass:_arraClass]) - { - _arraClassCached = object->isa; - [self serializeArray:(NSArray*)object]; - } - else if ([object isKindOfClass:_striClass]) - { - _striClassCached = object->isa; - [self serializeString:(NSString*)object]; - } - else if ([object isKindOfClass:_numbClass]) - { - _numbClassCached = object->isa; - [self serializeNumber:(NSNumber*)object]; - } - else if ([object isKindOfClass:_nullClass]) - { - _nullClassCached = object->isa; - [self serializeNull]; - } - else - { - if ([object conformsToProtocol:@protocol(NXSerializable)]) - { - - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - id value = [object performSelector:@selector(serialize)]; - ASSERT(![value conformsToProtocol:@protocol(NXSerializable)]); // this will recurse forever - [self serializeObject:value]; - - [pool drain]; - - } - else - { - // Enable this code if you want to know when you're serializing an "unsupported" object. - // NSString* reason = [NSString stringWithFormat:@"Unsupported object type: %@", [object class]]; - // ASSERT(!reason); - [self serializeString:[object description]]; - } - } -} --(void)serializeNull -{ - appendBytes("null", 4); -} --(void)serializeDictionary:(NSDictionary*)object -{ - ASSERT(object); - ASSERT([object isKindOfClass:[NSDictionary class]]); - ASSERT(_buffer); - - appendChar('{'); - - CFIndex count = CFDictionaryGetCount((CFDictionaryRef)object); - - id allKeys[count]; - id allValues[count]; - - // This is much faster than calling [object allKeys] and iterating. - CFDictionaryGetKeysAndValues((CFDictionaryRef)object, (void const**)allKeys, (void const**)allValues); - - for (CFIndex i = 0; i < count; i++) - { - id key = allKeys[i]; - ASSERT(key); - [self serializeObject:key]; - appendChar(':'); - - id value = allValues[i]; - ASSERT(value); - - [self serializeObject:value]; - appendChar(','); - } - - if (count > 0) - { - // remove the last "," - _current -= 1; - } - - appendChar('}'); - - ASSERT(_current < _length); -} --(void)serializeArray:(NSArray*)object -{ - ASSERT(object); - ASSERT([object isKindOfClass:[NSArray class]]); - ASSERT(_buffer); - - appendChar('['); - - for (id key in object) - { - ASSERT(key); - [self serializeObject:key]; - appendChar(','); - } - - if ([object count] > 0) - { - // remove the last "," - _current -= 1; - } - - appendChar(']'); - - ASSERT(_current < _length); -} --(void)serializeNumber:(NSNumber*)object -{ - ASSERT(object); - ASSERT([object isKindOfClass:[NSNumber class]]); - ASSERT(_buffer); - - // Booleans can be tested with pointer equality. - if (object == (id)kCFBooleanTrue) - { - appendBytes("true", 4); - ASSERT(_current < _length); - return; - } - else if (object == (id)kCFBooleanFalse) - { - appendBytes("false", 5); - ASSERT(_current < _length); - return; - } - - - const char* objCType = [object objCType]; - ASSERT(strlen(objCType) == 1); - - switch(*objCType) - { - case 'c': - case 's': - case 'i': - case 'I': - case 'l': - case 'q': - { - long long value = [object longLongValue]; - resizeIfNeeded(49); - char converted[50] = {0}; - modp_litoa10(value, converted); - - char* str = converted; - do - { - appendCharNoResize(*str); - str++; - } - while (*str != '\0'); - - break; - } - case 'C': - case 'S': - case 'Q': - case 'L': - { - unsigned long long value = [object unsignedLongLongValue]; - resizeIfNeeded(49); - char converted[50] = {0}; - modp_ulitoa10(value, converted); - char* str = converted; - do - { - appendCharNoResize(*str); - str++; - } - while (*str != '\0'); - - break; - break; - } - case 'f': - case 'd': - { - double value = [object doubleValue]; - resizeIfNeeded(99); - char converted[100] = {0}; - modp_dtoa(value, converted, 9); - appendBytes(converted, strlen(converted)); - break; - } - default: - [NSException raise:EXCEPTION_NUMBER_TYPE format:@"Unsupported number type '%c'", *objCType]; - - } - - ASSERT(_current < _length); -} --(void)serializeString:(NSString*)object -{ - ASSERT(object); - ASSERT([object isKindOfClass:[NSString class]]); - ASSERT(_buffer); - - CFStringRef string = (CFStringRef)object; - CFIndex len = CFStringGetLength(string); - - if (len > _stringBufferLength) - { - _stringBufferLength = len + 1; - _stringBuffer = (UniChar*)realloc(_stringBuffer, sizeof(UniChar) * _stringBufferLength); - } - CFStringGetCharacters(string, CFRangeMake(0, len), _stringBuffer); - - resizeIfNeeded((len * 6) + 2); // Worst case scenario: every char needs to be unicode encoded, plus the '"'s. - - appendCharNoResize('\"'); - for (CFIndex i = 0; i < len; i++) - { - UniChar uc = _stringBuffer[i]; - if (uc < 127) - { - switch (uc) - { - case '\\': - appendCharNoResize('\\'); - appendCharNoResize('\\'); - break; - case '/': - appendCharNoResize('\\'); - appendCharNoResize('/'); - break; - case '"': - appendCharNoResize('\\'); - appendCharNoResize('"'); - break; - case '\b': - appendCharNoResize('\\'); - appendCharNoResize('b'); - break; - case '\f': - appendCharNoResize('\\'); - appendCharNoResize('f'); - break; - case '\n': - appendCharNoResize('\\'); - appendCharNoResize('n'); - break; - case '\r': - appendCharNoResize('\\'); - appendCharNoResize('r'); - break; - case '\t': - appendCharNoResize('\\'); - appendCharNoResize('t'); - break; - default: - appendCharNoResize(uc); - break; - } - } - else - { - appendCharNoResize('\\'); - appendCharNoResize('u'); - - static const char hexDigits[16] = - { - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' - }; - - ASSERT((uc & 0xF000) >> 12 >= 0 && (uc & 0xF000) >> 12 < 16); - ASSERT((uc & 0x0F00) >> 8 >= 0 && (uc & 0x0F00) >> 8 < 16); - ASSERT((uc & 0x00F0) >> 4 >= 0 && (uc & 0x00F0) >> 4 < 16); - ASSERT((uc & 0x000F) >> 0 >= 0 && (uc & 0x000F) >> 0 < 16); - - appendCharNoResize(hexDigits[(uc & 0xF000) >> 12]); - appendCharNoResize(hexDigits[(uc & 0x0F00) >> 8]); - appendCharNoResize(hexDigits[(uc & 0x00F0) >> 4]); - appendCharNoResize(hexDigits[(uc & 0x000F) >> 0]); - } - } - - appendCharNoResize('\"'); - - ASSERT(_current < _length); - -} - -@end - -/* - * Code adapted from http://code.google.com/p/stringencoders/source/browse/trunk/src/modp_numtoa.h - * Copyright © 2007, Nick Galbreath -- nickg [at] modp [dot] com - * All rights reserved. - * http://code.google.com/p/stringencoders/ - * Released under the MIT license. - */ -void modp_litoa10(signed long long value, char* str) -{ - char* wstr = str; - unsigned long long uvalue = (value < 0) ? -value : value; - - // Conversion. Number is reversed. - do - { - *wstr++ = (char)(48 + (uvalue % 10)); - } - while(uvalue /= 10); - - if (value < 0) - { - *wstr++ = '-'; - } - - *wstr = '\0'; - - // Reverse string - strreverse(str, wstr - 1); -} - -void modp_ulitoa10(unsigned long long value, char* str) -{ - char* wstr = str; - // Conversion. Number is reversed. - do - { - *wstr++ = (char)(48 + (value % 10)); - } - while (value /= 10); - - *wstr = '\0'; - // Reverse string - strreverse(str, wstr - 1); -} - -void strreverse(char* begin, char* end) -{ - while (end > begin) - { - char aux = *end; - *end-- = *begin; - *begin++ = aux; - } -} - -void modp_dtoa(double value, char* str, int prec) -{ - /** - * Powers of 10 - * 10^0 to 10^9 - */ - static const double pow10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, - 10000000, 100000000, 1000000000}; - - /* Hacky test for NaN - * under -fast-math this won't work, but then you also won't - * have correct nan values anyways. The alternative is - * to link with libmath (bad) or hack IEEE double bits (bad) - */ - if (! (value == value)) - { - str[0] = 'N'; str[1] = 'a'; str[2] = 'N'; str[3] = '\0'; - return; - } - /* if input is larger than thres_max, revert to exponential */ - const double thres_max = (double)(0x7FFFFFFF); - - double diff = 0.0; - char* wstr = str; - - if (prec < 0) - { - prec = 0; - } - else if (prec > 9) - { - /* precision of >= 10 can lead to overflow errors */ - prec = 9; - } - - - /* we'll work in positive values and deal with the - negative sign issue later */ - int neg = 0; - if (value < 0) - { - neg = 1; - value = -value; - } - - - int whole = (int) value; - double tmp = (value - whole) * pow10[prec]; - uint32_t frac = (uint32_t)(tmp); - diff = tmp - frac; - - if (diff > 0.5) - { - ++frac; - /* handle rollover, e.g. case 0.99 with prec 1 is 1.0 */ - if (frac >= pow10[prec]) - { - frac = 0; - ++whole; - } - } - else if (diff == 0.5 && ((frac == 0) || (frac & 1))) - { - /* if halfway, round up if odd, OR - if last digit is 0. That last part is strange */ - ++frac; - } - - /* for very large numbers switch back to native sprintf for exponentials. - anyone want to write code to replace this? */ - /* - normal printf behavior is to print EVERY whole number digit - which can be 100s of characters overflowing your buffers == bad - */ - if (value > thres_max) - { - sprintf(str, "%e", neg ? -value : value); - return; - } - - if (prec == 0) - { - diff = value - whole; - if (diff > 0.5) - { - /* greater than 0.5, round up, e.g. 1.6 -> 2 */ - ++whole; - } - else if (diff == 0.5 && (whole & 1)) - { - /* exactly 0.5 and ODD, then round up */ - /* 1.5 -> 2, but 2.5 -> 2 */ - ++whole; - } - } - else - { - int count = prec; - // now do fractional part, as an unsigned number - do - { - --count; - *wstr++ = (char)(48 + (frac % 10)); - } while (frac /= 10); - // add extra 0s - while (count-- > 0) - { - *wstr++ = '0'; - } - // add decimal - *wstr++ = '.'; - } - - // do whole part - // Take care of sign - // Conversion. Number is reversed. - do - { - *wstr++ = (char)(48 + (whole % 10)); - } while (whole /= 10); - - if (neg) - { - *wstr++ = '-'; - } - *wstr='\0'; - strreverse(str, wstr-1); -} - - - - diff --git a/Vendor/NXJSON/NXSerializable.h b/Vendor/NXJSON/NXSerializable.h deleted file mode 100644 index 892d2fd350..0000000000 --- a/Vendor/NXJSON/NXSerializable.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Copyright (c) 2011 Nextive LLC - - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - associated documentation files (the "Software"), to deal in the Software without restriction, - including without limitation the rights to use, copy, modify, merge, publish, distribute, - sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all copies or substantial - portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES - OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - Created by Martin Adoue (martin@nextive.com) and Hernan Pelassini (hernan@nextive.com) - - */ - -/** - - Implement this protocol to allow for seamless serialization of objects to the supported formats (JSON, binary, etc.) - - */ - - -@protocol NXSerializable -/** - Return any valid object for serialization *except* an object that conforms to this protocol. - If you want a `nil`, return `[NSNull null]` - */ --(id)serialize; -@end diff --git a/Vendor/SBJSON/JSON.h b/Vendor/SBJSON/JSON.h deleted file mode 100644 index db3c516db4..0000000000 --- a/Vendor/SBJSON/JSON.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (C) 2009-2010 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - @mainpage A strict JSON parser and generator for Objective-C - - JSON (JavaScript Object Notation) is a lightweight data-interchange - format. This framework provides two apis for parsing and generating - JSON. One standard object-based and a higher level api consisting of - categories added to existing Objective-C classes. - - This framework does its best to be as strict as possible, both in what it accepts and what it generates. For example, it does not support trailing commas in arrays or objects. Nor does it support embedded comments, or anything else not in the JSON specification. This is considered a feature. - - @section Links - - @li Project home page. - @li Online version of the API documentation. - -*/ - - -// This setting of 1 is best if you copy the source into your project. -// The build transforms the 1 to a 0 when building the framework and static lib. - -#if 1 - -#import "SBJsonParser.h" -#import "SBJsonWriter.h" -#import "NSObject+SBJSON.h" -#import "NSString+SBJSON.h" - -#else - -#import -#import -#import -#import - -#endif diff --git a/Vendor/SBJSON/NSObject+SBJSON.h b/Vendor/SBJSON/NSObject+SBJSON.h deleted file mode 100644 index 8e9620e682..0000000000 --- a/Vendor/SBJSON/NSObject+SBJSON.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import - - -/** - @brief Adds JSON generation to Foundation classes - - This is a category on NSObject that adds methods for returning JSON representations - of standard objects to the objects themselves. This means you can call the - -JSONRepresentation method on an NSArray object and it'll do what you want. - */ -@interface NSObject (NSObject_SBJSON) - -/** - @brief Returns a string containing the receiver encoded in JSON. - - This method is added as a category on NSObject but is only actually - supported for the following objects: - @li NSDictionary - @li NSArray - */ -- (NSString *)JSONRepresentation; - -@end - diff --git a/Vendor/SBJSON/NSObject+SBJSON.m b/Vendor/SBJSON/NSObject+SBJSON.m deleted file mode 100644 index 5cc845fee5..0000000000 --- a/Vendor/SBJSON/NSObject+SBJSON.m +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "NSObject+SBJSON.h" -#import "SBJsonWriter.h" -#import "RKFixCategoryBug.h" - -RK_FIX_CATEGORY_BUG(NSObject_SBJSON) - -@implementation NSObject (NSObject_SBJSON) - -- (NSString *)JSONRepresentation { - SBJsonWriter *jsonWriter = [SBJsonWriter new]; - NSString *json = [jsonWriter stringWithObject:self]; - if (!json) - NSLog(@"-JSONRepresentation failed. Error trace is: %@", [jsonWriter errorTrace]); - [jsonWriter release]; - return json; -} - -@end diff --git a/Vendor/SBJSON/NSString+SBJSON.h b/Vendor/SBJSON/NSString+SBJSON.h deleted file mode 100644 index 029aa309d3..0000000000 --- a/Vendor/SBJSON/NSString+SBJSON.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import - -/** - @brief Adds JSON parsing methods to NSString - -This is a category on NSString that adds methods for parsing the target string. -*/ -@interface NSString (NSString_SBJSON) - -/** - @brief Returns the NSDictionary or NSArray represented by the current string's JSON representation. - - Returns the dictionary or array represented in the receiver, or nil on error. - - Returns the NSDictionary or NSArray represented by the current string's JSON representation. - */ -- (id)JSONValue; - -@end diff --git a/Vendor/SBJSON/NSString+SBJSON.m b/Vendor/SBJSON/NSString+SBJSON.m deleted file mode 100644 index 4170f5e998..0000000000 --- a/Vendor/SBJSON/NSString+SBJSON.m +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2007-2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "NSString+SBJSON.h" -#import "SBJsonParser.h" -#import "RKFixCategoryBug.h" - -RK_FIX_CATEGORY_BUG(NSString_SBJSON) - -@implementation NSString (NSString_SBJSON) - -- (id)JSONValue -{ - SBJsonParser *jsonParser = [SBJsonParser new]; - id repr = [jsonParser objectWithString:self]; - if (!repr) - NSLog(@"-JSONValue failed. Error trace is: %@", [jsonParser errorTrace]); - [jsonParser release]; - return repr; -} - -@end diff --git a/Vendor/SBJSON/SBJsonBase.h b/Vendor/SBJSON/SBJsonBase.h deleted file mode 100644 index 7b108440f0..0000000000 --- a/Vendor/SBJSON/SBJsonBase.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import - -extern NSString * SBJSONErrorDomain; - - -enum { - EUNSUPPORTED = 1, - EPARSENUM, - EPARSE, - EFRAGMENT, - ECTRL, - EUNICODE, - EDEPTH, - EESCAPE, - ETRAILCOMMA, - ETRAILGARBAGE, - EEOF, - EINPUT -}; - -/** - @brief Common base class for parsing & writing. - - This class contains the common error-handling code and option between the parser/writer. - */ -@interface SBJsonBase : NSObject { - NSMutableArray *errorTrace; - -@protected - NSUInteger depth, maxDepth; -} - -/** - @brief The maximum recursing depth. - - Defaults to 512. If the input is nested deeper than this the input will be deemed to be - malicious and the parser returns nil, signalling an error. ("Nested too deep".) You can - turn off this security feature by setting the maxDepth value to 0. - */ -@property NSUInteger maxDepth; - -/** - @brief Return an error trace, or nil if there was no errors. - - Note that this method returns the trace of the last method that failed. - You need to check the return value of the call you're making to figure out - if the call actually failed, before you know call this method. - */ - @property(copy,readonly) NSArray* errorTrace; - -/// @internal for use in subclasses to add errors to the stack trace -- (void)addErrorWithCode:(NSUInteger)code description:(NSString*)str; - -/// @internal for use in subclasess to clear the error before a new parsing attempt -- (void)clearErrorTrace; - -@end diff --git a/Vendor/SBJSON/SBJsonBase.m b/Vendor/SBJSON/SBJsonBase.m deleted file mode 100644 index 6684325d13..0000000000 --- a/Vendor/SBJSON/SBJsonBase.m +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "SBJsonBase.h" -NSString * SBJSONErrorDomain = @"org.brautaset.JSON.ErrorDomain"; - - -@implementation SBJsonBase - -@synthesize errorTrace; -@synthesize maxDepth; - -- (id)init { - self = [super init]; - if (self) - self.maxDepth = 512; - return self; -} - -- (void)dealloc { - [errorTrace release]; - [super dealloc]; -} - -- (void)addErrorWithCode:(NSUInteger)code description:(NSString*)str { - NSDictionary *userInfo; - if (!errorTrace) { - errorTrace = [NSMutableArray new]; - userInfo = [NSDictionary dictionaryWithObject:str forKey:NSLocalizedDescriptionKey]; - - } else { - userInfo = [NSDictionary dictionaryWithObjectsAndKeys: - str, NSLocalizedDescriptionKey, - [errorTrace lastObject], NSUnderlyingErrorKey, - nil]; - } - - NSError *error = [NSError errorWithDomain:SBJSONErrorDomain code:code userInfo:userInfo]; - - [self willChangeValueForKey:@"errorTrace"]; - [errorTrace addObject:error]; - [self didChangeValueForKey:@"errorTrace"]; -} - -- (void)clearErrorTrace { - [self willChangeValueForKey:@"errorTrace"]; - [errorTrace release]; - errorTrace = nil; - [self didChangeValueForKey:@"errorTrace"]; -} - -@end diff --git a/Vendor/SBJSON/SBJsonParser.h b/Vendor/SBJSON/SBJsonParser.h deleted file mode 100644 index feaccd863e..0000000000 --- a/Vendor/SBJSON/SBJsonParser.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import -#import "SBJsonBase.h" - -/** - @brief The JSON parser class. - - JSON is mapped to Objective-C types in the following way: - - @li Null -> NSNull - @li String -> NSMutableString - @li Array -> NSMutableArray - @li Object -> NSMutableDictionary - @li Boolean -> NSNumber (initialised with -initWithBool:) - @li Number -> (NSNumber | NSDecimalNumber) - - Since Objective-C doesn't have a dedicated class for boolean values, these turns into NSNumber - instances. These are initialised with the -initWithBool: method, and - round-trip back to JSON properly. (They won't silently suddenly become 0 or 1; they'll be - represented as 'true' and 'false' again.) - - As an optimisation short JSON integers turn into NSNumber instances, while complex ones turn into NSDecimalNumber instances. - We can thus avoid any loss of precision as JSON allows ridiculously large numbers. - - */ -@interface SBJsonParser : SBJsonBase { - -@private - const char *c; -} - -/** - @brief Return the object represented by the given string - - Returns the object represented by the passed-in string or nil on error. The returned object can be - a string, number, boolean, null, array or dictionary. - - @param repr the json string to parse - */ -- (id)objectWithString:(NSString *)repr; - -/** - @brief Return the object represented by the given string - - Returns the object represented by the passed-in string or nil on error. The returned object can be - a string, number, boolean, null, array or dictionary. - - @param jsonText the json string to parse - @param error pointer to an NSError object to populate on error - */ - -- (id)objectWithString:(NSString*)jsonText - error:(NSError**)error; - - -@end - - diff --git a/Vendor/SBJSON/SBJsonParser.m b/Vendor/SBJSON/SBJsonParser.m deleted file mode 100644 index 222ef7038c..0000000000 --- a/Vendor/SBJSON/SBJsonParser.m +++ /dev/null @@ -1,516 +0,0 @@ -/* - Copyright (C) 2009,2010 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "SBJsonParser.h" - -@interface SBJsonParser () - -- (BOOL)scanValue:(NSObject **)o; - -- (BOOL)scanRestOfArray:(NSMutableArray **)o; -- (BOOL)scanRestOfDictionary:(NSMutableDictionary **)o; -- (BOOL)scanRestOfNull:(NSNull **)o; -- (BOOL)scanRestOfFalse:(NSNumber **)o; -- (BOOL)scanRestOfTrue:(NSNumber **)o; -- (BOOL)scanRestOfString:(NSMutableString **)o; - -// Cannot manage without looking at the first digit -- (BOOL)scanNumber:(NSNumber **)o; - -- (BOOL)scanHexQuad:(unichar *)x; -- (BOOL)scanUnicodeChar:(unichar *)x; - -- (BOOL)scanIsAtEnd; - -@end - -#define skipWhitespace(c) while (isspace(*c)) c++ -#define skipDigits(c) while (isdigit(*c)) c++ - - -@implementation SBJsonParser - -static char ctrl[0x22]; - - -+ (void)initialize { - ctrl[0] = '\"'; - ctrl[1] = '\\'; - for (int i = 1; i < 0x20; i++) - ctrl[i+1] = i; - ctrl[0x21] = 0; -} - -- (id)objectWithString:(NSString *)repr { - [self clearErrorTrace]; - - if (!repr) { - [self addErrorWithCode:EINPUT description:@"Input was 'nil'"]; - return nil; - } - - depth = 0; - c = [repr UTF8String]; - - id o; - if (![self scanValue:&o]) { - return nil; - } - - // We found some valid JSON. But did it also contain something else? - if (![self scanIsAtEnd]) { - [self addErrorWithCode:ETRAILGARBAGE description:@"Garbage after JSON"]; - return nil; - } - - NSAssert1(o, @"Should have a valid object from %@", repr); - - // Check that the object we've found is a valid JSON container. - if (![o isKindOfClass:[NSDictionary class]] && ![o isKindOfClass:[NSArray class]]) { - [self addErrorWithCode:EFRAGMENT description:@"Valid fragment, but not JSON"]; - return nil; - } - - return o; -} - -- (id)objectWithString:(NSString*)repr error:(NSError**)error { - id tmp = [self objectWithString:repr]; - if (tmp) - return tmp; - - if (error) - *error = [self.errorTrace lastObject]; - return nil; -} - - -/* - In contrast to the public methods, it is an error to omit the error parameter here. - */ -- (BOOL)scanValue:(NSObject **)o -{ - skipWhitespace(c); - - switch (*c++) { - case '{': - return [self scanRestOfDictionary:(NSMutableDictionary **)o]; - break; - case '[': - return [self scanRestOfArray:(NSMutableArray **)o]; - break; - case '"': - return [self scanRestOfString:(NSMutableString **)o]; - break; - case 'f': - return [self scanRestOfFalse:(NSNumber **)o]; - break; - case 't': - return [self scanRestOfTrue:(NSNumber **)o]; - break; - case 'n': - return [self scanRestOfNull:(NSNull **)o]; - break; - case '-': - case '0'...'9': - c--; // cannot verify number correctly without the first character - return [self scanNumber:(NSNumber **)o]; - break; - case '+': - [self addErrorWithCode:EPARSENUM description: @"Leading + disallowed in number"]; - return NO; - break; - case 0x0: - [self addErrorWithCode:EEOF description:@"Unexpected end of string"]; - return NO; - break; - default: - [self addErrorWithCode:EPARSE description: @"Unrecognised leading character"]; - return NO; - break; - } - - NSAssert(0, @"Should never get here"); - return NO; -} - -- (BOOL)scanRestOfTrue:(NSNumber **)o -{ - if (!strncmp(c, "rue", 3)) { - c += 3; - *o = [NSNumber numberWithBool:YES]; - return YES; - } - [self addErrorWithCode:EPARSE description:@"Expected 'true'"]; - return NO; -} - -- (BOOL)scanRestOfFalse:(NSNumber **)o -{ - if (!strncmp(c, "alse", 4)) { - c += 4; - *o = [NSNumber numberWithBool:NO]; - return YES; - } - [self addErrorWithCode:EPARSE description: @"Expected 'false'"]; - return NO; -} - -- (BOOL)scanRestOfNull:(NSNull **)o { - if (!strncmp(c, "ull", 3)) { - c += 3; - *o = [NSNull null]; - return YES; - } - [self addErrorWithCode:EPARSE description: @"Expected 'null'"]; - return NO; -} - -- (BOOL)scanRestOfArray:(NSMutableArray **)o { - if (maxDepth && ++depth > maxDepth) { - [self addErrorWithCode:EDEPTH description: @"Nested too deep"]; - return NO; - } - - *o = [NSMutableArray arrayWithCapacity:8]; - - for (; *c ;) { - id v; - - skipWhitespace(c); - if (*c == ']' && c++) { - depth--; - return YES; - } - - if (![self scanValue:&v]) { - [self addErrorWithCode:EPARSE description:@"Expected value while parsing array"]; - return NO; - } - - [*o addObject:v]; - - skipWhitespace(c); - if (*c == ',' && c++) { - skipWhitespace(c); - if (*c == ']') { - [self addErrorWithCode:ETRAILCOMMA description: @"Trailing comma disallowed in array"]; - return NO; - } - } - } - - [self addErrorWithCode:EEOF description: @"End of input while parsing array"]; - return NO; -} - -- (BOOL)scanRestOfDictionary:(NSMutableDictionary **)o -{ - if (maxDepth && ++depth > maxDepth) { - [self addErrorWithCode:EDEPTH description: @"Nested too deep"]; - return NO; - } - - *o = [NSMutableDictionary dictionaryWithCapacity:7]; - - for (; *c ;) { - id k, v; - - skipWhitespace(c); - if (*c == '}' && c++) { - depth--; - return YES; - } - - if (!(*c == '\"' && c++ && [self scanRestOfString:&k])) { - [self addErrorWithCode:EPARSE description: @"Object key string expected"]; - return NO; - } - - skipWhitespace(c); - if (*c != ':') { - [self addErrorWithCode:EPARSE description: @"Expected ':' separating key and value"]; - return NO; - } - - c++; - if (![self scanValue:&v]) { - NSString *string = [NSString stringWithFormat:@"Object value expected for key: %@", k]; - [self addErrorWithCode:EPARSE description: string]; - return NO; - } - - [*o setObject:v forKey:k]; - - skipWhitespace(c); - if (*c == ',' && c++) { - skipWhitespace(c); - if (*c == '}') { - [self addErrorWithCode:ETRAILCOMMA description: @"Trailing comma disallowed in object"]; - return NO; - } - } - } - - [self addErrorWithCode:EEOF description: @"End of input while parsing object"]; - return NO; -} - -- (BOOL)scanRestOfString:(NSMutableString **)o -{ - // if the string has no control characters in it, return it in one go, without any temporary allocations. - size_t len = strcspn(c, ctrl); - if (len && *(c + len) == '\"') - { - *o = [[[NSMutableString alloc] initWithBytes:(char*)c length:len encoding:NSUTF8StringEncoding] autorelease]; - c += len + 1; - return YES; - } - - *o = [NSMutableString stringWithCapacity:16]; - do { - // First see if there's a portion we can grab in one go. - // Doing this caused a massive speedup on the long string. - len = strcspn(c, ctrl); - if (len) { - // check for - id t = [[NSString alloc] initWithBytesNoCopy:(char*)c - length:len - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; - if (t) { - [*o appendString:t]; - [t release]; - c += len; - } - } - - if (*c == '"') { - c++; - return YES; - - } else if (*c == '\\') { - unichar uc = *++c; - switch (uc) { - case '\\': - case '/': - case '"': - break; - - case 'b': uc = '\b'; break; - case 'n': uc = '\n'; break; - case 'r': uc = '\r'; break; - case 't': uc = '\t'; break; - case 'f': uc = '\f'; break; - - case 'u': - c++; - if (![self scanUnicodeChar:&uc]) { - [self addErrorWithCode:EUNICODE description: @"Broken unicode character"]; - return NO; - } - c--; // hack. - break; - default: - [self addErrorWithCode:EESCAPE description: [NSString stringWithFormat:@"Illegal escape sequence '0x%x'", uc]]; - return NO; - break; - } - CFStringAppendCharacters((CFMutableStringRef)*o, &uc, 1); - c++; - - } else if (*c < 0x20) { - [self addErrorWithCode:ECTRL description: [NSString stringWithFormat:@"Unescaped control character '0x%x'", *c]]; - return NO; - - } else { - NSLog(@"should not be able to get here"); - } - } while (*c); - - [self addErrorWithCode:EEOF description:@"Unexpected EOF while parsing string"]; - return NO; -} - -- (BOOL)scanUnicodeChar:(unichar *)x -{ - unichar hi, lo; - - if (![self scanHexQuad:&hi]) { - [self addErrorWithCode:EUNICODE description: @"Missing hex quad"]; - return NO; - } - - if (hi >= 0xd800) { // high surrogate char? - if (hi < 0xdc00) { // yes - expect a low char - - if (!(*c == '\\' && ++c && *c == 'u' && ++c && [self scanHexQuad:&lo])) { - [self addErrorWithCode:EUNICODE description: @"Missing low character in surrogate pair"]; - return NO; - } - - if (lo < 0xdc00 || lo >= 0xdfff) { - [self addErrorWithCode:EUNICODE description:@"Invalid low surrogate char"]; - return NO; - } - - hi = (hi - 0xd800) * 0x400 + (lo - 0xdc00) + 0x10000; - - } else if (hi < 0xe000) { - [self addErrorWithCode:EUNICODE description:@"Invalid high character in surrogate pair"]; - return NO; - } - } - - *x = hi; - return YES; -} - -- (BOOL)scanHexQuad:(unichar *)x -{ - *x = 0; - for (int i = 0; i < 4; i++) { - unichar uc = *c; - c++; - int d = (uc >= '0' && uc <= '9') - ? uc - '0' : (uc >= 'a' && uc <= 'f') - ? (uc - 'a' + 10) : (uc >= 'A' && uc <= 'F') - ? (uc - 'A' + 10) : -1; - if (d == -1) { - [self addErrorWithCode:EUNICODE description:@"Missing hex digit in quad"]; - return NO; - } - *x *= 16; - *x += d; - } - return YES; -} - -- (BOOL)scanNumber:(NSNumber **)o -{ - BOOL simple = YES; - - const char *ns = c; - - // The logic to test for validity of the number formatting is relicensed - // from JSON::XS with permission from its author Marc Lehmann. - // (Available at the CPAN: http://search.cpan.org/dist/JSON-XS/ .) - - if ('-' == *c) - c++; - - if ('0' == *c && c++) { - if (isdigit(*c)) { - [self addErrorWithCode:EPARSENUM description: @"Leading 0 disallowed in number"]; - return NO; - } - - } else if (!isdigit(*c) && c != ns) { - [self addErrorWithCode:EPARSENUM description: @"No digits after initial minus"]; - return NO; - - } else { - skipDigits(c); - } - - // Fractional part - if ('.' == *c && c++) { - simple = NO; - if (!isdigit(*c)) { - [self addErrorWithCode:EPARSENUM description: @"No digits after decimal point"]; - return NO; - } - skipDigits(c); - } - - // Exponential part - if ('e' == *c || 'E' == *c) { - simple = NO; - c++; - - if ('-' == *c || '+' == *c) - c++; - - if (!isdigit(*c)) { - [self addErrorWithCode:EPARSENUM description: @"No digits after exponent"]; - return NO; - } - skipDigits(c); - } - - // If we are only reading integers, don't go through the expense of creating an NSDecimal. - // This ends up being a very large perf win. - if (simple) { - BOOL negate = NO; - long long val = 0; - const char *d = ns; - - if (*d == '-') { - negate = YES; - d++; - } - - while (isdigit(*d)) { - val *= 10; - if (val < 0) - goto longlong_overflow; - val += *d - '0'; - if (val < 0) - goto longlong_overflow; - d++; - } - - *o = [NSNumber numberWithLongLong:negate ? -val : val]; - return YES; - - } else { - // jumped to by simple branch, if an overflow occured - longlong_overflow:; - - id str = [[NSString alloc] initWithBytesNoCopy:(char*)ns - length:c - ns - encoding:NSUTF8StringEncoding - freeWhenDone:NO]; - [str autorelease]; - if (str && (*o = [NSDecimalNumber decimalNumberWithString:str])) - return YES; - - [self addErrorWithCode:EPARSENUM description: @"Failed creating decimal instance"]; - return NO; - } -} - -- (BOOL)scanIsAtEnd -{ - skipWhitespace(c); - return !*c; -} - - -@end diff --git a/Vendor/SBJSON/SBJsonWriter.h b/Vendor/SBJSON/SBJsonWriter.h deleted file mode 100644 index ae1a597bb7..0000000000 --- a/Vendor/SBJSON/SBJsonWriter.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import -#import "SBJsonBase.h" - -/** - @brief The JSON writer class. - - Objective-C types are mapped to JSON types in the following way: - - @li NSNull -> Null - @li NSString -> String - @li NSArray -> Array - @li NSDictionary -> Object - @li NSNumber (-initWithBool:) -> Boolean - @li NSNumber -> Number - - In JSON the keys of an object must be strings. NSDictionary keys need - not be, but attempting to convert an NSDictionary with non-string keys - into JSON will throw an exception. - - NSNumber instances created with the +initWithBool: method are - converted into the JSON boolean "true" and "false" values, and vice - versa. Any other NSNumber instances are converted to a JSON number the - way you would expect. - - */ -@interface SBJsonWriter : SBJsonBase { - -@private - BOOL sortKeys, humanReadable; -} - -/** - @brief Whether we are generating human-readable (multiline) JSON. - - Set whether or not to generate human-readable JSON. The default is NO, which produces - JSON without any whitespace. (Except inside strings.) If set to YES, generates human-readable - JSON with linebreaks after each array value and dictionary key/value pair, indented two - spaces per nesting level. - */ -@property BOOL humanReadable; - -/** - @brief Whether or not to sort the dictionary keys in the output. - - If this is set to YES, the dictionary keys in the JSON output will be in sorted order. - (This is useful if you need to compare two structures, for example.) The default is NO. - */ -@property BOOL sortKeys; - -/** - @brief Return JSON representation (or fragment) for the given object. - - Returns a string containing JSON representation of the passed in value, or nil on error. - If nil is returned and @p error is not NULL, @p *error can be interrogated to find the cause of the error. - - @param value any instance that can be represented as a JSON fragment - - */ -- (NSString*)stringWithObject:(id)value; - -/** - @brief Return JSON representation (or fragment) for the given object. - - Returns a string containing JSON representation of the passed in value, or nil on error. - If nil is returned and @p error is not NULL, @p *error can be interrogated to find the cause of the error. - - @param value any instance that can be represented as a JSON fragment - @param error pointer to object to be populated with NSError on failure - - */- (NSString*)stringWithObject:(id)value - error:(NSError**)error; - - -@end - -/** - @brief Allows generation of JSON for otherwise unsupported classes. - - If you have a custom class that you want to create a JSON representation for you can implement - this method in your class. It should return a representation of your object defined - in terms of objects that can be translated into JSON. For example, a Person - object might implement it like this: - - @code - - (id)proxyForJson { - return [NSDictionary dictionaryWithObjectsAndKeys: - name, @"name", - phone, @"phone", - email, @"email", - nil]; - } - @endcode - - */ -@interface NSObject (SBProxyForJson) -- (id)proxyForJson; -@end - diff --git a/Vendor/SBJSON/SBJsonWriter.m b/Vendor/SBJSON/SBJsonWriter.m deleted file mode 100644 index 83e8a202bd..0000000000 --- a/Vendor/SBJSON/SBJsonWriter.m +++ /dev/null @@ -1,239 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import "SBJsonWriter.h" - -@interface SBJsonWriter () - -- (BOOL)appendValue:(id)fragment into:(NSMutableString*)json; -- (BOOL)appendArray:(NSArray*)fragment into:(NSMutableString*)json; -- (BOOL)appendDictionary:(NSDictionary*)fragment into:(NSMutableString*)json; -- (BOOL)appendString:(NSString*)fragment into:(NSMutableString*)json; - -- (NSString*)indent; - -@end - -@implementation SBJsonWriter - -@synthesize sortKeys; -@synthesize humanReadable; - -static NSMutableCharacterSet *kEscapeChars; - -+ (void)initialize { - kEscapeChars = [[NSMutableCharacterSet characterSetWithRange: NSMakeRange(0,32)] retain]; - [kEscapeChars addCharactersInString: @"\"\\"]; -} - -- (NSString*)stringWithObject:(id)value { - [self clearErrorTrace]; - - if ([value isKindOfClass:[NSDictionary class]] || [value isKindOfClass:[NSArray class]]) { - depth = 0; - NSMutableString *json = [NSMutableString stringWithCapacity:128]; - if ([self appendValue:value into:json]) - return json; - } - - if ([value respondsToSelector:@selector(proxyForJson)]) { - NSString *tmp = [self stringWithObject:[value proxyForJson]]; - if (tmp) - return tmp; - } - - [self addErrorWithCode:EFRAGMENT description:@"Not valid type for JSON"]; - return nil; -} - -- (NSString*)stringWithObject:(id)value error:(NSError**)error { - NSString *tmp = [self stringWithObject:value]; - if (tmp) - return tmp; - - if (error) - *error = [self.errorTrace lastObject]; - return nil; -} - -- (NSString*)indent { - return [@"\n" stringByPaddingToLength:1 + 2 * depth withString:@" " startingAtIndex:0]; -} - -- (BOOL)appendValue:(id)fragment into:(NSMutableString*)json { - if ([fragment isKindOfClass:[NSDictionary class]]) { - if (![self appendDictionary:fragment into:json]) - return NO; - - } else if ([fragment isKindOfClass:[NSArray class]]) { - if (![self appendArray:fragment into:json]) - return NO; - - } else if ([fragment isKindOfClass:[NSString class]]) { - if (![self appendString:fragment into:json]) - return NO; - - } else if ([fragment isKindOfClass:[NSNumber class]]) { - if ('c' == *[fragment objCType]) { - [json appendString:[fragment boolValue] ? @"true" : @"false"]; - } else if ([fragment isEqualToNumber:(NSNumber*)kCFNumberNaN]) { - [self addErrorWithCode:EUNSUPPORTED description:@"NaN is not a valid number in JSON"]; - return NO; - - } else if (isinf([fragment doubleValue])) { - [self addErrorWithCode:EUNSUPPORTED description:@"Infinity is not a valid number in JSON"]; - return NO; - - } else { - [json appendString:[fragment stringValue]]; - } - } else if ([fragment isKindOfClass:[NSNull class]]) { - [json appendString:@"null"]; - } else if ([fragment respondsToSelector:@selector(proxyForJson)]) { - [self appendValue:[fragment proxyForJson] into:json]; - - } else { - [self addErrorWithCode:EUNSUPPORTED description:[NSString stringWithFormat:@"JSON serialisation not supported for %@", [fragment class]]]; - return NO; - } - return YES; -} - -- (BOOL)appendArray:(NSArray*)fragment into:(NSMutableString*)json { - if (maxDepth && ++depth > maxDepth) { - [self addErrorWithCode:EDEPTH description: @"Nested too deep"]; - return NO; - } - [json appendString:@"["]; - - BOOL addComma = NO; - for (id value in fragment) { - if (addComma) - [json appendString:@","]; - else - addComma = YES; - - if ([self humanReadable]) - [json appendString:[self indent]]; - - if (![self appendValue:value into:json]) { - return NO; - } - } - - depth--; - if ([self humanReadable] && [fragment count]) - [json appendString:[self indent]]; - [json appendString:@"]"]; - return YES; -} - -- (BOOL)appendDictionary:(NSDictionary*)fragment into:(NSMutableString*)json { - if (maxDepth && ++depth > maxDepth) { - [self addErrorWithCode:EDEPTH description: @"Nested too deep"]; - return NO; - } - [json appendString:@"{"]; - - NSString *colon = [self humanReadable] ? @" : " : @":"; - BOOL addComma = NO; - NSArray *keys = [fragment allKeys]; - if (self.sortKeys) - keys = [keys sortedArrayUsingSelector:@selector(compare:)]; - - for (id value in keys) { - if (addComma) - [json appendString:@","]; - else - addComma = YES; - - if ([self humanReadable]) - [json appendString:[self indent]]; - - if (![value isKindOfClass:[NSString class]]) { - [self addErrorWithCode:EUNSUPPORTED description: @"JSON object key must be string"]; - return NO; - } - - if (![self appendString:value into:json]) - return NO; - - [json appendString:colon]; - if (![self appendValue:[fragment objectForKey:value] into:json]) { - [self addErrorWithCode:EUNSUPPORTED description:[NSString stringWithFormat:@"Unsupported value for key %@ in object", value]]; - return NO; - } - } - - depth--; - if ([self humanReadable] && [fragment count]) - [json appendString:[self indent]]; - [json appendString:@"}"]; - return YES; -} - -- (BOOL)appendString:(NSString*)fragment into:(NSMutableString*)json { - - [json appendString:@"\""]; - - NSRange esc = [fragment rangeOfCharacterFromSet:kEscapeChars]; - if ( !esc.length ) { - // No special chars -- can just add the raw string: - [json appendString:fragment]; - - } else { - NSUInteger length = [fragment length]; - for (NSUInteger i = 0; i < length; i++) { - unichar uc = [fragment characterAtIndex:i]; - switch (uc) { - case '"': [json appendString:@"\\\""]; break; - case '\\': [json appendString:@"\\\\"]; break; - case '\t': [json appendString:@"\\t"]; break; - case '\n': [json appendString:@"\\n"]; break; - case '\r': [json appendString:@"\\r"]; break; - case '\b': [json appendString:@"\\b"]; break; - case '\f': [json appendString:@"\\f"]; break; - default: - if (uc < 0x20) { - [json appendFormat:@"\\u%04x", uc]; - } else { - CFStringAppendCharacters((CFMutableStringRef)json, &uc, 1); - } - break; - - } - } - } - - [json appendString:@"\""]; - return YES; -} - - -@end diff --git a/Vendor/YAJL/CHANGELOG.md b/Vendor/YAJL/CHANGELOG.md deleted file mode 100644 index 629cc62c5e..0000000000 --- a/Vendor/YAJL/CHANGELOG.md +++ /dev/null @@ -1,92 +0,0 @@ -== 0.2.25 - -- Fixing YAJL (iOS) build. - -== 0.2.22 - -- Fixing YAJL (Mac OSX) build. - -== 0.2.21 - -- Renaming categories to namespace them in case they are used externally. - -== 0.2.20 - -- Added framework build for iPhone - -== 0.2.17 - -- Updated to use yalj 1.0.9 (iPhone) - -== 0.2.16 - -- Hudson (JUnit XML support) -- Fix YAJL.h import -- Updated to use yajl 1.0.9 - -== 0.2.15 - -- YAJLParserOptionsStrictPrecision option -- Parsing as double on long long overflow, unless strict precision option - -== 0.2.14 - -- Fixing build problem - -== 0.2.13 - -- Using long long for non-decimal types (instead of always double). - -== 0.2.12 - -- Fixing MacOSX build/install to use @rpath correctly -- Defined error codes, and error userInfo key for value we errored on - -== 0.2.11 - -- Fixed bug where yajl_JSONWithOptions:error: would ignore options. - -== 0.2.10 - -- Gen options for ignoring unknown types and supporting PList types like NSData and NSDate -- Changed default capacity in YAJLDocument for slightly better perf - -== 0.2.9 - -- Enabling verbose errors in yajl - -== 0.2.8 - -- Memory usage fix from wooster (autorelease to release) -- Fixed memory leak when number parse error -- Added default init methods for YAJLDocument and YAJLParser - -== 0.2.7 - -- Changed yajl_encodeJSON to JSON for YAJLCoding protocol -- Updating comments for YAJLCoding - -== 0.2.6 - -- Supporting gen/parse from NSObject category (supports NSString, NSData and custom) -- Including standard/optimized build for arm6/7 -- Include yajl_*.h api header files (iPhone) -- 32/64 bit universal build (Mac OSX) - -== 0.2.5 - -- Added YAJLGen wrapper for yajl_gen -- Added streaming support to YAJLDocument -- Added NSString category -- Added NSObject category - -== 0.2.4 - -- Using yajl_number callback since its more compliant (correctly handles large double values) -- Changing YAJLParser API to allow for streaming data -- Added test for overflow.json -- Added test for insane sample.json - -== 0.2.3 - -- Fixed memory leak in YAJLParser diff --git a/Vendor/YAJL/Classes/NSBundle+YAJL.h b/Vendor/YAJL/Classes/NSBundle+YAJL.h deleted file mode 100644 index 4b8a41be96..0000000000 --- a/Vendor/YAJL/Classes/NSBundle+YAJL.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// NSBundle+YAJL.h -// YAJL -// -// Created by Gabriel Handford on 7/23/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "YAJLParser.h" - -/*! - Utilities for loading JSON from resource bundles. - - @code - id JSONValue = [[NSBundle mainBundle] yajl_JSONFromResource:@"kegs.json"]; - @endcode - */ -@interface NSBundle(YAJL) - -/*! - Load JSON from bundle. - @param resource Resource name with extension, for example, file.json - @throws YAJLParserException On parse error - */ -- (id)yajl_JSONFromResource:(NSString *)resource; - -/*! - Load JSON from bundle. - @param resource Resource name with extension, for example, file.json - @param options Parser options - - YAJLParserOptionsNone: No options - - YAJLParserOptionsAllowComments: Javascript style comments will be allowed in the input (both /&asterisk; &asterisk;/ and //) - - YAJLParserOptionsCheckUTF8: Invalid UTF8 strings will cause a parse error - - YAJLParserOptionsStrictPrecision: If YES will force strict precision and return integer overflow error - - @param error Out error - @result JSON value (NSArray, NSDictionary) or nil if errored - */ -- (id)yajl_JSONFromResource:(NSString *)resource options:(YAJLParserOptions)options error:(NSError **)error; - -@end diff --git a/Vendor/YAJL/Classes/NSBundle+YAJL.m b/Vendor/YAJL/Classes/NSBundle+YAJL.m deleted file mode 100644 index fec0825880..0000000000 --- a/Vendor/YAJL/Classes/NSBundle+YAJL.m +++ /dev/null @@ -1,50 +0,0 @@ -// -// NSBundle+YAJL.m -// YAJL -// -// Created by Gabriel Handford on 7/23/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "NSBundle+YAJL.h" -#import "GHNSBundle+Utils.h" -#import "NSObject+YAJL.h" -#import "RKFixCategoryBug.h" - -RK_FIX_CATEGORY_BUG(NSBundle_YAJL) - -@implementation NSBundle(YAJL) - -- (id)yajl_JSONFromResource:(NSString *)resource { - NSError *error = nil; - id JSONValue = [self yajl_JSONFromResource:resource options:YAJLParserOptionsNone error:&error]; - if (error) [NSException raise:YAJLParserException format:[error localizedDescription], nil]; - return JSONValue; -} - -- (id)yajl_JSONFromResource:(NSString *)resource options:(YAJLParserOptions)options error:(NSError **)error { - return [[self yajl_gh_loadStringDataFromResource:resource] yajl_JSONWithOptions:YAJLParserOptionsAllowComments error:error]; -} - -@end diff --git a/Vendor/YAJL/Classes/NSObject+YAJL.h b/Vendor/YAJL/Classes/NSObject+YAJL.h deleted file mode 100644 index e2a49dae53..0000000000 --- a/Vendor/YAJL/Classes/NSObject+YAJL.h +++ /dev/null @@ -1,154 +0,0 @@ -// -// NSObject+YAJL.h -// YAJL -// -// Created by Gabriel Handford on 7/23/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "YAJLGen.h" -#import "YAJLParser.h" - -/*! - Generate JSON string from NSArray, NSDictionary or custom object or parse JSON from NSString or custom object. - - Parse JSON: - @code - NSData *JSONData = [NSData dataWithContentsOfFile:@"example.json"]; - NSArray *arrayFromData = [JSONData yajl_JSON]; - - NSString *JSONString = @"[\"Test\"]"; - NSArray *arrayFromString = [JSONString yajl_JSON]; - - // With options and out error - NSError *error = nil; - NSArray *arrayFromString = [JSONString yajl_JSONWithOptions:YAJLParserOptionsAllowComments error:&error]; - @endcode - - Generate JSON: - @code - NSDictionary *dict = [NSDictionary dictionaryWithObject:@"value" forKey:@"key"]; - NSString *JSONString = [dict yajl_JSONString]; - - // Beautified with custon indent string - NSArray *array = [NSArray arrayWithObjects:@"value1", @"value2", nil]; - NSString *JSONString = [dict yajl_JSONStringWithOptions:YAJLGenOptionsBeautify indentString:@" "]; - @endcode - */ -@interface NSObject(YAJL) - -#pragma mark Gen - -/*! - Create JSON string from object. - Supported objects include: NSArray, NSDictionary, NSNumber, NSString, NSNull - To override JSON value to encode (or support custom objects), implement (id)JSON; See YAJLCoding in YAJLGen.h - @throws YAJLGenInvalidObjectException If object is invalid - @result JSON String - */ -- (NSString *)yajl_JSONString; - -/*! - Create JSON string from object. - Supported objects include: NSArray, NSDictionary, NSNumber, NSString, NSNull - To override JSON value to encode (or support custom objects), implement (id)JSON; See YAJLCoding in YAJLGen.h - @throws YAJLGenInvalidObjectException If object is invalid - @param options - - YAJLGenOptionsNone: No options - - YAJLGenOptionsBeautify: Beautifiy JSON output - - YAJLGenOptionsIgnoreUnknownTypes: Ignore unknown types (will use null value) - - YAJLGenOptionsIncludeUnsupportedTypes: Handle non-JSON types (including NSDate, NSData, NSURL) - - @param indentString - @result JSON String - */ -- (NSString *)yajl_JSONStringWithOptions:(YAJLGenOptions)options indentString:(NSString *)indentString; - - -#pragma mark Parsing - -/*! - Parse JSON (NSString or NSData or dataUsingEncoding:). - @result JSON object - @throws YAJLParserException If a parse error occured - @throws YAJLParsingUnsupportedException If not NSData or doesn't respond to dataUsingEncoding: - - @code - NSString *JSONString = @"{'foo':['bar', true]}"; - id JSONValue = [JSONString yajl_JSON]; - - NSData *JSONData = ...; - id JSONValue = [JSONData yajl_JSON]; - @endcode - */ -- (id)yajl_JSON; - -/*! - Parse JSON (NSString or NSData or dataUsingEncoding:) with out error. - - If an error occurs, the returned object will be the current state of the object when - the error occurred. - - @param error Error to set if we failed to parse - @result JSON object - @throws YAJLParserException If a parse error occured - @throws YAJLParsingUnsupportedException If not NSData or doesn't respond to dataUsingEncoding: - - @code - NSString *JSONString = @"{'foo':['bar', true]}"; - NSError *error = nil; - [JSONString yajl_JSON:error]; - if (error) ...; - @endcode - */ -- (id)yajl_JSON:(NSError **)error; - -/*! - Parse JSON (NSString or NSData or dataUsingEncoding:) with options and out error. - - If an error occurs, the returned object will be the current state of the object when - the error occurred. - - @param options Parse options - - YAJLParserOptionsNone: No options - - YAJLParserOptionsAllowComments: Javascript style comments will be allowed in the input (both /&asterisk; &asterisk;/ and //) - - YAJLParserOptionsCheckUTF8: Invalid UTF8 strings will cause a parse error - - YAJLParserOptionsStrictPrecision: If YES will force strict precision and return integer overflow error - - @param error Error to set if we failed to parse - @result JSON object - @throws YAJLParserException If a parse error occured - @throws YAJLParsingUnsupportedException If not NSData or doesn't respond to dataUsingEncoding: - - @code - NSString *JSONString = @"{'foo':['bar', true]} // comment"; - NSError *error = nil; - [JSONString yajl_JSONWithOptions:YAJLParserOptionsAllowComments error:error]; - if (error) ...; - @endcode - */ -- (id)yajl_JSONWithOptions:(YAJLParserOptions)options error:(NSError **)error; - -@end - diff --git a/Vendor/YAJL/Classes/NSObject+YAJL.m b/Vendor/YAJL/Classes/NSObject+YAJL.m deleted file mode 100644 index 9429c66a6b..0000000000 --- a/Vendor/YAJL/Classes/NSObject+YAJL.m +++ /dev/null @@ -1,82 +0,0 @@ -// -// NSObject+YAJL.m -// YAJL -// -// Created by Gabriel Handford on 7/23/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "NSObject+YAJL.h" -#import "YAJLGen.h" -#import "YAJLDocument.h" -#import "RKFixCategoryBug.h" - -RK_FIX_CATEGORY_BUG(NSObject_YAJL) - -@implementation NSObject(YAJL) - -#pragma mark Gen - -- (NSString *)yajl_JSONString { - return [self yajl_JSONStringWithOptions:YAJLGenOptionsNone indentString:@" "]; -} - -- (NSString *)yajl_JSONStringWithOptions:(YAJLGenOptions)options indentString:(NSString *)indentString { - YAJLGen *gen = [[YAJLGen alloc] initWithGenOptions:options indentString:indentString]; - [gen object:self]; - NSString *buffer = [[gen buffer] retain]; - [gen release]; - return [buffer autorelease]; -} - -#pragma mark Parsing - -- (id)yajl_JSON { - NSError *error = nil; - id JSON = [self yajl_JSON:&error]; - if (error) [NSException raise:YAJLParserException format:[error localizedDescription], nil]; - return JSON; -} - -- (id)yajl_JSON:(NSError **)error { - return [self yajl_JSONWithOptions:YAJLParserOptionsNone error:error]; -} - -- (id)yajl_JSONWithOptions:(YAJLParserOptions)options error:(NSError **)error { - NSData *data = nil; - if ([self isKindOfClass:[NSData class]]) { - data = (NSData *)self; - } else if ([self respondsToSelector:@selector(dataUsingEncoding:)]) { - data = [(id)self dataUsingEncoding:NSUTF8StringEncoding]; - } else { - [NSException raise:YAJLParsingUnsupportedException format:@"Object of type (%@) must implement dataUsingEncoding: to be parsed", [self class]]; - } - - YAJLDocument *document = [[YAJLDocument alloc] initWithData:data parserOptions:options error:error]; - id root = [document.root retain]; - [document release]; - return [root autorelease]; -} - -@end diff --git a/Vendor/YAJL/Classes/YAJL.h b/Vendor/YAJL/Classes/YAJL.h deleted file mode 100644 index 1858375d6a..0000000000 --- a/Vendor/YAJL/Classes/YAJL.h +++ /dev/null @@ -1,213 +0,0 @@ -// -// YAJL.h -// YAJL -// -// Created by Gabriel Handford on 7/23/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "YAJLParser.h" -#import "YAJLDocument.h" -#import "YAJLGen.h" -#import "NSObject+YAJL.h" -#import "NSBundle+YAJL.h" - -/*! - @mainpage YAJL - - The YAJL framework is an Objective-C wrapper around the http://lloyd.github.com/yajl/ SAX-style JSON parser. - - @section Links - - Source: http://github.com/gabriel/yajl-objc - - View docs online: http://gabriel.github.com/yajl-objc/ - - YAJL C docs: http://lloyd.github.com/yajl/ - - @section Usage Usage - - To use the framework (for Mac OS X or iOS): - - @code - // For Mac OS X - #import - // For iOS - #import - @endcode - - @section Examples Examples - - @subsection Example1 To parse JSON from NSData - - @code - NSData *JSONData = [NSData dataWithContentsOfFile:@"example.json"]; - NSArray *arrayFromData = [JSONData yajl_JSON]; - @endcode - - @subsection Example2 To parse JSON from NSString - - @code - NSString *JSONString = @"[1, 2, 3]"; - NSArray *arrayFromString = [JSONString yajl_JSON]; - @endcode - - @subsection Example2_1 To parse JSON from NSString with error and comments - - @code - // With options and out error - NSString *JSONString = @"[1, 2, 3] // Allow comments"; - NSError *error = nil; - NSArray *arrayFromString = [JSONString yajl_JSONWithOptions:YAJLParserOptionsAllowComments error:&error]; - @endcode - - @subsection Example3 To generate JSON from an object, NSArray, NSDictionary, etc. - - @code - NSDictionary *dict = [NSDictionary dictionaryWithObject:@"value" forKey:@"key"]; - NSString *JSONString = [dict yajl_JSONString]; - // ==> {"key":"value"} - @endcode - - @subsection Example4 To generate JSON from an object, beautified with custom indent - - @code - // Beautified with custon indent string - NSArray *array = [NSArray arrayWithObjects:@"value1", @"value2", nil]; - NSString *JSONString = [dict yajl_JSONStringWithOptions:YAJLGenOptionsBeautify indentString:@" "]; - @endcode - - @subsection Example5 To use the streaming (or SAX style) parser, use YAJLParser - - @code - NSData *data = [NSData dataWithContentsOfFile:@"example.json"]; - - YAJLParser *parser = [[YAJLParser alloc] initWithParserOptions:YAJLParserOptionsAllowComments]; - parser.delegate = self; - [parser parse:data]; - if (parser.parserError) - NSLog(@"Error:\n%@", parser.parserError); - - parser.delegate = nil; - [parser release]; - - // Include delegate methods from YAJLParserDelegate - - (void)parserDidStartDictionary:(YAJLParser *)parser { } - - (void)parserDidEndDictionary:(YAJLParser *)parser { } - - - (void)parserDidStartArray:(YAJLParser *)parser { } - - (void)parserDidEndArray:(YAJLParser *)parser { } - - - (void)parser:(YAJLParser *)parser didMapKey:(NSString *)key { } - - (void)parser:(YAJLParser *)parser didAdd:(id)value { } - @endcode - - @subsection ParserOptions Parser Options - - There are options when parsing that can be specified with YAJLParser#initWithParserOptions:. - - - YAJLParserOptionsAllowComments: Allows comments in JSON - - YAJLParserOptionsCheckUTF8: Will verify UTF-8 - - YAJLParserOptionsStrictPrecision: Will force strict precision and return integer overflow error, if number is greater than long long. - - @subsection Example6 Parsing as data becomes available - - @code - YAJLParser *parser = [[[YAJLParser alloc] init] autorelease]; - parser.delegate = self; - - // A chunk of data comes... - YAJLParserStatus status = [parser parse:chunk1]; - // 'status' should be YAJLParserStatusInsufficientData, if its not finished - if (parser.parserError) - NSLog(@"Error:\n%@", parser.parserError); - - // Another chunk of data comes... - YAJLParserStatus status = [parser parse:chunk2]; - // 'status' should be YAJLParserStatusOK if its finished - if (parser.parserError) - NSLog(@"Error:\n%@", parser.parserError); - @endcode - - @subsection Example7 Document style parsing - - To use the document style, use YAJLDocument. Usage should be very similar to NSXMLDocument. - - @code - NSData *data = [NSData dataWithContentsOfFile:@"example.json"]; - NSError *error = nil; - YAJLDocument *document = [[YAJLDocument alloc] initWithData:data parserOptions:YAJLParserOptionsNone error:&error]; - // Access root element at document.root - NSLog(@"Root: %@", document.root); - [document release]; - @endcode - - @subsection Example8 Document style parsing as data becomes available - - @code - YAJLDocument *document = [[YAJLDocument alloc] init]; - document.delegate = self; - - NSError *error = nil; - [document parse:chunk1 error:error]; - [document parse:chunk2 error:error]; - - // You can access root element at document.root - NSLog(@"Root: %@", document.root); - [document release]; - - // Or via the YAJLDocumentDelegate delegate methods - - - (void)document:(YAJLDocument *)document didAddDictionary:(NSDictionary *)dict { } - - (void)document:(YAJLDocument *)document didAddArray:(NSArray *)array { } - - (void)document:(YAJLDocument *)document didAddObject:(id)object toArray:(NSArray *)array { } - - (void)document:(YAJLDocument *)document didSetObject:(id)object forKey:(id)key inDictionary:(NSDictionary *)dict { } - @endcode - - @subsection Example9 Load JSON from Bundle - - @code - id JSONValue = [[NSBundle mainBundle] yajl_JSONFromResource:@"kegs.json"]; - @endcode - - @section CustomizedEncoding Customized Encoding - - To implement JSON encodable value for custom objects or override for existing objects, implement - (id)JSON; - - For example: - - @code - @interface CustomObject : NSObject - @end - - @implementation CustomObject - - - (id)JSON { - return [NSArray arrayWithObject:[NSNumber numberWithInteger:1]]; - } - - @end - @endcode - - */ \ No newline at end of file diff --git a/Vendor/YAJL/Classes/YAJLDocument.h b/Vendor/YAJL/Classes/YAJLDocument.h deleted file mode 100644 index 7890665a71..0000000000 --- a/Vendor/YAJL/Classes/YAJLDocument.h +++ /dev/null @@ -1,196 +0,0 @@ -// -// YAJLDecoder.h -// YAJL -// -// Created by Gabriel Handford on 3/1/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - - -#include "YAJLParser.h" - -typedef enum { - YAJLDecoderCurrentTypeNone, - YAJLDecoderCurrentTypeArray, - YAJLDecoderCurrentTypeDict -} YAJLDecoderCurrentType; - -extern NSInteger YAJLDocumentStackCapacity; - -@class YAJLDocument; - -/*! - YAJLDocument delegate notified when objects are added. - */ -@protocol YAJLDocumentDelegate -@optional -/*! - Did add dictionary. - @param document Sender - @param dict Dictionary that was added - */ -- (void)document:(YAJLDocument *)document didAddDictionary:(NSDictionary *)dict; - -/*! - Did add array. - @param document Sender - @param array Array that was added - */ -- (void)document:(YAJLDocument *)document didAddArray:(NSArray *)array; - -/*! - Did add object to array. - @param document Sender - @param object Object added - @param array Array objct was added to - */ -- (void)document:(YAJLDocument *)document didAddObject:(id)object toArray:(NSArray *)array; - -/*! - Did set object for key on dictionary. - @param document Sender - @param object Object that was set - @param key Key - @param dict Dictionary object was set for key on - */ -- (void)document:(YAJLDocument *)document didSetObject:(id)object forKey:(id)key inDictionary:(NSDictionary *)dict; -@end - -/*! - JSON document interface. - - @code - NSData *data = [NSData dataWithContentsOfFile:@"example.json"]; - NSError *error = nil; - YAJLDocument *document = [[YAJLDocument alloc] initWithData:data parserOptions:YAJLParserOptionsNone error:&error]; - // Access root element at document.root - NSLog(@"Root: %@", document.root); - [document release]; - @endcode - - Example for streaming: - @code - YAJLDocument *document = [[YAJLDocument alloc] init]; - document.delegate = self; - - NSError *error = nil; - [document parse:chunk1 error:error]; - [document parse:chunk2 error:error]; - - // You can access root element at document.root - NSLog(@"Root: %@", document.root); - [document release]; - - // Or via the YAJLDocumentDelegate delegate methods - - - (void)document:(YAJLDocument *)document didAddDictionary:(NSDictionary *)dict { } - - (void)document:(YAJLDocument *)document didAddArray:(NSArray *)array { } - - (void)document:(YAJLDocument *)document didAddObject:(id)object toArray:(NSArray *)array { } - - (void)document:(YAJLDocument *)document didSetObject:(id)object forKey:(id)key inDictionary:(NSDictionary *)dict { } - @endcode - */ -@interface YAJLDocument : NSObject { - - id root_; // NSArray or NSDictionary - YAJLParser *parser_; - - // TODO(gabe): This should be __weak - id delegate_; - - __weak NSMutableDictionary *dict_; // weak; if map in progress, points to the current map - __weak NSMutableArray *array_; // weak; If array in progress, points the current array - __weak NSString *key_; // weak; If map in progress, points to current key - - NSMutableArray *stack_; - NSMutableArray *keyStack_; - - YAJLDecoderCurrentType currentType_; - - YAJLParserStatus parserStatus_; - -} - -@property (readonly, nonatomic) id root; //! The root element of the document, either NSArray or NSDictionary -@property (readonly, nonatomic) YAJLParserStatus parserStatus; //! The current status of parsing -@property (assign, nonatomic) id delegate; //! Delegate - -/*! - Create document from data. - @param data Data to parse - @param parserOptions Parse options - - YAJLParserOptionsNone: No options - - YAJLParserOptionsAllowComments: Javascript style comments will be allowed in the input (both /&asterisk; &asterisk;/ and //) - - YAJLParserOptionsCheckUTF8: Invalid UTF8 strings will cause a parse error - - YAJLParserOptionsStrictPrecision: If YES will force strict precision and return integer overflow error - @param error Error to set on failure - */ -- (id)initWithData:(NSData *)data parserOptions:(YAJLParserOptions)parserOptions error:(NSError **)error; - -/*! - Create document from data. - @param data Data to parse - @param parserOptions Parse options - - YAJLParserOptionsNone: No options - - YAJLParserOptionsAllowComments: Javascript style comments will be allowed in the input (both /&asterisk; &asterisk;/ and //) - - YAJLParserOptionsCheckUTF8: Invalid UTF8 strings will cause a parse error - - YAJLParserOptionsStrictPrecision: If YES will force strict precision and return integer overflow error - @param capacity Initial capacity for NSArray and NSDictionary objects (Defaults to 20) - @param error Error to set on failure - */ -- (id)initWithData:(NSData *)data parserOptions:(YAJLParserOptions)parserOptions capacity:(NSInteger)capacity error:(NSError **)error; - -/*! - Create empty document with parser options. - @param parserOptions Parse options - - YAJLParserOptionsNone: No options - - YAJLParserOptionsAllowComments: Javascript style comments will be allowed in the input (both /&asterisk; &asterisk;/ and //) - - YAJLParserOptionsCheckUTF8: Invalid UTF8 strings will cause a parse error - - YAJLParserOptionsStrictPrecision: If YES will force strict precision and return integer overflow error - */ -- (id)initWithParserOptions:(YAJLParserOptions)parserOptions; - -/*! - Create empty document with parser options. - @param parserOptions Parse options - - YAJLParserOptionsNone: No options - - YAJLParserOptionsAllowComments: Javascript style comments will be allowed in the input (both /&asterisk; &asterisk;/ and //) - - YAJLParserOptionsCheckUTF8: Invalid UTF8 strings will cause a parse error - - YAJLParserOptionsStrictPrecision: If YES will force strict precision and return integer overflow error - @param capacity Initial capacity for NSArray and NSDictionary objects (Defaults to 20) - */ -- (id)initWithParserOptions:(YAJLParserOptions)parserOptions capacity:(NSInteger)capacity; - -/*! - Parse data. - @param data Data to parse - @param error Out error to set on failure - @result Parser status - - YAJLParserStatusNone: No status - - YAJLParserStatusOK: Parsed OK - - YAJLParserStatusInsufficientData: There was insufficient data - - YAJLParserStatusError: Parser errored - */ -- (YAJLParserStatus)parse:(NSData *)data error:(NSError **)error; - -@end diff --git a/Vendor/YAJL/Classes/YAJLDocument.m b/Vendor/YAJL/Classes/YAJLDocument.m deleted file mode 100644 index 28f6b0324b..0000000000 --- a/Vendor/YAJL/Classes/YAJLDocument.m +++ /dev/null @@ -1,177 +0,0 @@ -// -// YAJLDocument.m -// YAJL -// -// Created by Gabriel Handford on 3/1/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - - -#import "YAJLDocument.h" - -@interface YAJLDocument () -- (void)_pop; -- (void)_popKey; -@end - -NSInteger YAJLDocumentStackCapacity = 20; - -@implementation YAJLDocument - -@synthesize root=root_, parserStatus=parserStatus_, delegate=delegate_; - -- (id)init { - return [self initWithParserOptions:0]; -} - -- (id)initWithParserOptions:(YAJLParserOptions)parserOptions { - return [self initWithParserOptions:parserOptions capacity:YAJLDocumentStackCapacity]; -} - -- (id)initWithParserOptions:(YAJLParserOptions)parserOptions capacity:(NSInteger)capacity { - if ((self = [super init])) { - stack_ = [[NSMutableArray alloc] initWithCapacity:YAJLDocumentStackCapacity]; - keyStack_ = [[NSMutableArray alloc] initWithCapacity:YAJLDocumentStackCapacity]; - parserStatus_ = YAJLParserStatusNone; - parser_ = [[YAJLParser alloc] initWithParserOptions:parserOptions]; - parser_.delegate = self; - } - return self; -} - -- (id)initWithData:(NSData *)data parserOptions:(YAJLParserOptions)parserOptions error:(NSError **)error { - return [self initWithData:data parserOptions:parserOptions capacity:YAJLDocumentStackCapacity error:error]; -} - -- (id)initWithData:(NSData *)data parserOptions:(YAJLParserOptions)parserOptions capacity:(NSInteger)capacity error:(NSError **)error { - if ((self = [self initWithParserOptions:parserOptions capacity:capacity])) { - [self parse:data error:error]; - } - return self; -} - -- (void)dealloc { - [stack_ release]; - [keyStack_ release]; - parser_.delegate = nil; - [parser_ release]; - [root_ release]; - [super dealloc]; -} - -- (YAJLParserStatus)parse:(NSData *)data error:(NSError **)error { - parserStatus_ = [parser_ parse:data]; - if (error) *error = [parser_ parserError]; - return parserStatus_; -} - -#pragma mark Delegates - -- (void)parser:(YAJLParser *)parser didAdd:(id)value { - switch(currentType_) { - case YAJLDecoderCurrentTypeArray: - [array_ addObject:value]; - if ([delegate_ respondsToSelector:@selector(document:didAddObject:toArray:)]) - [delegate_ document:self didAddObject:value toArray:array_]; - break; - case YAJLDecoderCurrentTypeDict: - NSParameterAssert(key_); - [dict_ setObject:value forKey:key_]; - if ([delegate_ respondsToSelector:@selector(document:didSetObject:forKey:inDictionary:)]) - [delegate_ document:self didSetObject:value forKey:key_ inDictionary:dict_]; - [self _popKey]; - break; - default: - break; - } -} - -- (void)parser:(YAJLParser *)parser didMapKey:(NSString *)key { - key_ = key; - [keyStack_ addObject:key_]; // Push -} - -- (void)_popKey { - key_ = nil; - [keyStack_ removeLastObject]; // Pop - if ([keyStack_ count] > 0) - key_ = [keyStack_ objectAtIndex:[keyStack_ count]-1]; -} - -- (void)parserDidStartDictionary:(YAJLParser *)parser { - NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:YAJLDocumentStackCapacity]; - if (!root_) root_ = [dict retain]; - [stack_ addObject:dict]; // Push - [dict release]; - dict_ = dict; - currentType_ = YAJLDecoderCurrentTypeDict; -} - -- (void)parserDidEndDictionary:(YAJLParser *)parser { - id value = [[stack_ objectAtIndex:[stack_ count]-1] retain]; - NSDictionary *dict = dict_; - [self _pop]; - [self parser:parser didAdd:value]; - [value release]; - if ([delegate_ respondsToSelector:@selector(document:didAddDictionary:)]) - [delegate_ document:self didAddDictionary:dict]; -} - -- (void)parserDidStartArray:(YAJLParser *)parser { - NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:YAJLDocumentStackCapacity]; - if (!root_) root_ = [array retain]; - [stack_ addObject:array]; // Push - [array release]; - array_ = array; - currentType_ = YAJLDecoderCurrentTypeArray; -} - -- (void)parserDidEndArray:(YAJLParser *)parser { - id value = [[stack_ objectAtIndex:[stack_ count]-1] retain]; - NSArray *array = array_; - [self _pop]; - [self parser:parser didAdd:value]; - [value release]; - if ([delegate_ respondsToSelector:@selector(document:didAddArray:)]) - [delegate_ document:self didAddArray:array]; -} - -- (void)_pop { - [stack_ removeLastObject]; - array_ = nil; - dict_ = nil; - currentType_ = YAJLDecoderCurrentTypeNone; - - id value = nil; - if ([stack_ count] > 0) value = [stack_ objectAtIndex:[stack_ count]-1]; - if ([value isKindOfClass:[NSArray class]]) { - array_ = (NSMutableArray *)value; - currentType_ = YAJLDecoderCurrentTypeArray; - } else if ([value isKindOfClass:[NSDictionary class]]) { - dict_ = (NSMutableDictionary *)value; - currentType_ = YAJLDecoderCurrentTypeDict; - } -} - -@end diff --git a/Vendor/YAJL/Classes/YAJLGen.h b/Vendor/YAJL/Classes/YAJLGen.h deleted file mode 100644 index ef8eed2ae0..0000000000 --- a/Vendor/YAJL/Classes/YAJLGen.h +++ /dev/null @@ -1,171 +0,0 @@ -// -// YAJLGen.h -// YAJL -// -// Created by Gabriel Handford on 7/19/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#include "yajl_gen.h" - - -extern NSString *const YAJLGenInvalidObjectException; //! Exception type if we encounter invalid object - -//! JSON generate options -enum YAJLGenOptions { - YAJLGenOptionsNone = 0, //!< No options - YAJLGenOptionsBeautify = 1 << 0, //!< Beautifiy JSON output - YAJLGenOptionsIgnoreUnknownTypes = 1 << 1, //!< Ignore unknown types (will use null value) - YAJLGenOptionsIncludeUnsupportedTypes = 1 << 2, //!< Handle non-JSON types (including NSDate, NSData, NSURL) -}; -typedef NSUInteger YAJLGenOptions; - -/*! - YAJL JSON string generator. - Supports the following types: - - NSArray - - NSDictionary - - NSString - - NSNumber - - NSNull - - We also support the following types (if using YAJLGenOptionsIncludeUnsupportedTypes option), - by converting to JSON supported types: - - NSDate: number representing number of milliseconds since (1970) epoch - - NSData: Base64 encoded string - - NSURL: URL (absolute) string - */ -@interface YAJLGen : NSObject { - yajl_gen gen_; - - YAJLGenOptions genOptions_; -} - -/*! - JSON generator with options. - @param genOptions Generate options - - YAJLGenOptionsNone: No options - - YAJLGenOptionsBeautify: Beautifiy JSON output - - YAJLGenOptionsIgnoreUnknownTypes: Ignore unknown types (will use null value) - - YAJLGenOptionsIncludeUnsupportedTypes: Handle non-JSON types (including NSDate, NSData, NSURL) - - @param indentString String for indentation - */ -- (id)initWithGenOptions:(YAJLGenOptions)genOptions indentString:(NSString *)indentString; - -/*! - Write JSON for object to buffer. - @param obj Supported or custom object - */ -- (void)object:(id)obj; - -/*! - Write null value to buffer. - */ -- (void)null; - -/*! - Write bool value to buffer. - @param b Output true or false - */ -- (void)bool:(BOOL)b; - -/*! - Write numeric value to buffer. - @param number Numeric value - */ -- (void)number:(NSNumber *)number; - -/*! - Write string value to buffer. - @param s String value - */ -- (void)string:(NSString *)s; - -/*! - Write dictionary start ('{') to buffer. - */ -- (void)startDictionary; - -/*! - Write dictionary end ('}') to buffer. - */ -- (void)endDictionary; - -/*! - Write array start ('[') to buffer. - */ -- (void)startArray; - -/*! - Write array end (']') to buffer. - */ -- (void)endArray; - -/*! - Clear JSON buffer. - */ -- (void)clear; - -/*! - Get current JSON buffer. - */ -- (NSString *)buffer; - -@end - - -/*! - Custom objects can support manual JSON encoding. - - @code - @interface CustomObject : NSObject - @end - - @implementation CustomObject - - - (id)JSON { - return [NSArray arrayWithObject:[NSNumber numberWithInteger:1]]; - } - - @end - @endcode - - And then: - - @code - CustomObject *customObject = [[CustomObject alloc] init]; - NSString *JSONString = [customObject yajl_JSON]; - // JSONString == "[1]"; - @endcode - */ -@protocol YAJLCoding - -/*! - Provide custom and/or encodable object to parse to JSON string. - @result Object encodable as JSON such as NSDictionary, NSArray, etc - */ -- (id)JSON; - -@end diff --git a/Vendor/YAJL/Classes/YAJLGen.m b/Vendor/YAJL/Classes/YAJLGen.m deleted file mode 100644 index bd9b0e08b8..0000000000 --- a/Vendor/YAJL/Classes/YAJLGen.m +++ /dev/null @@ -1,165 +0,0 @@ -// -// YAJLGen.m -// YAJL -// -// Created by Gabriel Handford on 7/19/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "YAJLGen.h" -#import "GTMBase64.h" - -NSString *const YAJLGenInvalidObjectException = @"YAJLGenInvalidObjectException"; - -@implementation YAJLGen - -- (id)init { - return [self initWithGenOptions:YAJLGenOptionsNone indentString:@""]; -} - -- (id)initWithGenOptions:(YAJLGenOptions)genOptions indentString:(NSString *)indentString { - if ((self = [super init])) { - genOptions_ = genOptions; - yajl_gen_config cfg = { - ((genOptions & YAJLGenOptionsBeautify) ? 1 : 0), - [indentString UTF8String] - }; - gen_ = yajl_gen_alloc(&cfg, NULL); - } - return self; -} - -- (void)dealloc { - if (gen_ != NULL) yajl_gen_free(gen_); - [super dealloc]; -} - -- (void)object:(id)obj { - if ([obj respondsToSelector:@selector(JSON)]) { - return [self object:[obj JSON]]; - } else if ([obj isKindOfClass:[NSArray class]]) { - [self startArray]; - for(id element in obj) - [self object:element]; - [self endArray]; - } else if ([obj isKindOfClass:[NSDictionary class]]) { - [self startDictionary]; - for(id key in obj) { - [self object:key]; - [self object:[obj objectForKey:key]]; - } - [self endDictionary]; - } else if ([obj isKindOfClass:[NSNumber class]]) { - if ('c' != *[obj objCType]) { - [self number:obj]; - } else { - [self bool:[obj boolValue]]; - } - } else if ([obj isKindOfClass:[NSString class]]) { - [self string:obj]; - } else if ([obj isKindOfClass:[NSNull class]]) { - [self null]; - } else { - - BOOL unknownType = NO; - if (genOptions_ & YAJLGenOptionsIncludeUnsupportedTypes) { - // Begin with support for non-JSON representable (PList) types - if ([obj isKindOfClass:[NSDate class]]) { - [self number:[NSNumber numberWithLongLong:round([obj timeIntervalSince1970] * 1000)]]; - } else if ([obj isKindOfClass:[NSData class]]) { - [self string:[YAJL_GTMBase64 stringByEncodingData:obj]]; - } else if ([obj isKindOfClass:[NSURL class]]) { - [self string:[obj absoluteString]]; - } else { - unknownType = YES; - } - } else { - unknownType = YES; - } - - // If we didn't handle special PList types - if (unknownType) { - if (!(genOptions_ & YAJLGenOptionsIgnoreUnknownTypes)) { - [NSException raise:YAJLGenInvalidObjectException format:@"Unknown object type: %@ (%@)", [obj class], obj]; - } else { - [self null]; // Use null value for unknown type if we are ignoring - } - } - } -} - -- (void)null { - yajl_gen_null(gen_); -} - -- (void)bool:(BOOL)b { - yajl_gen_bool(gen_, b); -} - -- (void)number:(NSNumber *)number { - NSString *s = [number stringValue]; - unsigned int length = [s lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - const char *c = [s UTF8String]; - yajl_gen_number(gen_, c, length); -} - -- (void)string:(NSString *)s { - unsigned int length = [s lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - const unsigned char *c = (const unsigned char *)[s UTF8String]; - yajl_gen_string(gen_, c, length); -} - -- (void)startDictionary { - yajl_gen_map_open(gen_); -} - -- (void)endDictionary { - yajl_gen_map_close(gen_); -} - -- (void)startArray { - yajl_gen_array_open(gen_); -} - -- (void)endArray { - yajl_gen_array_close(gen_); -} - -- (void)clear { - yajl_gen_clear(gen_); -} - -- (NSString *)buffer { - const unsigned char *buf; - unsigned int len; - yajl_gen_get_buf(gen_, &buf, &len); - NSString *s = [NSString stringWithUTF8String:(const char*)buf]; - return s; -} - -@end - - - - diff --git a/Vendor/YAJL/Classes/YAJLParser.h b/Vendor/YAJL/Classes/YAJLParser.h deleted file mode 100644 index 7db511c9fd..0000000000 --- a/Vendor/YAJL/Classes/YAJLParser.h +++ /dev/null @@ -1,181 +0,0 @@ -// -// YAJLParser.h -// YAJL -// -// Created by Gabriel Handford on 6/14/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - - -#include "yajl_parse.h" - - -extern NSString *const YAJLErrorDomain; //! Error domain for YAJL -extern NSString *const YAJLParserException; //! Generic parse exception -extern NSString *const YAJLParsingUnsupportedException; //! Parsing unsupported exception - -extern NSString *const YAJLParserValueKey; //! Key in NSError userInfo for value we errored on - -//! Parser error codes -enum YAJLParserErrorCode { - YAJLParserErrorCodeAllocError = -1000, //!< Alloc error - YAJLParserErrorCodeDoubleOverflow = -1001, //!< Double overflow - YAJLParserErrorCodeIntegerOverflow = -1002 //!< Integer overflow -}; -typedef NSInteger YAJLParserErrorCode; //! Parser error codes - -//! Parser options -enum YAJLParserOptions { - YAJLParserOptionsNone = 0, //!< No options - YAJLParserOptionsAllowComments = 1 << 0, //!< Javascript style comments will be allowed in the input (both /&asterisk; &asterisk;/ and //) - YAJLParserOptionsCheckUTF8 = 1 << 1, //!< Invalid UTF8 strings will cause a parse error - YAJLParserOptionsStrictPrecision = 1 << 2, //!< If YES will force strict precision and return integer overflow error -}; -typedef NSUInteger YAJLParserOptions; //! Parser options - -//! Parser status -enum { - YAJLParserStatusNone = 0, //!< No status - YAJLParserStatusOK = 1, //!< Parsed OK - YAJLParserStatusInsufficientData = 2, //!< There was insufficient data - YAJLParserStatusError = 3 //!< Parser errored -}; -typedef NSUInteger YAJLParserStatus; //!< Status of the last parse event - - -@class YAJLParser; - -/*! - Delegate for YAJL JSON parser. - */ -@protocol YAJLParserDelegate - -/*! - Parser did start dictionary. - @param parser Sender - */ -- (void)parserDidStartDictionary:(YAJLParser *)parser; - -/*! - Parser did end dictionary. - @param parser Sender - */ -- (void)parserDidEndDictionary:(YAJLParser *)parser; - -/*! - Parser did start array. - @param parser Sender - */ -- (void)parserDidStartArray:(YAJLParser *)parser; - -/*! - Parser did end array. - @param parser Sender - */ -- (void)parserDidEndArray:(YAJLParser *)parser; - -/*! - Parser did map key. - @param parser Sender - @param key Key that was mapped - */ -- (void)parser:(YAJLParser *)parser didMapKey:(NSString *)key; - -/*! - Did add value. - @param parser Sender - @param value Value of type NSNull, NSString or NSNumber - */ -- (void)parser:(YAJLParser *)parser didAdd:(id)value; - -@end - -/*! - JSON parser. - - @code - NSData *data = [NSData dataWithContentsOfFile:@"example.json"]; - - YAJLParser *parser = [[YAJLParser alloc] initWithParserOptions:YAJLParserOptionsAllowComments]; - parser.delegate = self; - [parser parse:data]; - if (parser.parserError) { - NSLog(@"Error:\n%@", parser.parserError); - } - - parser.delegate = nil; - [parser release]; - - // Include delegate methods from YAJLParserDelegate - - (void)parserDidStartDictionary:(YAJLParser *)parser { } - - (void)parserDidEndDictionary:(YAJLParser *)parser { } - - - (void)parserDidStartArray:(YAJLParser *)parser { } - - (void)parserDidEndArray:(YAJLParser *)parser { } - - - (void)parser:(YAJLParser *)parser didMapKey:(NSString *)key { } - - (void)parser:(YAJLParser *)parser didAdd:(id)value { } - @endcode - */ -@interface YAJLParser : NSObject { - - yajl_handle handle_; - - __weak id delegate_; // weak - - YAJLParserOptions parserOptions_; - - NSError *parserError_; -} - -@property (assign, nonatomic) __weak id delegate; -@property (readonly, retain, nonatomic) NSError *parserError; -@property (readonly, nonatomic) YAJLParserOptions parserOptions; - -/*! - Create parser with data and options. - @param parserOptions Parser options - - YAJLParserOptionsNone: No options - - YAJLParserOptionsAllowComments: Javascript style comments will be allowed in the input (both /&asterisk; &asterisk;/ and //) - - YAJLParserOptionsCheckUTF8: Invalid UTF8 strings will cause a parse error - - YAJLParserOptionsStrictPrecision: If YES will force strict precision and return integer overflow error - */ -- (id)initWithParserOptions:(YAJLParserOptions)parserOptions; - -/*! - Parse data. - - If streaming, you can call parse multiple times as long as - previous calls return YAJLParserStatusInsufficientData. - - @param data - @result Parser status - - YAJLParserStatusNone: No status - - YAJLParserStatusOK: Parsed OK - - YAJLParserStatusInsufficientData: There was insufficient data - - YAJLParserStatusError: Parser errored - */ -- (YAJLParserStatus)parse:(NSData *)data; - -@end diff --git a/Vendor/YAJL/Classes/YAJLParser.m b/Vendor/YAJL/Classes/YAJLParser.m deleted file mode 100644 index ec09c7f010..0000000000 --- a/Vendor/YAJL/Classes/YAJLParser.m +++ /dev/null @@ -1,284 +0,0 @@ -// -// YAJLParser.m -// YAJL -// -// Created by Gabriel Handford on 6/14/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - - -#import "YAJLParser.h" - -NSString *const YAJLErrorDomain = @"YAJLErrorDomain"; -NSString *const YAJLParserException = @"YAJLParserException"; -NSString *const YAJLParsingUnsupportedException = @"YAJLParsingUnsupportedException"; - -NSString *const YAJLParserValueKey = @"YAJLParserValueKey"; - -@interface YAJLParser () -@property (retain, nonatomic) NSError *parserError; -@end - -//! @internal - -@interface YAJLParser () -- (void)_add:(id)value; -- (void)_mapKey:(NSString *)key; - -- (void)_startDictionary; -- (void)_endDictionary; - -- (void)_startArray; -- (void)_endArray; - -- (NSError *)_errorForStatus:(NSInteger)code message:(NSString *)message value:(NSString *)value; -- (void)_cancelWithErrorForStatus:(NSInteger)code message:(NSString *)message value:(NSString *)value; -@end - -//! @endinternal - - -@implementation YAJLParser - -@synthesize parserError=parserError_, delegate=delegate_, parserOptions=parserOptions_; - -- (id)init { - return [self initWithParserOptions:0]; -} - -- (id)initWithParserOptions:(YAJLParserOptions)parserOptions { - if ((self = [super init])) { - parserOptions_ = parserOptions; - } - return self; -} - -- (void)dealloc { - if (handle_ != NULL) { - yajl_free(handle_); - handle_ = NULL; - } - - [parserError_ release]; - [super dealloc]; -} - -#pragma mark Error Helpers - -- (NSError *)_errorForStatus:(NSInteger)code message:(NSString *)message value:(NSString *)value { - NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObject:message forKey:NSLocalizedDescriptionKey]; - if (value) [userInfo setObject:value forKey:YAJLParserValueKey]; - return [NSError errorWithDomain:YAJLErrorDomain code:code userInfo:userInfo]; -} - -- (void)_cancelWithErrorForStatus:(NSInteger)code message:(NSString *)message value:(NSString *)value { - self.parserError = [self _errorForStatus:code message:message value:value]; -} - -#pragma mark YAJL Callbacks - -int yajl_null(void *ctx) { - [(id)ctx _add:[NSNull null]]; - return 1; -} - -int yajl_boolean(void *ctx, int boolVal) { - NSNumber *number = [[NSNumber alloc] initWithBool:(BOOL)boolVal]; - [(id)ctx _add:number]; - [number release]; - return 1; -} - -// Instead of using yajl_integer, and yajl_double we use yajl_number and parse -// as double (or long long); This is to be more compliant since Javascript numbers are represented -// as double precision floating point, though JSON spec doesn't define a max value -// and is up to the parser? - -//int yajl_integer(void *ctx, long integerVal) { -// [(id)ctx _add:[NSNumber numberWithLong:integerVal]]; -// return 1; -//} -// -//int yajl_double(void *ctx, double doubleVal) { -// [(id)ctx _add:[NSNumber numberWithDouble:doubleVal]]; -// return 1; -//} - -int ParseDouble(void *ctx, const char *buf, const char *numberVal, unsigned int numberLen) { - double d = strtod((char *)buf, NULL); - if ((d == HUGE_VAL || d == -HUGE_VAL) && errno == ERANGE) { - NSString *s = [[NSString alloc] initWithBytes:numberVal length:numberLen encoding:NSUTF8StringEncoding]; - [(id)ctx _cancelWithErrorForStatus:YAJLParserErrorCodeDoubleOverflow message:[NSString stringWithFormat:@"double overflow on '%@'", s] value:s]; - [s release]; - return 0; - } - NSNumber *number = [[NSNumber alloc] initWithDouble:d]; - [(id)ctx _add:number]; - [number release]; - return 1; -} - -int yajl_number(void *ctx, const char *numberVal, unsigned int numberLen) { - char buf[numberLen+1]; - memcpy(buf, numberVal, numberLen); - buf[numberLen] = 0; - - if (memchr(numberVal, '.', numberLen) || memchr(numberVal, 'e', numberLen) || memchr(numberVal, 'E', numberLen)) { - return ParseDouble(ctx, buf, numberVal, numberLen); - } else { - long long i = strtoll((const char *) buf, NULL, 10); - if ((i == LLONG_MIN || i == LLONG_MAX) && errno == ERANGE) { - if (([(id)ctx parserOptions] & YAJLParserOptionsStrictPrecision) == YAJLParserOptionsStrictPrecision) { - NSString *s = [[NSString alloc] initWithBytes:numberVal length:numberLen encoding:NSUTF8StringEncoding]; - [(id)ctx _cancelWithErrorForStatus:YAJLParserErrorCodeIntegerOverflow message:[NSString stringWithFormat:@"integer overflow on '%@'", s] value:s]; - [s release]; - return 0; - } else { - // If we integer overflow lets try double precision for HUGE_VAL > double > LLONG_MAX - return ParseDouble(ctx, buf, numberVal, numberLen); - } - } - NSNumber *number = [[NSNumber alloc] initWithLongLong:i]; - [(id)ctx _add:number]; - [number release]; - } - - return 1; -} - -int yajl_string(void *ctx, const unsigned char *stringVal, unsigned int stringLen) { - NSString *s = [[NSString alloc] initWithBytes:stringVal length:stringLen encoding:NSUTF8StringEncoding]; - [(id)ctx _add:s]; - [s release]; - return 1; -} - -int yajl_map_key(void *ctx, const unsigned char *stringVal, unsigned int stringLen) { - NSString *s = [[NSString alloc] initWithBytes:stringVal length:stringLen encoding:NSUTF8StringEncoding]; - [(id)ctx _mapKey:s]; - [s release]; - return 1; -} - -int yajl_start_map(void *ctx) { - [(id)ctx _startDictionary]; - return 1; -} - -int yajl_end_map(void *ctx) { - [(id)ctx _endDictionary]; - return 1; -} - -int yajl_start_array(void *ctx) { - [(id)ctx _startArray]; - return 1; -} - -int yajl_end_array(void *ctx) { - [(id)ctx _endArray]; - return 1; -} - -static yajl_callbacks callbacks = { -yajl_null, -yajl_boolean, -NULL, // yajl_integer (using yajl_number) -NULL, // yajl_double (using yajl_number) -yajl_number, -yajl_string, -yajl_start_map, -yajl_map_key, -yajl_end_map, -yajl_start_array, -yajl_end_array -}; - -#pragma mark - - -//! @internal - -- (void)_add:(id)value { - [delegate_ parser:self didAdd:value]; -} - -- (void)_mapKey:(NSString *)key { - [delegate_ parser:self didMapKey:key]; -} - -- (void)_startDictionary { - [delegate_ parserDidStartDictionary:self]; -} - -- (void)_endDictionary { - [delegate_ parserDidEndDictionary:self]; -} - -- (void)_startArray { - [delegate_ parserDidStartArray:self]; -} - -- (void)_endArray { - [delegate_ parserDidEndArray:self]; -} - -//! @endinternal - -- (YAJLParserStatus)parse:(NSData *)data { - if (!handle_) { - yajl_parser_config cfg = { - ((parserOptions_ & YAJLParserOptionsAllowComments) ? 1 : 0), // allowComments: if nonzero, javascript style comments will be allowed in the input (both /* */ and //) - ((parserOptions_ & YAJLParserOptionsCheckUTF8) ? 1 : 0) // checkUTF8: if nonzero, invalid UTF8 strings will cause a parse error - }; - - handle_ = yajl_alloc(&callbacks, &cfg, NULL, self); - if (!handle_) { - self.parserError = [self _errorForStatus:YAJLParserErrorCodeAllocError message:@"Unable to allocate YAJL handle" value:nil]; - return YAJLParserStatusError; - } - } - - yajl_status status = yajl_parse(handle_, [data bytes], [data length]); - if (status == yajl_status_client_canceled) { - // We cancelled because we encountered an error here in the client; - // and parserError should be already set - NSAssert(self.parserError, @"Client cancelled, but we have no parserError set"); - return YAJLParserStatusError; - } else if (status == yajl_status_error) { - unsigned char *errorMessage = yajl_get_error(handle_, 1, [data bytes], [data length]); - NSString *errorString = [NSString stringWithUTF8String:(char *)errorMessage]; - self.parserError = [self _errorForStatus:status message:errorString value:nil]; - yajl_free_error(handle_, errorMessage); - return YAJLParserStatusError; - } else if (status == yajl_status_insufficient_data) { - return YAJLParserStatusInsufficientData; - } else if (status == yajl_status_ok) { - return YAJLParserStatusOK; - } else { - self.parserError = [self _errorForStatus:status message:[NSString stringWithFormat:@"Unexpected status %d", status] value:nil]; - return YAJLParserStatusError; - } -} - -@end diff --git a/Vendor/YAJL/LICENSE b/Vendor/YAJL/LICENSE deleted file mode 100644 index c0dbc5f8e7..0000000000 --- a/Vendor/YAJL/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -// -// Created by Gabriel Handford on 3/1/09. -// Copyright 2009. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// \ No newline at end of file diff --git a/Vendor/YAJL/Libraries/GHKit/GHNSBundle+Utils.h b/Vendor/YAJL/Libraries/GHKit/GHNSBundle+Utils.h deleted file mode 100644 index 6178c13d21..0000000000 --- a/Vendor/YAJL/Libraries/GHKit/GHNSBundle+Utils.h +++ /dev/null @@ -1,32 +0,0 @@ -// -// GHNSBundle+Utils.h -// GHKit -// -// Created by Gabriel Handford on 4/27/09. -// Copyright 2009. All rights reserved. -// - -@interface NSBundle (YAJL_GHUtils) - -/*! - Load data from resource. - @param resource Name of resource - @result NSData - */ -- (NSData *)yajl_gh_loadDataFromResource:(NSString *)resource; - -/*! - Load string data from resource. - @param resource Name of resource - @result NSString - */ -- (NSString *)yajl_gh_loadStringDataFromResource:(NSString *)resource; - -/*! - Get URL for resource. - @param resource Name of resource - @result URL to resource - */ -- (NSURL *)yajl_gh_URLForResource:(NSString *)resource; - -@end diff --git a/Vendor/YAJL/Libraries/GHKit/GHNSBundle+Utils.m b/Vendor/YAJL/Libraries/GHKit/GHNSBundle+Utils.m deleted file mode 100644 index 871c6405ff..0000000000 --- a/Vendor/YAJL/Libraries/GHKit/GHNSBundle+Utils.m +++ /dev/null @@ -1,33 +0,0 @@ -// -// GHNSBundle+Utils.m -// GHKit -// -// Created by Gabriel Handford on 4/27/09. -// Copyright 2009. All rights reserved. -// - -#import "GHNSBundle+Utils.h" - -@implementation NSBundle (YAJL_GHUtils) - -- (NSData *)yajl_gh_loadDataFromResource:(NSString *)resource { - NSParameterAssert(resource); - NSString *resourcePath = [self pathForResource:[resource stringByDeletingPathExtension] ofType:[resource pathExtension]]; - if (!resourcePath) [NSException raise:NSInvalidArgumentException format:@"Resource not found: %@", resource]; - NSError *error = nil; - NSData *data = [NSData dataWithContentsOfFile:resourcePath options:0 error:&error]; - if (error) [NSException raise:NSInvalidArgumentException format:@"Error loading resource at path (%@): %@", resourcePath, error]; - return data; -} - -- (NSString *)yajl_gh_loadStringDataFromResource:(NSString *)resource { - return [[[NSString alloc] initWithData:[self yajl_gh_loadDataFromResource:resource] encoding:NSUTF8StringEncoding] autorelease]; -} - -- (NSURL *)yajl_gh_URLForResource:(NSString *)resource { - NSParameterAssert(resource); - NSString *resourcePath = [self pathForResource:[resource stringByDeletingPathExtension] ofType:[resource pathExtension]]; - return resourcePath ? [NSURL fileURLWithPath:resourcePath] : nil; -} - -@end diff --git a/Vendor/YAJL/Libraries/GTM/GTMBase64.h b/Vendor/YAJL/Libraries/GTM/GTMBase64.h deleted file mode 100644 index a3561e5390..0000000000 --- a/Vendor/YAJL/Libraries/GTM/GTMBase64.h +++ /dev/null @@ -1,195 +0,0 @@ -// -// GTMBase64.h -// -// Copyright 2006-2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not -// use this file except in compliance with the License. You may obtain a copy -// of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations under -// the License. -// - -#import - -// Give ourselves a consistent way to do inlines. Apple's macros even use -// a few different actual definitions, so we're based off of the foundation -// one. -#if !defined(GTM_INLINE) -#if defined (__GNUC__) && (__GNUC__ == 4) -#define GTM_INLINE static __inline__ __attribute__((always_inline)) -#else -#define GTM_INLINE static __inline__ -#endif -#endif - -#define _GTMDevAssert(condition, ...) do { } while (0) - -// GTMBase64 -// -/// Helper for handling Base64 and WebSafeBase64 encodings -// -/// The webSafe methods use different character set and also the results aren't -/// always padded to a multiple of 4 characters. This is done so the resulting -/// data can be used in urls and url query arguments without needing any -/// encoding. You must use the webSafe* methods together, the data does not -/// interop with the RFC methods. -// -@interface YAJL_GTMBase64 : NSObject - -// -// Standard Base64 (RFC) handling -// - -// encodeData: -// -/// Base64 encodes contents of the NSData object. -// -/// Returns: -/// A new autoreleased NSData with the encoded payload. nil for any error. -// -+(NSData *)encodeData:(NSData *)data; - -// decodeData: -// -/// Base64 decodes contents of the NSData object. -// -/// Returns: -/// A new autoreleased NSData with the decoded payload. nil for any error. -// -+(NSData *)decodeData:(NSData *)data; - -// encodeBytes:length: -// -/// Base64 encodes the data pointed at by |bytes|. -// -/// Returns: -/// A new autoreleased NSData with the encoded payload. nil for any error. -// -+(NSData *)encodeBytes:(const void *)bytes length:(NSUInteger)length; - -// decodeBytes:length: -// -/// Base64 decodes the data pointed at by |bytes|. -// -/// Returns: -/// A new autoreleased NSData with the encoded payload. nil for any error. -// -+(NSData *)decodeBytes:(const void *)bytes length:(NSUInteger)length; - -// stringByEncodingData: -// -/// Base64 encodes contents of the NSData object. -// -/// Returns: -/// A new autoreleased NSString with the encoded payload. nil for any error. -// -+(NSString *)stringByEncodingData:(NSData *)data; - -// stringByEncodingBytes:length: -// -/// Base64 encodes the data pointed at by |bytes|. -// -/// Returns: -/// A new autoreleased NSString with the encoded payload. nil for any error. -// -+(NSString *)stringByEncodingBytes:(const void *)bytes length:(NSUInteger)length; - -// decodeString: -// -/// Base64 decodes contents of the NSString. -// -/// Returns: -/// A new autoreleased NSData with the decoded payload. nil for any error. -// -+(NSData *)decodeString:(NSString *)string; - -// -// Modified Base64 encoding so the results can go onto urls. -// -// The changes are in the characters generated and also allows the result to -// not be padded to a multiple of 4. -// Must use the matching call to encode/decode, won't interop with the -// RFC versions. -// - -// webSafeEncodeData:padded: -// -/// WebSafe Base64 encodes contents of the NSData object. If |padded| is YES -/// then padding characters are added so the result length is a multiple of 4. -// -/// Returns: -/// A new autoreleased NSData with the encoded payload. nil for any error. -// -+(NSData *)webSafeEncodeData:(NSData *)data - padded:(BOOL)padded; - -// webSafeDecodeData: -// -/// WebSafe Base64 decodes contents of the NSData object. -// -/// Returns: -/// A new autoreleased NSData with the decoded payload. nil for any error. -// -+(NSData *)webSafeDecodeData:(NSData *)data; - -// webSafeEncodeBytes:length:padded: -// -/// WebSafe Base64 encodes the data pointed at by |bytes|. If |padded| is YES -/// then padding characters are added so the result length is a multiple of 4. -// -/// Returns: -/// A new autoreleased NSData with the encoded payload. nil for any error. -// -+(NSData *)webSafeEncodeBytes:(const void *)bytes - length:(NSUInteger)length - padded:(BOOL)padded; - -// webSafeDecodeBytes:length: -// -/// WebSafe Base64 decodes the data pointed at by |bytes|. -// -/// Returns: -/// A new autoreleased NSData with the encoded payload. nil for any error. -// -+(NSData *)webSafeDecodeBytes:(const void *)bytes length:(NSUInteger)length; - -// stringByWebSafeEncodingData:padded: -// -/// WebSafe Base64 encodes contents of the NSData object. If |padded| is YES -/// then padding characters are added so the result length is a multiple of 4. -// -/// Returns: -/// A new autoreleased NSString with the encoded payload. nil for any error. -// -+(NSString *)stringByWebSafeEncodingData:(NSData *)data - padded:(BOOL)padded; - -// stringByWebSafeEncodingBytes:length:padded: -// -/// WebSafe Base64 encodes the data pointed at by |bytes|. If |padded| is YES -/// then padding characters are added so the result length is a multiple of 4. -// -/// Returns: -/// A new autoreleased NSString with the encoded payload. nil for any error. -// -+(NSString *)stringByWebSafeEncodingBytes:(const void *)bytes - length:(NSUInteger)length - padded:(BOOL)padded; - -// webSafeDecodeString: -// -/// WebSafe Base64 decodes contents of the NSString. -// -/// Returns: -/// A new autoreleased NSData with the decoded payload. nil for any error. -// -+(NSData *)webSafeDecodeString:(NSString *)string; - -@end diff --git a/Vendor/YAJL/Libraries/GTM/GTMBase64.m b/Vendor/YAJL/Libraries/GTM/GTMBase64.m deleted file mode 100644 index 9b7a0cdc9f..0000000000 --- a/Vendor/YAJL/Libraries/GTM/GTMBase64.m +++ /dev/null @@ -1,693 +0,0 @@ -// -// GTMBase64.m -// -// Copyright 2006-2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); you may not -// use this file except in compliance with the License. You may obtain a copy -// of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -// License for the specific language governing permissions and limitations under -// the License. -// - -#import "GTMBase64.h" - -static const char *kBase64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char *kWebSafeBase64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; -static const char kBase64PaddingChar = '='; -static const char kBase64InvalidChar = 99; - -static const char kBase64DecodeChars[] = { - // This array was generated by the following code: - // #include - // #include - // #include - // main() - // { - // static const char Base64[] = - // "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - // char *pos; - // int idx, i, j; - // printf(" "); - // for (i = 0; i < 255; i += 8) { - // for (j = i; j < i + 8; j++) { - // pos = strchr(Base64, j); - // if ((pos == NULL) || (j == 0)) - // idx = 99; - // else - // idx = pos - Base64; - // if (idx == 99) - // printf(" %2d, ", idx); - // else - // printf(" %2d/*%c*/,", idx, j); - // } - // printf("\n "); - // } - // } - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 62/*+*/, 99, 99, 99, 63/*/ */, - 52/*0*/, 53/*1*/, 54/*2*/, 55/*3*/, 56/*4*/, 57/*5*/, 58/*6*/, 59/*7*/, - 60/*8*/, 61/*9*/, 99, 99, 99, 99, 99, 99, - 99, 0/*A*/, 1/*B*/, 2/*C*/, 3/*D*/, 4/*E*/, 5/*F*/, 6/*G*/, - 7/*H*/, 8/*I*/, 9/*J*/, 10/*K*/, 11/*L*/, 12/*M*/, 13/*N*/, 14/*O*/, - 15/*P*/, 16/*Q*/, 17/*R*/, 18/*S*/, 19/*T*/, 20/*U*/, 21/*V*/, 22/*W*/, - 23/*X*/, 24/*Y*/, 25/*Z*/, 99, 99, 99, 99, 99, - 99, 26/*a*/, 27/*b*/, 28/*c*/, 29/*d*/, 30/*e*/, 31/*f*/, 32/*g*/, - 33/*h*/, 34/*i*/, 35/*j*/, 36/*k*/, 37/*l*/, 38/*m*/, 39/*n*/, 40/*o*/, - 41/*p*/, 42/*q*/, 43/*r*/, 44/*s*/, 45/*t*/, 46/*u*/, 47/*v*/, 48/*w*/, - 49/*x*/, 50/*y*/, 51/*z*/, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 -}; - -static const char kWebSafeBase64DecodeChars[] = { - // This array was generated by the following code: - // #include - // #include - // #include - // main() - // { - // static const char Base64[] = - // "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; - // char *pos; - // int idx, i, j; - // printf(" "); - // for (i = 0; i < 255; i += 8) { - // for (j = i; j < i + 8; j++) { - // pos = strchr(Base64, j); - // if ((pos == NULL) || (j == 0)) - // idx = 99; - // else - // idx = pos - Base64; - // if (idx == 99) - // printf(" %2d, ", idx); - // else - // printf(" %2d/*%c*/,", idx, j); - // } - // printf("\n "); - // } - // } - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 62/*-*/, 99, 99, - 52/*0*/, 53/*1*/, 54/*2*/, 55/*3*/, 56/*4*/, 57/*5*/, 58/*6*/, 59/*7*/, - 60/*8*/, 61/*9*/, 99, 99, 99, 99, 99, 99, - 99, 0/*A*/, 1/*B*/, 2/*C*/, 3/*D*/, 4/*E*/, 5/*F*/, 6/*G*/, - 7/*H*/, 8/*I*/, 9/*J*/, 10/*K*/, 11/*L*/, 12/*M*/, 13/*N*/, 14/*O*/, - 15/*P*/, 16/*Q*/, 17/*R*/, 18/*S*/, 19/*T*/, 20/*U*/, 21/*V*/, 22/*W*/, - 23/*X*/, 24/*Y*/, 25/*Z*/, 99, 99, 99, 99, 63/*_*/, - 99, 26/*a*/, 27/*b*/, 28/*c*/, 29/*d*/, 30/*e*/, 31/*f*/, 32/*g*/, - 33/*h*/, 34/*i*/, 35/*j*/, 36/*k*/, 37/*l*/, 38/*m*/, 39/*n*/, 40/*o*/, - 41/*p*/, 42/*q*/, 43/*r*/, 44/*s*/, 45/*t*/, 46/*u*/, 47/*v*/, 48/*w*/, - 49/*x*/, 50/*y*/, 51/*z*/, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 -}; - - -// Tests a character to see if it's a whitespace character. -// -// Returns: -// YES if the character is a whitespace character. -// NO if the character is not a whitespace character. -// -GTM_INLINE BOOL IsSpace(unsigned char c) { - // we use our own mapping here because we don't want anything w/ locale - // support. - static BOOL kSpaces[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, // 0-9 - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 10-19 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20-29 - 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 30-39 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40-49 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 50-59 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60-69 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 70-79 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80-89 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 90-99 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 100-109 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 110-119 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 120-129 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 130-139 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 140-149 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 150-159 - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 160-169 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 170-179 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 180-189 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 190-199 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 200-209 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 210-219 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 220-229 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 230-239 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 240-249 - 0, 0, 0, 0, 0, 1, // 250-255 - }; - return kSpaces[c]; -} - -// Calculate how long the data will be once it's base64 encoded. -// -// Returns: -// The guessed encoded length for a source length -// -GTM_INLINE NSUInteger CalcEncodedLength(NSUInteger srcLen, BOOL padded) { - NSUInteger intermediate_result = 8 * srcLen + 5; - NSUInteger len = intermediate_result / 6; - if (padded) { - len = ((len + 3) / 4) * 4; - } - return len; -} - -// Tries to calculate how long the data will be once it's base64 decoded. -// Unlike the above, this is always an upperbound, since the source data -// could have spaces and might end with the padding characters on them. -// -// Returns: -// The guessed decoded length for a source length -// -GTM_INLINE NSUInteger GuessDecodedLength(NSUInteger srcLen) { - return (srcLen + 3) / 4 * 3; -} - - -@interface YAJL_GTMBase64 (PrivateMethods) - -+(NSData *)baseEncode:(const void *)bytes - length:(NSUInteger)length - charset:(const char *)charset - padded:(BOOL)padded; - -+(NSData *)baseDecode:(const void *)bytes - length:(NSUInteger)length - charset:(const char*)charset - requirePadding:(BOOL)requirePadding; - -+(NSUInteger)baseEncode:(const char *)srcBytes - srcLen:(NSUInteger)srcLen - destBytes:(char *)destBytes - destLen:(NSUInteger)destLen - charset:(const char *)charset - padded:(BOOL)padded; - -+(NSUInteger)baseDecode:(const char *)srcBytes - srcLen:(NSUInteger)srcLen - destBytes:(char *)destBytes - destLen:(NSUInteger)destLen - charset:(const char *)charset - requirePadding:(BOOL)requirePadding; - -@end - - -@implementation YAJL_GTMBase64 - -// -// Standard Base64 (RFC) handling -// - -+(NSData *)encodeData:(NSData *)data { - return [self baseEncode:[data bytes] - length:[data length] - charset:kBase64EncodeChars - padded:YES]; -} - -+(NSData *)decodeData:(NSData *)data { - return [self baseDecode:[data bytes] - length:[data length] - charset:kBase64DecodeChars - requirePadding:YES]; -} - -+(NSData *)encodeBytes:(const void *)bytes length:(NSUInteger)length { - return [self baseEncode:bytes - length:length - charset:kBase64EncodeChars - padded:YES]; -} - -+(NSData *)decodeBytes:(const void *)bytes length:(NSUInteger)length { - return [self baseDecode:bytes - length:length - charset:kBase64DecodeChars - requirePadding:YES]; -} - -+(NSString *)stringByEncodingData:(NSData *)data { - NSString *result = nil; - NSData *converted = [self baseEncode:[data bytes] - length:[data length] - charset:kBase64EncodeChars - padded:YES]; - if (converted) { - result = [[[NSString alloc] initWithData:converted - encoding:NSASCIIStringEncoding] autorelease]; - } - return result; -} - -+(NSString *)stringByEncodingBytes:(const void *)bytes length:(NSUInteger)length { - NSString *result = nil; - NSData *converted = [self baseEncode:bytes - length:length - charset:kBase64EncodeChars - padded:YES]; - if (converted) { - result = [[[NSString alloc] initWithData:converted - encoding:NSASCIIStringEncoding] autorelease]; - } - return result; -} - -+(NSData *)decodeString:(NSString *)string { - NSData *result = nil; - NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding]; - if (data) { - result = [self baseDecode:[data bytes] - length:[data length] - charset:kBase64DecodeChars - requirePadding:YES]; - } - return result; -} - -// -// Modified Base64 encoding so the results can go onto urls. -// -// The changes are in the characters generated and also the result isn't -// padded to a multiple of 4. -// Must use the matching call to encode/decode, won't interop with the -// RFC versions. -// - -+(NSData *)webSafeEncodeData:(NSData *)data - padded:(BOOL)padded { - return [self baseEncode:[data bytes] - length:[data length] - charset:kWebSafeBase64EncodeChars - padded:padded]; -} - -+(NSData *)webSafeDecodeData:(NSData *)data { - return [self baseDecode:[data bytes] - length:[data length] - charset:kWebSafeBase64DecodeChars - requirePadding:NO]; -} - -+(NSData *)webSafeEncodeBytes:(const void *)bytes - length:(NSUInteger)length - padded:(BOOL)padded { - return [self baseEncode:bytes - length:length - charset:kWebSafeBase64EncodeChars - padded:padded]; -} - -+(NSData *)webSafeDecodeBytes:(const void *)bytes length:(NSUInteger)length { - return [self baseDecode:bytes - length:length - charset:kWebSafeBase64DecodeChars - requirePadding:NO]; -} - -+(NSString *)stringByWebSafeEncodingData:(NSData *)data - padded:(BOOL)padded { - NSString *result = nil; - NSData *converted = [self baseEncode:[data bytes] - length:[data length] - charset:kWebSafeBase64EncodeChars - padded:padded]; - if (converted) { - result = [[[NSString alloc] initWithData:converted - encoding:NSASCIIStringEncoding] autorelease]; - } - return result; -} - -+(NSString *)stringByWebSafeEncodingBytes:(const void *)bytes - length:(NSUInteger)length - padded:(BOOL)padded { - NSString *result = nil; - NSData *converted = [self baseEncode:bytes - length:length - charset:kWebSafeBase64EncodeChars - padded:padded]; - if (converted) { - result = [[[NSString alloc] initWithData:converted - encoding:NSASCIIStringEncoding] autorelease]; - } - return result; -} - -+(NSData *)webSafeDecodeString:(NSString *)string { - NSData *result = nil; - NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding]; - if (data) { - result = [self baseDecode:[data bytes] - length:[data length] - charset:kWebSafeBase64DecodeChars - requirePadding:NO]; - } - return result; -} - -@end - -@implementation YAJL_GTMBase64 (PrivateMethods) - -// -// baseEncode:length:charset:padded: -// -// Does the common lifting of creating the dest NSData. it creates & sizes the -// data for the results. |charset| is the characters to use for the encoding -// of the data. |padding| controls if the encoded data should be padded to a -// multiple of 4. -// -// Returns: -// an autorelease NSData with the encoded data, nil if any error. -// -+(NSData *)baseEncode:(const void *)bytes - length:(NSUInteger)length - charset:(const char *)charset - padded:(BOOL)padded { - // how big could it be? - NSUInteger maxLength = CalcEncodedLength(length, padded); - // make space - NSMutableData *result = [NSMutableData data]; - [result setLength:maxLength]; - // do it - NSUInteger finalLength = [self baseEncode:bytes - srcLen:length - destBytes:[result mutableBytes] - destLen:[result length] - charset:charset - padded:padded]; - if (finalLength) { - _GTMDevAssert(finalLength == maxLength, @"how did we calc the length wrong?"); - } else { - // shouldn't happen, this means we ran out of space - result = nil; - } - return result; -} - -// -// baseDecode:length:charset:requirePadding: -// -// Does the common lifting of creating the dest NSData. it creates & sizes the -// data for the results. |charset| is the characters to use for the decoding -// of the data. -// -// Returns: -// an autorelease NSData with the decoded data, nil if any error. -// -// -+(NSData *)baseDecode:(const void *)bytes - length:(NSUInteger)length - charset:(const char *)charset - requirePadding:(BOOL)requirePadding { - // could try to calculate what it will end up as - NSUInteger maxLength = GuessDecodedLength(length); - // make space - NSMutableData *result = [NSMutableData data]; - [result setLength:maxLength]; - // do it - NSUInteger finalLength = [self baseDecode:bytes - srcLen:length - destBytes:[result mutableBytes] - destLen:[result length] - charset:charset - requirePadding:requirePadding]; - if (finalLength) { - if (finalLength != maxLength) { - // resize down to how big it was - [result setLength:finalLength]; - } - } else { - // either an error in the args, or we ran out of space - result = nil; - } - return result; -} - -// -// baseEncode:srcLen:destBytes:destLen:charset:padded: -// -// Encodes the buffer into the larger. returns the length of the encoded -// data, or zero for an error. -// |charset| is the characters to use for the encoding -// |padded| tells if the result should be padded to a multiple of 4. -// -// Returns: -// the length of the encoded data. zero if any error. -// -+(NSUInteger)baseEncode:(const char *)srcBytes - srcLen:(NSUInteger)srcLen - destBytes:(char *)destBytes - destLen:(NSUInteger)destLen - charset:(const char *)charset - padded:(BOOL)padded { - if (!srcLen || !destLen || !srcBytes || !destBytes) { - return 0; - } - - char *curDest = destBytes; - const unsigned char *curSrc = (const unsigned char *)(srcBytes); - - // Three bytes of data encodes to four characters of cyphertext. - // So we can pump through three-byte chunks atomically. - while (srcLen > 2) { - // space? - _GTMDevAssert(destLen >= 4, @"our calc for encoded length was wrong"); - curDest[0] = charset[curSrc[0] >> 2]; - curDest[1] = charset[((curSrc[0] & 0x03) << 4) + (curSrc[1] >> 4)]; - curDest[2] = charset[((curSrc[1] & 0x0f) << 2) + (curSrc[2] >> 6)]; - curDest[3] = charset[curSrc[2] & 0x3f]; - - curDest += 4; - curSrc += 3; - srcLen -= 3; - destLen -= 4; - } - - // now deal with the tail (<=2 bytes) - switch (srcLen) { - case 0: - // Nothing left; nothing more to do. - break; - case 1: - // One byte left: this encodes to two characters, and (optionally) - // two pad characters to round out the four-character cypherblock. - _GTMDevAssert(destLen >= 2, @"our calc for encoded length was wrong"); - curDest[0] = charset[curSrc[0] >> 2]; - curDest[1] = charset[(curSrc[0] & 0x03) << 4]; - curDest += 2; - destLen -= 2; - if (padded) { - _GTMDevAssert(destLen >= 2, @"our calc for encoded length was wrong"); - curDest[0] = kBase64PaddingChar; - curDest[1] = kBase64PaddingChar; - curDest += 2; - } - break; - case 2: - // Two bytes left: this encodes to three characters, and (optionally) - // one pad character to round out the four-character cypherblock. - _GTMDevAssert(destLen >= 3, @"our calc for encoded length was wrong"); - curDest[0] = charset[curSrc[0] >> 2]; - curDest[1] = charset[((curSrc[0] & 0x03) << 4) + (curSrc[1] >> 4)]; - curDest[2] = charset[(curSrc[1] & 0x0f) << 2]; - curDest += 3; - destLen -= 3; - if (padded) { - _GTMDevAssert(destLen >= 1, @"our calc for encoded length was wrong"); - curDest[0] = kBase64PaddingChar; - curDest += 1; - } - break; - } - // return the length - return (curDest - destBytes); -} - -// -// baseDecode:srcLen:destBytes:destLen:charset:requirePadding: -// -// Decodes the buffer into the larger. returns the length of the decoded -// data, or zero for an error. -// |charset| is the character decoding buffer to use -// -// Returns: -// the length of the encoded data. zero if any error. -// -+(NSUInteger)baseDecode:(const char *)srcBytes - srcLen:(NSUInteger)srcLen - destBytes:(char *)destBytes - destLen:(NSUInteger)destLen - charset:(const char *)charset - requirePadding:(BOOL)requirePadding { - if (!srcLen || !destLen || !srcBytes || !destBytes) { - return 0; - } - - int decode; - NSUInteger destIndex = 0; - int state = 0; - char ch = 0; - while (srcLen-- && (ch = *srcBytes++) != 0) { - if (IsSpace(ch)) // Skip whitespace - continue; - - if (ch == kBase64PaddingChar) - break; - - decode = charset[(unsigned int)ch]; - if (decode == kBase64InvalidChar) - return 0; - - // Four cyphertext characters decode to three bytes. - // Therefore we can be in one of four states. - switch (state) { - case 0: - // We're at the beginning of a four-character cyphertext block. - // This sets the high six bits of the first byte of the - // plaintext block. - _GTMDevAssert(destIndex < destLen, @"our calc for decoded length was wrong"); - destBytes[destIndex] = decode << 2; - state = 1; - break; - case 1: - // We're one character into a four-character cyphertext block. - // This sets the low two bits of the first plaintext byte, - // and the high four bits of the second plaintext byte. - _GTMDevAssert((destIndex+1) < destLen, @"our calc for decoded length was wrong"); - destBytes[destIndex] |= decode >> 4; - destBytes[destIndex+1] = (decode & 0x0f) << 4; - destIndex++; - state = 2; - break; - case 2: - // We're two characters into a four-character cyphertext block. - // This sets the low four bits of the second plaintext - // byte, and the high two bits of the third plaintext byte. - // However, if this is the end of data, and those two - // bits are zero, it could be that those two bits are - // leftovers from the encoding of data that had a length - // of two mod three. - _GTMDevAssert((destIndex+1) < destLen, @"our calc for decoded length was wrong"); - destBytes[destIndex] |= decode >> 2; - destBytes[destIndex+1] = (decode & 0x03) << 6; - destIndex++; - state = 3; - break; - case 3: - // We're at the last character of a four-character cyphertext block. - // This sets the low six bits of the third plaintext byte. - _GTMDevAssert(destIndex < destLen, @"our calc for decoded length was wrong"); - destBytes[destIndex] |= decode; - destIndex++; - state = 0; - break; - } - } - - // We are done decoding Base-64 chars. Let's see if we ended - // on a byte boundary, and/or with erroneous trailing characters. - if (ch == kBase64PaddingChar) { // We got a pad char - if ((state == 0) || (state == 1)) { - return 0; // Invalid '=' in first or second position - } - if (srcLen == 0) { - if (state == 2) { // We run out of input but we still need another '=' - return 0; - } - // Otherwise, we are in state 3 and only need this '=' - } else { - if (state == 2) { // need another '=' - while ((ch = *srcBytes++) && (srcLen-- > 0)) { - if (!IsSpace(ch)) - break; - } - if (ch != kBase64PaddingChar) { - return 0; - } - } - // state = 1 or 2, check if all remain padding is space - while ((ch = *srcBytes++) && (srcLen-- > 0)) { - if (!IsSpace(ch)) { - return 0; - } - } - } - } else { - // We ended by seeing the end of the string. - - if (requirePadding) { - // If we require padding, then anything but state 0 is an error. - if (state != 0) { - return 0; - } - } else { - // Make sure we have no partial bytes lying around. Note that we do not - // require trailing '=', so states 2 and 3 are okay too. - if (state == 1) { - return 0; - } - } - } - - // If then next piece of output was valid and got written to it means we got a - // very carefully crafted input that appeared valid but contains some trailing - // bits past the real length, so just toss the thing. - if ((destIndex < destLen) && - (destBytes[destIndex] != 0)) { - return 0; - } - - return destIndex; -} - -@end diff --git a/Vendor/YAJL/yajl-1.0.11/api/yajl_common.h b/Vendor/YAJL/yajl-1.0.11/api/yajl_common.h deleted file mode 100644 index a227debbd1..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/api/yajl_common.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __YAJL_COMMON_H__ -#define __YAJL_COMMON_H__ - -#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(YAJL_SHARED) -# ifdef YAJL_BUILD -# define YAJL_API __declspec(dllexport) -# else -# define YAJL_API __declspec(dllimport) -# endif -#else -# define YAJL_API -#endif - -/** pointer to a malloc function, supporting client overriding memory - * allocation routines */ -typedef void * (*yajl_malloc_func)(void *ctx, unsigned int 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, unsigned int 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 diff --git a/Vendor/YAJL/yajl-1.0.11/api/yajl_gen.h b/Vendor/YAJL/yajl-1.0.11/api/yajl_gen.h deleted file mode 100644 index 97c20426cb..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/api/yajl_gen.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * \file yajl_gen.h - * Interface to YAJL's JSON generation facilities. - */ - -#include "yajl_common.h" - -#ifndef __YAJL_GEN_H__ -#define __YAJL_GEN_H__ - -#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 - } 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, - unsigned int len); - - /** configuration structure for the generator */ - typedef struct { - /** generate indented (beautiful) output */ - unsigned int beautify; - /** an opportunity to define an indent string. such as \\t or - * some number of spaces. default is four spaces ' '. This - * member is only relevant when beautify is true */ - const char * indentString; - } yajl_gen_config; - - /** allocate a generator handle - * \param config a pointer to a structure containing parameters which - * configure the behavior of the json generator - * \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_gen_config * config, - const yajl_alloc_funcs * allocFuncs); - - /** allocate a generator handle that will print to the specified - * callback rather than storing the results in an internal buffer. - * \param callback a pointer to a printer function. May be NULL - * in which case, the results will be store in an - * internal buffer. - * \param config a pointer to a structure containing parameters - * which configure the behavior of the json - * generator. - * \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. - * \param ctx a context pointer that will be passed to the - * printer callback. - * - * \returns an allocated handle on success, NULL on failure (bad params) - */ - YAJL_API yajl_gen yajl_gen_alloc2(const yajl_print_t callback, - const yajl_gen_config * config, - const yajl_alloc_funcs * allocFuncs, - void * ctx); - - /** 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 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, - unsigned int len); - YAJL_API yajl_gen_status yajl_gen_string(yajl_gen hand, - const unsigned char * str, - unsigned int 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, - unsigned int * 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); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Vendor/YAJL/yajl-1.0.11/api/yajl_parse.h b/Vendor/YAJL/yajl-1.0.11/api/yajl_parse.h deleted file mode 100644 index a3dcffcef0..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/api/yajl_parse.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * \file yajl_parse.h - * Interface to YAJL's JSON parsing facilities. - */ - -#include "yajl_common.h" - -#ifndef __YAJL_PARSE_H__ -#define __YAJL_PARSE_H__ - -#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, - /** The parse cannot yet complete because more json input text - * is required, call yajl_parse with the next buffer of input text. - * (pertinent only when stream parsing) */ - yajl_status_insufficient_data, - /** 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. - * - * Note about handling of numbers: - * yajl will only convert numbers that can be represented in a double - * or a 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 long int 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 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, - unsigned int 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, - unsigned int stringLen); - - int (* yajl_start_map)(void * ctx); - int (* yajl_map_key)(void * ctx, const unsigned char * key, - unsigned int stringLen); - int (* yajl_end_map)(void * ctx); - - int (* yajl_start_array)(void * ctx); - int (* yajl_end_array)(void * ctx); - } yajl_callbacks; - - /** configuration structure for the generator */ - typedef struct { - /** if nonzero, javascript style comments will be allowed in - * the json input, both slash star and slash slash */ - unsigned int allowComments; - /** if nonzero, invalid UTF8 strings will cause a parse - * error */ - unsigned int checkUTF8; - } yajl_parser_config; - - /** 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 config configuration parameters for the parse. - * \param ctx a context pointer that will be passed to callbacks. - */ - YAJL_API yajl_handle yajl_alloc(const yajl_callbacks * callbacks, - const yajl_parser_config * config, - const yajl_alloc_funcs * allocFuncs, - void * ctx); - - /** 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, - unsigned int 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_parse_complete(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, - unsigned int 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 unsigned int 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 diff --git a/Vendor/YAJL/yajl-1.0.11/api/yajl_version.h b/Vendor/YAJL/yajl-1.0.11/api/yajl_version.h deleted file mode 100644 index d03d6a3448..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/api/yajl_version.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef YAJL_VERSION_H_ -#define YAJL_VERSION_H_ - -#include "yajl_common.h" - -#define YAJL_MAJOR 1 -#define YAJL_MINOR 0 -#define YAJL_MICRO 11 - -#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_ */ - diff --git a/Vendor/YAJL/yajl-1.0.11/yajl.c b/Vendor/YAJL/yajl-1.0.11/yajl.c deleted file mode 100644 index 03458140e3..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "api/yajl_parse.h" -#include "yajl_lex.h" -#include "yajl_parser.h" -#include "yajl_alloc.h" - -#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_insufficient_data: - statStr = "eof was met before the parse could complete"; - break; - case yajl_status_error: - statStr = "parse error"; - break; - } - return statStr; -} - -yajl_handle -yajl_alloc(const yajl_callbacks * callbacks, - const yajl_parser_config * config, - const yajl_alloc_funcs * afs, - void * ctx) -{ - unsigned int allowComments = 0; - unsigned int validateUTF8 = 0; - 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)); - - if (config != NULL) { - allowComments = config->allowComments; - validateUTF8 = config->checkUTF8; - } - - hand->callbacks = callbacks; - hand->ctx = ctx; - hand->lexer = yajl_lex_alloc(&(hand->alloc), allowComments, validateUTF8); - hand->bytesConsumed = 0; - hand->decodeBuf = yajl_buf_alloc(&(hand->alloc)); - yajl_bs_init(hand->stateStack, &(hand->alloc)); - - yajl_bs_push(hand->stateStack, yajl_state_start); - - return hand; -} - -void -yajl_free(yajl_handle handle) -{ - yajl_bs_free(handle->stateStack); - yajl_buf_free(handle->decodeBuf); - yajl_lex_free(handle->lexer); - YA_FREE(&(handle->alloc), handle); -} - -yajl_status -yajl_parse(yajl_handle hand, const unsigned char * jsonText, - unsigned int jsonTextLen) -{ - yajl_status status; - status = yajl_do_parse(hand, jsonText, jsonTextLen); - return status; -} - -yajl_status -yajl_parse_complete(yajl_handle hand) -{ - /* The particular case we want to handle is a trailing number. - * Further input consisting of digits could cause our interpretation - * of the number to change (buffered "1" but "2" comes in). - * A very simple approach to this is to inject whitespace to terminate - * any number in the lex buffer. - */ - return yajl_parse(hand, (const unsigned char *)" ", 1); -} - -unsigned char * -yajl_get_error(yajl_handle hand, int verbose, - const unsigned char * jsonText, unsigned int jsonTextLen) -{ - return yajl_render_error_string(hand, jsonText, jsonTextLen, verbose); -} - -unsigned int -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 */ diff --git a/Vendor/YAJL/yajl-1.0.11/yajl/yajl_common.h b/Vendor/YAJL/yajl-1.0.11/yajl/yajl_common.h deleted file mode 100644 index a227debbd1..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl/yajl_common.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __YAJL_COMMON_H__ -#define __YAJL_COMMON_H__ - -#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(YAJL_SHARED) -# ifdef YAJL_BUILD -# define YAJL_API __declspec(dllexport) -# else -# define YAJL_API __declspec(dllimport) -# endif -#else -# define YAJL_API -#endif - -/** pointer to a malloc function, supporting client overriding memory - * allocation routines */ -typedef void * (*yajl_malloc_func)(void *ctx, unsigned int 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, unsigned int 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 diff --git a/Vendor/YAJL/yajl-1.0.11/yajl/yajl_gen.h b/Vendor/YAJL/yajl-1.0.11/yajl/yajl_gen.h deleted file mode 100644 index a3fbd4cdda..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl/yajl_gen.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * \file yajl_gen.h - * Interface to YAJL's JSON generation facilities. - */ - -#include - -#ifndef __YAJL_GEN_H__ -#define __YAJL_GEN_H__ - -#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 - } 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, - unsigned int len); - - /** configuration structure for the generator */ - typedef struct { - /** generate indented (beautiful) output */ - unsigned int beautify; - /** an opportunity to define an indent string. such as \\t or - * some number of spaces. default is four spaces ' '. This - * member is only relevant when beautify is true */ - const char * indentString; - } yajl_gen_config; - - /** allocate a generator handle - * \param config a pointer to a structure containing parameters which - * configure the behavior of the json generator - * \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_gen_config * config, - const yajl_alloc_funcs * allocFuncs); - - /** allocate a generator handle that will print to the specified - * callback rather than storing the results in an internal buffer. - * \param callback a pointer to a printer function. May be NULL - * in which case, the results will be store in an - * internal buffer. - * \param config a pointer to a structure containing parameters - * which configure the behavior of the json - * generator. - * \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. - * \param ctx a context pointer that will be passed to the - * printer callback. - * - * \returns an allocated handle on success, NULL on failure (bad params) - */ - YAJL_API yajl_gen yajl_gen_alloc2(const yajl_print_t callback, - const yajl_gen_config * config, - const yajl_alloc_funcs * allocFuncs, - void * ctx); - - /** 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 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, - unsigned int len); - YAJL_API yajl_gen_status yajl_gen_string(yajl_gen hand, - const unsigned char * str, - unsigned int 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, - unsigned int * 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); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/Vendor/YAJL/yajl-1.0.11/yajl/yajl_parse.h b/Vendor/YAJL/yajl-1.0.11/yajl/yajl_parse.h deleted file mode 100644 index 1cbd930233..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl/yajl_parse.h +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * \file yajl_parse.h - * Interface to YAJL's JSON parsing facilities. - */ - -#include - -#ifndef __YAJL_PARSE_H__ -#define __YAJL_PARSE_H__ - -#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, - /** The parse cannot yet complete because more json input text - * is required, call yajl_parse with the next buffer of input text. - * (pertinent only when stream parsing) */ - yajl_status_insufficient_data, - /** 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. - * - * Note about handling of numbers: - * yajl will only convert numbers that can be represented in a double - * or a 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 long int 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 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, - unsigned int 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, - unsigned int stringLen); - - int (* yajl_start_map)(void * ctx); - int (* yajl_map_key)(void * ctx, const unsigned char * key, - unsigned int stringLen); - int (* yajl_end_map)(void * ctx); - - int (* yajl_start_array)(void * ctx); - int (* yajl_end_array)(void * ctx); - } yajl_callbacks; - - /** configuration structure for the generator */ - typedef struct { - /** if nonzero, javascript style comments will be allowed in - * the json input, both slash star and slash slash */ - unsigned int allowComments; - /** if nonzero, invalid UTF8 strings will cause a parse - * error */ - unsigned int checkUTF8; - } yajl_parser_config; - - /** 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 config configuration parameters for the parse. - * \param ctx a context pointer that will be passed to callbacks. - */ - YAJL_API yajl_handle yajl_alloc(const yajl_callbacks * callbacks, - const yajl_parser_config * config, - const yajl_alloc_funcs * allocFuncs, - void * ctx); - - /** 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, - unsigned int 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_parse_complete(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, - unsigned int 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 unsigned int 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 diff --git a/Vendor/YAJL/yajl-1.0.11/yajl/yajl_version.h b/Vendor/YAJL/yajl-1.0.11/yajl/yajl_version.h deleted file mode 100644 index e3e8d09952..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl/yajl_version.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef YAJL_VERSION_H_ -#define YAJL_VERSION_H_ - -#include - -#define YAJL_MAJOR 1 -#define YAJL_MINOR 0 -#define YAJL_MICRO 11 - -#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_ */ - diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_alloc.c b/Vendor/YAJL/yajl-1.0.11/yajl_alloc.c deleted file mode 100644 index ccfb7c3dde..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_alloc.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * \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, unsigned int sz) -{ - return malloc(sz); -} - -static void * yajl_internal_realloc(void *ctx, void * previous, - unsigned int sz) -{ - return realloc(previous, sz); -} - -static void yajl_internal_free(void *ctx, void * ptr) -{ - 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; -} - diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_alloc.h b/Vendor/YAJL/yajl-1.0.11/yajl_alloc.h deleted file mode 100644 index 94e7de5f4a..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_alloc.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * \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 diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_buf.c b/Vendor/YAJL/yajl-1.0.11/yajl_buf.c deleted file mode 100644 index 04e608a3e8..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_buf.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "yajl_buf.h" - -#include -#include -#include - -#define YAJL_BUF_INIT_SIZE 2048 - -struct yajl_buf_t { - unsigned int len; - unsigned int used; - unsigned char * data; - yajl_alloc_funcs * alloc; -}; - -static -void yajl_buf_ensure_available(yajl_buf buf, unsigned int want) -{ - unsigned int 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, unsigned int 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; -} - -unsigned int yajl_buf_len(yajl_buf buf) -{ - return buf->used; -} - -void -yajl_buf_truncate(yajl_buf buf, unsigned int len) -{ - assert(len <= buf->used); - buf->used = len; -} diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_buf.h b/Vendor/YAJL/yajl-1.0.11/yajl_buf.h deleted file mode 100644 index e330f33ae0..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_buf.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#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, unsigned int 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 */ -unsigned int yajl_buf_len(yajl_buf buf); - -/* truncate the buffer */ -void yajl_buf_truncate(yajl_buf buf, unsigned int len); - -#endif diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_bytestack.h b/Vendor/YAJL/yajl-1.0.11/yajl_bytestack.h deleted file mode 100644 index 872ede1162..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_bytestack.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * 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; - unsigned int size; - unsigned int 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 diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_encode.c b/Vendor/YAJL/yajl-1.0.11/yajl_encode.c deleted file mode 100644 index ad5b1c591d..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_encode.c +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#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(yajl_buf buf, const unsigned char * str, - unsigned int len) -{ - yajl_string_encode2((const yajl_print_t) &yajl_buf_append, buf, str, len); -} - -void -yajl_string_encode2(const yajl_print_t print, - void * ctx, - const unsigned char * str, - unsigned int len) -{ - unsigned int beg = 0; - unsigned int 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; - /* case '/': 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, 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, - unsigned int len) -{ - unsigned int beg = 0; - unsigned int 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; - break; - } - default: - assert("this should never happen" == NULL); - } - yajl_buf_append(buf, unescaped, strlen(unescaped)); - beg = ++end; - } else { - end++; - } - } - yajl_buf_append(buf, str + beg, end - beg); -} diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_encode.h b/Vendor/YAJL/yajl-1.0.11/yajl_encode.h deleted file mode 100644 index f24277908c..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_encode.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __YAJL_ENCODE_H__ -#define __YAJL_ENCODE_H__ - -#include "yajl_buf.h" -#include "api/yajl_gen.h" - -void yajl_string_encode2(const yajl_print_t printer, - void * ctx, - const unsigned char * str, - unsigned int length); - -void yajl_string_encode(yajl_buf buf, const unsigned char * str, - unsigned int length); - -void yajl_string_decode(yajl_buf buf, const unsigned char * str, - unsigned int length); - -#endif diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_gen.c b/Vendor/YAJL/yajl-1.0.11/yajl_gen.c deleted file mode 100644 index 6ad9c0b442..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_gen.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "api/yajl_gen.h" -#include "yajl_buf.h" -#include "yajl_encode.h" - -#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 depth; - unsigned int pretty; - 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; -}; - -yajl_gen -yajl_gen_alloc(const yajl_gen_config * config, - const yajl_alloc_funcs * afs) -{ - return yajl_gen_alloc2(NULL, config, afs, NULL); -} - -yajl_gen -yajl_gen_alloc2(const yajl_print_t callback, - const yajl_gen_config * config, - const yajl_alloc_funcs * afs, - void * ctx) -{ - 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)); - 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)); - - if (config) { - g->pretty = config->beautify; - g->indentString = config->indentString ? config->indentString : " "; - } - - if (callback) { - g->print = callback; - g->ctx = ctx; - } else { - g->print = (yajl_print_t)&yajl_buf_append; - g->ctx = yajl_buf_alloc(&(g->alloc)); - } - - return g; -} - -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->pretty) g->print(g->ctx, "\n", 1); \ - } else if (g->state[g->depth] == yajl_gen_map_val) { \ - g->print(g->ctx, ":", 1); \ - if (g->pretty) g->print(g->ctx, " ", 1); \ - } - -#define INSERT_WHITESPACE \ - if (g->pretty) { \ - if (g->state[g->depth] != yajl_gen_map_val) { \ - unsigned int _i; \ - for (_i=0;_idepth;_i++) \ - g->print(g->ctx, g->indentString, \ - strlen(g->indentString)); \ - } \ - } - -#define ENSURE_NOT_KEY \ - if (g->state[g->depth] == yajl_gen_map_key) { \ - 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 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->pretty && g->state[g->depth] == yajl_gen_complete) \ - g->print(g->ctx, "\n", 1); - -yajl_gen_status -yajl_gen_integer(yajl_gen g, long int number) -{ - char i[32]; - ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; - sprintf(i, "%ld", number); - g->print(g->ctx, i, strlen(i)); - APPENDED_ATOM; - FINAL_NEWLINE; - return yajl_gen_status_ok; -} - -#ifdef 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, "%g", number); - g->print(g->ctx, i, strlen(i)); - APPENDED_ATOM; - FINAL_NEWLINE; - return yajl_gen_status_ok; -} - -yajl_gen_status -yajl_gen_number(yajl_gen g, const char * s, unsigned int 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, - unsigned int len) -{ - ENSURE_VALID_STATE; INSERT_SEP; INSERT_WHITESPACE; - g->print(g->ctx, "\"", 1); - yajl_string_encode2(g->print, g->ctx, str, len); - 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, 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->pretty) 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; - (g->depth)--; - if (g->pretty) 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->pretty) 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; - if (g->pretty) g->print(g->ctx, "\n", 1); - (g->depth)--; - 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, - unsigned int * 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); -} diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_lex.c b/Vendor/YAJL/yajl-1.0.11/yajl_lex.c deleted file mode 100644 index 11e5f7bca9..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_lex.c +++ /dev/null @@ -1,737 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#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 */ - unsigned int lineOff; - unsigned int 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. */ - unsigned int 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 conrol char - * IJC - invalid json char - * VHC - valid hex char - * note. the solidus '/' may be escaped or not. - * note. the - */ -#define VEC 1 -#define IJC 2 -#define VHC 4 -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 , 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 , 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 , - -/* include these so we don't have to always check the range of the char */ - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 -}; - -/** 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, - unsigned int jsonTextLen, unsigned int * 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; \ -} - -static yajl_tok -yajl_lex_string(yajl_lexer lexer, const unsigned char * jsonText, - unsigned int jsonTextLen, unsigned int * offset) -{ - yajl_tok tok = yajl_tok_error; - int hasEscapes = 0; - - for (;;) { - unsigned char curChar; - - 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, - unsigned int jsonTextLen, unsigned int * 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, - unsigned int jsonTextLen, unsigned int * 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, - unsigned int jsonTextLen, unsigned int * offset, - const unsigned char ** outBuf, unsigned int * outLen) -{ - yajl_tok tok = yajl_tok_error; - unsigned char c; - unsigned int 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; -} - -unsigned int yajl_lex_current_line(yajl_lexer lexer) -{ - return lexer->lineOff; -} - -unsigned int yajl_lex_current_char(yajl_lexer lexer) -{ - return lexer->charOff; -} - -yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText, - unsigned int jsonTextLen, unsigned int offset) -{ - const unsigned char * outBuf; - unsigned int outLen; - unsigned int bufLen = yajl_buf_len(lexer->buf); - unsigned int 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; -} diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_lex.h b/Vendor/YAJL/yajl-1.0.11/yajl_lex.h deleted file mode 100644 index 6791a2958c..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_lex.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#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 -n * 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, - unsigned int jsonTextLen, unsigned int * offset, - const unsigned char ** outBuf, unsigned int * 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, - unsigned int jsonTextLen, unsigned int 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. */ -unsigned int yajl_lex_current_offset(yajl_lexer lexer); - -/** get the number of lines lexed by this lexer instance */ -unsigned int yajl_lex_current_line(yajl_lexer lexer); - -/** get the number of chars lexed by this lexer instance since the last - * \n or \r */ -unsigned int yajl_lex_current_char(yajl_lexer lexer); - -#endif diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_parser.c b/Vendor/YAJL/yajl-1.0.11/yajl_parser.c deleted file mode 100644 index 7fae6c6e1d..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_parser.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "yajl_lex.h" -#include "yajl_parser.h" -#include "yajl_encode.h" -#include "yajl_bytestack.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -unsigned char * -yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText, - unsigned int jsonTextLen, int verbose) -{ - unsigned int 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"; - } - - { - unsigned int 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); - 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) { - unsigned int start, end, i; - unsigned int spacesNeeded; - - spacesNeeded = (offset < 30 ? 40 - offset : 10); - start = (offset >= 30 ? offset - 30 : 0); - end = (offset + 30 > jsonTextLen ? jsonTextLen : offset + 30); - - for (i=0;ialloc), (strlen((char *) str) + - strlen((char *) text) + - strlen(arrow) + 1)); - 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_parse(yajl_handle hand, const unsigned char * jsonText, - unsigned int jsonTextLen) -{ - yajl_tok tok; - const unsigned char * buf; - unsigned int bufLen; - unsigned int * offset = &(hand->bytesConsumed); - - *offset = 0; - - - around_again: - switch (yajl_bs_current(hand->stateStack)) { - case yajl_state_parse_complete: - 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_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_insufficient_data; - 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: - /* - * note. strtol does not respect the length of - * the lexical token. in a corner case where the - * lexed number is a integer with a trailing zero, - * immediately followed by the end of buffer, - * sscanf could run off into oblivion and cause a - * crash. for this reason we copy the integer - * (and doubles), into our parse buffer (the same - * one used for unescaping strings), before - * calling strtol. yajl_buf ensures null padding, - * so we're safe. - */ - 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 int i = 0; - yajl_buf_clear(hand->decodeBuf); - yajl_buf_append(hand->decodeBuf, buf, bufLen); - buf = yajl_buf_data(hand->decodeBuf); - i = strtol((const char *) buf, NULL, 10); - if ((i == LONG_MIN || i == LONG_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); - 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) { - 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_insufficient_data; - 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_insufficient_data; - 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_insufficient_data; - 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_insufficient_data; - 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; -} - diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_parser.h b/Vendor/YAJL/yajl-1.0.11/yajl_parser.h deleted file mode 100644 index f72f3de6ed..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_parser.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2010, Lloyd Hilaiel. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. Neither the name of Lloyd Hilaiel nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __YAJL_PARSER_H__ -#define __YAJL_PARSER_H__ - -#include "api/yajl_parse.h" -#include "yajl_bytestack.h" -#include "yajl_buf.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; - -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 */ - unsigned int 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; -}; - -yajl_status -yajl_do_parse(yajl_handle handle, const unsigned char * jsonText, - unsigned int jsonTextLen); - -unsigned char * -yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText, - unsigned int jsonTextLen, int verbose); - - -#endif diff --git a/Vendor/YAJL/yajl-1.0.11/yajl_version.c b/Vendor/YAJL/yajl-1.0.11/yajl_version.c deleted file mode 100644 index cc7651e0c8..0000000000 --- a/Vendor/YAJL/yajl-1.0.11/yajl_version.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "yajl_version.h" - -int yajl_version(void) -{ - return YAJL_VERSION; -} -