]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
* Renamed "dynloader" to "serv_extensions" globally. We don't want people
[citadel.git] / citadel / room_ops.c
index 8d83038c65d4f61a2ffd12aff66cdedfb5e6e407..a2ef5da7bea1c9b81d0bd6ef6191706e8196c9eb 100644 (file)
@@ -31,7 +31,7 @@
 #include <errno.h>
 #include "citadel.h"
 #include "server.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
 #include "database.h"
 #include "config.h"
 #include "room_ops.h"
@@ -497,10 +497,12 @@ void list_roomname(struct quickroom *qrbuf)
        }
 
        /* ...and now the other parameters */
-       cprintf("|%u|%d|%d\n",
+       cprintf("|%u|%d|%d|%d\n",
                qrbuf->QRflags,
                (int) qrbuf->QRfloor,
-               (int) qrbuf->QRorder);
+               (int) qrbuf->QRorder,
+               (int) qrbuf->QRflags2
+       );
 }
 
 
@@ -574,6 +576,32 @@ void cmd_lkra(char *argbuf)
 
 
 
+void cmd_lprm_backend(struct quickroom *qrbuf, void *data)
+{
+       int FloorBeingSearched = (-1);
+       FloorBeingSearched = *(int *)data;
+
+       if (   ((qrbuf->QRflags & QR_PRIVATE) == 0)
+               && ((qrbuf->QRflags & QR_MAILBOX) == 0)
+           && ((qrbuf->QRfloor == (FloorBeingSearched))
+               || ((FloorBeingSearched) < 0)))
+               list_roomname(qrbuf);
+}
+
+void cmd_lprm(char *argbuf)
+{
+       int FloorBeingSearched = (-1);
+       if (strlen(argbuf) > 0)
+               FloorBeingSearched = extract_int(argbuf, 0);
+
+       cprintf("%d Publiic rooms:\n", LISTING_FOLLOWS);
+
+       ForEachRoom(cmd_lprm_backend, &FloorBeingSearched);
+       cprintf("000\n");
+}
+
+
+
 /* 
  * cmd_lkrn()   -  List all known rooms with new messages
  */
@@ -689,7 +717,8 @@ void cmd_lzrm(char *argbuf)
  * or access control is done here -- the caller should make sure that the
  * specified room exists and is ok to access.
  */
-void usergoto(char *where, int display_result, int *retmsgs, int *retnew)
+void usergoto(char *where, int display_result, int transiently,
+               int *retmsgs, int *retnew)
 {
        int a;
        int new_messages = 0;
@@ -718,8 +747,11 @@ void usergoto(char *where, int display_result, int *retmsgs, int *retnew)
        begin_critical_section(S_USERSUPP);
        CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
 
-       /* Know the room ... but not if it's the page log room */
-       if (strcasecmp(CC->quickroom.QRname, config.c_logpages)) {
+       /* Know the room ... but not if it's the page log room, or if the
+        * caller specified that we're only entering this room transiently.
+        */
+       if ((strcasecmp(CC->quickroom.QRname, config.c_logpages))
+          && (transiently == 0) ) {
                vbuf.v_flags = vbuf.v_flags & ~V_FORGET & ~V_LOCKOUT;
                vbuf.v_flags = vbuf.v_flags | V_ACCESS;
        }
@@ -774,19 +806,28 @@ void usergoto(char *where, int display_result, int *retmsgs, int *retnew)
        if (retmsgs != NULL) *retmsgs = total_messages;
        if (retnew != NULL) *retnew = new_messages;
        lprintf(9, "<%s> %d new of %d total messages\n",
-               CC->quickroom.QRname, new_messages, total_messages);
+               CC->quickroom.QRname,
+               new_messages, total_messages
+       );
 
-       if (display_result)
-               cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d|%d\n",
+       if (display_result) {
+               cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d|%d|%d|\n",
                        CIT_OK, CtdlCheckExpress(),
                        truncated_roomname,
-                       new_messages, total_messages,
-                       info, CC->quickroom.QRflags,
-                       CC->quickroom.QRhighest,
-                       vbuf.v_lastseen,
-                       rmailflag, raideflag, newmailcount,
-                       CC->quickroom.QRfloor,
-                       vbuf.v_view);
+                       (int)new_messages,
+                       (int)total_messages,
+                       (int)info,
+                       (int)CC->quickroom.QRflags,
+                       (long)CC->quickroom.QRhighest,
+                       (long)vbuf.v_lastseen,
+                       (int)rmailflag,
+                       (int)raideflag,
+                       (int)newmailcount,
+                       (int)CC->quickroom.QRfloor,
+                       (int)vbuf.v_view,
+                       (int)CC->quickroom.QRdefaultview
+               );
+       }
 }
 
 
@@ -802,11 +843,13 @@ void cmd_goto(char *gargs)
        char augmented_roomname[SIZ];
        char towhere[SIZ];
        char password[SIZ];
+       int transiently = 0;
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
        extract(towhere, gargs, 0);
        extract(password, gargs, 1);
+       transiently = extract_int(gargs, 2);
 
        getuser(&CC->usersupp, CC->curr_user);
 
@@ -839,7 +882,7 @@ void cmd_goto(char *gargs)
                if (CC->internal_pgm) {
                        memcpy(&CC->quickroom, &QRscratch,
                                sizeof(struct quickroom));
-                       usergoto(NULL, 1, NULL, NULL);
+                       usergoto(NULL, 1, transiently, NULL, NULL);
                        return;
                }
 
