/*
* $Id$
*
- * Citadel/UX message support routines
+ * Citadel message support routines
* see copyright.txt for copyright information
*/
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);
+void ctdl_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;
int num_msgs;
char rc_alt_semantics;
-char rc_reply_extedit;
extern char room_name[];
extern unsigned room_flags;
+extern unsigned room_flags2;
extern long highest_msg_read;
-extern struct CtdlServInfo serv_info;
extern char temp[];
extern char temp2[];
extern int screenwidth;
if (a == 127)
a = 8;
- /******* new ***********/
- if ((a > 32) && (a < 127) && (prev == 13)) {
+ if ((a != 32) && (prev == 13)) {
add_word(textlist, "\n");
scr_printf(" ");
}
- /***********************/
if ((a == 32) && (prev == 13)) {
add_word(textlist, "\n");
}
if (a == 8) {
- if (strlen(wordbuf) > 0) {
+ if (!IsEmptyStr(wordbuf)) {
wordbuf[strlen(wordbuf) - 1] = 0;
scr_putc(8);
scr_putc(32);
scr_putc(8);
scr_putc(32);
scr_putc(8);
- } while (strlen(wordbuf) && wordbuf[strlen(wordbuf) - 1] != ' ');
+ } while (!IsEmptyStr(wordbuf) && wordbuf[strlen(wordbuf) - 1] != ' ');
} else if (a == 13) {
scr_printf("\n");
- if (strlen(wordbuf) == 0)
+ if (IsEmptyStr(wordbuf))
finished = 1;
else {
for (b = 0; b < strlen(wordbuf); ++b)
}
}
-/* Read a message from the server
+
+/*
+ * Free the struct parts
+ */
+void free_parts(struct parts *p)
+{
+ struct parts *a_part = p;
+
+ while (a_part) {
+ struct parts *q;
+
+ q = a_part;
+ a_part = a_part->next;
+ free(q);
+ }
+}
+
+
+/*
+ * Read a message from the server
*/
int read_message(CtdlIPC *ipc,
long num, /* message number */
has_images = 0;
sigcaught = 0;
- sttybbs(1);
+ stty_ctdl(1);
strcpy(reply_to, NO_REPLY_TO);
strcpy(reply_subject, "");
++lines_printed;
lines_printed =
checkpagin(lines_printed, pagin, screenheight);
- sttybbs(0);
+ stty_ctdl(0);
return (0);
}
message->nhdr ? "yes" : "no",
message->author, message->type,
message->msgid);
- if (strlen(message->subject)) {
+ if (!IsEmptyStr(message->subject)) {
pprintf("subj=%s\n", message->subject);
}
- if (strlen(message->email)) {
+ if (!IsEmptyStr(message->email)) {
pprintf("rfca=%s\n", message->email);
}
pprintf("hnod=%s\nroom=%s\nnode=%s\ntime=%s",
message->hnod, message->room,
message->node,
asctime(localtime(&message->time)));
- if (strlen(message->recipient)) {
+ if (!IsEmptyStr(message->recipient)) {
pprintf("rcpt=%s\n", message->recipient);
}
if (message->attachments) {
}
}
pprintf("\n");
- sttybbs(0);
+ stty_ctdl(0);
return (0);
}
fmt_date(now, sizeof now, message->time, 0);
if (dest) {
fprintf(dest, "%s from %s ", now, message->author);
- if (strlen(message->email)) {
+ if (!IsEmptyStr(message->email)) {
fprintf(dest, "<%s> ", message->email);
}
} else {
scr_printf("from ");
color(BRIGHT_CYAN);
scr_printf("%s ", message->author);
- if (strlen(message->email)) {
+ if (!IsEmptyStr(message->email)) {
color(DIM_WHITE);
scr_printf("<");
color(BRIGHT_BLUE);
scr_printf("> ");
}
}
- if (strlen(message->node)) {
+ if (!IsEmptyStr(message->node)) {
if ((room_flags & QR_NETWORK)
- || ((strcasecmp(message->node, serv_info.serv_nodename)
- && (strcasecmp(message->node, serv_info.serv_fqdn))))) {
- if (strlen(message->email) == 0) {
+ || ((strcasecmp(message->node, ipc->ServInfo.nodename)
+ && (strcasecmp(message->node, ipc->ServInfo.fqdn))))) {
+ if (IsEmptyStr(message->email)) {
if (dest) {
fprintf(dest, "@%s ", message->node);
} else {
}
}
}
- if (strcasecmp(message->hnod, serv_info.serv_humannode)
- && (strlen(message->hnod)) && (!strlen(message->email))) {
+ if (strcasecmp(message->hnod, ipc->ServInfo.humannode)
+ && (!IsEmptyStr(message->hnod)) && (IsEmptyStr(message->email))) {
if (dest) {
fprintf(dest, "(%s) ", message->hnod);
} else {
scr_printf(") ");
}
}
- if (strcasecmp(message->room, room_name) && (strlen(message->email) == 0)) {
+ if (strcasecmp(message->room, room_name) && (IsEmptyStr(message->email))) {
if (dest) {
fprintf(dest, "in %s> ", message->room);
} else {
scr_printf("%s> ", message->room);
}
}
- if (strlen(message->recipient)) {
+ if (!IsEmptyStr(message->recipient)) {
if (dest) {
fprintf(dest, "to %s ", message->recipient);
} else {
/* Set the reply-to address to an Internet e-mail address if possible
*/
- if (message->email != NULL) if (strlen(message->email) > 0) {
- safestrncpy(reply_to, message->email, sizeof reply_to);
+ if (message->email != NULL) if (!IsEmptyStr(message->email)) {
+ if (!IsEmptyStr(message->author)) {
+ snprintf(reply_to, sizeof reply_to, "%s <%s>", message->author, message->email);
+ }
+ else {
+ safestrncpy(reply_to, message->email, sizeof reply_to);
+ }
}
/* But if we can't do that, set it to a Citadel address.
if (message->subject != NULL) {
safestrncpy(reply_subject, message->subject,
sizeof reply_subject);
- if (strlen(message->subject) > 0) {
+ if (!IsEmptyStr(message->subject)) {
if (dest) {
fprintf(dest, "Subject: %s\n",
message->subject);
* of the client screen.
*/
if (!strcasecmp(message->content_type, "text/html")) {
- converted_text = html_to_ascii(message->text, screenwidth, 0);
+ converted_text = html_to_ascii(message->text, 0, screenwidth, 0);
if (converted_text != NULL) {
free(message->text);
message->text = converted_text;
for (ptr = message->attachments; ptr; ptr = ptr->next) {
if ( (!strcasecmp(ptr->disposition, "attachment"))
- || (!strcasecmp(ptr->disposition, "inline"))) {
- color(DIM_WHITE);
- scr_printf("Part ");
- color(BRIGHT_MAGENTA);
- scr_printf("%s", ptr->number);
- color(DIM_WHITE);
- scr_printf(": ");
- color(BRIGHT_CYAN);
- scr_printf("%s", ptr->filename);
- color(DIM_WHITE);
- scr_printf(" (%s, %ld bytes)\n", ptr->mimetype, ptr->length);
- if (!strncmp(ptr->mimetype, "image/", 6))
- has_images++;
+ || (!strcasecmp(ptr->disposition, "inline"))
+ || (!strcasecmp(ptr->disposition, ""))
+ ) {
+ if ( (strcasecmp(ptr->number, message->mime_chosen))
+ && (!IsEmptyStr(ptr->mimetype))
+ ) {
+ color(DIM_WHITE);
+ pprintf("Part ");
+ color(BRIGHT_MAGENTA);
+ pprintf("%s", ptr->number);
+ color(DIM_WHITE);
+ pprintf(": ");
+ color(BRIGHT_CYAN);
+ pprintf("%s", ptr->filename);
+ color(DIM_WHITE);
+ pprintf(" (%s, %ld bytes)\n", ptr->mimetype, ptr->length);
+ if (!strncmp(ptr->mimetype, "image/", 6)) {
+ has_images++;
+ }
+ }
}
}
}
if (pagin == 1 && !dest)
color(DIM_WHITE);
- sttybbs(0);
+ stty_ctdl(0);
return (fr);
}
long msglen = 0L;
scr_printf("Enter text to be replaced:\n: ");
- getline(srch_str, (sizeof(srch_str)-1) );
- if (strlen(srch_str) == 0)
+ ctdl_getline(srch_str, (sizeof(srch_str)-1) );
+ if (IsEmptyStr(srch_str))
return;
scr_printf("Enter text to replace it with:\n: ");
- getline(rplc_str, (sizeof(rplc_str)-1) );
+ ctdl_getline(rplc_str, (sizeof(rplc_str)-1) );
fp = fopen(filename, "r+");
if (fp == NULL)
}
}
fseek(fp, wpos, 0);
- if (strlen(buf) > 0)
+ if (!IsEmptyStr(buf))
fwrite((char *) buf, strlen(buf), 1, fp);
wpos = ftell(fp);
fclose(fp);
* Function to begin composing a new message
*/
int client_make_message(CtdlIPC *ipc,
- char *filename, /* temporary file name */
- char *recipient, /* NULL if it's not mail */
- int is_anonymous,
- int format_type,
- int mode,
- char *subject) /* buffer to store subject line */
+ char *filename, /* temporary file name */
+ char *recipient, /* NULL if it's not mail */
+ int is_anonymous,
+ int format_type,
+ int mode,
+ char *subject, /* buffer to store subject line */
+ int subject_required)
{
FILE *fp;
int a, b, e_ex_code;
if (mode >= 2)
{
- if((mode-2) < MAX_EDITORS && strlen(editor_paths[mode-2]) > 0) {
+ if((mode-2) < MAX_EDITORS && !IsEmptyStr(editor_paths[mode-2])) {
editor_path = editor_paths[mode-2];
- } else if (strlen(editor_paths[0]) > 0) {
+ } else if (!IsEmptyStr(editor_paths[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;
}
}
datestr,
(is_anonymous ? "[anonymous]" : fullname)
);
- if (strlen(recipient) > 0) {
+ if (!IsEmptyStr(recipient)) {
size_t tmp = strlen(header);
snprintf(&header[tmp], sizeof header - tmp,
" to %s", recipient);
}
}
scr_printf("%s\n", header);
- if (subject != NULL) if (strlen(subject) > 0) {
+ if (subject != NULL) if (!IsEmptyStr(subject)) {
scr_printf("Subject: %s\n", subject);
}
+
+ if ( (subject_required) && (IsEmptyStr(subject)) ) {
+ newprompt("Subject: ", subject, 70);
+ }
beg = 0L;
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 {
case 2:
default: /* allow 2+ modes */
e_ex_code = 1; /* start with a failed exit code */
+ screen_reset();
+ stty_ctdl(SB_RESTORE);
editor_pid = fork();
cksum = file_checksum(filename);
- screen_reset();
- sttybbs(SB_RESTORE);
if (editor_pid == 0) {
char tmp[SIZ];
b = ka_wait(&e_ex_code);
} while ((b != editor_pid) && (b >= 0));
editor_pid = (-1);
- sttybbs(0);
+ stty_ctdl(0);
screen_set();
break;
}
err_printf("*** Aborted message.\n");
e_ex_code = 1;
}
- if (e_ex_code == 0)
+ if (e_ex_code == 0) {
goto MEFIN;
+ }
goto MEABT2;
}
"add s<U>bject|"
"<R>eplace string|<H>old message");
- if (b == 'a')
- goto MEABT;
- if (b == 'c')
- goto ME1;
- if (b == 's')
- goto MEFIN;
+ if (b == 'a') goto MEABT;
+ if (b == 'c') goto ME1;
+ if (b == 's') goto MEFIN;
if (b == 'p') {
scr_printf(" %s from %s", datestr, fullname);
- if (strlen(recipient) > 0)
+ if (!IsEmptyStr(recipient)) {
scr_printf(" to %s", recipient);
+ }
scr_printf("\n");
- if (subject != NULL) if (strlen(subject) > 0) {
+ if (subject != NULL) if (!IsEmptyStr(subject)) {
scr_printf("Subject: %s\n", subject);
}
fp = fopen(filename, "r");
}
+/*
+ * break_big_lines() - break up lines that are >1024 characters
+ * otherwise the server will truncate
+ */
+void break_big_lines(char *msg) {
+ char *ptr;
+ char *break_here;
+
+ if (msg == NULL) {
+ return;
+ }
+
+ ptr = msg;
+ while (strlen(ptr) > 1000) {
+ break_here = strchr(&ptr[900], ' ');
+ if ((break_here == NULL) || (break_here > &ptr[999])) {
+ break_here = &ptr[999];
+ }
+ *break_here = '\n';
+ ptr = break_here++;
+ }
+}
+
/*
* entmsg() - edit and create a message
*/
int entmsg(CtdlIPC *ipc,
int is_reply, /* nonzero if this was a <R>eply command */
- int c) /* mode */
-{
+ int c, /* mode */
+ int masquerade /* prompt for a non-default display name? */
+) {
char buf[SIZ];
int a, b;
int need_recp = 0;
struct ctdlipcmessage message;
unsigned long *msgarr = NULL;
int r; /* IPC response code */
+ int subject_required = 0;
if (c > 0)
mode = 1;
strcpy(message.recipient, "");
strcpy(message.author, "");
strcpy(message.subject, "");
- message.text = message.author; /* point to "", changes later */
+ message.text = ""; /* point to "", changes later */
message.anonymous = 0;
message.type = mode;
- r = CtdlIPCPostMessage(ipc, 0, &message, buf);
+
+ if (masquerade) {
+ newprompt("Display name for this message: ", message.author, 40);
+ }
+
+ r = CtdlIPCPostMessage(ipc, 0, &subject_required, &message, buf);
if (r / 100 != 2 && r / 10 != 57) {
scr_printf("%s\n", buf);
* in this room, but a recipient needs to be specified.
*/
need_recp = 0;
- if (r / 10 == 57)
+ if (r / 10 == 57) {
need_recp = 1;
+ }
/* If the user is a dumbass, tell them how to type. */
if ((userflags & US_EXPERT) == 0) {
strcpy(buf, reply_to);
} else {
scr_printf("Enter recipient: ");
- getline(buf, (SIZ-100) );
- if (strlen(buf) == 0)
+ ctdl_getline(buf, (SIZ-100) );
+ if (IsEmptyStr(buf))
return (1);
}
} else
strcpy(message.recipient, buf);
if (is_reply) {
- if (strlen(reply_subject) > 0) {
+ if (!IsEmptyStr(reply_subject)) {
if (!strncasecmp(reply_subject,
"Re: ", 3)) {
strcpy(message.subject, reply_subject);
}
/* If it's mail, we've got to check the validity of the recipient... */
- if (strlen(message.recipient) > 0) {
- r = CtdlIPCPostMessage(ipc, 0, &message, buf);
+ if (!IsEmptyStr(message.recipient)) {
+ r = CtdlIPCPostMessage(ipc, 0, &subject_required, &message, buf);
if (r / 100 != 2) {
scr_printf("%s\n", buf);
return (1);
}
/* 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, subject_required) != 0) {
+ if (msgarr) free(msgarr);
return (2);
}
/* Reopen the temp file that was created, so we can send it */
fp = fopen(temp, "r");
- /* Yes, unlink it now, so it doesn't stick around if we crash */
- unlink(temp);
-
if (!fp || !(message.text = load_message_from_file(fp))) {
err_printf("*** Internal error while trying to save message!\n"
"%s: %s\n",
temp, strerror(errno));
+ unlink(temp);
return(errno);
}
if (fp) fclose(fp);
+ /* Break lines that are >1024 characters, otherwise the server
+ * will truncate them.
+ */
+ break_big_lines(message.text);
+
/* Transmit message to the server */
- r = CtdlIPCPostMessage(ipc, 1, &message, buf);
+ r = CtdlIPCPostMessage(ipc, 1, NULL, &message, buf);
if (r / 100 != 4) {
scr_printf("%s\n", buf);
return (1);
}
+ /* Yes, unlink it now, so it doesn't stick around if we crash */
+ unlink(temp);
+
if (num_msgs >= 1) highmsg = msgarr[num_msgs - 1];
if (msgarr) free(msgarr);
scr_printf("*** %d additional messages have been entered "
"in this room by other users.\n", b);
}
+ free(message.text);
return(0);
}
scr_printf("%2d %s", ++line, buf);
}
scr_printf("Begin quoting at [ 1] : ");
- getline(buf, 3);
+ ctdl_getline(buf, 3);
qstart = (buf[0] == 0) ? (1) : atoi(buf);
scr_printf(" End quoting at [%d] : ", line);
- getline(buf, 3);
+ ctdl_getline(buf, 3);
qend = (buf[0] == 0) ? (line) : atoi(buf);
rewind(qfile);
line = 0;
/*
- * Image viewer thread (for background image viewing)
+ * Run image viewer in background
*/
-void *image_view_thread(void *filename)
+int do_image_view(const char *filename)
{
char cmd[SIZ];
pid_t childpid;
- int retcode;
- snprintf(cmd, sizeof cmd, imagecmd, (char *)filename);
+ snprintf(cmd, sizeof cmd, imagecmd, filename);
childpid = fork();
if (childpid < 0) {
- color(BRIGHT_RED);
- perror("Cannot fork");
- color(DIM_WHITE);
- unlink((char *)filename);
- return ((void *) childpid);
+ unlink(filename);
+ return childpid;
}
if (childpid == 0) {
- execlp("/bin/sh", "sh", "-c", cmd, NULL);
- exit(127);
+ int retcode;
+ pid_t grandchildpid;
+
+ grandchildpid = fork();
+ if (grandchildpid < 0) {
+ return grandchildpid;
+ }
+
+ if (grandchildpid == 0) {
+ int nullfd;
+ int outfd = -1;
+ int errfd = -1;
+
+ nullfd = open("/dev/null", O_WRONLY);
+ if (nullfd > -1) {
+ dup2(1, outfd);
+ dup2(2, errfd);
+ dup2(nullfd, 1);
+ dup2(nullfd, 2);
+ }
+ retcode = system(cmd);
+ if (nullfd > -1) {
+ dup2(outfd, 1);
+ dup2(errfd, 2);
+ close(nullfd);
+ }
+ unlink(filename);
+ exit(retcode);
+ }
+
+ if (grandchildpid > 0) {
+ exit(0);
+ }
}
if (childpid > 0) {
+ int retcode;
+
waitpid(childpid, &retcode, 0);
- unlink((char *)filename);
- return ((void *)retcode);
+ return retcode;
}
-
- return ((void *)-1);
+
+ return -1;
}
*/
void image_view(CtdlIPC *ipc, unsigned long msg)
{
- struct parts *selected_part = NULL;
struct parts *ptr = last_message_parts;
char part[SIZ];
int found = 0;
if ((!strcasecmp(ptr->disposition, "attachment")
|| !strcasecmp(ptr->disposition, "inline"))
&& !strncmp(ptr->mimetype, "image/", 6)) {
- if (!found) {
- found = 1;
- selected_part = ptr;
- strcpy(part, selected_part->number);
+ found++;
+ if (found == 1) {
+ strcpy(part, ptr->number);
}
-#if 0
- color(DIM_WHITE);
- scr_printf("Part ");
- color(BRIGHT_MAGENTA);
- scr_printf("%s", ptr->number);
- color(DIM_WHITE);
- scr_printf(": ");
- color(BRIGHT_CYAN);
- scr_printf("%s", ptr->filename);
- color(DIM_WHITE);
- scr_printf(" (%s, %ld bytes)\n", ptr->mimetype, ptr->length);
-#endif
}
}
- while (found) {
- found = 0;
- strprompt("View which part (0 when done)", part, SIZ-1);
+ while (found > 0) {
+ if (found > 1)
+ strprompt("View which part (0 when done)", part, SIZ-1);
+ found = -found;
for (ptr = last_message_parts; ptr; ptr = ptr->next) {
if ((!strcasecmp(ptr->disposition, "attachment")
|| !strcasecmp(ptr->disposition, "inline"))
&& !strncmp(ptr->mimetype, "image/", 6)
- && !strcmp(ptr->number, part)) {
+ && !strcasecmp(ptr->number, part)) {
char tmp[PATH_MAX];
char buf[SIZ];
void *file = NULL; /* The downloaded file */
-#ifdef THREADED_CLIENT
- pthread_t *ivthread = NULL;
-#endif
int r;
-
- // view image
- found = 1;
- r = CtdlIPCAttachmentDownload(ipc, msg, selected_part->number, &file, progress, buf);
+
+ /* view image */
+ found = -found;
+ r = CtdlIPCAttachmentDownload(ipc, msg, ptr->number, &file, progress, buf);
if (r / 100 != 2) {
scr_printf("%s\n", buf);
} else {
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),
- selected_part->filename);
+ CtdlMakeTempFileName(tmp, sizeof tmp);
+ strcat(tmp, ptr->filename);
save_buffer(file, len, tmp);
free(file);
- #if 0
- pthread_create(ivthread, NULL, image_view_thread, tmp);
- #endif
- snprintf(buf, sizeof buf, imagecmd, tmp);
- system(buf);
- unlink(tmp);
+ do_image_view(tmp);
}
break;
}
}
+ if (found == 1)
+ break;
}
}
else
b = 0;
- strcpy(prtfile, tmpnam(NULL));
+ CtdlMakeTempFileName(prtfile, sizeof prtfile);
if (msg_arr) {
free(msg_arr);
}
/* clear parts list */
- /* FIXME free() the old parts list */
+ free_parts(last_message_parts);
last_message_parts = NULL;
/* now read the message... */
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);
keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top ");
if (rc_url_cmd[0] && num_urls)
keyopt("<U>RLview ");
- if (has_images > 0 && strlen(imagecmd) > 0)
+ if (has_images > 0 && !IsEmptyStr(imagecmd))
keyopt("<I>mages ");
keyopt("<?>help -> ");
/* space key same as <N> */ if (e == 32)
e = 'n';
/* del/move for aides only */
- if ((!is_room_aide)
- && ((room_flags & QR_MAILBOX) ==
- 0)) {
+ if ( (!is_room_aide)
+ && ((room_flags & QR_MAILBOX) == 0)
+ && ((room_flags2 & QR2_COLLABDEL) == 0)
+ ) {
if ((e == 'd') || (e == 'm'))
e = 0;
}
/* print only if available */
- if ((e == 'p') && (strlen(printcmd) == 0))
+ if ((e == 'p') && (IsEmptyStr(printcmd)))
e = 0;
/* can't file if not allowed */
if ((e == 'f')
e = 0;
/* link only if browser avail*/
if ((e == 'u')
- && (strlen(rc_url_cmd) == 0))
+ && (IsEmptyStr(rc_url_cmd)))
e = 0;
if ((e == 'i')
- && (!strlen(imagecmd) || !has_images))
+ && (IsEmptyStr(imagecmd) || !has_images))
e = 0;
} while ((e != 'a') && (e != 'n') && (e != 's')
&& (e != 'd') && (e != 'm') && (e != 'p')
scr_printf("mY next");
break;
case 'i':
- scr_printf("Images");
break;
case '?':
scr_printf("? <help>");
break;
}
- if (userflags & US_DISAPPEAR)
+ if (userflags & US_DISAPPEAR || e == 'i')
scr_printf("\r%79s\r", "");
else
scr_printf("\n");
" N Next (continue with next message)\n"
" Y My Next (continue with next message you authored)\n"
" B Back (go back to previous message)\n");
- if ((is_room_aide)
- || (room_flags & QR_MAILBOX)) {
+ if ( (is_room_aide)
+ || (room_flags & QR_MAILBOX)
+ || (room_flags2 & QR2_COLLABDEL)
+ ) {
scr_printf(" D Delete this message\n"
" M Move message to another room\n");
}
scr_printf(" C Copy message to another room\n");
- if (strlen(printcmd) > 0)
+ if (!IsEmptyStr(printcmd))
scr_printf(" P Print this message\n");
scr_printf(
" Q Quote portions of this message for your next post\n"
if (rc_allow_attachments)
scr_printf
(" F (save attachments to a file)\n");
- if (strlen(rc_url_cmd) > 0)
+ if (!IsEmptyStr(rc_url_cmd))
scr_printf(" U (list URL's for display)\n");
- if (strlen(imagecmd) > 0 && has_images > 0)
+ if (!IsEmptyStr(imagecmd) && has_images > 0)
scr_printf(" I Image viewer\n");
scr_printf("\n");
goto RMSGREAD;
case 'c':
newprompt("Enter target room: ",
targ, ROOMNAMELEN - 1);
- if (strlen(targ) > 0) {
+ if (!IsEmptyStr(targ)) {
r = CtdlIPCMoveMessage(ipc, (e == 'c' ? 1 : 0),
msg_arr[a], targ, cmd);
scr_printf("%s\n", cmd);
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
*/
- if (!strlen(filename))
+ if (IsEmptyStr(filename))
strcpy(filename, reply_subject);
destination_directory(save_to, filename);
save_buffer(attachment,
goto RMSGREAD;
case 'r':
savedpos = num_msgs;
- entmsg(ipc, 1, (rc_reply_extedit ? 2 : 0));
+ entmsg(ipc, 1, ((userflags & US_EXTEDIT) ? 2 : 0), 0);
num_msgs = savedpos;
goto RMSGREAD;
case 'u':
/* find the next message by me, stay here if we find nothing */
int finda;
int lasta = a;
- for (finda = a; ((finda < num_msgs) && (finda >= 0)); finda += rdir)
+ for (finda = (a + rdir); ((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 */
return;
}
- while (transcript && strlen(transcript)) {
+ while (transcript && !IsEmptyStr(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);
}