void CtdlUnregisterProtoHook(void (*handler) (char *), char *cmd)
{
- struct ProtoFunctionHook *cur, *p;
+ struct ProtoFunctionHook *cur, *p, *lastcur;
- for (cur = ProtoHookList; cur != NULL; cur = cur->next) {
+ for (cur = ProtoHookList;
+ cur != NULL;
+ cur = (cur != NULL)? cur->next: NULL) {
/* This will also remove duplicates if any */
while (cur != NULL &&
handler == cur->handler &&
if (cur == ProtoHookList) {
ProtoHookList = p;
}
+ else if (lastcur != NULL)
+ {
+ lastcur->next = p;
+ }
free(cur);
cur = p;
}
+ lastcur = cur;
+ }
+}
+
+void CtdlDestroyProtoHooks(void)
+{
+ struct ProtoFunctionHook *cur, *p;
+
+ cur = ProtoHookList;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed server command %s (%s)\n",
+ cur->cmd, cur->desc);
+ p = cur->next;
+ free(cur);
+ cur = p;
}
+ ProtoHookList = NULL;
}
}
}
+void CtdlDestroyCleanupHooks(void)
+{
+ struct CleanupFunctionHook *cur, *p;
+
+ cur = CleanupHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed cleanup function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ CleanupHookTable = NULL;
+}
+
void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType)
{
}
}
+void CtdlDestroySessionHooks(void)
+{
+ struct SessionFunctionHook *cur, *p;
+
+ cur = SessionHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed session function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ SessionHookTable = NULL;
+}
+
void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
{
}
}
+void CtdlDestroyUserHooks(void)
+{
+ struct UserFunctionHook *cur, *p;
+
+ cur = UserHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed user function \n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ UserHookTable = NULL;
+}
+
void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
int EventType)
}
}
+void CtdlDestroyMessageHook(void)
+{
+ struct MessageFunctionHook *cur, *p;
+
+ cur = MessageHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed message function \n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ MessageHookTable = NULL;
+}
+
void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
{
}
}
+void CtdlDestroyNetprocHooks(void)
+{
+ struct NetprocFunctionHook *cur, *p;
+
+ cur = NetprocHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Unregistered netproc function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ NetprocHookTable = NULL;
+}
+
void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
{
}
}
}
+void CtdlDestroyDeleteHooks(void)
+{
+ struct DeleteFunctionHook *cur, *p;
+
+ cur = DeleteHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed netproc function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ DeleteHookTable = NULL;
+}
}
}
+void CtdlDestroyFixedOutputHooks(void)
+{
+ struct FixedOutputHook *cur, *p;
+
+ cur = FixedOutputTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed fixed output function for %s\n", cur->content_type);
+ p = cur->next;
+ free(cur);
+ cur = p;
+
+ }
+ FixedOutputTable = NULL;
+}
+
/* returns nonzero if we found a hook and used it */
int PerformFixedOutputHooks(char *content_type, char *content, int content_length)
{
}
}
+void CtdlDestroyXmsgHooks(void)
+{
+ struct XmsgFunctionHook *cur, *p;
+
+ cur = XmsgHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Destroyed x-msg function "
+ "(priority %d)\n", cur->order);
+ p = cur->next;
+
+ free(cur);
+ cur = p;
+ }
+ XmsgHookTable = NULL;
+}
+
void CtdlRegisterServiceHook(int tcp_port,
char *sockpath,
}
else if (tcp_port <= 0) { /* port -1 to disable */
lprintf(CTDL_INFO, "Service has been manually disabled, skipping\n");
+ free (message);
free(newfcn);
return;
}
AddPortError(message, error);
strcat(message, "FAILED.");
lprintf(CTDL_CRIT, "%s\n", message);
+ free (message);
free(error);
free(newfcn);
}
}
}
+void CtdlDestroyServiceHook(void)
+{
+ struct ServiceFunctionHook *cur, *p;
+
+ cur = ServiceHookTable;
+ while (cur != NULL)
+ {
+ close(cur->msock);
+ if (cur->sockpath) {
+ lprintf(CTDL_INFO, "Closed UNIX domain socket %s\n",
+ cur->sockpath);
+ } else if (cur->tcp_port) {
+ lprintf(CTDL_INFO, "Closed TCP port %d\n", cur->tcp_port);
+ } else {
+ lprintf(CTDL_INFO, "Unregistered unknown service\n");
+ }
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ ServiceHookTable = NULL;
+}
+
void PerformSessionHooks(int EventType)
{