--- lmtp2nntp.c 2001/10/12 13:24:44 1.90
+++ lmtp2nntp.c 2001/10/15 10:13:50 1.91
@@ -143,6 +143,8 @@
char *option_operationmodefakestatus;
char *option_operationmodefakedsn;
int option_maxmessagesize;
+ char *azHeaderValuePairs;
+ size_t asHeaderValuePairs;
int option_timeout_lmtp_accept;
int option_timeout_lmtp_read;
int option_timeout_lmtp_write;
@@ -218,6 +220,7 @@
"[-c addr[:port]] "
"[-d addr[:port][,addr[:port], ...]] "
"[-g groupmode] "
+ "[-h header:value] "
"[-l level[:logfile]] "
"[-m mailfrom] "
"[-n nodename] "
@@ -403,6 +406,8 @@
char *cpAddr;
char *cpPrefixLen;
struct passwd *sPasswd;
+ char *cpHeadername;
+ char *cpHeadervalue;
/* drop effective uid/gid priviledges */
seteuid(getuid());
@@ -429,6 +434,8 @@
ctx->option_operationmodefakestatus = "553"; /* Requested action not taken: mailbox name not allowed */
ctx->option_operationmodefakedsn = "5.7.1"; /* Delivery not authorized, message refused */
ctx->option_maxmessagesize = 8 * 1024 * 1024;
+ ctx->azHeaderValuePairs = NULL;
+ ctx->asHeaderValuePairs = 0;
ctx->option_timeout_lmtp_accept = 0;
ctx->option_timeout_lmtp_read = 10;
ctx->option_timeout_lmtp_write = 10;
@@ -485,7 +492,7 @@
*/
/* read in the arguments */
- while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:l:m:n:o:s:t:u:v")) != -1) {
+ while ((i = getopt(argc, argv, "C:DKP:Va:b:c:d:g:h:l:m:n:o:s:t:u:v")) != -1) {
switch (i) {
case 'C': /*POD [B<-C> I<childsmax>] */
ctx->option_childsmax = atoi(optarg);
@@ -693,6 +700,28 @@
CU(ERR_EXECUTION);
}
break;
+ case 'h': /*POD [B<-h> I<header>:<value>] */
+ cpHeadername = strdup(optarg);
+ if ((cp = strrchr(cpHeadername, ':')) == NULL) {
+ free(cpHeadername);
+ fprintf(stderr, "%s:Error: header \"%s\" for -h option not terminated with colon\n",
+ ctx->progname, cpHeadername);
+ CU(ERR_EXECUTION);
+ }
+ cp++;
+ if (*cp == NUL) {
+ free(cpHeadername);
+ fprintf(stderr, "%s:Error: header \"%s\" for -h option has no value\n",
+ ctx->progname, cpHeadername);
+ CU(ERR_EXECUTION);
+ }
+ cpHeadervalue = strdup(cp);
+ *cp = NUL;
+ argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeadername);
+ argz_add(&ctx->azHeaderValuePairs, &ctx->asHeaderValuePairs, cpHeadervalue);
+ free(cpHeadervalue);
+ free(cpHeadername);
+ break;
case 'l': /*POD [B<-l> I<level>[:I<logfile>]] */
if ((cp = strrchr(optarg, ':')) != NULL) {
*cp++ = NUL;
@@ -1238,6 +1267,8 @@
sa_destroy(ctx->saAltio);
if (ctx->saaAltio)
sa_addr_destroy(ctx->saaAltio);
+ if (ctx->azHeaderValuePairs != NULL)
+ free(ctx->azHeaderValuePairs);
if (ctx->option_pidfile != NULL)
free(ctx->option_pidfile);
if (ctx->option_logfile != NULL)
@@ -2002,6 +2033,15 @@
}
}
+ /* Optionally add command line specified Header/Value Pairs
+ */
+ if ((ctx->asHeaderValuePairs >= 1) && ((ctx->asHeaderValuePairs & 1) == 0)) {
+ cp = NULL;
+ while ((cp = argz_next(ctx->azHeaderValuePairs, ctx->asHeaderValuePairs, cp)) != NULL) {
+ argz_add(&ctx->msg->azHeaders, &ctx->msg->asHeaders, cp);
+ }
+ }
+
/* RFC0821 4.2.1. REPLY CODES BY FUNCTION GROUPS 554 Transaction failed
* RFC1893 2. Status Codes 5.X.X Permanent Failure
* RFC1893 3.5 Network and Routing Status X.6.5 Conversion Failed
|