X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fserv_extensions.c;h=b03741e7a02a90a42c611c412f87c4f03eb18136;hb=bcbaf2800c778043c12f9fd2d719ca9271ac6cb4;hp=a742c619167297ad82531e253936ac27b363696e;hpb=1e62641ed3334a62c2bd58c537cc2a3eb75653f0;p=citadel.git diff --git a/citadel/serv_extensions.c b/citadel/serv_extensions.c index a742c6191..b03741e7a 100644 --- a/citadel/serv_extensions.c +++ b/citadel/serv_extensions.c @@ -87,6 +87,7 @@ extern FixedOutputHook *FixedOutputTable; typedef struct SessionFunctionHook SessionFunctionHook; struct SessionFunctionHook { SessionFunctionHook *next; + int Priority; void (*h_function_pointer) (void); int eventtype; }; @@ -595,20 +596,28 @@ void CtdlDestroyEVCleanupHooks(void) } -void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType) +void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType, int Priority) { - SessionFunctionHook *newfcn; newfcn = (SessionFunctionHook *) malloc(sizeof(SessionFunctionHook)); - newfcn->next = SessionHookTable; + newfcn->Priority = Priority; newfcn->h_function_pointer = fcn_ptr; newfcn->eventtype = EventType; - SessionHookTable = newfcn; - MOD_syslog(LOG_DEBUG, "Registered a new session function (type %d)\n", - EventType); + SessionFunctionHook **pfcn; + pfcn = &SessionHookTable; + while ((*pfcn != NULL) && + ((*pfcn)->Priority < newfcn->Priority) && + ((*pfcn)->next != NULL)) + pfcn = &(*pfcn)->next; + + newfcn->next = *pfcn; + *pfcn = newfcn; + + MOD_syslog(LOG_DEBUG, "Registered a new session function (type %d Priority %d)\n", + EventType, Priority); }