Removed charset translation code

This commit is contained in:
Michiel Broek 2003-01-30 21:23:57 +00:00
parent 8c5034f00f
commit d95fc43626
21 changed files with 719 additions and 3941 deletions

View File

@ -5,23 +5,20 @@ v0.37.01 14-Jan-2003.
general:
This version may be used on production systems, but be
carefull and check your logs. Before I make any changes that
make it more difficult to downgrade I will wait a few days.
Things to watch out for:
Messages in the logs about too many open files.
Systems not being called or called with wrong protols.
Let me know if something goes wrong.
Make sure you have a copy of the previous sources available
if you need to downgrade.
carefull and check your logs.
Spanish templates and macros added to the examples.
In several messages handling functions the international
charset translations are removed because of several bugs. They
will be replaced by standard library functions. Right now the
messages are 8 bit clean and there is no translation on the
gateway.
nodelist.a:
Added experimental support for IP nodes lookup using a default
domain method. This is not the final implementation yet!
common.a:
Remove a bug which very seldom crashed mbfido with charset
translation. Do we really need charset conversion?
Removed charset conversion/translation.
mbtask:
Arcmail for non-CM nodes and Txx nodes is now sent during the
@ -37,6 +34,9 @@ v0.37.01 14-Jan-2003.
In the import function several bugfixes for reading files.bbs.
Fixed upper/lowercase filenames bug with import.
mbfido:
Removed all code for charset translation.
v0.37.00 26-Dec-2002 - 14-Jan-2003

6
TODO
View File

@ -165,6 +165,12 @@ mbsetup:
N: Add switch for file area to skip checking and indexing.
N: Add menu switches in nodes/groups to select/deselect all groups
at once.
N: Add global setup in menus 9.1 and 10.1 at least to change uplink
data.
L: Generate crossreference document:
File Areas <=> BBS groups
File Areas <=> Newfiles groups

View File

@ -7,16 +7,16 @@ include ../Makefile.global
CLCOMM_SRCS = clcomm.c client.c crc.c semafore.c signame.c
CLCOMM_OBJS = clcomm.o client.o crc.o semafore.o signame.o
CLCOMM_HDRS = clcomm.h
COMMON_SRCS = attach.c charconv_utf.c falists.c hdr.c parsedate.c rfcmsg.c unpacker.c \
COMMON_SRCS = attach.c falists.c hdr.c parsedate.c rfcmsg.c unpacker.c \
batchrd.c charset.c ftn.c pktname.c mangle.c sectest.c \
charconv.c dostran.c ftnmsg.c mbfile.c nodelock.c rawio.c strcasestr.c \
charconv_hz.c execute.c expipe.c getheader.c mime.c noderecord.c rfcaddr.c strutil.c \
charconv_jp.c faddr.c gmtoffset.c packet.c rfcdate.c term.c
COMMON_OBJS = ftscprod.o attach.o charconv_utf.o falists.o hdr.o parsedate.o rfcmsg.o unpacker.o \
batchrd.o charset.o ftn.o pktname.o mangle.o sectest.o \
charconv.o dostran.o ftnmsg.o mbfile.o nodelock.o rawio.o strcasestr.o \
charconv_hz.o execute.o expipe.o getheader.o mime.o noderecord.o rfcaddr.o strutil.o \
charconv_jp.o faddr.o gmtoffset.o packet.o rfcdate.o term.o
dostran.c ftnmsg.c mbfile.c nodelock.c rawio.c strcasestr.c \
execute.c expipe.c getheader.c noderecord.c rfcaddr.c strutil.c \
faddr.c gmtoffset.c packet.c rfcdate.c term.c
COMMON_OBJS = ftscprod.o attach.o falists.o hdr.o parsedate.o rfcmsg.o unpacker.o \
batchrd.o ftn.o pktname.o mangle.o sectest.o \
dostran.o ftnmsg.o mbfile.o nodelock.o rawio.o strcasestr.o \
execute.o expipe.o getheader.o noderecord.o rfcaddr.o strutil.o \
faddr.o gmtoffset.o packet.o rfcdate.o term.o
COMMON_HDRS = common.h
NODELIST_SRCS = nodelist.c
NODELIST_OBJS = nodelist.o
@ -130,34 +130,29 @@ crc.o: ../config.h libs.h memwatch.h clcomm.h
semafore.o: ../config.h libs.h memwatch.h structs.h clcomm.h common.h
signame.o: ../config.h libs.h memwatch.h clcomm.h
attach.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h common.h
charconv_utf.o: ../config.h libs.h memwatch.h structs.h common.h
falists.o: ../config.h libs.h memwatch.h structs.h clcomm.h common.h
hdr.o: ../config.h libs.h memwatch.h structs.h common.h
parsedate.o: ../config.h libs.h memwatch.h structs.h common.h
rfcmsg.o: ../config.h libs.h memwatch.h structs.h users.h records.h common.h clcomm.h
unpacker.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h common.h
batchrd.o: ../config.h libs.h memwatch.h structs.h clcomm.h common.h
charset.o: ../config.h libs.h memwatch.h structs.h common.h clcomm.h
charset.o:
ftn.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h dbftn.h common.h
pktname.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h common.h
mangle.o: ../config.h libs.h memwatch.h structs.h clcomm.h common.h
sectest.o: ../config.h libs.h structs.h common.h clcomm.h
charconv.o: ../config.h libs.h memwatch.h structs.h users.h records.h common.h clcomm.h
dostran.o: ../config.h libs.h memwatch.h structs.h users.h records.h common.h
ftnmsg.o: ../config.h libs.h memwatch.h structs.h common.h clcomm.h
mbfile.o: ../config.h libs.h memwatch.h structs.h clcomm.h common.h
nodelock.o: ../config.h libs.h memwatch.h structs.h clcomm.h common.h
rawio.o: ../config.h libs.h memwatch.h structs.h common.h mberrors.h
strcasestr.o: ../config.h libs.h memwatch.h
charconv_hz.o: ../config.h libs.h memwatch.h structs.h common.h clcomm.h
execute.o: ../config.h libs.h memwatch.h structs.h clcomm.h mberrors.h common.h
expipe.o: ../config.h libs.h memwatch.h structs.h clcomm.h mberrors.h common.h
getheader.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h common.h
mime.o: ../config.h libs.h memwatch.h structs.h clcomm.h common.h
noderecord.o: ../config.h libs.h memwatch.h structs.h common.h users.h records.h dbnode.h common.h
rfcaddr.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h common.h
strutil.o: ../config.h libs.h memwatch.h structs.h common.h
charconv_jp.o: ../config.h libs.h memwatch.h structs.h common.h
faddr.o: ../config.h libs.h memwatch.h structs.h common.h
gmtoffset.o: ../config.h libs.h memwatch.h structs.h common.h
packet.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h common.h dbnode.h

View File

@ -1,712 +0,0 @@
/*****************************************************************************
*
* $Id$
* Purpose ...............: Common utilities - character set conversion
*
*****************************************************************************
* Copyright (C) 1997-2002
*
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../config.h"
#include "libs.h"
#include "memwatch.h"
#include "structs.h"
#include "users.h"
#include "records.h"
#include "common.h"
#include "clcomm.h"
#ifndef BUFSIZ
#define BUFSIZ 512
#endif
char *oldfilemap=NULL;
char maptab[] = {
"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"
"\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
"\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057"
"\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077"
"\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117"
"\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137"
"\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157"
"\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177"
"\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217"
"\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237"
"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257"
"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277"
"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"
"\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"
"\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357"
"\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377"
};
static int ctoi(char *);
static int ctoi(char *s)
{
int i;
if (!strncmp(s,"0x",2))
sscanf(s+2,"%x",&i);
else if (*s == '0')
sscanf(s,"%o",&i);
else if (strspn(s,"0123456789") == strlen(s))
sscanf(s,"%d",&i);
else
i=0;
return i;
}
static int getmaptab(char *);
static int getmaptab(char *maptab_name)
{
FILE *fp;
char buf[BUFSIZ], *p, *q;
int in, on;
if ((fp = fopen(maptab_name, "r")) == NULL) {
WriteError("$can't open mapchan file \"%s\" ", maptab_name);
return 0;
}
while (fgets(buf, sizeof(buf)-1, fp)) {
p = strtok(buf," \t\n#");
q = strtok(NULL," \t\n#");
if (p && q) {
in = ctoi(p);
on = ctoi(q);
if (in && on)
maptab[in] = on;
}
}
fclose(fp);
return 0;
}
char *strnkconv(const char *src, int incode, int outcode, int n)
{
char ki[10], ko[10];
int kolen;
static char *dest;
int destlen;
int i;
outcode = getkcode(outcode, ki, ko);
kolen = strlen(ko);
dest = strkconv(src, incode, outcode);
destlen = strlen(dest);
if(destlen >= kolen && destlen > strlen(src)) {
for(i = 0; i < kolen; i++)
*(dest + n - 1 + i) = ko[i];
*(dest + n) = '\0';
}
return dest;
}
char *strkconv(const char *src, int incode, int outcode)
{
static char *dest;
int bytes = 1;
if ((incode==outcode) && (incode!=CHRS_NOTSET) && (incode!=CHRS_AUTODETECT))
return (char *)src;
if (!src)
return NULL;
if((incode == CHRS_AUTODETECT) || (incode == CHRS_NOTSET)) {
if (LANG_BITS == 16) {
bytes = 2;
incode = iso2022_detectcode((char *)src,incode);
}
}
if(dest)
free(dest);
dest = (char *)malloc((strlen(src) + 1) + ((6 * bytes) + 1));
kconv((char *)src, &dest, incode, outcode);
return dest;
}
void kconv(char *in, char **out, int incode, int outcode)
{
char ki[10], ko[10];
outcode = getkcode(outcode, ki, ko);
if (incode == outcode)
noconv(in,out);
else {
switch (incode) {
case CHRS_NOTSET : noconv(in,out);
break;
case CHRS_ASCII : noconv(in,out);
break;
case CHRS_BIG5 :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_CP424 :
switch (outcode) {
case CHRS_CP862 : eight2eight(in,out,(char *)CP424__CP862); break;
case CHRS_ISO_8859_8 : eight2eight(in,out,(char *)CP424__ISO_8859_8); break;
default : noconv(in,out); break;
}
break;
case CHRS_CP437 :
switch (outcode) {
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15: eight2eight(in,out,(char *)CP437__ISO_8859_1); break;
case CHRS_MACINTOSH : eight2eight(in,out,(char *)CP437__MACINTOSH); break;
default : noconv(in,out); break;
}
break;
case CHRS_CP850 :
switch (outcode) {
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15: eight2eight(in,out,(char *)CP850__ISO_8859_1); break;
case CHRS_MACINTOSH : eight2eight(in,out,(char *)CP850__MACINTOSH); break;
default : noconv(in,out); break;
}
break;
case CHRS_CP852 :
switch (outcode) {
case CHRS_FIDOMAZOVIA : eight2eight(in,out,(char *)CP852__FIDOMAZOVIA); break;
case CHRS_ISO_8859_2 : eight2eight(in,out,(char *)CP852__ISO_8859_2); break;
default : noconv(in,out); break;
}
break;
case CHRS_CP862 :
switch (outcode) {
case CHRS_CP424 : eight2eight(in,out,(char *)CP862__CP424); break;
case CHRS_ISO_8859_8 : eight2eight(in,out,(char *)CP862__ISO_8859_8); break;
default : noconv(in,out); break;
}
break;
case CHRS_CP866 :
switch (outcode) {
case CHRS_ISO_8859_5 : eight2eight(in,out,(char *)CP866__ISO_8859_5); break;
case CHRS_KOI8_R :
case CHRS_KOI8_U : eight2eight(in,out,(char *)CP866__KOI8); break;
default : noconv(in,out); break;
}
break;
case CHRS_CP895 :
switch (outcode) {
case CHRS_ISO_8859_2 : eight2eight(in,out,(char *)CP895__ISO_8859_2); break;
case CHRS_CP437 : eight2eight(in,out,(char *)CP895__CP437); break;
default : noconv(in,out); break;
}
break;
case CHRS_EUC_JP :
switch (outcode) {
case CHRS_EUC_JP : euc2euc(in,out,incode,0); break;
case CHRS_ISO_2022_JP : euc2seven(in,out,incode,ki,ko); break;
case CHRS_NEC : euc2seven(in,out,incode,ki,ko); break;
case CHRS_SJIS : euc2shift(in,out,incode,0); break;
default : noconv(in,out); break;
}
break;
case CHRS_EUC_KR :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_FIDOMAZOVIA :
switch (outcode) {
case CHRS_CP852 : eight2eight(in,out,(char *)FIDOMAZOVIA__CP852); break;
case CHRS_ISO_8859_2 : eight2eight(in,out,(char *)FIDOMAZOVIA__ISO_8859_2); break;
default : noconv(in,out); break;
}
break;
case CHRS_GB :
switch (outcode) {
case CHRS_HZ : gb2hz(in,out); break;
default : noconv(in,out); break;
}
case CHRS_HZ :
switch (outcode) {
case CHRS_GB : hz2gb(in,out); break;
default : noconv(in,out); break;
}
case CHRS_ISO_11 :
switch (outcode) {
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15: eight2eight(in,out,(char *)ISO_11__ISO_8859_1); break;
default : noconv(in,out); break;
}
break;
case CHRS_ISO_4 :
switch (outcode) {
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15: eight2eight(in,out,(char *)ISO_4__ISO_8859_1); break;
default : noconv(in,out); break;
}
break;
case CHRS_ISO_60 :
switch (outcode) {
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15: eight2eight(in,out,(char *)ISO_60__ISO_8859_1); break;
default : noconv(in,out); break;
}
break;
case CHRS_ISO_2022_CN :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_2022_JP :
switch (outcode) {
case CHRS_EUC_JP : seven2euc(in,out); break;
case CHRS_ISO_2022_JP : seven2seven(in,out,ki,ko); break;
case CHRS_NEC : seven2seven(in,out,ki,ko); break;
case CHRS_SJIS : seven2shift(in,out); break;
default : noconv(in,out); break;
}
break;
case CHRS_ISO_2022_KR :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_2022_TW :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15:
switch (outcode) {
case CHRS_CP437 : eight2eight(in,out,(char *)ISO_8859_1__CP437); break;
case CHRS_CP850 : eight2eight(in,out,(char *)ISO_8859_1__CP850); break;
case CHRS_MACINTOSH : eight2eight(in,out,(char *)ISO_8859_1__MACINTOSH); break;
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15: noconv(in,out); break;
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_2 :
switch (outcode) {
case CHRS_CP852 : eight2eight(in,out,(char *)ISO_8859_2__CP852); break;
case CHRS_CP895 : eight2eight(in,out,(char *)ISO_8859_2__CP895); break;
case CHRS_FIDOMAZOVIA : eight2eight(in,out,(char *)ISO_8859_2__FIDOMAZOVIA); break;
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_3 :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_4 :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_5 :
switch (outcode) {
case CHRS_CP866 : eight2eight(in,out,(char *)ISO_8859_5__CP866); break;
case CHRS_KOI8_R :
case CHRS_KOI8_U : eight2eight(in,out,(char *)ISO_8859_5__KOI8); break;
case CHRS_MIK_CYR : eight2eight(in,out,(char *)ISO_8859_5__MIK_CYR); break;
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_6 :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_7 :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_8 :
switch (outcode) {
case CHRS_CP424 : eight2eight(in,out,(char *)ISO_8859_8__CP424); break;
case CHRS_CP862 : eight2eight(in,out,(char *)ISO_8859_8__CP862); break;
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_9 :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_10 :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_ISO_8859_11 :
switch (outcode) {
default : noconv(in,out); break;
}
break;
case CHRS_KOI8_R :
case CHRS_KOI8_U :
switch (outcode) {
case CHRS_CP866 : eight2eight(in,out,(char *)KOI8__CP866); break;
case CHRS_ISO_8859_5 : eight2eight(in,out,(char *)KOI8__ISO_8859_5); break;
case CHRS_MIK_CYR : eight2eight(in,out,(char *)KOI8__MIK_CYR); break;
default : noconv(in,out); break;
}
break;
case CHRS_MACINTOSH :
switch (outcode) {
case CHRS_CP437 : eight2eight(in,out,(char *)MACINTOSH__CP437); break;
case CHRS_CP850 : eight2eight(in,out,(char *)MACINTOSH__CP850); break;
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15: eight2eight(in,out,(char *)MACINTOSH__ISO_8859_1); break;
default : noconv(in,out); break;
}
break;
case CHRS_MIK_CYR :
switch (outcode) {
case CHRS_ISO_8859_5 : eight2eight(in,out,(char *)MIK_CYR__ISO_8859_5); break;
case CHRS_KOI8_R :
case CHRS_KOI8_U : eight2eight(in,out,(char *)MIK_CYR__KOI8); break;
default : noconv(in,out); break;
}
break;
case CHRS_NEC :
switch (outcode) {
case CHRS_EUC_JP : seven2euc(in,out); break;
case CHRS_ISO_2022_JP : seven2seven(in,out,ki,ko); break;
case CHRS_NEC : seven2seven(in,out,ki,ko); break;
case CHRS_SJIS : seven2shift(in,out); break;
default : noconv(in,out); break;
}
break;
case CHRS_SJIS :
switch (outcode) {
case CHRS_EUC_JP : shift2euc(in,out,incode,0); break;
case CHRS_ISO_2022_JP : shift2seven(in,out,incode,ki,ko); break;
case CHRS_NEC : shift2seven(in,out,incode,ki,ko); break;
case CHRS_SJIS : shift2shift(in,out,incode,0); break;
default : noconv(in,out); break;
}
break;
case CHRS_UTF_7 :
utf7_to_eight(in,out,&outcode);
break;
case CHRS_UTF_8 :
utf8_to_eight(in,out,&outcode);
break;
case CHRS_ZW :
switch (outcode) {
case CHRS_HZ : zw2hz(in,out); break;
case CHRS_GB : zw2gb(in,out); break;
default : noconv(in,out); break;
}
break;
default : noconv(in,out); break;
}
}
}
int getkcode(int code,char ki[],char ko[])
{
if (code == CHRS_ISO_2022_CN) {
strcpy(ki,"$A");
strcpy(ko,"(T");
} else if (code == CHRS_ISO_2022_JP) {
strcpy(ki,"$B");
strcpy(ko,"(B");
} else if (code == CHRS_ISO_2022_KR) {
strcpy(ki,"$(C");
strcpy(ko,"(B");
} else if (code == CHRS_ISO_2022_TW) {
strcpy(ki,"$(G");
strcpy(ko,"(B");
}
return code;
}
int SkipESCSeq(FILE *in,int temp,int *intwobyte)
{
int tempdata;
tempdata = *intwobyte;
if (temp == '$' || temp == '(')
fgetc(in);
if (temp == 'K' || temp == '$')
*intwobyte = TRUE;
else
*intwobyte = FALSE;
if (tempdata == *intwobyte)
return FALSE;
else
return TRUE;
}
void noconv(char *in, char **out)
{
char *p;
p=*out;
while (*in)
*p++=*in++;
*p='\0';
}
void eight2eight(char *in,char **out, char *filemap)
{
char *p;
int i;
if (oldfilemap != filemap) {
oldfilemap = filemap;
filemap = xstrcpy(getenv("MBSE_ROOT"));
filemap = xstrcat(filemap, (char *)"/etc/maptabs/");
filemap = xstrcat(filemap, oldfilemap);
for (i = 0; i < 256; i++)
maptab[i] = (unsigned char)i;
getmaptab(filemap);
}
p=*out;
while (*in) {
*p=maptab[*in & 0xff];
in++;
p++;
}
*p='\0';
}
int iso2022_detectcode(char *in,int whatcode)
{
int c=0;
while (((whatcode == CHRS_NOTSET) || (whatcode==CHRS_AUTODETECT)) && (*in)) {
if ((c = (unsigned int)(*in++))) {
if (c == ESC) {
c = (unsigned int)(*in++);
if (c == '$') {
c = (unsigned int)(*in++);
switch (c) {
case 'A' : whatcode = CHRS_ISO_2022_CN; break;
case 'B' :
case '@' : whatcode = CHRS_ISO_2022_JP; break;
case '(' :
case ')' : c = (unsigned int)(*in++);
switch (c) {
case 'A' : whatcode = CHRS_ISO_2022_CN; break;
case 'C' : whatcode = CHRS_ISO_2022_KR; break;
case 'D' : whatcode = CHRS_ISO_2022_JP; break;
case 'E' : whatcode = CHRS_ISO_2022_CN; break;
case 'G' :
case 'H' :
case 'I' :
case 'J' :
case 'K' :
case 'L' :
case 'M' : whatcode = CHRS_ISO_2022_TW; break;
case 'X' : whatcode = CHRS_ISO_2022_CN; break;
default: break;
}
break;
case '*' : c = (unsigned int)(*in++);
switch (c) {
case 'H' :
case 'X' : whatcode = CHRS_ISO_2022_CN; break;
default: break;
}
break;
case '+' : c = (unsigned int)(*in++);
switch (c) {
case 'H' :
case 'I' :
case 'J' :
case 'K' :
case 'L' :
case 'M' :
case 'X' : whatcode = CHRS_ISO_2022_CN; break;
default: break;
}
break;
default: break;
}
}
} else if (whatcode == CHRS_NOTSET)
return whatcode;
#if (LANG_DEFAULT == LANG_JAPAN)
else if ((c >= 129 && c <= 141) || (c >= 143 && c <= 159))
whatcode = CHRS_SJIS;
else if (c == 142) {
c = (unsigned int)(*in++);
if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160) || (c >= 224 && c <= 252))
whatcode = CHRS_SJIS;
else if (c >= 161 && c <= 223)
whatcode = CHRS_AUTODETECT;
} else if (c >= 161 && c <= 223) {
c = (unsigned int)(*in++);
if (c >= 240 && c <= 254)
whatcode = CHRS_EUC_JP;
else if (c >= 161 && c <= 223)
whatcode = CHRS_AUTODETECT;
else if (c >= 224 && c <= 239) {
whatcode = CHRS_AUTODETECT;
while (c >= 64 && c != EOF && whatcode == CHRS_AUTODETECT) {
if (c >= 129) {
if (c <= 141 || (c >= 143 && c <= 159))
whatcode = CHRS_SJIS;
else if (c >= 253 && c <= 254)
whatcode = CHRS_EUC_JP;
}
c = (unsigned int)(*in++);
}
} else if (c <= 159)
whatcode = CHRS_SJIS;
} else if (c >= 240 && c <= 254)
whatcode = CHRS_EUC_JP;
else if (c >= 224 && c <= 239) {
c = (unsigned int)(*in++);
if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160))
whatcode = CHRS_SJIS;
else if (c >= 253 && c <= 254)
whatcode = CHRS_EUC_JP;
else if (c >= 161 && c <= 252)
whatcode = CHRS_AUTODETECT;
}
#endif /* (LANG_DEFAULT == LANG_JAPAN) */
}
}
return whatcode;
}
char *hdrnconv(char *s, int incode, int outcode, int n)
{
char ki[10],ko[10];
int kolen;
static char *dest;
int destlen;
int i;
getkcode(outcode, ki, ko);
kolen = strlen(ko);
dest = hdrconv(s, incode, outcode);
destlen = strlen(dest);
if(destlen >= kolen && destlen > n) {
for(i = 0; i < kolen; i++)
*(dest + n - 1 - kolen + i) = ko[i];
*(dest + n) = '\0';
}
return dest;
}
char *hdrconv(char *s, int incode, int outcode)
{
#define BCODAGE 1
#define QCODAGE 2
char ttbuf[1024];
char *iptr, *tptr;
char *xbuf=NULL, *buf=NULL, *q;
int codage;
iptr = s;
while (*iptr) {
if (!strncmp(iptr,"=?",2)) {
q=strchr(iptr+2,'?');
if (q) {
incode=getcode(iptr+2);
if (incode==CHRS_NOTSET)
return s;
iptr=q;
} else {
return s;
}
if (!strncasecmp(iptr,"?Q?",3)) {
codage = QCODAGE;
iptr+=3;
} else if (!strncasecmp(iptr,"?B?",3)) {
codage = BCODAGE;
iptr+=3;
} else {
iptr=xstrcpy(iptr);
*(iptr+3)='\0';
Syslog('+', "mimehdr_decode: unknown codage %s",iptr);
return s;
}
tptr = ttbuf;
while ((*iptr) && (strncmp(iptr,"?=",2)))
*tptr++ = *iptr++;
*tptr = '\0';
if (!strncmp(iptr,"?=",2)) {
iptr++;
iptr++;
}
if (codage==QCODAGE) {
while ((q = strchr(ttbuf, '_')))
*q=' ';
xbuf=xstrcat(xbuf,qp_decode(ttbuf));
} else if (codage==BCODAGE) {
xbuf=xstrcat(xbuf,b64_decode(ttbuf));
}
} else { /* not coded */
*ttbuf=*iptr;
*(ttbuf+1)='\0';
xbuf=xstrcat(xbuf,ttbuf);
iptr++;
}
}
buf=strkconv(xbuf, incode, outcode);
return buf;
}

