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