17 #include "sysdep_decls.h"
18 #include "citserver.h"
21 #include "dynloader.h"
25 extern struct CitContext *ContextList;
27 #define MODULE_NAME "Dummy test module"
28 #define MODULE_AUTHOR "Art Cancro"
29 #define MODULE_EMAIL "ajc@uncnsrd.mt-kisco.ny.us"
30 #define MAJOR_VERSION 0
31 #define MINOR_VERSION 3
33 static struct DLModule_Info info = {
41 void CleanupTest(void) {
42 lprintf(9, "--- test of adding an unload hook --- \n");
45 void NewRoomTest(void) {
46 lprintf(9, "--- test module was told we're now in %s ---\n",
50 void SessionStartTest(void) {
51 lprintf(9, "--- starting up session %d ---\n",
55 void SessionStopTest(void) {
56 lprintf(9, "--- ending session %d ---\n",
60 void LoginTest(void) {
61 lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
65 void Ygorl(char *username, long usernum) {
66 if (!strcasecmp(username, "Hexslinger")) {
67 strcpy(username, "Flaming Asshole");
73 void DoPurgeMessages(struct quickroom *qrbuf) {
74 struct ExpirePolicy epbuf;
77 GetExpirePolicy(&epbuf, qrbuf);
79 lprintf(9, "ExpirePolicy for <%s> is <%d> <%d>\n",
80 qrbuf->QRname, epbuf.expire_mode, epbuf.expire_value);
82 /* If the room is set to never expire messages ... do nothing */
83 if (epbuf.expire_mode == EXPIRE_NEXTLEVEL) return;
84 if (epbuf.expire_mode == EXPIRE_MANUAL) return;
88 /* Nothing to do if there aren't any messages */
89 if (CC->num_msgs == 0) return;
91 /* If the room is set to expire by count, do that */
92 if (epbuf.expire_mode == EXPIRE_NUMMSGS) {
93 while (CC->num_msgs > epbuf.expire_value) {
94 delnum = MessageFromList(0);
95 lprintf(5, "Expiring message %ld\n", delnum);
96 cdb_delete(CDB_MSGMAIN, &delnum, sizeof(long));
97 memcpy(&CC->msglist[0], &CC->msglist[1],
98 (sizeof(long)*(CC->num_msgs - 1)));
99 CC->num_msgs = CC->num_msgs - 1;
103 /* If the room is set to expire by age... FIX (write this!!) (/
104 if (epbuf.expire_mode == EXPIRE_AGE) {
110 void PurgeMessages(void) {
111 ForEachRoom(DoPurgeMessages);
114 struct DLModule_Info *Dynamic_Module_Init(void)
116 CtdlRegisterCleanupHook(CleanupTest);
117 CtdlRegisterCleanupHook(PurgeMessages);
118 CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
119 CtdlRegisterSessionHook(SessionStartTest, EVT_START);
120 CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
121 CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
122 CtdlRegisterUserHook(Ygorl, EVT_OUTPUTMSG);