View File

@ -1,484 +0,0 @@
/*****************************************************************************
*
* File ..................: common/charconv_hz.c
* Purpose ...............: Common utilities
* Last modification date : 29-Aug-2000
*
*****************************************************************************
* Copyright (C) 1997-2000
*
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../config.h"
#include "libs.h"
#include "memwatch.h"
#include "structs.h"
#include "common.h"
#include "clcomm.h"
int LF2CR = FALSE; /* flag for converting ASCII <LF> to <CR> */
int CR2LF=FALSE; /* flag for converting ASCII <CR> to <LF> */
int pass8 = FALSE; /* flat for parsing all 8 bits of a character */
int termStyle = FALSE; /* flag for ignoring line-continuation markers */
int MAXLEN = 77; /* default maximum line length in the above style */
int MINLEN = 7; /* minimum line length in the above style */
int errorCount = 0; /* number of parsing errors detected */
/*
* internal functions
*/
void EOFerror(void);
void ESCerror(int c);
void GBerror(int c1,int c2);
void GBerror1(int c);
void GBtoSGB(int hi, int lo, int *hi1, int *lo1);
void mac2gb(int hi, int lo, int *hi1, int *lo1);
void dos2gb(int hi, int lo, int *hi1, int *lo1);
void zw2gb(char *src,char **dest)
{
char *buf;
buf=(char*)malloc(strlen(*dest) * sizeof(char));
zw2hz(src,&buf);
hz2gb(buf,dest);
free(buf);
}
void zw2hz(char *src,char **dest)
{
/*
Copyright (C) 1989, 1992 Fung F. Lee
zw2hz 2.0: do a straightforward conversion from a zW file into a HZ file
This version was an update of version 1.1, because the specification of
zW had been changed by the original authors.
Since the set of all zW files is a proper subset of the set of all
HZ (HGB) files, it is always possible to do perfect translation from
zW to HZ (HGB); but not vice versa.
* HGB - High-bit-set GB, as used in CCDOS, Macintosh System 6.0.x and later.
As for error handling, I took the lazy approach. For example, if the
original zW file contains invalid GB codes, they will also show up in
the output HZ file, and can be detected by "hz2gb -v".
This program is free for general distribution.
*/
/* As we do not want to impose any limit of line length (such as 80 characters
per line), we parse the input stream on a character by character basis,
because in the worst case, a line can be as long as a file.
Although in practice the line length (with or without soft CR marker at
its end) is likely to be about 80 characters or so, I am not sure what
the maximum line length is enforced by the zW standard, nor do I think
it is a necessary assumption for proper decoding.
*/
int c1, c2;
int ASCIImode = TRUE;
int lineStart = TRUE;
FILE *fin, *fout;
OPENINOUTFILES(&fin,&fout,src);
while ((c1 = fgetc(fin)) != EOF) {
if (ASCIImode) {
if (c1 == '\n') {
fputc('\n', fout);
lineStart = TRUE;
} else if (lineStart && c1 == 'z') {
c2 = fgetc(fin);
if (c2 == EOF) {
fputc(c1, fout);
break;
}
if (c2 == 'W') {
fprintf(fout, "~{");
ASCIImode = FALSE;
} else {
fputc(c1, fout);
fputc(c2, fout);
}
lineStart = FALSE;
} else {
fputc(c1, fout);
lineStart = FALSE;
}
} else { /* GBmode */
c2 = fgetc(fin);
if (c1 == '\n') {
ungetc(c2, fin);
fprintf(fout, "~}~\n"); /* soft CR - with line continuation */
lineStart = TRUE;
ASCIImode = TRUE;
} else if (c2 == EOF) {
fputc(c1, fout);
break;
} else if (c1 == '#' && c2 == '\n') {
fprintf(fout, "~}\n"); /* hard CR */
lineStart = TRUE;
ASCIImode = TRUE;
} else if (c2 == '\n') { /* This may be an invalid zW sequence, ... */
/* anyway, for robustness, I choose ... */
/* eat c1 */ /* c1 may be ' ' or something else */
fprintf(fout, "~}\n"); /* hard CR */
lineStart = TRUE;
ASCIImode = TRUE;
} else if (c1 == '#' && c2 == ' ') {
fprintf(fout, "~} ~{"); /* temporary escape and back */
} else if (c1 == ' ') { /* 0x20?? is now for ASCII characters */
fprintf(fout, "~}%c~{", c2); /* temporary escape and back */
} else { /* ASSUME they are GB codes, and fix them in program hz2gb */
fputc(c1, fout); fputc(c2, fout);
}
}
}
CLOSEINOUTFILES(&fin,&fout,dest);
}
void hz2gb(char *src,char **dest)
{
/*
Copyright (C) 1989, 1992 Fung F. Lee
hz2gb 2.0: convert a HZ file into a Macintosh* / CCDOS SGB file.
*For Macintosh pre-6.0.x Simplified Chinese Operating System.
Later versions use the same internal code (High-bit-set GB) as CCDOS does.
The HZ specification does not dictate how to convert invalid HZ files,
just as the definition of a programming language usually does not specify
how a compiler should handle illegal programming constructs.
The error recovery procedure of this HZ decoder was designed after
examination of the conversion errors reported by hz2gb 1.1 of some of the
"HZ" files posted on the news group alt.chinese.text. I suspected that
most of the errors occured due to improper manual insertion of escape
sequences, and/or using invalid GB codes, such as those for "space" ($2121).
Such errors should not have occured if the files were first properly edited
as GB codes, and then converted by an HZ encoder, such as gb2hz (preferably
with the -t option.)
To prevent some hanzi displayers from ill behaviour, the output stream
should be or should be corrected to be valid mixed ASCII and GB sequences.
The error recovery procedure is by no means unique, and may change in the
future. Users should NOT regard the error recovery features as part of the
HZ specification.
This program is free for general distribution.
*/
FILE *fin, *fout;
int c1, c2, c3, c4;
int ASCIImode = TRUE;
OPENINOUTFILES(&fin,&fout,src);
while ((c1=fgetc(fin)) != EOF) {
if (!pass8)
c1 = CLEAN7(c1);
if (ASCIImode) {
if (c1 == '~') {
if ((c2 = fgetc(fin)) == EOF) {
EOFerror();
break;
}
if (!pass8)
c2 = CLEAN7(c2);
switch (c2) {
case '~' : fputc('~', fout);
break;
case '{' : ASCIImode = FALSE;
break;
case '\n': /* line-continuation marker: eat it unless ... */
if (termStyle)
fputc('\n', fout);
break;
default : ESCerror(c2);
fputc('~', fout);
fputc(c2, fout);
break;
}
} else {
if (LF2CR && c1=='\n')
c1 = '\r';
fputc(c1, fout);
}
} else { /* GBmode */
if (isprint(c1)) {
if ((c2 = fgetc(fin)) == EOF) {
EOFerror();
break;
}
if (!pass8)
c2 = CLEAN7(c2);
if (isGB1(c1) && isGB2(c2)) {
GBtoSGB(c1, c2, &c3, &c4);
fputc(c3, fout);
fputc(c4, fout);
} else if (c1 == '~' && c2 == '}') { /* 0x7E7D */
ASCIImode = TRUE;
} else if (isGB1U(c1) && isGB2(c2)) { /* 0x78?? - 0x7D?? */
GBerror(c1, c2); /* non-standard extended code? */
fputc(HI(BOX), fout);
fputc(LO(BOX), fout);
} else if (c1 == '~') { /* 0x7E */
GBerror(c1, c2); /* undefined shift-out code? */
ASCIImode = TRUE; /* safer assumption? */
fputc(c1, fout);
fputc(c2, fout);
} else if (c1 == ' ') { /* 0x20 */
GBerror(c1, c2); /* looks like artifacts of zwdos? */
fputc(c2, fout);
} else if (c2 == ' ') { /* 0x20 */
GBerror(c1, c2); /* null image looks like "sp"? */
fputc(HI(SPACE), fout);
fputc(LO(SPACE), fout);
} else { /* isprint(c1) && !isprint(c2)) */
GBerror(c1, c2); /* premature shift-out? */
ASCIImode = TRUE; /* safer assumption? */
fputc(c1, fout);
fputc(c2, fout);
}
} else { /* !isprint(c1) */
GBerror1(c1); /* premature shift-out? */
ASCIImode = TRUE; /* safer assumption? */
fputc(c1, fout);
}
}
}
CLOSEINOUTFILES(&fin,&fout,dest);
}
void GBtoSGB(int hi, int lo, int *hi1, int *lo1)
{
#ifdef DOS
*hi1 = 0x80 | hi;
*lo1 = 0x80 | lo;
#endif
#ifdef MAC
*hi1 = 0x81 + (hi - 0x21)/2;
if (hi%2 != 0) {
*lo1 = 0x40 + (lo - 0x21);
if (*lo1 >= 0x7F)
*lo1 += 1;
} else
*lo1 = 0x9F + (lo - 0x21);
#endif
}
void EOFerror()
{
errorCount++;
Syslog('m', "hz2gb: Unexpected EOF");
}
void ESCerror(int c)
{
errorCount++;
Syslog('m', "hz2gb: Invalid ASCII escape sequence:\"~%c\"", c);
}
void GBerror(int c1, int c2)
{
errorCount++;
Syslog('m', "hz2gb: Invalid GB code:\"%c%c\"(0x%4x)", c1,c2, DB(c1,c2));
}
void GBerror1(int c)
{
errorCount++;
Syslog('m', "hz2gb: Invalid GB code first byte:'%c'(0x%2x)", c, c);
}
void gb2hz(char *src,char **dest)
{
/*
Copyright (C) 1989 Fung F. Lee
sgb2hz: convert a Macintosh/CCDOS SGB file into a HZ file.
This program is free for general distribution.
*/
FILE *fin, *fout;
int c1, c2, c3, c4;
#ifdef MAC
int hi;
#endif
int GBmode = FALSE;
int len = 0;
OPENINOUTFILES(&fin,&fout,src);
while ((c1=fgetc(fin)) != EOF) {
if (notAscii(c1))
#ifdef MAC
{
hi = c1 & 0xF0;
switch (hi) {
case 0x80:
case 0x90:
case 0xA0:
if (termStyle) {
if (GBmode && len>MAXLEN-5) {
fprintf(fout, "~}~\n");
GBmode = FALSE;
len = 0;
} else if (!GBmode && len>MAXLEN-7) {
fprintf(fout, "~\n");
GBmode = FALSE; len = 0;
}
}
if (!GBmode) { /* switch to GB mode */
fprintf(fout, "~{");
len += 2;
}
GBmode = TRUE;
c2 = fgetc(fin);
mac2gb(c1, c2, &c3, &c4);
fputc(c3, fout);
fputc(c4, fout);
len += 2;
break;
case 0xB0:
case 0xC0:
case 0xD0:
case 0xE0:
WriteError("gb2hz: ignored non-Ascii character: %2x\n", c1);
break;
case 0xF0:
switch (c1) {
case 0xFD:
case 0xFE:
case 0xFF:
WriteError("gb2hz: ignored non-Ascii character: %2x\n", c1);
break;
default:
c2 = fgetc(fin);
WriteError("gb2hz: ignored user defined SGB code: %2x%2x\n", c1, c2);
break;
}
}
}
#endif
#ifdef DOS
{
if (termStyle) {
if (GBmode && len>MAXLEN-5) {
fprintf(fout, "~}~\n");
GBmode = FALSE;
len = 0;
} else if (!GBmode && len>MAXLEN-7) {
fprintf(fout, "~\n");
GBmode = FALSE; len = 0;
}
}
if (!GBmode) { /* switch to GB mode */
fprintf(fout, "~{");
len += 2;
}
GBmode = TRUE;
c2 = fgetc(fin);
dos2gb(c1, c2, &c3, &c4);
fputc(c3, fout);
fputc(c4, fout);
len += 2;
}
#endif
/* c1 is ASCII */
else {
if (GBmode) {
fprintf(fout, "~}");
len += 2;
}
/* assert(len<=MAXLEN-1) */
if (termStyle && (len>MAXLEN-2 || (len>MAXLEN-3 && c1=='~'))) {
fprintf(fout, "~\n");
len = 0;
}
GBmode = FALSE;
if (CR2LF && c1=='\r')
c1 = '\n';
fputc(c1, fout);
len++;
if (c1=='\n')
len=0;
else if (c1== '~') {
fputc('~', fout);
len++;
}
}
}
if (GBmode)
fprintf(fout, "~}");
CLOSEINOUTFILES(&fin,&fout,dest);
}
#ifdef MAC
void mac2gb(int hi, int lo, int *hi1, int *lo1)
{
if (lo >= 0x9F) {
*hi1 = 0x21 + (hi - 0x81) * 2 + 1;
*lo1 = 0x21 + (lo - 0x9F);
} else {
*hi1 = 0x21 + (hi - 0x81) * 2;
if (lo > 0x7F)
lo--;
*lo1 = 0x21 + (lo - 0x40);
}
}
#endif
#ifdef DOS
void dos2gb(int hi, int lo, int *hi1, int *lo1)
{
*hi1 = hi - 0x80;
*lo1 = lo - 0x80;
}
#endif

