From 4628994acabec7ed1a94cb0ec24cbd353c92f32c Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 26 Feb 2007 19:22:02 +0000 Subject: [PATCH] Added find rfc charset function --- lib/charset.c | 28 +++++++++++++++++++++++++++- lib/mbselib.h | 1 + 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/charset.c b/lib/charset.c index ff9b7904..ef9e231f 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -77,7 +77,7 @@ struct _charalias charalias[] = { 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_CP437, (char *)"CP437 2", (char *)"iso-8859-1", (char *)"CP437", (char *)"ISO-8859-1", (char *)"en_US", (char *)"IBM codepage 437 (Western European) (ANSI terminal)"}, + {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)"}, @@ -158,6 +158,32 @@ int find_ftn_charset(char *ftnkludge) +/* + * Returns index of charset or -1 if not found. + */ +int find_rfc_charset(char *rfcname) +{ + static int i; + int j; + + Syslog(loglevel, "find_rfc_charset(%s)", rfcname); + + for (i = 0; charmap[i].rfcname; i++) { + if (strcasecmp(rfcname, charmap[i].rfcname) == 0) + break; + } + + if (charmap[i].rfcname == NULL) { + WriteError("find_rfc_charset(%s) not found", rfcname); + return FTNC_ERROR; + } + + Syslog(loglevel, "find_rfc_charset(%s) result %d", rfcname, i); + return i; +} + + + char *getftnchrs(int val) { int i; diff --git a/lib/mbselib.h b/lib/mbselib.h index e3a1833e..6f7653bc 100644 --- a/lib/mbselib.h +++ b/lib/mbselib.h @@ -2600,6 +2600,7 @@ int create_tmpwork(void); /* Create tmp workdir */ * Charset mapping */ int find_ftn_charset(char *); /* Return FTN charset index */ +int fine_rfc_charset(char *); /* Return RFC charset index */ char *getftnchrs(int); /* Return FTN characterset name */ char *getrfcchrs(int); /* Return RFC characterset name */ char *getlocale(int); /* Return locale name */