From 28391e51fb1a9c0002bb0154f56ce73770894b88 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 24 Oct 1998 04:05:03 +0000 Subject: [PATCH] policy.c: implemented cmd_gpex() and cmd_spex() --- citadel/ChangeLog | 1 + citadel/config.h | 1 + citadel/policy.c | 81 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 449a2de75..6528075ce 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -2,6 +2,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 + * policy.c: implemented cmd_gpex() and cmd_spex() Wed Oct 21 22:24:48 EDT 1998 Art Cancro * Mail rooms now hide their owner-prefix from the client. diff --git a/citadel/config.h b/citadel/config.h index 87bd2ead4..0a99f5b52 100644 --- a/citadel/config.h +++ b/citadel/config.h @@ -1,4 +1,5 @@ void get_config(void); +void put_config(void); extern struct config config; extern char bbs_home_directory[PATH_MAX]; extern int home_specified; diff --git a/citadel/policy.c b/citadel/policy.c index 841736d13..d607d398f 100644 --- a/citadel/policy.c +++ b/citadel/policy.c @@ -47,7 +47,27 @@ void GetExpirePolicy(struct ExpirePolicy *epbuf, struct quickroom *qrbuf) { * Get Policy EXpire */ void cmd_gpex(char *argbuf) { - cprintf("%d Command not yet implemented.\n", ERROR); + struct ExpirePolicy exp; + struct floor flbuf; + char which[256]; + + extract(which, argbuf, 0); + if (!strcasecmp(which, "room")) { + memcpy(&exp, &CC->quickroom.QRep, sizeof(struct ExpirePolicy)); + } + else if (!strcasecmp(which, "floor")) { + getfloor(&flbuf, CC->quickroom.QRfloor); + memcpy(&exp, &flbuf.f_ep, sizeof(struct ExpirePolicy)); + } + else if (!strcasecmp(which, "site")) { + memcpy(&exp, &config.c_ep, sizeof(struct ExpirePolicy)); + } + else { + cprintf("%d Invalid keyword.\n", ERROR); + return; + } + + cprintf("%d %d|%d\n", OK, exp.expire_mode, exp.expire_value); } @@ -55,7 +75,64 @@ void cmd_gpex(char *argbuf) { * Set Policy EXpire */ void cmd_spex(char *argbuf) { - cprintf("%d Command not yet implemented.\n", ERROR); + struct ExpirePolicy exp; + struct floor flbuf; + char which[256]; + + bzero(&exp, sizeof(struct ExpirePolicy)); + extract(which, argbuf, 0); + exp.expire_mode = extract_int(argbuf, 1); + exp.expire_value = extract_int(argbuf, 2); + + if ((exp.expire_mode < 0) || (exp.expire_mode > 3)) { + cprintf("%d Invalid policy.\n", ERROR); + return; + } + + if (!strcasecmp(which, "room")) { + if (!is_room_aide()) { + cprintf("%d Higher access required.\n", + ERROR+HIGHER_ACCESS_REQUIRED); + return; + } + lgetroom(&CC->quickroom, CC->quickroom.QRname); + memcpy(&CC->quickroom.QRep, &exp, sizeof(struct ExpirePolicy)); + lputroom(&CC->quickroom, CC->quickroom.QRname); + cprintf("%d ok\n", OK); + return; + } + + if (CC->usersupp.axlevel < 6) { + cprintf("%d Higher access required.\n", + ERROR+HIGHER_ACCESS_REQUIRED); + return; + } + + if (!strcasecmp(which, "floor")) { + lgetfloor(&flbuf, CC->quickroom.QRfloor); + memcpy(&flbuf.f_ep, &exp, sizeof(struct ExpirePolicy)); + lputfloor(&flbuf, CC->quickroom.QRfloor); + cprintf("%d ok\n", OK); + return; + } + + else if (!strcasecmp(which, "site")) { + if (exp.expire_mode == EXPIRE_NEXTLEVEL) { + cprintf("%d Invalid policy (no higher level)\n", + ERROR); + return; + } + memcpy(&config.c_ep, &exp, sizeof(struct ExpirePolicy)); + put_config(); + cprintf("%d ok\n", OK); + return; + } + + else { + cprintf("%d Invalid keyword.\n", ERROR); + return; + } + } -- 2.30.2