]> code.citadel.org Git - citadel.git/commitdiff
Built some more of the message expiry infrastructure
authorArt Cancro <ajc@citadel.org>
Mon, 12 Oct 1998 03:18:17 +0000 (03:18 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 12 Oct 1998 03:18:17 +0000 (03:18 +0000)
citadel/ChangeLog
citadel/citadel.h
citadel/room_ops.c
citadel/room_ops.h
citadel/serv_test.c
citadel/setup.c
citadel/sysdep.c

index 05268207a33ebd8c311f83b29a6b79e5a72140b9..995cec03be8ea82296a44872b0be1b2ca3f6a63a 100644 (file)
@@ -1,3 +1,6 @@
+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.
index ae1610b7eaa8fce38903285e14b12cc2fa686206..483e7a145e8bad5e4f08315165a682921cb01c33 100644 (file)
@@ -30,16 +30,17 @@ typedef unsigned char CIT_UBYTE;
 #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       */
 
 
 /* 
@@ -69,7 +70,7 @@ struct config {
        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
@@ -139,7 +140,7 @@ struct quickroom {
        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        */
        };
 
 
@@ -189,7 +190,7 @@ struct floor {
        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 */
index 46700e2f73db86da93733ecd2389dc11f757f0a2..fc88de813d5b095b83249a165e481a0dd1440125 100644 (file)
@@ -383,7 +383,6 @@ int sort_msglist(long listptrs[], int oldcount)
        }
 
 
-
 /*
  * Determine whether a given room is one of the base non-editable rooms
  */
@@ -393,6 +392,33 @@ int is_noneditable(struct quickroom *qrbuf) {
        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
  */
index 76514af017b2c739933750ec26eea4002be06d43..6caffbb33ba7f158b114fd26a63340d4e3ac59dc 100644 (file)
@@ -45,3 +45,4 @@ void cmd_eflr (char *argbuf);
 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);
index dc7915a599b0de295543fd38c0efd02d60e97863..4ce9e839034ed834a12dae36db6674e950834ba6 100644 (file)
@@ -19,6 +19,7 @@
 #include "support.h"
 #include "config.h"
 #include "dynloader.h"
+#include "room_ops.h"
 
 extern struct CitContext *ContextList;
 
@@ -67,9 +68,24 @@ void Ygorl(char *username, long usernum) {
        }
 
 
+
+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);
index 80f6b18bf18bbb00e5afc48de58adb4862ca77d5..1a09e708e8de23efa54ba952e3f7a67a6e2902de 100644 (file)
@@ -825,6 +825,11 @@ void write_config_to_disk(void) {
                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);
        }
@@ -1023,6 +1028,9 @@ int main(int argc, char *argv[]) {
 
 NEW_INST:
        config.c_setup_level = REV_LEVEL;
+
+/******************************************/
+
        write_config_to_disk();
 
        system("mkdir info 2>/dev/null");               /* Create these */
index 93cfa8e2679da4012b2f0b1f0c2c55484d6da369..4ea3d9b2a5644556d6ceb6f0a5824f8a513a35f1 100644 (file)
@@ -115,7 +115,7 @@ void begin_critical_section(int which_one)
 {
        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);
@@ -132,7 +132,7 @@ void end_critical_section(int which_one)
 {
        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]);