View File

@ -1,808 +0,0 @@
/*****************************************************************************
*
* File ..................: charconv_jp.c
* Purpose ...............: Common utilities
* Last modification date : 29-Aug-2000
*
*****************************************************************************
* Copyright (C) 1997-2000
*
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../config.h"
#include "libs.h"
#include "memwatch.h"
#include "structs.h"
#include "common.h"
/* ### Modified by P. Saratxaga on 26 Oct 95 ###
* This is the kcon.c taken from JE version (code from T. Tanaka)
* I've modified it to support 8bit -> 8bit transcoding in addition of
* japanese (16 bits) ones.
* Also the codings are not readen from a config file but taken from the
* charset values in Header lines.
*/
void OPENINOUTFILES(FILE **in, FILE **out, char *src)
{
*in=tmpfile();
*out=tmpfile();
fwrite(src, sizeof(char), strlen(src), *in);
rewind(*in);
}
void CLOSEINOUTFILES(FILE **in, FILE **out,char **dest)
{
int destlen, c;
char *p;
rewind(*out);
for(destlen = 0; (c = fgetc(*out)) != EOF; destlen++);
rewind(*out);
if(*dest)
free(*dest);
*dest = (char *)malloc((destlen + 1) * sizeof(char));
for(p = *dest; (c = fgetc(*out)) != EOF; p++)
*p = (char)(c & 0xff);
*p = '\0';
fclose(*in);
fclose(*out);
}
void sjis2jis(int *p1,int *p2)
{
register unsigned char c1 = *p1;
register unsigned char c2 = *p2;
register int adjust = c2 < 159;
register int rowOffset = c1 < 160 ? 112 : 176;
register int cellOffset = adjust ? (31 + (c2 > 127)) : 126;
*p1 = ((c1 - rowOffset) << 1) - adjust;
*p2 -= cellOffset;
}
void jis2sjis(int *p1,int *p2)
{
register unsigned char c1 = *p1;
register unsigned char c2 = *p2;
register int rowOffset = c1 < 95 ? 112 : 176;
register int cellOffset = c1 % 2 ? 31 + (c2 > 95) : 126;
*p1 = ((c1 + 1) >> 1) + rowOffset;
*p2 = c2 + cellOffset;
}
void shift2seven(char *src,char **dest,int incode,char ki[],char ko[])
{
int p1,p2,intwobyte = FALSE;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case NUL :
case FF :
break;
case CR :
case NL :
if (intwobyte) {
intwobyte = FALSE;
fprintf(out,"%c%s",ESC,ko);
}
fprintf(out,"%c",NL);
break;
default :
if SJIS1(p1) {
p2 = fgetc(in);
if SJIS2(p2) {
sjis2jis(&p1,&p2);
if (!intwobyte) {
intwobyte = TRUE;
fprintf(out,"%c%s",ESC,ki);
}
}
fprintf(out,"%c%c",p1,p2);
} else if HANKATA(p1) {
han2zen(in,&p1,&p2,incode);
sjis2jis(&p1,&p2);
if (!intwobyte) {
intwobyte = TRUE;
fprintf(out,"%c%s",ESC,ki);
}
fprintf(out,"%c%c",p1,p2);
} else {
if (intwobyte) {
intwobyte = FALSE;
fprintf(out,"%c%s",ESC,ko);
}
fprintf(out,"%c",p1);
}
break;
}
}
if (intwobyte)
fprintf(out,"%c%s",ESC,ko);
CLOSEINOUTFILES(&in,&out,dest);
}
void shift2euc(char *src, char **dest, int incode, int tofullsize)
{
int p1,p2;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case CR :
case NL :
fprintf(out,"%c",NL);
break;
case NUL :
case FF :
break;
default :
if SJIS1(p1) {
p2 = fgetc(in);
if SJIS2(p2) {
sjis2jis(&p1,&p2);
p1 += 128;
p2 += 128;
}
fprintf(out,"%c%c",p1,p2);
} else if HANKATA(p1) {
if (tofullsize) {
han2zen(in,&p1,&p2,incode);
sjis2jis(&p1,&p2);
p1 += 128;
p2 += 128;
} else {
p2 = p1;
p1 = 142;
}
fprintf(out,"%c%c",p1,p2);
} else
fprintf(out,"%c",p1);
break;
}
}
CLOSEINOUTFILES(&in,&out,dest);
}
void euc2seven(char *src,char **dest,int incode,char ki[],char ko[])
{
int p1,p2,intwobyte = FALSE;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case NL :
if (intwobyte) {
intwobyte = FALSE;
fprintf(out,"%c%s",ESC,ko);
}
fprintf(out,"%c",p1);
break;
case FF :
break;
default :
if ISEUC(p1) {
p2 = fgetc(in);
if ISEUC(p2) {
p1 -= 128;
p2 -= 128;
if (!intwobyte) {
intwobyte = TRUE;
fprintf(out,"%c%s",ESC,ki);
}
}
fprintf(out,"%c%c",p1,p2);
}
else if (p1 == 142) {
p2 = fgetc(in);
if HANKATA(p2) {
p1 = p2;
han2zen(in,&p1,&p2,incode);
sjis2jis(&p1,&p2);
if (!intwobyte) {
intwobyte = TRUE;
fprintf(out,"%c%s",ESC,ki);
}
}
fprintf(out,"%c%c",p1,p2);
}
else {
if (intwobyte) {
intwobyte = FALSE;
fprintf(out,"%c%s",ESC,ko);
}
fprintf(out,"%c",p1);
}
break;
}
}
if (intwobyte)
fprintf(out,"%c%s",ESC,ko);
CLOSEINOUTFILES(&in,&out,dest);
}
void euc2shift(char *src,char **dest,int incode,int tofullsize)
{
int p1,p2;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case FF :
break;
default :
if ISEUC(p1) {
p2 = fgetc(in);
if ISEUC(p2) {
p1 -= 128;
p2 -= 128;
jis2sjis(&p1,&p2);
}
fprintf(out,"%c%c",p1,p2);
}
else if (p1 == 142) {
p2 = fgetc(in);
if HANKATA(p2) {
if (tofullsize) {
p1 = p2;
han2zen(in,&p1,&p2,incode);
fprintf(out,"%c%c",p1,p2);
}
else {
p1 = p2;
fprintf(out,"%c",p1);
}
}
else
fprintf(out,"%c%c",p1,p2);
}
else
fprintf(out,"%c",p1);
break;
}
}
CLOSEINOUTFILES(&in,&out,dest);
}
void euc2euc(char *src,char **dest,int incode,int tofullsize)
{
int p1,p2;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case FF :
break;
default :
if ISEUC(p1) {
p2 = fgetc(in);
if ISEUC(p2)
fprintf(out,"%c%c",p1,p2);
}
else if (p1 == 142) {
p2 = fgetc(in);
if (HANKATA(p2) && tofullsize) {
p1 = p2;
han2zen(in,&p1,&p2,incode);
sjis2jis(&p1,&p2);
p1 += 128;
p2 += 128;
}
fprintf(out,"%c%c",p1,p2);
}
else
fprintf(out,"%c",p1);
break;
}
}
CLOSEINOUTFILES(&in,&out,dest);
}
void shift2shift(char *src,char **dest,int incode,int tofullsize)
{
int p1,p2;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case CR :
case NL :
fprintf(out,"%c",NL);
break;
case NUL :
case FF :
break;
default :
if SJIS1(p1) {
p2 = fgetc(in);
if SJIS2(p2)
fprintf(out,"%c%c",p1,p2);
}
else if (HANKATA(p1) && tofullsize) {
han2zen(in,&p1,&p2,incode);
fprintf(out,"%c%c",p1,p2);
}
else
fprintf(out,"%c",p1);
break;
}
}
CLOSEINOUTFILES(&in,&out,dest);
}
void seven2shift(char *src,char **dest)
{
int temp,p1,p2,intwobyte = FALSE;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case ESC :
temp = fgetc(in);
SkipESCSeq(in,temp,&intwobyte);
break;
case NL :
if (intwobyte)
intwobyte = FALSE;
fprintf(out,"%c",p1);
break;
case FF :
break;
default :
if (intwobyte) {
p2 = fgetc(in);
jis2sjis(&p1,&p2);
fprintf(out,"%c%c",p1,p2);
}
else
fprintf(out,"%c",p1);
break;
}
}
CLOSEINOUTFILES(&in,&out,dest);
}
void seven2euc(char *src, char **dest)
{
int temp,p1,p2,intwobyte = FALSE;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case ESC :
temp = fgetc(in);
SkipESCSeq(in,temp,&intwobyte);
break;
case NL :
if (intwobyte)
intwobyte = FALSE;
fprintf(out,"%c",p1);
break;
case FF :
break;
default :
if (intwobyte) {
p2 = fgetc(in);
p1 += 128;
p2 += 128;
fprintf(out,"%c%c",p1,p2);
}
else
fprintf(out,"%c",p1);
break;
}
}
CLOSEINOUTFILES(&in,&out,dest);
}
void seven2seven(char *src,char **dest,char ki[],char ko[])
{
int temp,p1,p2,change,intwobyte = FALSE;
FILE *in, *out;
OPENINOUTFILES(&in,&out,src);
while ((p1 = fgetc(in)) != EOF) {
switch (p1) {
case ESC :
temp = fgetc(in);
change = SkipESCSeq(in,temp,&intwobyte);
if ((intwobyte) && (change))
fprintf(out,"%c%s",ESC,ki);
else if (change)
fprintf(out,"%c%s",ESC,ko);
break;
case NL :
if (intwobyte) {
intwobyte = FALSE;
fprintf(out,"%c%s",ESC,ko);
}
fprintf(out,"%c",p1);
break;
case FF :
break;
default :
if (intwobyte) {
p2 = fgetc(in);
fprintf(out,"%c%c",p1,p2);
}
else
fprintf(out,"%c",p1);
break;
}
}
if (intwobyte)
fprintf(out,"%c%s",ESC,ko);
CLOSEINOUTFILES(&in,&out,dest);
}
void han2zen(FILE *in,int *p1,int *p2,int incode)
{
int junk,maru,nigori;
maru = nigori = FALSE;
if (incode == CHRS_SJIS) {
*p2 = fgetc(in);
if (*p2 == 222) {
if (ISNIGORI(*p1) || *p1 == 179)
nigori = TRUE;
else
ungetc(*p2,in);
}
else if (*p2 == 223) {
if ISMARU(*p1)
maru = TRUE;
else
ungetc(*p2,in);
}
else
ungetc(*p2,in);
}
else if (incode == CHRS_EUC_JP) {
junk = fgetc(in);
if (junk == 142) {
*p2 = fgetc(in);
if (*p2 == 222) {
if (ISNIGORI(*p1) || *p1 == 179)
nigori = TRUE;
else {
ungetc(*p2,in);
ungetc(junk,in);
}
}
else if (*p2 == 223) {
if ISMARU(*p1)
maru = TRUE;
else {
ungetc(*p2,in);
ungetc(junk,in);
}
}
else {
ungetc(*p2,in);
ungetc(junk,in);
}
}
else
ungetc(junk,in);
}
switch (*p1) {
case 161 :
*p1 = 129;
*p2 = 66;
break;
case 162 :
*p1 = 129;
*p2 = 117;
break;
case 163 :
*p1 = 129;
*p2 = 118;
break;
case 164 :
*p1 = 129;
*p2 = 65;
break;
case 165 :
*p1 = 129;
*p2 = 69;
break;
case 166 :
*p1 = 131;
*p2 = 146;
break;
case 167 :
*p1 = 131;
*p2 = 64;
break;
case 168 :
*p1 = 131;
*p2 = 66;
break;
case 169 :
*p1 = 131;
*p2 = 68;
break;
case 170 :
*p1 = 131;
*p2 = 70;
break;
case 171 :
*p1 = 131;
*p2 = 72;
break;
case 172 :
*p1 = 131;
*p2 = 131;
break;
case 173 :
*p1 = 131;
*p2 = 133;
break;
case 174 :
*p1 = 131;
*p2 = 135;
break;
case 175 :
*p1 = 131;
*p2 = 98;
break;
case 176 :
*p1 = 129;
*p2 = 91;
break;
case 177 :
*p1 = 131;
*p2 = 65;
break;
case 178 :
*p1 = 131;
*p2 = 67;
break;
case 179 :
*p1 = 131;
*p2 = 69;
break;
case 180 :
*p1 = 131;
*p2 = 71;
break;
case 181 :
*p1 = 131;
*p2 = 73;
break;
case 182 :
*p1 = 131;
*p2 = 74;
break;
case 183 :
*p1 = 131;
*p2 = 76;
break;
case 184 :
*p1 = 131;
*p2 = 78;
break;
case 185 :
*p1 = 131;
*p2 = 80;
break;
case 186 :
*p1 = 131;
*p2 = 82;
break;
case 187 :
*p1 = 131;
*p2 = 84;
break;
case 188 :
*p1 = 131;
*p2 = 86;
break;
case 189 :
*p1 = 131;
*p2 = 88;
break;
case 190 :
*p1 = 131;
*p2 = 90;
break;
case 191 :
*p1 = 131;
*p2 = 92;
break;
case 192 :
*p1 = 131;
*p2 = 94;
break;
case 193 :
*p1 = 131;
*p2 = 96;
break;
case 194 :
*p1 = 131;
*p2 = 99;
break;
case 195 :
*p1 = 131;
*p2 = 101;
break;
case 196 :
*p1 = 131;
*p2 = 103;
break;
case 197 :
*p1 = 131;
*p2 = 105;
break;
case 198 :
*p1 = 131;
*p2 = 106;
break;
case 199 :
*p1 = 131;
*p2 = 107;
break;
case 200 :
*p1 = 131;
*p2 = 108;
break;
case 201 :
*p1 = 131;
*p2 = 109;
break;
case 202 :
*p1 = 131;
*p2 = 110;
break;
case 203 :
*p1 = 131;
*p2 = 113;
break;
case 204 :
*p1 = 131;
*p2 = 116;
break;
case 205 :
*p1 = 131;
*p2 = 119;
break;
case 206 :
*p1 = 131;
*p2 = 122;
break;
case 207 :
*p1 = 131;
*p2 = 125;
break;
case 208 :
*p1 = 131;
*p2 = 126;
break;
case 209 :
*p1 = 131;
*p2 = 128;
break;
case 210 :
*p1 = 131;
*p2 = 129;
break;
case 211 :
*p1 = 131;
*p2 = 130;
break;
case 212 :
*p1 = 131;
*p2 = 132;
break;
case 213 :
*p1 = 131;
*p2 = 134;
break;
case 214 :
*p1 = 131;
*p2 = 136;
break;
case 215 :
*p1 = 131;
*p2 = 137;
break;
case 216 :
*p1 = 131;
*p2 = 138;
break;
case 217 :
*p1 = 131;
*p2 = 139;
break;
case 218 :
*p1 = 131;
*p2 = 140;
break;
case 219 :
*p1 = 131;
*p2 = 141;
break;
case 220 :
*p1 = 131;
*p2 = 143;
break;
case 221 :
*p1 = 131;
*p2 = 147;
break;
case 222 :
*p1 = 129;
*p2 = 74;
break;
case 223 :
*p1 = 129;
*p2 = 75;
break;
}
if (nigori) {
if ((*p2 >= 74 && *p2 <= 103) || (*p2 >= 110 && *p2 <= 122))
(*p2)++;
else if (*p1 == 131 && *p2 == 69)
*p2 = 148;
}
else if (maru && *p2 >= 110 && *p2 <= 122)
*p2 += 2;
}

View File

