/*
* Text client functions for reading and writing of messages
*
- * Copyright (c) 1987-2010 by the citadel.org team
+ * Copyright (c) 1987-2012 by the citadel.org team
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdep.h"
#include "citadel_decls.h"
#include "messages.h"
#include "commands.h"
+#include "tuiconfig.h"
#include "rooms.h"
#ifndef HAVE_SNPRINTF
#include "snprintf.h"
void stty_ctdl(int cmd);
int haschar(const char *st, int ch);
-void ctdl_getline(char *string, int lim);
int file_checksum(char *filename);
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;
extern char room_name[];
extern char tempdir[];
extern unsigned room_flags;
}
+/*
+ * This is a mini RFC2047 decoder.
+ * It only handles strings encoded from UTF-8 as Quoted-printable.
+ */
+void mini_2047_decode(char *s) {
+ if (!s) return;
+
+ char *qstart = strstr(s, "=?UTF-8?Q?");
+ if (!qstart) return;
+
+ char *qend = strstr(s, "?=");
+ if (!qend) return;
+
+ if (qend <= qstart) return;
+
+ strcpy(qstart, &qstart[10]);
+ qend -= 10;
+
+ char *p = qstart;
+ while (p < qend) {
+
+ if (p[0] == '=') {
+
+ char ch[3];
+ ch[0] = p[1];
+ ch[1] = p[2];
+ ch[2] = p[3];
+ int c;
+ sscanf(ch, "%02x", &c);
+ p[0] = c;
+ strcpy(&p[1], &p[3]);
+ qend -= 2;
+ }
+
+ if (p[0] == '_') {
+ p[0] = ' ';
+ }
+
+ ++p;
+ }
+
+ strcpy(qend, &qend[2]);
+}
+
/*
* Read a message from the server
*/
scr_printf("part=%s|%s|%s|%s|%s|%ld\n",
ptr->name, ptr->filename, ptr->number,
ptr->disposition, ptr->mimetype,
- ptr->length);
+ ptr->length
+ );
}
}
scr_printf("\n");
safestrncpy(reply_subject, message->subject, sizeof reply_subject);
if (!IsEmptyStr(message->subject)) {
if (dest) {
- fprintf(dest, "Subject: %s\n",
- message->subject);
+ fprintf(dest, "Subject: %s\n", message->subject);
} else {
color(DIM_WHITE);
scr_printf("Subject: ");
color(BRIGHT_CYAN);
+ mini_2047_decode(message->subject);
scr_printf("%s\n", message->subject);
}
}
long msglen = 0L;
int rv;
- scr_printf("Enter text to be replaced:\n: ");
- ctdl_getline(srch_str, (sizeof(srch_str)-1) );
+ newprompt("Enter test to be replaced: ", srch_str, (sizeof(srch_str)-1) );
if (IsEmptyStr(srch_str)) {
return;
}
- scr_printf("Enter text to replace it with:\n: ");
- ctdl_getline(rplc_str, (sizeof(rplc_str)-1) );
+ newprompt("Enter text to replace it with: ", rplc_str, (sizeof(rplc_str)-1) );
fp = fopen(filename, "r+");
if (fp == NULL) {
long beg;
char datestr[SIZ];
char header[SIZ];
- char *editor_path = NULL;
int cksum = 0;
- if (mode >= 2)
- {
- if ((mode-2) < MAX_EDITORS && !IsEmptyStr(editor_paths[mode-2]))
- {
- editor_path = editor_paths[mode-2];
- } else if (!IsEmptyStr(editor_paths[0]))
- {
- editor_path = editor_paths[0];
- } else {
- scr_printf("*** No editor available; using built-in editor.\n");
- mode = 0;
- }
+ if ( (mode == 2) && (IsEmptyStr(editor_path)) ) {
+ scr_printf("*** No editor available; using built-in editor.\n");
+ mode = 0;
}
fmt_date(datestr, sizeof datestr, time(NULL), 0);
fp = fopen(filename, "r");
if (fp != NULL) {
fmout(screenwidth, fp, NULL, NULL, 0);
- /* TODO: why ftell if we ignore the result? */
beg = ftell(fp);
if (beg < 0)
scr_printf("failed to get stream position %s\n",
if (is_reply) {
strcpy(buf, reply_to);
} else {
- scr_printf("Enter recipient: ");
- ctdl_getline(buf, (SIZ-100) );
- if (IsEmptyStr(buf))
+ newprompt("Enter recipient: ", buf, SIZ-100);
+ if (IsEmptyStr(buf)) {
return (1);
+ }
}
} else
strcpy(buf, "sysop");
while (fgets(buf, 128, qfile) != NULL) {
scr_printf("%3d %s", ++line, buf);
}
- scr_printf("Begin quoting at [1] : ");
- ctdl_getline(buf, 4);
- qstart = (buf[0] == 0) ? (1) : atoi(buf);
- scr_printf(" End quoting at [%d] : ", line);
- ctdl_getline(buf, 4);
- qend = (buf[0] == 0) ? (line) : atoi(buf);
+
+ qstart = intprompt("Begin quoting at", 1, 1, line);
+ qend = intprompt(" End quoting at", line, qstart, line);
+
rewind(qfile);
line = 0;
if (fgets(buf, 128, qfile) == NULL) {
} while ((g != f) && (g >= 0));
scr_printf("Message printed.\n");
}
- if (rc_alt_semantics && c == 1) {
- char buf[SIZ];
-
- r = CtdlIPCSetMessageSeen(ipc, msg_arr[a], 1, buf);
- }
if (e == SIGQUIT)
return;
if (((userflags & US_NOPROMPT) || (e == SIGINT))
-/*
- * Verify the message base
- */
-void check_message_base(CtdlIPC *ipc)
-{
- char buf[SIZ];
- char *transcript = NULL;
- int r; /* IPC response code */
-
- scr_printf
- ("Please read the documentation before running this command.\n"
- "Having done so, do you still want to check the message base? ");
- if (yesno() == 0)
- return;
-
- r = CtdlIPCMessageBaseCheck(ipc, &transcript, buf);
- if (r / 100 != 1) {
- scr_printf("%s\n", buf);
- return;
- }
-
- while (transcript && !IsEmptyStr(transcript)) {
- extract_token(buf, transcript, 0, '\n', sizeof buf);
- remove_token(transcript, 0, '\n');
- scr_printf("%s\n", buf);
- }
- if (transcript) free(transcript);
- return;
-}
-
-
/*
* Loads the contents of a file into memory. Caller must free the allocated
* memory.