X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fserv_extensions.c;h=74eb0c5bda2ab3b117f6ecee6722da8950425195;hb=cdc34fa661ed54fdcebf86521496220cc28f4943;hp=4f2ddfa1fb38b707b2764a6340fc6834727b0fb7;hpb=5bf6670f304602919abae191ba88232d693de1ff;p=citadel.git diff --git a/citadel/serv_extensions.c b/citadel/serv_extensions.c index 4f2ddfa1f..74eb0c5bd 100644 --- a/citadel/serv_extensions.c +++ b/citadel/serv_extensions.c @@ -47,6 +47,7 @@ #endif struct CleanupFunctionHook *CleanupHookTable = NULL; +struct CleanupFunctionHook *EVCleanupHookTable = NULL; struct SessionFunctionHook *SessionHookTable = NULL; struct UserFunctionHook *UserHookTable = NULL; struct XmsgFunctionHook *XmsgHookTable = NULL; @@ -261,6 +262,7 @@ void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void)) } } + void CtdlDestroyCleanupHooks(void) { struct CleanupFunctionHook *cur, *p; @@ -276,6 +278,56 @@ void CtdlDestroyCleanupHooks(void) CleanupHookTable = NULL; } +void CtdlRegisterEVCleanupHook(void (*fcn_ptr) (void)) +{ + + struct CleanupFunctionHook *newfcn; + + newfcn = (struct CleanupFunctionHook *) + malloc(sizeof(struct CleanupFunctionHook)); + newfcn->next = EVCleanupHookTable; + newfcn->h_function_pointer = fcn_ptr; + EVCleanupHookTable = newfcn; + + syslog(LOG_INFO, "Registered a new cleanup function\n"); +} + + +void CtdlUnregisterEVCleanupHook(void (*fcn_ptr) (void)) +{ + struct CleanupFunctionHook *cur, *p; + + for (cur = EVCleanupHookTable; cur != NULL; cur = cur->next) { + /* This will also remove duplicates if any */ + while (cur != NULL && + fcn_ptr == cur->h_function_pointer) { + syslog(LOG_INFO, "Unregistered cleanup function\n"); + p = cur->next; + if (cur == EVCleanupHookTable) { + EVCleanupHookTable = p; + } + free(cur); + cur = p; + } + } +} + + +void CtdlDestroyEVCleanupHooks(void) +{ + struct CleanupFunctionHook *cur, *p; + + cur = EVCleanupHookTable; + while (cur != NULL) + { + syslog(LOG_INFO, "Destroyed cleanup function\n"); + p = cur->next; + free(cur); + cur = p; + } + EVCleanupHookTable = NULL; +} + void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType) {