@ -1,269 +0,0 @@
/*****************************************************************************
*
* File ..................: charconv_utf.c
* Purpose ...............: Common utilities
* Last modification date : 29-Aug-2000
*
*****************************************************************************
* Copyright (C) 1997-2000
*
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../config.h"
#include "libs.h"
#include "memwatch.h"
#include "structs.h"
#include "common.h"
char Base_64Code[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/* returns numeric value from a Base64Code[] digit */
static int index_hex2[128] = {
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1,0x3e, -1, -1, -1,0x3f,
0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,
0x3c,0x3d, -1, -1, -1, -1, -1, -1,
-1,0x00,0x01,0x02,0x03,0x04,0x05,0x06,
0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,
0x17,0x18,0x19, -1, -1, -1, -1, -1,
-1,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,
0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,
0x31,0x32,0x33, -1, -1, -1, -1, -1
};
void utf7_to_eight(char *in,char **out,int *code)
{
int isb64,l_code=CHRS_AUTODETECT;
char *p, *q, *buf;
buf=malloc(strlen(in)*sizeof(char));
isb64=0;
for (p = in, q = buf; *p != '\0';) {
if (isb64) { /* we are in B64 encoding, that is in utf-7 */
int bit_buffer=0;
int nbits=0;
int i,l,result,offset=0;
/* find the lenght of the B64 string */
l=strspn(p,Base_64Code);
for (i=0;i<l;i++) {
bit_buffer <<= 6;
bit_buffer |= index_hex2[(unsigned int)*p++];
nbits += 6;
if (nbits >= 8) {
nbits -= 8;
result = ((bit_buffer >> nbits)&0xff);
/* if the charset code is unknown try to find it.
* it only works for latin1 (iso-8859-1), cyrillic, greek,
* arabic and hebrew (iso-8859-[5678]), as for other latin
* encodings it is harder, iso-8859-2 is assumed as it is
* the most common
*/
if ((l_code==CHRS_AUTODETECT) || (l_code==CHRS_ISO_8859_1)) {
if (result == 0x00) l_code=CHRS_ISO_8859_1;
else if (result == 0x01) l_code=CHRS_ISO_8859_2;
else if (result == 0x03) l_code=CHRS_ISO_8859_7;
else if (result == 0x04) l_code=CHRS_ISO_8859_5;
else if (result == 0x05) l_code=CHRS_ISO_8859_8;
else if (result == 0x06) l_code=CHRS_ISO_8859_6;
}
/* what to add to next byte to convert to iso-8859-*
* note that it doesn't work for iso-8859-{2,3,4,9,10}
* as the offset changes for almost each char
*/
if (result == 0x00) offset=0x00;
else if (result == 0x03) offset=0x30;
else if (result == 0x04) offset=0xa0;
else if (result == 0x05) offset=0x10;
else if (result == 0x06) offset=0xa0;
/* convert to the right 8bit char by adding offset */
if (result < 0x06) *q++ = (char)((bit_buffer & 0xff) + offset);
else *q++ = (char)(bit_buffer & 0xff);
}
}
/* end of B64 encoding */
if (*p == '-') p++;
isb64=0;
} else if (*p == '+') { /* '+' is the beginning of a new B64 section */
isb64=1;
p++;
} else { /* ascii encoding */
*q++=*p++;
}
}
*q = '\0';
/* now we know the 8bit charset that was encoded whith utf-7,
* so ask again to see if a conversion to FTN charset is needed
*/
if (*code==CHRS_AUTODETECT || *code==CHRS_NOTSET)
*code=getoutcode(l_code);
switch (l_code) {
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15:
switch (*code) {
case CHRS_CP437 : eight2eight(buf,out,(char *)ISO_8859_1__CP437); break;
case CHRS_CP850 : eight2eight(buf,out,(char *)ISO_8859_1__CP850); break;
case CHRS_MACINTOSH : eight2eight(buf,out,(char *)ISO_8859_1__MACINTOSH); break;
default : noconv(buf,out); break;
}
break;
case CHRS_ISO_8859_5 :
switch (*code) {
case CHRS_CP866 : eight2eight(buf,out,(char *)ISO_8859_5__CP866); break;
case CHRS_KOI8_R :
case CHRS_KOI8_U : eight2eight(buf,out,(char *)ISO_8859_5__KOI8); break;
case CHRS_MIK_CYR : eight2eight(buf,out,(char *)ISO_8859_5__MIK_CYR); break;
default : noconv(buf,out); break;
}
break;
case CHRS_ISO_8859_8 :
switch (*code) {
case CHRS_CP424 : eight2eight(buf,out,(char *)ISO_8859_8__CP424); break;
case CHRS_CP862 : eight2eight(buf,out,(char *)ISO_8859_8__CP862); break;
default : noconv(buf,out); break;
}
break;
default : noconv(in,out); break;
}
}
/*
* UNICODE UTF-8
* ------------- ------------------------------------
* 0000 -> 007F = 7 bits = 0xxxxxxx
* 0080 -> 07FF = 11 bits = 110xxxxx 10xxxxxx
* 0800 -> FFFF = 16 bits = 1110xxxx 10xxxxxx 10xxxxxx
*/
void utf8_to_eight(char *in,char **out,int *code)
{
int is8bit,l_code=CHRS_AUTODETECT;
char *p, *q, *buf;
buf=malloc(strlen(in)*sizeof(char));
is8bit=0;
for (p = in, q = buf; *p != '\0';) {
int bit_buffer=0;
int nbits=0;
int result,offset=0;
if ((*p & 0xff) >= 0xe0) { /* 16 bits = 1110xxxx 10xxxxxx 10xxxxxx */
bit_buffer=((*p++ & 0xff) & 0x0f);
bit_buffer=(bit_buffer << 4);
bit_buffer+=((*p++ & 0xff) & 0xbf);
bit_buffer=(bit_buffer << 6);
bit_buffer+=((*p++ & 0xff) & 0x3f);
nbits=16;
} else if ((*p & 0xff) >= 0xc0) { /* 11 bits = 110xxxxx 10xxxxxx */
bit_buffer=((*p++ & 0xff) & 0x2f);
bit_buffer=(bit_buffer << 6);
bit_buffer+=((*p++ & 0xff) & 0x3f);
nbits=11;
} else { /* 7 bits = 0xxxxxxx */
bit_buffer=(*p++ & 0xff);
nbits=7;
}
if (nbits >= 8) {
result = ((bit_buffer >> 8)&0xff);
/* if the charset code is unknown try to find it.
* it only works for latin1 (iso-8859-1), cyrillic, greek,
* arabic and hebrew (iso-8859-[5678]), as for other latin
* encodings it is harder, iso-8859-2 is assumed as it is
* the most common
*/
if ((l_code==CHRS_AUTODETECT) || (l_code==CHRS_ISO_8859_1)) {
if (result == 0x00) l_code=CHRS_ISO_8859_1;
else if (result == 0x01) l_code=CHRS_ISO_8859_2;
else if (result == 0x03) l_code=CHRS_ISO_8859_7;
else if (result == 0x04) l_code=CHRS_ISO_8859_5;
else if (result == 0x05) l_code=CHRS_ISO_8859_8;
else if (result == 0x06) l_code=CHRS_ISO_8859_6;
}
/* what to add to next byte to convert to iso-8859-*
* note that it doesn't work for iso-8859-{2,3,4,9,10}
* as the offset changes for almost each char
*/
if (result == 0x00) offset=0x00;
else if (result == 0x03) offset=0x30;
else if (result == 0x04) offset=0xa0;
else if (result == 0x05) offset=0x10;
else if (result == 0x06) offset=0xa0;
/* convert to the right 8bit char by adding offset */
if (result < 0x06) *q++ = (char)((bit_buffer & 0xff) + offset);
else *q++ = (char)(bit_buffer & 0xff);
} else { /* ascii encoding */
*q++ = (char)(bit_buffer & 0xff);
}
}
*q = '\0';
/* now we know the 8bit charset that was encoded whith utf-7,
* so ask again to see if a conversion to FTN charset is needed
*/
if (*code==CHRS_AUTODETECT || *code==CHRS_NOTSET)
*code=getoutcode(l_code);
switch (l_code) {
case CHRS_ISO_8859_1 :
case CHRS_ISO_8859_15:
switch (*code) {
case CHRS_CP437 : eight2eight(buf,out,(char *)ISO_8859_1__CP437); break;
case CHRS_CP850 : eight2eight(buf,out,(char *)ISO_8859_1__CP850); break;
case CHRS_MACINTOSH : eight2eight(buf,out,(char *)ISO_8859_1__MACINTOSH); break;
default : noconv(buf,out); break;
}
break;
case CHRS_ISO_8859_5 :
switch (*code) {
case CHRS_CP866 : eight2eight(buf,out,(char *)ISO_8859_5__CP866); break;
case CHRS_KOI8_R :
case CHRS_KOI8_U : eight2eight(buf,out,(char *)ISO_8859_5__KOI8); break;
case CHRS_MIK_CYR : eight2eight(buf,out,(char *)ISO_8859_5__MIK_CYR); break;
default : noconv(buf,out); break;
}
break;
case CHRS_ISO_8859_8 :
switch (*code) {
case CHRS_CP424 : eight2eight(buf,out,(char *)ISO_8859_8__CP424); break;
case CHRS_CP862 : eight2eight(buf,out,(char *)ISO_8859_8__CP862); break;
default : noconv(buf,out); break;
}
break;
default : noconv(in,out); break;
}
}

View File

