NETCFG: move netconfig parser into its own file.
[citadel.git] / citadel / include / ctdl_module.h
index 15a03a521d5ac61793b1f9cfedd9d746643d9e20..eddcbeffcc92df2cfe961eb23cb9001200a8518b 100644 (file)
 #endif
 #include <limits.h>
 
-
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif
-
-
 #include <libcitadel.h>
 
 #include "server.h"
 
 #define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
 
-#define CtdlAideMessage(TEXT, SUBJECT) quickie_message("Citadel",NULL,NULL,AIDEROOM,TEXT,FMT_CITADEL,SUBJECT) 
+#define CtdlAideMessage(TEXT, SUBJECT)         \
+       quickie_message(                        \
+               "Citadel",                      \
+               NULL,                           \
+               NULL,                           \
+               AIDEROOM,                       \
+               TEXT,                           \
+               FMT_CITADEL,                    \
+               SUBJECT) 
+
+
+#define CtdlAideFPMessage(TEXT, SUBJECT, N, STR, STRLEN) \
+       flood_protect_quickie_message(                   \
+               "Citadel",                               \
+               NULL,                                    \
+               NULL,                                    \
+               AIDEROOM,                                \
+               TEXT,                                    \
+               FMT_CITADEL,                             \
+               SUBJECT,                                 \
+               N,                                       \
+               STR,                                     \
+               STRLEN)
 /*
  * Hook functions available to modules.
  */
-
-void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType);
+/* Priorities for  */
+#define PRIO_QUEUE 500
+#define PRIO_AGGR 1000
+#define PRIO_SEND 1500
+#define PRIO_CLEANUP 2000
+/* Priorities for EVT_HOUSE */
+#define PRIO_HOUSE 3000
+/* Priorities for EVT_LOGIN */
+#define PRIO_CREATE 10000
+/* Priorities for EVT_LOGOUT */
+#define PRIO_LOGOUT 15000
+/* Priorities for EVT_LOGIN */
+#define PRIO_LOGIN 20000
+/* Priorities for EVT_START */
+#define PRIO_START 25000
+/* Priorities for EVT_STOP */
+#define PRIO_STOP 30000
+/* Priorities for EVT_ASYNC */
+#define PRIO_ASYNC 35000
+/* Priorities for EVT_SHUTDOWN */
+#define PRIO_SHUTDOWN 40000
+/* Priorities for EVT_UNSTEALTH */
+#define PRIO_UNSTEALTH 45000
+/* Priorities for EVT_STEALTH */
+#define PRIO_STEALTH 50000
+void CtdlRegisterSessionHook(void (*fcn_ptr)(void), int EventType, int Priority);
 void CtdlUnregisterSessionHook(void (*fcn_ptr)(void), int EventType);
 void CtdlShutdownServiceHooks(void);
 
@@ -104,6 +144,9 @@ 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,
@@ -335,6 +378,45 @@ struct config {
 extern struct config config;
 
 
+typedef struct CfgLineType CfgLineType;
+typedef struct RoomNetCfgLine RoomNetCfgLine;
+typedef struct OneRoomNetCfg OneRoomNetCfg;
+
+typedef void (*CfgLineParser)(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *rncfg);
+typedef void (*CfgLineSerializer)(const CfgLineType *ThisOne, StrBuf *OuptputBuffer, OneRoomNetCfg *rncfg, RoomNetCfgLine *data);
+typedef void (*CfgLineDeAllocator)(const CfgLineType *ThisOne, RoomNetCfgLine **data);
+
+struct CfgLineType {
+       RoomNetCfg C;
+       CfgLineParser Parser;
+       CfgLineSerializer Serializer;
+       CfgLineDeAllocator DeAllocator;
+       ConstStr Str;
+       int IsSingleLine;
+};
+
+struct RoomNetCfgLine {
+       RoomNetCfgLine *next;
+       StrBuf *Value;
+};
+
+struct OneRoomNetCfg {
+       long lastsent;
+       StrBuf *Sender;
+       StrBuf *RoomInfo;
+       RoomNetCfgLine *NetConfigs[maxRoomNetCfg];
+       StrBuf *misc;
+};
+
+
+#define CtdlREGISTERRoomCfgType(a, p, uniq, s, d) RegisterRoomCfgType(#a, sizeof(#a) - 1, a, p, uniq, s, d);
+void RegisterRoomCfgType(const char* Name, long len, RoomNetCfg eCfg, CfgLineParser p, int uniq, CfgLineSerializer s, CfgLineDeAllocator d);
+void ParseGeneric(const CfgLineType *ThisOne, StrBuf *Line, const char *LinePos, OneRoomNetCfg *sc);
+void SerializeGeneric(const CfgLineType *ThisOne, StrBuf *OutputBuffer, OneRoomNetCfg *sc, RoomNetCfgLine *data);
+void DeleteGenericCfgLine(const CfgLineType *ThisOne, RoomNetCfgLine **data);
+
+
+
 
 /*
  * Expose API calls from user_ops.c