formatting
authorArt Cancro <ajc@citadel.org>
Tue, 9 Mar 2021 00:31:30 +0000 (19:31 -0500)
committerArt Cancro <ajc@citadel.org>
Tue, 9 Mar 2021 00:31:30 +0000 (19:31 -0500)
citadel/auth.c
citadel/ctdlmigrate.c
citadel/database.c
citadel/modules/migrate/serv_migrate.c
citadel/msgbase.c

index f80aab524988ccb98ee63b5dc1cc876dc6fd93c2..0b251280dec3c8c34cf1ce61828cd9d75ce1b10d 100644 (file)
@@ -1,20 +1,18 @@
-/*
- * system-level password checking for host auth mode
- * by Nathan Bryant, March 1999
- * updated by Trey van Riper, June 2005
- *
- * Copyright (c) 1999-2016 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public 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.
- */
-
-#if defined(__linux) || defined(__sun) /* needed for crypt(): */
+// system-level password checking for host auth mode
+// by Nathan Bryant, March 1999
+// updated by Trey van Riper, June 2005
+//
+// Copyright (c) 1999-2016 by the citadel.org team
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public 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.
+
+#if defined(__linux) || defined(__sun) // needed for crypt():
 #define _XOPEN_SOURCE
 #define _XOPEN_SOURCE_EXTENDED 1
 #endif
 #define _XOPEN_SOURCE
 #define _XOPEN_SOURCE_EXTENDED 1
 #endif
 #ifdef HAVE_PAM_START
 #include <security/pam_appl.h>
 
 #ifdef HAVE_PAM_START
 #include <security/pam_appl.h>
 
-/*
- * struct appdata: passed to the conversation function
- */
+// struct appdata: passed to the conversation function
 struct appdata {
        const char *name;
        const char *pw;
 };
 
 struct appdata {
        const char *name;
        const char *pw;
 };
 
