]> git.saurik.com Git - apple/security.git/blobdiff - OSX/codesign_tests/main.c
Security-57336.1.9.tar.gz
[apple/security.git] / OSX / codesign_tests / main.c
diff --git a/OSX/codesign_tests/main.c b/OSX/codesign_tests/main.c
new file mode 100644 (file)
index 0000000..8f8960e
--- /dev/null
@@ -0,0 +1,33 @@
+//
+//  Copyright (c) 2011 Apple. All rights reserved.
+//
+
+#include <Security/Security.h>
+#include <Security/SecTask.h>
+#include <stdio.h>
+#include <err.h>
+
+int main (int argc, const char * argv[])
+{
+       long num = 1000;
+
+       while (num-- > 0) {
+               SecTaskRef secTask = SecTaskCreateFromSelf(NULL);
+               if (secTask == NULL)
+                       errx(1, "SecTaskCreateFromSelf");
+
+               CFErrorRef error = NULL;
+               CFTypeRef value = SecTaskCopyValueForEntitlement(secTask, CFSTR("com.apple.security.some-entitlement"), &error);
+               if (value == NULL)
+                       errx(1, "SecTaskCopyValueForEntitlement");
+
+               if (num == 1)
+                       CFShow(value);
+
+               CFRelease(value);
+               CFRelease(secTask);
+       }
+
+       return 0;
+}
+