* Client stability and enhancements:
authorMichael Hampton <io_error@uncensored.citadel.org>
Thu, 26 Feb 2004 20:17:30 +0000 (20:17 +0000)
committerMichael Hampton <io_error@uncensored.citadel.org>
Thu, 26 Feb 2004 20:17:30 +0000 (20:17 +0000)
  * CtdlServInfo structure moved inside CtdlIPC; eliminates unnecessary
    global and makes IPC more self-contained
  * Removed redundant serv_ from variable names in CtdlServInfo struct
  * Send SIGHUP to process group when connection_died().  Kills self and
    children (e.g. external editor).

16 files changed:
citadel/ChangeLog
citadel/citadel.c
citadel/citadel_ipc.c
citadel/citadel_ipc.h
citadel/client_chat.c
citadel/commands.c
citadel/ipc_c_tcp.c
citadel/ipcdef.h
citadel/messages.c
citadel/rooms.c
citadel/routines.c
citadel/routines.h
citadel/routines2.c
citadel/screen.c
citadel/screen.h
citadel/whobbs.c

index 49859b5d31bc676fc64d5dfd4c9b5eb8d01933b7..f7aae480cade0d3cdcffb95e2a56f8326ce1eba3 100644 (file)
@@ -1,4 +1,12 @@
  $Log$
+ Revision 614.51  2004/02/26 20:17:29  error
+ * Client stability and enhancements:
+   * CtdlServInfo structure moved inside CtdlIPC; eliminates unnecessary
+     global and makes IPC more self-contained
+   * Removed redundant serv_ from variable names in CtdlServInfo struct
+   * Send SIGHUP to process group when connection_died().  Kills self and
+     children (e.g. external editor).
+
  Revision 614.50  2004/02/25 01:35:34  error
  Missing parameter to a printf() function.  No idea where it went, but I
  put it back.
@@ -5402,4 +5410,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 4caa66956199039e583fb2f907d9d2d00b007859..d31c8ae2d2260fd73a812f1d91f1a040947f76d0 100644 (file)
@@ -68,7 +68,6 @@ char editor_paths[MAX_EDITORS][SIZ];  /* paths to external editors */
 char printcmd[SIZ];            /* print command */
 int editor_pid = (-1);
 char fullname[USERNAME_SIZE];
-struct CtdlServInfo serv_info; /* Info on the server connected */
 int screenwidth;
 int screenheight;
 unsigned room_flags;
@@ -480,7 +479,7 @@ void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto)
                        system(rc_gotmail_cmd);
                }
        }
-       status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
+       status_line(ipc->ServInfo.humannode, ipc->ServInfo.bbs_city,
                        room_name, secure, newmailcount);
 }
 
@@ -700,9 +699,9 @@ void check_screen_dims(void)
 /*
  * set floor mode depending on client, server, and user settings
  */