-/*
- * conv(): the PAM conversation function. this assumes that a
- * PAM_PROMPT_ECHO_ON is asking for a username, and a PAM_PROMPT_ECHO_OFF is
- * asking for a password. esoteric authentication modules will fail with this
- * code, but we can't really support them with the existing client protocol
- * anyway. the failure mode should be to deny access, in any case.
- */
-static int conv(int num_msg, const struct pam_message **msg,
-               struct pam_response **resp, void *appdata_ptr)
-{
+// conv(): the PAM conversation function. this assumes that a
+// PAM_PROMPT_ECHO_ON is asking for a username, and a PAM_PROMPT_ECHO_OFF is
+// asking for a password. esoteric authentication modules will fail with this
+// code, but we can't really support them with the existing client protocol
+// anyway. the failure mode should be to deny access, in any case.
+static int conv(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) {
        struct pam_response *temp_resp;
        struct appdata *data = appdata_ptr;
 
        struct pam_response *temp_resp;
        struct appdata *data = appdata_ptr;
 
@@ -77,15 +69,12 @@ static int conv(int num_msg, const struct pam_message **msg,
        *resp = temp_resp;
        return PAM_SUCCESS;
 }
        *resp = temp_resp;
        return PAM_SUCCESS;
 }
-#endif                         /* HAVE_PAM_START */
+#endif                         // HAVE_PAM_START
 
 
 
 
-/*
- * check that `pass' is the correct password for `uid'
- * returns zero if no, nonzero if yes
- */
-int validate_password(uid_t uid, const char *pass)
-{
+// check that `pass' is the correct password for `uid'
+// returns zero if no, nonzero if yes
+int validate_password(uid_t uid, const char *pass) {
        if (pass == NULL) {
                return (0);
        }
        if (pass == NULL) {
                return (0);
        }
@@ -145,7 +134,7 @@ int validate_password(uid_t uid, const char *pass)
        if (!strcmp(crypt(pass, crypted_pwd), crypted_pwd)) {
                retval = -1;
        }
        if (!strcmp(crypt(pass, crypted_pwd), crypted_pwd)) {
                retval = -1;
        }
-#endif                         /* HAVE_PAM_START */
+#endif                         // HAVE_PAM_START
 
        return retval;
 }
 
        return retval;
 }
index b2f58b80afddb245a9bbe60eacd3fc8e1b9631a0..d18707a27319dece1fac47bf3314214783739100 100644 (file)
@@ -1,16 +1,14 @@
-/*
- * Across-the-wire migration utility for Citadel
- *
- * Copyright (c) 2009-2021 citadel.org
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public 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.
- */
+// Across-the-wire migration utility for Citadel
+//
+// Copyright (c) 2009-2021 citadel.org
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public 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.
 
 #include <stdlib.h>
 #include <unistd.h>
 
 #include <stdlib.h>
 #include <unistd.h>
 #include "citadel_dirs.h"
 
 
 #include "citadel_dirs.h"
 
 
-
 // yeah, this wouldn't work in a multithreaded program.
 static int gmaxlen = 0;
 static char *gdeftext = NULL;
 
 // yeah, this wouldn't work in a multithreaded program.
 static int gmaxlen = 0;
 static char *gdeftext = NULL;
 
+
+// support function for getz()
 static int limit_rl(FILE *dummy) {
        if (rl_end > gmaxlen) {
                return '\b';
 static int limit_rl(FILE *dummy) {
        if (rl_end > gmaxlen) {
                return '\b';
@@ -52,6 +51,7 @@ static int limit_rl(FILE *dummy) {
 }
 
 
 }
 
 
+// support function for getz()
 static int getz_deftext(void) {
        if (gdeftext) {
                rl_insert_text(gdeftext);
 static int getz_deftext(void) {
        if (gdeftext) {
                rl_insert_text(gdeftext);
@@ -62,11 +62,7 @@ static int getz_deftext(void) {
 }
 
 
 }
 
 
-/*
- * Replacement for gets() that doesn't throw a compiler warning.
- * We're only using it for some simple prompts, so we don't need
- * to worry about attackers exploiting it.
- */
+// Replacement for gets() that uses libreadline.
 void getz(char *buf, int maxlen, char *default_value, char *prompt) {
        rl_startup_hook = getz_deftext;
        rl_getc_function = limit_rl;
 void getz(char *buf, int maxlen, char *default_value, char *prompt) {
        rl_startup_hook = getz_deftext;
        rl_getc_function = limit_rl;
@@ -76,15 +72,14 @@ void getz(char *buf, int maxlen, char *default_value, char *prompt) {
 }
 
 
 }
 
 
+// Exit from the program while displaying an error code
 void ctdlmigrate_exit(int cmdexit) {
        printf("\n\n\033[3%dmExit code %d\033[0m\n", (cmdexit ? 1 : 2), cmdexit);
        exit(cmdexit);
 }
 
 
 void ctdlmigrate_exit(int cmdexit) {
        printf("\n\n\033[3%dmExit code %d\033[0m\n", (cmdexit ? 1 : 2), cmdexit);
        exit(cmdexit);
 }
 
 
-/*
- * Connect to a Citadel on a remote host using a TCP/IP socket
- */
+// Connect to a Citadel on a remote host using a TCP/IP socket
 static int tcp_connectsock(char *host, char *service) {
        struct in6_addr serveraddr;
        struct addrinfo hints;
 static int tcp_connectsock(char *host, char *service) {
        struct in6_addr serveraddr;
        struct addrinfo hints;
@@ -105,32 +100,27 @@ static int tcp_connectsock(char *host, char *service) {
        hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
 
        hints.ai_family = AF_UNSPEC;
        hints.ai_socktype = SOCK_STREAM;
 
-       /*
-        * Handle numeric IPv4 and IPv6 addresses
-        */
+       // Handle numeric IPv4 and IPv6 addresses
        rc = inet_pton(AF_INET, host, &serveraddr);
        rc = inet_pton(AF_INET, host, &serveraddr);
-       if (rc == 1) {          /* dotted quad */
+       if (rc == 1) {                                  // dotted quad
                hints.ai_family = AF_INET;
                hints.ai_flags |= AI_NUMERICHOST;
        } else {
                rc = inet_pton(AF_INET6, host, &serveraddr);
                hints.ai_family = AF_INET;
                hints.ai_flags |= AI_NUMERICHOST;
        } else {
                rc = inet_pton(AF_INET6, host, &serveraddr);
-               if (rc == 1) {  /* IPv6 address */
+               if (rc == 1) {                          // IPv6 address
                        hints.ai_family = AF_INET6;
                        hints.ai_flags |= AI_NUMERICHOST;
                }
        }
 
                        hints.ai_family = AF_INET6;
                        hints.ai_flags |= AI_NUMERICHOST;
                }
        }
 
-       /* Begin the connection process */
-
+       // Begin the connection process
        rc = getaddrinfo(host, service, &hints, &res);
        if (rc != 0) {
                fprintf(stderr, "ctdlmigrate: %s\n", strerror(errno));
                return (-1);
        }
 
        rc = getaddrinfo(host, service, &hints, &res);
        if (rc != 0) {
                fprintf(stderr, "ctdlmigrate: %s\n", strerror(errno));
                return (-1);
        }
 
-       /*
-        * Try all available addresses until we connect to one or until we run out.
-        */
+       // Try all available addresses until we connect to one or until we run out.
        for (ai = res; ai != NULL; ai = ai->ai_next) {
                sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                if (sock < 0) {
        for (ai = res; ai != NULL; ai = ai->ai_next) {
                sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
                if (sock < 0) {
@@ -140,17 +130,18 @@ static int tcp_connectsock(char *host, char *service) {
 
                rc = connect(sock, ai->ai_addr, ai->ai_addrlen);
                if (rc >= 0) {
 
                rc = connect(sock, ai->ai_addr, ai->ai_addrlen);
                if (rc >= 0) {
-                       return (sock);  /* Connected! */
+                       return (sock);  // Connected!
                }
                else {
                        fprintf(stderr, "ctdlmigrate: %s\n", strerror(errno));
                }
                else {
                        fprintf(stderr, "ctdlmigrate: %s\n", strerror(errno));
-                       close(sock);    /* Failed.  Close the socket to avoid fd leak! */
+                       close(sock);    // Failed.  Close the socket to avoid fd leak!
                }
        }
        return (-1);
 }
 
 
                }
        }
        return (-1);
 }
 
 
+// Connect to a Citadel on a remote host using a unix domaion socket
 int uds_connectsock(char *sockpath) {
        int s;
        struct sockaddr_un addr;
 int uds_connectsock(char *sockpath) {
        int s;
        struct sockaddr_un addr;
@@ -175,13 +166,11 @@ int uds_connectsock(char *sockpath) {
 }
 
 
 }
 
 
-/*
- * input binary data from socket
- */
+// input binary data from socket
 void serv_read(int serv_sock, char *buf, int bytes) {
 void serv_read(int serv_sock, char *buf, int bytes) {
-       int len, rlen;
+       int len = 0;
+       int rlen = 0;
 
 
-       len = 0;
        while (len < bytes) {
                rlen = read(serv_sock, &buf[len], bytes - len);
                if (rlen < 1) {
        while (len < bytes) {
                rlen = read(serv_sock, &buf[len], bytes - len);
                if (rlen < 1) {
@@ -192,9 +181,7 @@ void serv_read(int serv_sock, char *buf, int bytes) {
 }
 
 
 }
 
 
-/*
- * send binary to server
- */
+// send binary to server
 void serv_write(int serv_sock, char *buf, int nbytes) {
        int bytes_written = 0;
        int retval;
 void serv_write(int serv_sock, char *buf, int nbytes) {
        int bytes_written = 0;
        int retval;
@@ -208,46 +195,37 @@ void serv_write(int serv_sock, char *buf, int nbytes) {
 }
 
 
 }
 
 
-/*
- * input string from socket - implemented in terms of serv_read()
- */
+// input string from socket - implemented in terms of serv_read()
 void serv_gets(int serv_sock, char *buf) {
        int i;
 
 void serv_gets(int serv_sock, char *buf) {
        int i;
 
-       /* Read one character at a time.
-        */
+       // Read one character at a time.
        for (i = 0;; i++) {
                serv_read(serv_sock, &buf[i], 1);
                if (buf[i] == '\n' || i == (SIZ-1))
                        break;
        }
 
        for (i = 0;; i++) {
                serv_read(serv_sock, &buf[i], 1);
                if (buf[i] == '\n' || i == (SIZ-1))
                        break;
        }
 
-       /* If we got a long line, discard characters until the newline.
-        */
+       // If we got a long line, discard characters until the newline.
        if (i == (SIZ-1)) {
                while (buf[i] != '\n') {
                        serv_read(serv_sock, &buf[i], 1);
                }
        }
 
        if (i == (SIZ-1)) {
                while (buf[i] != '\n') {
                        serv_read(serv_sock, &buf[i], 1);
                }
        }
 
-       /* Strip all trailing nonprintables (crlf)
-        */
+       // Strip all trailing nonprintables (crlf)
        buf[i] = 0;
 }
 
 
        buf[i] = 0;
 }
 
 
-/*
- * send line to server - implemented in terms of serv_write()
- */
+// send line to server - implemented in terms of serv_write()
 void serv_puts(int serv_sock, char *buf) {
        serv_write(serv_sock, buf, strlen(buf));
        serv_write(serv_sock, "\n", 1);
 }
 
 
 void serv_puts(int serv_sock, char *buf) {
        serv_write(serv_sock, buf, strlen(buf));
        serv_write(serv_sock, "\n", 1);
 }
 
 
-/*
- * serv_printf()       Send formatted printable data to the server
- */
+// send formatted printable data to the server
 void serv_printf(int serv_sock, const char *format, ...) {   
        va_list arg_ptr;   
        char buf[1024];
 void serv_printf(int serv_sock, const char *format, ...) {   
        va_list arg_ptr;   
        char buf[1024];
@@ -260,6 +238,7 @@ void serv_printf(int serv_sock, const char *format, ...) {
 }
 
 
 }
 
 
+// You know what main() does.  If you don't, you shouldn't be trying to understand this program.
 int main(int argc, char *argv[]) {
        char ctdldir[PATH_MAX]=CTDLDIR;
        char yesno[2];
 int main(int argc, char *argv[]) {
        char ctdldir[PATH_MAX]=CTDLDIR;
        char yesno[2];
@@ -277,7 +256,7 @@ int main(int argc, char *argv[]) {
        int local_admin_socket = (-1);
        int progress = 0;
 
        int local_admin_socket = (-1);
        int progress = 0;
 
-       /* Parse command line */
+       // Parse command line
        while ((a = getopt(argc, argv, "h:")) != EOF) {
                switch (a) {
                case 'h':
        while ((a = getopt(argc, argv, "h:")) != EOF) {
                switch (a) {
                case 'h':
@@ -313,8 +292,7 @@ int main(int argc, char *argv[]) {
                "the source system.  The target may be a different CPU architecture\n"
                "and/or operating system.  The source system should be running\n"
                "Citadel version \033[33m%d\033[0m or newer, and the target system should be running\n"
                "the source system.  The target may be a different CPU architecture\n"
                "and/or operating system.  The source system should be running\n"
                "Citadel version \033[33m%d\033[0m or newer, and the target system should be running\n"
-               "either the same version or a newer version.  You will also need\n"
-               "the \033[33mrsync\033[0m utility, and OpenSSH v4 or newer.\n"
+               "either the same version or a newer version.\n"
                "\n"
                "You must run this utility on the TARGET SYSTEM.  Any existing data\n"
                "on this system will be ERASED.  Your target system will be on this\n"
                "\n"
                "You must run this utility on the TARGET SYSTEM.  Any existing data\n"
                "on this system will be ERASED.  Your target system will be on this\n"
@@ -331,14 +309,15 @@ int main(int argc, char *argv[]) {
 
        if (!cmdexit) {
                printf( "\033[2J\033[H\n"
 
        if (!cmdexit) {
                printf( "\033[2J\033[H\n"
-                       "          \033[32m╔═══════════════════════════════════════════════╗\n"
-                       "          ║                                               ║\n"
-                       "          ║       \033[33mValidate source and target systems\033[32m      ║\n"
-                       "          ║                                               ║\n"
-                       "          ╚═══════════════════════════════════════════════╝\033[0m\n"
+                       "\033[32m╔═══════════════════════════════════════════════╗\n"
+                       "║                                               ║\n"
+                       "║       \033[33mValidate source and target systems\033[32m      ║\n"
+                       "║                                               ║\n"
+                       "╚═══════════════════════════════════════════════╝\033[0m\n"
                        "\n\n");
        
                        "\n\n");
        
-               printf("First we must validate that the local target system is running and ready to receive data.\n");
+               printf("First we must validate that the local target system is running\n");
+               printf("and ready to receive data.\n");
                printf("Checking connectivity to Citadel in %s...\n", ctdldir);
                local_admin_socket = uds_connectsock("citadel-admin.socket");
                if (local_admin_socket < 0) {
                printf("Checking connectivity to Citadel in %s...\n", ctdldir);
                local_admin_socket = uds_connectsock("citadel-admin.socket");
                if (local_admin_socket < 0) {
@@ -405,15 +384,15 @@ int main(int argc, char *argv[]) {
 
        if (!cmdexit) {
                printf( "\033[2J\033[H\n"
 
        if (!cmdexit) {
                printf( "\033[2J\033[H\n"
-                       "          \033[32m╔═══════════════════════════════════════════════════════════════════╗\n"
-                       "          ║                                                                   ║\n"
-                       "          ║ \033[33mMigrating from: %-50s\033[32m║\n"
-                       "          ║                                                                   ║\n"
-                       "          ╠═══════════════════════════════════════════════════════════════════╣\n"
-                       "          ║                                                                   ║\n"
-                       "          ║ Lines received: 0                           Percent complete: 0   ║\n"
-                       "          ║                                                                   ║\n"
-                       "          ╚═══════════════════════════════════════════════════════════════════╝\033[0m\n"
+                       "\033[32m╔═══════════════════════════════════════════════════════════════════╗\n"
+                       "║                                                                   ║\n"
+                       "║ \033[33mMigrating from: %-50s\033[32m║\n"
+                       "║                                                                   ║\n"
+                       "╠═══════════════════════════════════════════════════════════════════╣\n"
+                       "║                                                                   ║\n"
+                       "║ Lines received: 0                           Percent complete: 0   ║\n"
+                       "║                                                                   ║\n"
+                       "╚═══════════════════════════════════════════════════════════════════╝\033[0m\n"
                        "\n", remote_host
                );
        }
                        "\n", remote_host
                );
        }
@@ -446,11 +425,11 @@ int main(int argc, char *argv[]) {
                        ++linecount;
                        if (!strncasecmp(buf, "<progress>", 10)) {
                                progress = atoi(&buf[10]);
                        ++linecount;
                        if (!strncasecmp(buf, "<progress>", 10)) {
                                progress = atoi(&buf[10]);
-                               printf("\033[8;75H\033[33m%d\033[0m\033[20;0H\n", progress);
+                               printf("\033[8;65H\033[33m%d\033[0m\033[12;0H\n", progress);
                        }
                        if (time(NULL) != last_update) {
                                last_update = time(NULL);
                        }
                        if (time(NULL) != last_update) {
                                last_update = time(NULL);
-                               printf("\033[8;29H\033[33m%d\033[0m\033[20;0H\n", linecount);
+                               printf("\033[8;19H\033[33m%d\033[0m\033[12;0H\n", linecount);
                        }
                        serv_puts(local_admin_socket, buf);
                }
                        }
                        serv_puts(local_admin_socket, buf);
                }
@@ -463,7 +442,9 @@ int main(int argc, char *argv[]) {
                ctdlmigrate_exit(86);
        }
 
                ctdlmigrate_exit(86);
        }
 
-       // FIXME restart the local server now
+       // FIXME restart the local server here
 
 
+       close(remote_server_socket);
+       close(local_admin_socket);
        ctdlmigrate_exit(cmdexit);
 }
        ctdlmigrate_exit(cmdexit);
 }
index ee6aaac2f36cc97a542fc05bda6744ccb99b2221..dfeb4f013946cb1c4f9c1cda84f2a8143c7b192a 100644 (file)
@@ -728,7 +728,8 @@ void cdb_trunc(int cdb) {
        if (TSD->tid != NULL) {
                syslog(LOG_ERR, "db: cdb_trunc must not be called in a transaction.");
                cdb_abort();
        if (TSD->tid != NULL) {
                syslog(LOG_ERR, "db: cdb_trunc must not be called in a transaction.");
                cdb_abort();
-       } else {
+       }
+       else {
                bailIfCursor(TSD->cursors, "attempt to write during r/o cursor");
 
              retry:
                bailIfCursor(TSD->cursors, "attempt to write during r/o cursor");
 
              retry:
index 2ac3cb8ff7a7e7114d8cfa67a0024879f077112b..31815f485903d0c76cb945c472640f6f9ff85edb 100644 (file)
@@ -1,32 +1,28 @@
-/*
- * This module dumps and/or loads the Citadel database in XML format.
- *
- * Copyright (c) 1987-2021 by the citadel.org team
- *
- * This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public 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.
- */
-
-/*
- * Explanation of <progress> tags:
- *
- * 0%          started
- * 2%          finished exporting configuration
- * 7%          finished exporting users
- * 12%         finished exporting openids
- * 17%         finished exporting rooms
- * 18%         finished exporting floors
- * 25%         finished exporting visits
- * 26-99%      exporting messages
- * 100%                finished exporting messages
- *
- * These tags are inserted into the XML stream to give the reader an approximation of its progress.
- */
+// This module dumps and/or loads the Citadel database in XML format.
+//
+// Copyright (c) 1987-2021 by the citadel.org team
+//
+// This program is open source software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public 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.
+//
+// Explanation of <progress> tags:
+//
+// 0%          started
+// 2%          finished exporting configuration
+// 7%          finished exporting users
+// 12%         finished exporting openids
+// 17%         finished exporting rooms
+// 18%         finished exporting floors
+// 25%         finished exporting visits
+// 26-99%      exporting messages
+// 100%                finished exporting messages
+//
+// These tags are inserted into the XML stream to give the reader an approximation of its progress.
 
 #include "sysdep.h"
 #include <stdlib.h>
 
 #include "sysdep.h"
 #include <stdlib.h>
@@ -61,13 +57,11 @@ FILE *migr_global_message_list;
 int total_msgs = 0;
 char *ikey = NULL;                     // If we're importing a config key we store it here.
 
 int total_msgs = 0;
 char *ikey = NULL;                     // If we're importing a config key we store it here.
 
-/******************************************************************************
- *        Code which implements the export appears in this section            *
- ******************************************************************************/
+//*****************************************************************************
+//*       Code which implements the export appears in this section            *
+//*****************************************************************************
 
 
-/*
- * Output a string to the client with these characters escaped:  & < > " '
- */
+// Output a string to the client with these characters escaped:  & < > " '
 void xml_strout(char *str) {
 
        char *c = str;
 void xml_strout(char *str) {
 
        char *c = str;
@@ -100,9 +94,7 @@ void xml_strout(char *str) {
 }
 
 
 }
 
 
-/*
- * Export a user record as XML
- */
+// Export a user record as XML
 void migr_export_users_backend(char *username, void *data) {
 
        struct ctdluser u;
 void migr_export_users_backend(char *username, void *data) {
 
        struct ctdluser u;
@@ -176,7 +168,7 @@ void migr_export_rooms_backend(struct ctdlroom *buf, void *data) {
        cprintf("<msgnum_pic>%ld</msgnum_pic>\n", buf->msgnum_pic);
        client_write(HKEY("</room>\n"));
 
        cprintf("<msgnum_pic>%ld</msgnum_pic>\n", buf->msgnum_pic);
        client_write(HKEY("</room>\n"));
 
-       /* message list goes inside this tag */
+       // message list goes inside this tag
        CtdlGetRoom(&CC->room, buf->QRname);
        client_write(HKEY("<room_messages>"));
        client_write(HKEY("<FRname>"));
        CtdlGetRoom(&CC->room, buf->QRname);
        client_write(HKEY("<room_messages>"));
        client_write(HKEY("<FRname>"));
@@ -197,12 +189,10 @@ void migr_export_rooms(void) {
                fclose(migr_global_message_list);
        }
 
                fclose(migr_global_message_list);
        }
 
-       /*
-        * Process the 'global' message list.  (Sort it and remove dups.
-        * Dups are ok because a message may be in more than one room, but
-        * this will be handled by exporting the reference count, not by
-        * exporting the message multiple times.)
-        */
+       // Process the 'global' message list.  (Sort it and remove dups.
+       // Dups are ok because a message may be in more than one room, but
+       // this will be handled by exporting the reference count, not by
+       // exporting the message multiple times.)
        snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
        if (system(cmd) != 0) {
                syslog(LOG_ERR, "migrate: error %d", errno);
        snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
        if (system(cmd) != 0) {
                syslog(LOG_ERR, "migrate: error %d", errno);
@@ -245,9 +235,7 @@ void migr_export_floors(void) {
 }
 
 
 }
 
 
-/*
- * Return nonzero if the supplied string contains only characters which are valid in a sequence set.
- */
+// Return nonzero if the supplied string contains only characters which are valid in a sequence set.
 int is_sequence_set(char *s) {
        if (!s) return(0);
 
 int is_sequence_set(char *s) {
        if (!s) return(0);
 
@@ -262,9 +250,7 @@ int is_sequence_set(char *s) {
 }
 
 
 }
 
 
-/* 
- *  Traverse the visits file...
- */
+// Traverse the visits file...
 void migr_export_visits(void) {
        visit vbuf;
        struct cdbdata *cdbv;
 void migr_export_visits(void) {
        visit vbuf;
        struct cdbdata *cdbv;
@@ -459,7 +445,7 @@ void migr_export_messages(void) {
                syslog(LOG_ERR, "migrate: export aborted due to client disconnect!");
        }
 
                syslog(LOG_ERR, "migrate: export aborted due to client disconnect!");
        }
 
-       migr_export_message(-1L);       /* This frees the encoding buffer */
+       migr_export_message(-1L);       // This frees the encoding buffer
 }
 
 
 }
 
 
@@ -475,7 +461,7 @@ void migr_do_export(void) {
        cprintf("<version>%d</version>\n", REV_LEVEL);
        cprintf("<progress>%d</progress>\n", 0);
 
        cprintf("<version>%d</version>\n", REV_LEVEL);
        cprintf("<progress>%d</progress>\n", 0);
 
-       /* export the configuration database */
+       // export the configuration database
        migr_export_configs();
        cprintf("<progress>%d</progress>\n", 2);
        
        migr_export_configs();
        cprintf("<progress>%d</progress>\n", 2);
        
@@ -497,16 +483,14 @@ void migr_do_export(void) {
 }
 
 
 }
 
 
-/******************************************************************************
- *                              Import code                                   *
- *    Here's the code that implements the import side.  It's going to end up  *
- *        being one big loop with lots of global variables.  I don't care.    *
- * You wouldn't run multiple concurrent imports anyway.  If this offends your *
- * delicate sensibilities  then go rewrite it in Ruby on Rails or something.  *
- ******************************************************************************/
+//                              Import code
+//   Here's the code that implements the import side.  It's going to end up
+//       being one big loop with lots of global variables.  I don't care.
+// You wouldn't run multiple concurrent imports anyway.  If this offends your
+//  delicate sensibilities  then go rewrite it in Ruby on Rails or something.
 
 
 
 
-int citadel_migrate_data = 0;          /* Are we inside a <citadel_migrate_data> tag pair? */
+int citadel_migrate_data = 0;          // Are we inside a <citadel_migrate_data> tag pair?
 StrBuf *migr_chardata = NULL;
 StrBuf *migr_MsgData = NULL;
 struct ctdluser usbuf;
 StrBuf *migr_chardata = NULL;
 StrBuf *migr_MsgData = NULL;
 struct ctdluser usbuf;
@@ -520,9 +504,7 @@ visit vbuf;
 struct MetaData smi;
 long import_msgnum = 0;
 
 struct MetaData smi;
 long import_msgnum = 0;
 
-/*
- * This callback stores up the data which appears in between tags.
- */
+// This callback stores up the data which appears in between tags.
 void migr_xml_chardata(void *data, const XML_Char *s, int len) {
        StrBufAppendBufPlain(migr_chardata, s, len, 0);
 }
 void migr_xml_chardata(void *data, const XML_Char *s, int len) {
        StrBufAppendBufPlain(migr_chardata, s, len, 0);
 }
@@ -531,19 +513,19 @@ void migr_xml_chardata(void *data, const XML_Char *s, int len) {
 void migr_xml_start(void *data, const char *el, const char **attr) {
        int i;
 
 void migr_xml_start(void *data, const char *el, const char **attr) {
        int i;
 
-       /*** GENERAL STUFF ***/
+       //  *** GENERAL STUFF ***
 
 
-       /* Reset chardata_len to zero and init buffer */
+       // Reset chardata_len to zero and init buffer
        FlushStrBuf(migr_chardata);
        FlushStrBuf(migr_MsgData);
 
        if (!strcasecmp(el, "citadel_migrate_data")) {
                ++citadel_migrate_data;
 
        FlushStrBuf(migr_chardata);
        FlushStrBuf(migr_MsgData);
 
        if (!strcasecmp(el, "citadel_migrate_data")) {
                ++citadel_migrate_data;
 
-               /* As soon as it looks like the input data is a genuine Citadel XML export,
-                * whack the existing database on disk to make room for the new one.
-                */
+               // As soon as it looks like the input data is a genuine Citadel XML export,
+               // whack the existing database on disk to make room for the new one.
                if (citadel_migrate_data == 1) {
                if (citadel_migrate_data == 1) {
+                       syslog(LOG_INFO, "migrate: erasing existing databases so we can receive the incoming import");
                        for (i = 0; i < MAXCDB; ++i) {
                                cdb_trunc(i);
                        }
                        for (i = 0; i < MAXCDB; ++i) {
                                cdb_trunc(i);
                        }
@@ -556,9 +538,8 @@ void migr_xml_start(void *data, const char *el, const char **attr) {
                return;
        }
 
                return;
        }
 
-       /* When we begin receiving XML for one of these record types, clear out the associated
-        * buffer so we don't accidentally carry over any data from a previous record.
-        */
+       // When we begin receiving XML for one of these record types, clear out the associated
+       // buffer so we don't accidentally carry over any data from a previous record.
        if (!strcasecmp(el, "user"))                    memset(&usbuf, 0, sizeof (struct ctdluser));
        else if (!strcasecmp(el, "openid"))             memset(openid_url, 0, sizeof openid_url);
        else if (!strcasecmp(el, "room"))               memset(&qrbuf, 0, sizeof (struct ctdlroom));
        if (!strcasecmp(el, "user"))                    memset(&usbuf, 0, sizeof (struct ctdluser));
        else if (!strcasecmp(el, "openid"))             memset(openid_url, 0, sizeof openid_url);
        else if (!strcasecmp(el, "room"))               memset(&qrbuf, 0, sizeof (struct ctdlroom));
@@ -676,7 +657,7 @@ void migr_xml_end(void *data, const char *el) {
        long msgnum = 0L;
        long *msglist = NULL;
        int msglist_alloc = 0;
        long msgnum = 0L;
        long *msglist = NULL;
        int msglist_alloc = 0;
-       /*** GENERAL STUFF ***/
+       // *** GENERAL STUFF ***
 
        if (!strcasecmp(el, "citadel_migrate_data")) {
                --citadel_migrate_data;
 
        if (!strcasecmp(el, "citadel_migrate_data")) {
                --citadel_migrate_data;
@@ -690,7 +671,7 @@ void migr_xml_end(void *data, const char *el) {
 
        // syslog(LOG_DEBUG, "END TAG: <%s> DATA: <%s>\n", el, (migr_chardata_len ? migr_chardata : ""));
 
 
        // syslog(LOG_DEBUG, "END TAG: <%s> DATA: <%s>\n", el, (migr_chardata_len ? migr_chardata : ""));
 
-       /*** CONFIG ***/
+       // *** CONFIG ***
 
        if (!strcasecmp(el, "config")) {
                syslog(LOG_DEBUG, "migrate: imported config key=%s", ikey);
 
        if (!strcasecmp(el, "config")) {
                syslog(LOG_DEBUG, "migrate: imported config key=%s", ikey);
@@ -705,7 +686,7 @@ void migr_xml_end(void *data, const char *el) {
                }
        }
 
                }
        }
 
-       /*** USER ***/
+       // *** USER ***
        else if ((!strncasecmp(el, HKEY("u_"))) && 
                 migr_userrecord(data, el))
                ; /* Nothing to do anymore */
        else if ((!strncasecmp(el, HKEY("u_"))) && 
                 migr_userrecord(data, el))
                ; /* Nothing to do anymore */
@@ -714,12 +695,12 @@ void migr_xml_end(void *data, const char *el) {
                syslog(LOG_INFO, "migrate: imported user: %s", usbuf.fullname);
        }
 
                syslog(LOG_INFO, "migrate: imported user: %s", usbuf.fullname);
        }
 
-       /*** OPENID ***/
+       // *** OPENID ***
 
        else if (!strcasecmp(el, "oid_url"))                    safestrncpy(openid_url, ChrPtr(migr_chardata), sizeof openid_url);
        else if (!strcasecmp(el, "oid_usernum"))                openid_usernum = atol(ChrPtr(migr_chardata));
 
 
        else if (!strcasecmp(el, "oid_url"))                    safestrncpy(openid_url, ChrPtr(migr_chardata), sizeof openid_url);
        else if (!strcasecmp(el, "oid_usernum"))                openid_usernum = atol(ChrPtr(migr_chardata));
 
-       else if (!strcasecmp(el, "openid")) {                   /* see serv_openid_rp.c for a description of the record format */
+       else if (!strcasecmp(el, "openid")) {                   // see serv_openid_rp.c for a description of the record format
                char *oid_data;
                int oid_data_len;
                oid_data_len = sizeof(long) + strlen(openid_url) + 1;
                char *oid_data;
                int oid_data_len;
                oid_data_len = sizeof(long) + strlen(openid_url) + 1;
@@ -731,16 +712,16 @@ void migr_xml_end(void *data, const char *el) {
                syslog(LOG_INFO, "migrate: imported OpenID: %s (%ld)", openid_url, openid_usernum);
        }
 
                syslog(LOG_INFO, "migrate: imported OpenID: %s (%ld)", openid_url, openid_usernum);
        }
 
-       /*** ROOM ***/
+       // *** ROOM ***
        else if ((!strncasecmp(el, HKEY("QR"))) && 
                 migr_roomrecord(data, el))
        else if ((!strncasecmp(el, HKEY("QR"))) && 
                 migr_roomrecord(data, el))
-               ; /* Nothing to do anymore */
+               ; // Nothing to do anymore
        else if (!strcasecmp(el, "room")) {
                CtdlPutRoom(&qrbuf);
                syslog(LOG_INFO, "migrate: imported room: %s", qrbuf.QRname);
        }
 
        else if (!strcasecmp(el, "room")) {
                CtdlPutRoom(&qrbuf);
                syslog(LOG_INFO, "migrate: imported room: %s", qrbuf.QRname);
        }
 
-       /*** ROOM MESSAGE POINTERS ***/
+       // *** ROOM MESSAGE POINTERS ***
 
        else if (!strcasecmp(el, "FRname")) {
                safestrncpy(FRname, ChrPtr(migr_chardata), sizeof FRname);
 
        else if (!strcasecmp(el, "FRname")) {
                safestrncpy(FRname, ChrPtr(migr_chardata), sizeof FRname);
@@ -786,26 +767,26 @@ void migr_xml_end(void *data, const char *el) {
                }
        }
 
                }
        }
 
-       /*** FLOORS ***/
+       // *** FLOORS ***
        else if ((!strncasecmp(el, HKEY("f_"))) && 
                 migr_floorrecord(data, el))
        else if ((!strncasecmp(el, HKEY("f_"))) && 
                 migr_floorrecord(data, el))
-               ; /* Nothing to do anymore */
+               ; // Nothing to do anymore
 
        else if (!strcasecmp(el, "floor")) {
                CtdlPutFloor(&flbuf, floornum);
                syslog(LOG_INFO, "migrate: imported floor #%d (%s)", floornum, flbuf.f_name);
        }
 
 
        else if (!strcasecmp(el, "floor")) {
                CtdlPutFloor(&flbuf, floornum);
                syslog(LOG_INFO, "migrate: imported floor #%d (%s)", floornum, flbuf.f_name);
        }
 
-       /*** VISITS ***/
+       // *** VISITS ***
        else if ((!strncasecmp(el, HKEY("v_"))) && migr_visitrecord(data, el)) {
        else if ((!strncasecmp(el, HKEY("v_"))) && migr_visitrecord(data, el)) {
-               ; /* Nothing to do anymore */
+               ; // Nothing to do anymore
        }
        else if (!strcasecmp(el, "visit")) {
                put_visit(&vbuf);
                syslog(LOG_INFO, "migrate: imported visit: %ld/%ld/%ld", vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
        }
 
        }
        else if (!strcasecmp(el, "visit")) {
                put_visit(&vbuf);
                syslog(LOG_INFO, "migrate: imported visit: %ld/%ld/%ld", vbuf.v_roomnum, vbuf.v_roomgen, vbuf.v_usernum);
        }
 
-       /*** MESSAGES ***/
+       // *** MESSAGES ***
        
        else if (!strcasecmp(el, "msg_msgnum"))                 smi.meta_msgnum = import_msgnum = atol(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "msg_meta_refcount"))          smi.meta_refcount = atoi(ChrPtr(migr_chardata));
        
        else if (!strcasecmp(el, "msg_msgnum"))                 smi.meta_msgnum = import_msgnum = atol(ChrPtr(migr_chardata));
        else if (!strcasecmp(el, "msg_meta_refcount"))          smi.meta_refcount = atoi(ChrPtr(migr_chardata));
@@ -834,8 +815,8 @@ void migr_xml_end(void *data, const char *el) {
                }
 
                syslog(LOG_INFO,
                }
 
                syslog(LOG_INFO,
-                      "migrate: %s message #%ld, size=%d, refcount=%d, bodylength=%ld, content-type: %s",
-                      (rc!= 0)?"failed to import ":"Imported ",
+                      "migrate: %s message #%ld, size=%d, ref=%d, body=%ld, content-type: %s",
+                      (rc!= 0)?"failed to import":"imported",
                       import_msgnum,
                       StrLength(migr_MsgData),
                       smi.meta_refcount,
                       import_msgnum,
                       StrLength(migr_MsgData),
                       smi.meta_refcount,
@@ -845,15 +826,13 @@ void migr_xml_end(void *data, const char *el) {
                memset(&smi, 0, sizeof(smi));
        }
 
                memset(&smi, 0, sizeof(smi));
        }
 
-       /*** MORE GENERAL STUFF ***/
+       // *** MORE GENERAL STUFF ***
 
        FlushStrBuf(migr_chardata);
 }
 
 
 
        FlushStrBuf(migr_chardata);
 }
 
 
-/*
- * Import begins here
- */
+// Import begins here
 void migr_do_import(void) {
        XML_Parser xp;
        char buf[SIZ];
 void migr_do_import(void) {
        XML_Parser xp;
        char buf[SIZ];
@@ -893,12 +872,11 @@ void migr_do_import(void) {
 }
 
 
 }
 
 
-/******************************************************************************
- *                         Dispatcher, Common code                            *
- ******************************************************************************/
-/*
- * Dump out the pathnames of directories which can be copied "as is"
- */
+// ******************************************************************************
+// *                         Dispatcher, Common code                            *
+// ******************************************************************************
+
+// Dump out the pathnames of directories which can be copied "as is"
 void migr_do_listdirs(void) {
        cprintf("%d Don't forget these:\n", LISTING_FOLLOWS);
        cprintf("files|%s\n",           ctdl_file_dir);
 void migr_do_listdirs(void) {
        cprintf("%d Don't forget these:\n", LISTING_FOLLOWS);
        cprintf("files|%s\n",           ctdl_file_dir);
@@ -908,9 +886,9 @@ void migr_do_listdirs(void) {
 }
 
 
 }
 
 
-/******************************************************************************
- *                    Repair database integrity                               *
- ******************************************************************************/
+/******************************************************************************
+// *                    Repair database integrity                               *
+// ******************************************************************************
 
 StrBuf *PlainMessageBuf = NULL;
 HashList *UsedMessageIDS = NULL;
 
 StrBuf *PlainMessageBuf = NULL;
 HashList *UsedMessageIDS = NULL;
@@ -920,11 +898,10 @@ int migr_restore_message_metadata(long msgnum, int refcount) {
        struct CtdlMessage *msg;
        char *mptr = NULL;
 
        struct CtdlMessage *msg;
        char *mptr = NULL;
 
-       /* We can use a static buffer here because there will never be more than
-        * one of this operation happening at any given time, and it's really best
-        * to just keep it allocated once instead of torturing malloc/free.
-        * Call this function with msgnum "-1" to free the buffer when finished.
-        */
+       // We can use a static buffer here because there will never be more than
+       // one of this operation happening at any given time, and it's really best
+       // to just keep it allocated once instead of torturing malloc/free.
+       // Call this function with msgnum "-1" to free the buffer when finished.
        static int encoded_alloc = 0;
        static char *encoded_msg = NULL;
 
        static int encoded_alloc = 0;
        static char *encoded_msg = NULL;
 
@@ -942,7 +919,7 @@ int migr_restore_message_metadata(long msgnum, int refcount) {
                PlainMessageBuf = NewStrBufPlain(NULL, 10*SIZ);
        }
 
                PlainMessageBuf = NewStrBufPlain(NULL, 10*SIZ);
        }
 
-       /* Ok, here we go ... */
+       // Ok, here we go ...
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
 
        msg = CtdlFetchMessage(msgnum, 1);
        if (msg == NULL) {
@@ -953,7 +930,7 @@ int migr_restore_message_metadata(long msgnum, int refcount) {
        smi.meta_msgnum = msgnum;
        smi.meta_refcount = refcount;
        
        smi.meta_msgnum = msgnum;
        smi.meta_refcount = refcount;
        
-       /* restore the content type from the message body: */
+       // restore the content type from the message body:
        mptr = bmstrcasestr(msg->cm_fields[eMesageText], "Content-type:");
        if (mptr != NULL) {
                char *aptr;
        mptr = bmstrcasestr(msg->cm_fields[eMesageText], "Content-type:");
        if (mptr != NULL) {
                char *aptr;
@@ -996,7 +973,7 @@ void migr_check_room_msg(long msgnum, void *userdata) {
 
 
 void migr_check_rooms_backend(struct ctdlroom *buf, void *data) {
 
 
 void migr_check_rooms_backend(struct ctdlroom *buf, void *data) {
-       /* message list goes inside this tag */
+       // message list goes inside this tag
        CtdlGetRoom(&CC->room, buf->QRname);
        CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, migr_check_room_msg, NULL);
 }
        CtdlGetRoom(&CC->room, buf->QRname);
        CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL, NULL, migr_check_room_msg, NULL);
 }
@@ -1035,12 +1012,10 @@ void migr_do_restore_meta(void) {
                fclose(migr_global_message_list);
        }
 
                fclose(migr_global_message_list);
        }
 
-       /*
-        * Process the 'global' message list.  (Sort it and remove dups.
-        * Dups are ok because a message may be in more than one room, but
-        * this will be handled by exporting the reference count, not by
-        * exporting the message multiple times.)
-        */
+       // Process the 'global' message list.  (Sort it and remove dups.
+       // Dups are ok because a message may be in more than one room, but
+       // this will be handled by exporting the reference count, not by
+       // exporting the message multiple times.)
        snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
        if (system(cmd) != 0) {
                syslog(LOG_ERR, "migrate: error %d", errno);
        snprintf(cmd, sizeof cmd, "sort -n <%s >%s", migr_tempfilename1, migr_tempfilename2);
        if (system(cmd) != 0) {
                syslog(LOG_ERR, "migrate: error %d", errno);
@@ -1091,15 +1066,15 @@ void migr_do_restore_meta(void) {
                fclose(migr_global_message_list);
        }
 
                fclose(migr_global_message_list);
        }
 
-       migr_restore_message_metadata(-1L, -1); /* This frees the encoding buffer */
+       migr_restore_message_metadata(-1L, -1); // This frees the encoding buffer
        cprintf("%d system analysis completed", CIT_OK);
        Ctx->kill_me = 1;
 }
 
 
        cprintf("%d system analysis completed", CIT_OK);
        Ctx->kill_me = 1;
 }
 
 
-/******************************************************************************
- *                         Dispatcher, Common code                            *
- ******************************************************************************/
+/******************************************************************************
+// *                         Dispatcher, Common code                            *
+// ******************************************************************************
 void cmd_migr(char *cmdbuf) {
        char cmd[32];
        
 void cmd_migr(char *cmdbuf) {
        char cmd[32];
        
@@ -1139,9 +1114,9 @@ void cmd_migr(char *cmdbuf) {
 }
 
 
 }
 
 
-/******************************************************************************
- *                              Module Hook                                  *
- ******************************************************************************/
+/******************************************************************************
+// *                              Module Hook                                   *
+// ******************************************************************************
 
 CTDL_MODULE_INIT(migrate)
 {
 
 CTDL_MODULE_INIT(migrate)
 {
@@ -1150,6 +1125,6 @@ CTDL_MODULE_INIT(migrate)
                CtdlRegisterProtoHook(cmd_migr, "MIGR", "Across-the-wire migration");
        }
        
                CtdlRegisterProtoHook(cmd_migr, "MIGR", "Across-the-wire migration");
        }
        
-       /* return our module name for the log */
+       // return our module name for the log
        return "migrate";
 }
        return "migrate";
 }
index 1dd266acdab775760246dfeb3343c505eafebf29..77bc946156b93f57f13931ad2b2ef985aff9f916 100644 (file)
@@ -423,19 +423,19 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
        StrBuf *lostr;
        StrBuf *histr;
        const char *pvset;
        StrBuf *lostr;
        StrBuf *histr;
        const char *pvset;
-       char *is_set;   /* actually an array of booleans */
+       char *is_set;   // actually an array of booleans
 
 
-       /* Don't bother doing *anything* if we were passed a list of zero messages */
+       // Don't bother doing *anything* if we were passed a list of zero messages
        if (num_target_msgnums < 1) {
                return;
        }
 
        if (num_target_msgnums < 1) {
                return;
        }
 
-       /* If no room was specified, we go with the current room. */
+       // If no room was specified, we go with the current room.
        if (!which_room) {
                which_room = &CC->room;
        }
 
        if (!which_room) {
                which_room = &CC->room;
        }
 
-       /* If no user was specified, we go with the current user. */
+       // If no user was specified, we go with the current user.
        if (!which_user) {
                which_user = &CC->user;
        }
        if (!which_user) {
                which_user = &CC->user;
        }
@@ -446,19 +446,19 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                   which_set,
                   which_room->QRname);
 
                   which_set,
                   which_room->QRname);
 
-       /* Learn about the user and room in question */
+       // Learn about the user and room in question
        CtdlGetRelationship(&vbuf, which_user, which_room);
 
        CtdlGetRelationship(&vbuf, which_user, which_room);
 
-       /* Load the message list */
+       // Load the message list
        cdbfr = cdb_fetch(CDB_MSGLISTS, &which_room->QRnumber, sizeof(long));
        if (cdbfr != NULL) {
                msglist = (long *) cdbfr->ptr;
        cdbfr = cdb_fetch(CDB_MSGLISTS, &which_room->QRnumber, sizeof(long));
        if (cdbfr != NULL) {
                msglist = (long *) cdbfr->ptr;
-               cdbfr->ptr = NULL;      /* CtdlSetSeen() now owns this memory */
+               cdbfr->ptr = NULL;      // CtdlSetSeen() now owns this memory
                num_msgs = cdbfr->len / sizeof(long);
                cdb_free(cdbfr);
        }
        else {
                num_msgs = cdbfr->len / sizeof(long);
                cdb_free(cdbfr);
        }
        else {
-               return; /* No messages at all?  No further action. */
+               return; // No messages at all?  No further action.
        }
 
        is_set = malloc(num_msgs * sizeof(char));
        }
 
        is_set = malloc(num_msgs * sizeof(char));
@@ -477,7 +477,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
        }
 
 
        }
 
 
-#if 0  /* This is a special diagnostic section.  Do not allow it to run during normal operation. */
+#if 0  // This is a special diagnostic section.  Do not allow it to run during normal operation.
        syslog(LOG_DEBUG, "There are %d messages in the room.\n", num_msgs);
        for (i=0; i<num_msgs; ++i) {
                if ((i > 0) && (msglist[i] <= msglist[i-1])) abort();
        syslog(LOG_DEBUG, "There are %d messages in the room.\n", num_msgs);
        for (i=0; i<num_msgs; ++i) {
                if ((i > 0) && (msglist[i] <= msglist[i-1])) abort();
@@ -488,7 +488,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
        }
 #endif
 
        }
 #endif
 
-       /* Translate the existing sequence set into an array of booleans */
+       // Translate the existing sequence set into an array of booleans
        setstr = NewStrBuf();
        lostr = NewStrBuf();
        histr = NewStrBuf();
        setstr = NewStrBuf();
        lostr = NewStrBuf();
        histr = NewStrBuf();
@@ -521,7 +521,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
        FreeStrBuf(&lostr);
        FreeStrBuf(&histr);
 
        FreeStrBuf(&lostr);
        FreeStrBuf(&histr);
 
-       /* Now translate the array of booleans back into a sequence set */
+       // Now translate the array of booleans back into a sequence set
        FlushStrBuf(vset);
        was_seen = 0;
        lo = (-1);
        FlushStrBuf(vset);
        was_seen = 0;
        lo = (-1);
@@ -530,7 +530,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
        for (i=0; i<num_msgs; ++i) {
                is_seen = is_set[i];
 
        for (i=0; i<num_msgs; ++i) {
                is_seen = is_set[i];
 
-               /* Apply changes */
+               // Apply changes
                for (k=0; k<num_target_msgnums; ++k) {
                        if (msglist[i] == target_msgnums[k]) {
                                is_seen = target_setting;
                for (k=0; k<num_target_msgnums; ++k) {
                        if (msglist[i] == target_msgnums[k]) {
                                is_seen = target_setting;
@@ -569,23 +569,19 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                was_seen = is_seen;
        }
 
                was_seen = is_seen;
        }
 
-       /*
-        * We will have to stuff this string back into a 4096 byte buffer, so if it's
-        * larger than that now, truncate it by removing tokens from the beginning.
-        * The limit of 100 iterations is there to prevent an infinite loop in case
-        * something unexpected happens.
-        */
+       // We will have to stuff this string back into a 4096 byte buffer, so if it's
+       // larger than that now, truncate it by removing tokens from the beginning.
+       // The limit of 100 iterations is there to prevent an infinite loop in case
+       // something unexpected happens.
        int number_of_truncations = 0;
        while ( (StrLength(vset) > SIZ) && (number_of_truncations < 100) ) {
                StrBufRemove_token(vset, 0, ',');
                ++number_of_truncations;
        }
 
        int number_of_truncations = 0;
        while ( (StrLength(vset) > SIZ) && (number_of_truncations < 100) ) {
                StrBufRemove_token(vset, 0, ',');
                ++number_of_truncations;
        }
 
-       /*
-        * If we're truncating the sequence set of messages marked with the 'seen' flag,
-        * we want the earliest messages (the truncated ones) to be marked, not unmarked.
-        * Otherwise messages at the beginning will suddenly appear to be 'unseen'.
-        */
+       // If we're truncating the sequence set of messages marked with the 'seen' flag,
+       // we want the earliest messages (the truncated ones) to be marked, not unmarked.
+       // Otherwise messages at the beginning will suddenly appear to be 'unseen'.
        if ( (which_set == ctdlsetseen_seen) && (number_of_truncations > 0) ) {
                StrBuf *first_tok;
                first_tok = NewStrBuf();
        if ( (which_set == ctdlsetseen_seen) && (number_of_truncations > 0) ) {
                StrBuf *first_tok;
                first_tok = NewStrBuf();
@@ -608,7 +604,7 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
                vset = new_set;
        }
 
                vset = new_set;
        }
 
-       /* Decide which message set we're manipulating */
+       // Decide which message set we're manipulating
        switch (which_set) {
                case ctdlsetseen_seen:
                        safestrncpy(vbuf.v_seen, ChrPtr(vset), sizeof vbuf.v_seen);
        switch (which_set) {
                case ctdlsetseen_seen:
                        safestrncpy(vbuf.v_seen, ChrPtr(vset), sizeof vbuf.v_seen);
@@ -625,10 +621,8 @@ void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
 }
 
 
 }
 
 
-/*
- * API function to perform an operation for each qualifying message in the
- * current room.  (Returns the number of messages processed.)
- */
+// API function to perform an operation for each qualifying message in the
+// current room.  (Returns the number of messages processed.)
 int CtdlForEachMessage(int mode, long ref, char *search_string,
                        char *content_type,
                        struct CtdlMessage *compare,
 int CtdlForEachMessage(int mode, long ref, char *search_string,
                        char *content_type,
                        struct CtdlMessage *compare,