From: Art Cancro Date: Sat, 24 Oct 1998 00:12:05 +0000 (+0000) Subject: policy.c: added, moved GetExpirePolicy() from room_ops.c X-Git-Tag: v7.86~8241 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=54b66cb2b73d38de9541d87960270d526e6557d8;p=citadel.git policy.c: added, moved GetExpirePolicy() from room_ops.c --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index bd9217910..449a2de75 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,6 +1,7 @@ Fri Oct 23 19:34:38 EDT 1998 Art Cancro * setup.c: default node name is now obtained from uname() * config.c: added put_config() + * policy.c: added, moved GetExpirePolicy() from room_ops.c Wed Oct 21 22:24:48 EDT 1998 Art Cancro * Mail rooms now hide their owner-prefix from the client. diff --git a/citadel/Makefile.in b/citadel/Makefile.in index 6e9709a58..2b64808aa 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -58,12 +58,12 @@ netpoll: netpoll.o config.o ipc_c_tcp.o citserver: citserver.ro user_ops.ro support.ro room_ops.ro file_ops.ro \ msgbase.ro config.ro sysdep.ro locate_host.ro \ housekeeping.ro database.ro control.ro logging.ro \ - dynloader.ro $(SNPRINTF:.o=.ro) + policy.ro dynloader.ro $(SNPRINTF:.o=.ro) $(CC) \ citserver.ro user_ops.ro room_ops.ro file_ops.ro support.ro \ msgbase.ro config.ro sysdep.ro locate_host.ro \ housekeeping.ro database.ro control.ro logging.ro \ - dynloader.ro $(SNPRINTF:.o=.ro)\ + policy.ro dynloader.ro $(SNPRINTF:.o=.ro)\ $(LDFLAGS) $(SERVER_LDFLAGS) $(LIBS) -o citserver %.ro: %.c diff --git a/citadel/citadel.h b/citadel/citadel.h index 483e7a145..c82702d1c 100644 --- a/citadel/citadel.h +++ b/citadel/citadel.h @@ -34,13 +34,13 @@ typedef unsigned char CIT_UBYTE; */ struct ExpirePolicy { int expire_mode; - long expire_value; + int expire_value; }; #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 */ +#define EXPIRE_AGE 3 /* Expire messages after n days */ /* diff --git a/citadel/policy.c b/citadel/policy.c new file mode 100644 index 000000000..9ca62e5f1 --- /dev/null +++ b/citadel/policy.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "citadel.h" +#include "server.h" +#include "database.h" +#include "config.h" +#include "room_ops.h" +#include "sysdep_decls.h" +#include "support.h" +#include "user_ops.h" +#include "msgbase.h" +#include "serv_chat.h" +#include "citserver.h" + + +/* + * Retrieve the applicable expire 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)); + } + + diff --git a/citadel/policy.h b/citadel/policy.h new file mode 100644 index 000000000..2c019f851 --- /dev/null +++ b/citadel/policy.h @@ -0,0 +1 @@ +void GetExpirePolicy(struct ExpirePolicy *epbuf, struct quickroom *qrbuf); diff --git a/citadel/room_ops.c b/citadel/room_ops.c index fe722e782..9b2f3d6b0 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -435,30 +435,6 @@ int is_noneditable(struct quickroom *qrbuf) { -/* - * 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)); - } - - /* * Back-back-end for all room listing commands */ diff --git a/citadel/room_ops.h b/citadel/room_ops.h index a1305cb45..d89a95206 100644 --- a/citadel/room_ops.h +++ b/citadel/room_ops.h @@ -46,5 +46,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); void list_roomname(struct quickroom *qrbuf); diff --git a/citadel/serv_test.c b/citadel/serv_test.c index b02fec444..81f000fae 100644 --- a/citadel/serv_test.c +++ b/citadel/serv_test.c @@ -28,15 +28,15 @@ extern struct CitContext *ContextList; #define MODULE_AUTHOR "Art Cancro" #define MODULE_EMAIL "ajc@uncnsrd.mt-kisco.ny.us" #define MAJOR_VERSION 0 -#define MINOR_VERSION 2 +#define MINOR_VERSION 3 static struct DLModule_Info info = { - MODULE_NAME, - MODULE_AUTHOR, - MODULE_EMAIL, - MAJOR_VERSION, - MINOR_VERSION -}; + MODULE_NAME, + MODULE_AUTHOR, + MODULE_EMAIL, + MAJOR_VERSION, + MINOR_VERSION + }; void CleanupTest(void) { lprintf(9, "--- test of adding an unload hook --- \n"); @@ -76,7 +76,7 @@ void DoPurgeMessages(struct quickroom *qrbuf) { GetExpirePolicy(&epbuf, qrbuf); - lprintf(9, "ExpirePolicy for <%s> is <%d> <%ld>\n", + lprintf(9, "ExpirePolicy for <%s> is <%d> <%d>\n", qrbuf->QRname, epbuf.expire_mode, epbuf.expire_value); /* If the room is set to never expire messages ... do nothing */ @@ -100,6 +100,10 @@ void DoPurgeMessages(struct quickroom *qrbuf) { } } + /* If the room is set to expire by age... FIX (write this!!) (/ + if (epbuf.expire_mode == EXPIRE_AGE) { + } + put_msglist(qrbuf); }