@ -1,388 +0,0 @@
/*****************************************************************************
*
* File ..................: charset.c
* Purpose ...............: Common utilities
* Last modification date : 09-Sep-2000
*
*****************************************************************************
* Copyright (C) 1997-2000
*
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../config.h"
#include "libs.h"
#include "memwatch.h"
#include "structs.h"
#include "common.h"
#include "clcomm.h"
/* ### Created by P.Saratxaga on 7 Nov 1995 ###
* Functions for charset reading
* - bugfix for bad Content-Type lines lacking ";". By Marc Schaeffer.
*/
int defaultrfcchar = CHRS_DEFAULT_RFC;
int defaultftnchar = CHRS_DEFAULT_FTN;
int toftnchar = CHRS_NOTSET;
//#ifndef HAVE_STRCASESTR
//char *strcasestr(char *, char *);
//#endif
/* tailor getoutcode() and getincode() to show your transcodage preferences */
int getoutcode(int code) /* rfc -> FTN */
{
if ((code==CHRS_MACINTOSH) && (toftnchar!=CHRS_NOTSET))
return toftnchar;
else if (code==CHRS_MACINTOSH) return CHRS_ISO_8859_1;
else if ((toftnchar!=CHRS_NOTSET) && (code==defaultrfcchar))
return toftnchar;
else if (code==CHRS_UTF_7||code==CHRS_UTF_8) return CHRS_AUTODETECT;
else if (code==CHRS_ZW) return CHRS_GB;
else return code;
}
int getincode(int code) /* FTN -> rfc */
{
if (code==CHRS_CP437) return CHRS_ISO_8859_1;
else if (code==CHRS_CP850) return CHRS_ISO_8859_1;
else if (code==CHRS_CP852) return CHRS_ISO_8859_2;
else if (code==CHRS_CP862) return CHRS_ISO_8859_8;
else if (code==CHRS_CP866) return CHRS_KOI8_R;
else if (code==CHRS_CP895) return CHRS_ISO_8859_2;
else if (code==CHRS_EUC_JP) return CHRS_ISO_2022_JP;
/* else if (code==CHRS_EUC_KR) return CHRS_ISO_2022_KR; */
else if (code==CHRS_FIDOMAZOVIA) return CHRS_ISO_8859_2;
else if (code==CHRS_ISO_11) return CHRS_ISO_8859_1;
else if (code==CHRS_ISO_4) return CHRS_ISO_8859_1;
else if (code==CHRS_ISO_60) return CHRS_ISO_8859_1;
else if (code==CHRS_ISO_8859_1_QP) return CHRS_ISO_8859_1_QP;
else if (code==CHRS_MACINTOSH) return CHRS_ISO_8859_1;
else if (code==CHRS_MIK_CYR) return CHRS_ISO_8859_5;
else if (code==CHRS_SJIS) return CHRS_ISO_2022_JP;
else if (code==defaultftnchar) return CHRS_AUTODETECT;
else return code;
}
char *getcharset(int code)
{
char *charset;
if (code==CHRS_ASCII) charset=(char *)"us-ascii";
else if (code==CHRS_BIG5) charset=(char *)"x-CN-Big5";
else if (code==CHRS_CP424) charset=(char *)"x-cp424";
else if (code==CHRS_CP437) charset=(char *)"x-cp437";
else if (code==CHRS_CP850) charset=(char *)"x-cp850";
else if (code==CHRS_CP852) charset=(char *)"x-cp852";
else if (code==CHRS_CP862) charset=(char *)"x-cp862";
else if (code==CHRS_CP866) charset=(char *)"x-cp866";
else if (code==CHRS_CP895) charset=(char *)"x-cp895";
else if (code==CHRS_EUC_JP) charset=(char *)"EUC-jp";
else if (code==CHRS_EUC_KR) charset=(char *)"EUC-kr";
else if (code==CHRS_FIDOMAZOVIA) charset=(char *)"x-FIDOMAZOVIA";
else if (code==CHRS_GB) charset=(char *)"x-CN-GB";
else if (code==CHRS_HZ) charset=(char *)"x-HZ";
else if (code==CHRS_ISO_2022_CN) charset=(char *)"iso-2022-cn";
else if (code==CHRS_ISO_2022_JP) charset=(char *)"iso-2022-jp";
else if (code==CHRS_ISO_2022_KR) charset=(char *)"iso-2022-kr";
else if (code==CHRS_ISO_2022_TW) charset=(char *)"iso-2022-tw";
else if (code==CHRS_ISO_8859_1) charset=(char *)"iso-8859-1";
else if (code==CHRS_ISO_8859_1_QP) charset=(char *)"iso-8859-1";
else if (code==CHRS_ISO_8859_2) charset=(char *)"iso-8859-2";
else if (code==CHRS_ISO_8859_3) charset=(char *)"iso-8859-3";
else if (code==CHRS_ISO_8859_4) charset=(char *)"iso-8859-4";
else if (code==CHRS_ISO_8859_5) charset=(char *)"iso-8859-5";
else if (code==CHRS_ISO_8859_6) charset=(char *)"iso-8859-6";
else if (code==CHRS_ISO_8859_7) charset=(char *)"iso-8859-7";
else if (code==CHRS_ISO_8859_8) charset=(char *)"iso-8859-8";
else if (code==CHRS_ISO_8859_9) charset=(char *)"iso-8859-5";
else if (code==CHRS_ISO_8859_10) charset=(char *)"iso-8859-10";
else if (code==CHRS_ISO_8859_11) charset=(char *)"iso-8859-11";
else if (code==CHRS_ISO_8859_15) charset=(char *)"iso-8859-15";
else if (code==CHRS_KOI8_R) charset=(char *)"koi8-r";
else if (code==CHRS_KOI8_U) charset=(char *)"koi8-u";
else if (code==CHRS_MACINTOSH) charset=(char *)"x-mac-roman";
else if (code==CHRS_MIK_CYR) charset=(char *)"x-mik-cyr";
else if (code==CHRS_NEC) charset=(char *)"x-NEC-JIS";
else if (code==CHRS_SJIS) charset=(char *)"x-sjis";
else if (code==CHRS_UTF_7) charset=(char *)"utf-7";
else if (code==CHRS_UTF_8) charset=(char *)"utf-8";
else if (code==CHRS_VISCII_11) charset=(char *)"viscii";
else if (code==CHRS_ZW) charset=(char *)"x-zW";
else charset=(char *)"us-ascii"; /* mime default */
return charset;
}
int getcode(char *p)
{
int code;
while (*p && isspace(*p)) p++;
if (strncmp(p,"\"",1) == 0) p++;
/* if (strncasecmp(p,"us-ascii",8) == 0) code=CHRS_ASCII; */
/* most newsreaders/mail user agents are misconfigured and put "us-ascii" when
in fact they use the local charset. */
if (strncasecmp(p,"us-ascii",8) == 0) code=defaultrfcchar;
else if (strncasecmp(p,"CN-GB",5) == 0) code=CHRS_GB;
else if (strncasecmp(p,"CN-Big5",7) == 0) code=CHRS_BIG5;
else if (strncasecmp(p,"EUC-jp",6) == 0) code=CHRS_EUC_JP;
else if (strncasecmp(p,"EUC-kr",6) == 0) code=CHRS_EUC_KR;
else if (strncasecmp(p,"iso-2022-cn",11) == 0) code=CHRS_ISO_2022_CN;
else if (strncasecmp(p,"iso-2022-jp",11) == 0) code=CHRS_ISO_2022_JP;
else if (strncasecmp(p,"iso-2022-kr",11) == 0) code=CHRS_ISO_2022_KR;
else if (strncasecmp(p,"iso-2022-tw",11) == 0) code=CHRS_ISO_2022_TW;
else if (strncasecmp(p,"iso8859-1",9) == 0) code = CHRS_ISO_8859_1; /* erroneous iso8859-1 */
else if (strncasecmp(p,"iso-8859-10",11) == 0) code=CHRS_ISO_8859_10;
else if (strncasecmp(p,"iso-8859-11",11) == 0) code=CHRS_ISO_8859_11;
else if (strncasecmp(p,"iso-8859-15",11) == 0) code=CHRS_ISO_8859_15;
else if (strncasecmp(p,"iso-8859-1",10) == 0) code = CHRS_ISO_8859_1;
else if (strncasecmp(p,"iso-8859-2",10) == 0) code=CHRS_ISO_8859_2;
else if (strncasecmp(p,"iso-8859-3",10) == 0) code=CHRS_ISO_8859_3;
else if (strncasecmp(p,"iso-8859-4",10) == 0) code=CHRS_ISO_8859_4;
else if (strncasecmp(p,"iso-8859-5",10) == 0) code=CHRS_ISO_8859_5;
else if (strncasecmp(p,"iso-8859-6",10) == 0) code=CHRS_ISO_8859_6;
else if (strncasecmp(p,"iso-8859-7",10) == 0) code=CHRS_ISO_8859_7;
else if (strncasecmp(p,"iso-8859-8",10) == 0) code=CHRS_ISO_8859_8;
else if (strncasecmp(p,"iso-8859-9",10) == 0) code=CHRS_ISO_8859_9;
else if (strncasecmp(p,"koi8-r",6) == 0) code=CHRS_KOI8_R;
else if (strncasecmp(p,"koi8-u",6) == 0) code=CHRS_KOI8_U;
else if (strncasecmp(p,"macintosh",9) == 0) code=CHRS_MACINTOSH;
else if (strncasecmp(p,"Shift_JIS",9) == 0) code=CHRS_SJIS;
else if (strncasecmp(p,"utf-7",5) == 0) code=CHRS_UTF_7;
else if (strncasecmp(p,"utf-8",5) == 0) code=CHRS_UTF_8;
else if (strncasecmp(p,"viscii",6) == 0) code=CHRS_VISCII_11;
else if (strncasecmp(p,"x-cp424",7) == 0) code=CHRS_CP424;
else if (strncasecmp(p,"x-cp437",7) == 0) code=CHRS_CP437;
else if (strncasecmp(p,"x-cp850",7) == 0) code=CHRS_CP850;
else if (strncasecmp(p,"x-cp852",7) == 0) code=CHRS_CP852;
else if (strncasecmp(p,"x-cp862",7) == 0) code=CHRS_CP862;
else if (strncasecmp(p,"x-cp866",7) == 0) code=CHRS_CP866;
else if (strncasecmp(p,"x-cp895",7) == 0) code=CHRS_CP895;
else if (strncasecmp(p,"x-CN-GB",7) == 0) code=CHRS_GB;
else if (strncasecmp(p,"x-CN-Big5",9) == 0) code=CHRS_BIG5;
else if (strncasecmp(p,"x-EUC-jp",8) == 0) code=CHRS_EUC_JP;
else if (strncasecmp(p,"x-FIDOMAZ",9) == 0) code=CHRS_FIDOMAZOVIA;
else if (strncasecmp(p,"x-gb2312",8) == 0) code=CHRS_GB;
else if (strncasecmp(p,"x-HZ",4) == 0) code=CHRS_HZ;
else if (strncasecmp(p,"x-mac-roman",11) == 0) code=CHRS_MACINTOSH;
else if (strncasecmp(p,"x-MAZOVIA",9) == 0) code=CHRS_FIDOMAZOVIA;
else if (strncasecmp(p,"x-mik",5) == 0) code=CHRS_MIK_CYR;
else if (strncasecmp(p,"x-NEC-JIS",9) == 0) code=CHRS_NEC;
else if (strncasecmp(p,"x-Shift-JIS",11) == 0) code=CHRS_SJIS;
else if (strncasecmp(p,"x-sjis",6) == 0) code=CHRS_SJIS;
else if (strncasecmp(p,"x-tis620",8) == 0) code=CHRS_ISO_8859_11;
else if (strncasecmp(p,"x-x-big5",8) == 0) code=CHRS_BIG5;
else if (strncasecmp(p,"x-zW",4) == 0) code=CHRS_ZW;
/* only intended to be in Areas file. So we can try to found the
* from the values of chars in message itself */
else if (strncasecmp(p,"AUTODETECT",10) == 0) code=CHRS_AUTODETECT;
else if (strncasecmp(p,"default",7) == 0) code=CHRS_NOTSET;
else { code=CHRS_NOTSET; Syslog('+', "Unknown charset: %s",p); }
return code;
}
int readcharset(char *p)
{
int code;
if (!strchr(p, ';')) /* foolproof MSC96 */
return CHRS_NOTSET;
else if ((strcasestr(p,(char *)"text/plain")) && (strcasestr(p,(char *)"charset=")))
code=getcode(strcasestr(strchr(p,';'),(char *)"charset=")+8);
else if ((strcasestr(p,(char *)"text/html")) && (strcasestr(p,(char *)"charset=")))
code=getcode(strcasestr(strchr(p,';'),(char *)"charset=")+8);
else code=CHRS_NOTSET;
return code;
}
/* readchrs() is also used to read outcode in Areas file (if JE defined) */
int readchrs(char *p)
{
int code;
while (*p && isspace(*p)) p++;
if (strncasecmp(p,"8859",4) == 0) code=CHRS_ISO_8859_1;
/* for X-FTN-CODEPAGE: */
else if (strncasecmp(p,"437",3) == 0) code=CHRS_CP437;
else if (strncasecmp(p,"850",3) == 0) code=CHRS_CP850;
else if (strncasecmp(p,"Arabic",6) == 0) code=CHRS_ISO_8859_6;
else if (strncasecmp(p,"ASCII",5) == 0) code=CHRS_ASCII;
else if (strncasecmp(p,"BIG",3) == 0) code=CHRS_BIG5;
else if (strncasecmp(p,"CP 852",6) == 0) code=CHRS_CP852;
else if (strncasecmp(p,"CP424",5) == 0) code=CHRS_CP424;
else if (strncasecmp(p,"CP437",5) == 0) code=CHRS_CP437;
else if (strncasecmp(p,"CP850",5) == 0) code=CHRS_CP850;
else if (strncasecmp(p,"CP852",5) == 0) code=CHRS_CP852;
else if (strncasecmp(p,"CP862",5) == 0) code=CHRS_CP862;
else if (strncasecmp(p,"CP866",5) == 0) code=CHRS_CP866; /* ??? */
else if (strncasecmp(p,"CP895",5) == 0) code=CHRS_CP895;
else if (strncasecmp(p,"CP932",5) == 0) code=CHRS_SJIS;
else if (strncasecmp(p,"CP942",5) == 0) code=CHRS_SJIS;
else if (strncasecmp(p,"Cyrillic",8) == 0) code=CHRS_ISO_8859_5;
else if (strncasecmp(p,"EUC-JP",6) == 0) code=CHRS_EUC_JP;
else if (strncasecmp(p,"EUC-KR",6) == 0) code=CHRS_EUC_KR;
else if (strncasecmp(p,"EUC",3) == 0) code=CHRS_EUC_JP;
else if (strncasecmp(p,"FIDOMAZ",7) == 0) code=CHRS_FIDOMAZOVIA;
else if (strncasecmp(p,"GB",2) == 0) code=CHRS_GB;
else if (strncasecmp(p,"Greek",5) == 0) code=CHRS_ISO_8859_7;
else if (strncasecmp(p,"Hebrew",6) == 0) code=CHRS_ISO_8859_8;
else if (strncasecmp(p,"HZ",2) == 0) code=CHRS_HZ;
/* Some FTN programs are misconfigured and use "IBMPC 2" kludge
* for the local DOS charset, even if it is DOS cyrillic or other
* so we will assume defaultftnchar here
*/
else if (strncasecmp(p,"IBMPC",5) == 0) code=defaultftnchar;
else if (strncasecmp(p,"IBM",3) == 0) code=CHRS_CP437; /* "IBMPC 1" "IBMPC 2" "IBM CMP" */
else if (strncasecmp(p,"ISO-11",6) == 0) code=CHRS_ISO_11;
else if (strncasecmp(p,"ISO-2022-CN",11) == 0) code=CHRS_ISO_2022_CN;
else if (strncasecmp(p,"ISO-2022-KR",11) == 0) code=CHRS_ISO_2022_KR;
else if (strncasecmp(p,"ISO-2022-TW",11) == 0) code=CHRS_ISO_2022_TW;
else if (strncasecmp(p,"ISO-4",5) == 0) code=CHRS_ISO_4;
else if (strncasecmp(p,"ISO-60",6) == 0) code=CHRS_ISO_60;
else if (strncasecmp(p,"ISO-8859",8) == 0) code=CHRS_ISO_8859_1;
else if (strncasecmp(p,"JIS",3) == 0) code=CHRS_ISO_2022_JP; /* ??? - JE */
else if (strncasecmp(p,"Kanji",5) == 0) code=CHRS_ISO_2022_JP;
else if (strncasecmp(p,"KOI8-R",6) == 0) code=CHRS_KOI8_R;
else if (strncasecmp(p,"KOI8-U",6) == 0) code=CHRS_KOI8_U;
else if (strncasecmp(p,"KOI8",4) == 0) code=CHRS_KOI8_R;
else if (strncasecmp(p,"LATIN-0",7) == 0) code=CHRS_ISO_8859_15;
else if (strncasecmp(p,"LATIN1QP",8) == 0) code=CHRS_ISO_8859_1_QP;
else if (strncasecmp(p,"LATIN-1",7) == 0) code=CHRS_ISO_8859_1;
else if (strncasecmp(p,"Latin-2",7) == 0) code=CHRS_ISO_8859_2;
else if (strncasecmp(p,"Latin-3",7) == 0) code=CHRS_ISO_8859_3;
else if (strncasecmp(p,"Latin-4",7) == 0) code=CHRS_ISO_8859_4;
else if (strncasecmp(p,"Latin-5",7) == 0) code=CHRS_ISO_8859_9;
else if (strncasecmp(p,"Latin-6",7) == 0) code=CHRS_ISO_8859_10;
else if (strncasecmp(p,"MAC",3) == 0) code=CHRS_MACINTOSH;
else if (strncasecmp(p,"MIK",3) == 0) code=CHRS_MIK_CYR;
else if (strncasecmp(p,"MAZOVIA",7) == 0) code=CHRS_FIDOMAZOVIA;
else if (strncasecmp(p,"NEC",3) == 0) code=CHRS_NEC; /* ??? - JE */
else if (strncasecmp(p,"PC-8",4) == 0) code=CHRS_CP437;
else if (strncasecmp(p,"SJIS",4) == 0) code=CHRS_SJIS; /* ??? - JE */
else if (strncasecmp(p,"Thai",4) == 0) code=CHRS_ISO_8859_11;
else if (strncasecmp(p,"UJIS",4) == 0) code=CHRS_EUC_JP;
else if (strncasecmp(p,"UTF-7",5) == 0) code=CHRS_UTF_7;
else if (strncasecmp(p,"UTF-8",5) == 0) code=CHRS_UTF_8;
else if (strncasecmp(p,"VISCII",6) == 0) code=CHRS_VISCII_11;
else if (strncasecmp(p,"ZW",2) == 0) code=CHRS_ZW;
/* only intended to be in Areas file. So we can try to found the
* from the values of chars in message itself */
else if (strncasecmp(p,"AUTODETECT",10) == 0) code=CHRS_AUTODETECT;
else if (strncasecmp(p,"default",7) == 0) code=CHRS_NOTSET;
else { code=CHRS_NOTSET; Syslog('+', "Unknown CHRS: %s",p); }
return code;
/* if you know of other CHRS: values which are in use, let me know so I can
include them. Mail me to srtxg@chanae.alphanet.ch or srtxg (2:293/2219) */
}
char *getchrs(int code)
{
char *chrs=NULL;
if (code == CHRS_ASCII) chrs=(char *)"ASCII 2";
else if (code == CHRS_BIG5) chrs=(char *)"BIG5"; /* ??? */
else if (code == CHRS_CP424) chrs=(char *)"CP424"; /* ??? */
else if (code == CHRS_CP437) chrs=(char *)"IBMPC 2";
else if (code == CHRS_CP850) chrs=(char *)"CP850 2";
else if (code == CHRS_CP852) chrs=(char *)"CP852"; /* ??? */
else if (code == CHRS_CP862) chrs=(char *)"CP862"; /* ??? */
else if (code == CHRS_CP866) chrs=(char *)"CP866";
else if (code == CHRS_CP895) chrs=(char *)"CP895 2";
else if (code == CHRS_EUC_JP) chrs=(char *)"UJIS"; /* ??? */
else if (code == CHRS_EUC_KR) chrs=(char *)"EUC-KR"; /* ??? */
else if (code == CHRS_FIDOMAZOVIA) chrs=(char *)"FIDOMAZ 2";
else if (code == CHRS_GB) chrs=(char *)"GB"; /* ??? */
else if (code == CHRS_HZ) chrs=(char *)"HZ 2"; /* ??? */
else if (code == CHRS_ISO_2022_CN) chrs=(char *)"ISO-2022-CN"; /* ??? */
else if (code == CHRS_ISO_2022_JP) chrs=(char *)"JIS";
else if (code == CHRS_ISO_2022_KR) chrs=(char *)"ISO-2022-KR"; /* ??? */
else if (code == CHRS_ISO_2022_TW) chrs=(char *)"ISO-2022-TW"; /* ??? */
else if (code == CHRS_ISO_8859_1) chrs=(char *)"LATIN-1 2";
else if (code == CHRS_ISO_8859_1_QP) chrs=(char *)"LATIN-1 2";
else if (code == CHRS_ISO_8859_2) chrs=(char *)"Latin-2 3";
else if (code == CHRS_ISO_8859_3) chrs=(char *)"Latin-3 3";
else if (code == CHRS_ISO_8859_4) chrs=(char *)"Latin-4 3";
else if (code == CHRS_ISO_8859_5) chrs=(char *)"Cyrillic 3"; /* ??? */
else if (code == CHRS_ISO_8859_6) chrs=(char *)"Arabic 3"; /* ??? */
else if (code == CHRS_ISO_8859_7) chrs=(char *)"Greek 3"; /* ??? */
else if (code == CHRS_ISO_8859_8) chrs=(char *)"Hebrew 3"; /* ??? */
else if (code == CHRS_ISO_8859_9) chrs=(char *)"Latin-5 3";
else if (code == CHRS_ISO_8859_10) chrs=(char *)"Latin-6 3";
else if (code == CHRS_ISO_8859_11) chrs=(char *)"Thai 3";
else if (code == CHRS_ISO_8859_15) chrs=(char *)"LATIN-0 2";
else if (code == CHRS_KOI8_R) chrs=(char *)"KOI8-R"; /* ??? */
else if (code == CHRS_KOI8_U) chrs=(char *)"KOI8-U"; /* ??? */
else if (code == CHRS_MACINTOSH) chrs=(char *)"MAC 2";
else if (code == CHRS_MIK_CYR) chrs=(char *)"MIK-CYR";
else if (code == CHRS_NEC) chrs=(char *)"NEC-JIS"; /* ??? */
else if (code == CHRS_SJIS) chrs=(char *)"SJIS"; /* ??? */
else if (code == CHRS_UTF_7) chrs=(char *)"UTF-7";
else if (code == CHRS_UTF_8) chrs=(char *)"UTF-8";
else if (code == CHRS_VISCII_11) chrs=(char *)"VISCII 3";
else if (code == CHRS_ZW) chrs=(char *)"ZW"; /* ??? */
else chrs=NULL;
return chrs;
}
void writechrs(int code, FILE *pkt, int ispkt)
{
char *akludge,*endline,*chrs=NULL;
akludge = endline = NULL;
if (ispkt==0) {
akludge=(char *)"X-FTN-"; endline=(char *)"\n";
} else if (ispkt==1) {
akludge=(char *)"\1"; endline=(char *)"\r";
} else if (ispkt==2) {
akludge=(char *)"X-FTN-ORIG"; endline=(char *)"\n";
} else if (ispkt==3) {
akludge=(char *)"\1"; endline=(char *)"\n";
}
chrs=getchrs(code);
if (chrs) fprintf(pkt,"%sCHRS: %s%s",akludge,chrs,endline);
}

View File

