X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=rfc822.c;h=15b88f05ef476312af280de1d2ec7183ed4768db;hb=5c7da5cc729148aace14fdf4b088554bddb7447c;hp=beff379db9c5034ae5ba08a91dbc6de2c8268ebf;hpb=d5d433e0c051cb0912421a1df3f239438928f7d2;p=~andy%2Ffetchmail diff --git a/rfc822.c b/rfc822.c index beff379d..15b88f05 100644 --- a/rfc822.c +++ b/rfc822.c @@ -19,19 +19,24 @@ is part of fetchmail and the Unix Cookbook, and are released under the MIT license. Compile with -DMAIN to build the demonstrator. ******************************************************************************/ + +#include "config.h" + #include #include #include +#include #include #include "fetchmail.h" +#include "sdump.h" #ifndef MAIN #include "i18n.h" #else #include static int verbose; -char *program_name = "rfc822"; +const char *program_name = "rfc822"; #endif /* MAIN */ #ifndef TRUE @@ -41,6 +46,8 @@ char *program_name = "rfc822"; #define HEADER_END(p) ((p)[0] == '\n' && ((p)[1] != ' ' && (p)[1] != '\t')) +#define BEFORE_EOL(s) (strcspn((s), "\r\n")) + char *reply_hack( char *buf /* header to be hacked */, const char *host /* server hostname */, @@ -72,8 +79,10 @@ char *reply_hack( } #ifndef MAIN - if (outlevel >= O_DEBUG) - report_build(stdout, GT_("About to rewrite %s"), 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++) @@ -208,8 +217,12 @@ char *reply_hack( } #ifndef MAIN - if (outlevel >= O_DEBUG) - report_complete(stdout, GT_("Rewritten version is %s\n"), 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); @@ -426,6 +439,8 @@ int main(int argc, char *argv[]) break; } + longbuf[0] = '\0'; + while (fgets(buf, sizeof(buf)-1, stdin)) { if (buf[0] == ' ' || buf[0] == '\t')