diff --git a/ChangeLog b/ChangeLog index 39670aca..d0492570 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,9 @@ v0.91.5 18-Feb-2007 be displayed before we know if a user ahs a utf-8 or ansi terminal, so change your logo screen so that it has no ansi grafics, just plain ascii with ansi color codes. + Start and leave mbsetup, this will upgrade the newfiles + reports to set a defaults CHRS kludge CP437 2 which is good + for reports with ANSI blockgraphics. mbselib: Fixed a too low memory allocation in clencode. @@ -42,6 +45,11 @@ v0.91.5 18-Feb-2007 mbfido: The make web stat produces UTF-8 webpages. + mbaff: + For each newfile report there is now a CHRS kludge setting. + Reports will be converted to the selected charset. Origin + characterset is CP437 for now. + mbnntp: Reading news outputs UTF-8 coded articles. TODO: test posting and fix if needed. @@ -49,6 +57,10 @@ v0.91.5 18-Feb-2007 mbtask: Fixed a too low memory allocation in clencode. + mbsetup: + In newfiles reports the Hi-ASCII setting is gone and a CHRS + kludge selection is added. Defaults to CP437 2. + lang: Language prompts 44, 75 and 76 are obsolete. diff --git a/lib/charset.c b/lib/charset.c index ceff5566..ef42e9ea 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -71,31 +71,29 @@ struct _charalias charalias[] = { /* - * Array of charset identifiers. Order is important for reverse - * search from rfc -> ftn, best ftn kludge should be on top. + * Array of charset identifiers. */ struct _charmap charmap[] = { - {FTNC_NONE, (char *)"Undef", (char *)"iso-8859-1", (char *)"Undef", (char *)"ISO-8859-1", (char *)"C", (char *)"Undefined"}, - {FTNC_LATIN_1,(char *)"LATIN-1 2",(char *)"iso-8859-1", (char *)"LATIN1", (char *)"ISO-8859-1", (char *)"en_US", (char *)"ISO 8859-1 (Western European)"}, + {FTNC_NONE, (char *)"Undef", (char *)"Undef", (char *)"Undef", (char *)"Undef", (char *)"C", (char *)"Undefined"}, {FTNC_CP437, (char *)"CP437 2", (char *)"us-ascii", (char *)"CP437", (char *)"ISO-8859-1", (char *)"en_US", (char *)"IBM codepage 437 (Western European) (ANSI terminal)"}, - {FTNC_CP865, (char *)"CP865 2", (char *)"iso-8859-1", (char *)"CP865", (char *)"ISO-8859-1", (char *)"sv_SE", (char *)"IBM codepage 865 (Nordic)"}, - {FTNC_MAC, (char *)"MAC", (char *)"Macintosh", (char *)"MACINTOSH",(char *)"ISO-8859-1", (char *)"en_US", (char *)"MacIntosh character set"}, {FTNC_CP850, (char *)"CP850 2", (char *)"iso-8859-1", (char *)"CP850", (char *)"ISO-8859-1", (char *)"en_US", (char *)"IBM codepage 850 (Latin-1)"}, + {FTNC_CP865, (char *)"CP865 2", (char *)"iso-8859-1", (char *)"CP865", (char *)"ISO-8859-1", (char *)"sv_SE", (char *)"IBM codepage 865 (Nordic)"}, + {FTNC_CP866, (char *)"CP866 2", (char *)"iso-8859-5", (char *)"CP866", (char *)"ISO-8859-5", (char *)"ru_RU", (char *)"IBM codepage 866 (Russian)"}, + {FTNC_LATIN_1,(char *)"LATIN-1 2",(char *)"iso-8859-1", (char *)"LATIN1", (char *)"ISO-8859-1", (char *)"en_US", (char *)"ISO 8859-1 (Western European)"}, {FTNC_LATIN_2,(char *)"LATIN-2 2",(char *)"iso-8859-2", (char *)"LATIN2", (char *)"ISO-8859-2", (char *)"cs_CZ", (char *)"ISO 8859-2 (Eastern European)"}, + {FTNC_LATIN_5,(char *)"LATIN-5 2",(char *)"iso-8859-5", (char *)"LATIN5", (char *)"ISO-8859-5", (char *)"turks", (char *)"ISO 8859-5 (Turkish)"}, + {FTNC_MAC, (char *)"MAC", (char *)"Macintosh", (char *)"MACINTOSH",(char *)"ISO-8859-1", (char *)"en_US", (char *)"MacIntosh character set"}, {FTNC_CP852, (char *)"CP852 2", (char *)"iso-8859-2", (char *)"CP852", (char *)"ISO-8859-2", (char *)"cs_CZ", (char *)"IBM codepage 852 (Czech, Latin-1)"}, {FTNC_CP895, (char *)"CP895 2", (char *)"iso-8859-2", (char *)"CP850", (char *)"ISO-8859-2", (char *)"cs_CZ", (char *)"IBM codepage 895 (Czech, Kamenicky)"}, - {FTNC_LATIN_5,(char *)"LATIN-5 2",(char *)"iso-8859-5", (char *)"LATIN5", (char *)"ISO-8859-5", (char *)"turks", (char *)"ISO 8859-5 (Turkish)"}, - {FTNC_CP866, (char *)"CP866 2", (char *)"iso-8859-5", (char *)"CP866", (char *)"ISO-8859-5", (char *)"ru_RU", (char *)"IBM codepage 866 (Russian)"}, - {FTNC_LATIN_9,(char *)"LATIN-9 2",(char *)"iso-8859-15",(char *)"LATIN-9", (char *)"ISO-8859-15",(char *)"en_US", (char *)"ISO 8859-1 (Western European EURO)"}, {FTNC_KOI8_R, (char *)"KOI8-R 2", (char *)"koi8-r", (char *)"KOI8-R", (char *)"KOI8-R", (char *)"ru_RUi.koi8r",(char *)"Unix codepage KOI8-R (Russian)"}, {FTNC_CP936, (char *)"CP936 2", (char *)"hz-gb-2312", (char *)"GB2312", (char *)"GB2312", (char *)"zh_CN.gbk", (char *)"IBM codepage 936 (Chinese, GBK)"}, + {FTNC_LATIN_9,(char *)"LATIN-9 2",(char *)"iso-8859-15",(char *)"LATIN-9", (char *)"ISO-8859-15",(char *)"en_US", (char *)"ISO 8859-1 (Western European EURO)"}, {FTNC_UTF8, (char *)"UTF-8 4", (char *)"utf-8", (char *)"UTF-8", (char *)"UTF-8", (char *)"en_US.UTF-8", (char *)"Unicode UTF-8 (ISO/IEC 10646)"}, {FTNC_ERROR, NULL, NULL, NULL, NULL, NULL, (char *)"ERROR"} }; - /* * Returns index of charset or -1 if not found. */ @@ -188,6 +186,7 @@ char *getftnchrs(int val) static char kludge[20]; if ((val >= FTNC_NONE) && (val <= FTNC_MAXCHARS)) { + Syslog('-', "getftnchrs(%d) %s", val, charmap[val].ftnkludge); snprintf(kludge, 20, "%s", charmap[val].ftnkludge); return kludge; } @@ -202,6 +201,7 @@ char *getrfcchrs(int val) static char rfcname[20]; if ((val >= FTNC_NONE) && (val <= FTNC_MAXCHARS)) { + Syslog('-', "getrfcchrs(%d) %s", val, charmap[val].rfcname); snprintf(rfcname, 20, "%s", charmap[val].rfcname); return rfcname; } @@ -216,6 +216,7 @@ char *get_ic_ftn(int val) static char ic_ftnname[20]; if ((val >= FTNC_NONE) && (val <= FTNC_MAXCHARS)) { + Syslog('-', "get_ic_ftn(%d) %s", val, charmap[val].ic_ftn); snprintf(ic_ftnname, 20, "%s", charmap[val].ic_ftn); return ic_ftnname; } @@ -230,6 +231,7 @@ char *get_ic_rfc(int val) static char ic_rfcname[20]; if ((val >= FTNC_NONE) && (val <= FTNC_MAXCHARS)) { + Syslog('-', "get_ic_rfc(%d) %s", val, charmap[val].ic_rfc); snprintf(ic_rfcname, 20, "%s", charmap[val].ic_rfc); return ic_rfcname; } diff --git a/mbfido/announce.c b/mbfido/announce.c index ceebe689..d395c449 100644 --- a/mbfido/announce.c +++ b/mbfido/announce.c @@ -4,7 +4,7 @@ * Purpose ...............: Announce new files and FileFind * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2007 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -174,13 +174,15 @@ int StartMsg(void) CountPosted(newfiles.Area); - snprintf(Msg.From, 101, "%s", newfiles.From); - snprintf(Msg.To, 101, "%s", newfiles.Too); + chartran_init((char *)"CP437", get_ic_ftn(newfiles.charset), 'f'); + + snprintf(Msg.From, 101, "%s", chartran(newfiles.From)); + snprintf(Msg.To, 101, "%s", chartran(newfiles.Too)); if (MsgCount == 1) { - snprintf(Msg.Subject, 101, "%s", newfiles.Subject); + snprintf(Msg.Subject, 101, "%s", chartran(newfiles.Subject)); TotalSize = TotalFiles = 0; } else - snprintf(Msg.Subject, 101, "%s #%d", newfiles.Subject, MsgCount); + snprintf(Msg.Subject, 101, "%s #%d", chartran(newfiles.Subject), MsgCount); snprintf(Msg.FromAddress, 101, "%s", aka2str(newfiles.UseAka)); Msg.Written = time(NULL); Msg.Arrived = time(NULL); @@ -191,7 +193,7 @@ int StartMsg(void) * Start message text including kludges */ Msg_Id(newfiles.UseAka); - Msg_Pid(); + Msg_Pid(newfiles.charset); return Msg_Top(newfiles.Template, newfiles.Language, newfiles.UseAka); } @@ -227,6 +229,8 @@ void FinishMsg(int Final, int filepos) Msg_UnLock(); Syslog('+', "Posted message %ld, %d bytes", Msg.Id, Msg.Size); + chartran_close(); + snprintf(temp, PATH_MAX, "%s/tmp/echomail.jam", getenv("MBSE_ROOT")); if ((fp = fopen(temp, "a")) != NULL) { fprintf(fp, "%s %u\n", newfiles.Area, Msg.Id); @@ -268,12 +272,12 @@ int Report(gr_list *ta, int filepos) break; } - Syslog('m', "Announce %s %s %s", T_File.Echo, T_File.Name, T_File.LName); + Syslog('m', "Announce %s %s %s", T_File.Echo, T_File.Name, chartran(T_File.LName)); if ((fi = OpenMacro(newfiles.Template, newfiles.Language, FALSE)) != NULL) { /* * Area block header */ - MacroVars("GJZ", "ssd", T_File.Echo, T_File.Comment, 0); + MacroVars("GJZ", "ssd", T_File.Echo, chartran(T_File.Comment), 0); fseek(fi, filepos, SEEK_SET); Msg_Macro(fi); filepos1 = ftell(fi); @@ -296,7 +300,7 @@ int Report(gr_list *ta, int filepos) ftime = T_File.Fdate; MacroVars("sl", "ss", T_File.Name, T_File.LName); MacroVars("bk", "dd", T_File.Size, T_File.SizeKb); - MacroVars("dt", "ss", rfcdate(ftime), To_Low(T_File.LDesc[0],newfiles.HiAscii)); + MacroVars("dt", "ss", rfcdate(ftime), chartran(T_File.LDesc[0])); Msg_Macro(fi); filepos2 = ftell(fi); @@ -306,7 +310,7 @@ int Report(gr_list *ta, int filepos) for (i = 1; i < 24; i++) { fseek(fi, filepos2, SEEK_SET); if (strlen(T_File.LDesc[i])) { - MacroVars("t", "s", To_Low(T_File.LDesc[i],newfiles.HiAscii)); + MacroVars("t", "s", chartran(T_File.LDesc[i])); Msg_Macro(fi); } else { line = calloc(MAXSTR, sizeof(char)); diff --git a/mbfido/filefind.c b/mbfido/filefind.c index 24ed87a5..ea836fe3 100644 --- a/mbfido/filefind.c +++ b/mbfido/filefind.c @@ -4,7 +4,7 @@ * Purpose ...............: Announce new files and FileFind * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2007 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -193,7 +193,7 @@ int StartReply(ff_list *ffl) MsgText_Add2(temp); Msg.ReplyCRC = upd_crc32(temp, crc, strlen(temp)); free(temp); - Msg_Pid(); + Msg_Pid(FTNC_NONE); return Msg_Top(scanmgr.template, scanmgr.Language, scanmgr.Aka); } diff --git a/mbfido/msgutil.c b/mbfido/msgutil.c index 8860bbb6..f7529ef1 100644 --- a/mbfido/msgutil.c +++ b/mbfido/msgutil.c @@ -4,7 +4,7 @@ * Purpose ...............: Announce new files and FileFind * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2007 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -81,7 +81,10 @@ void Msg_Id(fidoaddr aka) -void Msg_Pid(void) +/* + * Passed charset overrides defaults + */ +void Msg_Pid(int charset) { char *temp; time_t tt; @@ -89,7 +92,9 @@ void Msg_Pid(void) temp = calloc(81, sizeof(char)); snprintf(temp, 81, "\001PID: MBSE-FIDO %s (%s-%s)", VERSION, OsName(), OsCPU()); MsgText_Add2(temp); - if (msgs.Charset != FTNC_NONE) { + if (charset != FTNC_NONE) { + snprintf(temp, 81, "\001CHRS: %s", getftnchrs(charset)); + } else if (msgs.Charset != FTNC_NONE) { snprintf(temp, 81, "\001CHRS: %s", getftnchrs(msgs.Charset)); } else { snprintf(temp, 81, "\001CHRS: %s", getftnchrs(FTNC_LATIN_1)); diff --git a/mbfido/msgutil.h b/mbfido/msgutil.h index f1b59a15..f77c30d8 100644 --- a/mbfido/msgutil.h +++ b/mbfido/msgutil.h @@ -5,7 +5,7 @@ void Msg_Id(fidoaddr); -void Msg_Pid(void); +void Msg_Pid(int); void Msg_Macro(FILE *); int Msg_Top(char *, int, fidoaddr); void Msg_Bot(fidoaddr, char *, char *); diff --git a/mbsetup/m_new.c b/mbsetup/m_new.c index 79cb41a1..9b062141 100644 --- a/mbsetup/m_new.c +++ b/mbsetup/m_new.c @@ -4,7 +4,7 @@ * Purpose ...............: Newfiles Setup * ***************************************************************************** - * Copyright (C) 1997-2005 + * Copyright (C) 1997-2007 * * Michiel Broek FIDO: 2:280/2802 * Beekmansbos 10 @@ -74,7 +74,7 @@ int CountNewfiles(void) snprintf(newfiles.Template, 15, "newfiles"); newfiles.Language = 'E'; newfiles.Active = TRUE; - newfiles.HiAscii = TRUE; + newfiles.charset = FTNC_CP437; fwrite(&newfiles, sizeof(newfiles), 1, fil); snprintf(group, 13, "LOCAL"); fwrite(&group, 13, 1, fil); @@ -105,78 +105,85 @@ int CountNewfiles(void) */ int OpenNewfiles(void) { - FILE *fin, *fout; - char fnin[PATH_MAX], fnout[PATH_MAX]; - int oldsize; - int i, old_groups; - int oldgroup; - char group[13]; + FILE *fin, *fout; + char *fnin, *fnout, group[13]; + int oldsize, i, old_groups, oldgroup; - snprintf(fnin, PATH_MAX, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); - snprintf(fnout, PATH_MAX, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); - if ((fin = fopen(fnin, "r")) != NULL) { - if ((fout = fopen(fnout, "w")) != NULL) { - fread(&newfileshdr, sizeof(newfileshdr), 1, fin); - /* - * In case we are automatic upgrading the data format - * we save the old format. If it is changed, the - * database must always be updated. - */ - oldsize = newfileshdr.recsize; - oldgroup = newfileshdr.grpsize; - old_groups = oldgroup / 13; - if ((oldsize != sizeof(newfiles)) || (CFG.new_groups != old_groups)) - NewUpdated = 1; - else - NewUpdated = 0; - if (oldsize != sizeof(newfiles)) - Syslog('+', "Updated %s, format changed", fnin); - else if (CFG.new_groups != old_groups) - Syslog('+', "Updated %s, nr of groups now %d", fnin, CFG.new_groups); + fnin = calloc(PATH_MAX, sizeof(char)); + fnout = calloc(PATH_MAX, sizeof(char)); + snprintf(fnin, PATH_MAX, "%s/etc/newfiles.data", getenv("MBSE_ROOT")); + snprintf(fnout, PATH_MAX, "%s/etc/newfiles.temp", getenv("MBSE_ROOT")); + + if ((fin = fopen(fnin, "r")) != NULL) { + if ((fout = fopen(fnout, "w")) != NULL) { + fread(&newfileshdr, sizeof(newfileshdr), 1, fin); + /* + * In case we are automatic upgrading the data format + * we save the old format. If it is changed, the + * database must always be updated. + */ + oldsize = newfileshdr.recsize; + oldgroup = newfileshdr.grpsize; + old_groups = oldgroup / 13; + if ((oldsize != sizeof(newfiles)) || (CFG.new_groups != old_groups)) + NewUpdated = 1; + else + NewUpdated = 0; + if (oldsize != sizeof(newfiles)) + Syslog('+', "Updated %s, format changed", fnin); + else if (CFG.new_groups != old_groups) + Syslog('+', "Updated %s, nr of groups now %d", fnin, CFG.new_groups); + + newfileshdr.hdrsize = sizeof(newfileshdr); + newfileshdr.recsize = sizeof(newfiles); + newfileshdr.grpsize = CFG.new_groups * 13; + fwrite(&newfileshdr, sizeof(newfileshdr), 1, fout); - newfileshdr.hdrsize = sizeof(newfileshdr); - newfileshdr.recsize = sizeof(newfiles); - newfileshdr.grpsize = CFG.new_groups * 13; - fwrite(&newfileshdr, sizeof(newfileshdr), 1, fout); - - /* - * The datarecord is filled with zero's before each - * read, so if the format changed, the new fields - * will be empty. - */ - memset(&newfiles, 0, sizeof(newfiles)); - while (fread(&newfiles, oldsize, 1, fin) == 1) { - if (!strlen(newfiles.Template)) { - snprintf(newfiles.Template, 15, "newfiles"); - NewUpdated = 1; - } - fwrite(&newfiles, sizeof(newfiles), 1, fout); - memset(&newfiles, 0, sizeof(newfiles)); - /* - * Copy the existing groups - */ - for (i = 1; i <= old_groups; i++) { - fread(&group, 13, 1, fin); - if (i <= CFG.new_groups) - fwrite(&group, 13, 1, fout); - } - if (old_groups < CFG.new_groups) { - /* - * The size increased, fill with - * blank records. - */ - memset(&group, 0, 13); - for (i = (old_groups + 1); i <= CFG.new_groups; i++) - fwrite(&group, 13, 1, fout); - } - } - fclose(fin); - fclose(fout); - return 0; - } else - return -1; + /* + * The datarecord is filled with zero's before each + * read, so if the format changed, the new fields + * will be empty. + */ + memset(&newfiles, 0, sizeof(newfiles)); + while (fread(&newfiles, oldsize, 1, fin) == 1) { + if (!strlen(newfiles.Template)) { + snprintf(newfiles.Template, 15, "newfiles"); + NewUpdated = 1; + } + if (newfiles.charset == FTNC_NONE) { + newfiles.charset = FTNC_CP437; + NewUpdated = 1; + } + fwrite(&newfiles, sizeof(newfiles), 1, fout); + memset(&newfiles, 0, sizeof(newfiles)); + /* + * Copy the existing groups + */ + for (i = 1; i <= old_groups; i++) { + fread(&group, 13, 1, fin); + if (i <= CFG.new_groups) + fwrite(&group, 13, 1, fout); + } + if (old_groups < CFG.new_groups) { + /* + * The size increased, fill with blank records. + */ + memset(&group, 0, 13); + for (i = (old_groups + 1); i <= CFG.new_groups; i++) + fwrite(&group, 13, 1, fout); + } + } + fclose(fin); + fclose(fout); + free(fnin); + free(fnout); + return 0; } - return -1; + } + + free(fnin); + free(fnout); + return -1; } @@ -249,6 +256,7 @@ int AppendNewfiles(void) snprintf(newfiles.From, 36, "%s", CFG.sysop_name); newfiles.Language = 'E'; snprintf(newfiles.Template, 15, "newfiles"); + newfiles.charset = FTNC_CP437; strncpy(newfiles.Origin, CFG.origin, 50); fwrite(&newfiles, sizeof(newfiles), 1, fil); memset(&group, 0, 13); @@ -280,8 +288,8 @@ void NewScreen(void) mbse_mvprintw(15, 2, "9. Aka to use"); mbse_mvprintw(16, 2, "10. Active"); mbse_mvprintw(17, 2, "11. Deleted"); - mbse_mvprintw(16,42, "12. High ASCII"); - mbse_mvprintw(17,42, "13. New groups"); + mbse_mvprintw(16,42, "12. New groups"); + mbse_mvprintw(17,42, "13. CHRS kludge"); } @@ -360,12 +368,12 @@ int EditNewRec(int Area) show_str( 15,18,35, aka2str(newfiles.UseAka)); show_bool(16,18, newfiles.Active); show_bool(17,18, newfiles.Deleted); - show_bool(16,58, newfiles.HiAscii); i = 0; for (tmp = fgr; tmp; tmp = tmp->next) if (tmp->tagged) i++; - show_int( 17,58, i); + show_int( 16,58, i); + show_charset(17,58, newfiles.charset); switch(select_menu(13)) { case 0: @@ -420,10 +428,11 @@ int EditNewRec(int Area) break; case 10:E_BOOL(16,18, newfiles.Active, "If this report is ^active^") case 11:E_BOOL(17,18, newfiles.Deleted, "Is this record ^deleted^") - case 12:E_BOOL(16,58, newfiles.HiAscii, "Allow ^High ASCII^ in this report") - case 13:if (E_Group(&fgr, (char *)"12.13 NEWFILE GROUPS")) + case 12:if (E_Group(&fgr, (char *)"12.13 NEWFILE GROUPS")) GrpChanged = TRUE; break; + case 13:newfiles.charset = edit_charset(17,58, newfiles.charset); + break; } } } @@ -585,7 +594,7 @@ int new_doc(FILE *fp, FILE *toc, int page) add_webtable(wp, (char *)"Language", temp); add_webtable(wp, (char *)"Aka to use", aka2str(newfiles.UseAka)); add_webtable(wp, (char *)"Active", getboolean(newfiles.Active)); - add_webtable(wp, (char *)"Allow High ASCII", getboolean(newfiles.HiAscii)); + add_webtable(wp, (char *)"CHRS kludge", getftnchrs(newfiles.charset)); fprintf(fp, " Area comment %s\n", newfiles.Comment); fprintf(fp, " Message area %s\n", newfiles.Area); fprintf(fp, " Origin line %s\n", newfiles.Origin); @@ -595,7 +604,7 @@ int new_doc(FILE *fp, FILE *toc, int page) fprintf(fp, " Language %c\n", newfiles.Language); fprintf(fp, " Aka to use %s\n", aka2str(newfiles.UseAka)); fprintf(fp, " Active %s\n", getboolean(newfiles.Active)); - fprintf(fp, " Allow High ASCII %s\n", getboolean(newfiles.HiAscii)); + fprintf(fp, " CHRS kludge %s\n", getftnchrs(newfiles.charset)); fprintf(fp, "\n File groups:\n "); groups = newfileshdr.grpsize / sizeof(group); for (i = 0; i < groups; i++) {