summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-08-15 18:26:58 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-08-15 18:26:58 +0800
commite0eaf617dd1be01eaa67430d21326af2b247c1b2 (patch)
treeedb480b9350c5c4be2f31b60767dbc773b1d515d
parent1905343ae9d6f0ba2f7d88218c815735db2b4d89 (diff)
downloadpttbbs-e0eaf617dd1be01eaa67430d21326af2b247c1b2.tar
pttbbs-e0eaf617dd1be01eaa67430d21326af2b247c1b2.tar.gz
pttbbs-e0eaf617dd1be01eaa67430d21326af2b247c1b2.tar.bz2
pttbbs-e0eaf617dd1be01eaa67430d21326af2b247c1b2.tar.lz
pttbbs-e0eaf617dd1be01eaa67430d21326af2b247c1b2.tar.xz
pttbbs-e0eaf617dd1be01eaa67430d21326af2b247c1b2.tar.zst
pttbbs-e0eaf617dd1be01eaa67430d21326af2b247c1b2.zip
* 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
-rw-r--r--util/bbsmail.c40
1 files changed, 37 insertions, 3 deletions
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, ".");