diff options
Diffstat (limited to 'StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation')
4 files changed, 0 insertions, 1886 deletions
diff --git a/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMLogger.h b/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMLogger.h deleted file mode 100644 index 16f0eafb..00000000 --- a/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMLogger.h +++ /dev/null @@ -1,508 +0,0 @@ -// -// GTMLogger.h -// -// Copyright 2007-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. -// - -// Key Abstractions -// ---------------- -// -// This file declares multiple classes and protocols that are used by the -// GTMLogger logging system. The 4 main abstractions used in this file are the -// following: -// -// * logger (GTMLogger) - The main logging class that users interact with. It -// has methods for logging at different levels and uses a log writer, a log -// formatter, and a log filter to get the job done. -// -// * log writer (GTMLogWriter) - Writes a given string to some log file, where -// a "log file" can be a physical file on disk, a POST over HTTP to some URL, -// or even some in-memory structure (e.g., a ring buffer). -// -// * log formatter (GTMLogFormatter) - Given a format string and arguments as -// a va_list, returns a single formatted NSString. A "formatted string" could -// be a string with the date prepended, a string with values in a CSV format, -// or even a string of XML. -// -// * log filter (GTMLogFilter) - Given a formatted log message as an NSString -// and the level at which the message is to be logged, this class will decide -// whether the given message should be logged or not. This is a flexible way -// to filter out messages logged at a certain level, messages that contain -// certain text, or filter nothing out at all. This gives the caller the -// flexibility to dynamically enable debug logging in Release builds. -// -// This file also declares some classes to handle the common log writer, log -// formatter, and log filter cases. Callers can also create their own writers, -// formatters, and filters and they can even build them on top of the ones -// declared here. Keep in mind that your custom writer/formatter/filter may be -// called from multiple threads, so it must be thread-safe. - -#import <Foundation/Foundation.h> -#import "GTMDefines.h" - -// Predeclaration of used protocols that are declared later in this file. -@protocol GTMLogWriter, GTMLogFormatter, GTMLogFilter; - -// GTMLogger -// -// GTMLogger is the primary user-facing class for an object-oriented logging -// system. It is built on the concept of log formatters (GTMLogFormatter), log -// writers (GTMLogWriter), and log filters (GTMLogFilter). When a message is -// sent to a GTMLogger to log a message, the message is formatted using the log -// formatter, then the log filter is consulted to see if the message should be -// logged, and if so, the message is sent to the log writer to be written out. -// -// GTMLogger is intended to be a flexible and thread-safe logging solution. Its -// flexibility comes from the fact that GTMLogger instances can be customized -// with user defined formatters, filters, and writers. And these writers, -// filters, and formatters can be combined, stacked, and customized in arbitrary -// ways to suit the needs at hand. For example, multiple writers can be used at -// the same time, and a GTMLogger instance can even be used as another -// GTMLogger's writer. This allows for arbitrarily deep logging trees. -// -// A standard GTMLogger uses a writer that sends messages to standard out, a -// formatter that smacks a timestamp and a few other bits of interesting -// information on the message, and a filter that filters out debug messages from -// release builds. Using the standard log settings, a log message will look like -// the following: -// -// 2007-12-30 10:29:24.177 myapp[4588/0xa07d0f60] [lvl=1] foo=<Foo: 0x123> -// -// The output contains the date and time of the log message, the name of the -// process followed by its process ID/thread ID, the log level at which the -// message was logged (in the previous example the level was 1: -// kGTMLoggerLevelDebug), and finally, the user-specified log message itself (in -// this case, the log message was @"foo=%@", foo). -// -// Multiple instances of GTMLogger can be created, each configured their own -// way. Though GTMLogger is not a singleton (in the GoF sense), it does provide -// access to a shared (i.e., globally accessible) GTMLogger instance. This makes -// it convenient for all code in a process to use the same GTMLogger instance. -// The shared GTMLogger instance can also be configured in an arbitrary, and -// these configuration changes will affect all code that logs through the shared -// instance. - -// -// Log Levels -// ---------- -// GTMLogger has 3 different log levels: Debug, Info, and Error. GTMLogger -// doesn't take any special action based on the log level; it simply forwards -// this information on to formatters, filters, and writers, each of which may -// optionally take action based on the level. Since log level filtering is -// performed at runtime, log messages are typically not filtered out at compile -// time. The exception to this rule is that calls to the GTMLoggerDebug() macro -// *ARE* filtered out of non-DEBUG builds. This is to be backwards compatible -// with behavior that many developers are currently used to. Note that this -// means that GTMLoggerDebug(@"hi") will be compiled out of Release builds, but -// [[GTMLogger sharedLogger] logDebug:@"hi"] will NOT be compiled out. -// -// Standard loggers are created with the GTMLogLevelFilter log filter, which -// filters out certain log messages based on log level, and some other settings. -// -// In addition to the -logDebug:, -logInfo:, and -logError: methods defined on -// GTMLogger itself, there are also C macros that make usage of the shared -// GTMLogger instance very convenient. These macros are: -// -// GTMLoggerDebug(...) -// GTMLoggerInfo(...) -// GTMLoggerError(...) -// -// Again, a notable feature of these macros is that GTMLogDebug() calls *will be -// compiled out of non-DEBUG builds*. -// -// Standard Loggers -// ---------------- -// GTMLogger has the concept of "standard loggers". A standard logger is simply -// a logger that is pre-configured with some standard/common writer, formatter, -// and filter combination. Standard loggers are created using the creation -// methods beginning with "standard". The alternative to a standard logger is a -// regular logger, which will send messages to stdout, with no special -// formatting, and no filtering. -// -// How do I use GTMLogger? -// ---------------------- -// The typical way you will want to use GTMLogger is to simply use the -// GTMLogger*() macros for logging from code. That way we can easily make -// changes to the GTMLogger class and simply update the macros accordingly. Only -// your application startup code (perhaps, somewhere in main()) should use the -// GTMLogger class directly in order to configure the shared logger, which all -// of the code using the macros will be using. Again, this is just the typical -// situation. -// -// To be complete, there are cases where you may want to use GTMLogger directly, -// or even create separate GTMLogger instances for some reason. That's fine, -// too. -// -// Examples -// -------- -// The following show some common GTMLogger use cases. -// -// 1. You want to log something as simply as possible. Also, this call will only -// appear in debug builds. In non-DEBUG builds it will be completely removed. -// -// GTMLoggerDebug(@"foo = %@", foo); -// -// 2. The previous example is similar to the following. The major difference is -// that the previous call (example 1) will be compiled out of Release builds -// but this statement will not be compiled out. -// -// [[GTMLogger sharedLogger] logDebug:@"foo = %@", foo]; -// -// 3. Send all logging output from the shared logger to a file. We do this by -// creating an NSFileHandle for writing associated with a file, and setting -// that file handle as the logger's writer. -// -// NSFileHandle *f = [NSFileHandle fileHandleForWritingAtPath:@"/tmp/f.log" -// create:YES]; -// [[GTMLogger sharedLogger] setWriter:f]; -// GTMLoggerError(@"hi"); // This will be sent to /tmp/f.log -// -// 4. Create a new GTMLogger that will log to a file. This example differs from -// the previous one because here we create a new GTMLogger that is different -// from the shared logger. -// -// GTMLogger *logger = [GTMLogger standardLoggerWithPath:@"/tmp/temp.log"]; -// [logger logInfo:@"hi temp log file"]; -// -// 5. Create a logger that writes to stdout and does NOT do any formatting to -// the log message. This might be useful, for example, when writing a help -// screen for a command-line tool to standard output. -// -// GTMLogger *logger = [GTMLogger logger]; -// [logger logInfo:@"%@ version 0.1 usage", progName]; -// -// 6. Send log output to stdout AND to a log file. The trick here is that -// NSArrays function as composite log writers, which means when an array is -// set as the log writer, it forwards all logging messages to all of its -// contained GTMLogWriters. -// -// // Create array of GTMLogWriters -// NSArray *writers = [NSArray arrayWithObjects: -// [NSFileHandle fileHandleForWritingAtPath:@"/tmp/f.log" create:YES], -// [NSFileHandle fileHandleWithStandardOutput], nil]; -// -// GTMLogger *logger = [GTMLogger standardLogger]; -// [logger setWriter:writers]; -// [logger logInfo:@"hi"]; // Output goes to stdout and /tmp/f.log -// -// For futher details on log writers, formatters, and filters, see the -// documentation below. -// -// NOTE: GTMLogger is application level logging. By default it does nothing -// with _GTMDevLog/_GTMDevAssert (see GTMDefines.h). An application can choose -// to bridge _GTMDevLog/_GTMDevAssert to GTMLogger by providing macro -// definitions in its prefix header (see GTMDefines.h for how one would do -// that). -// -@interface GTMLogger : NSObject { - @private - id<GTMLogWriter> writer_; - id<GTMLogFormatter> formatter_; - id<GTMLogFilter> filter_; -} - -// -// Accessors for the shared logger instance -// - -// Returns a shared/global standard GTMLogger instance. Callers should typically -// use this method to get a GTMLogger instance, unless they explicitly want -// their own instance to configure for their own needs. This is the only method -// that returns a shared instance; all the rest return new GTMLogger instances. -+ (id)sharedLogger; - -// Sets the shared logger instance to |logger|. Future calls to +sharedLogger -// will return |logger| instead. -+ (void)setSharedLogger:(GTMLogger *)logger; - -// -// Creation methods -// - -// Returns a new autoreleased GTMLogger instance that will log to stdout, using -// the GTMLogStandardFormatter, and the GTMLogLevelFilter filter. -+ (id)standardLogger; - -// Same as +standardLogger, but logs to stderr. -+ (id)standardLoggerWithStderr; - -// Same as +standardLogger but levels >= kGTMLoggerLevelError are routed to -// stderr, everything else goes to stdout. -+ (id)standardLoggerWithStdoutAndStderr; - -// Returns a new standard GTMLogger instance with a log writer that will -// write to the file at |path|, and will use the GTMLogStandardFormatter and -// GTMLogLevelFilter classes. If |path| does not exist, it will be created. -+ (id)standardLoggerWithPath:(NSString *)path; - -// Returns an autoreleased GTMLogger instance that will use the specified -// |writer|, |formatter|, and |filter|. -+ (id)loggerWithWriter:(id<GTMLogWriter>)writer - formatter:(id<GTMLogFormatter>)formatter - filter:(id<GTMLogFilter>)filter; - -// Returns an autoreleased GTMLogger instance that logs to stdout, with the -// basic formatter, and no filter. The returned logger differs from the logger -// returned by +standardLogger because this one does not do any filtering and -// does not do any special log formatting; this is the difference between a -// "regular" logger and a "standard" logger. -+ (id)logger; - -// Designated initializer. This method returns a GTMLogger initialized with the -// specified |writer|, |formatter|, and |filter|. See the setter methods below -// for what values will be used if nil is passed for a parameter. -- (id)initWithWriter:(id<GTMLogWriter>)writer - formatter:(id<GTMLogFormatter>)formatter - filter:(id<GTMLogFilter>)filter; - -// -// Logging methods -// - -// Logs a message at the debug level (kGTMLoggerLevelDebug). -- (void)logDebug:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); -// Logs a message at the info level (kGTMLoggerLevelInfo). -- (void)logInfo:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); -// Logs a message at the error level (kGTMLoggerLevelError). -- (void)logError:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); -// Logs a message at the assert level (kGTMLoggerLevelAssert). -- (void)logAssert:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); - - -// -// Accessors -// - -// Accessor methods for the log writer. If the log writer is set to nil, -// [NSFileHandle fileHandleWithStandardOutput] is used. -- (id<GTMLogWriter>)writer; -- (void)setWriter:(id<GTMLogWriter>)writer; - -// Accessor methods for the log formatter. If the log formatter is set to nil, -// GTMLogBasicFormatter is used. This formatter will format log messages in a -// plain printf style. -- (id<GTMLogFormatter>)formatter; -- (void)setFormatter:(id<GTMLogFormatter>)formatter; - -// Accessor methods for the log filter. If the log filter is set to nil, -// GTMLogNoFilter is used, which allows all log messages through. -- (id<GTMLogFilter>)filter; -- (void)setFilter:(id<GTMLogFilter>)filter; - -@end // GTMLogger - - -// Helper functions that are used by the convenience GTMLogger*() macros that -// enable the logging of function names. -@interface GTMLogger (GTMLoggerMacroHelpers) -- (void)logFuncDebug:(const char *)func msg:(NSString *)fmt, ... - NS_FORMAT_FUNCTION(2, 3); -- (void)logFuncInfo:(const char *)func msg:(NSString *)fmt, ... - NS_FORMAT_FUNCTION(2, 3); -- (void)logFuncError:(const char *)func msg:(NSString *)fmt, ... - NS_FORMAT_FUNCTION(2, 3); -- (void)logFuncAssert:(const char *)func msg:(NSString *)fmt, ... - NS_FORMAT_FUNCTION(2, 3); -@end // GTMLoggerMacroHelpers - - -// The convenience macros are only defined if they haven't already been defined. -#ifndef GTMLoggerInfo - -// Convenience macros that log to the shared GTMLogger instance. These macros -// are how users should typically log to GTMLogger. Notice that GTMLoggerDebug() -// calls will be compiled out of non-Debug builds. -#define GTMLoggerDebug(...) \ - [[GTMLogger sharedLogger] logFuncDebug:__func__ msg:__VA_ARGS__] -#define GTMLoggerInfo(...) \ - [[GTMLogger sharedLogger] logFuncInfo:__func__ msg:__VA_ARGS__] -#define GTMLoggerError(...) \ - [[GTMLogger sharedLogger] logFuncError:__func__ msg:__VA_ARGS__] -#define GTMLoggerAssert(...) \ - [[GTMLogger sharedLogger] logFuncAssert:__func__ msg:__VA_ARGS__] - -// If we're not in a debug build, remove the GTMLoggerDebug statements. This -// makes calls to GTMLoggerDebug "compile out" of Release builds -#ifndef DEBUG -#undef GTMLoggerDebug -#define GTMLoggerDebug(...) do {} while(0) -#endif - -#endif // !defined(GTMLoggerInfo) - -// Log levels. -typedef enum { - kGTMLoggerLevelUnknown, - kGTMLoggerLevelDebug, - kGTMLoggerLevelInfo, - kGTMLoggerLevelError, - kGTMLoggerLevelAssert, -} GTMLoggerLevel; - - -// -// Log Writers -// - -// Protocol to be implemented by a GTMLogWriter instance. -@protocol GTMLogWriter <NSObject> -// Writes the given log message to where the log writer is configured to write. -- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level; -@end // GTMLogWriter - - -// Simple category on NSFileHandle that makes NSFileHandles valid log writers. -// This is convenient because something like, say, +fileHandleWithStandardError -// now becomes a valid log writer. Log messages are written to the file handle -// with a newline appended. -@interface NSFileHandle (GTMFileHandleLogWriter) <GTMLogWriter> -// Opens the file at |path| in append mode, and creates the file with |mode| -// if it didn't previously exist. -+ (id)fileHandleForLoggingAtPath:(NSString *)path mode:(mode_t)mode; -@end // NSFileHandle - - -// This category makes NSArray a GTMLogWriter that can be composed of other -// GTMLogWriters. This is the classic Composite GoF design pattern. When the -// GTMLogWriter -logMessage:level: message is sent to the array, the array -// forwards the message to all of its elements that implement the GTMLogWriter -// protocol. -// -// This is useful in situations where you would like to send log output to -// multiple log writers at the same time. Simply create an NSArray of the log -// writers you wish to use, then set the array as the "writer" for your -// GTMLogger instance. -@interface NSArray (GTMArrayCompositeLogWriter) <GTMLogWriter> -@end // GTMArrayCompositeLogWriter - - -// This category adapts the GTMLogger interface so that it can be used as a log -// writer; it's an "adapter" in the GoF Adapter pattern sense. -// -// This is useful when you want to configure a logger to log to a specific -// writer with a specific formatter and/or filter. But you want to also compose -// that with a different log writer that may have its own formatter and/or -// filter. -@interface GTMLogger (GTMLoggerLogWriter) <GTMLogWriter> -@end // GTMLoggerLogWriter - - -// -// Log Formatters -// - -// Protocol to be implemented by a GTMLogFormatter instance. -@protocol GTMLogFormatter <NSObject> -// Returns a formatted string using the format specified in |fmt| and the va -// args specified in |args|. -- (NSString *)stringForFunc:(NSString *)func - withFormat:(NSString *)fmt - valist:(va_list)args - level:(GTMLoggerLevel)level NS_FORMAT_FUNCTION(2, 0); -@end // GTMLogFormatter - - -// A basic log formatter that formats a string the same way that NSLog (or -// printf) would. It does not do anything fancy, nor does it add any data of its -// own. -@interface GTMLogBasicFormatter : NSObject <GTMLogFormatter> - -// Helper method for prettying C99 __func__ and GCC __PRETTY_FUNCTION__ -- (NSString *)prettyNameForFunc:(NSString *)func; - -@end // GTMLogBasicFormatter - - -// A log formatter that formats the log string like the basic formatter, but -// also prepends a timestamp and some basic process info to the message, as -// shown in the following sample output. -// 2007-12-30 10:29:24.177 myapp[4588/0xa07d0f60] [lvl=1] log mesage here -@interface GTMLogStandardFormatter : GTMLogBasicFormatter { - @private - NSDateFormatter *dateFormatter_; // yyyy-MM-dd HH:mm:ss.SSS - NSString *pname_; - pid_t pid_; -} -@end // GTMLogStandardFormatter - - -// -// Log Filters -// - -// Protocol to be implemented by a GTMLogFilter instance. -@protocol GTMLogFilter <NSObject> -// Returns YES if |msg| at |level| should be logged; NO otherwise. -- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level; -@end // GTMLogFilter - - -// A log filter that filters messages at the kGTMLoggerLevelDebug level out of -// non-debug builds. Messages at the kGTMLoggerLevelInfo level are also filtered -// out of non-debug builds unless GTMVerboseLogging is set in the environment or -// the processes's defaults. Messages at the kGTMLoggerLevelError level are -// never filtered. -@interface GTMLogLevelFilter : NSObject <GTMLogFilter> { - @private - BOOL verboseLoggingEnabled_; - NSUserDefaults *userDefaults_; -} -@end // GTMLogLevelFilter - -// A simple log filter that does NOT filter anything out; -// -filterAllowsMessage:level will always return YES. This can be a convenient -// way to enable debug-level logging in release builds (if you so desire). -@interface GTMLogNoFilter : NSObject <GTMLogFilter> -@end // GTMLogNoFilter - - -// Base class for custom level filters. Not for direct use, use the minimum -// or maximum level subclasses below. -@interface GTMLogAllowedLevelFilter : NSObject <GTMLogFilter> { - @private - NSIndexSet *allowedLevels_; -} -@end - -// A log filter that allows you to set a minimum log level. Messages below this -// level will be filtered. -@interface GTMLogMininumLevelFilter : GTMLogAllowedLevelFilter - -// Designated initializer, logs at levels < |level| will be filtered. -- (id)initWithMinimumLevel:(GTMLoggerLevel)level; - -@end - -// A log filter that allows you to set a maximum log level. Messages whose level -// exceeds this level will be filtered. This is really only useful if you have -// a composite GTMLogger that is sending the other messages elsewhere. -@interface GTMLogMaximumLevelFilter : GTMLogAllowedLevelFilter - -// Designated initializer, logs at levels > |level| will be filtered. -- (id)initWithMaximumLevel:(GTMLoggerLevel)level; - -@end - - -// For subclasses only -@interface GTMLogger (PrivateMethods) - -- (void)logInternalFunc:(const char *)func - format:(NSString *)fmt - valist:(va_list)args - level:(GTMLoggerLevel)level NS_FORMAT_FUNCTION(2, 0); - -@end - diff --git a/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMLogger.m b/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMLogger.m deleted file mode 100644 index e6b2ba12..00000000 --- a/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMLogger.m +++ /dev/null @@ -1,648 +0,0 @@ -// -// GTMLogger.m -// -// Copyright 2007-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 "GTMLogger.h" -#import <fcntl.h> -#import <unistd.h> -#import <stdlib.h> -#import <pthread.h> - - -#if !defined(__clang__) && (__GNUC__*10+__GNUC_MINOR__ >= 42) -// Some versions of GCC (4.2 and below AFAIK) aren't great about supporting -// -Wmissing-format-attribute -// when the function is anything more complex than foo(NSString *fmt, ...). -// You see the error inside the function when you turn ... into va_args and -// attempt to call another function (like vsprintf for example). -// So we just shut off the warning for this file. We reenable it at the end. -#pragma GCC diagnostic ignored "-Wmissing-format-attribute" -#endif // !__clang__ - -// Reference to the shared GTMLogger instance. This is not a singleton, it's -// just an easy reference to one shared instance. -static GTMLogger *gSharedLogger = nil; - - -@implementation GTMLogger - -// Returns a pointer to the shared logger instance. If none exists, a standard -// logger is created and returned. -+ (id)sharedLogger { - @synchronized(self) { - if (gSharedLogger == nil) { - gSharedLogger = [[self standardLogger] retain]; - } - } - return [[gSharedLogger retain] autorelease]; -} - -+ (void)setSharedLogger:(GTMLogger *)logger { - @synchronized(self) { - [gSharedLogger autorelease]; - gSharedLogger = [logger retain]; - } -} - -+ (id)standardLogger { - // Don't trust NSFileHandle not to throw - @try { - id<GTMLogWriter> writer = [NSFileHandle fileHandleWithStandardOutput]; - id<GTMLogFormatter> fr = [[[GTMLogStandardFormatter alloc] init] - autorelease]; - id<GTMLogFilter> filter = [[[GTMLogLevelFilter alloc] init] autorelease]; - return [[[self alloc] initWithWriter:writer - formatter:fr - filter:filter] autorelease]; - } - @catch (id e) { - // Ignored - } - return nil; -} - -+ (id)standardLoggerWithStderr { - // Don't trust NSFileHandle not to throw - @try { - id me = [self standardLogger]; - [me setWriter:[NSFileHandle fileHandleWithStandardError]]; - return me; - } - @catch (id e) { - // Ignored - } - return nil; -} - -+ (id)standardLoggerWithStdoutAndStderr { - // We're going to take advantage of the GTMLogger to GTMLogWriter adaptor - // and create a composite logger that an outer "standard" logger can use - // as a writer. Our inner loggers should apply no formatting since the main - // logger does that and we want the caller to be able to change formatters - // or add writers without knowing the inner structure of our composite. - - // Don't trust NSFileHandle not to throw - @try { - GTMLogBasicFormatter *formatter = [[[GTMLogBasicFormatter alloc] init] - autorelease]; - GTMLogger *stdoutLogger = - [self loggerWithWriter:[NSFileHandle fileHandleWithStandardOutput] - formatter:formatter - filter:[[[GTMLogMaximumLevelFilter alloc] - initWithMaximumLevel:kGTMLoggerLevelInfo] - autorelease]]; - GTMLogger *stderrLogger = - [self loggerWithWriter:[NSFileHandle fileHandleWithStandardError] - formatter:formatter - filter:[[[GTMLogMininumLevelFilter alloc] - initWithMinimumLevel:kGTMLoggerLevelError] - autorelease]]; - GTMLogger *compositeWriter = - [self loggerWithWriter:[NSArray arrayWithObjects: - stdoutLogger, stderrLogger, nil] - formatter:formatter - filter:[[[GTMLogNoFilter alloc] init] autorelease]]; - GTMLogger *outerLogger = [self standardLogger]; - [outerLogger setWriter:compositeWriter]; - return outerLogger; - } - @catch (id e) { - // Ignored - } - return nil; -} - -+ (id)standardLoggerWithPath:(NSString *)path { - @try { - NSFileHandle *fh = [NSFileHandle fileHandleForLoggingAtPath:path mode:0644]; - if (fh == nil) return nil; - id me = [self standardLogger]; - [me setWriter:fh]; - return me; - } - @catch (id e) { - // Ignored - } - return nil; -} - -+ (id)loggerWithWriter:(id<GTMLogWriter>)writer - formatter:(id<GTMLogFormatter>)formatter - filter:(id<GTMLogFilter>)filter { - return [[[self alloc] initWithWriter:writer - formatter:formatter - filter:filter] autorelease]; -} - -+ (id)logger { - return [[[self alloc] init] autorelease]; -} - -- (id)init { - return [self initWithWriter:nil formatter:nil filter:nil]; -} - -- (id)initWithWriter:(id<GTMLogWriter>)writer - formatter:(id<GTMLogFormatter>)formatter - filter:(id<GTMLogFilter>)filter { - if ((self = [super init])) { - [self setWriter:writer]; - [self setFormatter:formatter]; - [self setFilter:filter]; - } - return self; -} - -- (void)dealloc { - // Unlikely, but |writer_| may be an NSFileHandle, which can throw - @try { - [formatter_ release]; - [filter_ release]; - [writer_ release]; - } - @catch (id e) { - // Ignored - } - [super dealloc]; -} - -- (id<GTMLogWriter>)writer { - return [[writer_ retain] autorelease]; -} - -- (void)setWriter:(id<GTMLogWriter>)writer { - @synchronized(self) { - [writer_ autorelease]; - writer_ = nil; - if (writer == nil) { - // Try to use stdout, but don't trust NSFileHandle - @try { - writer_ = [[NSFileHandle fileHandleWithStandardOutput] retain]; - } - @catch (id e) { - // Leave |writer_| nil - } - } else { - writer_ = [writer retain]; - } - } -} - -- (id<GTMLogFormatter>)formatter { - return [[formatter_ retain] autorelease]; -} - -- (void)setFormatter:(id<GTMLogFormatter>)formatter { - @synchronized(self) { - [formatter_ autorelease]; - formatter_ = nil; - if (formatter == nil) { - @try { - formatter_ = [[GTMLogBasicFormatter alloc] init]; - } - @catch (id e) { - // Leave |formatter_| nil - } - } else { - formatter_ = [formatter retain]; - } - } -} - -- (id<GTMLogFilter>)filter { - return [[filter_ retain] autorelease]; -} - -- (void)setFilter:(id<GTMLogFilter>)filter { - @synchronized(self) { - [filter_ autorelease]; - filter_ = nil; - if (filter == nil) { - @try { - filter_ = [[GTMLogNoFilter alloc] init]; - } - @catch (id e) { - // Leave |filter_| nil - } - } else { - filter_ = [filter retain]; - } - } -} - -- (void)logDebug:(NSString *)fmt, ... { - va_list args; - va_start(args, fmt); - [self logInternalFunc:NULL format:fmt valist:args level:kGTMLoggerLevelDebug]; - va_end(args); -} - -- (void)logInfo:(NSString *)fmt, ... { - va_list args; - va_start(args, fmt); - [self logInternalFunc:NULL format:fmt valist:args level:kGTMLoggerLevelInfo]; - va_end(args); -} - -- (void)logError:(NSString *)fmt, ... { - va_list args; - va_start(args, fmt); - [self logInternalFunc:NULL format:fmt valist:args level:kGTMLoggerLevelError]; - va_end(args); -} - -- (void)logAssert:(NSString *)fmt, ... { - va_list args; - va_start(args, fmt); - [self logInternalFunc:NULL format:fmt valist:args level:kGTMLoggerLevelAssert]; - va_end(args); -} - -@end // GTMLogger - -@implementation GTMLogger (GTMLoggerMacroHelpers) - -- (void)logFuncDebug:(const char *)func msg:(NSString *)fmt, ... { - va_list args; - va_start(args, fmt); - [self logInternalFunc:func format:fmt valist:args level:kGTMLoggerLevelDebug]; - va_end(args); -} - -- (void)logFuncInfo:(const char *)func msg:(NSString *)fmt, ... { - va_list args; - va_start(args, fmt); - [self logInternalFunc:func format:fmt valist:args level:kGTMLoggerLevelInfo]; - va_end(args); -} - -- (void)logFuncError:(const char *)func msg:(NSString *)fmt, ... { - va_list args; - va_start(args, fmt); - [self logInternalFunc:func format:fmt valist:args level:kGTMLoggerLevelError]; - va_end(args); -} - -- (void)logFuncAssert:(const char *)func msg:(NSString *)fmt, ... { - va_list args; - va_start(args, fmt); - [self logInternalFunc:func format:fmt valist:args level:kGTMLoggerLevelAssert]; - va_end(args); -} - -@end // GTMLoggerMacroHelpers - -@implementation GTMLogger (PrivateMethods) - -- (void)logInternalFunc:(const char *)func - format:(NSString *)fmt - valist:(va_list)args - level:(GTMLoggerLevel)level { - // Primary point where logging happens, logging should never throw, catch - // everything. - @try { - NSString *fname = func ? [NSString stringWithUTF8String:func] : nil; - NSString *msg = [formatter_ stringForFunc:fname - withFormat:fmt - valist:args - level:level]; - if (msg && [filter_ filterAllowsMessage:msg level:level]) - [writer_ logMessage:msg level:level]; - } - @catch (id e) { - // Ignored - } -} - -@end // PrivateMethods - - -@implementation NSFileHandle (GTMFileHandleLogWriter) - -+ (id)fileHandleForLoggingAtPath:(NSString *)path mode:(mode_t)mode { - int fd = -1; - if (path) { - int flags = O_WRONLY | O_APPEND | O_CREAT; - fd = open([path fileSystemRepresentation], flags, mode); - } - if (fd == -1) return nil; - return [[[self alloc] initWithFileDescriptor:fd - closeOnDealloc:YES] autorelease]; -} - -- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level { - @synchronized(self) { - // Closed pipes should not generate exceptions in our caller. Catch here - // as well [GTMLogger logInternalFunc:...] so that an exception in this - // writer does not prevent other writers from having a chance. - @try { - NSString *line = [NSString stringWithFormat:@"%@\n", msg]; - [self writeData:[line dataUsingEncoding:NSUTF8StringEncoding]]; - } - @catch (id e) { - // Ignored - } - } -} - -@end // GTMFileHandleLogWriter - - -@implementation NSArray (GTMArrayCompositeLogWriter) - -- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level { - @synchronized(self) { - id<GTMLogWriter> child = nil; - for (child in self) { - if ([child conformsToProtocol:@protocol(GTMLogWriter)]) - [child logMessage:msg level:level]; - } - } -} - -@end // GTMArrayCompositeLogWriter - - -@implementation GTMLogger (GTMLoggerLogWriter) - -- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level { - switch (level) { - case kGTMLoggerLevelDebug: - [self logDebug:@"%@", msg]; - break; - case kGTMLoggerLevelInfo: - [self logInfo:@"%@", msg]; - break; - case kGTMLoggerLevelError: - [self logError:@"%@", msg]; - break; - case kGTMLoggerLevelAssert: - [self logAssert:@"%@", msg]; - break; - default: - // Ignore the message. - break; - } -} - -@end // GTMLoggerLogWriter - - -@implementation GTMLogBasicFormatter - -- (NSString *)prettyNameForFunc:(NSString *)func { - NSString *name = [func stringByTrimmingCharactersInSet: - [NSCharacterSet whitespaceAndNewlineCharacterSet]]; - NSString *function = @"(unknown)"; - if ([name length]) { - if (// Objective C __func__ and __PRETTY_FUNCTION__ - [name hasPrefix:@"-["] || [name hasPrefix:@"+["] || - // C++ __PRETTY_FUNCTION__ and other preadorned formats - [name hasSuffix:@")"]) { - function = name; - } else { - // Assume C99 __func__ - function = [NSString stringWithFormat:@"%@()", name]; - } - } - return function; -} - -- (NSString *)stringForFunc:(NSString *)func - withFormat:(NSString *)fmt - valist:(va_list)args - level:(GTMLoggerLevel)level { - // Performance note: We may want to do a quick check here to see if |fmt| - // contains a '%', and if not, simply return 'fmt'. - if (!(fmt && args)) return nil; - return [[[NSString alloc] initWithFormat:fmt arguments:args] autorelease]; -} - -@end // GTMLogBasicFormatter - - -@implementation GTMLogStandardFormatter - -- (id)init { - if ((self = [super init])) { - dateFormatter_ = [[NSDateFormatter alloc] init]; - [dateFormatter_ setFormatterBehavior:NSDateFormatterBehavior10_4]; - [dateFormatter_ setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"]; - pname_ = [[[NSProcessInfo processInfo] processName] copy]; - pid_ = [[NSProcessInfo processInfo] processIdentifier]; - if (!(dateFormatter_ && pname_)) { - [self release]; - return nil; - } - } - return self; -} - -- (void)dealloc { - [dateFormatter_ release]; - [pname_ release]; - [super dealloc]; -} - -- (NSString *)stringForFunc:(NSString *)func - withFormat:(NSString *)fmt - valist:(va_list)args - level:(GTMLoggerLevel)level { - NSString *tstamp = nil; - @synchronized (dateFormatter_) { - tstamp = [dateFormatter_ stringFromDate:[NSDate date]]; - } - return [NSString stringWithFormat:@"%@ %@[%d/%p] [lvl=%d] %@ %@", - tstamp, pname_, pid_, pthread_self(), - level, [self prettyNameForFunc:func], - // |super| has guard for nil |fmt| and |args| - [super stringForFunc:func withFormat:fmt valist:args level:level]]; -} - -@end // GTMLogStandardFormatter - -static NSString *const kVerboseLoggingKey = @"GTMVerboseLogging"; - -// Check the environment and the user preferences for the GTMVerboseLogging key -// to see if verbose logging has been enabled. The environment variable will -// override the defaults setting, so check the environment first. -// COV_NF_START -static BOOL IsVerboseLoggingEnabled(NSUserDefaults *userDefaults) { - NSString *value = [[[NSProcessInfo processInfo] environment] - objectForKey:kVerboseLoggingKey]; - if (value) { - // Emulate [NSString boolValue] for pre-10.5 - value = [value stringByTrimmingCharactersInSet: - [NSCharacterSet whitespaceAndNewlineCharacterSet]]; - if ([[value uppercaseString] hasPrefix:@"Y"] || - [[value uppercaseString] hasPrefix:@"T"] || - [value intValue]) { - return YES; - } else { - return NO; - } - } - return [userDefaults boolForKey:kVerboseLoggingKey]; -} -// COV_NF_END - -@implementation GTMLogLevelFilter - -- (id)init { - self = [super init]; - if (self) { - // Keep a reference to standardUserDefaults, avoiding a crash if client code calls - // "NSUserDefaults resetStandardUserDefaults" which releases it from memory. We are still - // notified of changes through our instance. Note: resetStandardUserDefaults does not actually - // clear settings: - // https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/index.html#//apple_ref/occ/clm/NSUserDefaults/resetStandardUserDefaults - // and so should only be called in test code if necessary. - userDefaults_ = [[NSUserDefaults standardUserDefaults] retain]; - [userDefaults_ addObserver:self - forKeyPath:kVerboseLoggingKey - options:NSKeyValueObservingOptionNew - context:nil]; - - verboseLoggingEnabled_ = IsVerboseLoggingEnabled(userDefaults_); - } - - return self; -} - -- (void)dealloc { - [userDefaults_ removeObserver:self forKeyPath:kVerboseLoggingKey]; - [userDefaults_ release]; - - [super dealloc]; -} - -// In DEBUG builds, log everything. If we're not in a debug build we'll assume -// that we're in a Release build. -- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level { -#if defined(DEBUG) && DEBUG - return YES; -#endif - - BOOL allow = YES; - - switch (level) { - case kGTMLoggerLevelDebug: - allow = NO; - break; - case kGTMLoggerLevelInfo: - allow = verboseLoggingEnabled_; - break; - case kGTMLoggerLevelError: - allow = YES; - break; - case kGTMLoggerLevelAssert: - allow = YES; - break; - default: - allow = YES; - break; - } - - return allow; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath - ofObject:(id)object - change:(NSDictionary *)change - context:(void *)context -{ - if([keyPath isEqual:kVerboseLoggingKey]) { - verboseLoggingEnabled_ = IsVerboseLoggingEnabled(userDefaults_); - } -} - -@end // GTMLogLevelFilter - - -@implementation GTMLogNoFilter - -- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level { - return YES; // Allow everything through -} - -@end // GTMLogNoFilter - - -@implementation GTMLogAllowedLevelFilter - -// Private designated initializer -- (id)initWithAllowedLevels:(NSIndexSet *)levels { - self = [super init]; - if (self != nil) { - allowedLevels_ = [levels retain]; - // Cap min/max level - if (!allowedLevels_ || - // NSIndexSet is unsigned so only check the high bound, but need to - // check both first and last index because NSIndexSet appears to allow - // wraparound. - ([allowedLevels_ firstIndex] > kGTMLoggerLevelAssert) || - ([allowedLevels_ lastIndex] > kGTMLoggerLevelAssert)) { - [self release]; - return nil; - } - } - return self; -} - -- (id)init { - // Allow all levels in default init - return [self initWithAllowedLevels:[NSIndexSet indexSetWithIndexesInRange: - NSMakeRange(kGTMLoggerLevelUnknown, - (kGTMLoggerLevelAssert - kGTMLoggerLevelUnknown + 1))]]; -} - -- (void)dealloc { - [allowedLevels_ release]; - [super dealloc]; -} - -- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level { - return [allowedLevels_ containsIndex:level]; -} - -@end // GTMLogAllowedLevelFilter - - -@implementation GTMLogMininumLevelFilter - -- (id)initWithMinimumLevel:(GTMLoggerLevel)level { - return [super initWithAllowedLevels:[NSIndexSet indexSetWithIndexesInRange: - NSMakeRange(level, - (kGTMLoggerLevelAssert - level + 1))]]; -} - -@end // GTMLogMininumLevelFilter - - -@implementation GTMLogMaximumLevelFilter - -- (id)initWithMaximumLevel:(GTMLoggerLevel)level { - return [super initWithAllowedLevels:[NSIndexSet indexSetWithIndexesInRange: - NSMakeRange(kGTMLoggerLevelUnknown, level + 1)]]; -} - -@end // GTMLogMaximumLevelFilter - -#if !defined(__clang__) && (__GNUC__*10+__GNUC_MINOR__ >= 42) -// See comment at top of file. -#pragma GCC diagnostic error "-Wmissing-format-attribute" -#endif // !__clang__ diff --git a/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.h b/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.h deleted file mode 100644 index dceadc44..00000000 --- a/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.h +++ /dev/null @@ -1,199 +0,0 @@ -// -// GTMNSData+zlib.h -// -// Copyright 2007-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 <Foundation/Foundation.h> -#import "GTMDefines.h" - -/// Helpers for dealing w/ zlib inflate/deflate calls. -@interface NSData (GTMZLibAdditions) - -// NOTE: For 64bit, none of these apis handle input sizes >32bits, they will -// return nil when given such data. To handle data of that size you really -// should be streaming it rather then doing it all in memory. - -#pragma mark Gzip Compression - -/// Return an autoreleased NSData w/ the result of gzipping the bytes. -// -// Uses the default compression level. -+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes - length:(NSUInteger)length; -+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of gzipping the payload of |data|. -// -// Uses the default compression level. -+ (NSData *)gtm_dataByGzippingData:(NSData *)data __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByGzippingData:(NSData *)data - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level. -// -// |level| can be 1-9, any other values will be clipped to that range. -+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level. -+ (NSData *)gtm_dataByGzippingData:(NSData *)data - compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByGzippingData:(NSData *)data - compressionLevel:(int)level - error:(NSError **)error; - -#pragma mark Zlib "Stream" Compression - -// NOTE: deflate is *NOT* gzip. deflate is a "zlib" stream. pick which one -// you really want to create. (the inflate api will handle either) - -/// Return an autoreleased NSData w/ the result of deflating the bytes. -// -// Uses the default compression level. -+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes - length:(NSUInteger)length __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of deflating the payload of |data|. -// -// Uses the default compression level. -+ (NSData *)gtm_dataByDeflatingData:(NSData *)data __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByDeflatingData:(NSData *)data - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level. -// -// |level| can be 1-9, any other values will be clipped to that range. -+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level. -+ (NSData *)gtm_dataByDeflatingData:(NSData *)data - compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByDeflatingData:(NSData *)data - compressionLevel:(int)level - error:(NSError **)error; - -#pragma mark Uncompress of Gzip or Zlib - -/// Return an autoreleased NSData w/ the result of decompressing the bytes. -// -// The bytes to decompress can be zlib or gzip payloads. -+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes - length:(NSUInteger)length __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of decompressing the payload of |data|. -// -// The data to decompress can be zlib or gzip payloads. -+ (NSData *)gtm_dataByInflatingData:(NSData *)data __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByInflatingData:(NSData *)data - error:(NSError **)error; - -#pragma mark "Raw" Compression Support - -// NOTE: raw deflate is *NOT* gzip or deflate. it does not include a header -// of any form and should only be used within streams here an external crc/etc. -// is done to validate the data. The RawInflate apis can be used on data -// processed like this. - -/// Return an autoreleased NSData w/ the result of *raw* deflating the bytes. -// -// Uses the default compression level. -// *No* header is added to the resulting data. -+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data|. -// -// Uses the default compression level. -// *No* header is added to the resulting data. -+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of *raw* deflating the bytes using |level| compression level. -// -// |level| can be 1-9, any other values will be clipped to that range. -// *No* header is added to the resulting data. -+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data| using |level| compression level. -// *No* header is added to the resulting data. -+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data - compressionLevel:(int)level __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data - compressionLevel:(int)level - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of *raw* decompressing the bytes. -// -// The data to decompress, it should *not* have any header (zlib nor gzip). -+ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes - length:(NSUInteger)length __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error; - -/// Return an autoreleased NSData w/ the result of *raw* decompressing the payload of |data|. -// -// The data to decompress, it should *not* have any header (zlib nor gzip). -+ (NSData *)gtm_dataByRawInflatingData:(NSData *)data __attribute__((deprecated("Use error variant"))); -+ (NSData *)gtm_dataByRawInflatingData:(NSData *)data - error:(NSError **)error; - -@end - -FOUNDATION_EXPORT NSString *const GTMNSDataZlibErrorDomain; -FOUNDATION_EXPORT NSString *const GTMNSDataZlibErrorKey; // NSNumber -FOUNDATION_EXPORT NSString *const GTMNSDataZlibRemainingBytesKey; // NSNumber - -typedef NS_ENUM(NSInteger, GTMNSDataZlibError) { - GTMNSDataZlibErrorGreaterThan32BitsToCompress = 1024, - // An internal zlib error. - // GTMNSDataZlibErrorKey will contain the error value. - // NSLocalizedDescriptionKey may contain an error string from zlib. - // Look in zlib.h for list of errors. - GTMNSDataZlibErrorInternal, - // There was left over data in the buffer that was not used. - // GTMNSDataZlibRemainingBytesKey will contain number of remaining bytes. - GTMNSDataZlibErrorDataRemaining -}; diff --git a/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.m b/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.m deleted file mode 100644 index bf74b2d2..00000000 --- a/StoneIsland/platforms/ios/Pods/GoogleToolboxForMac/Foundation/GTMNSData+zlib.m +++ /dev/null @@ -1,531 +0,0 @@ -// -// GTMNSData+zlib.m -// -// Copyright 2007-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 "GTMNSData+zlib.h" -#import <zlib.h> -#import "GTMDefines.h" - -#define kChunkSize 1024 - -NSString *const GTMNSDataZlibErrorDomain = @"com.google.GTMNSDataZlibErrorDomain"; -NSString *const GTMNSDataZlibErrorKey = @"GTMNSDataZlibErrorKey"; -NSString *const GTMNSDataZlibRemainingBytesKey = @"GTMNSDataZlibRemainingBytesKey"; - -typedef enum { - CompressionModeZlib, - CompressionModeGzip, - CompressionModeRaw, -} CompressionMode; - -@interface NSData (GTMZlibAdditionsPrivate) -+ (NSData *)gtm_dataByCompressingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level - mode:(CompressionMode)mode - error:(NSError **)error; -+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes - length:(NSUInteger)length - isRawData:(BOOL)isRawData - error:(NSError **)error; -@end - -@implementation NSData (GTMZlibAdditionsPrivate) - -+ (NSData *)gtm_dataByCompressingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level - mode:(CompressionMode)mode - error:(NSError **)error { - if (!bytes || !length) { - return nil; - } - -#if defined(__LP64__) && __LP64__ - // Don't support > 32bit length for 64 bit, see note in header. - if (length > UINT_MAX) { - if (error) { - *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain - code:GTMNSDataZlibErrorGreaterThan32BitsToCompress - userInfo:nil]; - } - return nil; - } -#endif - - if (level == Z_DEFAULT_COMPRESSION) { - // the default value is actually outside the range, so we have to let it - // through specifically. - } else if (level < Z_BEST_SPEED) { - level = Z_BEST_SPEED; - } else if (level > Z_BEST_COMPRESSION) { - level = Z_BEST_COMPRESSION; - } - - z_stream strm; - bzero(&strm, sizeof(z_stream)); - - int memLevel = 8; // the default - int windowBits = 15; // the default - switch (mode) { - case CompressionModeZlib: - // nothing to do - break; - - case CompressionModeGzip: - windowBits += 16; // enable gzip header instead of zlib header - break; - - case CompressionModeRaw: - windowBits *= -1; // Negative to mean no header. - break; - } - int retCode; - if ((retCode = deflateInit2(&strm, level, Z_DEFLATED, windowBits, - memLevel, Z_DEFAULT_STRATEGY)) != Z_OK) { - // COV_NF_START - no real way to force this in a unittest (we guard all args) - if (error) { - NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:retCode] - forKey:GTMNSDataZlibErrorKey]; - *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain - code:GTMNSDataZlibErrorInternal - userInfo:userInfo]; - } - return nil; - // COV_NF_END - } - - // hint the size at 1/4 the input size - NSMutableData *result = [NSMutableData dataWithCapacity:(length/4)]; - unsigned char output[kChunkSize]; - - // setup the input - strm.avail_in = (unsigned int)length; - strm.next_in = (unsigned char*)bytes; - - // loop to collect the data - do { - // update what we're passing in - strm.avail_out = kChunkSize; - strm.next_out = output; - retCode = deflate(&strm, Z_FINISH); - if ((retCode != Z_OK) && (retCode != Z_STREAM_END)) { - // COV_NF_START - no real way to force this in a unittest - // (in inflate, we can feed bogus/truncated data to test, but an error - // here would be some internal issue w/in zlib, and there isn't any real - // way to test it) - if (error) { - NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:retCode] - forKey:GTMNSDataZlibErrorKey]; - *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain - code:GTMNSDataZlibErrorInternal - userInfo:userInfo]; - } - deflateEnd(&strm); - return nil; - // COV_NF_END - } - // collect what we got - unsigned gotBack = kChunkSize - strm.avail_out; - if (gotBack > 0) { - [result appendBytes:output length:gotBack]; - } - - } while (retCode == Z_OK); - - // if the loop exits, we used all input and the stream ended - _GTMDevAssert(strm.avail_in == 0, - @"thought we finished deflate w/o using all input, %u bytes left", - strm.avail_in); - _GTMDevAssert(retCode == Z_STREAM_END, - @"thought we finished deflate w/o getting a result of stream end, code %d", - retCode); - - // clean up - deflateEnd(&strm); - - return result; -} // gtm_dataByCompressingBytes:length:compressionLevel:useGzip: - -+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes - length:(NSUInteger)length - isRawData:(BOOL)isRawData - error:(NSError **)error { - if (!bytes || !length) { - return nil; - } - -#if defined(__LP64__) && __LP64__ - // Don't support > 32bit length for 64 bit, see note in header. - if (length > UINT_MAX) { - return nil; - } -#endif - - z_stream strm; - bzero(&strm, sizeof(z_stream)); - - // setup the input - strm.avail_in = (unsigned int)length; - strm.next_in = (unsigned char*)bytes; - - int windowBits = 15; // 15 to enable any window size - if (isRawData) { - windowBits *= -1; // make it negative to signal no header. - } else { - windowBits += 32; // and +32 to enable zlib or gzip header detection. - } - - int retCode; - if ((retCode = inflateInit2(&strm, windowBits)) != Z_OK) { - // COV_NF_START - no real way to force this in a unittest (we guard all args) - if (error) { - NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:retCode] - forKey:GTMNSDataZlibErrorKey]; - *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain - code:GTMNSDataZlibErrorInternal - userInfo:userInfo]; - } - return nil; - // COV_NF_END - } - - // hint the size at 4x the input size - NSMutableData *result = [NSMutableData dataWithCapacity:(length*4)]; - unsigned char output[kChunkSize]; - - // loop to collect the data - do { - // update what we're passing in - strm.avail_out = kChunkSize; - strm.next_out = output; - retCode = inflate(&strm, Z_NO_FLUSH); - if ((retCode != Z_OK) && (retCode != Z_STREAM_END)) { - if (error) { - NSMutableDictionary *userInfo = - [NSMutableDictionary dictionaryWithObject:[NSNumber numberWithInt:retCode] - forKey:GTMNSDataZlibErrorKey]; - if (strm.msg) { - NSString *message = [NSString stringWithUTF8String:strm.msg]; - if (message) { - [userInfo setObject:message forKey:NSLocalizedDescriptionKey]; - } - } - *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain - code:GTMNSDataZlibErrorInternal - userInfo:userInfo]; - } - inflateEnd(&strm); - return nil; - } - // collect what we got - unsigned gotBack = kChunkSize - strm.avail_out; - if (gotBack > 0) { - [result appendBytes:output length:gotBack]; - } - - } while (retCode == Z_OK); - - // make sure there wasn't more data tacked onto the end of a valid compressed - // stream. - if (strm.avail_in != 0) { - if (error) { - NSDictionary *userInfo = - [NSDictionary dictionaryWithObject:[NSNumber numberWithUnsignedInt:strm.avail_in] - forKey:GTMNSDataZlibRemainingBytesKey]; - *error = [NSError errorWithDomain:GTMNSDataZlibErrorDomain - code:GTMNSDataZlibErrorDataRemaining - userInfo:userInfo]; - } - result = nil; - } - // the only way out of the loop was by hitting the end of the stream - _GTMDevAssert(retCode == Z_STREAM_END, - @"thought we finished inflate w/o getting a result of stream end, code %d", - retCode); - - // clean up - inflateEnd(&strm); - - return result; -} // gtm_dataByInflatingBytes:length:windowBits: - -@end - - -@implementation NSData (GTMZLibAdditions) - -+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes - length:(NSUInteger)length { - return [self gtm_dataByGzippingBytes:bytes length:length error:NULL]; -} // gtm_dataByGzippingBytes:length: - -+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error { - return [self gtm_dataByCompressingBytes:bytes - length:length - compressionLevel:Z_DEFAULT_COMPRESSION - mode:CompressionModeGzip - error:error]; -} // gtm_dataByGzippingBytes:length:error: - -+ (NSData *)gtm_dataByGzippingData:(NSData *)data { - return [self gtm_dataByGzippingData:data error:NULL]; -} // gtm_dataByGzippingData: - -+ (NSData *)gtm_dataByGzippingData:(NSData *)data error:(NSError **)error { - return [self gtm_dataByCompressingBytes:[data bytes] - length:[data length] - compressionLevel:Z_DEFAULT_COMPRESSION - mode:CompressionModeGzip - error:error]; -} // gtm_dataByGzippingData:error: - -+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level { - return [self gtm_dataByGzippingBytes:bytes - length:length - compressionLevel:level - error:NULL]; -} // gtm_dataByGzippingBytes:length:level: - -+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level - error:(NSError **)error{ - return [self gtm_dataByCompressingBytes:bytes - length:length - compressionLevel:level - mode:CompressionModeGzip - error:error]; -} // gtm_dataByGzippingBytes:length:level:error - -+ (NSData *)gtm_dataByGzippingData:(NSData *)data - compressionLevel:(int)level { - return [self gtm_dataByGzippingData:data - compressionLevel:level - error:NULL]; -} // gtm_dataByGzippingData:level: - -+ (NSData *)gtm_dataByGzippingData:(NSData *)data - compressionLevel:(int)level - error:(NSError **)error{ - return [self gtm_dataByCompressingBytes:[data bytes] - length:[data length] - compressionLevel:level - mode:CompressionModeGzip - error:error]; -} // gtm_dataByGzippingData:level:error - -#pragma mark - - -+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes - length:(NSUInteger)length { - return [self gtm_dataByDeflatingBytes:bytes - length:length - error:NULL]; -} // gtm_dataByDeflatingBytes:length: - -+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error{ - return [self gtm_dataByCompressingBytes:bytes - length:length - compressionLevel:Z_DEFAULT_COMPRESSION - mode:CompressionModeZlib - error:error]; -} // gtm_dataByDeflatingBytes:length:error - -+ (NSData *)gtm_dataByDeflatingData:(NSData *)data { - return [self gtm_dataByDeflatingData:data error:NULL]; -} // gtm_dataByDeflatingData: - -+ (NSData *)gtm_dataByDeflatingData:(NSData *)data error:(NSError **)error { - return [self gtm_dataByCompressingBytes:[data bytes] - length:[data length] - compressionLevel:Z_DEFAULT_COMPRESSION - mode:CompressionModeZlib - error:error]; -} // gtm_dataByDeflatingData: - -+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level { - return [self gtm_dataByDeflatingBytes:bytes - length:length - compressionLevel:level - error:NULL]; -} // gtm_dataByDeflatingBytes:length:level: - -+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level - error:(NSError **)error { - return [self gtm_dataByCompressingBytes:bytes - length:length - compressionLevel:level - mode:CompressionModeZlib - error:error]; -} // gtm_dataByDeflatingBytes:length:level:error: - -+ (NSData *)gtm_dataByDeflatingData:(NSData *)data - compressionLevel:(int)level { - return [self gtm_dataByDeflatingData:data - compressionLevel:level - error:NULL]; -} // gtm_dataByDeflatingData:level: - -+ (NSData *)gtm_dataByDeflatingData:(NSData *)data - compressionLevel:(int)level - error:(NSError **)error { - return [self gtm_dataByCompressingBytes:[data bytes] - length:[data length] - compressionLevel:level - mode:CompressionModeZlib - error:error]; -} // gtm_dataByDeflatingData:level:error: - -#pragma mark - - -+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes - length:(NSUInteger)length { - return [self gtm_dataByInflatingBytes:bytes - length:length - error:NULL]; -} // gtm_dataByInflatingBytes:length: - -+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error { - return [self gtm_dataByInflatingBytes:bytes - length:length - isRawData:NO - error:error]; -} // gtm_dataByInflatingBytes:length:error: - -+ (NSData *)gtm_dataByInflatingData:(NSData *)data { - return [self gtm_dataByInflatingData:data error:NULL]; -} // gtm_dataByInflatingData: - -+ (NSData *)gtm_dataByInflatingData:(NSData *)data - error:(NSError **)error { - return [self gtm_dataByInflatingBytes:[data bytes] - length:[data length] - isRawData:NO - error:error]; -} // gtm_dataByInflatingData: - -#pragma mark - - -+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length { - return [self gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:NULL]; -} // gtm_dataByRawDeflatingBytes:length: - -+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error { - return [self gtm_dataByCompressingBytes:bytes - length:length - compressionLevel:Z_DEFAULT_COMPRESSION - mode:CompressionModeRaw - error:error]; -} // gtm_dataByRawDeflatingBytes:length:error: - -+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data { - return [self gtm_dataByRawDeflatingData:data error:NULL]; -} // gtm_dataByRawDeflatingData: - -+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data error:(NSError **)error { - return [self gtm_dataByCompressingBytes:[data bytes] - length:[data length] - compressionLevel:Z_DEFAULT_COMPRESSION - mode:CompressionModeRaw - error:error]; -} // gtm_dataByRawDeflatingData:error: - -+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level { - return [self gtm_dataByRawDeflatingBytes:bytes - length:length - compressionLevel:level - error:NULL]; -} // gtm_dataByRawDeflatingBytes:length:compressionLevel: - -+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes - length:(NSUInteger)length - compressionLevel:(int)level - error:(NSError **)error{ - return [self gtm_dataByCompressingBytes:bytes - length:length - compressionLevel:level - mode:CompressionModeRaw - error:error]; -} // gtm_dataByRawDeflatingBytes:length:compressionLevel:error: - -+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data - compressionLevel:(int)level { - return [self gtm_dataByRawDeflatingData:data - compressionLevel:level - error:NULL]; -} // gtm_dataByRawDeflatingData:compressionLevel: - -+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data - compressionLevel:(int)level - error:(NSError **)error { - return [self gtm_dataByCompressingBytes:[data bytes] - length:[data length] - compressionLevel:level - mode:CompressionModeRaw - error:error]; -} // gtm_dataByRawDeflatingData:compressionLevel:error: - -+ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes - length:(NSUInteger)length { - return [self gtm_dataByInflatingBytes:bytes - length:length - error:NULL]; -} // gtm_dataByRawInflatingBytes:length: - -+ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes - length:(NSUInteger)length - error:(NSError **)error{ - return [self gtm_dataByInflatingBytes:bytes - length:length - isRawData:YES - error:error]; -} // gtm_dataByRawInflatingBytes:length:error: - -+ (NSData *)gtm_dataByRawInflatingData:(NSData *)data { - return [self gtm_dataByRawInflatingData:data - error:NULL]; -} // gtm_dataByRawInflatingData: - -+ (NSData *)gtm_dataByRawInflatingData:(NSData *)data - error:(NSError **)error { - return [self gtm_dataByInflatingBytes:[data bytes] - length:[data length] - isRawData:YES - error:error]; -} // gtm_dataByRawInflatingData:error: - -@end |