@ -393,16 +393,6 @@ time_t parsefdate(char *, void *);
char *rfcdate(time_t);
/*
* Frome mime.c
*/
char *qp_decode(char *);
/* int=0 for text (normal mode), int=1 for headers and gatebau MSGID */
char *qp_encode(char *,int);
char *b64_decode(char *);
char *b64_encode(char *);
/*
* From rfcmsg.c
@ -433,233 +423,14 @@ char *bgets(char *, int, FILE *);
/*
* recognized charsets
*/
#define CHRS_AUTODETECT -1
#define CHRS_NOTSET 0
#define CHRS_ASCII 1 /* us-ascii */
#define CHRS_BIG5 2 /* Chinese Big5 charset */
#define CHRS_CP424 3 /* hebrew EBCDIC */
#define CHRS_CP437 4 /* Latin-1 MS codage (cp437) */
#define CHRS_CP850 5 /* Latin-1 MS codage (cp850) */
#define CHRS_CP852 6 /* Polish MS-DOS codage */
#define CHRS_CP862 7 /* Hebrew PC */
#define CHRS_CP866 8 /* Cyrillic Alt-PC (cp866) */
#define CHRS_CP895 9 /* Kamenicky (DOS charset in CZ & SK) */
#define CHRS_EUC_JP 10 /* Japanese EUC */
#define CHRS_EUC_KR 11 /* Korean EUC */
#define CHRS_FIDOMAZOVIA 12 /* Polish "FIDOMAZOVIA" charset */
#define CHRS_GB 13 /* Chinese GB 2312 8 bits */
#define CHRS_HZ 14 /* Chinese HZ coding */
#define CHRS_ISO_2022_CN 15 /* Chinese GB 2312 7 bits */
#define CHRS_ISO_2022_JP 16 /* Japanese iso-2022-jp */
#define CHRS_ISO_2022_KR 17 /* Korean iso-2022-kr */
#define CHRS_ISO_2022_TW 18 /* Taiwanese iso-2022-tw */
#define CHRS_ISO_8859_1 19 /* Latin-1, Western Europe, America */
#define CHRS_ISO_8859_1_QP 20
#define CHRS_ISO_8859_2 21 /* Latin-2, Eastern Europe */
#define CHRS_ISO_8859_3 22 /* Latin-3, Balkanics languages */
#define CHRS_ISO_8859_4 23 /* Latin-4, Scandinavian, Baltic */
#define CHRS_ISO_8859_5 24 /* Cyrillic (iso-8859-5) */
#define CHRS_ISO_8859_6 25 /* Arabic (iso-8859-6) */
#define CHRS_ISO_8859_7 26 /* Greek (iso-8859-7) */
#define CHRS_ISO_8859_8 27 /* Hebrew (iso-8859-8) */
#define CHRS_ISO_8859_9 28 /* Latin-5, Turkish */
#define CHRS_ISO_8859_10 29 /* Latin-6, Lappish/Nordic/Eskimo */
#define CHRS_ISO_8859_11 30 /* Thai (iso-8859-11, aka TIS620) */
#define CHRS_ISO_8859_15 31 /* Latin-0 (Latin-1 + a few letters) */
#define CHRS_KOI8_R 32 /* Cyrillic Koi8 (Russian) */
#define CHRS_KOI8_U 33 /* Cyrillic Koi8 (Ukranian) */
#define CHRS_MACINTOSH 34 /* Macintosh */
#define CHRS_MIK_CYR 35 /* Bulgarian "Mik" cyrillic charset */
#define CHRS_NEC 36 /* Japanese NEC-JIS charset */
#define CHRS_SJIS 37 /* Japanese Shift-JIS (MS codage) */
#define CHRS_UTF_7 38 /* Unicode in UTF-7 encoding */
#define CHRS_UTF_8 39 /* Unicode in UTF-8 encoding */
#define CHRS_VISCII_10 40 /* VISCII 1.0 */
#define CHRS_VISCII_11 41 /* VISCII 1.1 */
#define CHRS_ZW 42 /* Chinese Zw encoding */
#define CHRS_ISO_11 91
#define CHRS_ISO_4 92
#define CHRS_ISO_60 93
/*
* languages (used for LANG_DEFAULT definition)
*/
#define LANG_WEST 1 /* West-European languages */
#define LANG_EAST 2 /* East-Eurpean languages */
#define LANG_JAPAN 3 /* japanese */
#define LANG_KOREA 4 /* korean */
#define LANG_CHINA 5 /* chinese */
#define LANG_CYRILLIC 6 /* Cyrillic based languages */
/*
* Define these according to the values used in your country
*/
#define CHRS_DEFAULT_FTN CHRS_CP437
#define CHRS_DEFAULT_RFC CHRS_ISO_8859_1
#define LANG_DEFAULT LANG_WEST
#if (LANG_DEFAULT==LANG_JAPAN || LANG_DEFAULT==LANG_KOREA || LANG_DEFAULT==LANG_CHINA)
#define LANG_BITS 16
#else
#define LANG_BITS 8
#endif
/*
* used to recognize pgpsigned messages
*/
#define PGP_SIGNED_BEGIN "-----BEGIN PGP SIGNED MESSAGE-----"
#define PGP_SIG_BEGIN "-----BEGIN PGP SIGNATURE-----"
#define PGP_SIG_END "-----END PGP SIGNATURE-----"
/*
* charset reading functions
*/
int getoutcode(int);
int getincode(int);
char *getcharset(int);
char *getchrs(int);
int getcode(char *);
int readchrs(char *);
int readcharset(char *);
void writechrs(int,FILE *,int);
/*
* some special chars values
*/
#define NUL 0
#define NL 10
#define FF 12
#define CR 13
#define ESC 27
/* ************ general functions ************* */
char *hdrconv(char *, int, int);
char *hdrnconv(char *, int, int, int);
char *strnkconv(const char *, int, int, int);
char *strkconv(const char *, int, int);
void kconv(char *, char **, int, int);
/* ************ 8 bit charsets **************** */
void noconv(char *, char **);
void eight2eight(char *, char **, char *);
/*
* maptabs names
*/
#define CP424__CP862 "cp424__cp862"
#define CP424__ISO_8859_8 "cp424__iso-8859-8"
#define CP437__ISO_8859_1 "cp437__iso-8859-1"
#define CP437__MACINTOSH "cp437__mac"
#define CP850__ISO_8859_1 "cp437__iso-8859-1"
#define CP850__MACINTOSH "cp437__mac"
#define CP852__FIDOMAZOVIA "cp852__fidomazovia"
#define CP852__ISO_8859_2 "cp852__iso-8859-2"
#define CP862__CP424 "cp862__cp424"
#define CP862__ISO_8859_8 "cp862__iso-8859-8"
#define CP866__ISO_8859_5 "mik__iso-8859-5"
#define CP866__KOI8 "cp866__koi8"
#define CP895__CP437 "cp895__cp437"
#define CP895__ISO_8859_2 "cp895__iso-8859-2"
#define FIDOMAZOVIA__CP852 "fidomazovia__cp852"
#define FIDOMAZOVIA__ISO_8859_2 "fidomazovia__iso-8859-2"
#define ISO_11__ISO_8859_1 "iso-11__iso-8859-1"
#define ISO_4__ISO_8859_1 "iso-4__iso-8859-1"
#define ISO_60__ISO_8859_1 "iso-60__iso-8859-1"
#define ISO_8859_1__CP437 "iso-8859-1__cp437"
#define ISO_8859_1__MACINTOSH "iso-8859-1__mac"
#define ISO_8859_1__CP850 "iso-8859-1__cp437"
#define ISO_8859_2__CP852 "iso-8859-2__cp852"
#define ISO_8859_2__CP895 "iso-8859-2__cp895"
#define ISO_8859_2__FIDOMAZOVIA "iso-8859-2__fidomazovia"
#define ISO_8859_5__CP866 "iso-8859-5__mik"
#define ISO_8859_5__KOI8 "iso-8859-5__koi8"
#define ISO_8859_5__MIK_CYR "iso-8859-5__mik"
#define ISO_8859_8__CP424 "iso-8859-8__cp424"
#define ISO_8859_8__CP862 "iso-8859-8__cp862"
#define KOI8__CP866 "koi8__cp866"
#define KOI8__ISO_8859_5 "koi8__iso-8859-5"
#define KOI8__MIK_CYR "koi8__mik"
#define MACINTOSH__CP437 "mac__cp437"
#define MACINTOSH__CP850 "mac__cp437"
#define MACINTOSH__ISO_8859_1 "mac__iso-8859-1"
#define MIK_CYR__ISO_8859_5 "mik__iso-8859-5"
#define MIK_CYR__KOI8 "mik__koi8"
/* ??? */
int SkipESCSeq(FILE *, int, int *);
int getkcode(int, char [],char []);
int iso2022_detectcode(char *, int);
#define DOS
#define SPACE 0xA1A1 /* GB "space" symbol */
#define BOX 0xA1F5 /* GB "blank box" symbol */
#define isGB1(c) ((c)>=0x21 && (c)<=0x77) /* GB 1st byte */
#define isGB1U(c) ((c)>=0x78 && (c)<=0x7D) /* GB 1st byte unused*/
#define isGB2(c) ((c)>=0x21 && (c)<=0x7E) /* GB 2nd byte */
#define HI(code) (((code) & 0xFF00)>>8)
#define LO(code) ((code) & 0x00FF)
#define DB(hi,lo) ((((hi)&0xFF) << 8) | ((lo)&0xFF))
#define CLEAN7(c) ((c) & 0x7F) /* strip MSB */
#define notAscii(c) ((c)&0x80)
/* Chinese charsets */
void gb2hz(char *in, char **out);
void hz2gb(char *in, char **out);
void zw2hz(char *in, char **out);
void zw2gb(char *in, char **out);
#define SJIS1(A) ((A >= 129 && A <= 159) || (A >= 224 && A <= 239))
#define SJIS2(A) (A >= 64 && A <= 252)
#define HANKATA(A) (A >= 161 && A <= 223)
#define ISEUC(A) (A >= 161 && A <= 254)
#define ISMARU(A) (A >= 202 && A <= 206)
#define ISNIGORI(A) ((A >= 182 && A <= 196) || (A >= 202 && A <= 206))
void OPENINOUTFILES(FILE **, FILE **, char *);
void CLOSEINOUTFILES(FILE **, FILE **, char **);
void han2zen(FILE *, int *, int *, int);
void sjis2jis(int *, int *);
void jis2sjis(int *, int *);
/* ************ 16 bits charsets ************* */
/* japanese charsets */
void shift2seven(char *, char **, int, char [], char []);
void shift2euc(char *, char **, int, int);
void euc2seven(char *, char **, int, char [], char []);
void euc2euc(char *, char **, int, int);
void shift2shift(char *, char **, int, int);
void euc2shift(char *, char **, int, int);
void seven2shift(char *, char **);
void seven2euc(char *, char **);
void seven2seven(char *, char **, char [], char []);
void utf7_to_eight(char *, char **, int *);
void utf8_to_eight(char *, char **, int *);
// #define NUL 0
// #define NL 10
// #define FF 12
// #define CR 13
// #define ESC 27

View File

