Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / mantools / postconf2html
blob0e0c9816c56e6ba0c0cfc19327beea4469de23af
1 #!/usr/bin/perl
3 # postconf2html - add HTML paragraphs
5 # Basic operation:
7 # - Process input as text blocks separated by one or more empty
8 # (or all whitespace) lines.
10 # - Skip text between <!-- and -->; each must be on a different line.
12 # - Don't touch blocks that start with `<' in column zero.
14 # The only changes made are:
16 # - Emit "<DT><a name="parametername">parametername</a>...</DT><DD>" at
17 # the top of each parameter description.
19 # All other non-comment input is flagged as an error.
21 #use Getopt::Std;
23 #$opt_h = undef;
24 #$opt_v = undef;
25 #getopts("hv");
27 #die "Usage: $0 [-hv]\n" if ($opt_h);
29 #push @ARGV, "/dev/null"; # XXX
31 while(<>) {
33 # Skip comments.
34 next if /^#/;
36 # Skip blank lines before text block.
37 next unless (/\S/);
39 # Gobble up the next text block.
40 $block = "";
41 $comment = 0;
42 do {
43 $_ =~ s/\s+\n$/\n/;
44 $block .= $_;
45 if ($_ =~ /<!--/)
46 { $comment = 1; }
47 if ($comment && $_ =~ /-->/)
48 { $comment = 0; $block =~ s/<!--.*-->//sg; }
49 } while((($_ = <>) && /\S/) || $comment);
51 # Skip blanks after comment elimination.
52 if ($block =~ /^\s/) {
53 $block =~ s/^\s+//s;
54 next if ($block eq "");
57 # Don't touch a text block starting with < in column zero.
58 if ($block =~ /^</) {
59 print "$block\n";
62 # Meta block. Emit upper case tags for html2man.
63 elsif ($block =~ /^%PARAM/) {
64 print "\n</DD>\n\n" if ($param);
65 print "\n<DL>\n\n" if ($need_dl);
66 $need_dl = 0;
67 ($junk, $param, $defval) = split(/\s+/, $block, 3);
68 $defval =~ s/\s+$//s;
69 $defval = "empty" if ($defval eq "");
70 $defval = "default: $defval" unless ($defval eq "read-only");
71 print "<DT><b><a name=\"$param\">$param</a>\n($defval)</b></DT><DD>\n\n";
74 # Meta block. Emit upper case tags for html2man.
75 elsif ($block =~ /^%CLASS/) {
76 print "\n</DD>\n\n" if ($param);
77 print "\n</DL>\n\n" if ($class);
78 $param ="";
79 ($junk, $class, $text) = split(/\s+/, $block, 3);
80 $text =~ s/\s+$//s;
81 print "<H2><a name=\"$class\">$text</a></H2>\n\n";
82 $need_dl = 1;
85 # Can't happen.
86 else {
87 die "Unrecognized text block:\n$block";
91 print "\n</DD>\n\n" if ($param);
92 print "\n</DL>\n\n" if ($class);