-void set_floor_mode(void)
+void set_floor_mode(CtdlIPC* ipc)
 {
-       if (serv_info.serv_ok_floors == 0) {
+       if (ipc->ServInfo.ok_floors == 0) {
                floor_mode = 0; /* Don't use floors if the server */
        }
        /* doesn't support them!          */
@@ -758,14 +757,14 @@ void get_serv_info(CtdlIPC *ipc, char *supplied_hostname)
 {
        char buf[SIZ];
 
-       CtdlIPCServerInfo(ipc, &serv_info, buf);
+       CtdlIPCServerInfo(ipc, buf);
 
        /* be nice and identify ourself to the server */
        CtdlIPCIdentifySoftware(ipc, SERVER_TYPE, 0, REV_LEVEL,
                 (ipc->isLocal ? "local" : CITADEL),
                 (supplied_hostname) ? supplied_hostname : 
                 /* Look up the , in the bible if you're confused */
-                (locate_host(buf), buf), buf);
+                (locate_host(ipc, buf), buf), buf);
 
        /* Tell the server what our preferred content formats are */
        if ((CtdlIPCSpecifyPreferredFormats(ipc, buf, "text/html|text/plain") / 100 )== 2) {
@@ -1024,6 +1023,7 @@ int main(int argc, char **argv)
        load_command_set();     /* parse the citadel.rc file */
        sttybbs(SB_NO_INTR);    /* Install the new ones */
        signal(SIGHUP, dropcarr);       /* Cleanup gracefully if carrier is dropped */
+       signal(SIGPIPE, dropcarr);      /* Cleanup gracefully if local conn. dropped */
        signal(SIGTERM, dropcarr);      /* Cleanup gracefully if terminated */
        signal(SIGCONT, catch_sigcont); /* Catch SIGCONT so we can reset terminal */
 #ifdef SIGWINCH
@@ -1167,11 +1167,11 @@ int main(int argc, char **argv)
 #endif
 
        get_serv_info(ipc, telnet_client_host);
-       scr_printf("%-24s\n%s\n%s\n", serv_info.serv_software, serv_info.serv_humannode,
-                  serv_info.serv_bbs_city);
+       scr_printf("%-24s\n%s\n%s\n", ipc->ServInfo.software, ipc->ServInfo.humannode,
+                  ipc->ServInfo.bbs_city);
        scr_flush();
 
-       status_line(serv_info.serv_humannode, serv_info.serv_bbs_city, NULL,
+       status_line(ipc->ServInfo.humannode, ipc->ServInfo.bbs_city, NULL,
                    secure, -1);
 
        screenwidth = 80;       /* default screen dimensions */
@@ -1348,7 +1348,7 @@ NEWUSR:   if (strlen(rc_password) == 0) {
        check_screen_dims();
 #endif
 
-       set_floor_mode();
+       set_floor_mode(ipc);
 
        /* Enter the lobby */
        dotgoto(ipc, "_BASEROOM_", 1, 0);
@@ -1708,12 +1708,12 @@ NEWUSR: if (strlen(rc_password) == 0) {
 
                        case 37:
                                enter_config(ipc, 0);
-                               set_floor_mode();
+                               set_floor_mode(ipc);
                                break;
 
                        case 59:
                                enter_config(ipc, 3);
-                               set_floor_mode();
+                               set_floor_mode(ipc);
                                break;
 
                        case 60:
index 9ef8c5174e162296717d3479653bda99a6b0f583..87dbc631cd16a3de7b35d050ec13b50bf3c57345 100644 (file)
@@ -604,7 +604,7 @@ int CtdlIPCWhoKnowsRoom(CtdlIPC *ipc, char **listing, char *cret)
 
 
 /* INFO */
-int CtdlIPCServerInfo(CtdlIPC *ipc, struct CtdlServInfo *ServInfo, char *cret)
+int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret)
 {
        register int ret;
        size_t bytes;
@@ -612,7 +612,6 @@ int CtdlIPCServerInfo(CtdlIPC *ipc, struct CtdlServInfo *ServInfo, char *cret)
        char buf[SIZ];
 
        if (!cret) return -2;
-       if (!ServInfo) return -2;
 
        ret = CtdlIPCGenericCommand(ipc, "INFO", NULL, 0, &listing, &bytes, cret);
        if (ret / 100 == 1) {
@@ -622,30 +621,31 @@ int CtdlIPCServerInfo(CtdlIPC *ipc, struct CtdlServInfo *ServInfo, char *cret)
                        extract_token(buf, listing, 0, '\n');
                        remove_token(listing, 0, '\n');
                        switch (line++) {
-                       case 0:         ServInfo->serv_pid = atoi(buf);
+                       case 0:         ipc->ServInfo.pid = atoi(buf);
                                        break;
-                       case 1:         strcpy(ServInfo->serv_nodename,buf);
+                       case 1:         strcpy(ipc->ServInfo.nodename,buf);
                                        break;
-                       case 2:         strcpy(ServInfo->serv_humannode,buf);
+                       case 2:         strcpy(ipc->ServInfo.humannode,buf);
                                        break;
-                       case 3:         strcpy(ServInfo->serv_fqdn,buf);
+                       case 3:         strcpy(ipc->ServInfo.fqdn,buf);
                                        break;
-                       case 4:         strcpy(ServInfo->serv_software,buf);
+                       case 4:         strcpy(ipc->ServInfo.software,buf);
                                        break;
-                       case 5:         ServInfo->serv_rev_level = atoi(buf);
+                       case 5:         ipc->ServInfo.rev_level = atoi(buf);
                                        break;
-                       case 6:         strcpy(ServInfo->serv_bbs_city,buf);
+                       case 6:         strcpy(ipc->ServInfo.bbs_city,buf);
                                        break;
-                       case 7:         strcpy(ServInfo->serv_sysadm,buf);
+                       case 7:         strcpy(ipc->ServInfo.sysadm,buf);
                                        break;
-                       case 9:         strcpy(ServInfo->serv_moreprompt,buf);
+                       case 9:         strcpy(ipc->ServInfo.moreprompt,buf);
                                        break;
-                       case 10:        ServInfo->serv_ok_floors = atoi(buf);
+                       case 10:        ipc->ServInfo.ok_floors = atoi(buf);
                                        break;
-                       case 11:        ServInfo->serv_paging_level = atoi(buf);
+                       case 11:        ipc->ServInfo.paging_level = atoi(buf);
                                        break;
-                       case 13:        ServInfo->serv_supports_qnop = atoi(buf);
-                       case 14:        ServInfo->serv_supports_ldap = atoi(buf);
+                       case 13:        ipc->ServInfo.supports_qnop = atoi(buf);
+                                       break;
+                       case 14:        ipc->ServInfo.supports_ldap = atoi(buf);
                                        break;
                        }
                }
@@ -1129,7 +1129,8 @@ int CtdlIPCOnlineUsers(CtdlIPC *ipc, char **listing, time_t *stamp, char *cret)
 /* OPEN */
 int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf,
                size_t resume,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)
+                       (CtdlIPC*, unsigned long, unsigned long),
                char *cret)
 {
        register int ret;
@@ -1175,7 +1176,8 @@ int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf,
 /* OPNA */
 int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part,
                void **buf,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)
+                       (CtdlIPC*, unsigned long, unsigned long),
                char *cret)
 {
        register int ret;
@@ -1213,7 +1215,8 @@ int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part,
 
 /* OIMG */
 int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)
+                       (CtdlIPC*, unsigned long, unsigned long),
                char *cret)
 {
        register int ret;
@@ -1253,7 +1256,8 @@ int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf,
 /* UOPN */
 int CtdlIPCFileUpload(CtdlIPC *ipc, const char *save_as, const char *comment,
                const char *path,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)
+                       (CtdlIPC*, unsigned long, unsigned long),
                char *cret)
 {
        register int ret;
@@ -1285,7 +1289,8 @@ int CtdlIPCFileUpload(CtdlIPC *ipc, const char *save_as, const char *comment,
 /* UIMG */
 int CtdlIPCImageUpload(CtdlIPC *ipc, int for_real, const char *path,
                const char *save_as,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)
+                       (CtdlIPC*, unsigned long, unsigned long),
                char *cret)
 {
        register int ret;
@@ -2139,7 +2144,8 @@ int CtdlIPCSpecifyPreferredFormats(CtdlIPC *ipc, char *cret, char *formats) {
 
 /* READ */
 int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume,
-              void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)
+                       (CtdlIPC*, unsigned long, unsigned long),
               char *cret)
 {
        register size_t len;
@@ -2151,7 +2157,7 @@ int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume,
 
        len = resume;
        if (progress_gauge_callback)
-               progress_gauge_callback(len, bytes);
+               progress_gauge_callback(ipc, len, bytes);
        while (len < bytes) {
                register size_t block;
 
@@ -2162,7 +2168,7 @@ int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume,
                }
                len += block;
                if (progress_gauge_callback)
-                       progress_gauge_callback(len, bytes);
+                       progress_gauge_callback(ipc, len, bytes);
        }
        return len;
 }
@@ -2170,7 +2176,8 @@ int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume,
 /* READ - pipelined */
 int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes,
               size_t resume,
-              void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)
+                       (CtdlIPC*, unsigned long, unsigned long),
               char *cret)
 {
        register size_t len;
@@ -2189,7 +2196,7 @@ int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes,
        len = 0;
        CtdlIPC_lock(ipc);
        if (progress_gauge_callback)
-               progress_gauge_callback(len, bytes);
+               progress_gauge_callback(ipc, len, bytes);
 
        /* How many calls will be in the pipeline? */
        calls = (bytes - resume) / 4096;
@@ -2212,7 +2219,7 @@ int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes,
                        serv_read(ipc, ((*buf) + (i * 4096)), len);
                }
                if (progress_gauge_callback)
