[Mimedefang] prepend new headers?
Matthew.van.Eerde at hbinc.com
Matthew.van.Eerde at hbinc.com
Tue Dec 20 15:27:18 EST 2005
David F. Skoll wrote:
>> If so, I'll use "N" for "N"ew header
>
> Sounds great! A lot of the code for action_insert_header will be the
> same as for action_add_header, so there's opportunity for refactoring
> there. If you want to make a first-pass at it, I will take a look and
> clean
> it up if necessary.
I attach two patches - one for mimedefang.c and one for mimedefang.pl.
Stupid question...
Whenever I run ./configure it makes a new mimedefang.pl.
How can I patch the template so that action_insert_header is automatically in the generated mimedefang.pl, instead of having to repatch mimedefang.pl every time I rerun ./configure?
--
Matthew.van.Eerde (at) hbinc.com 805.964.4554 x902
Hispanic Business Inc./HireDiversity.com Software Engineer
-------------- next part --------------
--- mimedefang.c.original 2005-12-20 12:05:17.000000000 -0800
+++ mimedefang.c 2005-12-20 12:14:09.000000000 -0800
@@ -1405,6 +1405,28 @@
}
break;
+ case 'N':
+ /* Insert a header in position count */
+ split_on_space3(rptr + 1, &hdr, &count, &val);
+ if (hdr && val && count) {
+ percent_decode((unsigned char *) hdr);
+ percent_decode((unsigned char *) count);
+ percent_decode((unsigned char *) val);
+ if (sscanf(count, "%d", &j) != 1 || j < 0) {
+ j = 0; /* 0 means add header at the top */
+ }
+#ifdef SMFIR_INSHEADER
+ MD_SMFI_TRY(smfi_insheader, (ctx, j, hdr, val));
+#else
+ syslog(LOG_WARNING,
+ "%s: No smfi_insheader, using smfi_addheader",
+ data->qid);
+
+ MD_SMFI_TRY(smfi_addheader, (ctx, hdr, val));
+#endif
+ }
+ break;
+
case 'I':
/* Change a header */
split_on_space3(rptr+1, &hdr, &count, &val);
-------------- next part --------------
--- mimedefang.pl.original 2005-12-20 12:05:33.000000000 -0800
+++ mimedefang.pl 2005-12-20 12:02:46.000000000 -0800
@@ -884,6 +884,23 @@
write_result_line2("H", $header, $value);
}
+#***********************************************************************
+# %PROCEDURE: action_insert_header
+# %ARGUMENTS:
+# header -- header name (eg: X-My-Header)
+# value -- header value (eg: any text goes here)
+# position -- where to place it (eg: 0 [default] to make it first)
+# %RETURNS:
+# Nothing
+# %DESCRIPTION:
+# Makes a note for milter to insert a header in the message.
+#***********************************************************************
+sub action_insert_header ($$;$) {
+ my($header, $value, $pos) = @_;
+ $pos = 0 unless defined($pos);
+ return if (!in_message_context("action_insert_header"));
+ write_result_line3("N", $header, $pos, $value);
+}
#***********************************************************************
# %PROCEDURE: action_change_header
More information about the MIMEDefang
mailing list