@ -362,7 +362,7 @@ faddr *parsefaddr(char *s)
}
}
if (strspn(p," ") != strlen(p))
freename = xstrcpy(qp_decode(p));
freename = xstrcpy(p);
}
tmpaddr=(faddr*)malloc(sizeof(faddr));
@ -411,7 +411,7 @@ char *ascinode(faddr *a, int fl)
}
if ((fl & 0x40) && (a->name)) {
f = qp_encode(a->name, 0);
f = a->name;
t = buf + strlen(buf);
skip = 0;
if ((!strchr(f,'@')) && ((strchr(f,BLANK_SUBS)) || (strchr(f,'.')) || (strchr(f,'_')))) {

View File

@ -1,268 +0,0 @@
/*****************************************************************************
*
* File ..................: mime.c
* Purpose ...............: Common library
* Last modification date : 25-Aug-2000
*
*****************************************************************************
* Copyright (C) 1997-2000
*
* 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, 675 Mass Ave, Cambridge, MA 02139, USA.
*****************************************************************************/
#include "../config.h"
#include "libs.h"
#include "memwatch.h"
#include "structs.h"
#include "clcomm.h"
#include "common.h"
/* QP-Decode code by T.Tanaka <tt@efnet.com> */
/* QP-Encode inspired from sendmail code of Berkley */
/* XD() converts hexadecimal digit to decimal */
#define XD(c) ( (((c) >= '0') && ((c) <= '9')) ? (c) - '0' : \
(((c) >= 'A') && ((c) <= 'F')) ? (c) - 'A' + 10 : \
(((c) >= 'a') && ((c) <= 'f')) ? (c) - 'a' + 10 : 0)
/* chars to be converted in qp_encode() */
char badchars[] = "\001\002\003\004\005\006\007" \
"\010\011\012\013\014\015\016\017" \
"\020\021\022\023\024\025\026\027" \
"\030\031\032\033\034\035\036\037" \
"\177" \
"\200\201\202\203\204\205\206\207" \
"\210\211\212\213\214\215\216\217" \
"\220\221\222\223\224\225\226\227" \
"\230\231\232\233\234\235\236\237" \
"\240\241\242\243\244\245\246\247" \
"\250\251\252\253\254\255\256\257" \
"\260\261\262\263\264\265\266\267" \
"\270\271\272\273\274\275\276\277" \
"\300\301\302\303\304\305\306\307" \
"\310\311\312\313\314\315\316\317" \
"\320\321\322\323\324\325\326\327" \
"\330\331\332\333\334\335\336\337" \
"\340\341\342\343\344\345\346\347" \
"\350\351\352\353\354\355\356\357" \
"\360\361\362\363\364\365\366\367" \
"\370\371\372\373\374\375\376\377";
char badchars2[] = "!\"#$@[\\]^`{|}~()<>,;:/_";
char Base16Code[] = "0123456789ABCDEF";
char Base64Code[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/* returns numeric value from a Base64Code[] digit */
static int index_hex[128] = {
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1,0x3e, -1, -1, -1,0x3f,
0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,
0x3c,0x3d, -1, -1, -1, -1, -1, -1,
-1,0x00,0x01,0x02,0x03,0x04,0x05,0x06,
0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
0x0f,0x10,0x11,0x12,0x13,0x14,0x15,0x16,
0x17,0x18,0x19, -1, -1, -1, -1, -1,
-1,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20,
0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,0x30,
0x31,0x32,0x33, -1, -1, -1, -1, -1
};
char *qp_decode(char *s)
{
static char *buf;
char *p, *q;
if (buf)
free(buf);
if ((buf = malloc(strlen(s) + 1 * sizeof(char))) == NULL) {
WriteError("qp_decode: out of memory:string too long:\"%s\"", s);
return s;
}
for (p = s, q = buf; *p != '\0';) {
if (*p == '=') {
++p;
if (*p == '\0') { /* ends with "=(null)" */
*q++ = '=';
break;
} else if (*p == '\n')
break;
else if (isxdigit(*p) && isxdigit(*(p + 1))) {
*q++ = 16 * XD(*p) + XD(*(p + 1));
++p;
++p;
} else { /* "=1x" "=5(null)" "=G\n" "=0=" etc. */
*q++ = '=';
*q++ = *p++;
}
} else
*q++ = *p++;
}
*q = '\0';
return buf;
}
char *qp_encode(char *s, int mode)
{
static char *buf;
char *p, *q;
int linelen = 0;
if (buf)
free(buf);
if ((buf = malloc(3 * strlen(s) + 1 * sizeof(char))) == NULL) {
WriteError("qp_encode: out of memory:string too long:\"%s\"", s);
return s;
}
for (p = s, q = buf; *p != '\0';) {
if (*p == '\n') {
*q++ = *p++;
linelen = 0;
} else if ((mode == 1) && (*p == ' ')) {
*q++ = '_';
p++;
linelen += 1;
} else if (*p == ' ' || *p == '\t') {
if ((linelen > 72) && (*(p+1) != '\n')) {
*q++ = *p++;
*q++ = '=';
*q++ = '\n';
linelen = 0;
} else if (*(p+1) == '\n') {
*q++ = *p++;
*q++ = '=';
*q++ = *p++;
linelen = 0;
} else {
*q++ = *p++;
linelen += 1;
}
} else if ((strchr(badchars,*p)) || (*p == '=') || ((mode==1) && (strchr(badchars2,*p)))) {
if (linelen > 72) {
*q++ = '\n';
linelen = 0;
}
*q++ = '=';
*q++ = Base16Code[(*p >> 4) & 0x0f];
*q++ = Base16Code[*p & 0x0f];
linelen += 3;
p++;
} else {
*q++ = *p++;
linelen++;
}
}
*q = '\0';
return buf;
}
/*
* Base64 stores 3 bytes of 8bits into 4 bytes of six bits (the 2 remaining
* bits are left to 0).
*
* AAAAAAAA BBBBBBBB CCCCCCCC --> 00AAAAAA 00AABBBB 00BBBBCC 00CCCCCC
*
*/
char *b64_decode(char *s)
{
static char *buf;
static char buf2[4];
char *p, *q;
int i,t;
if (buf)
free(buf);
if ((buf = malloc(3 * strlen(s) + 1 * sizeof(char))) == NULL) {
WriteError("b64_decode:out of memory:string too long:\"%s\"", s);
return s;
}
for (p = s, q = buf; *p != '\0';) {
for (i = 0; i < 4; i++)
buf2[i]=0x40;
for (i = 0;((i < 4) && (*p != '\0'));) {
t = (index_hex[(unsigned int)*p]);
if (*p == '=')
buf2[i++]=0x40;
else if (t != -1)
buf2[i++]=(char)t;
p++;
}
if ((buf2[0] < 0x40) && (buf2[1] < 0x40))
*q++=(((buf2[0] & 0x3f) << 2) | ((buf2[1] >> 4) & 0x03));
if ((buf2[1] < 0x40) && (buf2[2] < 0x40))
*q++=(((buf2[1] & 0x0f) << 4) | ((buf2[2] >> 2) & 0x0f));
if ((buf2[2] < 0x40) && (buf2[3] < 0x40))
*q++=(((buf2[2] & 0x03) << 6) | (buf2[3] & 0x3f));
}
*q = '\0';
return buf;
}
char *b64_encode(char *s)
{
static char *buf;
static char buf2[3];
char *p, *q;
int i;
if (buf)
free(buf);
if ((buf = malloc(3 * strlen(s) + 1 * sizeof(char))) == NULL) {
WriteError("b64_encode:out of memory:string too long:\"%s\"", s);
return s;
}
for (p = s, q = buf; *p != '\0';) {
for (i = 0; ((i < 3) && (*p != '\0')); )
buf2[i++] = *p++;
*q++=Base64Code[((buf2[0] >> 2) & 0x3f)];
*q++=Base64Code[(((buf2[0] & 0x03) << 4) | ((buf2[1] >> 4) & 0x0f))];
if (i<2)
*q++='=';
else
*q++=Base64Code[(((buf2[1] & 0x0f) << 2) | ((buf2[2] >> 6) & 0x03))];
if (i<3)
*q++='=';
else
*q++=Base64Code[(buf2[2] & 0x3f)];
}
*q = '\0';
return buf;
}

View File

@ -242,8 +242,8 @@ int CheckEchoGroup(char *Area, int SendUplink, faddr *f)
msgs.NetReply = mgroup.NetReply;
msgs.Active = TRUE;
msgs.Quotes = mgroup.Quotes;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
tag = tl(tag);
for (i = 0; i < strlen(tag); i++)

View File

@ -308,20 +308,18 @@ void Send(int newsmode, char *outstr)
int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int flags, FILE *pkt)
{
int rrq, result = 1, modtype = 0;
int incode = CHRS_NOTSET, outcode = CHRS_NOTSET;
int waskludge = FALSE, badkludge, pgpsigned = FALSE;
int waskludge = FALSE, badkludge;
int bNeedToGetAddressFromMsgid = (int)NULL;
int newsmode = 0, lines, pass, count, first;
char *newsgroup = NULL, *distribution = NULL, *moderator = NULL;
char *temp, *p, *q, *r, *l, *b;
char *To = NULL, buf[4096], *charset, c;
char *To = NULL, buf[4096], c;
time_t now;
rfcmsg *kmsg = NULL, **tmsg, *qmsg, *msg = NULL;
off_t endmsg_off, tear_off, orig_off, via_off;
faddr *o, *bestaka, *ta, *tfaddr;
FILE *fp;
fa_list *rlist, *tfa, *ftnpath = NULL;
int dirtyoutcode = CHRS_NOTSET;
struct utsname utsbuf;
char MailFrom[128], MailTo[128];
@ -416,9 +414,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if (waskludge && (isspace(buf[0])))
fputs("\n",fp); /* first body line is not RFC hdr */
waskludge=0;
if (!strncmp(buf,PGP_SIGNED_BEGIN, strlen(PGP_SIGNED_BEGIN)))
pgpsigned = TRUE;
else if ((!strncmp(buf,"---",3)) && ((buf[3] == '\r') || (buf[3] == ' ') || (buf[3] == '\n'))) {
if ((!strncmp(buf,"---",3)) && (buf[3] != '-')) {
tear_off=ftell(fp);
if ((hdr((char *)"Tearline",kmsg) == NULL)) {
*tmsg=(rfcmsg *)malloc(sizeof(rfcmsg));
@ -523,46 +519,46 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
bestaka = bestaka_s(f);
rewind(fp);
p = hdr((char *)"CHRS", kmsg);
if (p == NULL)
p = hdr((char *)"CHARSET", kmsg);
if (p == NULL)
p = hdr((char *)"CODEPAGE", kmsg);
if (p)
outcode = readchrs(p);
else {
p=hdr((char *)"Content-Type",msg);
if (p == NULL)
p=hdr((char *)"RFC-Content-Type",kmsg);
if (p == NULL)
p=hdr((char *)"Content-Type",kmsg);
if (p)
outcode=readcharset(p);
else {
q = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
(hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
(hdr((char *)"ORIGID",kmsg)) || ((hdr((char *)"MSGID",kmsg)) && (!chkftnmsgid(q))))
outcode = defaultrfcchar;
else
outcode = defaultftnchar;
if (q)
free(q);
q = NULL;
}
}
// p = hdr((char *)"CHRS", kmsg);
// if (p == NULL)
// p = hdr((char *)"CHARSET", kmsg);
// if (p == NULL)
// p = hdr((char *)"CODEPAGE", kmsg);
// if (p)
// outcode = readchrs(p);
// else {
// p=hdr((char *)"Content-Type",msg);
// if (p == NULL)
// p=hdr((char *)"RFC-Content-Type",kmsg);
// if (p == NULL)
// p=hdr((char *)"Content-Type",kmsg);
// if (p)
// outcode=readcharset(p);
// else {
// q = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
// if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
// (hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
// (hdr((char *)"ORIGID",kmsg)) || ((hdr((char *)"MSGID",kmsg)) && (!chkftnmsgid(q))))
// outcode = defaultrfcchar;
// else
// outcode = defaultftnchar;
// if (q)
// free(q);
// q = NULL;
// }
// }
/*
* A hack for TerMail
*/
p = hdr((char *)"PID", kmsg);
if ((p) && (!strncmp(p, "TerMail", 7)) && (outcode == defaultrfcchar))
outcode = defaultftnchar;
// p = hdr((char *)"PID", kmsg);
// if ((p) && (!strncmp(p, "TerMail", 7)) && (outcode == defaultrfcchar))
// outcode = defaultftnchar;
if (dirtyoutcode != CHRS_NOTSET)
outcode = dirtyoutcode;
if (pgpsigned)
incode = outcode;
// if (dirtyoutcode != CHRS_NOTSET)
// outcode = dirtyoutcode;
// if (pgpsigned)
// incode = outcode;
if (kmsg && !strcmp(kmsg->key,"AREA")) {
/*
@ -585,20 +581,20 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
newsmode = FALSE;
Syslog('m', "Got %s message", newsmode?"echo":"netmail");
if ((outcode == CHRS_NOTSET) && (hdr((char *)"MSGID", kmsg))) {
p = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
(hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
(hdr((char *)"ORIGID",kmsg)) || ((hdr((char *)"MSGID",kmsg)) && (!chkftnmsgid(p))))
outcode = defaultrfcchar;
else
outcode = defaultftnchar;
free(p);
}
if (pgpsigned)
incode = outcode;
else if (incode == CHRS_NOTSET)
incode = getincode(outcode);
// if ((outcode == CHRS_NOTSET) && (hdr((char *)"MSGID", kmsg))) {
// p = rfcmsgid(hdr((char *)"MSGID",kmsg),bestaka);
// if ((hdr((char *)"Message-ID",msg)) || (hdr((char *)"RFC-Message-ID",kmsg)) ||
// (hdr((char *)"Message-ID",kmsg)) || (hdr((char *)"RFCID",kmsg)) ||
// (hdr((char *)"ORIGID",kmsg)) || ((hdr((char *)"MSGID",kmsg)) && (!chkftnmsgid(p))))
// outcode = defaultrfcchar;
// else
// outcode = defaultftnchar;
// free(p);
// }
// if (pgpsigned)
// incode = outcode;
// else if (incode == CHRS_NOTSET)
// incode = getincode(outcode);
/*
@ -857,7 +853,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if (p == NULL)
p=hdr((char *)"To",msg);
if ((p) && (strcasecmp(p,"All\n"))) {
sprintf(temp,"X-Comment-To:%s",hdrconv(p,outcode,incode));
sprintf(temp,"X-Comment-To:%s", p);
Send(newsmode, temp);
} else {
if (p == NULL)
@ -867,10 +863,10 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if (p == NULL)
p=hdr((char *)"RFC-To",kmsg);
if ((p) && (strcasecmp(p,"All\n"))) {
sprintf(temp,"X-Comment-To: %s",hdrconv(p,outcode,incode));
sprintf(temp,"X-Comment-To: %s", p);
Send(newsmode, temp);
} else if ((t) && (t->name) && (strcasecmp(t->name,"All"))) {
sprintf(temp,"X-Comment-To: %s\n",hdrconv(t->name,outcode,incode));
sprintf(temp,"X-Comment-To: %s\n", t->name);
Send(newsmode, temp);
} else {
sprintf(temp,"X-Comment-To: All\n");
@ -991,22 +987,22 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
if ((p = hdr((char *)"From",msg))) {
sprintf(temp, "From:%s", hdrconv(p,outcode,incode));
sprintf(temp, "From:%s", p);
Send(newsmode, temp);
} else if ((p = hdr((char *)"RFC-From",kmsg))) {
Syslog('m', "b");
sprintf(temp, "From: %s", hdrconv(p,outcode,incode));
sprintf(temp, "From: %s", p);
Send(newsmode, temp);
} else if ((p = hdr((char *)"From\n",kmsg))) {
Syslog('m', "c");
sprintf(temp, "From: %s", hdrconv(p,outcode,incode));
sprintf(temp, "From: %s", p);
Send(newsmode, temp);
} else if ((p = hdr((char *)"X-PcBoard-FROM",msg))) {
if (f->name) {
while (isspace(*p))
p++;
p[strlen(p)-1] = '\0';
sprintf(temp,"From: %s <%s>\n", hdrconv(f->name,outcode,incode), p);
sprintf(temp,"From: %s <%s>\n", f->name, p);
} else {
sprintf(temp,"From:%s\n", p);
}
@ -1035,12 +1031,12 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
*r--='\0';
}
Syslog('m', "d");
sprintf(temp,"From: \"%s\" <%s>\n",hdrconv(l,outcode,incode),p);
sprintf(temp,"From: \"%s\" <%s>\n", l, p);
Send(newsmode, temp);
free(q);
} else if (f->name) {
Syslog('m', "e");
sprintf(temp,"From: \"%s\" <%s>\n",hdrconv(f->name,outcode,incode),p);
sprintf(temp,"From: \"%s\" <%s>\n", f->name, p);
Send(newsmode, temp);
} else {
Syslog('m', "f");
@ -1051,9 +1047,9 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
if (p)
sprintf(temp,"X-FTN-Sender: %s\n",hdrconv(ascinode(f,0xff),outcode,incode));
sprintf(temp,"X-FTN-Sender: %s\n", ascinode(f,0xff));
else
sprintf(temp,"From: %s\n",hdrconv(ascinode(f,0xff),outcode,incode));
sprintf(temp,"From: %s\n", ascinode(f,0xff));
Send(newsmode, temp);
if ((p=hdr((char *)"Reply-To",msg))) {
@ -1117,15 +1113,15 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
if ((p = hdr((char *)"Subject",msg)))
sprintf(temp, "Subject:%s", hdrconv(p,outcode,incode));
sprintf(temp, "Subject:%s", p);
else if ((p = hdr((char *)"RFC-Subject",kmsg)))
sprintf(temp, "Subject: %s", hdrconv(p,outcode,incode));
sprintf(temp, "Subject: %s", p);
else if ((p = hdr((char *)"Subject",kmsg)))
sprintf(temp, "Subject: %s", hdrconv(p,outcode,incode));
sprintf(temp, "Subject: %s", p);
else if ((p = hdr((char *)"X-PcBoard-SUBJECT",msg)))
sprintf(temp, "Subject:%s", hdrconv(p,outcode,incode));
sprintf(temp, "Subject:%s", p);
else if (subj && (strspn(subj," \t\n\r") != strlen(subj)))
sprintf(temp, "Subject: %s\n", hdrconv(subj,outcode,incode));
sprintf(temp, "Subject: %s\n", subj);
else
sprintf(temp, "Subject: <none>\n");
Send(newsmode, temp);
@ -1200,25 +1196,25 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
if ((p=hdr((char *)"Organization",msg))) {
sprintf(temp,"Organization:%s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization:%s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"Organisation",msg))) {
sprintf(temp,"Organization:%s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization:%s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"RFC-Organization",kmsg))) {
sprintf(temp,"Organization: %s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization: %s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"RFC-Organisation",kmsg))) {
sprintf(temp,"Organization: %s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization: %s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"Organization",kmsg))) {
sprintf(temp,"Organization: %s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization: %s",p);
Send(newsmode, temp);
} else if ((p=hdr((char *)"Organisation",kmsg))) {
sprintf(temp,"Organization: %s",hdrconv(p,outcode,incode));
sprintf(temp,"Organization: %s",p);
Send(newsmode, temp);
} else if (origline) {
sprintf(temp,"Organization: %s\n",hdrconv(origline,outcode,incode));
sprintf(temp,"Organization: %s\n",origline);
Send(newsmode, temp);
}
@ -1256,13 +1252,13 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
}
sprintf(temp, "X-FTN-CHRS: %s\n", getchrs(incode));
Send(newsmode, temp);
if (incode != outcode) {
sprintf(temp, "X-FTN-ORIGCHRS: %s\n", getchrs(outcode));
Send(newsmode, temp);
}
charset = getcharset(incode);
// sprintf(temp, "X-FTN-CHRS: %s\n", getchrs(incode));
// Send(newsmode, temp);
// if (incode != outcode) {
// sprintf(temp, "X-FTN-ORIGCHRS: %s\n", getchrs(outcode));
// Send(newsmode, temp);
// }
// charset = getcharset(incode);
if ((p=hdr((char *)"Mime-Version",msg))) {
sprintf(temp,(char *)"Mime-Version:%s",p);
@ -1273,9 +1269,9 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
} else if ((p=hdr((char *)"Mime-Version",kmsg))) {
sprintf(temp,(char *)"Mime-Version: %s",p);
Send(newsmode, temp);
} else if ((charset) && (incode != CHRS_NOTSET)) {
sprintf(temp,"Mime-Version: 1.0\n");
Send(newsmode, temp);
// } else if ((charset) && (incode != CHRS_NOTSET)) {
// sprintf(temp,"Mime-Version: 1.0\n");
// Send(newsmode, temp);
}
if ((p=hdr((char *)"Content-Type",msg))) {
@ -1287,12 +1283,12 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
} else if ((p=hdr((char *)"Content-Type",kmsg))) {
sprintf(temp,"Content-Type: %s",p);
Send(newsmode, temp);
} else if ((charset) && (incode != CHRS_NOTSET)) {
if ((p=hdr((char *)"FSCHTML",kmsg)) || (p=hdr((char *)"HTML",kmsg)))
sprintf(temp,"Content-Type: text/html; charset=%s\n",charset);
else
sprintf(temp,"Content-Type: text/plain; charset=%s\n",charset);
Send(newsmode, temp);
// } else if ((charset) && (incode != CHRS_NOTSET)) {
// if ((p=hdr((char *)"FSCHTML",kmsg)) || (p=hdr((char *)"HTML",kmsg)))
// sprintf(temp,"Content-Type: text/html; charset=%s\n",charset);
// else
// sprintf(temp,"Content-Type: text/plain; charset=%s\n",charset);
// Send(newsmode, temp);
}
if ((p=hdr((char *)"Content-Length",msg))) {
@ -1313,16 +1309,16 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
sprintf(temp,"Content-Transfer-Encoding: %s",p);
else if ((p=hdr((char *)"Content-Transfer-Encoding",kmsg)))
sprintf(temp,"Content-Transfer-Encoding: %s",p);
else if ((charset) && (incode == CHRS_ISO_8859_1_QP))
sprintf(temp,"Content-Transfer-Encoding: quoted-printable\n");
else if ((charset) && (incode != CHRS_NOTSET)) {
if ((incode == CHRS_ASCII || incode == CHRS_UTF_7))
sprintf(temp,"Content-Transfer-Encoding: 7bit\n");
else if (strncasecmp(charset,"iso-2022-",9) == 0)
sprintf(temp,"Content-Transfer-Encoding: 7bit\n");
else
sprintf(temp,"Content-Transfer-Encoding: 8bit\n"); /* all others are 8 bit */
}
// else if ((charset) && (incode == CHRS_ISO_8859_1_QP))
// sprintf(temp,"Content-Transfer-Encoding: quoted-printable\n");
// else if ((charset) && (incode != CHRS_NOTSET)) {
// if ((incode == CHRS_ASCII || incode == CHRS_UTF_7))
// sprintf(temp,"Content-Transfer-Encoding: 7bit\n");
// else if (strncasecmp(charset,"iso-2022-",9) == 0)
// sprintf(temp,"Content-Transfer-Encoding: 7bit\n");
// else
// sprintf(temp,"Content-Transfer-Encoding: 8bit\n"); /* all others are 8 bit */
// }
if (temp[0])
Send(newsmode, temp);
@ -1388,7 +1384,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
strcasecmp(qmsg->key,"Distribution") &&
strcasecmp(qmsg->key,"Approved") &&
strcasecmp(qmsg->key,"Message-ID")) {
sprintf(temp,"%s:%s",qmsg->key,hdrconv(qmsg->val,outcode,incode));
sprintf(temp,"%s:%s",qmsg->key,qmsg->val);
Send(newsmode, temp);
}
}
@ -1468,16 +1464,16 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
strcasecmp(qmsg->key,"RFC-Approved") &&
strcasecmp(qmsg->key,"RFC-Message-ID")) {
if (!strncmp(qmsg->key,"RFC-",4)) {
sprintf(temp,"%s: %s",qmsg->key+4,hdrconv(qmsg->val,outcode,incode));
sprintf(temp,"%s: %s",qmsg->key+4,qmsg->val);
Send(newsmode, temp);
} else if ((!strncasecmp(qmsg->key,"X-",2)) || (!strncasecmp(qmsg->key,"NNTP-",5))) {
sprintf(temp,"%s: %s",qmsg->key,hdrconv(qmsg->val,outcode,incode));
sprintf(temp,"%s: %s",qmsg->key,qmsg->val);
Send(newsmode, temp);
} else if ((!strncasecmp(qmsg->key,"ZC-",3))) {
sprintf(temp,"X-%s: %s",qmsg->key,qmsg->val);
Send(newsmode, temp);
} else if ((!strcasecmp(qmsg->key,"Origin")) || (!strcasecmp(qmsg->key,"MOOD"))) {
sprintf(temp,"X-FTN-%s: %s",qmsg->key,hdrconv(qmsg->val,outcode,incode));
sprintf(temp,"X-FTN-%s: %s",qmsg->key,qmsg->val);
Send(newsmode, temp);
} else {
sprintf(temp,"X-FTN-%s: %s",qmsg->key,qmsg->val);
@ -1560,7 +1556,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
if ((p=hdr((char *)"X-Body-Start",msg))) {
lines++;
q = xstrcpy(strkconv(p, outcode, incode));
q = xstrcpy(p);
Send(newsmode, q);
free(q);
}
@ -1578,7 +1574,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
case ' ': b=p-1; break;
case '\n': b=NULL; count=0; lines++; break;
}
if ((count++ > BOUNDARY) && (!pgpsigned)) {
if ((count++ > BOUNDARY) /* && (!pgpsigned) */ ) {
if (b) {
// *b++='\r';
// *b = '\n';
@ -1592,7 +1588,7 @@ int ftn2rfc(faddr *f, faddr *t, char *subj, char *origline, time_t mdate, int fl
}
}
if (strncmp(buf, ".\r\n", 3))
q = xstrcpy(strkconv(buf, outcode, incode));
q = xstrcpy(buf);
else
q = xstrcpy((char *)" .\n");
Send(newsmode, q);

View File

@ -678,8 +678,8 @@ int Areas(void)
msgs.Type = ECHOMAIL;
msgs.MsgKinds = PUBLIC;
msgs.UsrDelete = TRUE;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
strcpy(msgs.Origin, CFG.origin);
}

View File

@ -121,7 +121,7 @@ int ftnmsgid(char *msgid, char **s, unsigned long *n, char *areaname)
r = strrchr(l+6,'_');
if (r)
*r++ = '\0';
*s = xstrcpy(qp_decode(l+6));
*s = xstrcpy(l+6);
if (r)
sscanf(r,"%lx",&nid);
ftnorigin = 1;
@ -209,11 +209,10 @@ int ftnmsgid(char *msgid, char **s, unsigned long *n, char *areaname)
ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *recipient)
ftnmsg *mkftnhdr(rfcmsg *msg, int newsmode, faddr *recipient)
{
char *freename = NULL, *rfcfrom = NULL, *p, *q, *l, *r;
char *fbuf = NULL;
char *ftnfrom=NULL;
char *fbuf = NULL, *ftnfrom=NULL;
static ftnmsg *tmsg;
int needreplyaddr = 1;
faddr *tmp, *tmp2;
@ -268,7 +267,6 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
}
if (*l) {
strcpy(l,hdrnconv(l,incode,outcode,MAXNAME));
if (strlen(l) > MAXNAME)
l[MAXNAME]='\0';
free(tmsg->to->name);
@ -380,12 +378,12 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
p = freename + strlen(freename) -1;
while ((isspace(*p)) || (*p == '\n'))
*(p--)='\0';
strcpy(freename, hdrconv(freename, incode, outcode));
if ((*freename == '\"') && (*(p=freename+strlen(freename)-1) == '\"')) {
freename++;
*p='\0';
}
}
// if (*freename == '\0') freename=rfcfrom;
if ((!freename) || ((freename) && (*freename == '\0')) || (strcmp(freename,".")==0))
freename=rfcfrom;
@ -492,11 +490,6 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
if (p) {
while (isspace(*p))
p++;
/*
* charset conversion for subject line is done in message.c
* here we only convert quoted-printable and base64 to 8 bit
*/
tmsg->subj = xstrcpy(hdrnconv(p, 0, 0, MAXSUBJ));
tmsg->subj = xstrcpy(p);
if (*(p=tmsg->subj+strlen(tmsg->subj)-1) == '\n')
*p='\0';
@ -513,8 +506,10 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
tmsg->flags |= M_RRQ;
if (hdr((char *)"Notice-Requested-Upon-Delivery-To",msg))
tmsg->flags |= M_RRQ;
if (!newsmode)
if (!newsmode) {
tmsg->flags |= M_PVT;
tmsg->flags |= M_KILLSENT;
}
if ((p = hdr((char *)"X-Origin-Date",msg)))
tmsg->date = parsedate(p, NULL);
@ -585,7 +580,7 @@ ftnmsg *mkftnhdr(rfcmsg *msg, int incode, int outcode, int newsmode, faddr *reci
if (p) {
while (isspace(*p))
p++;
tmsg->origin = xstrcpy(hdrconv(p, incode, outcode));
tmsg->origin = xstrcpy(p);
if (tmsg->origin)
if (*(p = tmsg->origin + strlen(tmsg->origin)-1) == '\n')
*p='\0';

View File

@ -3,7 +3,7 @@
int ftnmsgid(char *,char **,unsigned long *,char *);
ftnmsg *mkftnhdr(rfcmsg *, int, int, int, faddr *);
ftnmsg *mkftnhdr(rfcmsg *, int, faddr *);
#endif

View File

@ -94,7 +94,7 @@ void Msg_Pid(void)
temp = calloc(81, sizeof(char));
sprintf(temp, "\001PID: MBSE-FIDO %s", VERSION);
MsgText_Add2(temp);
sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
// sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
tt = time(NULL);
sprintf(temp, "\001TZUTC: %s", gmtoffset(tt));
MsgText_Add2(temp);

View File

@ -196,8 +196,8 @@ void Post(char *To, long Area, char *Subj, char *File, char *Flavor)
Msg.ReplyCRC = 0xffffffff;
sprintf(temp, "\001PID: MBSE-FIDO %s", VERSION);
MsgText_Add2(temp);
sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
MsgText_Add2(temp);
// sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
// MsgText_Add2(temp);
sprintf(temp, "\001TZUTC: %s", gmtoffset(tt));
MsgText_Add2(temp);

View File

@ -68,7 +68,6 @@ static int removesupersedes;
static int removeapproved;
static int removereplyto;
static int removereturnto;
static int dirtyoutcode = CHRS_NOTSET;
@ -135,15 +134,15 @@ int kludgewrite(char *s, FILE *fp)
int rfc2ftn(FILE *fp, faddr *recipient)
{
char sbe[16], *p, *q, *temp, *origin, newsubj[4 * (MAXSUBJ+1)], *oldsubj, *acup_a = NULL;
int i, rc, incode, outcode, pgpsigned, newsmode, seenlen, oldnet;
int i, rc, newsmode, seenlen, oldnet;
rfcmsg *msg = NULL, *tmsg, *tmp;
ftnmsg *fmsg = NULL;
FILE *ofp;
fa_list *sbl = NULL, *ptl = NULL, *tmpl;
faddr *ta, *fta;
unsigned long svmsgid, svreply, acup_n = 0;
int sot_kludge = FALSE, eot_kludge = FALSE, qp_or_base64 = FALSE, tinyorigin = FALSE;
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders, html_message = FALSE;
int sot_kludge = FALSE, eot_kludge = FALSE, tinyorigin = FALSE;
int needsplit, hdrsize, datasize, splitpart, forbidsplit, rfcheaders;
time_t Now;
temp = calloc(4097, sizeof(char));
@ -158,8 +157,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
// Syslog('m', "========== RFC end");
// rewind(fp);
msg = parsrfc(fp);
incode = outcode = CHRS_NOTSET;
pgpsigned = FALSE;
newsmode = hdr((char *)"Newsgroups", msg) ?TRUE:FALSE;
Syslog('m', "RFC message is %s", newsmode ? "news article":"e-mail message");
@ -169,30 +166,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
else
email_in++;
p = hdr((char *)"Content-Type",msg);
if (p)
incode = readcharset(p);
if (incode == CHRS_NOTSET) {
p = hdr((char *)"X-FTN-CHRS",msg);
if (p == NULL)
p = hdr((char *)"X-FTN-CHARSET", msg);
if (p == NULL)
p = hdr((char *)"X-FTN-CODEPAGE", msg);
if (p)
incode = readchrs(p);
}
if ((p = hdr((char *)"Content-Type",msg)) && ((strcasestr(p,(char *)"multipart/signed")) ||
(strcasestr(p,(char *)"application/pgp")))) {
pgpsigned = TRUE;
outcode = incode;
} else if ((p = hdr((char *)"X-FTN-ORIGCHRS", msg)))
outcode = readchrs(p);
else if (dirtyoutcode != CHRS_NOTSET)
outcode = dirtyoutcode;
else
outcode = getoutcode(incode);
if (!CFG.allowcontrol) {
if (hdr((char *)"Control",msg)) {
Syslog('+', "Control message skipped");
@ -201,7 +174,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
}
}
if ((fmsg = mkftnhdr(msg, incode, outcode, newsmode, recipient)) == NULL) {
if ((fmsg = mkftnhdr(msg, newsmode, recipient)) == NULL) {
WriteError("Unable to create FTN headers from RFC ones, aborting");
tidyrfc(msg);
return 1;
@ -229,20 +202,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
}
}
if (incode == CHRS_NOTSET && newsmode)
incode = msgs.Rfccode;
if (outcode == CHRS_NOTSET) {
if (newsmode)
outcode = msgs.Ftncode;
else
outcode = CHRS_DEFAULT_FTN;
}
if ((incode == CHRS_NOTSET) && (hdr((char *)"Message-ID",msg))) {
if (chkftnmsgid(hdr((char *)"Message-ID",msg)))
incode = CHRS_DEFAULT_FTN;
else
incode = CHRS_DEFAULT_RFC;
}
chkftnmsgid(hdr((char *)"Message-ID",msg)); // ??
removemime = FALSE;
removemsgid = FALSE;
removeref = FALSE;
@ -252,10 +212,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
removereplyto = TRUE;
removereturnto = TRUE;
ftnorigin = fmsg->ftnorigin;
if ((hdr((char *)"X-PGP-Signed",msg)))
pgpsigned = TRUE;
if (pgpsigned)
Syslog('m', "pgpsigned = %s", pgpsigned ? "True":"False");
q = hdr((char *)"Content-Transfer-Encoding",msg);
if (q)
@ -268,38 +224,14 @@ int rfc2ftn(FILE *fp, faddr *recipient)
p++;
/*
* turn the quoted-printable decode mode on; remember FTN is virtually 8-bit clean
* Check for mime to remove.
*/
if ((strncasecmp(p, "text/plain", 10) == 0) && (strncasecmp(q, "quoted-printable", 16) == 0))
qp_or_base64 = 1;
/*
* turn the base64 decode mode on
*/
else if ((strncasecmp(p, "text/plain", 10) == 0) && (strncasecmp(q, "base64", 6) == 0))
qp_or_base64 = 2;
/*
* text/html support from FSC-HTML 001 proposal of Odinn Sorensen (2:236/77)
*/
if (strncasecmp(p, "text/html", 9) == 0)
html_message = TRUE;
for (tmp = msg; tmp; tmp = tmp->next)
if (((strcasecmp(tmp->key,"X-FTN-KLUDGE") == 0) && (strcasecmp(tmp->val,"FSCHTML") == 0)) ||
(strcasecmp(tmp->key,"X-FTN-HTML") == 0))
html_message = FALSE;
if ((readcharset(p) != CHRS_NOTSET ) && ((q == NULL) || (strncasecmp(q,"7bit",4) == 0) ||
((!pgpsigned) && (qp_or_base64==1)) || ((!pgpsigned) && (qp_or_base64==2)) || (strncasecmp(q,"8bit",4) == 0)))
if ((strncasecmp(p, "text/plain", 10) == 0) && ((q == NULL) ||
(strncasecmp(q,"7bit",4) == 0) || (strncasecmp(q,"8bit",4) == 0)))
removemime=1; /* no need in MIME headers */
/*
* some old MUA puts "text" instead of "text/plain; charset=..."
*/
else if ((strcasecmp(p,"text\n") == 0))
removemime = TRUE;
}
if (removemime || qp_or_base64 || html_message)
Syslog('m', "removemime=%s, qp_or_base64 = %d, html_message=%s", removemime ? "True":"False", qp_or_base64,
html_message ? "True":"False");
if (removemime)
Syslog('m', "removemime=%s", removemime ? "True":"False");
if ((p = hdr((char *)"Message-ID",msg))) {
if (!removemsgid)
@ -412,7 +344,6 @@ int rfc2ftn(FILE *fp, faddr *recipient)
} else {
strncpy(newsubj,fmsg->subj,MAXSUBJ);
}
strcpy(newsubj, hdrnconv(newsubj, incode, outcode, MAXSUBJ));
newsubj[MAXSUBJ]='\0';
if (splitpart) {
@ -500,14 +431,14 @@ int rfc2ftn(FILE *fp, faddr *recipient)
}
}
if (getchrs(outcode) != NULL) {
hdrsize += 8 + strlen(getchrs(outcode));
fprintf(ofp, "\001CHRS: %s\n", getchrs(outcode));
if (html_message) {
hdrsize += 9;
fprintf(ofp, "\1HTML: 5\n");
}
}
// if (getchrs(outcode) != NULL) {
// hdrsize += 8 + strlen(getchrs(outcode));
// fprintf(ofp, "\001CHRS: %s\n", getchrs(outcode));
// if (html_message) {
// hdrsize += 9;
// fprintf(ofp, "\1HTML: 5\n");
// }
// }
if (CFG.allowcontrol && (!hdr((char *)"X-FTN-ACUPDATE",msg)) && (p=hdr((char *)"Control",msg))) {
if (strstr(p,"cancel")) {
@ -593,6 +524,7 @@ int rfc2ftn(FILE *fp, faddr *recipient)
kludgewrite(tmp->val,ofp);
}
/*
* Add the Received: header from this system to the mesage.
*/
@ -611,7 +543,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
hdrsize += strlen(tmp->key)+strlen(tmp->val);
fprintf(ofp,"\1RFC-%s:",tmp->key);
}
kludgewrite(hdrconv(tmp->val, incode, outcode),ofp);
// kludgewrite(hdrconv(tmp->val, incode, outcode),ofp);
kludgewrite(tmp->val, ofp);
}
}
@ -626,7 +559,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
hdrsize += strlen(tmp->key)+strlen(tmp->val);
fprintf(ofp,"%s:",tmp->key);
}
charwrite(hdrconv(tmp->val, incode, outcode),ofp);
charwrite(tmp->val, ofp);
// charwrite(hdrconv(tmp->val, incode, outcode),ofp);
}
}
@ -634,8 +568,8 @@ int rfc2ftn(FILE *fp, faddr *recipient)
charwrite((char *)"\n",ofp);
if ((hdr((char *)"X-FTN-SOT",msg)) || (sot_kludge))
fprintf(ofp,"\1SOT:\n");
if ((splitpart == 0) && (hdr((char *)"X-PGP-Signed",msg)))
fprintf(ofp,PGP_SIGNED_BEGIN"\n");
// if ((splitpart == 0) && (hdr((char *)"X-PGP-Signed",msg)))
// fprintf(ofp,PGP_SIGNED_BEGIN"\n");
}
if (replyaddr) {
replyaddr = NULL;
@ -646,47 +580,57 @@ int rfc2ftn(FILE *fp, faddr *recipient)
needsplit = FALSE;
} else if ((p=hdr((char *)"X-Body-Start",msg))) {
datasize += strlen(p);
if (qp_or_base64==1)
charwrite(strkconv(qp_decode(p), incode, outcode), ofp);
else if (qp_or_base64==2)
charwrite(strkconv(b64_decode(p), incode, outcode), ofp);
else
charwrite(strkconv(p, incode, outcode), ofp);
charwrite(p, ofp);
// if (qp_or_base64==1)
// charwrite(strkconv(qp_decode(p), incode, outcode), ofp);
// else if (qp_or_base64==2)
// charwrite(strkconv(b64_decode(p), incode, outcode), ofp);
// else
// charwrite(strkconv(p, incode, outcode), ofp);
}
//Syslog('-', "14");
while (!(needsplit=(!forbidsplit) && (((splitpart && (datasize > (CFG.new_split * 1024))) ||
(!splitpart && ((datasize+hdrsize) > (CFG.new_split * 1024)))))) && (bgets(temp,4096-1,fp))) {
// Striplf(temp);
Syslog('-', "%d", strlen(temp));
// if (*(temp + strlen(temp)) != '\0') {
Syslog('-', "%d", (*(temp + strlen(temp))));
// }
Syslog('-', "14a \"%s\"", temp);
datasize += strlen(temp);
if (qp_or_base64==1)
charwrite(strkconv(qp_decode(temp), incode, outcode), ofp);
else if (qp_or_base64==2)
charwrite(strkconv(b64_decode(temp), incode, outcode), ofp);
else
charwrite(strkconv(temp, incode, outcode), ofp);
charwrite(temp, ofp);
// if (qp_or_base64==1)
// charwrite(strkconv(qp_decode(temp), incode, outcode), ofp);
// else if (qp_or_base64==2)
// charwrite(strkconv(b64_decode(temp), incode, outcode), ofp);
// else
// charwrite(strkconv(temp, incode, outcode), ofp);
}
//Syslog('-', "15");
if (needsplit) {
fprintf(ofp,"\n * Message split, to be continued *\n");
splitpart++;
} else if ((p=hdr((char *)"X-PGP-Signed",msg))) {
fprintf(ofp,PGP_SIG_BEGIN"\n");
if ((q=hdr((char *)"X-PGP-Version",msg))) {
fprintf(ofp,"Version:");
charwrite(q,ofp);
}
if ((q=hdr((char *)"X-PGP-Charset",msg))) {
fprintf(ofp,"Charset:");
charwrite(q,ofp);
}
if ((q=hdr((char *)"X-PGP-Comment",msg))) {
fprintf(ofp,"Comment:");
charwrite(q,ofp);
}
fprintf(ofp,"\n");
p=xstrcpy(p);
q=strtok(p," \t\n");
fprintf(ofp,"%s\n",q);
while ((q=(strtok(NULL," \t\n"))))
fprintf(ofp,"%s\n",q);
fprintf(ofp,PGP_SIG_END"\n");
// } else if ((p=hdr((char *)"X-PGP-Signed",msg))) {
// fprintf(ofp,PGP_SIG_BEGIN"\n");
// if ((q=hdr((char *)"X-PGP-Version",msg))) {
// fprintf(ofp,"Version:");
// charwrite(q,ofp);
// }
// if ((q=hdr((char *)"X-PGP-Charset",msg))) {
// fprintf(ofp,"Charset:");
// charwrite(q,ofp);
// }
// if ((q=hdr((char *)"X-PGP-Comment",msg))) {
// fprintf(ofp,"Comment:");
// charwrite(q,ofp);
// }
// fprintf(ofp,"\n");
// p=xstrcpy(p);
// q=strtok(p," \t\n");
// fprintf(ofp,"%s\n",q);
// while ((q=(strtok(NULL," \t\n"))))
// fprintf(ofp,"%s\n",q);
// fprintf(ofp,PGP_SIG_END"\n");
}
if ((p=hdr((char *)"X-FTN-EOT",msg)) || (eot_kludge))
fprintf(ofp,"\1EOT:\n");
@ -704,11 +648,11 @@ int rfc2ftn(FILE *fp, faddr *recipient)
if (*(q=p+strlen(p)-1) == '\n')
*q='\0';
origin = xstrcpy((char *)" * Origin: ");
origin = xstrcat(origin, hdrconv(p, incode, outcode));
origin = xstrcat(origin, p);
} else {
origin = xstrcpy((char *)" * Origin: ");
if (fmsg->origin)
origin = xstrcat(origin, hdrconv(fmsg->origin, incode, outcode));
origin = xstrcat(origin, fmsg->origin);
else
origin = xstrcat(origin, CFG.origin);
origin = xstrcat(origin, (char *)" (");

View File

@ -216,8 +216,8 @@ void Add_Headkludges(faddr *dest, int IsReply)
break;
}
sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
MsgText_Add2(temp);
// sprintf(temp, "\001CHRS: %s", getchrs(msgs.Ftncode));
// MsgText_Add2(temp);
sprintf(temp, "\001MSGID: %s %08lx", aka2str(msgs.Aka), sequencer());
MsgText_Add2(temp);
Msg.MsgIdCRC = upd_crc32(temp, crc, strlen(temp));

