19 #include "sysdep_decls.h"
20 #include "citserver.h"
23 #include "dynloader.h"
29 extern struct CitContext *ContextList;
31 #define MODULE_NAME "Dummy test module"
32 #define MODULE_AUTHOR "Art Cancro"
33 #define MODULE_EMAIL "ajc@uncnsrd.mt-kisco.ny.us"
34 #define MAJOR_VERSION 0
35 #define MINOR_VERSION 3
37 static struct DLModule_Info info = {
45 void CleanupTest(void) {
46 lprintf(9, "--- test of adding an unload hook --- \n");
49 void NewRoomTest(void) {
50 lprintf(9, "--- test module was told we're now in %s ---\n",
54 void SessionStartTest(void) {
55 lprintf(9, "--- starting up session %d ---\n",
59 void SessionStopTest(void) {
60 lprintf(9, "--- ending session %d ---\n",
64 void LoginTest(void) {
65 lprintf(9, "--- Hello, %s ---\n", CC->curr_user);
69 void Ygorl(char *username, long usernum) {
70 if (!strcasecmp(username, "Hexslinger")) {
71 strcpy(username, "Flaming Asshole");
77 void DoPurgeMessages(struct quickroom *qrbuf) {
78 struct ExpirePolicy epbuf;
85 GetExpirePolicy(&epbuf, qrbuf);
87 /* lprintf(9, "ExpirePolicy for <%s> is <%d> <%d>\n",
88 qrbuf->QRname, epbuf.expire_mode, epbuf.expire_value);
91 /* If the room is set to never expire messages ... do nothing */
92 if (epbuf.expire_mode == EXPIRE_NEXTLEVEL) return;
93 if (epbuf.expire_mode == EXPIRE_MANUAL) return;
97 /* Nothing to do if there aren't any messages */
98 if (CC->num_msgs == 0) return;
100 /* If the room is set to expire by count, do that */
101 if (epbuf.expire_mode == EXPIRE_NUMMSGS) {
102 while (CC->num_msgs > epbuf.expire_value) {
103 delnum = MessageFromList(0);
104 lprintf(5, "Expiring message %ld\n", delnum);
105 cdb_delete(CDB_MSGMAIN, &delnum, sizeof(long));
106 memcpy(&CC->msglist[0], &CC->msglist[1],
107 (sizeof(long)*(CC->num_msgs - 1)));
108 CC->num_msgs = CC->num_msgs - 1;
112 /* If the room is set to expire by age... */
113 if (epbuf.expire_mode == EXPIRE_AGE) {
114 for (a=0; a<(CC->num_msgs); ++a) {
115 delnum = MessageFromList(a);
116 sprintf(msgid, "%ld", delnum);
117 xtime = output_message(msgid, MT_DATE, 0, 0);
120 && (now - xtime > (time_t)(epbuf.expire_value * 86400L))) {
121 cdb_delete(CDB_MSGMAIN, &delnum, sizeof(long));
122 SetMessageInList(a, 0L);
123 lprintf(5, "Expiring message %ld\n", delnum);
127 CC->num_msgs = sort_msglist(CC->msglist, CC->num_msgs);
131 void PurgeMessages(void) {
132 ForEachRoom(DoPurgeMessages);
135 struct DLModule_Info *Dynamic_Module_Init(void)
137 CtdlRegisterCleanupHook(CleanupTest);
138 CtdlRegisterCleanupHook(PurgeMessages);
139 CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
140 CtdlRegisterSessionHook(SessionStartTest, EVT_START);
141 CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
142 CtdlRegisterSessionHook(LoginTest, EVT_LOGIN);
143 CtdlRegisterUserHook(Ygorl, EVT_OUTPUTMSG);