From bb9fd9dcb85be4739758d6086e79d36accf6e8c0 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Fri, 14 Jan 2005 19:52:12 +0000 Subject: [PATCH] Added Russion support --- AUTHORS | 2 +- ChangeLog | 8 ++++++++ mbnntp/auth.c | 1 + mbnntp/commands.c | 35 ++++++++++++++++++++++++++++++----- mbnntp/mbnntp.h | 2 ++ mbsebbs/email.c | 4 ++-- mbsebbs/mail.c | 33 +++++++++++++++++++++++---------- mbsebbs/mail.h | 2 +- 8 files changed, 68 insertions(+), 19 deletions(-) diff --git a/AUTHORS b/AUTHORS index 841d8060..ce4f0f04 100644 --- a/AUTHORS +++ b/AUTHORS @@ -51,4 +51,4 @@ Przemyslaw Kwiatkowski 2:480/127@fidonet Phil Kimble kimerud@users.sourceforge.net 1:14/200@fidonet David Gonzalez skynetbbs@007mundo.com 4:930/1@fidonet Malte Tychsen 2:240/9350@fidonet - +Dmitry Komissaroff rsprog@mail.ru diff --git a/ChangeLog b/ChangeLog index d0c9ca4b..99a99200 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,8 @@ v0.71.1 28-Nov-2004 Added port to OpenBSD, is under test (and doesn't work). Code cleanup so that compile stops on unknown OSes and CPUs instead of missing code parts. + Added Unix codepage KOI8-R (Russian) and patches from Dmitry + Komissaroff. mbsebbs: The creation of the mailout semafore is now after the hangup @@ -28,6 +30,8 @@ v0.71.1 28-Nov-2004 Made zmodem-8k downloads work again. Some small buffer protections added in addfile. Fixed keyboad input for all bigendian machines. + Patches from Dmitry Komissaroff to make charset translation + work on message subject lines. mbnewuser: During hangup we set sighup to ignore. @@ -66,6 +70,10 @@ v0.71.1 28-Nov-2004 is fresh created. Changed X-JAM kludges to X-FTN kludges to make it compatible with the rest of the gates. + Patches from Dmitry Komissaroff to make charset translation + work on message subject lines. It will now also send the right + charset of the user in the charset header line so that the + client will show the message in the users charset. mbsetup: Added support for XxxxBSD console port. diff --git a/mbnntp/auth.c b/mbnntp/auth.c index fda3bedc..cdd8d9eb 100644 --- a/mbnntp/auth.c +++ b/mbnntp/auth.c @@ -113,6 +113,7 @@ void auth_pass(char *cmd) while (fread(&usrconfig, usrconfighdr.recsize, 1, fp) == 1) { if (strcmp(usrconfig.Name, username) == 0) { FoundName = TRUE; + usercharset=usrconfig.Charset; break; } grecno++; diff --git a/mbnntp/commands.c b/mbnntp/commands.c index e983d88d..422498f1 100644 --- a/mbnntp/commands.c +++ b/mbnntp/commands.c @@ -64,7 +64,7 @@ void send_xlat(char *inp) { char *xl, temp[1024]; int i; - + memset(&temp, 0, sizeof(temp)); for (i = 0; i < strlen(inp); i++) { @@ -105,6 +105,27 @@ char *make_msgid(char *msgid) +char *getrfcchrs(int val) +{ + switch (val) { + case FTNC_NONE: return (char *)"iso-8859-1"; + case FTNC_CP437: return (char *)"cp437"; + case FTNC_CP850: return (char *)"cp850"; + case FTNC_CP865: return (char *)"cp865"; + case FTNC_CP866: return (char *)"cp866"; + case FTNC_CP852: return (char *)"cp852"; + case FTNC_CP895: return (char *)"cp895"; + case FTNC_LATIN_1: return (char *)"iso-8859-1"; + case FTNC_LATIN_2: return (char *)"iso-8859-2"; + case FTNC_LATIN_5: return (char *)"iso-8859-5"; + case FTNC_MAC: return (char *)"MAC 2"; + case FTNC_KOI8_R: return (char *)"koi8-r"; + default: return (char *)"iso-8859-1"; + } +} + + + /* * ARTICLE * BODY @@ -173,10 +194,12 @@ void command_abhs(char *buf) return; } + + /* - * Setup a default translation + * Setup a charset translation */ - charset_set_in_out((char *)"x-ibmpc", (char *)"iso-8859-1"); + charset_set_in_out(getrfcchrs(msgs.Charset),getrfcchrs(usercharset)); if (Msg_Read(art, 75)) { @@ -192,7 +215,9 @@ void command_abhs(char *buf) send_nntp("Path: MBNNTP!not-for-mail"); send_nntp("From: %s <%s>", Msg.From, Msg.FromAddress); send_nntp("Newsgroups: %s", currentgroup); - send_nntp("Subject: %s", Msg.Subject); + char *subj; + asprintf(&subj,"Subject: %s", Msg.Subject); + send_xlat(subj); send_nntp("Date: %s", rfcdate(Msg.Written + (gmt_offset((time_t)0) * 60))); send_nntp("Message-ID: %s", make_msgid(Msg.Msgid)); if (strlen(Msg.Replyid)) @@ -213,7 +238,7 @@ void command_abhs(char *buf) } send_nntp("MIME-Version: 1.0"); - send_nntp("Content-Type: text/plain; charset=iso-8859-1; format=fixed"); + send_nntp("Content-Type: text/plain; charset=%s; format=fixed", getrfcchrs(usercharset)); send_nntp("Content-Transfer-Encoding: 8bit"); } diff --git a/mbnntp/mbnntp.h b/mbnntp/mbnntp.h index f44fd7ba..814d2f68 100644 --- a/mbnntp/mbnntp.h +++ b/mbnntp/mbnntp.h @@ -3,6 +3,8 @@ /* $Id$ */ +int usercharset; + void send_nntp(const char *, ...); #ifndef USE_NEWSGATE diff --git a/mbsebbs/email.c b/mbsebbs/email.c index e83daca0..fa272ad6 100644 --- a/mbsebbs/email.c +++ b/mbsebbs/email.c @@ -450,7 +450,7 @@ int Read_a_Email(unsigned long Num) if (Kludges) { pout(LIGHTGRAY, BLACK, p); Enter(1); - if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE)) + if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE, FALSE)) break; } } else { @@ -460,7 +460,7 @@ int Read_a_Email(unsigned long Num) colour(CFG.HiliteF, CFG.HiliteB); PUTSTR(p); Enter(1); - if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE)) + if (CheckLine(CFG.TextColourF, CFG.TextColourB, TRUE, FALSE)) break; } } while ((p = (char *)MsgText_Next()) != NULL); diff --git a/mbsebbs/mail.c b/mbsebbs/mail.c index 6fdb28a4..f17cf92b 100644 --- a/mbsebbs/mail.c +++ b/mbsebbs/mail.c @@ -79,8 +79,7 @@ extern int LC_Wrote; /* Lastcaller info write message */ /* * Internal prototypes */ - -void ShowMsgHdr(void); /* Show message header */ +void ShowMsgHdr(int Conv); /* Show message header */ int Read_a_Msg(unsigned long Num, int);/* Read a message */ int Export_a_Msg(unsigned long Num);/* Export message to homedir */ int ReadPanel(void); /* Read panel bar */ @@ -892,13 +891,13 @@ int Save_Msg(int IsReply, faddr *Dest) /* * Show message header screen top for reading messages. */ -void ShowMsgHdr() +void ShowMsgHdr(int Conv) { static char Buf1[35], Buf2[35], Buf3[81]; char msg[81]; struct tm *tm; time_t now; - int color; + int color, i; Buf1[0] = '\0'; Buf2[0] = '\0'; @@ -986,7 +985,18 @@ void ShowMsgHdr() /* Subject : */ pout(YELLOW, BLACK, (char *) Language(210)); - pout(GREEN, BLACK, Msg.Subject); + colour(GREEN, BLACK); + + if (Conv) { + /* + * Try to translate character sets + */ + for (i = 0; i < strlen(Msg.Subject); i++) { + PUTSTR(charset_map_c(Msg.Subject[i], FALSE)); + } + } else { + PUTSTR(Msg.Subject); + } Enter(1); colour(CFG.HiliteF, CFG.HiliteB); @@ -1207,7 +1217,6 @@ int Read_a_Msg(unsigned long Num, int UpdateLR) sleep(3); return FALSE; } - ShowMsgHdr(); /* * Fill Quote file in case the user wants to reply. Note that line @@ -1263,6 +1272,10 @@ int Read_a_Msg(unsigned long Num, int UpdateLR) if (charsin && charsout && strcmp(charsout, charsin)) { UseIconv = charset_set_in_out(charsin, charsout); } + /* + * Show message header with charset mapping if needed. + */ + ShowMsgHdr(UseIconv); /* * Show message text @@ -1275,7 +1288,7 @@ int Read_a_Msg(unsigned long Num, int UpdateLR) if (Kludges) { pout(LIGHTGRAY, BLACK, p); Enter(1); - if (CheckLine(CFG.TextColourF, CFG.TextColourB, FALSE)) + if (CheckLine(CFG.TextColourF, CFG.TextColourB, FALSE, UseIconv)) break; } } else { @@ -1296,7 +1309,7 @@ int Read_a_Msg(unsigned long Num, int UpdateLR) Enter(1); } - if (CheckLine(CFG.TextColourF, CFG.TextColourB, FALSE)) + if (CheckLine(CFG.TextColourF, CFG.TextColourB, FALSE, UseIconv)) break; } } while ((p = (char *)MsgText_Next()) != NULL); @@ -1933,7 +1946,7 @@ void Delete_Msg() /* * Check linecounter for reading messages. */ -int CheckLine(int FG, int BG, int Email) +int CheckLine(int FG, int BG, int Email, int Conv) { int x, z; @@ -1960,7 +1973,7 @@ int CheckLine(int FG, int BG, int Email) if (Email) ShowEmailHdr(); else - ShowMsgHdr(); + ShowMsgHdr(Conv); colour(FG, BG); } return FALSE; diff --git a/mbsebbs/mail.h b/mbsebbs/mail.h index 3c56ac35..7047df07 100644 --- a/mbsebbs/mail.h +++ b/mbsebbs/mail.h @@ -9,7 +9,7 @@ int LC(int); /* More prompt for reading messages */ int Edit_Msg(void); /* Edit a message */ int Ext_Edit(void); /* External Message editor */ -int CheckLine(int, int, int); /* Check linecounter for read */ +int CheckLine(int, int, int, int); /* Check linecounter for read */ void SysopComment(char *); /* Comment to Sysop */ void Post_Msg(void); /* Post a message */ void Read_Msgs(void); /* Read Messages */