#include <dirent.h>
#include <strings.h>
#include <syslog.h>
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
#include <limits.h>
#include <ctype.h>
#include "citadel.h"
#include "sysdep_decls.h"
#include "msgbase.h"
#include "tools.h"
+#include "config.h"
#ifndef HAVE_SNPRINTF
#include <stdarg.h>
struct UserFunctionHook *UserHookTable = NULL;
struct XmsgFunctionHook *XmsgHookTable = NULL;
struct MessageFunctionHook *MessageHookTable = NULL;
+struct ServiceFunctionHook *ServiceHookTable = NULL;
struct ProtoFunctionHook {
void (*handler) (char *cmdbuf);
lprintf(5, "Registered a new x-msg function (priority %d)\n", order);
}
+void CtdlRegisterServiceHook(int tcp_port,
+ void (*h_greeting_function) (void),
+ void (*h_command_function) (void) )
+{
+ struct ServiceFunctionHook *newfcn;
+
+ newfcn = (struct ServiceFunctionHook *)
+ mallok(sizeof(struct ServiceFunctionHook));
+ newfcn->next = ServiceHookTable;
+ newfcn->tcp_port = tcp_port;
+ newfcn->h_greeting_function = h_greeting_function;
+ newfcn->h_command_function = h_command_function;
+ newfcn->msock = ig_tcp_server(tcp_port, config.c_maxsessions);
+
+ if (newfcn->msock >= 0) {
+ ServiceHookTable = newfcn;
+ lprintf(5, "Registered a new service (TCP port %d)\n",
+ tcp_port);
+ }
+ else {
+ lprintf(2, "ERROR: could not bind to TCP port %d.\n",
+ tcp_port);
+ phree(newfcn);
+ }
+}
+
+
void PerformSessionHooks(int EventType)
{