/***************************************************************************** * ManageEventsCallback * - * This is invoked when launchd loads a event dictionary and needs to inform * us what a daemon / agent is looking for. *****************************************************************************/ static void ManageEventsCallback(UserEventAgentLaunchdAction action, CFNumberRef token, CFTypeRef eventMatchDict, void* vContext) { if (action == kUserEventAgentLaunchdAdd) { if (!eventMatchDict) { fprintf(stderr, "%s:%s empty dictionary\n", sPluginIdentifier, __FUNCTION__); return; } if (CFGetTypeID(eventMatchDict) != CFDictionaryGetTypeID()) { fprintf(stderr, "%s:%s given non-dict for event dictionary, action %d\n", sPluginIdentifier, __FUNCTION__, action); return; } // Launchd wants us to add a launch event for this token and matching dictionary. asl_log(NULL, NULL, ASL_LEVEL_INFO, "%s:%s calling AddEventToPlugin", sPluginIdentifier, __FUNCTION__); AddEventToPlugin((BonjourUserEventsPlugin*)vContext, token, (CFDictionaryRef)eventMatchDict); } else if (action == kUserEventAgentLaunchdRemove) { // Launchd wants us to remove the event hook we setup for this token / matching dictionary. // Note: eventMatchDict can be NULL for Remove. asl_log(NULL, NULL, ASL_LEVEL_INFO, "%s:%s calling RemoveEventToPlugin", sPluginIdentifier, __FUNCTION__); RemoveEventFromPlugin((BonjourUserEventsPlugin*)vContext, token); } else { asl_log(NULL, NULL, ASL_LEVEL_INFO, "%s:%s unknown callback event\n", sPluginIdentifier, __FUNCTION__); } }
/***************************************************************************** * ManageEventsCallback * - * This is invoked when launchd loads a event dictionary and needs to inform * us what a daemon / agent is looking for. *****************************************************************************/ static void ManageEventsCallback(UserEventAgentLaunchdAction action, CFNumberRef token, CFTypeRef eventMatchDict, void* vContext) { if (!eventMatchDict || CFGetTypeID(eventMatchDict) != CFDictionaryGetTypeID()) { fprintf(stderr, "%s given non-dictionary for event dictionary\n", sPluginIdentifier); return; } if (action == kUserEventAgentLaunchdAdd) { // Launchd wants us to add a launch event for this token and matching dictionary. AddEventToPlugin((BonjourUserEventsPlugin*)vContext, token, (CFDictionaryRef)eventMatchDict); } else if (action == kUserEventAgentLaunchdRemove) { // Launchd wants us to remove the event hook we setup for this token / matching dictionary. RemoveEventFromPlugin((BonjourUserEventsPlugin*)vContext, token); } else { fprintf(stderr, "%s got unknown UserEventAction: %d\n", sPluginIdentifier, action); } }