@@ -856,7 +899,7 @@ void cmd_goto(char *gargs)
                            ((ra & UA_GOTOALLOWED))) {
                                memcpy(&CC->quickroom, &QRscratch,
                                        sizeof(struct quickroom));
-                               usergoto(NULL, 1, NULL, NULL);
+                               usergoto(NULL, 1, transiently, NULL, NULL);
                                return;
                        } else if ((QRscratch.QRflags & QR_PASSWORDED) &&
                            ((ra & UA_KNOWN) == 0) &&
@@ -877,7 +920,7 @@ void cmd_goto(char *gargs)
                        } else {
                                memcpy(&CC->quickroom, &QRscratch,
                                        sizeof(struct quickroom));
-                               usergoto(NULL, 1, NULL, NULL);
+                               usergoto(NULL, 1, transiently, NULL, NULL);
                                return;
                        }
                }
@@ -999,7 +1042,7 @@ void cmd_getr(void)
        if (CtdlAccessCheck(ac_room_aide)) return;
 
        getroom(&CC->quickroom, CC->quickroom.QRname);
-       cprintf("%d%c%s|%s|%s|%d|%d|%d|%d\n",
+       cprintf("%d%c%s|%s|%s|%d|%d|%d|%d|%d|\n",
                CIT_OK,
                CtdlCheckExpress(),
 
@@ -1016,7 +1059,9 @@ void cmd_getr(void)
                (int) CC->quickroom.QRfloor,
                (int) CC->quickroom.QRorder,
 
-               CC->quickroom.QRdefaultview);
+               CC->quickroom.QRdefaultview,
+               CC->quickroom.QRflags2
+               );
 }
 
 
@@ -1036,6 +1081,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
        struct floor *fl;
        struct floor flbuf;
        long owner = 0L;
+       char actual_old_name[SIZ];
 
        lprintf(9, "CtdlRenameRoom(%s, %s, %d)\n",
                old_name, new_name, new_floor);
@@ -1070,6 +1116,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
 
        else {
                /* Rename it */
+               strcpy(actual_old_name, qrbuf.QRname);
                if (qrbuf.QRflags & QR_MAILBOX) {
                        owner = atol(qrbuf.QRname);
                }
@@ -1114,7 +1161,7 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
                 * records, so we have to delete the old one.
                 */
                if (strcasecmp(new_name, old_name)) {
-                       b_deleteroom(old_name);
+                       b_deleteroom(actual_old_name);
                }
 
                ret = crr_ok;
@@ -1216,6 +1263,11 @@ void cmd_setr(char *args)
                CC->quickroom.QRdefaultview = extract_int(args, 7);
        }
 
+       /* Second set of flags */
+       if (num_parms(args) >= 9) {
+               CC->quickroom.QRflags2 = extract_int(args, 8);
+       }
+
        /* Misc. flags */
        CC->quickroom.QRflags = (extract_int(args, 3) | QR_INUSE);
        /* Clean up a client boo-boo: if the client set the room to
@@ -1469,7 +1521,7 @@ void cmd_kill(char *argbuf)
        if (kill_ok) {
                strcpy(deleted_room_name, CC->quickroom.QRname);
                delete_room(&CC->quickroom);    /* Do the dirty work */
-               usergoto(config.c_baseroom, 0, NULL, NULL); /* Return to the Lobby */
+               usergoto(config.c_baseroom, 0, 0, NULL, NULL); /* Return to the Lobby */
 
                /* tell the world what we did */
                snprintf(aaa, sizeof aaa, "%s> killed by %s\n",
@@ -1588,12 +1640,14 @@ void cmd_cre8(char *args)
        char aaa[SIZ];
        unsigned newflags;
        struct floor *fl;
+       int avoid_access = 0;
 
        cre8_ok = extract_int(args, 0);
        extract(new_room_name, args, 1);
        new_room_name[ROOMNAMELEN - 1] = 0;
        new_room_type = extract_int(args, 2);
        extract(new_room_pass, args, 3);
+       avoid_access = extract_int(args, 5);
        new_room_pass[9] = 0;
        new_room_floor = 0;
 
@@ -1648,7 +1702,8 @@ void cmd_cre8(char *args)
 
        /* Check to make sure the requested room name doesn't already exist */
        newflags = create_room(new_room_name,
-                          new_room_type, new_room_pass, new_room_floor, 0, 0);
+                               new_room_type, new_room_pass, new_room_floor,
+                               0, avoid_access);
        if (newflags == 0) {
                cprintf("%d '%s' already exists.\n",
                        ERROR + ALREADY_EXISTS, new_room_name);
@@ -1764,9 +1819,14 @@ void cmd_cflr(char *argbuf)
        extract(new_floor_name, argbuf, 0);
        cflr_ok = extract_int(argbuf, 1);
 
-
        if (CtdlAccessCheck(ac_aide)) return;
 
+       if (strlen(new_floor_name) == 0) {
+               cprintf("%d Blank floor name not allowed.\n",
+                       ERROR+ILLEGAL_VALUE);
+               return;
+       }
+
        for (a = 0; a < MAXFLOORS; ++a) {
                getfloor(&flbuf, a);