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
--- 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);
--- 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
_______________________________________________
NOTE: If there is a disclaimer or other legal boilerplate in the above
message, it is NULL AND VOID.  You may ignore it.

Visit http://www.mimedefang.org and http://www.roaringpenguin.com
MIMEDefang mailing list [email protected]
http://lists.roaringpenguin.com/mailman/listinfo/mimedefang

Reply via email to