policy.c: implemented cmd_gpex() and cmd_spex()
authorArt Cancro <ajc@citadel.org>
Sat, 24 Oct 1998 04:05:03 +0000 (04:05 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 24 Oct 1998 04:05:03 +0000 (04:05 +0000)
citadel/ChangeLog
citadel/config.h
citadel/policy.c

index 449a2de75d8509b884c6ec9dc0f131a2d06ec5c6..6528075ce5fca272452c2e9ed2b1bc205275f56b 100644 (file)
@@ -2,6 +2,7 @@ Fri Oct 23 19:34:38 EDT 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * 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 <ajc@uncnsrd.mt-kisco.ny.us>
        * Mail rooms now hide their owner-prefix from the client.
index 87bd2ead48995b456621d46755d10d1040ab8731..0a99f5b52a89966e602b0f88ab2bfec6f80d03e8 100644 (file)
@@ -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;
index 841736d13eb02705ab855098297f024b83f98fe5..d607d398f418702e17b6fb6c5f18d2734e15bf1b 100644 (file)
@@ -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;
+               }
+
        }