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