void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority);
-void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
void CtdlShutdownServiceHooks(void);
-
void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
-void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
-
void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
-void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
-
void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType);
-void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType);
-
void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *) );
-void CtdlUnregisterRoomHook(int (*fnc_ptr)(struct ctdlroom *) );
-
void CtdlRegisterDeleteHook(void (*handler)(char *, long) );
-void CtdlUnregisterDeleteHook(void (*handler)(char *, long) );
-
void CtdlRegisterCleanupHook(void (*fcn_ptr)(void));
-void CtdlUnregisterCleanupHook(void (*fcn_ptr)(void));
-
void CtdlRegisterEVCleanupHook(void (*fcn_ptr)(void));
-void CtdlUnregisterEVCleanupHook(void (*fcn_ptr)(void));
-
void CtdlRegisterProtoHook(void (*handler)(char *), char *cmd, char *desc);
-
void CtdlRegisterServiceHook(int tcp_port,
char *sockpath,
void (*h_greeting_function) (void),
void (*h_async_function) (void),
const char *ServiceName
);
-void CtdlUnregisterServiceHook(int tcp_port,
- char *sockpath,
- void (*h_greeting_function) (void),
- void (*h_command_function) (void),
- void (*h_async_function) (void)
-);
-
void CtdlRegisterFixedOutputHook(char *content_type, void (*output_function) (char *supplied_data, int len));
-void CtdlUnRegisterFixedOutputHook(char *content_type);
void CtdlRegisterMaintenanceThread(char *name, void *(*thread_proc) (void *arg));
-void CtdlRegisterSearchFuncHook(Array (*)(const char *), char *name);
/*
* if you say a) (which may take a while)
ac_internal,
};
-
-
-/*
- * API declarations from serv_extensions.h
- */
-void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name);
-
#define NODENAME CtdlGetConfigStr("c_nodename")
#define FQDN CtdlGetConfigStr("c_fqdn")
#define CREATAIDE CtdlGetConfigInt("c_creataide")
};
RoomFunctionHook *RoomHookTable = NULL;
-
-typedef struct SearchFunctionHook SearchFunctionHook;
-struct SearchFunctionHook {
- SearchFunctionHook *next;
- void (*fcn_ptr) (int *, long **, const char *);
- char *name;
-};
-SearchFunctionHook *SearchFunctionHookTable = NULL;
-
ServiceFunctionHook *ServiceHookTable = NULL;
typedef struct ProtoFunctionHook ProtoFunctionHook;
}
-void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int EventType)
-{
- SessionFunctionHook *cur, *p, *last;
- last = NULL;
- cur = SessionHookTable;
- while (cur != NULL) {
- if ((fcn_ptr == cur->h_function_pointer) &&
- (EventType == cur->eventtype))
- {
- syslog(LOG_DEBUG, "extensions: unregistered session function (type %d)", EventType);
- p = cur->next;
-
- free(cur);
- cur = NULL;
-
- if (last != NULL)
- last->next = p;
- else
- SessionHookTable = p;
- cur = p;
- }
- else {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
void CtdlRegisterUserHook(void (*fcn_ptr) (ctdluser *), int EventType)
{
}
-void CtdlUnregisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType)
-{
- UserFunctionHook *cur, *p, *last;
- last = NULL;
- cur = UserHookTable;
- while (cur != NULL) {
- if ((fcn_ptr == cur->h_function_pointer) &&
- (EventType == cur->eventtype))
- {
- syslog(LOG_DEBUG, "extensions: unregistered user function (type %d)", EventType);
- p = cur->next;
-
- free(cur);
- cur = NULL;
-
- if (last != NULL)
- last->next = p;
- else
- UserHookTable = p;
- cur = p;
- }
- else {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType)
{
}
-void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *, struct recptypes *), int EventType)
-{
- MessageFunctionHook *cur, *p, *last;
- last = NULL;
- cur = MessageHookTable;
- while (cur != NULL) {
- if ((handler == cur->h_function_pointer) &&
- (EventType == cur->eventtype))
- {
- syslog(LOG_DEBUG, "extensions: unregistered message function (type %d)", EventType);
- p = cur->next;
- free(cur);
- cur = NULL;
-
- if (last != NULL)
- last->next = p;
- else
- MessageHookTable = p;
- cur = p;
- }
- else {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
{
RoomFunctionHook *newfcn;
}
-void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
-{
- RoomFunctionHook *cur, *p, *last;
- last = NULL;
- cur = RoomHookTable;
- while (cur != NULL)
- {
- if (fcn_ptr == cur->fcn_ptr) {
- syslog(LOG_DEBUG, "extensions: unregistered room function");
- p = cur->next;
-
- free(cur);
- cur = NULL;
-
- if (last != NULL)
- last->next = p;
- else
- RoomHookTable = p;
- cur = p;
- }
- else {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
void CtdlRegisterDeleteHook(void (*handler)(char *, long) )
{
DeleteFunctionHook *newfcn;
}
-void CtdlUnregisterDeleteHook(void (*handler)(char *, long) )
-{
- DeleteFunctionHook *cur, *p, *last;
-
- last = NULL;
- cur = DeleteHookTable;
- while (cur != NULL) {
- if (handler == cur->h_function_pointer )
- {
- syslog(LOG_DEBUG, "extensions: unregistered delete function");
- p = cur->next;
- free(cur);
-
- if (last != NULL)
- last->next = p;
- else
- DeleteHookTable = p;
-
- cur = p;
- }
- else {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
void CtdlRegisterFixedOutputHook(char *content_type, void (*handler)(char *, int) )
{
FixedOutputHook *newfcn;
}
-void CtdlUnregisterFixedOutputHook(char *content_type)
-{
- FixedOutputHook *cur, *p, *last;
-
- last = NULL;
- cur = FixedOutputTable;
- while (cur != NULL) {
- /* This will also remove duplicates if any */
- if (!strcasecmp(content_type, cur->content_type)) {
- syslog(LOG_DEBUG, "extensions: unregistered fixed output function for %s", content_type);
- p = cur->next;
- free(cur);
-
- if (last != NULL)
- last->next = p;
- else
- FixedOutputTable = p;
-
- cur = p;
- }
- else
- {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
/* returns nonzero if we found a hook and used it */
int PerformFixedOutputHooks(char *content_type, char *content, int content_length)
{
}
-void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *, char *), int order)
-{
- XmsgFunctionHook *cur, *p, *last;
-
- last = NULL;
- cur = XmsgHookTable;
- while (cur != NULL) {
- /* This will also remove duplicates if any */
- if (fcn_ptr == cur->h_function_pointer &&
- order == cur->order) {
- syslog(LOG_DEBUG, "extensions: unregistered x-msg function (priority %d)", order);
- p = cur->next;
- free(cur);
-
- if (last != NULL) {
- last->next = p;
- }
- else {
- XmsgHookTable = p;
- }
- cur = p;
- }
- else {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
void CtdlRegisterServiceHook(int tcp_port,
char *sockpath,
void (*h_greeting_function) (void),
}
-void CtdlUnregisterServiceHook(int tcp_port, char *sockpath,
- void (*h_greeting_function) (void),
- void (*h_command_function) (void),
- void (*h_async_function) (void)
- )
-{
- ServiceFunctionHook *cur, *p, *last;
-
- last = NULL;
- cur = ServiceHookTable;
- while (cur != NULL) {
- /* This will also remove duplicates if any */
- if (h_greeting_function == cur->h_greeting_function &&
- h_command_function == cur->h_command_function &&
- h_async_function == cur->h_async_function &&
- tcp_port == cur->tcp_port &&
- !(sockpath && cur->sockpath && strcmp(sockpath, cur->sockpath)) )
- {
- if (cur->msock > 0)
- close(cur->msock);
- if (sockpath) {
- syslog(LOG_INFO, "extensions: closed UNIX domain socket %s", sockpath);
- unlink(sockpath);
- } else if (tcp_port) {
- syslog(LOG_INFO, "extensions: closed TCP port %d", tcp_port);
- } else {
- syslog(LOG_INFO, "extensions: unregistered service \"%s\"", cur->ServiceName);
- }
- p = cur->next;
- free(cur);
- if (last != NULL)
- last->next = p;
- else
- ServiceHookTable = p;
- cur = p;
- }
- else {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
// During shutdown we can close all of the listening sockets.
void CtdlShutdownServiceHooks(void) {
ServiceFunctionHook *cur;
}
-void CtdlRegisterSearchFuncHook(Array (*fcn_ptr)(const char *), char *name) {
- SearchFunctionHook *newfcn;
-
- if (!name || !fcn_ptr) {
- return;
- }
-
- newfcn = (SearchFunctionHook *) malloc(sizeof(SearchFunctionHook));
- newfcn->next = SearchFunctionHookTable;
- newfcn->name = name;
- newfcn->fcn_ptr = fcn_ptr;
- SearchFunctionHookTable = newfcn;
-
- syslog(LOG_DEBUG, "extensions: registered a new search function (%s)", name);
-}
-
-
-void CtdlUnregisterSearchFuncHook(void (*fcn_ptr)(int *, long **, const char *), char *name) {
- SearchFunctionHook *cur, *p, *last;
-
- last = NULL;
- cur = SearchFunctionHookTable;
- while (cur != NULL) {
- if (fcn_ptr &&
- (cur->fcn_ptr == fcn_ptr) &&
- name && !strcmp(name, cur->name))
- {
- syslog(LOG_DEBUG, "extensions: unregistered search function(%s)", name);
- p = cur->next;
- free (cur);
- if (last != NULL)
- last->next = p;
- else
- SearchFunctionHookTable = p;
- cur = p;
- }
- else {
- last = cur;
- cur = cur->next;
- }
- }
-}
-
-
-void CtdlModuleDoSearch(int *num_msgs, long **search_msgs, const char *search_string, const char *func_name) {
- SearchFunctionHook *fcn = NULL;
-
- for (fcn = SearchFunctionHookTable; fcn != NULL; fcn = fcn->next) {
- if (!func_name || !strcmp(func_name, fcn->name)) {
- (*fcn->fcn_ptr) (num_msgs, search_msgs, search_string);
- return;
- }
- }
- *num_msgs = 0;
-}
-
-
void PerformSessionHooks(int EventType) {
SessionFunctionHook *fcn = NULL;