--- memos.c.orig Mon May 21 15:55:45 2001 +++ memos.c Wed Apr 9 20:25:30 2003 @@ -45,7 +45,7 @@ void Help(void); int main(int argc, char *argv[]); -void write_memo_mbox(struct Memo m, struct MemoAppInfo mai, int category); +void write_memo_mbox(struct Memo m, struct MemoAppInfo mai, int category, int num); void write_memo_in_directory(char *dirname, struct Memo m, struct MemoAppInfo mai, int category, int verbose); @@ -310,7 +310,7 @@ switch (mode) { case MEMO_MBOX_STDOUT: - write_memo_mbox(m, mai, category); + write_memo_mbox(m, mai, category, i); break; case MEMO_DIRECTORY: write_memo_in_directory(dirname, m, mai, category, @@ -349,18 +349,20 @@ * ***********************************************************************/ void -write_memo_mbox(struct Memo m, struct MemoAppInfo mai, int category) +write_memo_mbox(struct Memo m, struct MemoAppInfo mai, int category, int num) { int j; printf("From Your.Palm Tue Oct 1 07:56:25 1996\n"); printf("Received: Palm@p by memo Tue Oct 1 07:56:25 1996\n"); - printf("To: you@y\n"); - printf("Date: Thu, 31 Oct 1996 23:34:38 -0500\n"); + printf("Date: Wed, 01 Jan 2003 00:00:00 +0900 (JST)\n"); + printf("From: Palm =?iso-2022-jp?B?GyRCJE4lYSViGyhC?= <memos@PalmDevice>\n"); + printf("To: palm-owner@localhost\n"); + printf("X-Mail-Count: %d\n", num + 1); printf("Subject: "); /* print category name in brackets in subject field */ - printf("[%s] ", mai.category.name[category]); + printf("[%03d:%s] ", num + 1, mai.category.name[category]); /* print (at least part of) first line as part of subject: */ for (j = 0; j < 40; j++) { @@ -374,6 +376,7 @@ printf("\n"); puts(""); puts(m.text); + printf("\n"); } /*********************************************************************** @@ -419,28 +422,36 @@ if ((!m.text[j]) || (m.text[j] == '\n')) break; if (m.text[j] == '/') { - strncat(pathbuffer, "=2F", 3); + strncat(pathbuffer, "_", 1); + continue; + } + if (m.text[j] == ' ') { + strncat(pathbuffer, "_", 1); + continue; + } + if (m.text[j] == '\'') { + strncat(pathbuffer, "_", 1); + continue; + } + if (m.text[j] == '\"') { + strncat(pathbuffer, "_", 1); + continue; + } + if (m.text[j] == '\\') { + strncat(pathbuffer, "_", 1); continue; } if (m.text[j] == '=') { - strncat(pathbuffer, "=3D", 3); + strncat(pathbuffer, "_", 1); continue; } -#ifdef OS2 if (m.text[j] == ':') { - strncat(pathbuffer, "=3A", 3); + strncat(pathbuffer, "_", 1); continue; } -#endif - /* escape if it's an ISO8859 control character (note: some - are printable on the Palm) */ - if ((m.text[j] | 0x7f) < ' ') { - tmp[0] = '\0'; - sprintf(tmp, "=%2X", (unsigned char) m.text[j]); - } else { - tmp[0] = m.text[j]; - tmp[1] = '\0'; - } + + tmp[0] = m.text[j]; + tmp[1] = '\0'; strcat(pathbuffer, tmp); }で、"-d" でファイルに落して使おうかなぁと考えたのだけど、良く考えると、ファイル名が SJIS の第一バイトで切れちゃうと破綻しそうなので、
% memos.exe -v | nkf -j -m0 > memos.mbox % imget --src=local:./memos.mbox --dst=+tmpとして Mew で読むことにした。Subject の encode はしていないし、メールの最後に無駄な空行がつくときもあるけど、とりあえず幸せ。