-                       progress_gauge_callback(i * 4096 + len, bytes);
+                       progress_gauge_callback(ipc, i * 4096 + len, bytes);
        }
        CtdlIPC_unlock(ipc);
        return len;
@@ -2237,7 +2244,8 @@ int CtdlIPCEndUpload(CtdlIPC *ipc, int discard, char *cret)
 
 /* WRIT */
 int CtdlIPCWriteUpload(CtdlIPC *ipc, const char *path,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)
+                       (CtdlIPC*, unsigned long, unsigned long),
                char *cret)
 {
        register int ret = -1;
@@ -2259,7 +2267,7 @@ int CtdlIPCWriteUpload(CtdlIPC *ipc, const char *path,
        rewind(fd);
 
        if (progress_gauge_callback)
-               progress_gauge_callback(0, bytes);
+               progress_gauge_callback(ipc, 0, bytes);
 
        while (offset < bytes) {
                register size_t to_write;
@@ -2280,7 +2288,7 @@ int CtdlIPCWriteUpload(CtdlIPC *ipc, const char *path,
                        serv_write(ipc, buf, to_write);
                        offset += to_write;
                        if (progress_gauge_callback)
-                               progress_gauge_callback(offset, bytes);
+                               progress_gauge_callback(ipc, offset, bytes);
                        /* Detect short reads and back up if needed */
                        /* offset will never be negative anyway */
                        fseek(fd, (signed)offset, SEEK_SET);
@@ -2289,7 +2297,7 @@ int CtdlIPCWriteUpload(CtdlIPC *ipc, const char *path,
                }
        }
        if (progress_gauge_callback)
-               progress_gauge_callback(1, 1);
+               progress_gauge_callback(ipc, 1, 1);
        return (!ferror(fd) ? ret : -2);
 }
 
@@ -2538,7 +2546,7 @@ static void serv_read(CtdlIPC *ipc, char *buf, unsigned int bytes)
        while (len < bytes) {
                rlen = read(ipc->sock, &buf[len], bytes - len);
                if (rlen < 1) {
-                       connection_died(ipc);
+                       connection_died(ipc, 0);
                        return;
                }
                len += rlen;
@@ -2564,7 +2572,7 @@ static void serv_write(CtdlIPC *ipc, const char *buf, unsigned int nbytes)
                retval = write(ipc->sock, &buf[bytes_written],
                               nbytes - bytes_written);
                if (retval < 1) {
-                       connection_died(ipc);
+                       connection_died(ipc, 0);
                        return;
                }
                bytes_written += retval;
@@ -2604,9 +2612,9 @@ static void serv_read_ssl(CtdlIPC* ipc, char *buf, unsigned int bytes)
                                serv_read(ipc, &buf[len], bytes - len);
                                return;
                        }
-                       error_printf("SSL_read in serv_read:\n");
-                       ERR_print_errors_fp(stderr);
-                       connection_died(ipc);
+                       error_printf("SSL_read in serv_read: %s\n",
+                                       ERR_reason_error_string(ERR_peek_error()));
+                       connection_died(ipc, 1);
                        return;
                }
                len += rlen;
@@ -2647,9 +2655,9 @@ static void serv_write_ssl(CtdlIPC *ipc, const char *buf, unsigned int nbytes)
                                                nbytes - bytes_written);
                                return;
                        }
