fix dlen
[citadel.git] / textclient / rooms.c
index 5c65cea82f83405c33ecf07b76e4c1d9f2ff184c..81ece7f72ef299945947a7e5da4af4491baa52b2 100644 (file)
@@ -1,20 +1,13 @@
 // Client-side functions which perform room operations
 //
-// Copyright (c) 1987-2018 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
 //
-// This program is open source software.  Use, duplication, and/or
-// disclosure are subject to the GNU General Purpose License version 3.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
+// This program is open source software.  Use, duplication, or disclosure is subject to the GNU General Public License version 3.
 
 #include "textclient.h"
 
 #define IFNEXPERT if ((userflags&US_EXPERT)==0)
 
-
 void stty_ctdl(int cmd);
 void dotgoto(CtdlIPC * ipc, char *towhere, int display_name, int fromungoto);
 void progress(CtdlIPC * ipc, unsigned long curr, unsigned long cmax);
@@ -44,12 +37,11 @@ extern int uglistsize;
 extern char floorlist[128][SIZ];
 
 
-void load_floorlist(CtdlIPC * ipc)
-{
+void load_floorlist(CtdlIPC * ipc) {
        int a;
        char buf[SIZ];
        char *listing = NULL;
-       int r;                  /* IPC response code */
+       int r;                  // IPC response code
 
        for (a = 0; a < 128; ++a)
                floorlist[a][0] = 0;
@@ -68,8 +60,7 @@ void load_floorlist(CtdlIPC * ipc)
 }
 
 
-void room_tree_list(struct ctdlroomlisting *rp)
-{
+void room_tree_list(struct ctdlroomlisting *rp) {
        static int c = 0;
        char rmname[ROOMNAMELEN];
        int f;
@@ -88,21 +79,24 @@ void room_tree_list(struct ctdlroomlisting *rp)
                f = rp->rlflags;
                if ((c + strlen(rmname) + 4) > screenwidth) {
 
-                       /* line break, check the paginator */
+                       // line break, check the paginator
                        scr_printf("\n");
                        c = 1;
                }
                if (f & QR_MAILBOX) {
                        color(BRIGHT_YELLOW);
-               } else if (f & QR_PRIVATE) {
+               }
+               else if (f & QR_PRIVATE) {
                        color(BRIGHT_RED);
-               } else {
+               }
+               else {
                        color(DIM_WHITE);
                }
                scr_printf("%s", rmname);
                if (f & QR_DIRECTORY) {
                        scr_printf("]  ");
-               } else {
+               }
+               else {
                        scr_printf(">  ");
                }
                c = c + strlen(rmname) + 3;
@@ -116,11 +110,8 @@ void room_tree_list(struct ctdlroomlisting *rp)
 }
 
 
-/* 
- * Room ordering stuff (compare first by floor, then by order)
- */
-int rordercmp(struct ctdlroomlisting *r1, struct ctdlroomlisting *r2)
-{
+// Room ordering stuff (compare first by floor, then by order)
+int rordercmp(struct ctdlroomlisting *r1, struct ctdlroomlisting *r2) {
        if ((r1 == NULL) && (r2 == NULL))
                return (0);
        if (r1 == NULL)
@@ -139,11 +130,8 @@ int rordercmp(struct ctdlroomlisting *r1, struct ctdlroomlisting *r2)
 }
 
 
-/*
- * Common code for all room listings
- */
-static void listrms(struct march *listing, int new_only, int floor_only, unsigned int flags, char *match)
-{
+// Common code for all room listings
+static void listrms(struct march *listing, int new_only, int floor_only, unsigned int flags, char *match) {
        struct march *mptr;
        struct ctdlroomlisting *rl = NULL;
        struct ctdlroomlisting *rp;
@@ -153,16 +141,13 @@ static void listrms(struct march *listing, int new_only, int floor_only, unsigne
        for (mptr = listing; mptr != NULL; mptr = mptr->next) {
                list_it = 1;
 
-               if ((new_only == LISTRMS_NEW_ONLY)
-                   && ((mptr->march_access & UA_HASNEWMSGS) == 0))
+               if ((new_only == LISTRMS_NEW_ONLY) && ((mptr->march_access & UA_HASNEWMSGS) == 0))
                        list_it = 0;
 
-               if ((new_only == LISTRMS_OLD_ONLY)
-                   && ((mptr->march_access & UA_HASNEWMSGS) != 0))
+               if ((new_only == LISTRMS_OLD_ONLY) && ((mptr->march_access & UA_HASNEWMSGS) != 0))
                        list_it = 0;
 
-               if ((floor_only >= 0)
-                   && (mptr->march_floor != floor_only))
+               if ((floor_only >= 0) && (mptr->march_floor != floor_only))
                        list_it = 0;
 
                if (flags && (mptr->march_flags & flags) == 0)
@@ -183,20 +168,24 @@ static void listrms(struct march *listing, int new_only, int floor_only, unsigne
                        rs = rl;
                        if (rl == NULL) {
                                rl = rp;
-                       } else {
+                       }
+                       else {
                                while (rp != NULL) {
                                        if (rordercmp(rp, rs) < 0) {
                                                if (rs->lnext == NULL) {
                                                        rs->lnext = rp;
                                                        rp = NULL;
-                                               } else {
+                                               }
+                                               else {
                                                        rs = rs->lnext;
                                                }
-                                       } else {
+                                       }
+                                       else {
                                                if (rs->rnext == NULL) {
                                                        rs->rnext = rp;
                                                        rp = NULL;
-                                               } else {
+                                               }
+                                               else {
                                                        rs = rs->rnext;
                                                }
                                        }
@@ -211,8 +200,7 @@ static void listrms(struct march *listing, int new_only, int floor_only, unsigne
 }
 
 
-void list_other_floors(void)
-{
+void list_other_floors(void) {
        int a, c;
 
        c = 1;
@@ -229,20 +217,17 @@ void list_other_floors(void)
 }
 
 
-/*
- * List known rooms.  kn_floor_mode should be set to 0 for a 'flat' listing,
- * 1 to list rooms on the current floor, or 2 to list rooms on all floors.
- */
-void knrooms(CtdlIPC * ipc, int kn_floor_mode)
-{
+// List known rooms.  kn_floor_mode should be set to 0 for a 'flat' listing,
+// 1 to list rooms on the current floor, or 2 to list rooms on all floors.
+void knrooms(CtdlIPC * ipc, int kn_floor_mode) {
        int a;
        struct march *listing = NULL;
        struct march *mptr;
-       int r;                  /* IPC response code */
+       int r;                  // IPC response code
        char buf[SIZ];
 
 
-       /* Ask the server for a room list */
+       // Ask the server for a room list
        r = CtdlIPCKnownRooms(ipc, SubscribedRooms, (-1), &listing, buf);
        if (r / 100 != 1) {
                listing = NULL;
@@ -285,7 +270,7 @@ void knrooms(CtdlIPC * ipc, int kn_floor_mode)
                }
        }
 
-       /* Free the room list */
+       // Free the room list
        while (listing) {
                mptr = listing->next;
                free(listing);
@@ -296,15 +281,14 @@ void knrooms(CtdlIPC * ipc, int kn_floor_mode)
 }
 
 
-void listzrooms(CtdlIPC * ipc)
-{                              /* list public forgotten rooms */
+void listzrooms(CtdlIPC * ipc) {       // list public forgotten rooms
        struct march *listing = NULL;
        struct march *mptr;
-       int r;                  /* IPC response code */
+       int r;                  // IPC response code
        char buf[SIZ];
 
 
-       /* Ask the server for a room list */
+       // Ask the server for a room list
        r = CtdlIPCKnownRooms(ipc, UnsubscribedRooms, (-1), &listing, buf);
        if (r / 100 != 1) {
                listing = NULL;
@@ -315,7 +299,7 @@ void listzrooms(CtdlIPC * ipc)
        listrms(listing, LISTRMS_ALL, -1, 0, NULL);
        scr_printf("\n");
 
-       /* Free the room list */
+       // Free the room list
        while (listing) {
                mptr = listing->next;
                free(listing);
@@ -325,14 +309,15 @@ void listzrooms(CtdlIPC * ipc)
        color(DIM_WHITE);
 }
 
-void dotknown(CtdlIPC * ipc, int what, char *match)
-{                              /* list rooms according to attribute */
+
+// list rooms according to attribute
+void dotknown(CtdlIPC * ipc, int what, char *match) {
        struct march *listing = NULL;
        struct march *mptr;
-       int r;                  /* IPC response code */
+       int r;                  // IPC response code
        char buf[SIZ];
 
-       /* Ask the server for a room list */
+       // Ask the server for a room list
        r = CtdlIPCKnownRooms(ipc, AllAccessibleRooms, (-1), &listing, buf);
        if (r / 100 != 1) {
                listing = NULL;
@@ -373,7 +358,7 @@ void dotknown(CtdlIPC * ipc, int what, char *match)
                break;
        }
 
-       /* Free the room list */
+       // Free the room list
        while (listing) {
                mptr = listing->next;
                free(listing);
@@ -384,8 +369,7 @@ void dotknown(CtdlIPC * ipc, int what, char *match)
 }
 
 
-int set_room_attr(CtdlIPC * ipc, unsigned int ibuf, char *prompt, unsigned int sbit)
-{
+int set_room_attr(CtdlIPC * ipc, unsigned int ibuf, char *prompt, unsigned int sbit) {
        int a;
 
        a = boolprompt(prompt, (ibuf & sbit));
@@ -397,14 +381,10 @@ int set_room_attr(CtdlIPC * ipc, unsigned int ibuf, char *prompt, unsigned int s
 }
 
 
-
-/*
- * Select a floor (used in several commands)
- * The supplied argument is the 'default' floor number.
- * This function returns the selected floor number.
- */
-int select_floor(CtdlIPC * ipc, int rfloor)
-{
+// Select a floor (used in several commands)
+// The supplied argument is the 'default' floor number.
+// This function returns the selected floor number.
+int select_floor(CtdlIPC * ipc, int rfloor) {
        int a, newfloor;
        char floorstr[SIZ];
 
@@ -415,7 +395,7 @@ int select_floor(CtdlIPC * ipc, int rfloor)
 
                do {
                        newfloor = (-1);
-                       safestrncpy(floorstr, floorlist[rfloor], sizeof floorstr);
+                       strncpy(floorstr, floorlist[rfloor], sizeof floorstr);
                        strprompt("Which floor", floorstr, 255);
                        for (a = 0; a < 128; ++a) {
                                if (!strcasecmp(floorstr, &floorlist[a][0]))
@@ -441,28 +421,23 @@ int select_floor(CtdlIPC * ipc, int rfloor)
        }
 
        else {
-               scr_printf("Floor selection bypassed because you have " "floor mode disabled.\n");
+               scr_printf("Floor selection bypassed because you have floor mode disabled.\n");
        }
 
        return (rfloor);
 }
 
 
-
-
-/*
- * .<A>ide <E>dit room
- */
-void editthisroom(CtdlIPC * ipc)
-{
+// .<A>ide <E>dit room
+void editthisroom(CtdlIPC * ipc) {
        int rbump = 0;
        char room_admin_name[USERNAME_SIZE];
        char buf[SIZ];
        struct ctdlroom *attr = NULL;
        struct ExpirePolicy *eptr = NULL;
-       int r;                  /* IPC response code */
+       int r;                  // IPC response code
 
-       /* Fetch the existing room config */
+       // Fetch the existing room config
        r = CtdlIPCGetRoomAttributes(ipc, &attr, buf);
        if (r / 100 != 2) {
                scr_printf("%s\n", buf);
@@ -470,33 +445,32 @@ void editthisroom(CtdlIPC * ipc)
        }
        eptr = &(attr->QRep);
 
-       /* Fetch the name of the current room admin */
+       // Fetch the name of the current room admin
        r = CtdlIPCGetRoomAide(ipc, buf);
        if (r / 100 == 2) {
-               safestrncpy(room_admin_name, buf, sizeof room_admin_name);
-       } else {
+               strncpy(room_admin_name, buf, sizeof room_admin_name);
+       }
+       else {
                strcpy(room_admin_name, "");
        }
        if (IsEmptyStr(room_admin_name)) {
                strcpy(room_admin_name, "none");
        }
 
-       /* Fetch the expire policy (this will silently fail on old servers,
-        * resulting in "default" policy)
-        */
+       // Fetch the expire policy (this will silently fail on old servers, resulting in "default" policy)
        r = CtdlIPCGetMessageExpirationPolicy(ipc, 0, &eptr, buf);
 
-       /* Now interact with the user. */
+       // Now interact with the user.
 
        strprompt("Room name", attr->QRname, ROOMNAMELEN - 1);
        attr->QRfloor = select_floor(ipc, attr->QRfloor);
        attr->QRflags = set_room_attr(ipc, attr->QRflags, "Private room", QR_PRIVATE);
        if (attr->QRflags & QR_PRIVATE) {
-               attr->QRflags = set_room_attr(ipc, attr->QRflags,
-                                             "Hidden room (accessible to anyone who knows the room name)", QR_GUESSNAME);
+               attr->QRflags =
+                   set_room_attr(ipc, attr->QRflags, "Hidden room (accessible to anyone who knows the room name)", QR_GUESSNAME);
        }
 
-       /* if it's public, clear the privacy classes */
+       // if it's public, clear the privacy classes
        if ((attr->QRflags & QR_PRIVATE) == 0) {
                if (attr->QRflags & QR_GUESSNAME) {
                        attr->QRflags = attr->QRflags - QR_GUESSNAME;
@@ -506,7 +480,7 @@ void editthisroom(CtdlIPC * ipc)
                }
        }
 
-       /* if it's private, choose the privacy classes */
+       // if it's private, choose the privacy classes
        if ((attr->QRflags & QR_PRIVATE)
            && ((attr->QRflags & QR_GUESSNAME) == 0)) {
                attr->QRflags = set_room_attr(ipc, attr->QRflags, "Accessible by entering a password", QR_PASSWORDED);
@@ -524,8 +498,8 @@ void editthisroom(CtdlIPC * ipc)
        attr->QRflags = set_room_attr(ipc, attr->QRflags, "Read-only room", QR_READONLY);
        attr->QRflags2 = set_room_attr(ipc, attr->QRflags2, "Allow message deletion by anyone who can post", QR2_COLLABDEL);
        attr->QRflags = set_room_attr(ipc, attr->QRflags, "Permanent room", QR_PERMANENT);
-       attr->QRflags2 = set_room_attr(ipc, attr->QRflags2,
-                                      "Subject Required (Force " "users to specify a message " "subject)", QR2_SUBJECTREQ);
+       attr->QRflags2 =
+           set_room_attr(ipc, attr->QRflags2, "Subject Required (Force users to specify a message subject)", QR2_SUBJECTREQ);
        attr->QRflags = set_room_attr(ipc, attr->QRflags, "Directory room", QR_DIRECTORY);
        if (attr->QRflags & QR_DIRECTORY) {
                strprompt("Directory name", attr->QRdirname, 14);
@@ -534,29 +508,30 @@ void editthisroom(CtdlIPC * ipc)
                attr->QRflags = set_room_attr(ipc, attr->QRflags, "Visible directory", QR_VISDIR);
        }
        attr->QRflags2 = set_room_attr(ipc, attr->QRflags2, "Self-service list subscribe/unsubscribe", QR2_SELFLIST);
-       attr->QRflags2 = set_room_attr(ipc, attr->QRflags2,
-                                      "public posting to this room via room_roomname@yourcitadel.org", QR2_SMTP_PUBLIC);
-       attr->QRflags2 = set_room_attr(ipc, attr->QRflags2, "moderated mailinglist", QR2_MODERATED);
+       attr->QRflags2 = set_room_attr(ipc, attr->QRflags2, "Allow non-subscribers to mail to this room", QR2_SMTP_PUBLIC);
+       attr->QRflags2 = set_room_attr(ipc, attr->QRflags2, "Moderated mailing list", QR2_MODERATED);
        attr->QRflags = set_room_attr(ipc, attr->QRflags, "Automatically make all messages anonymous", QR_ANONONLY);
        if ((attr->QRflags & QR_ANONONLY) == 0) {
                attr->QRflags = set_room_attr(ipc, attr->QRflags, "Ask users whether to make messages anonymous", QR_ANONOPT);
        }
        attr->QRorder = intprompt("Listing order", attr->QRorder, 0, 127);
 
-       /* Ask about the room admin */
+       // Ask about the room admin
        do {
                strprompt("Room admin (or 'none')", room_admin_name, 29);
                if (!strcasecmp(room_admin_name, "none")) {
                        strcpy(room_admin_name, "");
                        break;
-               } else {
+               }
+               else {
                        r = CtdlIPCQueryUsername(ipc, room_admin_name, buf);
-                       if (r / 100 != 2)
+                       if (r / 100 != 2) {
                                scr_printf("%s\n", buf);
+                       }
                }
        } while (r / 100 != 2);
 
-       /* Angels and demons dancing in my head... */
+       // Angels and demons dancing in my head...
        do {
                snprintf(buf, sizeof buf, "%d", attr->QRep.expire_mode);
                strprompt("Message expire policy (? for list)", buf, 1);
@@ -569,7 +544,7 @@ void editthisroom(CtdlIPC * ipc)
        } while ((buf[0] < 48) || (buf[0] > 51));
        attr->QRep.expire_mode = buf[0] - 48;
 
-       /* ...lunatics and monsters underneath my bed */
+       // ...lunatics and monsters underneath my bed
        if (attr->QRep.expire_mode == 2) {
                snprintf(buf, sizeof buf, "%d", attr->QRep.expire_value);
                strprompt("Keep how many messages online?", buf, 10);
@@ -582,7 +557,7 @@ void editthisroom(CtdlIPC * ipc)
                attr->QRep.expire_value = atol(buf);
        }
 
-       /* Give 'em a chance to change their minds */
+       // Give 'em a chance to change their minds
        scr_printf("Save changes (y/n)? ");
 
        if (yesno() == 1) {
@@ -600,26 +575,26 @@ void editthisroom(CtdlIPC * ipc)
                scr_printf("%s\n", buf);
                strncpy(buf, attr->QRname, ROOMNAMELEN);
                free(attr);
-               if (r / 100 == 2)
+               if (r / 100 == 2) {
                        dotgoto(ipc, buf, 2, 0);
-       } else
+               }
+       }
+       else {
                free(attr);
+       }
 }
 
 
-/*
- * un-goto the previous room, or a specified room
- */
-void dotungoto(CtdlIPC * ipc, char *towhere)
-{
-       /* Find this 'towhere' room in the list ungoto from this room to
-          that at the messagepointer position in that room in our ungoto list.
-          I suppose I could be a real dick and just ungoto that many places
-          in our list. */
+// un-goto the previous room, or a specified room
+void dotungoto(CtdlIPC * ipc, char *towhere) {
+       // Find this 'towhere' room in the list ungoto from this room to
+       // that at the messagepointer position in that room in our ungoto list.
+       // I suppose I could be a real dick and just ungoto that many places
+       // in our list.
        int found = -1;
        int lp;
        char buf[SIZ];
-       struct ctdlipcroom *rret = NULL;        /* ignored */
+       struct ctdlipcroom *rret = NULL;        // ignored
        int r;
 
        if (uglistsize == 0) {
@@ -647,7 +622,7 @@ void dotungoto(CtdlIPC * ipc, char *towhere)
 
        r = CtdlIPCGotoRoom(ipc, uglist[found], "", &rret, buf);
        if (rret)
-               free(rret);     /* ignored */
+               free(rret);     // ignored
        if (r / 100 != 2) {
                scr_printf("%s\n", buf);
                return;
@@ -656,25 +631,27 @@ void dotungoto(CtdlIPC * ipc, char *towhere)
        if (r / 100 != 2) {
                scr_printf("%s\n", buf);
        }
-       safestrncpy(buf, uglist[found], sizeof(buf));
-       /* we queue ungoto information here, because we're not really
-          ungotoing, we're really going to a random spot in some arbitrary
-          room list. */
+       strncpy(buf, uglist[found], sizeof(buf));
+       // we queue ungoto information here, because we're not really
+       // ungotoing, we're really going to a random spot in some arbitrary
+       // room list.
        dotgoto(ipc, buf, 0, 0);
 }
 
-void ungoto(CtdlIPC * ipc)
-{
+
+void ungoto(CtdlIPC * ipc) {
        char buf[SIZ];
-       struct ctdlipcroom *rret = NULL;        /* ignored */
+       struct ctdlipcroom *rret = NULL;        // ignored
        int r;
 
-       if (uglistsize == 0)
+       if (uglistsize == 0) {
                return;
+       }
 
        r = CtdlIPCGotoRoom(ipc, uglist[uglistsize - 1], "", &rret, buf);
-       if (rret)
-               free(rret);     /* ignored */
+       if (rret) {
+               free(rret);     // ignored
+       }
        if (r / 100 != 2) {
                scr_printf("%s\n", buf);
                return;
@@ -683,19 +660,16 @@ void ungoto(CtdlIPC * ipc)
        if (r / 100 != 2) {
                scr_printf("%s\n", buf);
        }
-       safestrncpy(buf, uglist[uglistsize - 1], sizeof(buf));
+       strncpy(buf, uglist[uglistsize - 1], sizeof(buf));
        uglistsize--;
        free(uglist[uglistsize]);
-       /* Don't queue ungoto info or we end up in a loop */
+       // Don't queue ungoto info or we end up in a loop
        dotgoto(ipc, buf, 0, 1);
 }
 
 
-/*
- * saves filelen bytes from file at pathname
- */
-int save_buffer(void *file, size_t filelen, const char *pathname)
-{
+// saves filelen bytes from file at pathname
+int save_buffer(void *file, size_t filelen, const char *pathname) {
        size_t block = 0;
        size_t bytes_written = 0;
        FILE *fp;
@@ -719,17 +693,15 @@ int save_buffer(void *file, size_t filelen, const char *pathname)
 }
 
 
-/*
- * Save supplied_filename in dest directory; gets the name only
- */
-void destination_directory(char *dest, const char *supplied_filename)
-{
+// Save supplied_filename in dest directory; gets the name only
+void destination_directory(char *dest, const char *supplied_filename) {
        static char save_dir[SIZ] = { 0 };
 
        if (IsEmptyStr(save_dir)) {
                if (getenv("HOME") == NULL) {
                        strcpy(save_dir, ".");
-               } else {
+               }
+               else {
                        sprintf(save_dir, "%s/Desktop", getenv("HOME"));
                        if (access(save_dir, W_OK) != 0) {
                                sprintf(save_dir, "%s", getenv("HOME"));
@@ -743,33 +715,31 @@ void destination_directory(char *dest, const char *supplied_filename)
        sprintf(dest, "%s/%s", save_dir, supplied_filename);
        strprompt("Save as", dest, PATH_MAX);
 
-       /* Remember the directory for next time */
+       // Remember the directory for next time
        strcpy(save_dir, dest);
        if (strrchr(save_dir, '/') != NULL) {
                strcpy(strrchr(save_dir, '/'), "");
-       } else {
+       }
+       else {
                strcpy(save_dir, ".");
        }
 }
 
 
-/*
- * download()  -  download a file or files.  The argument passed to this
- *                function determines which protocol to use.
- *  proto - 0 = paginate, 1 = xmodem, 2 = raw, 3 = ymodem, 4 = zmodem, 5 = save
- */
-void download(CtdlIPC * ipc, int proto)
-{
+// download()  -  download a file or files.  The argument passed to this
+//                function determines which protocol to use.
+//  proto - 0 = paginate, 1 = xmodem, 2 = raw, 3 = ymodem, 4 = zmodem, 5 = save
+void download(CtdlIPC * ipc, int proto) {
        char buf[SIZ];
        char filename[PATH_MAX];
        char tempname[PATH_MAX];
        char transmit_cmd[SIZ];
        FILE *tpipe = NULL;
-/*     int broken = 0;*/
+
        int r;
        int rv = 0;
-       void *file = NULL;      /* The downloaded file */
-       size_t filelen = 0L;    /* The downloaded file length */
+       void *file = NULL;      // The downloaded file
+       size_t filelen = 0L;    // The downloaded file length
 
        if ((room_flags & QR_DOWNLOAD) == 0) {
                scr_printf("*** You cannot download from this room.\n");
@@ -778,7 +748,7 @@ void download(CtdlIPC * ipc, int proto)
 
        newprompt("Enter filename: ", filename, PATH_MAX);
 
-       /* Save to local disk, for folks with their own copy of the client */
+       // Save to local disk, for folks with their own copy of the client
        if (proto == 5) {
                destination_directory(tempname, filename);
                r = CtdlIPCFileDownload(ipc, filename, &file, 0, progress, buf);
@@ -798,31 +768,32 @@ void download(CtdlIPC * ipc, int proto)
        }
        filelen = extract_unsigned_long(buf, 0);
 
-       /* Meta-download for public clients */
-       /* scr_printf("Fetching file from Citadel server...\n"); */
+       // Meta-download for public clients
+       // scr_printf("Fetching file from Citadel server...\n");
        mkdir(tempdir, 0700);
        snprintf(tempname, sizeof tempname, "%s/%s", tempdir, filename);
        tpipe = fopen(tempname, "wb");
        if (fwrite(file, filelen, 1, tpipe) < filelen) {
-               /* FIXME: restart syscall on EINTR 
-                  broken = 1; */
+               // FIXME: restart syscall on EINTR 
+               // broken = 1;
        }
        fclose(tpipe);
        if (file)
                free(file);
 
        if (proto == 0) {
-               /* FIXME: display internally instead */
+               // FIXME: display internally instead
                snprintf(transmit_cmd, sizeof transmit_cmd,
                         "SHELL=/dev/null; export SHELL; TERM=dumb; export TERM; exec more -d <%s", tempname);
-       } else if (proto == 1)
+       }
+       else if (proto == 1)
                snprintf(transmit_cmd, sizeof transmit_cmd, "exec sx %s", tempname);
        else if (proto == 3)
                snprintf(transmit_cmd, sizeof transmit_cmd, "exec sb %s", tempname);
        else if (proto == 4)
                snprintf(transmit_cmd, sizeof transmit_cmd, "exec sz %s", tempname);
        else
-               /* FIXME: display internally instead */
+               // FIXME: display internally instead
                snprintf(transmit_cmd, sizeof transmit_cmd, "exec cat %s", tempname);
 
        stty_ctdl(SB_RESTORE);
@@ -831,23 +802,20 @@ void download(CtdlIPC * ipc, int proto)
                scr_printf("failed to download '%s': %d\n", transmit_cmd, rv);
        stty_ctdl(SB_NO_INTR);
 
-       /* clean up the temporary directory */
+       // clean up the temporary directory
        nukedir(tempdir);
-       ctdl_beep();            /* Beep beep! */
+       ctdl_beep();            // Beep beep!
 }
 
 
-/*
- * read directory of this room
- */
-void roomdir(CtdlIPC * ipc)
-{
+// read directory of this room
+void roomdir(CtdlIPC * ipc) {
        char flnm[256];
        char flsz[32];
        char comment[256];
        char mimetype[256];
        char buf[256];
-       char *listing = NULL;   /* Returned directory listing */
+       char *listing = NULL;   // Returned directory listing
        int r;
 
        r = CtdlIPCReadDirectory(ipc, &listing, buf);
@@ -878,11 +846,8 @@ void roomdir(CtdlIPC * ipc)
 }
 
 
-/*
- * add a user to a private room
- */
-void invite(CtdlIPC * ipc)
-{
+// add a user to a private room
+void invite(CtdlIPC * ipc) {
        char username[USERNAME_SIZE];
        char buf[SIZ];
 
@@ -895,11 +860,8 @@ void invite(CtdlIPC * ipc)
 }
 
 
-/*
- * kick a user out of a room
- */
-void kickout(CtdlIPC * ipc)
-{
+// kick a user out of a room
+void kickout(CtdlIPC * ipc) {
        char username[USERNAME_SIZE];
        char buf[SIZ];
 
@@ -912,11 +874,8 @@ void kickout(CtdlIPC * ipc)
 }
 
 
-/*
- * aide command: kill the current room
- */
-void killroom(CtdlIPC * ipc)
-{
+// aide command: kill the current room
+void killroom(CtdlIPC * ipc) {
        char aaa[100];
        int r;
 
@@ -937,8 +896,8 @@ void killroom(CtdlIPC * ipc)
        dotgoto(ipc, "_BASEROOM_", 0, 0);
 }
 
-void forget(CtdlIPC * ipc)
-{                              /* forget the current room */
+
+void forget(CtdlIPC * ipc) {   // forget the current room
        char buf[SIZ];
 
        scr_printf("Are you sure you want to forget this room? ");
@@ -951,25 +910,22 @@ void forget(CtdlIPC * ipc)
                return;
        }
 
-       /* now return to the lobby */
+       // now return to the lobby
        dotgoto(ipc, "_BASEROOM_", 0, 0);
 }
 
 
-/*
- * create a new room
- */
-void entroom(CtdlIPC * ipc)
-{
+// create a new room
+void entroom(CtdlIPC * ipc) {
        char buf[SIZ];
        char new_room_name[ROOMNAMELEN];
        int new_room_type;
        char new_room_pass[10];
        int new_room_floor;
        int a, b;
-       int r;                  /* IPC response code */
+       int r;                  // IPC response code
 
-       /* Check permission to create room */
+       // Check permission to create room
        r = CtdlIPCCreateRoom(ipc, 0, "", 1, "", 0, buf);
        if (r / 100 != 2) {
                scr_printf("%s\n", buf);
@@ -1004,7 +960,7 @@ void entroom(CtdlIPC * ipc)
                        formout(ipc, "roomaccess");
                }
        } while ((b < '1') || (b > '5'));
-       b -= '0';               /* Portable */
+       b -= '0';               // Portable
        scr_printf("%d\n", b);
        new_room_type = b - 1;
        if (new_room_type == 2) {
@@ -1012,7 +968,8 @@ void entroom(CtdlIPC * ipc)
                for (a = 0; !IsEmptyStr(&new_room_pass[a]); ++a)
                        if (new_room_pass[a] == '|')
                                new_room_pass[a] = '_';
-       } else {
+       }
+       else {
                strcpy(new_room_pass, "");
        }
 
@@ -1038,23 +995,22 @@ void entroom(CtdlIPC * ipc)
                return;
        }
 
-       /* command succeeded... now GO to the new room! */
+       // command succeeded... now GO to the new room!
        dotgoto(ipc, new_room_name, 0, 0);
 }
 
 
 
-void readinfo(CtdlIPC * ipc)
-{                              /* read info file for current room */
+void readinfo(CtdlIPC * ipc) { // read info file for current room
        char buf[SIZ];
        char room_admin_name[64];
-       int r;                  /* IPC response code */
+       int r;                  // IPC response code
        char *text = NULL;
 
-       /* Name of currernt room admin */
+       // Name of currernt room admin
        r = CtdlIPCGetRoomAide(ipc, buf);
        if (r / 100 == 2)
-               safestrncpy(room_admin_name, buf, sizeof room_admin_name);
+               strncpy(room_admin_name, buf, sizeof room_admin_name);
        else
                strcpy(room_admin_name, "");
 
@@ -1072,11 +1028,8 @@ void readinfo(CtdlIPC * ipc)
 }
 
 
-/*
- * <W>ho knows room...
- */
-void whoknows(CtdlIPC * ipc)
-{
+// <W>ho knows room...
+void whoknows(CtdlIPC * ipc) {
        char buf[256];
        char *listing = NULL;
        int r;
@@ -1096,8 +1049,7 @@ void whoknows(CtdlIPC * ipc)
 }
 
 
-void do_edit(CtdlIPC * ipc, char *desc, char *read_cmd, char *check_cmd, char *write_cmd)
-{
+void do_edit(CtdlIPC * ipc, char *desc, char *read_cmd, char *check_cmd, char *write_cmd) {
        FILE *fp;
        char cmd[SIZ];
        int b, cksum, editor_exit;
@@ -1152,7 +1104,8 @@ void do_edit(CtdlIPC * ipc, char *desc, char *read_cmd, char *check_cmd, char *w
                editor_pid = (-1);
                scr_printf("Executed %s\n", editor_path);
                stty_ctdl(0);
-       } else {
+       }
+       else {
                scr_printf("Entering %s.  Press return twice when finished.\n", desc);
                fp = fopen(temp, "r+");
                citedit(fp);
@@ -1184,26 +1137,24 @@ void do_edit(CtdlIPC * ipc, char *desc, char *read_cmd, char *check_cmd, char *w
 }
 
 
-void enterinfo(CtdlIPC * ipc)
-{                              /* edit info file for current room */
+// edit info file for current room
+void enterinfo(CtdlIPC * ipc) {
        do_edit(ipc, "the Info file for this room", "RINF", "EINF 0", "EINF 1");
 }
 
-void enter_bio(CtdlIPC * ipc)
-{
+
+void enter_bio(CtdlIPC * ipc) {
        char cmd[SIZ];
        snprintf(cmd, sizeof cmd, "RBIO %s", fullname);
        do_edit(ipc, "your Bio", cmd, "NOOP", "EBIO");
 }
 
-/*
- * create a new floor
- */
-void create_floor(CtdlIPC * ipc)
-{
+
+// create a new floor
+void create_floor(CtdlIPC * ipc) {
        char buf[SIZ];
        char newfloorname[SIZ];
-       int r;                  /* IPC response code */
+       int r;                  // IPC response code
 
        load_floorlist(ipc);
 
@@ -1219,33 +1170,30 @@ void create_floor(CtdlIPC * ipc)
        r = CtdlIPCCreateFloor(ipc, 1, newfloorname, buf);
        if (r / 100 == 2) {
                scr_printf("Floor has been created.\n");
-       } else {
+       }
+       else {
                scr_printf("%s\n", buf);
        }
 
        load_floorlist(ipc);
 }
 
-/*
- * edit the current floor
- */
-void edit_floor(CtdlIPC * ipc)
-{
+
+// edit the current floor
+void edit_floor(CtdlIPC * ipc) {
        char buf[SIZ];
        struct ExpirePolicy *ep = NULL;
 
        load_floorlist(ipc);
 
-       /* Fetch the expire policy (this will silently fail on old servers,
-        * resulting in "default" policy)
-        */
+       // Fetch the expire policy (this will silently fail on old servers, resulting in "default" policy)
        CtdlIPCGetMessageExpirationPolicy(ipc, 1, &ep, buf);
 
-       /* Interact with the user */
+       // Interact with the user
        scr_printf("You are editing the floor called \"%s\"\n", &floorlist[(int) curr_floor][0]);
        strprompt("Floor name", &floorlist[(int) curr_floor][0], 255);
 
-       /* Angels and demons dancing in my head... */
+       // Angels and demons dancing in my head...
        do {
                snprintf(buf, sizeof buf, "%d", ep->expire_mode);
                strprompt("Floor default message expire policy (? for list)", buf, 1);
@@ -1258,7 +1206,7 @@ void edit_floor(CtdlIPC * ipc)
        } while ((buf[0] < '0') || (buf[0] > '3'));
        ep->expire_mode = buf[0] - '0';
 
-       /* ...lunatics and monsters underneath my bed */
+       // ...lunatics and monsters underneath my bed
        if (ep->expire_mode == 2) {
                snprintf(buf, sizeof buf, "%d", ep->expire_value);
                strprompt("Keep how many messages online?", buf, 10);
@@ -1271,7 +1219,7 @@ void edit_floor(CtdlIPC * ipc)
                ep->expire_value = atol(buf);
        }
 
-       /* Save it */
+       // Save it
        CtdlIPCSetMessageExpirationPolicy(ipc, 1, ep, buf);
        CtdlIPCEditFloor(ipc, curr_floor, &floorlist[(int) curr_floor][0], buf);
        scr_printf("%s\n", buf);
@@ -1279,13 +1227,8 @@ void edit_floor(CtdlIPC * ipc)
 }
 
 
-
-
-/*
- * kill the current floor 
- */
-void kill_floor(CtdlIPC * ipc)
-{
+// kill the current floor 
+void kill_floor(CtdlIPC * ipc) {
        int floornum_to_delete, a;
        char buf[SIZ];