1*fdd8201dSApple OSS Distributions #include <libkern/libkern.h> 2*fdd8201dSApple OSS Distributions #include <libkern/section_keywords.h> 3*fdd8201dSApple OSS Distributions #include <libkern/apple_encrypted_archive/apple_encrypted_archive.h> 4*fdd8201dSApple OSS Distributions 5*fdd8201dSApple OSS Distributions #if defined(SECURITY_READ_ONLY_LATE) 6*fdd8201dSApple OSS Distributions SECURITY_READ_ONLY_LATE(const apple_encrypted_archive_t *) apple_encrypted_archive = NULL; 7*fdd8201dSApple OSS Distributions SECURITY_READ_ONLY_LATE(registration_callback_t) registration_callback = NULL; 8*fdd8201dSApple OSS Distributions #else 9*fdd8201dSApple OSS Distributions const apple_encrypted_archive_t *apple_encrypted_archive = NULL; 10*fdd8201dSApple OSS Distributions registration_callback_t registration_callback = NULL; 11*fdd8201dSApple OSS Distributions #endif 12*fdd8201dSApple OSS Distributions 13*fdd8201dSApple OSS Distributions void apple_encrypted_archive_interface_register(const apple_encrypted_archive_t * aea)14*fdd8201dSApple OSS Distributionsapple_encrypted_archive_interface_register(const apple_encrypted_archive_t *aea) 15*fdd8201dSApple OSS Distributions { 16*fdd8201dSApple OSS Distributions if (apple_encrypted_archive) { 17*fdd8201dSApple OSS Distributions panic("apple_encrypted_archive interface already set"); 18*fdd8201dSApple OSS Distributions } 19*fdd8201dSApple OSS Distributions 20*fdd8201dSApple OSS Distributions apple_encrypted_archive = aea; 21*fdd8201dSApple OSS Distributions 22*fdd8201dSApple OSS Distributions if (registration_callback) { 23*fdd8201dSApple OSS Distributions registration_callback(); 24*fdd8201dSApple OSS Distributions } 25*fdd8201dSApple OSS Distributions } 26*fdd8201dSApple OSS Distributions 27*fdd8201dSApple OSS Distributions void apple_encrypted_archive_interface_set_registration_callback(registration_callback_t callback)28*fdd8201dSApple OSS Distributionsapple_encrypted_archive_interface_set_registration_callback(registration_callback_t callback) 29*fdd8201dSApple OSS Distributions { 30*fdd8201dSApple OSS Distributions if (callback && registration_callback) { 31*fdd8201dSApple OSS Distributions panic("apple_encrypted_archive interface registration callback is already set"); 32*fdd8201dSApple OSS Distributions } 33*fdd8201dSApple OSS Distributions 34*fdd8201dSApple OSS Distributions registration_callback = callback; 35*fdd8201dSApple OSS Distributions } 36