]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
* misc bugfixes and cleanups
[citadel.git] / citadel / room_ops.c
index 61315accccfb821dcfc31da5afd06d87904c997c..12c74727f1a984562c3d539a80723441c3de5552 100644 (file)
@@ -171,8 +171,10 @@ int getroom(struct quickroom *qrbuf, char *room_name)
  */
 int lgetroom(struct quickroom *qrbuf, char *room_name)
 {
-       begin_critical_section(S_QUICKROOM);
-       return (getroom(qrbuf, room_name));
+       register int retval;
+       retval = getroom(qrbuf, room_name);
+       if (retval == 0) begin_critical_section(S_QUICKROOM);
+       return(retval);
 }
 
 
@@ -314,15 +316,21 @@ void ForEachRoom(void (*CallBack) (struct quickroom *EachRoom, void *out_data),
 
 /*
  * delete_msglist()  -  delete room message pointers
- * FIXME - this really should check first to make sure there's actually a
- *       msglist to delete.  As things stand now, calling this function on
- *       a room which has never been posted in will result in a message
- *       like "gdbm: illegal data" (no big deal, but could use fixing).
  */
 void delete_msglist(struct quickroom *whichroom)
 {
+        struct cdbdata *cdbml;
 
-       cdb_delete(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
+       /* Make sure the msglist we're deleting actually exists, otherwise
+        * gdbm will complain when we try to delete an invalid record
+        */
+        cdbml = cdb_fetch(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
+        if (cdbml != NULL) {
+               cdb_free(cdbml);
+
+               /* Go ahead and delete it */
+               cdb_delete(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
+       }
 }
 
 
@@ -680,7 +688,7 @@ void usergoto(char *where, int display_result)
 
        if (display_result)
                cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d\n",
-                       OK, check_express(),
+                       OK, CtdlCheckExpress(),
                        truncated_roomname,
                        new_messages, total_messages,
                        info, CC->quickroom.QRflags,
@@ -890,13 +898,17 @@ void cmd_getr(void)
                        ERROR + HIGHER_ACCESS_REQUIRED);
                return;
        }
+
+       /********
        if (is_noneditable(&CC->quickroom)) {
                cprintf("%d Can't edit this room.\n", ERROR + NOT_HERE);
                return;
        }
+       ************/
+
        getroom(&CC->quickroom, CC->quickroom.QRname);
        cprintf("%d%c%s|%s|%s|%d|%d|%d\n",
-               OK, check_express(),
+               OK, CtdlCheckExpress(),
                CC->quickroom.QRname,
                ((CC->quickroom.QRflags & QR_PASSWORDED) ? CC->quickroom.QRpasswd : ""),
                ((CC->quickroom.QRflags & QR_DIRECTORY) ? CC->quickroom.QRdirname : ""),
@@ -916,6 +928,7 @@ void cmd_setr(char *args)
        char old_name[ROOMNAMELEN];
        int old_floor;
        int new_order = 0;
+       int ne = 0;
 
        if (!(CC->logged_in)) {
                cprintf("%d Not logged in.\n", ERROR + NOT_LOGGED_IN);
@@ -926,10 +939,19 @@ void cmd_setr(char *args)
                        ERROR + HIGHER_ACCESS_REQUIRED);
                return;
        }
+
+
        if (is_noneditable(&CC->quickroom)) {
+               ne = 1;
+       }
+
+       /***
                cprintf("%d Can't edit this room.\n", ERROR + NOT_HERE);
                return;
        }
+       ***/
+
+
        if (num_parms(args) >= 6) {
                getfloor(&flbuf, extract_int(args, 5));
                if ((flbuf.f_flags & F_INUSE) == 0) {
@@ -946,10 +968,16 @@ void cmd_setr(char *args)
                        new_order = 127;
        }
        lgetroom(&CC->quickroom, CC->quickroom.QRname);
+
+       /* Non-editable base rooms can't be renamed */
        strcpy(old_name, CC->quickroom.QRname);
-       extract(buf, args, 0);
-       buf[ROOMNAMELEN] = 0;
-       safestrncpy(CC->quickroom.QRname, buf, sizeof CC->quickroom.QRname);
+       if (!ne) {
+               extract(buf, args, 0);
+               buf[ROOMNAMELEN] = 0;
+               safestrncpy(CC->quickroom.QRname, buf,
+                       sizeof CC->quickroom.QRname);
+       }
+
        extract(buf, args, 1);
        buf[10] = 0;
        safestrncpy(CC->quickroom.QRpasswd, buf, sizeof CC->quickroom.QRpasswd);