struct DeleteFunctionHook *DeleteHookTable = NULL;
struct ServiceFunctionHook *ServiceHookTable = NULL;
struct FixedOutputHook *FixedOutputTable = NULL;
+struct RoomFunctionHook *RoomHookTable = NULL;
+
struct ProtoFunctionHook {
void (*handler) (char *cmdbuf);
}
+void CtdlRegisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
+{
+ struct RoomFunctionHook *newfcn;
+
+ newfcn = (struct RoomFunctionHook *)
+ malloc(sizeof(struct RoomFunctionHook));
+ newfcn->next = RoomHookTable;
+ newfcn->fcn_ptr = fcn_ptr;
+ RoomHookTable = newfcn;
+
+ lprintf(CTDL_INFO, "Registered a new room function\n");
+}
+
+
+void CtdlUnregisterRoomHook(int (*fcn_ptr)(struct ctdlroom *))
+{
+ struct RoomFunctionHook *cur, *p;
+
+ for (cur = RoomHookTable; cur != NULL; cur = cur->next) {
+ while (cur != NULL && fcn_ptr == cur->fcn_ptr) {
+ lprintf(CTDL_INFO, "Unregistered room function\n");
+ p = cur->next;
+ if (cur == RoomHookTable) {
+ RoomHookTable = p;
+ }
+ free(cur);
+ cur = p;
+ }
+ }
+}
+
+
+void CtdlDestroyRoomHooks(void)
+{
+ struct RoomFunctionHook *cur, *p;
+
+ cur = RoomHookTable;
+ while (cur != NULL)
+ {
+ lprintf(CTDL_INFO, "Unregistered room function\n");
+ p = cur->next;
+ free(cur);
+ cur = p;
+ }
+ RoomHookTable = NULL;
+}
+
void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) )
{
struct NetprocFunctionHook *newfcn;
}
+int PerformRoomHooks(struct ctdlroom *target_room)
+{
+ struct RoomFunctionHook *fcn;
+ int total_retval = 0;
+
+ lprintf(CTDL_DEBUG, "Performing room hooks\n");
+
+ for (fcn = RoomHookTable; fcn != NULL; fcn = fcn->next) {
+ total_retval = total_retval +
+ (*fcn->fcn_ptr) (target_room);
+ }
+
+ /* Return the sum of the return codes from the hook functions.
+ */
+ return total_retval;
+}
+
int PerformNetprocHooks(struct CtdlMessage *msg, char *target_room)
{