diff --git a/ChangeLog b/ChangeLog index f3d02349..e3b90a2f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,8 +38,8 @@ v0.51.1 21-Feb-2004 Added experimental characterset translation to message read. This will translate the message character set used to the users character set. When translation is impossible a ? is printed. - Doesn't work well with Russion, but seems to work with German - text. + After problems with iconv, switched to use code from Martin + Junius Fidogate package. In delete file in home directory the Y/N keys were read from the wrong language prompt. diff --git a/TODO b/TODO index 6cb07789..79a1bd5a 100644 --- a/TODO +++ b/TODO @@ -112,6 +112,8 @@ mbfido: N: Force processing of arealists so that all tags are forced to uppercase. Seems to give problems in some nets. + N: Make tic areas check case insensitive. + N: Let mbfido areas with a special switch update area descriptions. N: Send rulefile via netmail for each new connected mail area. diff --git a/config.h.in b/config.h.in index ec438660..465afc8b 100644 --- a/config.h.in +++ b/config.h.in @@ -182,9 +182,6 @@ /* Define if you have the header file. */ #undef HAVE_UTMPX_H -/* Define if you have the header file. */ -#undef HAVE_ICONV_H - /* Define if you have the memcpy function. */ #undef HAVE_MEMCPY diff --git a/configure b/configure index 809fb3aa..b85d82ed 100755 --- a/configure +++ b/configure @@ -5373,8 +5373,7 @@ done - -for ac_header in sys/resource.h usersec.h gshadow.h shadow.h iconv.h +for ac_header in sys/resource.h usersec.h gshadow.h shadow.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then diff --git a/configure.in b/configure.in index a6eecf52..990fc187 100644 --- a/configure.in +++ b/configure.in @@ -203,7 +203,7 @@ AC_HEADER_DIRENT AC_HEADER_TIME AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(sys/time.h termios.h sys/vfs.h unistd.h netinet/in.h regex.h) -AC_CHECK_HEADERS(sys/resource.h usersec.h gshadow.h shadow.h iconv.h) +AC_CHECK_HEADERS(sys/resource.h usersec.h gshadow.h shadow.h) AC_CHECK_HEADERS(limits.h utmp.h utmpx.h lastlog.h rpc/key_prot.h) AC_STRUCT_TIMEZONE diff --git a/lib/Makefile b/lib/Makefile index 23cd6e53..cc5a1590 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -33,17 +33,22 @@ MBINET_HDRS = mbinet.h DIESEL_SRCS = diesel.c mbdiesel.c DIESEL_HDRS = diesel.h DIESEL_OBJS = diesel.o mbdiesel.o +CHC_SRCS = mbcharsetc.c +CHC_HDRS = mbcharsetc.h +CHC_OBJS = mbcharsetc.o OTHER_HDRS = bluewave.h mbse.h users.h SRCS = ${COMMON_SRCS} ${DBASE_SRCS} ${MSGBASE_SRCS} ${MBINET_SRCS} \ - ${DIESEL_SRCS} ${NODELIST_SRCS} + ${DIESEL_SRCS} ${NODELIST_SRCS} ${CHC_SRCS} OBJS = ${COMMON_OBJS} ${DBASE_OBJS} ${MSGBASE_OBJS} ${MBINET_OBJS} \ - ${DIESEL_OBJS} ${NODELIST_OBJS} + ${DIESEL_OBJS} ${NODELIST_OBJS} ${CHC_OBJS} HDRS = ${COMMON_HDRS} ${DBASE_HDRS} ${MSGBASE_HDRS} ${MBINET_HDRS} \ - ${DIESEL_HDRS} ${NODELIST_HDRS} ${OTHER_HDRS} + ${DIESEL_HDRS} ${NODELIST_HDRS} ${CHC_HDRS} ${OTHER_HDRS} +MAPS = charset.map russian.map OTHER = Makefile README ftscprod.008 mkprod.awk \ README.diesel README.macro Diesel.doc nodelist.conf TARGET = libmbse.a libdbase.a libmsgbase.a libmbinet.a libdiesel.a \ - libnodelist.a + libnodelist.a mbcharsetc charset.bin +LIBS += ../lib/libmbse.a ############################################################################# @@ -79,8 +84,16 @@ libnodelist.a: ${NODELIST_OBJS} ar r $@ $? ${RANLIB} $@ +mbcharsetc: ${CHC_OBJS} ${LIBS} + ${CC} -o mbcharsetc ${CHC_OBJS} ${LDFLAGS} ${LIBS} + +charset.bin: mbcharsetc ${MAPS} + ./mbcharsetc charset.map charset.bin + install: all ${INSTALL} -c -o ${OWNER} -g ${GROUP} -m 0444 nodelist.conf ${ETCDIR} + ${INSTALL} -c -s -g ${GROUP} -o ${OWNER} -m 0751 mbcharsetc ${BINDIR} + ${INSTALL} -c -o ${OWNER} -g ${GROUP} -m 0444 charset.bin ${ETCDIR} clean: rm -f ${TARGET} *.o *.h~ *.c~ ftscprod.c core filelist Makefile.bak diff --git a/lib/charset.c b/lib/charset.c index 36906fc6..d6b4a147 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -32,6 +32,84 @@ #include "mbselib.h" +#define strieq(a,b) (strcasecmp ((a),(b)) == 0) +#define BUF_APPEND(d,s) str_append(d,sizeof(d),s) + + +/* + * Alias linked list + */ +static CharsetAlias *charset_alias_list = NULL; +static CharsetAlias *charset_alias_last = NULL; + +/* + * Table linked list + */ +static CharsetTable *charset_table_list = NULL; +static CharsetTable *charset_table_last = NULL; + +/* + * Current charset mapping table + */ +static CharsetTable *charset_table_used = NULL; + + + + +/* + * str_printf(): wrapper for sprintf()/snprintf() + */ +int str_printf(char *buf, size_t len, const char *fmt, ...) +{ + va_list args; + int n; + + va_start(args, fmt); + +#ifdef HAS_SNPRINTF + n = vsnprintf(buf, len, fmt, args); + /**FIXME: check for n==-1 and errno**/ +#else + n = vsprintf(buf, fmt, args); + if(n >= len) { + WriteError("Internal error - str_printf() buf overflow"); + /**NOT REACHED**/ + return FALSE; + } +#endif + /* Make sure that buf[] is terminated with a \0. vsnprintf() + * should do this automatically as required by the ANSI C99 + * proposal, but one never knows ... see also discussion on + * BugTraq */ + buf[len - 1] = 0; + + va_end(args); + + return n; +} + + +char *str_append(char *d, size_t n, char *s) +{ + int max = n - strlen(d) - 1; + + strncat(d, s, max); + d[n-1] = 0; + return d; +} + + + +char *str_copy(char *d, size_t n, char *s) +{ + strncpy(d, s, n); + d[n-1] = 0; + return d; +} + +#define BUF_COPY(d,s) str_copy (d,sizeof(d),s) + + char *getchrs(int val) { switch (val) { @@ -67,34 +145,288 @@ char *getchrsdesc(int val) -char *get_iconv_name(char *name) +/* + * Alloc new CharsetTable and put into linked list + */ +CharsetTable *charset_table_new(void) { - if (!strncasecmp(name, "CP437", 5)) - return (char *)"IBM437"; - if (!strncasecmp(name, "CP850", 5)) - return (char *)"IBM850"; - if (!strncasecmp(name, "CP865", 5)) - return (char *)"IBM865"; - if (!strncasecmp(name, "CP866", 5)) - return (char *)"IBM866"; - if (!strncasecmp(name, "LATIN-1", 7)) - return (char *)"ISO_8859-1"; - if (!strncasecmp(name, "LATIN-2", 7)) - return (char *)"ISO_8859-2"; - if (!strncasecmp(name, "LATIN-5", 7)) - return (char *)"ISO_8859-5"; - if (!strncasecmp(name, "PC-8", 4)) - return (char *)"IBM437"; - if (!strncasecmp(name, "IBMPC", 5)) - return (char *)"IBM437"; - if (!strncasecmp(name, "+7_FIDO", 7)) - return (char *)"IBM866"; - if (!strncasecmp(name, "CP1125", 6)) - return (char *)"CP1125"; + CharsetTable *p; - Syslog('+', "get_iconv_name(%s): no usable character set name found", name); - return NULL; + /* Alloc and clear */ + p = (CharsetTable *)xmalloc(sizeof(CharsetTable)); + memset(p, 0, sizeof(CharsetTable)); + p->next = NULL; /* Just to be sure */ + + /* Put into linked list */ + if(charset_table_list) + charset_table_last->next = p; + else + charset_table_list = p; + charset_table_last = p; + + return p; +} + + +/* + * Alloc new CharsetAlias and put into linked list + */ +CharsetAlias *charset_alias_new(void) +{ + CharsetAlias *p; + + /* Alloc and clear */ + p = (CharsetAlias *)xmalloc(sizeof(CharsetAlias)); + memset(p, 0, sizeof(CharsetAlias)); + p->next = NULL; /* Just to be sure */ + + /* Put into linked list */ + if(charset_alias_list) + charset_alias_last->next = p; + else + charset_alias_list = p; + charset_alias_last = p; + + return p; } +/* + * Write binary mapping file + */ +int charset_write_bin(char *name) +{ + FILE *fp; + CharsetTable *pt; + CharsetAlias *pa; + +// debug(14, "Writing charset.bin file %s", name); + + fp = fopen(name, "w+"); + if(!fp) + return FALSE; + + /* Write aliases */ + for (pa = charset_alias_list; pa; pa=pa->next) { + fputc(CHARSET_FILE_ALIAS, fp); + fwrite(pa, sizeof(CharsetAlias), 1, fp); + if(ferror(fp)) { + fclose(fp); + return FALSE; + } + } + + /* Write tables */ + for(pt = charset_table_list; pt; pt=pt->next) { + fputc(CHARSET_FILE_TABLE, fp); + fwrite(pt, sizeof(CharsetTable), 1, fp); + if(ferror(fp)) { + fclose(fp); + return FALSE; + } + } + + fclose(fp); + return TRUE; +} + + + +/* + * Read binary mapping file + */ +int charset_read_bin(void) +{ + FILE *fp; + int c, n; + CharsetTable *pt; + CharsetAlias *pa; + char *name; + + name = calloc(PATH_MAX, sizeof(char)); + sprintf(name, "%s/etc/charset.bin", getenv("MBSE_ROOT")); + Syslog('s', "Reading %s", name); + if ((fp = fopen(name, "r")) == NULL) { + WriteError("$Can't open %s", name); + free(name); + return FALSE; + } + free(name); + + while( (c = fgetc(fp)) != EOF ) { + switch(c) { + case CHARSET_FILE_ALIAS: + pa = charset_alias_new(); + n = fread((void *)pa, sizeof(CharsetAlias), 1, fp); + pa->next = NULL; /* overwritten by fread() */ + if(n != 1) + return FALSE; + Syslog('s', "read charset alias: %s -> %s", pa->alias, pa->name); + break; + case CHARSET_FILE_TABLE: + pt = charset_table_new(); + n = fread((void *)pt, sizeof(CharsetTable), 1, fp); + pt->next = NULL; /* overwritten by fread() */ + if(n != 1) + return FALSE; + Syslog('s', "read charset table: %s -> %s", pt->in, pt->out); + break; + default: + return FALSE; + break; + } + } + + if(ferror(fp)) + return FALSE; + fclose(fp); + return TRUE; +} + + + +/* + * Convert to MIME quoted-printable =XX if qp==TRUE + */ +char *charset_qpen(int c, int qp) +{ + static char buf[4]; + + c &= 0xff; + + if( qp && (c == '=' || c >= 0x80) ) + str_printf(buf, sizeof(buf), "=%02.2X", c & 0xff); + else + { + buf[0] = c; + buf[1] = 0; + } + + return buf; +} + + + +/* + * Map single character + */ +char *charset_map_c(int c, int qp) +{ + static char buf[MAX_CHARSET_OUT * 4]; + char *s; + + c &= 0xff; + buf[0] = 0; + + if(charset_table_used && c>=0x80) + { + s = charset_table_used->map[c - 0x80]; + while(*s) + BUF_APPEND(buf, charset_qpen(*s++, qp)); + } + else + { + BUF_COPY(buf, charset_qpen(c, qp)); + } + + return buf; +} + + + +/* + * Search alias + */ +char *charset_alias_fsc(char *name) +{ + CharsetAlias *pa; + + /* Search for aliases */ + for(pa = charset_alias_list; pa; pa=pa->next) + { + if(strieq(pa->name, name)) + return pa->alias; + } + + return name; +} + + + +char *charset_alias_rfc(char *name) +{ + CharsetAlias *pa; + + /* Search for aliases */ + for(pa = charset_alias_list; pa; pa=pa->next) + { + if(strieq(pa->alias, name)) + return pa->name; + } + + return name; +} + + + +/* + * Set character mapping table + */ +int charset_set_in_out(char *in, char *out) +{ + CharsetTable *pt; + CharsetAlias *pa; + int i; + + if (!in || !out) + return FALSE; + + /* + * Check if charset.bin is loaded. + */ + if ((charset_alias_list == NULL) || (charset_table_list == NULL)) + charset_read_bin(); + Syslog('s', "charset1: in=%s out=%s", in, out); + + + /* + * For charset names with a space (level number), shorten the name. + */ + for (i = 0; i < strlen(in); i++) + if (in[i] == ' ') { + in[i] = '\0'; + break; + } + + for (i = 0; i < strlen(out); i++) + if (out[i] == ' ') { + out[i] = '\0'; + break; + } + Syslog('s', "charset2: in=%s out=%s", in, out); + + /* Search for aliases */ + for (pa = charset_alias_list; pa; pa=pa->next) { + if (strieq(pa->alias, in)) + in = pa->name; + if (strieq(pa->alias, out)) + out = pa->name; + } + Syslog('s', "charset3: in=%s out=%s", in, out); + + /* Search for matching table */ + for (pt = charset_table_list; pt; pt=pt->next) { + if(strieq(pt->in, in) && strieq(pt->out, out)) { + Syslog('s', "charset: table found in=%s out=%s", pt->in, pt->out); + charset_table_used = pt; + return TRUE; + } + } + + Syslog('b', "charset: no table found in=%s out=%s", in, out); + charset_table_used = NULL; + return FALSE; +} + + diff --git a/lib/charset.map b/lib/charset.map new file mode 100644 index 00000000..49cc865a --- /dev/null +++ b/lib/charset.map @@ -0,0 +1,1321 @@ +# +# $Id$ +# +# Character set mapping table (to be compiled by mbcharsetc) +# +# Base of this map was made by Martin Junius for Fidogate, +# syntax is the same. +# +# Syntax: +# +# include FILE +# alias FSC-NAME RFC-NAME +# table IN-SET OUT-SET +# map IN-CHAR OUT-CHAR [OUT-CHAR] [OUT-CHAR] +# map 1:1 +# map 1:1-noctrl +# map default CHAR +# ... +# +# IN-SET/OUT-SET: us-ascii (FSC-0054: ASCII, VT100) +# iso-8859-1 (FSC-0054: LATIN-1, AMIGA) +# x-ibmpc (FSC-0054: IBMPC, PC-8) +# x-mac (FSC-0054: MAC) +# koir-8 (KOIR-8) +# x-alt (ALT) +# ... +# +# IN-CHAR: X character X +# \NNN octal value +# \xNN hex value +# +# OUT-CHAR: up to 3 characters (syntax IN-CHAR) +# +# 1:1 all characters not explicitly defined are +# mapped to the same character +# +# 1:1-noctrl all characters not explicitly defined are +# mapped to the same character, but not the +# high-bit control characters (0x80...0x9f) +# +# default CHAR all characters not explicitly defined are +# mapped to CHAR (syntax IN-CHAR) +# +# Currently only characters with high bit set (0x80) are mapped!!! +# If not defined, the default mapping is any character >=0x80 -> nothing. +# +# Charset names must be less than 16 characters in length!!! +# + +# +# Aliases for FSC-0054 ^ACHRS +# +# FSC-0054 name RFC 2045 name +# ------------- ------------- +alias ascii us-ascii +alias vt100 us-ascii +alias latin-1 iso-8859-1 +alias amiga iso-8859-1 +alias ibmpc x-ibmpc +alias pc-8 x-ibmpc +alias cp437 x-ibmpc +alias mac x-mac + + +# ---------------------------------------------------------------------------- +table us-ascii us-ascii +# nothing special to map + + +# ---------------------------------------------------------------------------- +table us-ascii iso-8859-1 +# nothing special to map + + +# ---------------------------------------------------------------------------- +table us-ascii x-ibmpc +# nothing special to map + + +# ---------------------------------------------------------------------------- +table us-ascii x-mac +# nothing special to map + + +# ---------------------------------------------------------------------------- +table iso-8859-1 us-ascii +map \x80 ? +map \x81 ? +map \x82 ? +map \x83 ? +map \x84 ? +map \x85 ? +map \x86 ? +map \x87 ? +map \x88 ? +map \x89 ? +map \x8A ? +map \x8B ? +map \x8C ? +map \x8D ? +map \x8E ? +map \x8F ? +map \x90 ? +map \x91 ? +map \x92 ? +map \x93 ? +map \x94 ? +map \x95 ? +map \x96 ? +map \x97 ? +map \x98 ? +map \x99 ? +map \x9A ? +map \x9B ? +map \x9C ? +map \x9D ? +map \x9E ? +map \x9F ? +map \xA0 \x20 +map \xA1 ! +map \xA2 c +map \xA3 # +map \xA4 ? +map \xA5 Y +map \xA6 | +map \xA7 S +map \xA8 " +map \xA9 ( C ) +map \xAA a +map \xAB < < +map \xAC - +map \xAD - +map \xAE ( R ) +map \xAF - +map \xB0 o +map \xB1 + - +map \xB2 ^ 2 +map \xB3 ^ 3 +map \xB4 ' +map \xB5 m u +map \xB6 P +map \xB7 . +map \xB8 , +map \xB9 ^ 1 +map \xBA o +map \xBB > > +map \xBC 1 / 4 +map \xBD 1 / 2 +map \xBE 3 / 4 +map \xBF ? +map \xC0 A +map \xC1 A +map \xC2 A +map \xC3 A +map \xC4 A e +map \xC5 A +map \xC6 A E +map \xC7 C +map \xC8 E +map \xC9 E +map \xCA E +map \xCB E +map \xCC I +map \xCD I +map \xCE I +map \xCF I +map \xD0 D +map \xD1 N +map \xD2 O +map \xD3 O +map \xD4 O +map \xD5 O +map \xD6 O e +map \xD7 x +map \xD8 O +map \xD9 U +map \xDA U +map \xDB U +map \xDC U e +map \xDD Y +map \xDE ? +map \xDF s s +map \xE0 a +map \xE1 a +map \xE2 a +map \xE3 a +map \xE4 a e +map \xE5 a +map \xE6 a e +map \xE7 c +map \xE8 e +map \xE9 e +map \xEA e +map \xEB e +map \xEC i +map \xED i +map \xEE i +map \xEF i +map \xF0 ? +map \xF1 n +map \xF2 o +map \xF3 o +map \xF4 o +map \xF5 o +map \xF6 o e +map \xF7 / +map \xF8 o +map \xF9 u +map \xFA u +map \xFB u +map \xFC u e +map \xFD y +map \xFE ? +map \xFF y + + +# ---------------------------------------------------------------------------- +table iso-8859-1 iso-8859-1 +map \x80 ? +map \x81 ? +map \x82 ? +map \x83 ? +map \x84 ? +map \x85 ? +map \x86 ? +map \x87 ? +map \x88 ? +map \x89 ? +map \x8A ? +map \x8B ? +map \x8C ? +map \x8D ? +map \x8E ? +map \x8F ? +map \x90 ? +map \x91 ? +map \x92 ? +map \x93 ? +map \x94 ? +map \x95 ? +map \x96 ? +map \x97 ? +map \x98 ? +map \x99 ? +map \x9A ? +map \x9B ? +map \x9C ? +map \x9D ? +map \x9E ? +map \x9F ? +map 1:1-noctrl + + +# ---------------------------------------------------------------------------- +table iso-8859-1 x-ibmpc +map \x80 ? +map \x81 ? +map \x82 ? +map \x83 ? +map \x84 ? +map \x85 ? +map \x86 ? +map \x87 ? +map \x88 ? +map \x89 ? +map \x8A ? +map \x8B ? +map \x8C ? +map \x8D ? +map \x8E ? +map \x8F ? +map \x90 ? +map \x91 ? +map \x92 ? +map \x93 ? +map \x94 ? +map \x95 ? +map \x96 ? +map \x97 ? +map \x98 ? +map \x99 ? +map \x9A ? +map \x9B ? +map \x9C ? +map \x9D ? +map \x9E ? +map \x9F ? +map \xA0 \xFF +map \xA1 \xAD +map \xA2 \x9B +map \xA3 \x9C +map \xA4 ? +map \xA5 \x9D +map \xA6 | +map \xA7 \x15 +map \xA8 " +map \xA9 c +map \xAA \xA6 +map \xAB \xAE +map \xAC \xAA +map \xAD - +map \xAE R +map \xAF - +map \xB0 \xF8 +map \xB1 \xF1 +map \xB2 \xFD +map \xB3 ^ 3 +map \xB4 ' +map \xB5 \xE6 +map \xB6 \x14 +map \xB7 \xFE +map \xB8 , +map \xB9 ^ 1 +map \xBA \xA7 +map \xBB \xAF +map \xBC \xAC +map \xBD \xAB +map \xBE 3 / 4 +map \xBF \xA8 +map \xC0 A +map \xC1 A +map \xC2 A +map \xC3 A +map \xC4 \x8E +map \xC5 \x8F +map \xC6 \x92 +map \xC7 \x80 +map \xC8 E +map \xC9 \x90 +map \xCA E +map \xCB E e +map \xCC I +map \xCD I +map \xCE I +map \xCF I e +map \xD0 D +map \xD1 \xA5 +map \xD2 O +map \xD3 O +map \xD4 O +map \xD5 O +map \xD6 \x99 +map \xD7 x +map \xD8 \x9D +map \xD9 U +map \xDA U +map \xDB U +map \xDC \x9A +map \xDD Y +map \xDE T h +map \xDF \xE1 +map \xE0 \x85 +map \xE1 \xA0 +map \xE2 \x83 +map \xE3 a +map \xE4 \x84 +map \xE5 \x86 +map \xE6 \x91 +map \xE7 \x87 +map \xE8 \x8A +map \xE9 \x82 +map \xEA \x88 +map \xEB \x89 +map \xEC \x8D +map \xED \xA1 +map \xEE \x8C +map \xEF \x8B +map \xF0 \xE7 +map \xF1 \xA4 +map \xF2 \x95 +map \xF3 \xA2 +map \xF4 \x93 +map \xF5 o +map \xF6 \x94 +map \xF7 \xF6 +map \xF8 \x9B +map \xF9 \x97 +map \xFA \xA3 +map \xFB \x96 +map \xFC \x81 +map \xFD y e +map \xFE t h +map \xFF \x98 + + +# ---------------------------------------------------------------------------- +table iso-8859-1 x-mac +map \x80 ? +map \x81 ? +map \x82 ? +map \x83 ? +map \x84 ? +map \x85 ? +map \x86 ? +map \x87 ? +map \x88 ? +map \x89 ? +map \x8A ? +map \x8B ? +map \x8C ? +map \x8D ? +map \x8E ? +map \x8F ? +map \x90 ? +map \x91 ? +map \x92 ? +map \x93 ? +map \x94 ? +map \x95 ? +map \x96 ? +map \x97 ? +map \x98 ? +map \x99 ? +map \x9A ? +map \x9B ? +map \x9C ? +map \x9D ? +map \x9E ? +map \x9F ? +map \xA0 \xCA +map \xA1 \xC1 +map \xA2 \xA2 +map \xA3 \xA3 +map \xA4 ? +map \xA5 \xB4 +map \xA6 | +map \xA7 \xA4 +map \xA8 \xAC +map \xA9 \xA9 +map \xAA \xBB +map \xAB \xC7 +map \xAC \xC2 +map \xAD \xD1 +map \xAE \xA8 +map \xAF ? +map \xB0 \xA1 +map \xB1 \xB1 +map \xB2 ^ 2 +map \xB3 ^ 3 +map \xB4 \xAB +map \xB5 \xB5 +map \xB6 \xA6 +map \xB7 \xA5 +map \xB8 , +map \xB9 ^ 1 +map \xBA \xBC +map \xBB \xC8 +map \xBC ? +map \xBD . 5 +map \xBE ? +map \xBF \xC0 +map \xC0 A +map \xC1 A +map \xC2 A +map \xC3 A +map \xC4 \x80 +map \xC5 \x81 +map \xC6 \xAE +map \xC7 \x82 +map \xC8 E +map \xC9 \x83 +map \xCA E +map \xCB E e +map \xCC I +map \xCD I +map \xCE I +map \xCF I e +map \xD0 D +map \xD1 \x84 +map \xD2 O +map \xD3 O +map \xD4 O +map \xD5 O +map \xD6 \x85 +map \xD7 x +map \xD8 \xAF +map \xD9 U +map \xDA U +map \xDB U +map \xDC \x86 +map \xDD Y +map \xDE ? +map \xDF \xA7 +map \xE0 \x88 +map \xE1 \x87 +map \xE2 \x89 +map \xE3 \x8B +map \xE4 \x8A +map \xE5 \x8C +map \xE6 \xBE +map \xE7 \x8D +map \xE8 \x8F +map \xE9 \x8E +map \xEA \x90 +map \xEB \x91 +map \xEC \x93 +map \xED \x92 +map \xEE \x94 +map \xEF \x95 +map \xF0 ? +map \xF1 \x96 +map \xF2 \x98 +map \xF3 \x97 +map \xF4 \x99 +map \xF5 \x9B +map \xF6 \x9A +map \xF7 \xD6 +map \xF8 \xBF +map \xF9 \x9D +map \xFA \x9C +map \xFB \x9E +map \xFC \x9F +map \xFD y e +map \xFE ? +map \xFF \xD7 + + +# ---------------------------------------------------------------------------- +table x-ibmpc us-ascii +map \x80 C +map \x81 u e +map \x82 e +map \x83 a +map \x84 a e +map \x85 a +map \x86 a +map \x87 c +map \x88 e +map \x89 e +map \x8A e +map \x8B i +map \x8C i +map \x8D i +map \x8E A e +map \x8F A +map \x90 E +map \x91 a e +map \x92 A E +map \x93 o +map \x94 o e +map \x95 o +map \x96 u +map \x97 u +map \x98 y +map \x99 O e +map \x9A U e +map \x9B c +map \x9C # +map \x9D Y +map \x9E P t +map \x9F f +map \xA0 a +map \xA1 i +map \xA2 o +map \xA3 u +map \xA4 n +map \xA5 N +map \xA6 a +map \xA7 o +map \xA8 ? +map \xA9 - +map \xAA ! +map \xAB . 5 +map \xAC ? +map \xAD ! +map \xAE < < +map \xAF > > +map \xB0 # +map \xB1 # +map \xB2 # +map \xB3 | +map \xB4 | +map \xB5 | +map \xB6 | +map \xB7 + +map \xB8 + +map \xB9 | +map \xBA | +map \xBB + +map \xBC + +map \xBD + +map \xBE + +map \xBF + +map \xC0 + +map \xC1 - +map \xC2 - +map \xC3 | +map \xC4 - +map \xC5 + +map \xC6 | +map \xC7 | +map \xC8 + +map \xC9 + +map \xCA = +map \xCB = +map \xCC | +map \xCD = +map \xCE + +map \xCF = +map \xD0 - +map \xD1 = +map \xD2 - +map \xD3 + +map \xD4 + +map \xD5 + +map \xD6 + +map \xD7 | +map \xD8 + +map \xD9 + +map \xDA + +map \xDB # +map \xDC n +map \xDD | +map \xDE | +map \xDF ~ +map \xE0 ? +map \xE1 s s +map \xE2 ? +map \xE3 ? +map \xE4 ? +map \xE5 ? +map \xE6 ? +map \xE7 ? +map \xE8 ? +map \xE9 ? +map \xEA ? +map \xEB ? +map \xEC ? +map \xED ? +map \xEE ? +map \xEF ? +map \xF0 = = +map \xF1 + - +map \xF2 > = +map \xF3 < = +map \xF4 ? +map \xF5 ? +map \xF6 / +map \xF7 ~ = +map \xF8 ? +map \xF9 . +map \xFA - +map \xFB ? +map \xFC ^ n +map \xFD ^ 2 +map \xFE o +map \xFF \x20 + + +# ---------------------------------------------------------------------------- +table x-ibmpc iso-8859-1 +map \x80 \xC7 +map \x81 \xFC +map \x82 \xE9 +map \x83 \xE2 +map \x84 \xE4 +map \x85 \xE0 +map \x86 \xE5 +map \x87 \xE7 +map \x88 \xEA +map \x89 \xEB +map \x8A \xE8 +map \x8B \xEF +map \x8C \xEE +map \x8D \xEC +map \x8E \xC4 +map \x8F \xC5 +map \x90 \xC9 +map \x91 \xE6 +map \x92 \xC6 +map \x93 \xF4 +map \x94 \xF6 +map \x95 \xF2 +map \x96 \xFB +map \x97 \xF9 +map \x98 \xFF +map \x99 \xD6 +map \x9A \xDC +map \x9B \xA2 +map \x9C \xA3 +map \x9D \xA5 +map \x9E ? +map \x9F f +map \xA0 \xE1 +map \xA1 \xED +map \xA2 \xF3 +map \xA3 \xFA +map \xA4 \xF1 +map \xA5 \xD1 +map \xA6 \xAA +map \xA7 \xBA +map \xA8 \xBF +map \xA9 - +map \xAA \xAC +map \xAB \xBD +map \xAC \xBC +map \xAD \xA1 +map \xAE \xAB +map \xAF \xBB +map \xB0 # +map \xB1 # +map \xB2 # +map \xB3 | +map \xB4 | +map \xB5 | +map \xB6 | +map \xB7 + +map \xB8 + +map \xB9 | +map \xBA | +map \xBB + +map \xBC + +map \xBD + +map \xBE + +map \xBF + +map \xC0 + +map \xC1 - +map \xC2 - +map \xC3 | +map \xC4 - +map \xC5 + +map \xC6 | +map \xC7 | +map \xC8 + +map \xC9 + +map \xCA = +map \xCB = +map \xCC | +map \xCD = +map \xCE + +map \xCF = +map \xD0 - +map \xD1 = +map \xD2 - +map \xD3 + +map \xD4 + +map \xD5 + +map \xD6 + +map \xD7 | +map \xD8 + +map \xD9 + +map \xDA + +map \xDB # +map \xDC n +map \xDD | +map \xDE | +map \xDF ~ +map \xE0 ? +map \xE1 \xDF +map \xE2 ? +map \xE3 ? +map \xE4 ? +map \xE5 ? +map \xE6 \xB5 +map \xE7 ? +map \xE8 ? +map \xE9 ? +map \xEA ? +map \xEB ? +map \xEC ? +map \xED ? +map \xEE ? +map \xEF ? +map \xF0 ? +map \xF1 \xB1 +map \xF2 ? +map \xF3 ? +map \xF4 ? +map \xF5 ? +map \xF6 \xF7 +map \xF7 ? +map \xF8 \xB0 +map \xF9 . +map \xFA \xB7 +map \xFB ? +map \xFC ? +map \xFD \xB2 +map \xFE o +map \xFF \x20 + + +# ---------------------------------------------------------------------------- +table x-ibmpc x-ibmpc +# nothing special to map + + +# ---------------------------------------------------------------------------- +table x-ibmpc x-mac +map \x80 \x82 +map \x81 \x9F +map \x82 \x8E +map \x83 \x89 +map \x84 \x8A +map \x85 \x88 +map \x86 \x8C +map \x87 \x8D +map \x88 \x90 +map \x89 \x91 +map \x8A \x8F +map \x8B \x95 +map \x8C \x94 +map \x8D \x93 +map \x8E \x80 +map \x8F \x81 +map \x90 \x83 +map \x91 \xBE +map \x92 \xAE +map \x93 \x99 +map \x94 \x9A +map \x95 \x98 +map \x96 \x9E +map \x97 \x9D +map \x98 \xD8 +map \x99 \x85 +map \x9A \x9F +map \x9B \xA2 +map \x9C \xA3 +map \x9D \xB4 +map \x9E P t +map \x9F \xC4 +map \xA0 \x87 +map \xA1 \x92 +map \xA2 \x97 +map \xA3 \x9C +map \xA4 \x96 +map \xA5 \x84 +map \xA6 \xBB +map \xA7 \xBC +map \xA8 \xC0 +map \xA9 - +map \xAA \xC2 +map \xAB . 5 +map \xAC ? +map \xAD \xC1 +map \xAE \xC7 +map \xAF \xC8 +map \xB0 # +map \xB1 # +map \xB2 # +map \xB3 | +map \xB4 | +map \xB5 | +map \xB6 | +map \xB7 + +map \xB8 + +map \xB9 | +map \xBA | +map \xBB + +map \xBC + +map \xBD + +map \xBE + +map \xBF + +map \xC0 + +map \xC1 - +map \xC2 - +map \xC3 | +map \xC4 - +map \xC5 + +map \xC6 | +map \xC7 | +map \xC8 + +map \xC9 + +map \xCA = +map \xCB = +map \xCC | +map \xCD = +map \xCE + +map \xCF = +map \xD0 - +map \xD1 = +map \xD2 - +map \xD3 + +map \xD4 + +map \xD5 + +map \xD6 + +map \xD7 | +map \xD8 + +map \xD9 + +map \xDA + +map \xDB # +map \xDC n +map \xDD | +map \xDE | +map \xDF ~ +map \xE0 a +map \xE1 \xA7 +map \xE2 ? +map \xE3 \xB9 +map \xE4 \xB7 +map \xE5 ? +map \xE6 \xB5 +map \xE7 ? +map \xE8 ? +map \xE9 ? +map \xEA \xBD +map \xEB \xB6 +map \xEC \xB0 +map \xED \xBF +map \xEE ? +map \xEF ? +map \xF0 = = +map \xF1 \xB1 +map \xF2 \xB3 +map \xF3 \xB2 +map \xF4 ? +map \xF5 ? +map \xF6 \xD6 +map \xF7 \xC5 +map \xF8 \xA1 +map \xF9 . +map \xFA \xD0 +map \xFB \xC3 +map \xFC ^ n +map \xFD ^ 2 +map \xFE \xA5 +map \xFF \x20 + + +# ---------------------------------------------------------------------------- +table x-mac us-ascii +map \x80 A e +map \x81 A +map \x82 C +map \x83 E +map \x84 N +map \x85 O e +map \x86 U e +map \x87 a +map \x88 a +map \x89 a +map \x8A a e +map \x8B a +map \x8C a +map \x8D c +map \x8E e +map \x8F e +map \x90 e +map \x91 e +map \x92 i +map \x93 i +map \x94 i +map \x95 i +map \x96 n +map \x97 o +map \x98 o +map \x99 o +map \x9A o e +map \x9B o +map \x9C u +map \x9D u +map \x9E u +map \x9F u e +map \xA0 + +map \xA1 o +map \xA2 c +map \xA3 # +map \xA4 S +map \xA5 o +map \xA6 ? +map \xA7 s s +map \xA8 R +map \xA9 c +map \xAA T M +map \xAB ' +map \xAC ? +map \xAD < > +map \xAE A E +map \xAF 0 +map \xB0 ? +map \xB1 + - +map \xB2 < = +map \xB3 > = +map \xB4 Y +map \xB5 m u +map \xB6 d +map \xB7 ? +map \xB8 ? +map \xB9 p i +map \xBA ? +map \xBB a +map \xBC o +map \xBD O +map \xBE a e +map \xBF o +map \xC0 ? +map \xC1 ! +map \xC2 ! +map \xC3 ? +map \xC4 f +map \xC5 ~ = +map \xC6 ? +map \xC7 > > +map \xC8 < < +map \xC9 . . +map \xCA \x20 +map \xCB A +map \xCC A +map \xCD O +map \xCE O E +map \xCF o e +map \xD0 - +map \xD1 - +map \xD2 " +map \xD3 " +map \xD4 ` +map \xD5 ' +map \xD6 / +map \xD7 ? +map \xD8 y +map \xD9 ? +map \xDA ? +map \xDB ? +map \xDC ? +map \xDD ? +map \xDE ? +map \xDF ? +map \xE0 ? +map \xE1 ? +map \xE2 ? +map \xE3 ? +map \xE4 ? +map \xE5 ? +map \xE6 ? +map \xE7 ? +map \xE8 ? +map \xE9 ? +map \xEA ? +map \xEB ? +map \xEC ? +map \xED ? +map \xEE ? +map \xEF ? +map \xF0 ? +map \xF1 ? +map \xF2 ? +map \xF3 ? +map \xF4 ? +map \xF5 ? +map \xF6 ? +map \xF7 ? +map \xF8 ? +map \xF9 ? +map \xFA ? +map \xFB ? +map \xFC ? +map \xFD ? +map \xFE ? +map \xFF ? + + +# ---------------------------------------------------------------------------- +table x-mac iso-8859-1 +map \x80 \xC4 +map \x81 \xC5 +map \x82 \xC7 +map \x83 \xC9 +map \x84 \xD1 +map \x85 \xD6 +map \x86 \xDC +map \x87 \xE1 +map \x88 \xE0 +map \x89 \xE2 +map \x8A \xE4 +map \x8B \xE3 +map \x8C \xE5 +map \x8D \xE7 +map \x8E \xE9 +map \x8F \xE8 +map \x90 \xEA +map \x91 \xEB +map \x92 \xED +map \x93 \xEC +map \x94 \xEE +map \x95 \xEF +map \x96 \xF1 +map \x97 \xF3 +map \x98 \xF2 +map \x99 \xF4 +map \x9A \xF6 +map \x9B \xF5 +map \x9C \xFA +map \x9D \xF9 +map \x9E \xFB +map \x9F \xFC +map \xA0 \xBE +map \xA1 \xB0 +map \xA2 \xA2 +map \xA3 \xA3 +map \xA4 \xA7 +map \xA5 o +map \xA6 \xB6 +map \xA7 \xDF +map \xA8 \xAE +map \xA9 \xA9 +map \xAA ? +map \xAB \xB4 +map \xAC \xA8 +map \xAD \xAD +map \xAE \xC6 +map \xAF \xD8 +map \xB0 ? +map \xB1 \xB1 +map \xB2 \xB2 +map \xB3 \xB3 +map \xB4 \xA5 +map \xB5 \xB5 +map \xB6 \xA6 +map \xB7 ? +map \xB8 ? +map \xB9 \xB9 +map \xBA \xBC +map \xBB \xAA +map \xBC \xBA +map \xBD \xBD +map \xBE \xE6 +map \xBF \xF8 +map \xC0 \xBF +map \xC1 \xA1 +map \xC2 \xAC +map \xC3 ? +map \xC4 f +map \xC5 ~ = +map \xC6 ? +map \xC7 \xAB +map \xC8 \xBB +map \xC9 . . +map \xCA \x20 +map \xCB \xC0 +map \xCC \xC3 +map \xCD \xD5 +map \xCE ? +map \xCF ? +map \xD0 \xD0 +map \xD1 - +map \xD2 " +map \xD3 " +map \xD4 ` +map \xD5 ' +map \xD6 / +map \xD7 \xD7 +map \xD8 \xFF +map \xD9 ? +map \xDA ? +map \xDB \xA4 +map \xDC ? +map \xDD \xDD +map \xDE \xDE +map \xDF ? +map \xE0 ? +map \xE1 \xB7 +map \xE2 ? +map \xE3 ? +map \xE4 ? +map \xE5 \xC2 +map \xE6 \xCA +map \xE7 \xC1 +map \xE8 \xCB +map \xE9 \xC8 +map \xEA \xCD +map \xEB \xCE +map \xEC \xCF +map \xED \xCC +map \xEE \xD3 +map \xEF \xD4 +map \xF0 \xF0 +map \xF1 \xD2 +map \xF2 \xDA +map \xF3 \xDB +map \xF4 \xD9 +map \xF5 ? +map \xF6 ? +map \xF7 ? +map \xF8 \xAF +map \xF9 ? +map \xFA ? +map \xFB ? +map \xFC \xB8 +map \xFD \xFD +map \xFE \xFE +map \xFF ? + + +# ---------------------------------------------------------------------------- +table x-mac x-ibmpc +map \x80 \x8E +map \x81 \x8F +map \x82 \x80 +map \x83 \x90 +map \x84 \xA5 +map \x85 \x94 +map \x86 \x9A +map \x87 \xA0 +map \x88 \x85 +map \x89 \x83 +map \x8A \x84 +map \x8B a +map \x8C \x86 +map \x8D \x87 +map \x8E \x82 +map \x8F \x8A +map \x90 \x88 +map \x91 \x89 +map \x92 \xA1 +map \x93 \x8D +map \x94 \x8C +map \x95 \x8B +map \x96 \xA4 +map \x97 \xA2 +map \x98 \x95 +map \x99 \x96 +map \x9A \x94 +map \x9B o +map \x9C \xA3 +map \x9D \x97 +map \x9E \x96 +map \x9F \x81 +map \xA0 + +map \xA1 \xF8 +map \xA2 \x9B +map \xA3 \x9C +map \xA4 \x15 +map \xA5 \xFE +map \xA6 \x14 +map \xA7 \xE1 +map \xA8 ( R ) +map \xA9 ( C ) +map \xAA t m +map \xAB ' +map \xAC ? +map \xAD < > +map \xAE \x92 +map \xAF \x9D +map \xB0 \xEC +map \xB1 \xF1 +map \xB2 \xF3 +map \xB3 \xF2 +map \xB4 \x9D +map \xB5 \xE6 +map \xB6 \xEB +map \xB7 \xE4 +map \xB8 ? +map \xB9 \xE3 +map \xBA ? +map \xBB \xA6 +map \xBC \xA7 +map \xBD \xEA +map \xBE \x91 +map \xBF \x9B +map \xC0 \xA8 +map \xC1 \xAD +map \xC2 \xAA +map \xC3 \xFB +map \xC4 \x9F +map \xC5 \xF7 +map \xC6 \x7F +map \xC7 \xAF +map \xC8 \xAE +map \xC9 . . +map \xCA \x20 +map \xCB A +map \xCC A +map \xCD O +map \xCE O E +map \xCF o e +map \xD0 \xFA +map \xD1 - +map \xD2 " +map \xD3 " +map \xD4 ` +map \xD5 ' +map \xD6 \xF6 +map \xD7 \x04 +map \xD8 \x98 +map \xD9 Y +map \xDA / +map \xDB C u +map \xDC < +map \xDD > +map \xDE f i +map \xDF f l +map \xE0 + + +map \xE1 . +map \xE2 ' +map \xE3 " +map \xE4 % . +map \xE5 A +map \xE6 E +map \xE7 A +map \xE8 E +map \xE9 E +map \xEA I +map \xEB I +map \xEC I +map \xED I +map \xEE O +map \xEF O +map \xF0 ? +map \xF1 O +map \xF2 U +map \xF3 U +map \xF4 U +map \xF5 i +map \xF6 ? +map \xF7 ? +map \xF8 - +map \xF9 u +map \xFA . +map \xFB o +map \xFC , +map \xFD " +map \xFE , +map \xFF v + + +# ---------------------------------------------------------------------------- +table x-mac x-mac +# nothing special to map + + +# ---------------------------------------------------------------------------- +include russian.map diff --git a/lib/mbcharsetc.c b/lib/mbcharsetc.c new file mode 100644 index 00000000..757f3c73 --- /dev/null +++ b/lib/mbcharsetc.c @@ -0,0 +1,388 @@ +/***************************************************************************** + * + * $Id$ + * Purpose ...............: Characterset Compiler + * Author ................: Martin Junius, for Fidogate + * + ***************************************************************************** + * Copyright (C) 1997-2004 + * + * Michiel Broek FIDO: 2:280/2802 + * Beekmansbos 10 + * 1971 BV IJmuiden + * the Netherlands + * + * This file is part of MBSE BBS. + * + * This BBS 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 2, or (at your option) any + * later version. + * + * MBSE BBS 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 MBSE BBS; see the file COPYING. If not, write to the Free + * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + *****************************************************************************/ + +/***************************************************************************** + * FIDOGATE --- Gateway UNIX Mail/News <-> FTN NetMail/EchoMail + * + * Charset mapping table compiler + * + ***************************************************************************** + * Copyright (C) 1990-2002 + * _____ _____ + * | |___ | Martin Junius + * | | | | | | Radiumstr. 18 + * |_|_|_|@home| D-51069 Koeln, Germany + * + * This file is part of FIDOGATE. + * + * FIDOGATE 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 2, or (at your option) any + * later version. + * + * FIDOGATE 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 FIDOGATE; see the file COPYING. If not, write to the Free + * Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + *****************************************************************************/ + +#include "../config.h" +#include "mbselib.h" +#include "mbcharsetc.h" + + +char *str_copy(char *, size_t, char *); + +#define strieq(a,b) (strcasecmp ((a),(b)) == 0) +#define PROGRAM "mbcharsetc" +#define BUFFERSIZE (32*1024) /* Global buffer */ +#define BUF_COPY(d,s) str_copy (d,sizeof(d),s) + +char buffer[BUFFERSIZE]; + + + +/* + * Prototypes + */ +int charset_parse_c (char *); +int charset_do_file (char *); +int compile_map (char *, char *); +void usage (void); + + + +/* + * Check for hex digits, signed char-safe version of isxdigit() + */ +int is_xdigit(int c) +{ + /* + * Some implementation only accept a parameter value range + * of [-1,255]. This may lead to problems, because we're quite often + * passing *p's to is_digit() with a char *p variable. The default + * char type is signed in most C implementation. + */ + return isxdigit((c & 0xff)); +} + + +/* + * Check for octal digits + */ +int is_odigit(int c) +{ + return c>='0' && c<'8'; +} + + + +/* + * isspace() replacement, checking for SPACE, TAB, CR, LF + */ +int is_space(int c) +{ + return c==' ' || c=='\t' || c=='\r' || c=='\n'; +} + + +/* + * Read line from config file. Strip `\n', leading spaces, + * comments (starting with `#'), and empty lines. cf_getline() returns + * a pointer to the first non-whitespace in buffer. + */ +static long cf_lineno = 0; + +long cf_lineno_get(void) +{ + return cf_lineno; +} + + +long cf_lineno_set(long n) +{ + long old; + + old = cf_lineno; + cf_lineno = n; + + return old; +} + + +char *cf_getline(char *cbuffer, int len, FILE *fp) +{ + char *p; + + while (fgets(cbuffer, len, fp)) { + cf_lineno++; + Striplf(cbuffer); + for(p = cbuffer; *p && is_space(*p); p++) ; /* Skip white spaces */ + if (*p != '#') + return p; + } + return NULL; +} + + + +/* + * Parse character + */ +int charset_parse_c(char *s) +{ + int val, n; + + if(s[0] == '\\') { /* Special: \NNN or \xNN */ + s++; + val = 0; + n = 0; + if(s[0]=='x' || s[0]=='X') { /* Hex */ + s++; + while (is_xdigit(s[0]) && n<2) { + s[0] = toupper(s[0]); + val = val * 16 + s[0] - (s[0]>'9' ? 'A'-10 : '0'); + s++; + n++; + } + if(*s) + return ERROR; + } else { /* Octal */ + while(is_odigit(s[0]) && n<3) { + val = val * 8 + s[0] - '0'; + s++; + n++; + } + if(*s) + return ERROR; + } + } else { + if(s[1] == 0) /* Single char */ + val = s[0] & 0xff; + else + return ERROR; + } + + return val & 0xff; +} + + + +/* + * Process one line from charset.map file + */ +int charset_do_line(char *line) +{ + static CharsetTable *pt = NULL; + char *key, *w1, *w2; + CharsetAlias *pa; + int i, c1, c2; + + key = strtok(line, " \t"); + if(!key) + return TRUE; + + if (strieq(key, "include")) { + w1 = strtok(NULL, " \t"); + if (charset_do_file(w1) == FALSE) + return FALSE; + } + + /* Define alias */ + else if (strieq(key, "alias")) { + w1 = strtok(NULL, " \t"); + w2 = strtok(NULL, " \t"); + if(!w1 || !w2) { + fprintf(stderr, "%s:%ld: argument(s) for alias missing\n", PROGRAM, cf_lineno_get()); + return FALSE; + } + + pa = charset_alias_new(); + BUF_COPY(pa->alias, w1); + BUF_COPY(pa->name, w2); + } + + /* Define table */ + else if (strieq(key, "table")) { + w1 = strtok(NULL, " \t"); + w2 = strtok(NULL, " \t"); + if(!w1 || !w2) { + fprintf(stderr, "%s:%ld: argument(s) for table missing\n", PROGRAM, cf_lineno_get()); + return FALSE; + } + + pt = charset_table_new(); + BUF_COPY(pt->in, w1); + BUF_COPY(pt->out, w2); + } + + /* Define mapping for character(s) in table */ + else if (strieq(key, "map")) { + w1 = strtok(NULL, " \t"); + if (!w1) { + fprintf(stderr, "%s:%ld: argument for map missing\n", PROGRAM, cf_lineno_get()); + return FALSE; + } + + /* 1:1 mapping */ + if (strieq(w1, "1:1")) { + for(i=0; imap[i][0] == 0) { + pt->map[i][0] = 0x80 + i; + pt->map[i][1] = 0; + } + } + } + /* 1:1 mapping, but not for 0x80...0x9f */ + if(strieq(w1, "1:1-noctrl")) { + for(i=0x20; imap[i][0] == 0) { + pt->map[i][0] = 0x80 + i; + pt->map[i][1] = 0; + } + } + } + /* Mapping for undefined characters */ + else if(strieq(w1, "default")) { + /**FIXME: not yet implemented**/ + } + /* Normal mapping */ + else { + if ((c1 = charset_parse_c(w1)) == ERROR) { + fprintf(stderr, "%s:%ld: illegal char %s\n", PROGRAM, cf_lineno_get(), w1); + return FALSE; + } + if (c1 < 0x80) { + fprintf(stderr, "%s:%ld: illegal char %s, must be >= 0x80\n", PROGRAM, cf_lineno_get(), w1); + return FALSE; + } + + for (i=0; imap[c1 & 0x7f][i] = c2; + } + for (; imap[c1 & 0x7f][i] = 0; + } + } + /* Error */ + else { + fprintf(stderr, "%s:%ld: illegal key word %s\n", PROGRAM, cf_lineno_get(), key); + return FALSE; + } + + return TRUE; +} + + + +/* + * Process charset.map file + */ +int charset_do_file(char *name) +{ + FILE *fp; + char *p; + long oldn; + + if(!name) + return FALSE; + + oldn = cf_lineno_set(0); + fp = fopen(name, "r"); + if(!fp) + return FALSE; + + while ((p = cf_getline(buffer, BUFFERSIZE, fp))) + charset_do_line(p); + + fclose(fp); + cf_lineno_set(oldn); + + return TRUE; +} + + + +/* + * Compile charset.map + */ +int compile_map(char *in, char *out) +{ + /* Read charset.map and compile */ + if(charset_do_file(in) == FALSE) { + fprintf(stderr, "%s: compiling map file %s failed", PROGRAM, in); + return MBERR_GENERAL; + } + + /* Write binary output file */ + if (charset_write_bin(out) == ERROR) { + fprintf(stderr, "%s: writing binary map file %s failed", PROGRAM, out); + return MBERR_GENERAL; + } + + return MBERR_OK; +} + + + +void usage(void) +{ + fprintf(stderr, "\n%s: MBSE BBS %s Character Map Compiler\n", PROGRAM, VERSION); + fprintf(stderr, " %s\n\n", COPYRIGHT); + fprintf(stderr, "usage: %s charset.map charset.bin\n\n", PROGRAM); + exit(MBERR_OK); +} + + + +int main(int argc, char **argv) +{ + int ret = MBERR_OK; + char *name_in, *name_out; + + if (argc != 3) + usage(); + + name_in = argv[1]; + name_out = argv[2]; + ret = compile_map(name_in, name_out); + + exit(ret); +} + diff --git a/lib/mbcharsetc.h b/lib/mbcharsetc.h new file mode 100644 index 00000000..f7870f5c --- /dev/null +++ b/lib/mbcharsetc.h @@ -0,0 +1,7 @@ +#ifndef _MBCHARSET_H +#define _MBCHARSET_H + +/* $Id$ */ + + +#endif diff --git a/lib/mbselib.h b/lib/mbselib.h index f70938a0..58721077 100644 --- a/lib/mbselib.h +++ b/lib/mbselib.h @@ -92,9 +92,6 @@ #endif #include #include -#ifdef HAVE_ICONV_H -#include -#endif #include #include @@ -376,39 +373,6 @@ struct icmp_filter { #define FTNC_MAXCHARS 8 /* Highest charset number */ -/* - * Mapping: - * - * Kludge iconv name - * ---------- --------------- - * ASCII 1 ISO646-US - * DUTCH 1 - * FINNISH 1 ISO646-FI - * FRENCH 1 ISO646-FR - * CANADIAN 1 ISO646-CA - * GERMAN 1 - * ITALIAN 1 ISO646-IT - * NORWEIG 1 ISO646-NO - * PORTU 1 ISO646-PT - * SPANISH 1 ISO646-ES - * SWEDISH 1 ISO646-SE - * SWISS 1 - * UK 1 ISO646-GB - * CP437 2 CP437 - * CP850 2 CP850 - * CP865 2 CP865 - * CP866 2 CP766 - * LATIN-1 2 ISO8859-1 - * LATIN-2 2 ISO8859-2 - * LATIN-5 2 ISO8859-5 - * MAC 2 MAC - * PC-8 ISO646-US - * IBMPC 2 CP437 - * UKR 2 CP866 - * +7_FIDO CP866 - * - */ - /***************************************************************************** * * Global typedefs. @@ -2129,15 +2093,6 @@ int attach(faddr, char *, int, char); -/* - * From charset.c - */ -char *getchrs(int); /* Return characterset name */ -char *getchrsdesc(int); /* Return characterset description */ -char *get_iconv_name(char *); /* Return usable name for iconv */ - - - /* * From dostran.c */ @@ -2461,6 +2416,48 @@ int gpt_running(int); /* Is timer running */ int msleep(int); /* Milliseconds timer */ + +/************************************************************************ + * + * Charset mapping + */ + +#define MAX_CHARSET_NAME 16 +#define MAX_CHARSET_IN 128 +#define MAX_CHARSET_OUT 4 + +#define CHARSET_FILE_ALIAS 'A' /* Id for binary file */ +#define CHARSET_FILE_TABLE 'T' /* Id for binary file */ + + +typedef struct st_charset_alias { + char alias[MAX_CHARSET_NAME]; /* Alias charset name */ + char name[MAX_CHARSET_NAME]; /* Real charset name */ + struct st_charset_alias *next; +} CharsetAlias; + +typedef struct st_charset_table { + char in[MAX_CHARSET_NAME]; /* Input charset name */ + char out[MAX_CHARSET_NAME]; /* Output charset name */ + char map[MAX_CHARSET_IN][MAX_CHARSET_OUT]; + struct st_charset_table *next; +} CharsetTable; + + +char *getchrs(int); /* Return characterset name */ +char *getchrsdesc(int); /* Return characterset description */ +CharsetTable *charset_table_new(void); /* Add table to linked list */ +CharsetAlias *charset_alias_new(void); /* Add alias to linked list */ +int charset_write_bin(char *); /* Save charset.bin */ +int charset_read_bin(void); /* Load ~/etc/charset.bin */ +char *charset_qpen(int, int); /* Convert to MIME quoted-printable */ +char *charset_map_c(int, int); /* map single character */ +char *charset_alias_fsc(char *); /* Search FSC alias */ +char *charset_alias_rfc(char *); /* Search RFC alias */ +int charset_set_in_out(char *, char *); /* Setup mapping */ + + + /************************************************************************ * * Records data diff --git a/lib/russian.map b/lib/russian.map new file mode 100644 index 00000000..7eeccf1c --- /dev/null +++ b/lib/russian.map @@ -0,0 +1,1111 @@ +# +# $Id$ +# +# Original written by Martin Junius for Fidogate. +# +# Character set mapping table (to be compiled by charsetc) +# + +# +# Russian, contributed by Andy Igoshin +# +alias alt cp866 +alias x-alt cp866 +alias x-cp866 cp866 +alias +7_fido cp866 +alias koi8-u koi8-r +alias ibm-878 koi8-r +alias ibm-915 iso-8859-5 +alias x-cp1251 cp1251 + +# ---------------------------------------------------------------------------- +# Channel map for translation CP866 codes to KOI8-R codes +# (Russian language) +# +table cp866 koi8-r +map \x80 \xE1 +map \x81 \xE2 +map \x82 \xF7 +map \x83 \xE7 +map \x84 \xE4 +map \x85 \xE5 +map \x86 \xF6 +map \x87 \xFA +map \x88 \xE9 +map \x89 \xEA +map \x8A \xEB +map \x8B \xEC +map \x8C \xED +map \x8D \xEE +map \x8E \xEF +map \x8F \xF0 +map \x90 \xF2 +map \x91 \xF3 +map \x92 \xF4 +map \x93 \xF5 +map \x94 \xE6 +map \x95 \xE8 +map \x96 \xE3 +map \x97 \xFE +map \x98 \xFB +map \x99 \xFD +map \x9A \xFF +map \x9B \xF9 +map \x9C \xF8 +map \x9D \xFC +map \x9E \xE0 +map \x9F \xF1 +map \xA0 \xC1 +map \xA1 \xC2 +map \xA2 \xD7 +map \xA3 \xC7 +map \xA4 \xC4 +map \xA5 \xC5 +map \xA6 \xD6 +map \xA7 \xDA +map \xA8 \xC9 +map \xA9 \xCA +map \xAA \xCB +map \xAB \xCC +map \xAC \xCD +map \xAD \xCE +map \xAE \xCF +map \xAF \xD0 +map \xB0 \x90 +map \xB1 \x91 +map \xB2 \x92 +map \xB3 \x81 +map \xB4 \x87 +map \xB5 \xB2 +map \xB6 \xB4 +map \xB7 \xA7 +map \xB8 \xA6 +map \xB9 \xB5 +map \xBA \xA1 +map \xBB \xA8 +map \xBC \xAE +map \xBD \xAD +map \xBE \xAC +map \xBF \x83 +map \xC0 \x84 +map \xC1 \x89 +map \xC2 \x88 +map \xC3 \x86 +map \xC4 \x80 +map \xC5 \x8A +map \xC6 \xAF +map \xC7 \xB0 +map \xC8 \xAB +map \xC9 \xA5 +map \xCA \xBB +map \xCB \xB8 +map \xCC \xB1 +map \xCD \xA0 +map \xCE \xBE +map \xCF \xB9 +map \xD0 \xBA +map \xD1 \xB6 +map \xD2 \xB7 +map \xD3 \xAA +map \xD4 \xA9 +map \xD5 \xA2 +map \xD6 \xA4 +map \xD7 \xBD +map \xD8 \xBC +map \xD9 \x85 +map \xDA \x82 +map \xDB \x8D +map \xDC \x8C +map \xDD \x8E +map \xDE \x8F +map \xDF \x8B +map \xE0 \xD2 +map \xE1 \xD3 +map \xE2 \xD4 +map \xE3 \xD5 +map \xE4 \xC6 +map \xE5 \xC8 +map \xE6 \xC3 +map \xE7 \xDE +map \xE8 \xDB +map \xE9 \xDD +map \xEA \xDF +map \xEB \xD9 +map \xEC \xD8 +map \xED \xDC +map \xEE \xC0 +map \xEF \xD1 +map \xF0 \xB3 +map \xF1 \xA3 +map \xF2 \x20 +map \xF3 \x20 +map \xF4 \x20 +map \xF5 \x20 +map \xF6 \x20 +map \xF7 \x20 +map \xF8 \x9C +map \xF9 \x95 +map \xFA \x9E +map \xFB \x96 +map \xFC \x20 +map \xFD \x20 +map \xFE \x94 +map \xFF \x9A + + +# ---------------------------------------------------------------------------- +# Channel map for translation KOI8-R codes to CP866 codes +# (Russian language) +# Due to fidonet wieredness, capital Russian EN translates to +# latin 'H'. +# +table koi8-r cp866 +map \x80 \xC4 +map \x81 \xB3 +map \x82 \xDA +map \x83 \xBF +map \x84 \xC0 +map \x85 \xD9 +map \x86 \xC3 +map \x87 \xB4 +map \x88 \xC2 +map \x89 \xC1 +map \x8A \xC5 +map \x8B \xDF +map \x8C \xDC +map \x8D \xDB +map \x8E \xDD +map \x8F \xDE +map \x90 \xB0 +map \x91 \xB1 +map \x92 \xB2 +map \x93 \x20 +map \x94 \xFE +map \x95 \xF9 +map \x96 \xFB +map \x97 \x20 +map \x98 \x20 +map \x99 \x20 +map \x9A \xFF +map \x9B \x20 +map \x9C \xF8 +map \x9D \x20 +map \x9E \xFA +map \x9F \x20 +map \xA0 \xCD +map \xA1 \xBA +map \xA2 \xD5 +map \xA3 \xF1 +map \xA4 \xD6 +map \xA5 \xC9 +map \xA6 \xB8 +map \xA7 \xB7 +map \xA8 \xBB +map \xA9 \xD4 +map \xAA \xD3 +map \xAB \xC8 +map \xAC \xBE +map \xAD \xBD +map \xAE \xBC +map \xAF \xC6 +map \xB0 \xC7 +map \xB1 \xCC +map \xB2 \xB5 +map \xB3 \xF0 +map \xB4 \xB6 +map \xB5 \xB9 +map \xB6 \xD1 +map \xB7 \xD2 +map \xB8 \xCB +map \xB9 \xCF +map \xBA \xD0 +map \xBB \xCA +map \xBC \xD8 +map \xBD \xD7 +map \xBE \xCE +map \xBF \x20 +map \xC0 \xEE +map \xC1 \xA0 +map \xC2 \xA1 +map \xC3 \xE6 +map \xC4 \xA4 +map \xC5 \xA5 +map \xC6 \xE4 +map \xC7 \xA3 +map \xC8 \xE5 +map \xC9 \xA8 +map \xCA \xA9 +map \xCB \xAA +map \xCC \xAB +map \xCD \xAC +map \xCE \xAD +map \xCF \xAE +map \xD0 \xAF +map \xD1 \xEF +map \xD2 \xE0 +map \xD3 \xE1 +map \xD4 \xE2 +map \xD5 \xE3 +map \xD6 \xA6 +map \xD7 \xA2 +map \xD8 \xEC +map \xD9 \xEB +map \xDA \xA7 +map \xDB \xE8 +map \xDC \xED +map \xDD \xE9 +map \xDE \xE7 +map \xDF \xEA +map \xE0 \x9E +map \xE1 \x80 +map \xE2 \x81 +map \xE3 \x96 +map \xE4 \x84 +map \xE5 \x85 +map \xE6 \x94 +map \xE7 \x83 +map \xE8 \x95 +map \xE9 \x88 +map \xEA \x89 +map \xEB \x8A +map \xEC \x8B +map \xED \x8C +#map \xEE \x8D +map \xEE \x48 +map \xEF \x8E +map \xF0 \x8F +map \xF1 \x9F +map \xF2 \x90 +map \xF3 \x91 +map \xF4 \x92 +map \xF5 \x93 +map \xF6 \x86 +map \xF7 \x82 +map \xF8 \x9C +map \xF9 \x9B +map \xFA \x87 +map \xFB \x98 +map \xFC \x9D +map \xFD \x99 +map \xFE \x97 +map \xFF \x9A + + + +# ---------------------------------------------------------------------------- +# Channel map for translation CP866 codes to ISO-8859-5 codes +# (Russian language) +# +table cp866 iso-8859-5 +map \x80 \xB0 +map \x81 \xB1 +map \x82 \xB2 +map \x83 \xB3 +map \x84 \xB4 +map \x85 \xB5 +map \x86 \xB6 +map \x87 \xB7 +map \x88 \xB8 +map \x89 \xB9 +map \x8A \xBA +map \x8B \xBB +map \x8C \xBC +map \x8D \xBD +map \x8E \xBE +map \x8F \xBF +map \x90 \xC0 +map \x91 \xC1 +map \x92 \xC2 +map \x93 \xC3 +map \x94 \xC4 +map \x95 \xC5 +map \x96 \xC6 +map \x97 \xC7 +map \x98 \xC8 +map \x99 \xC9 +map \x9A \xCA +map \x9B \xCB +map \x9C \xCC +map \x9D \xCD +map \x9E \xCE +map \x9F \xCF +map \xA0 \xD0 +map \xA1 \xD1 +map \xA2 \xD2 +map \xA3 \xD3 +map \xA4 \xD4 +map \xA5 \xD5 +map \xA6 \xD6 +map \xA7 \xD7 +map \xA8 \xD8 +map \xA9 \xD9 +map \xAA \xDA +map \xAB \xDB +map \xAC \xDC +map \xAD \xDD +map \xAE \xDE +map \xAF \xDF +map \xB0 \x20 +map \xB1 \x20 +map \xB2 \x20 +map \xB3 \x20 +map \xB4 \x20 +map \xB5 \x20 +map \xB6 \x20 +map \xB7 \x20 +map \xB8 \x20 +map \xB9 \x20 +map \xBA \x20 +map \xBB \x20 +map \xBC \x20 +map \xBD \x20 +map \xBE \x20 +map \xBF \x20 +map \xC0 \x20 +map \xC1 \x20 +map \xC2 \x20 +map \xC3 \x20 +map \xC4 \x20 +map \xC5 \x20 +map \xC6 \x20 +map \xC7 \x20 +map \xC8 \x20 +map \xC9 \x20 +map \xCA \x20 +map \xCB \x20 +map \xCC \x20 +map \xCD \x20 +map \xCE \x20 +map \xCF \x20 +map \xD0 \x20 +map \xD1 \x20 +map \xD2 \x20 +map \xD3 \x20 +map \xD4 \x20 +map \xD5 \x20 +map \xD6 \x20 +map \xD7 \x20 +map \xD8 \x20 +map \xD9 \x20 +map \xDA \x20 +map \xDB \x20 +map \xDC \x20 +map \xDD \x20 +map \xDE \x20 +map \xDF \x20 +map \xE0 \xE0 +map \xE1 \xE1 +map \xE2 \xE2 +map \xE3 \xE3 +map \xE4 \xE4 +map \xE5 \xE5 +map \xE6 \xE6 +map \xE7 \xE7 +map \xE8 \xE8 +map \xE9 \xE9 +map \xEA \xEA +map \xEB \xEB +map \xEC \xEC +map \xED \xED +map \xEE \xEE +map \xEF \xEF +map \xF0 \xA1 +map \xF1 \xF1 +map \xF2 \xA4 +map \xF3 \xF4 +map \xF4 \xA7 +map \xF5 \xF7 +map \xF6 \xAE +map \xF7 \xFE +map \xF8 \x20 +map \xF9 \x20 +map \xFA \x20 +map \xFB \x20 +map \xFC \xF0 +map \xFD \x20 +map \xFE \x20 +map \xFF \xA0 + + +# ---------------------------------------------------------------------------- +# Channel map for translation ISO-8859-5 codes to CP866 codes +# (Russian language) +# Due to fidonet wieredness, capital Russian EN translates to +# latin 'H'. +# +table iso-8859-5 cp866 +map \x80 \x20 +map \x81 \x20 +map \x82 \x20 +map \x83 \x20 +map \x84 \x20 +map \x85 \x20 +map \x86 \x20 +map \x87 \x20 +map \x88 \x20 +map \x89 \x20 +map \x8A \x20 +map \x8B \x20 +map \x8C \x20 +map \x8D \x20 +map \x8E \x20 +map \x8F \x20 +map \x90 \x20 +map \x91 \x20 +map \x92 \x20 +map \x93 \x20 +map \x94 \x20 +map \x95 \x20 +map \x96 \x20 +map \x97 \x20 +map \x98 \x20 +map \x99 \x20 +map \x9A \x20 +map \x9B \x20 +map \x9C \x20 +map \x9D \x20 +map \x9E \x20 +map \x9F \x20 +map \xA0 \xFF +map \xA1 \xF0 +map \xA2 \x20 +map \xA3 \x20 +map \xA4 \xF2 +map \xA5 \x20 +map \xA6 \x20 +map \xA7 \xF4 +map \xA8 \x20 +map \xA9 \x20 +map \xAA \x20 +map \xAB \x20 +map \xAC \x20 +map \xAD \x20 +map \xAE \xF6 +map \xAF \x20 +map \xB0 \x80 +map \xB1 \x81 +map \xB2 \x82 +map \xB3 \x83 +map \xB4 \x84 +map \xB5 \x85 +map \xB6 \x86 +map \xB7 \x87 +map \xB8 \x88 +map \xB9 \x89 +map \xBA \x8A +map \xBB \x8B +map \xBC \x8C +#map \xBD \x8D +map \xBD \x48 +map \xBE \x8E +map \xBF \x8F +map \xC0 \x90 +map \xC1 \x91 +map \xC2 \x92 +map \xC3 \x93 +map \xC4 \x94 +map \xC5 \x95 +map \xC6 \x96 +map \xC7 \x97 +map \xC8 \x98 +map \xC9 \x99 +map \xCA \x9A +map \xCB \x9B +map \xCC \x9C +map \xCD \x9D +map \xCE \x9E +map \xCF \x9F +map \xD0 \xA0 +map \xD1 \xA1 +map \xD2 \xA2 +map \xD3 \xA3 +map \xD4 \xA4 +map \xD5 \xA5 +map \xD6 \xA6 +map \xD7 \xA7 +map \xD8 \xA8 +map \xD9 \xA9 +map \xDA \xAA +map \xDB \xAB +map \xDC \xAC +map \xDD \xAD +map \xDE \xAE +map \xDF \xAF +map \xE0 \xE0 +map \xE1 \xE1 +map \xE2 \xE2 +map \xE3 \xE3 +map \xE4 \xE4 +map \xE5 \xE5 +map \xE6 \xE6 +map \xE7 \xE7 +map \xE8 \xE8 +map \xE9 \xE9 +map \xEA \xEA +map \xEB \xEB +map \xEC \xEC +map \xED \xED +map \xEE \xEE +map \xEF \xEF +map \xF0 \xFC +map \xF1 \xF1 +map \xF2 \x20 +map \xF3 \x20 +map \xF4 \xF3 +map \xF5 \x20 +map \xF6 \x20 +map \xF7 \xF5 +map \xF8 \x20 +map \xF9 \x20 +map \xFA \x20 +map \xFB \x20 +map \xFC \x20 +map \xFD \x20 +map \xFE \xF7 +map \xFF \x20 + + +# ---------------------------------------------------------------------------- +# Channel map for translation CP866 codes to CP1251 codes +# (Russian language) +# +table cp866 cp1251 +map \x80 \xC0 +map \x81 \xC1 +map \x82 \xC2 +map \x83 \xC3 +map \x84 \xC4 +map \x85 \xC5 +map \x86 \xC6 +map \x87 \xC7 +map \x88 \xC8 +map \x89 \xC9 +map \x8A \xCA +map \x8B \xCB +map \x8C \xCC +map \x8D \xCD +map \x8E \xCE +map \x8F \xCF +map \x90 \xD0 +map \x91 \xD1 +map \x92 \xD2 +map \x93 \xD3 +map \x94 \xD4 +map \x95 \xD5 +map \x96 \xD6 +map \x97 \xD7 +map \x98 \xD8 +map \x99 \xD9 +map \x9A \xDA +map \x9B \xDB +map \x9C \xDC +map \x9D \xDD +map \x9E \xDE +map \x9F \xDF +map \xA0 \xE0 +map \xA1 \xE1 +map \xA2 \xE2 +map \xA3 \xE3 +map \xA4 \xE4 +map \xA5 \xE5 +map \xA6 \xE6 +map \xA7 \xE7 +map \xA8 \xE8 +map \xA9 \xE9 +map \xAA \xEA +map \xAB \xEB +map \xAC \xEC +map \xAD \xED +map \xAE \xEE +map \xAF \xEF +map \xB0 \x20 +map \xB1 \x20 +map \xB2 \x20 +map \xB3 \x20 +map \xB4 \x20 +map \xB5 \x20 +map \xB6 \x20 +map \xB7 \x20 +map \xB8 \x20 +map \xB9 \x20 +map \xBA \x20 +map \xBB \x20 +map \xBC \x20 +map \xBD \x20 +map \xBE \x20 +map \xBF \x20 +map \xC0 \x20 +map \xC1 \x20 +map \xC2 \x20 +map \xC3 \x20 +map \xC4 \x20 +map \xC5 \x20 +map \xC6 \x20 +map \xC7 \x20 +map \xC8 \x20 +map \xC9 \x20 +map \xCA \x20 +map \xCB \x20 +map \xCC \x20 +map \xCD \x20 +map \xCE \x20 +map \xCF \x20 +map \xD0 \x20 +map \xD1 \x20 +map \xD2 \x20 +map \xD3 \x20 +map \xD4 \x20 +map \xD5 \x20 +map \xD6 \x20 +map \xD7 \x20 +map \xD8 \x20 +map \xD9 \x20 +map \xDA \x20 +map \xDB \x20 +map \xDC \x20 +map \xDD \x20 +map \xDE \x20 +map \xDF \x20 +map \xE0 \xF0 +map \xE1 \xF1 +map \xE2 \xF2 +map \xE3 \xF3 +map \xE4 \xF4 +map \xE5 \xF5 +map \xE6 \xF6 +map \xE7 \xF7 +map \xE8 \xF8 +map \xE9 \xF9 +map \xEA \xFA +map \xEB \xFB +map \xEC \xFC +map \xED \xFD +map \xEE \xFE +map \xEF \xFF +map \xF0 \xA8 +map \xF1 \xB8 +map \xF2 \xAA +map \xF3 \xBA +map \xF4 \xAF +map \xF5 \xBF +map \xF6 \xA1 +map \xF7 \xA2 +map \xF8 \xB0 +map \xF9 \x20 +map \xFA \xB7 +map \xFB \x20 +map \xFC \xB9 +map \xFD \xA4 +map \xFE \x20 +map \xFF \xA0 + + +# ---------------------------------------------------------------------------- +# Channel map for translation CP1251 codes to CP866 codes +# (Russian language) +# Due to fidonet wieredness, capital Russian EN translates to +# latin 'H'. +# +table cp1251 cp866 +map \x80 \x20 +map \x81 \x20 +map \x82 \x20 +map \x83 \x20 +map \x84 \x20 +map \x85 \x20 +map \x86 \x20 +map \x87 \x20 +map \x88 \x20 +map \x89 \x20 +map \x8A \x20 +map \x8B \x20 +map \x8C \x20 +map \x8D \x20 +map \x8E \x20 +map \x8F \x20 +map \x90 \x20 +map \x91 \x20 +map \x92 \x20 +map \x93 \x20 +map \x94 \x20 +map \x95 \x20 +map \x96 \x20 +map \x97 \x20 +map \x98 \x20 +map \x99 \x20 +map \x9A \x20 +map \x9B \x20 +map \x9C \x20 +map \x9D \x20 +map \x9E \x20 +map \x9F \x20 +map \xA0 \xFF +map \xA1 \xF6 +map \xA2 \xF7 +map \xA3 \x20 +map \xA4 \xFD +map \xA5 \x20 +map \xA6 \x20 +map \xA7 \x20 +map \xA8 \xF0 +map \xA9 \x20 +map \xAA \xF2 +map \xAB \x20 +map \xAC \x20 +map \xAD \x20 +map \xAE \x20 +map \xAF \xF4 +map \xB0 \xF8 +map \xB1 \x20 +map \xB2 \x20 +map \xB3 \x20 +map \xB4 \x20 +map \xB5 \x20 +map \xB6 \x20 +map \xB7 \xFA +map \xB8 \xF1 +map \xB9 \xFC +map \xBA \xF3 +map \xBB \x20 +map \xBC \x20 +map \xBD \x20 +map \xBE \x20 +map \xBF \xF5 +map \xC0 \x80 +map \xC1 \x81 +map \xC2 \x82 +map \xC3 \x83 +map \xC4 \x84 +map \xC5 \x85 +map \xC6 \x86 +map \xC7 \x87 +map \xC8 \x88 +map \xC9 \x89 +map \xCA \x8A +map \xCB \x8B +map \xCC \x8C +#map \xCD \x8D +map \xCD \x48 +map \xCE \x8E +map \xCF \x8F +map \xD0 \x90 +map \xD1 \x91 +map \xD2 \x92 +map \xD3 \x93 +map \xD4 \x94 +map \xD5 \x95 +map \xD6 \x96 +map \xD7 \x97 +map \xD8 \x98 +map \xD9 \x99 +map \xDA \x9A +map \xDB \x9B +map \xDC \x9C +map \xDD \x9D +map \xDE \x9E +map \xDF \x9F +map \xE0 \xA0 +map \xE1 \xA1 +map \xE2 \xA2 +map \xE3 \xA3 +map \xE4 \xA4 +map \xE5 \xA5 +map \xE6 \xA6 +map \xE7 \xA7 +map \xE8 \xA8 +map \xE9 \xA9 +map \xEA \xAA +map \xEB \xAB +map \xEC \xAC +map \xED \xAD +map \xEE \xAE +map \xEF \xAF +map \xF0 \xE0 +map \xF1 \xE1 +map \xF2 \xE2 +map \xF3 \xE3 +map \xF4 \xE4 +map \xF5 \xE5 +map \xF6 \xE6 +map \xF7 \xE7 +map \xF8 \xE8 +map \xF9 \xE9 +map \xFA \xEA +map \xFB \xEB +map \xFC \xEC +map \xFD \xED +map \xFE \xEE +map \xFF \xEF + + +# ---------------------------------------------------------------------------- +# Channel map for translation CP866 codes to MAC codes +# (Russian language) +# +table cp866 x-mac +map \x80 \x80 +map \x81 \x81 +map \x82 \x82 +map \x83 \x83 +map \x84 \x84 +map \x85 \x85 +map \x86 \x86 +map \x87 \x87 +map \x88 \x88 +map \x89 \x89 +map \x8A \x8A +map \x8B \x8B +map \x8C \x8C +map \x8D \x8D +map \x8E \x8E +map \x8F \x8F +map \x90 \x90 +map \x91 \x91 +map \x92 \x92 +map \x93 \x93 +map \x94 \x94 +map \x95 \x95 +map \x96 \x96 +map \x97 \x97 +map \x98 \x98 +map \x99 \x99 +map \x9A \x9A +map \x9B \x9B +map \x9C \x9C +map \x9D \x9D +map \x9E \x9E +map \x9F \x9F +map \xA0 \xE0 +map \xA1 \xE1 +map \xA2 \xE2 +map \xA3 \xE3 +map \xA4 \xE4 +map \xA5 \xE5 +map \xA6 \xE6 +map \xA7 \xE7 +map \xA8 \xE8 +map \xA9 \xE9 +map \xAA \xEA +map \xAB \xEB +map \xAC \xEC +map \xAD \xED +map \xAE \xEE +map \xAF \xEF +map \xB0 \x20 +map \xB1 \x20 +map \xB2 \x20 +map \xB3 \x20 +map \xB4 \x20 +map \xB5 \x20 +map \xB6 \x20 +map \xB7 \x20 +map \xB8 \x20 +map \xB9 \x20 +map \xBA \x20 +map \xBB \x20 +map \xBC \x20 +map \xBD \x20 +map \xBE \x20 +map \xBF \x20 +map \xC0 \x20 +map \xC1 \x20 +map \xC2 \x20 +map \xC3 \x20 +map \xC4 \x20 +map \xC5 \x20 +map \xC6 \x20 +map \xC7 \x20 +map \xC8 \x20 +map \xC9 \x20 +map \xCA \x20 +map \xCB \x20 +map \xCC \x20 +map \xCD \x20 +map \xCE \x20 +map \xCF \x20 +map \xD0 \x20 +map \xD1 \x20 +map \xD2 \x20 +map \xD3 \x20 +map \xD4 \x20 +map \xD5 \x20 +map \xD6 \x20 +map \xD7 \x20 +map \xD8 \x20 +map \xD9 \x20 +map \xDA \x20 +map \xDB \x20 +map \xDC \x20 +map \xDD \x20 +map \xDE \x20 +map \xDF \x20 +map \xE0 \xF0 +map \xE1 \xF1 +map \xE2 \xF2 +map \xE3 \xF3 +map \xE4 \xF4 +map \xE5 \xF5 +map \xE6 \xF6 +map \xE7 \xF7 +map \xE8 \xF8 +map \xE9 \xF9 +map \xEA \xFA +map \xEB \xFB +map \xEC \xFC +map \xED \xFD +map \xEE \xFE +map \xEF \xDF +map \xF0 \xDD +map \xF1 \xDE +map \xF2 \xB8 +map \xF3 \xB9 +map \xF4 \xBA +map \xF5 \xBB +map \xF6 \xD8 +map \xF7 \xD9 +map \xF8 \xA1 +map \xF9 \x20 +map \xFA \x20 +map \xFB \xC3 +map \xFC \xDC +map \xFD \xFF +map \xFE \x20 +map \xFF \xCA + + +# ---------------------------------------------------------------------------- +# Channel map for translation MAC codes to CP866 codes +# (Russian language) +# Due to fidonet wieredness, capital Russian EN translates to +# latin 'H'. +# +table x-mac cp866 +map \x80 \x80 +map \x81 \x81 +map \x82 \x82 +map \x83 \x83 +map \x84 \x84 +map \x85 \x85 +map \x86 \x86 +map \x87 \x87 +map \x88 \x88 +map \x89 \x89 +map \x8A \x8A +map \x8B \x8B +map \x8C \x8C +#map \x8D \x8D +map \x8D \x48 +map \x8E \x8E +map \x8F \x8F +map \x90 \x90 +map \x91 \x91 +map \x92 \x92 +map \x93 \x93 +map \x94 \x94 +map \x95 \x95 +map \x96 \x96 +map \x97 \x97 +map \x98 \x98 +map \x99 \x99 +map \x9A \x9A +map \x9B \x9B +map \x9C \x9C +map \x9D \x9D +map \x9E \x9E +map \x9F \x9F +map \xA0 \x20 +map \xA1 \xF8 +map \xA2 \x20 +map \xA3 \x20 +map \xA4 \x20 +map \xA5 \x20 +map \xA6 \x20 +map \xA7 \x20 +map \xA8 \x20 +map \xA9 \x20 +map \xAA \x20 +map \xAB \x20 +map \xAC \x20 +map \xAD \x20 +map \xAE \x20 +map \xAF \x20 +map \xB0 \x20 +map \xB1 \x20 +map \xB2 \x20 +map \xB3 \x20 +map \xB4 \x20 +map \xB5 \x20 +map \xB6 \x20 +map \xB7 \x20 +map \xB8 \xF2 +map \xB9 \xF3 +map \xBA \xF4 +map \xBB \xF5 +map \xBC \x20 +map \xBD \x20 +map \xBE \x20 +map \xBF \x20 +map \xC0 \x20 +map \xC1 \x20 +map \xC2 \x20 +map \xC3 \xFB +map \xC4 \x20 +map \xC5 \x20 +map \xC6 \x20 +map \xC7 \x20 +map \xC8 \x20 +map \xC9 \x20 +map \xCA \xFF +map \xCB \x20 +map \xCC \x20 +map \xCD \x20 +map \xCE \x20 +map \xCF \x20 +map \xD0 \x20 +map \xD1 \x20 +map \xD2 \x20 +map \xD3 \x20 +map \xD4 \x20 +map \xD5 \x20 +map \xD6 \x20 +map \xD7 \x20 +map \xD8 \xF6 +map \xD9 \xF7 +map \xDA \x20 +map \xDB \x20 +map \xDC \xFC +map \xDD \xF0 +map \xDE \xF1 +map \xDF \xEF +map \xE0 \xA0 +map \xE1 \xA1 +map \xE2 \xA2 +map \xE3 \xA3 +map \xE4 \xA4 +map \xE5 \xA5 +map \xE6 \xA6 +map \xE7 \xA7 +map \xE8 \xA8 +map \xE9 \xA9 +map \xEA \xAA +map \xEB \xAB +map \xEC \xAC +map \xED \xAD +map \xEE \xAE +map \xEF \xAF +map \xF0 \xE0 +map \xF1 \xE1 +map \xF2 \xE2 +map \xF3 \xE3 +map \xF4 \xE4 +map \xF5 \xE5 +map \xF6 \xE6 +map \xF7 \xE7 +map \xF8 \xE8 +map \xF9 \xE9 +map \xFA \xEA +map \xFB \xEB +map \xFC \xEC +map \xFD \xED +map \xFE \xEE +map \xFF \xFD diff --git a/mbsebbs/mail.c b/mbsebbs/mail.c index 554dfb0b..65ed2e3f 100644 --- a/mbsebbs/mail.c +++ b/mbsebbs/mail.c @@ -1137,14 +1137,8 @@ int Export_a_Msg(unsigned long Num) int Read_a_Msg(unsigned long Num, int UpdateLR) { char *p = NULL, *fn, *charset = NULL, *charsin = NULL, *charsout = NULL; - int ShowMsg = TRUE, UseIconv = FALSE; + int i, ShowMsg = TRUE, UseIconv = FALSE; lastread LR; - iconv_t iconvstr = (iconv_t)(0); -#ifdef HAVE_ICONV_H - size_t cnt, inleft, outleft; - char inbuf[256], outbuf[1024]; - char *inb, *outb; -#endif LastNum = Num; iLineCount = 7; @@ -1234,25 +1228,16 @@ int Read_a_Msg(unsigned long Num, int UpdateLR) */ charset = xstrcpy(getchrs(msgs.Charset)); } - charsin = xstrcpy(get_iconv_name(charset)); - charsout = xstrcpy(get_iconv_name(getchrs(exitinfo.Charset))); + charsin = xstrcpy(charset); + charsout = xstrcpy(getchrs(exitinfo.Charset)); Syslog('b', "Stage 3: charset %s, translate %s to %s", MBSE_SS(charset), MBSE_SS(charsin), MBSE_SS(charsout)); -#ifdef HAVE_ICONV_H /* - * Try to setup iconv if the charactersets are different. + * Try to setup charset mapping if the charactersets are different. */ if (charsin && charsout && strcmp(charsout, charsin)) { - - charsout = xstrcat(charsout, (char *)"//TRANSLIT"); - iconvstr = iconv_open(charsout, charsin); - if (iconvstr == (iconv_t)(-1)) { - Syslog('!', "$open_iconv(%s, %s)", charsin, charsout); - } else { - UseIconv = TRUE; - } + UseIconv = charset_set_in_out(charsin, charsout); } -#endif /* * Show message text @@ -1273,42 +1258,18 @@ int Read_a_Msg(unsigned long Num, int UpdateLR) if (strchr(p, '>') != NULL) if ((strlen(p) - strlen(strchr(p, '>'))) < 10) colour(CFG.HiliteF, CFG.HiliteB); -#ifdef HAVE_ICONV_H if (UseIconv) { /* - * Try to translate character sets with iconv + * Try to translate character sets */ - inleft = outleft = strlen(p); - memset(&inbuf, 0, sizeof(inbuf)); - memset(&outbuf, 0, sizeof(inbuf)); - sprintf(inbuf, "%s", p); - inb = inbuf; - outb = outbuf; - cnt = iconv(iconvstr, &inb, &inleft, &outb, &outleft); - if (cnt == (size_t)(-1)) { - /* - * Failed, log and show original line. - */ - Syslog('b', "iconv cnt=%d inleft=%d outleft=%d", cnt, inleft, outleft); - Syslog('b', "%s", printable(p, 0)); - Syslog('b', "$iconv"); - printf("%s\n", p); - } else { - if (strcmp(inbuf, outbuf)) { - /* - * Success, translated and log - */ - Syslog('b', "< %s", MBSE_SS(inbuf)); - Syslog('b', "> %s", MBSE_SS(outbuf)); - } - printf("%s\n", outbuf); + for (i = 0; i < strlen(p); i++) { + printf("%s", charset_map_c(p[i], FALSE)); } + printf("\n"); } else { printf("%s\n", p); } -#else - printf("%s\n", p); -#endif + if (CheckLine(CFG.TextColourF, CFG.TextColourB, FALSE)) break; } @@ -1323,12 +1284,6 @@ int Read_a_Msg(unsigned long Num, int UpdateLR) if (charsin) free(charsin); -#ifdef HAVE_ICONV_H - if (UseIconv && (iconv_close(iconvstr) == -1)) { - Syslog('!', "$iconv_close()"); - } -#endif - /* * Set the Received status on this message if it's for the user. */