From: Joey Schulze Date: Tue, 23 Nov 2004 09:39:43 +0000 (+0000) Subject: Try to gather originator information from the From_ line if there is X-Git-Tag: upstream_newmail_0-3~1 X-Git-Url: https://git.infodrom.org/?p=infodrom%2Fnewmail;a=commitdiff_plain;h=528c7b6fad005f9df9d7e4171089fa6ff3669651 Try to gather originator information from the From_ line if there is no From: line in the header. --- diff --git a/mbox.c b/mbox.c index 15887f7..c9791a4 100644 --- a/mbox.c +++ b/mbox.c @@ -128,6 +128,23 @@ char *realname(char *from) return name; } +/* + * Tries to extract useful content from the From_ line + */ +char *reduce_from_(char *from_) +{ + static char name[HDR_LEN]; + char *cpl, *cpr; + + for (cpl=from_; *cpl && isspace(*cpl); cpl++); + for (cpr=cpl; *cpr && !isspace(*cpr); cpr++); + + if (cpr > cpl) + stringcopy(name, cpl, + sizeof(name) < cpr-cpl+1?sizeof(name):cpr-cpl+1); + return name; +} + int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags) { FILE *f; @@ -158,6 +175,8 @@ int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags) continue; if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\n') { buf[strlen(buf)-1] = '\0'; + if (strlen(buf) > 0 && buf[strlen(buf)-1] == '\r') + buf[strlen(buf)-1] = '\0'; } else { while (!feof(f) && fgets(tmp, sizeof(tmp), f) != NULL) { if (strlen(tmp) > 0 && tmp[strlen(tmp)-1] == '\n') @@ -172,10 +191,8 @@ int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags) if (strlen(from)) stringcopy(realfrom, realname(from), sizeof(realfrom)); -#ifdef todo else stringcopy(realfrom, reduce_from_(from_), sizeof(realfrom)); -#endif emit(prefix, realfrom, subject, priority, opt_flags);