Mercurial > hg > Applications > mh
changeset 5:47d488958a4c
support contents-encoding in mhl.
author | kono |
---|---|
date | Sat, 03 Dec 2005 17:06:06 +0900 |
parents | 6bc439d68ff9 |
children | d802748a597d |
files | config/version config/version.c doc/version.rf h/mh.h sbr/ml_codeconv.c uip/.gdb_history uip/mhlsbr.c |
diffstat | 7 files changed, 401 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/config/version Wed Apr 20 14:39:40 2005 +0900 +++ b/config/version Sat Dec 03 17:06:06 2005 +0900 @@ -1,1 +1,1 @@ -6.8.3.34 +6.8.3.65
--- a/config/version.c Wed Apr 20 14:39:40 2005 +0900 +++ b/config/version.c Sat Dec 03 17:06:06 2005 +0900 @@ -1,5 +1,5 @@ #ifndef JAPAN -char *version = "@(#)MH 6.8.3 #34[UCI] (leo.ie.u-ryukyu.ac.jp) of Wed Apr 20 14:24:42 JST 2005"; +char *version = "@(#)MH 6.8.3 #65[UCI] (leo.ie.u-ryukyu.ac.jp) of Sat Dec 3 17:04:36 JST 2005"; #else /* JAPAN */ -char *version = "@(#)MH 6.8.3.JP-pre3.05-20010615 #34[UCI] (leo.ie.u-ryukyu.ac.jp) of Wed Apr 20 14:24:43 JST 2005"; +char *version = "@(#)MH 6.8.3.JP-pre3.05-20010615 #65[UCI] (leo.ie.u-ryukyu.ac.jp) of Sat Dec 3 17:04:36 JST 2005"; #endif /* JAPAN */
--- a/doc/version.rf Wed Apr 20 14:39:40 2005 +0900 +++ b/doc/version.rf Sat Dec 03 17:06:06 2005 +0900 @@ -1,1 +1,1 @@ -.ds MH 6.8.3 #34[UCI] +.ds MH 6.8.3 #65[UCI]
--- a/h/mh.h Wed Apr 20 14:39:40 2005 +0900 +++ b/h/mh.h Sat Dec 03 17:06:06 2005 +0900 @@ -383,6 +383,7 @@ void ml_pretty_fputs (); void junet_fputs (); char *ml_conv (); +char *ml_conv_decode (); #endif /* JAPAN */ #ifdef MIME_HEADERS char *exthdr_encode ();
--- a/sbr/ml_codeconv.c Wed Apr 20 14:39:40 2005 +0900 +++ b/sbr/ml_codeconv.c Sat Dec 03 17:06:06 2005 +0900 @@ -35,6 +35,17 @@ ((0xe0 <= (c)) && ((c) <= 0xfc))) #define IS_SJIS2(c) ((0x40 <= (c)) && ((c) <= 0xfc) && ((c) != 0x7f)) +/* encoding (mhn) */ + +#define CE_UNKNOWN 0x00 +#define CE_BASE64 0x01 +#define CE_QUOTED 0x02 +#define CE_8BIT 0x03 +#define CE_7BIT 0x04 +#define CE_BINARY 0x05 +#define CE_EXTENSION 0x06 +#define CE_EXTERNAL 0x07 /* for external-body */ + /* hold coding system information */ static coding_system_t ml_coding_info[CSL_SIZE] = { CS_DEFAULT, CS_DEFAULT, CS_DEFAULT }; @@ -60,17 +71,17 @@ static int nkf_output_ctr; static int nkf_limit; static int nkf_ilimit; -static void (*nkf_flush)(char *,int); +static void (*nkf_flush)(unsigned char *,int); -static void nkf_open(char *opt, char *in,int ilimit, - char *out,int limit,void (*flush)(char *,int),FILE *fp); -static void nkf_continue(char *in,int ilimit); +static void nkf_open(unsigned char *opt, unsigned char *in,int ilimit, + unsigned char *out,int limit,void (*flush)(unsigned char *,int),FILE *fp); +static void nkf_continue(unsigned char *in,int ilimit) ; static void nkf_end() ; -static void none(char *a,int b); +static void none(unsigned char *a,int b); -static void my_flush(char *out,int out_count); -static void extend(char *out,int out_count); -static void my_pretty(char *out,int out_count); +static void my_flush(unsigned char *out,int out_count); +static void extend(unsigned char *out,int out_count); +static void my_pretty(unsigned char *out,int out_count); static FILE *nkf_file; @@ -260,7 +271,7 @@ FILE *stream; int pretty; { - nkf_open("-w80",scanlk,-1,buf,BUFSIZ,pretty?my_pretty: my_flush,stream); + nkf_open((unsigned char *)"-w80",(unsigned char *)scanlk,-1,(unsigned char *)buf,BUFSIZ,pretty?my_pretty: my_flush,stream); nkf_end(); } @@ -405,7 +416,21 @@ if ((s == NULL) || ((coding = CSL_FILE(ml_coding_info)) == CS_NOCONV)) return(s); - ml_conv_sbr(s, coding); + ml_conv_sbr(s, coding, CE_UNKNOWN); + return(s); +} + +char * +ml_conv_decode(s,encode) + char *s; + int encode; +{ + coding_system_t coding; + + if ((s == NULL) || ((coding = CSL_FILE(ml_coding_info)) == CS_NOCONV)) + return(s); + + ml_conv_sbr(s, coding, encode); return(s); } @@ -424,11 +449,30 @@ case CS_UTF8: return "-w80"; case CS_NOCONV: return "-t"; } + return "-t"; } static char * -cs_input_opt(int cs) +cs_input_opt(int cs, int encode) { + switch(encode) { + case CE_BASE64: + switch(cs) { + case CS_JIS7: return "-JemB"; + case CS_JEUC: return "-EemB"; + case CS_SJIS: return "-SemB"; + case CS_UTF8: return "-W8emB"; + case CS_NOCONV: return "-t"; + } + case CE_QUOTED: + switch(cs) { + case CS_JIS7: return "-JemQ"; + case CS_JEUC: return "-EemQ"; + case CS_SJIS: return "-SemQ"; + case CS_UTF8: return "-W8emQ"; + case CS_NOCONV: return "-t"; + } + } switch(cs) { case CS_JIS7: return "-Je"; case CS_JEUC: return "-Ee"; @@ -436,16 +480,18 @@ case CS_UTF8: return "-W8e"; case CS_NOCONV: return "-t"; } + return "-e"; } static void -ml_conv_sbr(in, cs) +ml_conv_sbr(in, cs, encode) char *in; coding_system_t cs; + int encode; { - char *opt = cs_input_opt(cs); + char *opt = cs_input_opt(cs,encode); int len = strlen(in); - nkf_open(opt,in,len,in,len,extend,0); + nkf_open((unsigned char *)opt,(unsigned char *)in,len,(unsigned char *)in,len,extend,0); nkf_end(); nkf_output[nkf_output_ctr]=0; } @@ -454,7 +500,7 @@ mime_convert(char *ptr) { int len = strlen(ptr); - nkf_open("-me",ptr,len,ptr,len,extend,0); + nkf_open((unsigned char *)"-me",(unsigned char *)ptr,len,(unsigned char *)ptr,len,extend,0); nkf_end(); nkf_output[nkf_output_ctr]=0; } @@ -528,8 +574,8 @@ */ static void -nkf_open(char *opt, char *in,int ilimit, - char *out,int limit,void (*flush)(char *,int),FILE *fp) { +nkf_open(unsigned char *opt, unsigned char *in,int ilimit, + unsigned char *out,int limit,void (*flush)(unsigned char *,int),FILE *fp) { /* Flags are reset at each call. */ reinit(); @@ -553,7 +599,7 @@ } static void -nkf_continue(char *in,int ilimit) { +nkf_continue(unsigned char *in,int ilimit) { nkf_input_ctr = 0; nkf_input = in; nkf_ilimit = ilimit; @@ -570,24 +616,24 @@ } static void -extend(char *out,int out_count) +extend(unsigned char *out,int out_count) { nkf_output += nkf_output_ctr; } static void -none(char *a,int b) +none(unsigned char *a,int b) { } static void -my_flush(char *out,int out_count) +my_flush(unsigned char *out,int out_count) { fwrite(out,out_count,1,nkf_file); } static void -my_pretty(char *out,int out_count) +my_pretty(unsigned char *out,int out_count) { int c; FILE *fp = nkf_file;
--- a/uip/.gdb_history Wed Apr 20 14:39:40 2005 +0900 +++ b/uip/.gdb_history Sat Dec 03 17:06:06 2005 +0900 @@ -1,83 +1,256 @@ -quit -b fcc -run /tmp/ahoaho -l -quit -b fcc -run /tmp/ahoaho -l -l -l -p fileproc -whatis fileproc -b 2542 -c -quit -l fcc -l -l -l -l -b 2549 -run /tmp/ahoaho -l -p status -quit +run /tmp/draft.1 +b main +run +b main +l main +run +q +b main +run +l main +b 408 +run /tmp/draft.1 +run -junet /tmp/draft.1 +b ml_conv run q -run -where -up -q -show -q -run -p nkf_file +l main +b main +run -junet /tmp/draft.1 q -run show -l -quit -show -run -l -quit +run -junet /tmp/draft.1 +b main +run -junet /tmp/draft.1 +file xmhn +l main +b main +run -junet /tmp/draft.1 q +b main +run /tmp/draft.1 q -run -l -q +b main run -l q +b main run -l -where -up -down +q l -p nkf_output_ctr -p nkf_output -p nkf_file -p nkf_flush -b nkf_open +b main +run +b printf +run +q +b main run -c +q +b main run -up -l +exit q -b nkf_open -b open_nkf +b main +run +exit +q b main run q -b nkf_open +b main +b ml_conv +run /tmp/draft.1 +c +c +n +p codeing +p coding +l +p ml_coding_info +up +l +where +n +p s +c +c +run +run -auto -headers -junet /tmp/draft.1 +c +p ml_coding_info +c +where +s +s +n +p opt +n +run +c +n +n +p s +c +b ml_puts +b ml_fputs +c +c +b fputs +run +p argv[1] +c +c run c -ls -b main -run -info b +where +up +l +tb putc +c +b jis7_fputs +up +c +d 4 +c +c +c +c +c +c +c +c +n +n +c +q +b exthdr_encode +run -auto -headers -junet /tmp/draft.1 +c +n +n +o component +p component +p p +p *p +n +n +n +n +p input +p width +p output +s +n +n +s +s +p pp +l +n +n +n +n +n +n +n +p ip +p *ip +p (void*)*ip +n +n +n +n +n +n +n +s +n c c q +b ml_conv_decode +l ml_conv_decode +q +l ml_conv_decode +l ml_conv +l main +q +b main +run -form mhl.news /Users/kono/Mail/inspire/103 +b ml_conv_decode +c +s +q +l ml_conv +l process +b 972 +run -form mhl.news /Users/kono/Mail/inspire/103 +n +p cp +n +ru +p buf +n +p cp +p buf +n +p cp +q +b 972 +l process +b 972 +run -form mhl.news /Users/kono/Mail/inspire/103 +n +n +s +n +l +up +s +n +p cp +n +n +p cp +n +n +p content_encoding +p (int)content_encoding +b ml_conv_decode +c +n +p coding +where +l ml_conv_svr +l ml_conv_sbr +up +l +p content_encoding +p (int)content_encoding +down +l +s +l +q +b ml_conv_decode +run -form mhl.news /Users/kono/Mail/inspire/103 +n +p encode +n +run +n +s +s +s +n +p opt +run +s +p encode +s +p encode +l +p cs +s +s +l +p opt +q
--- a/uip/mhlsbr.c Wed Apr 20 14:39:40 2005 +0900 +++ b/uip/mhlsbr.c Sat Dec 03 17:06:06 2005 +0900 @@ -233,6 +233,56 @@ NULL }; +/* from mhn */ + +static int content_encoding; /* internal form */ +#define CE_UNKNOWN 0x00 +#define CE_BASE64 0x01 +#define CE_QUOTED 0x02 +#define CE_8BIT 0x03 +#define CE_7BIT 0x04 +#define CE_BINARY 0x05 +#define CE_EXTENSION 0x06 +#define CE_EXTERNAL 0x07 /* for external-body */ + +#define ENCODING_FIELD "Content-Transfer-Encoding" + +struct str2init { + char *mhnsi_key; + int mhnsi_value; +}; + +static struct str2init str2ces[] = { + {"base64", CE_BASE64}, + {"quoted-printable", CE_QUOTED}, + {"8bit", CE_8BIT}, + {"7bit", CE_7BIT}, + {"binary", CE_BINARY}, + + {NULL, CE_EXTENSION}, + {NULL, CE_UNKNOWN}, +}; + +#define istoken(c) \ + (!isspace (c) \ + && !iscntrl (c) \ + && !((c) & 0x80) \ + && (c) != '(' \ + && (c) != ')' \ + && (c) != '<' \ + && (c) != '>' \ + && (c) != '@' \ + && (c) != ',' \ + && (c) != ';' \ + && (c) != ':' \ + && (c) != '\\' \ + && (c) != '"' \ + && (c) != '/' \ + && (c) != '[' \ + && (c) != ']' \ + && (c) != '?' \ + && (c) != '=') + /* */ static int bellflg = 0; @@ -907,9 +957,49 @@ /* */ for (state = FLD;;) + next: switch (state = m_getfld (state, name, buf, sizeof buf, fp)) { case FLD: case FLDPLUS: +#ifdef ENCODING_FIELD + /* form mhn */ + if (uleq (name, ENCODING_FIELD)) { + char *cp, + *dp; + char c; + register struct str2init *s2i; + + cp = add (buf, NULLCP); + while (state == FLDPLUS) { + state = m_getfld (state, name, buf, sizeof buf, fp); + cp = add (buf, cp); + } + while (isspace (*cp)) + cp++; + for (dp = index (cp, '\n'); dp; dp = index (dp, '\n')) + *dp++ = ' '; + if (*cp == '(' ) { /* comment */ + int i; + for (i = 1;i;) { + switch (*cp++) { + case '(': i++; break; + case ')': --i; break; + case '\\': if ((*cp++) != '\0') break; + case '\0': goto next; + } + } + } + for (dp = cp; istoken (*dp); dp++); + c = *dp, *dp = '\0'; + for (s2i = str2ces; s2i -> mhnsi_key; s2i++) + if (uleq (cp, s2i -> mhnsi_key)) + break; + if (!s2i -> mhnsi_key && !uprf (cp, "X-")) + s2i++; + *dp = c; + content_encoding = s2i -> mhnsi_value; + } +#endif for (ip = ignores; *ip; ip++) if (uleq (name, *ip)) { while (state == FLDPLUS) @@ -988,7 +1078,7 @@ } else { strcpy(buf, ++cp); *cp = 0; - (void) ml_conv(holder.c_text); + (void) ml_conv_decode(holder.c_text,content_encoding); /* putcomp() may change the address of holder.c_text */ putcomp(c1, &holder, BODYCOMP); @@ -1005,7 +1095,7 @@ holder.c_text + buflen - cp, fp); } - (void) ml_conv(holder.c_text); + (void) ml_conv_decode(holder.c_text,content_encoding); putcomp(c1, &holder, BODYCOMP); #else /* JAPAN */ while (state == BODY) {