Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / mantools / xpostdef
blob6c8873f1716ec863b742f3561e53b75090898e3e
1 #!/usr/bin/perl
3 # Usage: xpostdef postconf.proto >postconf.proto.new
5 # Update parameter default values in postconf prototype file.
7 $POSTCONF="postconf";
9 # Read all the default parameter values. This also provides us with
10 # a list of all the parameters that postconf knows about.
12 open(POSTCONF, "$POSTCONF -d|") || die "cannot run $POSTCONF -d: !$\n";
13 while(<POSTCONF>) {
14 chop;
15 if (($name, $defval) = split(/\s+=\s+/, $_, 2)) {
16 $defval =~ s/&/\&amp;/g;
17 $defval =~ s/</\&lt;/g;
18 $defval =~ s/>/\&gt;/g;
19 $defval =~ s/\s+$//;
20 $defaults{$name} = $defval;
21 } else {
22 die "unexpected $POSTCONF output: $_\n";
25 close(POSTCONF) || die "$POSTCONF failed: $!\n";
27 # Censor out default values that are system or version dependent, or
28 # that don't display well.
30 $censored = <<EOF;
31 alias_database
32 alias_maps
33 command_directory
34 command_expansion_filter
35 config_directory
36 daemon_directory
37 default_database_type
38 default_rbl_reply
39 execution_directory_expansion_filter
40 export_environment
41 forward_expansion_filter
42 forward_path
43 html_directory
44 import_environment
45 mail_release_date
46 mail_spool_directory
47 mail_version
48 mailbox_delivery_lock
49 mailq_path
50 manpage_directory
51 mydomain
52 myhostname
53 mynetworks
54 newaliases_path
55 parent_domain_matches_subdomains
56 proxy_read_maps
57 queue_directory
58 readme_directory
59 sendmail_path
60 smtpd_expansion_filter
61 tls_random_source
62 virtual_mailbox_lock
63 milter_connect_macros
64 milter_helo_macros
65 milter_mail_macros
66 milter_rcpt_macros
67 milter_data_macros
68 milter_unknown_command_macros
69 milter_end_of_data_macros
70 EOF
72 for $name (split(/\s+/, $censored)) {
73 $defaults{$name} = "see \"postconf -d\" output";
76 # Process the postconf prototype file, and update default values
77 # with output from the postconf command. Leave alone any defaults
78 # that postconf didn't know about. This can happen when conditional
79 # features have been compile time disabled.
81 $name = $defval = $text = $line = "";
83 while(<>) {
84 if (/^%PARAM/) {
86 # Print the updated parameter text. Keep the old default if
87 # postconf doesn't have a suitable one.
89 if ($name) {
90 $defval = $defaults{$name} if (defined($defaults{$name}));
91 print "%PARAM $name $defval\n";
93 print $text;
95 # Reset the parameter name, default, and accumulated text.
97 $name = $defval = $text = $line = "";
99 # Accumulate the parameter name and default value.
101 do {
102 $_ =~ s/\s+$//;
103 $line .= " " . $_;
104 } while(($_ = <POSTCONF>) && /^../);
105 ($junk, $class, $name, $defval) = split(/\s+/, $line, 4);
106 } else {
108 # Accumulate the text in the parameter definition.
110 $_ =~ s/\s+$/\n/;
111 $text .= $_;
116 # Fix the last parameter.
118 if ($name && $text) {
119 $defval = $defaults{$name} if (defined($defaults{$name}));
120 print "%PARAM $name $defval\n$text";