View File

@ -91,8 +91,8 @@ int CountMsgarea(void)
msgs.Quotes = TRUE;
msgs.DaysOld = CFG.defdays;
msgs.MaxMsgs = CFG.defmsgs;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
strcpy(msgs.Origin, CFG.origin);
fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base, 0770);
@ -117,8 +117,8 @@ int CountMsgarea(void)
msgs.SYSec.level = 32000;
msgs.DaysOld = CFG.defdays;
msgs.MaxMsgs = CFG.defmsgs;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base))
@ -141,8 +141,8 @@ int CountMsgarea(void)
msgs.SYSec.level = 32000;
msgs.DaysOld = CFG.defdays;
msgs.MaxMsgs = CFG.defmsgs;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
fwrite(&msgs, sizeof(msgs), 1, fil);
mkdirs(msgs.Base, 0770);
if (Msg_Open(msgs.Base))
@ -227,8 +227,8 @@ int OpenMsgarea(void)
memset(&msgs, 0, sizeof(msgs));
while (fread(&msgs, oldsize, 1, fin) == 1) {
if ((oldsize != sizeof(msgs)) && !msgs.Rfccode) {
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
}
if ((oldsize != sizeof(msgs)) && !msgs.LinkSec.level) {
msgs.LinkSec.level = 1;
@ -305,8 +305,8 @@ void InitMsgRec(void)
msgs.Type = ECHOMAIL;
msgs.MsgKinds = PUBLIC;
msgs.UsrDelete = TRUE;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
msgs.MaxArticles = CFG.maxarticles;
strcpy(msgs.Origin, CFG.origin);
msgs.LinkSec.level = 1;
@ -1040,8 +1040,8 @@ int EditMsgRec(int Area)
show_str(14,16,16, msgs.Distribution);
show_msgtype(15,16, msgs.Type);
show_msgkinds(16,16, msgs.MsgKinds);
show_str(17,16,16, printable(getchrs(msgs.Ftncode), 0));
show_str(18,16,16, printable(getchrs(msgs.Rfccode), 0));
// show_str(17,16,16, printable(getchrs(msgs.Ftncode), 0));
// show_str(18,16,16, printable(getchrs(msgs.Rfccode), 0));
show_bool(19,16, msgs.Active);
show_int( 13,50, msgs.DaysOld);
@ -1129,8 +1129,8 @@ int EditMsgRec(int Area)
msgs.NetReply = mgroup.NetReply;
msgs.Quotes = mgroup.Quotes;
msgs.MaxArticles = CFG.maxarticles;
msgs.Rfccode = CHRS_DEFAULT_RFC;
msgs.Ftncode = CHRS_DEFAULT_FTN;
msgs.Rfccode = 0; // CHRS_DEFAULT_RFC;
msgs.Ftncode = 0; // CHRS_DEFAULT_FTN;
strncpy(msgs.Origin, CFG.origin, 50);
msgs.LinkSec = mgroup.LinkSec;
@ -1792,8 +1792,8 @@ int mail_area_doc(FILE *fp, FILE *toc, int page)
fprintf(fp, " Offline name %s\n", msgs.QWKname);
fprintf(fp, " Area type %s\n", getmsgtype(msgs.Type));
fprintf(fp, " Messages type %s\n", getmsgkinds(msgs.MsgKinds));
fprintf(fp, " FTN charset %s\n", printable(getchrs(msgs.Ftncode), 0));
fprintf(fp, " RFC charset %s\n", printable(getchrs(msgs.Rfccode), 0));
// fprintf(fp, " FTN charset %s\n", printable(getchrs(msgs.Ftncode), 0));
// fprintf(fp, " RFC charset %s\n", printable(getchrs(msgs.Rfccode), 0));
fprintf(fp, " Days old msgs. %d\n", msgs.DaysOld);
fprintf(fp, " Maximum msgs. %d\n", msgs.MaxMsgs);
fprintf(fp, " Max articles %d\n", msgs.MaxArticles);