From e0eaf617dd1be01eaa67430d21326af2b247c1b2 Mon Sep 17 00:00:00 2001 From: piaip Date: Sat, 15 Aug 2009 10:26:58 +0000 Subject: * make pretty subject names in internet mails (to make people who cannot understand English happy for common error notifications). git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4745 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/bbsmail.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'util/bbsmail.c') diff --git a/util/bbsmail.c b/util/bbsmail.c index c2cc732d..1b4de0ee 100644 --- a/util/bbsmail.c +++ b/util/bbsmail.c @@ -41,6 +41,40 @@ mailog(msg) void str_decode_M3(unsigned char *str); #endif +static const char * +bbsmail_pretty_subject(const char *subject) +{ +#ifdef WITHOUT_BBSMAIL_PRETTY_SUBJECT + return subject; +#else + + static const char *table[] = { + "Undelivered Mail Returned to Sender", + "°h«H³qª¾", + + NULL, + NULL, + }; + + const char **pat = table; + + while (*pat) + { + if (strncmp(*pat, subject, strlen(*pat)) == 0) + { + pat++; + assert(*pat); + return *pat; + } + // each entry has 2 records. + pat += 2; + } + + // fallback to original title + return subject; +#endif +} + int mail2bbs(char *userid) { int uid; @@ -75,7 +109,7 @@ int mail2bbs(char *userid) return -1; } -/* parse header */ + /* parse header */ while( fgets(genbuf, sizeof(genbuf), stdin) ){ if( genbuf[0] == '\n' ) break; @@ -179,9 +213,9 @@ int mail2bbs(char *userid) sprintf(genbuf, "%s => %s", sender, xuser.userid); mailog(genbuf); -/* append the record to the MAIL control file */ + /* append the record to the MAIL control file */ strip_ansi(title, title, 0); - strlcpy(mymail.title, title, sizeof(mymail.title)); + strlcpy(mymail.title, bbsmail_pretty_subject(title), sizeof(mymail.title)); if (strtok(sender, " .@\t\n\r")) strcat(sender, "."); -- cgit v1.2.3