X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/5c19dc3ae3bd8e40a9c028b0deddd50ff337692c..07691282a056c4efea71e1e505527601e8cc166b:/OSX/libsecurity_utilities/lib/cfmunge.h diff --git a/OSX/libsecurity_utilities/lib/cfmunge.h b/OSX/libsecurity_utilities/lib/cfmunge.h index 2b13d326..55a7df9d 100644 --- a/OSX/libsecurity_utilities/lib/cfmunge.h +++ b/OSX/libsecurity_utilities/lib/cfmunge.h @@ -40,8 +40,11 @@ namespace Security { // class CFMunge { public: - CFMunge(const char *fmt, va_list arg); - ~CFMunge(); + // Initialize a CFMunge. We start out with the default CFAllocator, and + // we do not throw errors. + // CFMunge consumes the va_list, the caller should call va_copy if necessary. + CFMunge(const char *fmt, va_list *args) + : format(fmt), args(args), allocator(NULL), error(errSecSuccess) { } protected: char next(); @@ -51,7 +54,7 @@ protected: protected: const char *format; - va_list args; + va_list *args; CFAllocatorRef allocator; OSStatus error; }; @@ -62,7 +65,7 @@ protected: // class CFMake : public CFMunge { public: - CFMake(const char *fmt, va_list arg) : CFMunge(fmt, arg) { } + CFMake(const char *fmt, va_list *args) : CFMunge(fmt, args) { } CFTypeRef make(); CFDictionaryRef addto(CFMutableDictionaryRef dict); @@ -83,14 +86,14 @@ protected: // Make a CF object following a general recipe // CFTypeRef cfmake(const char *format, ...); -CFTypeRef vcfmake(const char *format, va_list args); +CFTypeRef vcfmake(const char *format, va_list *args); template CFType cfmake(const char *format, ...) { va_list args; va_start(args, format); - CFType result = CFType(vcfmake(format, args)); + CFType result = CFType(vcfmake(format, &args)); va_end(args); return result; } @@ -103,17 +106,17 @@ CFDictionaryRef cfadd(CFMutableDictionaryRef dict, const char *format, ...); // Cfscan returns false on error; cfget throws. // bool cfscan(CFTypeRef source, const char *format, ...); -bool vcfscan(CFTypeRef source, const char *format, va_list args); +bool vcfscan(CFTypeRef source, const char *format, va_list *args); CFTypeRef cfget(CFTypeRef source, const char *format, ...); -CFTypeRef vcfget(CFTypeRef source, const char *format, va_list args); +CFTypeRef vcfget(CFTypeRef source, const char *format, va_list *args); template CFType cfget(CFTypeRef source, const char *format, ...) { va_list args; va_start(args, format); - CFType result = CFType(vcfget(source, format, args)); + CFType result = CFType(vcfget(source, format, &args)); va_end(args); return (result && CFTraits::check(result)) ? result : NULL; } @@ -125,7 +128,7 @@ public: { va_list args; va_start(args, format); - this->take(CFType(vcfmake(format, args))); + this->take(CFType(vcfmake(format, &args))); va_end(args); } };