xref: /netbsd-src/external/ibm-public/postfix/dist/mantools/check-table-proto (revision 059c16a85b0b39d60ad6d18f53c09510815afa2b)
1*059c16a8Schristos#!/bin/sh
2*059c16a8Schristos
3*059c16a8Schristos# Reports database configuration settings without proto/xxx_table documentation
4*059c16a8Schristos
5*059c16a8SchristosLANG=C; export LANG
6*059c16a8SchristosLC_ALL=C; export LC_ALL
7*059c16a8Schristos
8*059c16a8Schristostrap 'rm -f from-source.tmp from-doc.tmp 2>/dev/null' 0 1 2 3 15
9*059c16a8Schristos
10*059c16a8Schristos# For each database type, extract parameter names from its postconf
11*059c16a8Schristos# include file, and compare the result against a list of names from
12*059c16a8Schristos# the corresponding proto/xxx_table file.
13*059c16a8Schristos
14*059c16a8Schristos# Force a failure if the pcf*suffixes.h files do not exist. Avoid using
15*059c16a8Schristos# bash-specific shell features.
16*059c16a8Schristosfor map in `(ls src/postconf/pcf*suffixes.h || kill $$) |
17*059c16a8Schristos	sed 's;src/postconf/pcf_\(.*\)_suffixes.h$;\1;'`
18*059c16a8Schristosdo
19*059c16a8Schristos    # Extract parameter names from source code.
20*059c16a8Schristos    tr -cd '[A-zA-z_0-9\12]' < src/postconf/pcf_${map}_suffixes.h |
21*059c16a8Schristos	sort > from-source.tmp
22*059c16a8Schristos    # Extract parameter names from documentation.
23*059c16a8Schristos    sed -n '/^# *\.IP *"*\\fB\([a-zA-Z_0-9][a-zA-Z_0-9]*\).*/{
24*059c16a8Schristos	s//\1/
25*059c16a8Schristos	p
26*059c16a8Schristos    }' proto/${map}_table | sort > from-doc.tmp
27*059c16a8Schristos    cmp -s from-source.tmp from-doc.tmp || {
28*059c16a8Schristos	echo Settings in global/dict_${map}.c and proto/${map}_table differ.
29*059c16a8Schristos	diff from-source.tmp from-doc.tmp
30*059c16a8Schristos    }
31*059c16a8Schristosdone
32*059c16a8Schristos
33