On Thu, 26 Oct 2006 09:31:37 -0400
John Peacock <[EMAIL PROTECTED]> wrote:

> David Muir Sharnoff wrote:
> > +    if ($status) {
> > +    # this section needs to be kept in sync with the
> > cleanup_stat_map +    # array found in Postfix source file
> > src/global/cleanup_strerror.c +    # which in turn uses constants
> > defined in src/global/cleanup_user.h
> 
> It's extremely icky to have Perl code that relies on some other 
> project's .c and .h files like that.  [...] 
This plugin already relies on the #defines from
src/global/cleanup_user.h file (of postfix-2.x):

# postfix' cleanup flags:
use constant CLEANUP_FLAG_FILTER => (1<<1); # /* Enable content filter
*/ 
use constant CLEANUP_FLAG_BCC_OK => (1<<4); # /* Ok to add auto-BCC
addresses */
use constant CLEANUP_FLAG_MAP_OK => (1<<5); # /* Ok to map 
addresses */

> [...] Do you know how frequent changes
> are made to that array? [...]
IIRC these list of flags above has just been expanded, i.e. the flags
from postfix 1.x are still valid. The same is probably true for the STAT
array.

>[...] Is there any way that you can provide code to
> regenerate this block directly from the Postfix source (and perhaps 
> store the result in a DATA block at the end of the plugin, rather than
> inline)?

Something like this? ... called from $POSTFIX_SRC/, output redirected
to the desired file.

#!/bin/sh
# probably requires gawk!
echo "use strict;
use vars qw(%postfix_stat_msg); 
%postfix_stat_msg = ("
awk '/^[[:space:]]+CLEANUP_STAT_/ { 
  sub(",", " => ", $1); 
  sub(",", "", $NF); 
  print "    "$0";" 
}' src/global/cleanup_strerror.c
echo ");"
# next line ends at the "{",  wrapped by MUA
awk '/^[[:space:]]*#define[[:space:]]+CLEANUP_(FLAG|STAT)_/ && $0 !~
/\\$/ {  
   print "use constant "$2" => "$3";"
}' src/global/cleanup_user.h
echo "1;" 
# end

        Hanno

Reply via email to