-                       error_printf("SSL_write in serv_write:\n");
-                       ERR_print_errors_fp(stderr);
-                       connection_died(ipc);
+                       error_printf("SSL_write in serv_write: %s\n",
+                                       ERR_reason_error_string(ERR_peek_error()));
+                       connection_died(ipc, 1);
                        return;
                }
                bytes_written += retval;
index 15b4abc1979147c976c963236f96ea01ac944e97..953c6337cc4170e4aec0fa2a77dee5d2d1d53a1b 100644 (file)
@@ -32,8 +32,27 @@ extern "C" {
 #define ifree(o)       free(o);
 #endif
 
+struct CtdlServInfo {
+       int pid;
+       char nodename[32];
+       char humannode[64];
+       char fqdn[64];
+       char software[64];
+       int rev_level;
+       char bbs_city[64];
+       char sysadm[64];
+       char moreprompt[256];
+       int ok_floors;
+       int paging_level;
+       int supports_qnop;
+       int supports_ldap;
+};
+
 /* This class is responsible for the server connection */
 typedef struct _CtdlIPC {
+       /* The server info for this connection */
+       struct CtdlServInfo ServInfo;
+
 #if defined(HAVE_OPENSSL)
        /* NULL if not encrypted, non-NULL otherwise */
        SSL *ssl;
@@ -182,7 +201,7 @@ int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg,
 int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                struct ctdlipcmessage **mret, char *cret);
 int CtdlIPCWhoKnowsRoom(CtdlIPC *ipc, char **listing, char *cret);
-int CtdlIPCServerInfo(CtdlIPC *ipc, struct CtdlServInfo *ServInfo, char *cret);
+int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret);
 /* int CtdlIPCReadDirectory(CtdlIPC *ipc, struct ctdlipcfile **files, char *cret); */
 int CtdlIPCReadDirectory(CtdlIPC *ipc, char **listing, char *cret);
 int CtdlIPCSetLastRead(CtdlIPC *ipc, long msgnum, char *cret);
@@ -223,22 +242,22 @@ int CtdlIPCNetSendFile(CtdlIPC *ipc, const char *filename,
 int CtdlIPCOnlineUsers(CtdlIPC *ipc, char **listing, time_t *stamp, char *cret);
 int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf,
                size_t resume,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
                char *cret);
 int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part,
                void **buf,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
                char *cret);
 int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
                char *cret);
 int CtdlIPCFileUpload(CtdlIPC *ipc, const char *save_as, const char *comment,
                const char *path,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
                char *cret);
 int CtdlIPCImageUpload(CtdlIPC *ipc, int for_real, const char *path,
                const char *save_as,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
                char *cret);
 int CtdlIPCQueryUsername(CtdlIPC *ipc, const char *username, char *cret);
 int CtdlIPCFloorListing(CtdlIPC *ipc, char **listing, char *cret);
