X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Finclude%2Fctdl_module.h;h=3525504a8eaec726f3f208094e850e029837ada4;hb=1e6f5260bcc5c5a8f2d6ec5e0d164b84ac1ad893;hp=9b7f8e2f96ae460f671a8cddfb8c39561987abfb;hpb=bcbaf2800c778043c12f9fd2d719ca9271ac6cb4;p=citadel.git diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h index 9b7f8e2f9..3525504a8 100644 --- a/citadel/include/ctdl_module.h +++ b/citadel/include/ctdl_module.h @@ -45,12 +45,6 @@ #endif #include - -#ifndef HAVE_SNPRINTF -#include "snprintf.h" -#endif - - #include #include "server.h" @@ -72,7 +66,29 @@ #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. */ @@ -210,6 +226,9 @@ long CtdlGetCurrentMessageNumber(void); /* * Expose various room operation functions from room_ops.c to the modules API */ +typedef struct CfgLineType CfgLineType; +typedef struct RoomNetCfgLine RoomNetCfgLine; +typedef struct OneRoomNetCfg OneRoomNetCfg; unsigned CtdlCreateRoom(char *new_room_name, int new_room_type, @@ -224,8 +243,13 @@ int CtdlDoIHavePermissionToDeleteThisRoom(struct ctdlroom *qr); void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf, int *result, int *view); void CtdlPutRoomLock(struct ctdlroom *qrbuf); -void CtdlForEachRoom(void (*CallBack)(struct ctdlroom *EachRoom, void *out_data), - void *in_data); +typedef void (*ForEachRoomCallBack)(struct ctdlroom *EachRoom, void *out_data); +void CtdlForEachRoom(ForEachRoomCallBack CB, void *in_data); +typedef void (*ForEachRoomNetCfgCallBack)(struct ctdlroom *EachRoom, void *out_data, const OneRoomNetCfg *OneRNCFG); +void CtdlForEachNetCfgRoom(ForEachRoomNetCfgCallBack CB, + void *in_data, + RoomNetCfg filter); + void CtdlDeleteRoom(struct ctdlroom *qrbuf); int CtdlRenameRoom(char *old_name, char *new_name, int new_floor); void CtdlUserGoto (char *where, int display_result, int transiently, @@ -362,6 +386,87 @@ struct config { extern struct config config; +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; + int nSegments; +}; + +struct RoomNetCfgLine { + RoomNetCfgLine *next; + int nValues; + StrBuf **Value; +}; + +struct OneRoomNetCfg { + long lastsent; + StrBuf *Sender; + StrBuf *RoomInfo; + RoomNetCfgLine *NetConfigs[maxRoomNetCfg]; + StrBuf *misc; +}; + + +#define CtdlREGISTERRoomCfgType(a, p, uniq, nSegs, s, d) RegisterRoomCfgType(#a, sizeof(#a) - 1, a, p, uniq, nSegs, s, d); +void RegisterRoomCfgType(const char* Name, long len, RoomNetCfg eCfg, CfgLineParser p, int uniq, int nSegments, 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); + +const OneRoomNetCfg* CtdlGetNetCfgForRoom(long QRNumber); + +typedef struct _nodeconf { + int DeleteMe; + StrBuf *NodeName; + StrBuf *Secret; + StrBuf *Host; + StrBuf *Port; +}CtdlNodeConf; + +HashList* CtdlLoadIgNetCfg(void); + + +int CtdlNetconfigCheckRoomaccess(char *errmsgbuf, + size_t n, + const char* RemoteIdentifier); + + +typedef struct __NetMap { + StrBuf *NodeName; + time_t lastcontact; + StrBuf *NextHop; +}CtdlNetMap; + +HashList* CtdlReadNetworkMap(void); +StrBuf *CtdlSerializeNetworkMap(HashList *Map); +void NetworkLearnTopology(char *node, char *path, HashList *the_netmap, int *netmap_changed); +int CtdlIsValidNode(const StrBuf **nexthop, + const StrBuf **secret, + StrBuf *node, + HashList *IgnetCfg, + HashList *the_netmap); + + + + +int CtdlNetworkTalkingTo(const char *nodename, long len, int operation); + +/* + * Operations that can be performed by network_talking_to() + */ +enum { + NTT_ADD, + NTT_REMOVE, + NTT_CHECK +}; /* * Expose API calls from user_ops.c