X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=rfc822.c;h=4efba8349eb6a79c494cae0d95aa54e9b72fb7dc;hb=87bcf29364c4640edb87cc2186b965d1a564d70c;hp=24e3560c5a33e05a670d4e6eca28370cbe5057cd;hpb=b73b77380d9939e2b47f5ca7d723a86bde06d657;p=~andy%2Ffetchmail diff --git a/rfc822.c b/rfc822.c index 24e3560c..4efba834 100644 --- a/rfc822.c +++ b/rfc822.c @@ -19,15 +19,23 @@ is part of fetchmail and the Unix Cookbook, and are released under the MIT license. Compile with -DMAIN to build the demonstrator. ******************************************************************************/ + +#define _XOPEN_SOURCE 600 +#define __BSD_VISIBLE 1 + +#include "config.h" +#include "fetchmail.h" + #include #include #include +#include #include -#include "fetchmail.h" +#include "sdump.h" #ifndef MAIN -#include "i18n.h" +#include "gettext.h" #else #include static int verbose; @@ -41,7 +49,7 @@ const char *program_name = "rfc822"; #define HEADER_END(p) ((p)[0] == '\n' && ((p)[1] != ' ' && (p)[1] != '\t')) -#define BEFORE_EOL(s) strcspn((s), "\r\n")) +#define BEFORE_EOL(s) (strcspn((s), "\r\n")) char *reply_hack( char *buf /* header to be hacked */, @@ -74,9 +82,10 @@ char *reply_hack( } #ifndef MAIN - if (outlevel >= O_DEBUG) - report_build(stdout, GT_("About to rewrite %.*s...\n"), - (int)BEFORE_EOL(buf), buf); + if (outlevel >= O_DEBUG) { + report_build(stdout, GT_("About to rewrite %s...\n"), (cp = sdump(buf, BEFORE_EOL(buf)))); + xfree(cp); + } /* make room to hack the address; buf must be malloced */ for (cp = buf; *cp; cp++) @@ -211,9 +220,12 @@ char *reply_hack( } #ifndef MAIN - if (outlevel >= O_DEBUG) - report_complete(stdout, GT_("...rewritten version is %.*s.\n"), - (int)BEFORE_EOL(buf), buf); + if (outlevel >= O_DEBUG) { + report_complete(stdout, GT_("...rewritten version is %s.\n"), + (cp = sdump(buf, BEFORE_EOL(buf)))); + xfree(cp) + } + #endif /* MAIN */ *length = strlen(buf); return(buf); @@ -430,6 +442,8 @@ int main(int argc, char *argv[]) break; } + longbuf[0] = '\0'; + while (fgets(buf, sizeof(buf)-1, stdin)) { if (buf[0] == ' ' || buf[0] == '\t')