diff options
Diffstat (limited to 'src/tools/3rdparty/iossim_1_8_2/nsprintf.mm')
-rw-r--r-- | src/tools/3rdparty/iossim_1_8_2/nsprintf.mm | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/tools/3rdparty/iossim_1_8_2/nsprintf.mm b/src/tools/3rdparty/iossim_1_8_2/nsprintf.mm new file mode 100644 index 0000000000..b7413f593c --- /dev/null +++ b/src/tools/3rdparty/iossim_1_8_2/nsprintf.mm @@ -0,0 +1,44 @@ +/* + * NSLog() clone, but writes to arbitrary output stream + * + * See the IOSSIM_LICENSE file in this directory for the license on the source code in this file. + */ + +#import <Foundation/Foundation.h> +#import <stdio.h> + +int nsvfprintf (FILE *stream, NSString *format, va_list args) { + int retval; + + NSString *str = (NSString *) CFStringCreateWithFormatAndArguments(NULL, NULL, (CFStringRef) format, args); + retval = fprintf(stream, "%s\n", [str UTF8String]); + [str release]; + + return retval; +} + +int nsfprintf (FILE *stream, NSString *format, ...) { + va_list ap; + int retval; + + va_start(ap, format); + { + retval = nsvfprintf(stream, format, ap); + } + va_end(ap); + + return retval; +} + +int nsprintf (NSString *format, ...) { + va_list ap; + int retval; + + va_start(ap, format); + { + retval = nsvfprintf(stdout, format, ap); + } + va_end(ap); + + return retval; +} |