@@ -301,15 +320,15 @@ size_t CtdlIPCPartialRead(CtdlIPC *ipc, void **buf, size_t offset,
                size_t bytes, char *cret);
 int CtdlIPCEndUpload(CtdlIPC *ipc, int discard, char *cret);
 int CtdlIPCWriteUpload(CtdlIPC *ipc, const char *path,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
                char *cret);
 int CtdlIPCEndDownload(CtdlIPC *ipc, char *cret);
 int CtdlIPCReadDownload(CtdlIPC *ipc, void **buf, size_t bytes, size_t resume,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
                char *cret);
 int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes,
                size_t resume,
-               void (*progress_gauge_callback)(unsigned long, unsigned long),
+               void (*progress_gauge_callback)(CtdlIPC*, unsigned long, unsigned long),
                char *cret);
 int CtdlIPCGenericCommand(CtdlIPC *ipc, const char *command,
                const char *to_send, size_t bytes_to_send, char **to_receive,
@@ -323,7 +342,7 @@ void CtdlIPC_SetNetworkStatusCallback(CtdlIPC *ipc, void (*hook)(int state));
 extern int (*error_printf)(char *s, ...);
 void setIPCDeathHook(void (*hook)(void));
 void setIPCErrorPrintf(int (*func)(char *s, ...));
-void connection_died(CtdlIPC *ipc);
+void connection_died(CtdlIPC* ipc, int using_ssl);
 int CtdlIPC_getsockfd(CtdlIPC* ipc);
 char CtdlIPC_get(CtdlIPC* ipc);
 
index f32241154610b11c678b1fe7b2499aa1b0cf91a9..5b1351f7262f680919c403c1df71d66149a149fa 100644 (file)
@@ -48,7 +48,6 @@
 
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
-extern struct CtdlServInfo serv_info;
 extern char temp[];
 void getline(char *, int);
 
@@ -237,7 +236,7 @@ void page_user(CtdlIPC *ipc)
        strprompt("Page who", touser, 30);
 
        /* old server -- use inline paging */
-       if (serv_info.serv_paging_level == 0) {
+       if (ipc->ServInfo.paging_level == 0) {
                newprompt("Message: ", msg, 69);
                snprintf(buf, sizeof buf, "SEXP %s|%s", touser, msg);
                CtdlIPC_putline(ipc, buf);
@@ -249,7 +248,7 @@ void page_user(CtdlIPC *ipc)
                return;
        }
        /* new server -- use extended paging */
-       else if (serv_info.serv_paging_level >= 1) {
+       else if (ipc->ServInfo.paging_level >= 1) {
                snprintf(buf, sizeof buf, "SEXP %s||", touser);
                CtdlIPC_putline(ipc, buf);
                CtdlIPC_getline(ipc, buf);
index 25b879907534e293b4a8d2b2fdb6a9681b8205de..c00d389af1a3ee435b6fca941e3d933155444261 100644 (file)
@@ -270,7 +270,7 @@ void print_express(void)
                                        fprintf(outpipe, "at %d:%02dam",
                                                stamp->tm_hour, stamp->tm_min);
                                fprintf(outpipe, " from %s", sender);
-                               if (strncmp(serv_info.serv_nodename, node, 32))
+                               if (strncmp(ipc_for_signal_handlers->ServInfo.nodename, node, 32))
                                        fprintf(outpipe, " @%s", node);
                                fprintf(outpipe, ":\n%s\n", listing);
                                pclose(outpipe);
@@ -307,7 +307,7 @@ void print_express(void)
                scr_printf(" from %s", sender);
        
                /* Remote node, if any */
-               if (strncmp(serv_info.serv_nodename, node, 32))
+               if (strncmp(ipc_for_signal_handlers->ServInfo.nodename, node, 32))
                        scr_printf(" @%s", node);
        
                scr_printf(":\n");
@@ -376,7 +376,7 @@ static void really_do_keepalive(void) {
         * server supports it) and then do nothing.
         */
        if ( (keepalives_enabled == KA_HALF)
-          && (serv_info.serv_supports_qnop > 0) ) {
+          && (ipc_for_signal_handlers->ServInfo.supports_qnop > 0) ) {
                CtdlIPC_putline(ipc_for_signal_handlers, "QNOP");
        }
 }
@@ -478,9 +478,9 @@ int inkey(void)
                 * necessary and then waits again.
                 */
                do {
-                       scr_set_windowsize();
+                       scr_set_windowsize(ipc_for_signal_handlers);
                        do_keepalive();
-                       scr_set_windowsize();
+                       scr_set_windowsize(ipc_for_signal_handlers);
 
                        FD_ZERO(&rfds);
                        FD_SET(0, &rfds);
index e558932b032db1e11bf1d44dc89aeb379c787f0e..dd7afb33a920ae80f8ba3dc1b56ff9190c88ebf8 100644 (file)
@@ -47,14 +47,22 @@ void setIPCErrorPrintf(int (*func)(char *s, ...)) {
        error_printf = func;
 }
 
-void connection_died(CtdlIPC *ipc) {
+void connection_died(CtdlIPC* ipc, int using_ssl) {
        if (deathHook != NULL)
                deathHook();
 
-       error_printf("\rYour connection to this Citadel server is broken.\n"
-                       "Last error: %s\n"
-                       "Please re-connect and log in again.\n",
-                       strerror(errno));
+       error_printf("\r\nYour connection to %s is broken.\n",
+                       ipc->ServInfo.humannode);
+
+#ifdef HAVE_OPENSSL
+       if (using_ssl) {
+               error_printf("Last error: %s\n",
+                               ERR_reason_error_string(ERR_get_error()));
+       } else
+#endif
+               error_printf("Last error: %s\n", strerror(errno));
+
+       error_printf("Please re-connect and log in again.\n");
        fflush(stderr);
        fflush(stdout);
 
@@ -68,6 +76,9 @@ void connection_died(CtdlIPC *ipc) {
 #endif
        shutdown(ipc->sock, 2);
        ipc->sock = -1;
+
+       /* Hangup - let any children know as well */
+       kill(0, SIGHUP);
 }
 
 
index 94b78120362c9bc4d6f379a8ded612a73a86073f..5b566c0a10a0edc8dd029b1e6d66fc6bd913a2e7 100644 (file)
@@ -37,22 +37,6 @@ extern "C" {
 #define ASYNC_MSG              900
 #define ASYNC_GEXP             01
 
-struct CtdlServInfo {
-       int serv_pid;
-       char serv_nodename[32];
-       char serv_humannode[64];
-       char serv_fqdn[64];
-       char serv_software[64];
-       int serv_rev_level;
-       char serv_bbs_city[64];
-       char serv_sysadm[64];
-       char serv_moreprompt[256];
-       int serv_ok_floors;
-       int serv_paging_level;
-       int serv_supports_qnop;
-       int serv_supports_ldap;
-};
-
 #define QR_PERMANENT   1               /* Room does not purge              */
 #define QR_INUSE       2               /* Set if in use, clear if avail    */
 #define QR_PRIVATE     4               /* Set for any type of private room */
index 54d8557ebadc6d418d0fb76c34dc40a1fdd118ba..1e7bdb394a52fbac9f91157b2d7d09607293121f 100644 (file)
@@ -63,7 +63,7 @@ void sttybbs(int cmd);
 int haschar(const char *st, int ch);
 void getline(char *string, int lim);
 int file_checksum(char *filename);
-void progress(unsigned long curr, unsigned long cmax);
+void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax);
 
 unsigned long *msg_arr = NULL;
 int msg_arr_size = 0;
@@ -73,7 +73,6 @@ char rc_reply_extedit;
 extern char room_name[];
 extern unsigned room_flags;
 extern long highest_msg_read;
-extern struct CtdlServInfo serv_info;
 extern char temp[];
 extern char temp2[];
 extern int screenwidth;
@@ -510,8 +509,8 @@ int read_message(CtdlIPC *ipc,
                }
                if (strlen(message->node)) {
                        if ((room_flags & QR_NETWORK)
-                           || ((strcasecmp(message->node, serv_info.serv_nodename)
-                            && (strcasecmp(message->node, serv_info.serv_fqdn))))) {
+                           || ((strcasecmp(message->node, ipc->ServInfo.nodename)
+                            && (strcasecmp(message->node, ipc->ServInfo.fqdn))))) {
                                if (strlen(message->email) == 0) {
                                        if (dest) {
                                                fprintf(dest, "@%s ", message->node);
@@ -524,7 +523,7 @@ int read_message(CtdlIPC *ipc,
                                }
                        }
                }
-               if (strcasecmp(message->hnod, serv_info.serv_humannode)
+               if (strcasecmp(message->hnod, ipc->ServInfo.humannode)
                    && (strlen(message->hnod)) && (!strlen(message->email))) {
                        if (dest) {
                                fprintf(dest, "(%s) ", message->hnod);
@@ -1434,7 +1433,7 @@ void image_view(CtdlIPC *ipc, unsigned long msg)
                                        size_t len;
        
                                        len = (size_t)extract_long(buf, 0);
-                                       progress(len, len);
+                                       progress(ipc, len, len);
                                        scr_flush();
                                        snprintf(tmp, sizeof tmp, "%s.%s",
                                                tmpnam(NULL),
index 2a7f886dd547060b1586613c6097af4cf43c5e11..431403aa8cf46f4500cbf2fbee0c3c78410a7c86 100644 (file)
@@ -37,7 +37,7 @@
 void sttybbs(int cmd);
 void hit_any_key(void);
 void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto);
-void progress(unsigned long curr, unsigned long cmax);
+void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax);
 int pattern(char *search, char *patn);
 int file_checksum(char *filename);
 int nukedir(char *dirname);
index c8ab5bc212b2c1839c5aa77c729b869edeae8b1a..cfae5d1831b099d7e6477aadb1f5ae29ea4e2c53 100644 (file)
@@ -61,7 +61,6 @@ struct utmp *getutline(struct utmp *ut);
 extern unsigned userflags;
 extern char *axdefs[7];
 extern char sigcaught;
-extern struct CtdlServInfo serv_info;
 extern char rc_floor_mode;
 extern int rc_ansi_color;
 extern int rc_prompt_control;
@@ -81,11 +80,11 @@ void hit_any_key(CtdlIPC *ipc) {    /* hit any key to continue */
 
        color(COLOR_PUSH);
        color(DIM_RED);
-       scr_printf("%s\r",serv_info.serv_moreprompt);
+       scr_printf("%s\r", ipc->ServInfo.moreprompt);
        color(COLOR_POP);
        sttybbs(0);
        b=inkey();
-       for (a=0; a<strlen(serv_info.serv_moreprompt); ++a)
+       for (a=0; a<strlen(ipc->ServInfo.moreprompt); ++a)
                scr_putc(' ');
        scr_putc(13);
        sttybbs(1);
@@ -382,7 +381,7 @@ char *strerror(int e)
 #endif
 
 
-void progress(unsigned long curr, unsigned long cmax)
+void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax)
 {
        static char dots[] =
                "**************************************************";
@@ -392,7 +391,7 @@ void progress(unsigned long curr, unsigned long cmax)
 
        if (curr >= cmax) {
                sln_printf("\r%79s\r","");
-               status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
+               status_line(ipc->ServInfo.humannode, ipc->ServInfo.bbs_city,
                        room_name, secure, 0);
        } else {
                /* a will be range 0-50 rather than 0-100 */
@@ -411,7 +410,7 @@ void progress(unsigned long curr, unsigned long cmax)
  * NOT the same locate_host() in locate_host.c.  This one just does a
  * 'who am i' to try to discover where the user is...
  */
-void locate_host(char *hbuf)
+void locate_host(CtdlIPC* ipc, char *hbuf)
 {
 #ifndef HAVE_UTMP_H
        char buf[SIZ];
@@ -420,7 +419,7 @@ void locate_host(char *hbuf)
 
        who = (FILE *)popen("who am i","r");
        if (who==NULL) {
-               strcpy(hbuf,serv_info.serv_fqdn);
+               strcpy(hbuf, ipc->ServInfo.fqdn);
                return; 
        }
        fgets(buf,sizeof buf,who);
@@ -431,7 +430,7 @@ void locate_host(char *hbuf)
                if ((buf[a]=='(')||(buf[a]==')')) ++b;
        }
        if (b<2) {
-               strcpy(hbuf,serv_info.serv_fqdn);
+               strcpy(hbuf, ipc->ServInfo.fqdn);
                return;
        }
 
@@ -444,7 +443,7 @@ void locate_host(char *hbuf)
                if (buf[a]==')') buf[a] = 0;
        }
 
-       if (strlen(buf)==0) strcpy(hbuf,serv_info.serv_fqdn);
+       if (strlen(buf)==0) strcpy(hbuf, ipc->ServInfo.fqdn);
        else strncpy(hbuf,buf,24);
 #else
        char *tty = ttyname(0);
@@ -456,7 +455,7 @@ void locate_host(char *hbuf)
 
        if (tty == NULL) {
            fail:
-               safestrncpy(hbuf, serv_info.serv_fqdn, 24);
+               safestrncpy(hbuf, ipc->ServInfo.fqdn, 24);
                return;
        }
 
index f6637394bc56d24c2b25a0a1236b29106b7f29df..c1b0131e68012637ce56a9596910c88461a3619b 100644 (file)
@@ -3,12 +3,12 @@ void edituser(CtdlIPC *ipc);
 void interr(int errnum);
 int struncmp(char *lstr, char *rstr, int len);
 int pattern(char *search, char *patn);
-void enter_config(CtdlIPC *ipc, int mode);
-void locate_host(char *hbuf);
+void enter_config(CtdlIPCipc, int mode);
+void locate_host(CtdlIPC* ipc, char *hbuf);
 void misc_server_cmd(CtdlIPC *ipc, char *cmd);
 int nukedir(char *dirname);
 int num_parms(char *source);
 void strproc(char *string);
 void back(int spaces);
-void progress(unsigned long curr, unsigned long cmax);
+void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax);
 int set_attr(CtdlIPC *ipc, unsigned int sval, char *prompt, unsigned int sbit, int backwards);
index 6b366f09817e54727d64832cfadbb9df365179ce..320f40c1c85e92aa93d2cd15556e5bc409a49112 100644 (file)
@@ -161,7 +161,7 @@ void entregis(CtdlIPC *ipc)
                        striplt(diruser);
                        striplt(dirnode);
                        if ((strcasecmp(diruser, fullname))
-                          || (strcasecmp(dirnode, serv_info.serv_nodename))) {
+                          || (strcasecmp(dirnode, ipc->ServInfo.nodename))) {
                                scr_printf(
                                        "\nYou can't use %s as your address.\n",
                                        tmpemail);
@@ -752,7 +752,7 @@ void do_system_configuration(CtdlIPC *ipc)
        snprintf(sc[25], sizeof sc[25], "%d", a);
 
        /* LDAP settings */
-       if (serv_info.serv_supports_ldap) {
+       if (ipc->ServInfo.supports_ldap) {
                a = strlen(&sc[32][0]);
                a = (a ? 1 : 0);        /* Set only to 1 or 0 */
                a = boolprompt("Connect this Citadel to an LDAP directory", a);
index 0785cef0b8d37bce44cf0e2aa5f22d2f931291d8..2acfcd2d1d93c69fd78fed258a015f397674c623 100644 (file)
@@ -5,7 +5,6 @@
  */
 
 #include "sysdep.h"
-#include "screen.h"
 #include <stdio.h>
 #include <signal.h>
 #include <string.h>
@@ -25,6 +24,7 @@
 #include "citadel_ipc.h"
 #include "citadel_decls.h"
 #include "commands.h"
+#include "screen.h"
 
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
 static SCREEN *myscreen = NULL;
@@ -463,7 +463,7 @@ static volatile int caught_sigwinch = 0;
 /*
  * this is not supposed to be called from a signal handler.
  */
-int scr_set_windowsize()
+int scr_set_windowsize(CtdlIPC* ipc)
 {
 #if defined(HAVE_CURSES_H) && !defined(DISABLE_CURSES)
        if (mainwindow && caught_sigwinch) {
@@ -476,8 +476,8 @@ int scr_set_windowsize()
                wresize(statuswindow, 1, screenwidth);
 #endif
                mvwin(statuswindow, screenheight, 0);
-               status_line(serv_info.serv_humannode, serv_info.serv_bbs_city,
-                            room_name, secure, -1);
+               status_line(ipc->ServInfo.humannode, ipc->ServInfo.bbs_city,
+                               room_name, secure, -1);
                wnoutrefresh(mainwindow);
                wnoutrefresh(statuswindow);
                doupdate();
index 4c82a430fbe464f20c51a999f0a761920e1f71c3..f71fa2f3cdfe897a78c906cf03db276a19f3d84e 100644 (file)
@@ -31,7 +31,7 @@ int scr_color(int colornum);
 void scr_flush(void);
 void err_flush(void);
 void sln_flush(void);
-int scr_set_windowsize(void);
+int scr_set_windowsize(CtdlIPC* ipc);
 void windows_new(void);
 void windows_delete(void);
 int scr_blockread(void);
index 1ccd5a6b4e09e8f9a34d29d997078975aaf187c4..2dd59ef793f446ea4e2a0990b8795cba0e347bc8 100644 (file)
@@ -60,7 +60,6 @@ int main(int argc, char **argv)
        int r;                  /* IPC response code */
        time_t timenow;
        char *listing = NULL;
-       struct CtdlServInfo serv_info;
        CtdlIPC *ipc = NULL;
 
        /* If this environment variable is set, we assume that the program
@@ -80,10 +79,10 @@ int main(int argc, char **argv)
                logoff(atoi(buf));
                }
        strcpy(nodetitle, "this BBS");
-       r = CtdlIPCServerInfo(ipc, &serv_info, buf);
+       r = CtdlIPCServerInfo(ipc, buf);
        if (r / 100 == 1) {
-               my_pid = serv_info.serv_pid;
-               strcpy(nodetitle, serv_info.serv_humannode);
+               my_pid = ipc->ServInfo.pid;
+               strcpy(nodetitle, ipc->ServInfo.humannode);
        }
        
        if (www) {