]> code.citadel.org Git - citadel.git/blobdiff - citadel/messages.c
* Variable names, comments, documentation, etc... removed the acronym 'BBS'
[citadel.git] / citadel / messages.c
index 1e7bdb394a52fbac9f91157b2d7d09607293121f..701ad9d2a0a288a992ea2ebad4fe515984d282c4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Citadel/UX message support routines
+ * Citadel message support routines
  * see copyright.txt for copyright information
  */
 
@@ -59,7 +59,7 @@ struct cittext {
        char text[MAXWORDBUF];
 };
 
-void sttybbs(int cmd);
+void stty_ctdl(int cmd);
 int haschar(const char *st, int ch);
 void getline(char *string, int lim);
 int file_checksum(char *filename);
@@ -402,7 +402,7 @@ int read_message(CtdlIPC *ipc,
        has_images = 0;
 
        sigcaught = 0;
-       sttybbs(1);
+       stty_ctdl(1);
 
        strcpy(reply_to, NO_REPLY_TO);
        strcpy(reply_subject, "");
@@ -415,7 +415,7 @@ int read_message(CtdlIPC *ipc,
                ++lines_printed;
                lines_printed =
                    checkpagin(lines_printed, pagin, screenheight);
-               sttybbs(0);
+               stty_ctdl(0);
                return (0);
        }
 
@@ -462,7 +462,7 @@ int read_message(CtdlIPC *ipc,
                        }
                }
                pprintf("\n");
-               sttybbs(0);
+               stty_ctdl(0);
                return (0);
        }
 
@@ -729,7 +729,7 @@ int read_message(CtdlIPC *ipc,
 
        if (pagin == 1 && !dest)
                color(DIM_WHITE);
-       sttybbs(0);
+       stty_ctdl(0);
        return (fr);
 }
 
@@ -818,8 +818,8 @@ int client_make_message(CtdlIPC *ipc,
                } else if (strlen(editor_paths[0]) > 0) {
                        editor_path = editor_paths[0];
                } else {
-                       err_printf
-                           ("*** No editor available, using built-in editor\n");
+                       err_printf("*** No editor available, "
+                               "using built-in editor\n");
                        mode = 0;
                }
        }
@@ -856,7 +856,8 @@ int client_make_message(CtdlIPC *ipc,
        if (mode == 0) {
                fp = fopen(filename, "r");
                if (fp != NULL) {
-                       fmout(screenwidth, fp, NULL, NULL, 0, screenheight, 0, 0);
+                       fmout(screenwidth, fp, NULL, NULL, 0,
+                               screenheight, 0, 0);
                        beg = ftell(fp);
                        fclose(fp);
                } else {
@@ -913,7 +914,7 @@ ME1:        switch (mode) {
        default:        /* allow 2+ modes */
                e_ex_code = 1;  /* start with a failed exit code */
                screen_reset();
-               sttybbs(SB_RESTORE);
+               stty_ctdl(SB_RESTORE);
                editor_pid = fork();
                cksum = file_checksum(filename);
                if (editor_pid == 0) {
@@ -931,7 +932,7 @@ ME1:        switch (mode) {
                                b = ka_wait(&e_ex_code);
                        } while ((b != editor_pid) && (b >= 0));
                editor_pid = (-1);
-               sttybbs(0);
+               stty_ctdl(0);
                screen_set();
                break;
        }
@@ -1187,7 +1188,8 @@ int entmsg(CtdlIPC *ipc,
        }
 
        /* Now compose the message... */
-       if (client_make_message(ipc, temp, message.recipient, message.anonymous, 0, c, message.subject) != 0) {
+       if (client_make_message(ipc, temp, message.recipient,
+          message.anonymous, 0, c, message.subject) != 0) {
                return (2);
        }
 
@@ -1424,7 +1426,7 @@ void image_view(CtdlIPC *ipc, unsigned long msg)
                                void *file = NULL; /* The downloaded file */
                                int r;
        
-                               // view image
+                               /* view image */
                                found = -found;
                                r = CtdlIPCAttachmentDownload(ipc, msg, ptr->number, &file, progress, buf);
                                if (r / 100 != 2) {
@@ -1559,9 +1561,9 @@ RMSGREAD: scr_flush();
                        if (f == 0) {
                                freopen(prtfile, "r", stdin);
                                screen_reset();
-                               sttybbs(SB_RESTORE);
+                               stty_ctdl(SB_RESTORE);
                                ka_system(printcmd);
-                               sttybbs(SB_NO_INTR);
+                               stty_ctdl(SB_NO_INTR);
                                screen_set();
                                unlink(prtfile);
                                exit(0);
@@ -1764,7 +1766,7 @@ RMSGREAD: scr_flush();
                        if (r / 100 != 2) {
                                scr_printf("%s\n", cmd);
                        } else {
-                               extract(filename, cmd, 2);
+                               extract_token(filename, cmd, 2, '|', sizeof filename);
                                /*
                                 * Part 1 won't have a filename; use the
                                 * subject of the message instead. IO
@@ -1813,30 +1815,24 @@ RMSGREAD:       scr_flush();
             int lasta = a;
             for (finda = a; ((finda < num_msgs) && (finda >= 0)); finda += rdir)
               {
-                /* This is repetitively dumb, but that's what computers are for.
-                   We have to load up messages until we find one by us */
-                char buf[SIZ];
-                int founda = 0;
+               /* This is repetitively dumb, but that's what computers are for.
+                  We have to load up messages until we find one by us */
+               char buf[SIZ];
+               int founda = 0;
+               struct ctdlipcmessage *msg = NULL;
                 
                /* read the header so we can get 'from=' */
-                       snprintf(buf, sizeof buf, "MSG0 %ld|1", msg_arr[finda]);
-               CtdlIPC_putline(ipc, buf);
-               CtdlIPC_getline(ipc, buf);
-               while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) 
-                  {
-                       if ((!strncasecmp(buf, "from=", 5)) && (finda != a)) /* Skip current message. */
-                     { 
-                        if (strcasecmp(buf+5, fullname) == 0)
-                          {
-                            a = lasta; /* meesa current */
-                            founda = 1;
-                          }
-                         }
-                 }
-                   /* we are now in synch with the server */
-                if (founda)
-                  break; /* for */
-                lasta = finda; /* keep one behind or we skip on the reentrance to the for */
+               r = CtdlIPCGetSingleMessage(ipc, msg_arr[finda], 1, 0, &msg, buf);
+               if (!strncasecmp(msg->author, fullname, sizeof(fullname))) {
+                       a = lasta; /* meesa current */
+                       founda = 1;
+               }
+
+               free(msg);
+
+               if (founda)
+                       break; /* for */
+               lasta = finda; /* keep one behind or we skip on the reentrance to the for */
               } /* for */
           } /* case 'y' */
       } /* switch */
@@ -1887,7 +1883,7 @@ void check_message_base(CtdlIPC *ipc)
 
        while (transcript && strlen(transcript)) {
                lines_printed = 1;
-               extract_token(buf, transcript, 0, '\n');
+               extract_token(buf, transcript, 0, '\n', sizeof buf);
                remove_token(transcript, 0, '\n');
                pprintf("%s\n", buf);
        }