+Sun Oct 11 23:17:48 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * Built some more of the message expiry infrastructure
+
1998-10-11 Nathan Bryant <bryant@cs.usm.maine.edu>
* citserver.c: fix two more overruns, one of which was preventing
the "From Host" from showing up in the <W>ho listing.
#define ROOMNAMELEN 128
/*
- * Room policy stuff
+ * Message expiration policy stuff
*/
-struct RoomPolicy {
- int rp_expire_mode;
- long rp_expire_value;
+struct ExpirePolicy {
+ int expire_mode;
+ long expire_value;
};
-#define RP_EXPIRE_NEXTLEVEL 0 /* Inherit expiration policy */
-#define RP_EXPIRE_NUMMSGS 1 /* Keep only latest n messages */
-#define RP_EXPIRE_AGE 2 /* Expire messages by age */
+#define EXPIRE_NEXTLEVEL 0 /* Inherit expiration policy */
+#define EXPIRE_MANUAL 1 /* Don't expire messages at all */
+#define EXPIRE_NUMMSGS 2 /* Keep only latest n messages */
+#define EXPIRE_AGE 3 /* Expire messages by age */
/*
char c_net_password[20]; /* system net password */
int c_port_number; /* TCP port to run the server on */
int c_ipgm_secret; /* Internal program authentication */
- struct RoomPolicy c_default_rp; /* System default room policy */
+ struct ExpirePolicy c_ep; /* System default msg expire policy */
};
#define NODENAME config.c_nodename
long QRinfo; /* Info file update relative to msgs*/
char QRfloor; /* Which floor this room is on */
time_t QRmtime; /* Date/time of last post */
- struct RoomPolicy QRroompolicy; /* Room policy */
+ struct ExpirePolicy QRep; /* Message expiration policy */
};
unsigned short f_flags; /* flags */
char f_name[256]; /* name of floor */
int f_ref_count; /* reference count */
- struct RoomPolicy f_default_rp; /* default room policy */
+ struct ExpirePolicy f_ep; /* default expiration policy */
};
#define F_INUSE 1 /* floor is in use */
}
-
/*
* Determine whether a given room is one of the base non-editable rooms
*/
else return(0);
}
+
+
+/*
+ * Retrieve the applicable room policy for a specific room
+ */
+void GetExpirePolicy(struct ExpirePolicy *epbuf, struct quickroom *qrbuf) {
+ struct floor flbuf;
+
+ /* If the room has its own policy, return it */
+ if (qrbuf->QRep.expire_mode != 0) {
+ memcpy(epbuf, &qrbuf->QRep, sizeof(struct ExpirePolicy));
+ return;
+ }
+
+ /* Otherwise, if the floor has its own policy, return it */
+ getfloor(&flbuf, qrbuf->QRfloor);
+ if (flbuf.f_ep.expire_mode != 0) {
+ memcpy(epbuf, &flbuf.f_ep, sizeof(struct ExpirePolicy));
+ return;
+ }
+
+ /* Otherwise, fall back on the system default */
+ memcpy(epbuf, &config.c_ep, sizeof(struct ExpirePolicy));
+ }
+
+
+
/*
* cmd_lrms() - List all accessible rooms, known or forgotten
*/
void ForEachRoom(void (*CallBack)(struct quickroom *EachRoom));
void assoc_file_name(char *buf, struct quickroom *qrbuf, char *prefix);
void delete_room(struct quickroom *qrbuf);
+void GetExpirePolicy(struct ExpirePolicy *epbuf, struct quickroom *qrbuf);
#include "support.h"
#include "config.h"
#include "dynloader.h"
+#include "room_ops.h"
extern struct CitContext *ContextList;
}
+
+void DoPurgeMessages(struct quickroom *qrbuf) {
+ struct ExpirePolicy epbuf;
+
+ GetExpirePolicy(&epbuf, qrbuf);
+
+ lprintf(9, "ExpirePolicy for <%s> is <%d> <%ld>\n",
+ qrbuf->QRname, epbuf.expire_mode, epbuf.expire_value);
+ }
+
+void PurgeMessages(void) {
+ ForEachRoom(DoPurgeMessages);
+ }
+
struct DLModule_Info *Dynamic_Module_Init(void)
{
CtdlRegisterCleanupHook(CleanupTest);
+ CtdlRegisterCleanupHook(PurgeMessages);
CtdlRegisterSessionHook(NewRoomTest, EVT_NEWROOM);
CtdlRegisterSessionHook(SessionStartTest, EVT_START);
CtdlRegisterSessionHook(SessionStopTest, EVT_STOP);
display_error("setup: cannot open citadel.config");
cleanup(1);
}
+/******************************************/
+/* THIS IS TEMPORARY FIX FIX FIX FIX FIX */
+ config.c_ep.expire_mode = EXPIRE_NUMMSGS;
+ config.c_ep.expire_value = 10;
+/******************************************/
fwrite((char *)&config,sizeof(struct config),1,fp);
fclose(fp);
}
NEW_INST:
config.c_setup_level = REV_LEVEL;
+
+/******************************************/
+
write_config_to_disk();
system("mkdir info 2>/dev/null"); /* Create these */
{
int oldval;
- lprintf(8, "begin_critical_section(%d)\n", which_one);
+ /* lprintf(8, "begin_critical_section(%d)\n", which_one); */
/* Don't get interrupted during the critical section */
pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldval);
{
int oldval;
- lprintf(8, " end_critical_section(%d)\n", which_one);
+ /* lprintf(8, " end_critical_section(%d)\n", which_one); */
/* Let go of the semaphore */
pthread_mutex_unlock(&Critters[which_one]);