From b5dc098cafbbbf555376a1722547edf3e9cb3615 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 2 Mar 2007 20:27:14 +0000 Subject: [PATCH] Message replies using UTF-8 --- mbsebbs/mail.c | 84 ++++++++++++++++++++++++++++---------------------- mbsebbs/user.c | 4 +-- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/mbsebbs/mail.c b/mbsebbs/mail.c index 978d8c49..23f71981 100644 --- a/mbsebbs/mail.c +++ b/mbsebbs/mail.c @@ -1211,42 +1211,24 @@ int Read_a_Msg(unsigned int Num, int UpdateLR) } /* - * Fill Quote file in case the user wants to reply. Note that line - * wrapping is set lower then normal message read, to create room - * for the Quote> strings at the start of each line. + * Analyse this message to find the character encoding. */ - fn = calloc(PATH_MAX, sizeof(char)); - snprintf(fn, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name); - if ((qf = fopen(fn, "w")) != NULL) { - if (Msg_Read(Num, 75)) { - if ((p = (char *)MsgText_First()) != NULL) - do { - if ((p[0] == '\001') || (!strncmp(p, "SEEN-BY:", 8)) || (!strncmp(p, "AREA:", 5))) { - /* - * While we are here, check for the ^aCHRS: kludge and set the used charset. - */ - if (strncmp(p, "\001CHRS: ", 7) == 0) { - charset = xstrcpy(p + 7); - } - if (strncmp(p, "\001CHARSET: ", 10) == 0) { - charset = xstrcpy(p + 10); - } - if (Kludges) { - if (p[0] == '\001') { - p[0] = 'a'; - fprintf(qf, "^%s\n", p); - } else - fprintf(qf, "%s\n", p); - } - } else - fprintf(qf, "%s\n", p); - } while ((p = (char *)MsgText_Next()) != NULL); + if (Msg_Read(Num, 78)) { + if ((p = (char *)MsgText_First()) != NULL) { + do { + if ((p[0] == '\001') || (!strncmp(p, "SEEN-BY:", 8)) || (!strncmp(p, "AREA:", 5))) { + if (strncmp(p, "\001CHRS: ", 7) == 0) { + charset = xstrcpy(p + 7); + break; + } + if (strncmp(p, "\001CHARSET: ", 10) == 0) { + charset = xstrcpy(p + 10); + break; + } + } + } while ((p = (char *)MsgText_Next()) != NULL); } - fclose(qf); - } else { - WriteError("$Can't open %s", p); } - free(fn); if (charset == NULL) { /* @@ -1258,12 +1240,42 @@ int Read_a_Msg(unsigned int Num, int UpdateLR) } else { charsin = xstrcpy(get_ic_ftn(find_ftn_charset(charset))); } + chartran_init(charsin, get_ic_ftn(exitinfo.Charset), 'b'); /* - * Try to setup charset mapping if the charactersets are different. + * Fill Quote file in case the user wants to reply. Note that line + * wrapping is set lower then normal message read, to create room + * for the Quote> strings at the start of each line. The text is + * converted to the users local characterset so the reply can be + * done with the users prefered characterset. */ - chartran_init(charsin, get_ic_ftn(exitinfo.Charset), 'b'); - + fn = calloc(PATH_MAX, sizeof(char)); + snprintf(fn, PATH_MAX, "%s/%s/.quote", CFG.bbs_usersdir, exitinfo.Name); + if ((qf = fopen(fn, "w")) != NULL) { + if (Msg_Read(Num, 75)) { + if ((p = (char *)MsgText_First()) != NULL) { + do { + if ((p[0] == '\001') || (!strncmp(p, "SEEN-BY:", 8)) || (!strncmp(p, "AREA:", 5))) { + if (Kludges) { + if (p[0] == '\001') { + p[0] = 'a'; + fprintf(qf, "^%s\n", chartran(p)); + } else { + fprintf(qf, "%s\n", chartran(p)); + } + } + } else { + fprintf(qf, "%s\n", chartran(p)); + } + } while ((p = (char *)MsgText_Next()) != NULL); + } + } + fclose(qf); + } else { + WriteError("$Can't open %s", p); + } + free(fn); + /* * Show message header with charset mapping if needed. */ diff --git a/mbsebbs/user.c b/mbsebbs/user.c index 67c4a08e..ee827c1c 100644 --- a/mbsebbs/user.c +++ b/mbsebbs/user.c @@ -466,8 +466,8 @@ void user(void) Chg_Charset(); } - setlocale(LC_CTYPE, getlocale(exitinfo.Charset)); - Syslog('b', "setlocale(LC_CTYPE, NULL) returns \"%s\"", printable(setlocale(LC_CTYPE, NULL), 0)); +// setlocale(LC_CTYPE, getlocale(exitinfo.Charset)); +// Syslog('b', "setlocale(LC_CTYPE, NULL) returns \"%s\"", printable(setlocale(LC_CTYPE, NULL), 0)); GetLastUser(); StartTime = xstrcpy(GetLocalHM());