summaryrefslogtreecommitdiffstats
path: root/src/postconf/extract.awk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 01:46:30 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 01:46:30 +0000
commitb5896ba9f6047e7031e2bdee0622d543e11a6734 (patch)
treefd7b460593a2fee1be579bec5697e6d887ea3421 /src/postconf/extract.awk
parentInitial commit. (diff)
downloadpostfix-b5896ba9f6047e7031e2bdee0622d543e11a6734.tar.xz
postfix-b5896ba9f6047e7031e2bdee0622d543e11a6734.zip
Adding upstream version 3.4.23.upstream/3.4.23upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/postconf/extract.awk')
-rw-r--r--src/postconf/extract.awk190
1 files changed, 190 insertions, 0 deletions
diff --git a/src/postconf/extract.awk b/src/postconf/extract.awk
new file mode 100644
index 0000000..13b1f91
--- /dev/null
+++ b/src/postconf/extract.awk
@@ -0,0 +1,190 @@
+# Extract initialization tables from actual source code.
+
+# XXX: Associated variable aliasing:
+#
+# Some parameters bind to different variables in different contexts,
+# And other parameters map to associated variables in a many-to-1
+# fashion. This is mostly the result of the SMTP+LMTP integration
+# and the overloading of parameters that have identical semantics,
+# for the corresponding context.
+#
+# The "++table[...]" below ignores the associated variable name
+# when doing duplicate elimination. Differences in the default value
+# or lower/upper bounds still result in "postconf -d" duplicates,
+# which are a sign of an error somewhere...
+#
+# XXX Work around ancient AWK implementations with a 10 file limit
+# and no working close() operator (e.g. Solaris). Some systems
+# have a more modern implementation that is XPG4-compatible, but it
+# is too much bother to find out where each system keeps these.
+
+/^(static| )*(const +)?CONFIG_INT_TABLE .*\{/,/\};/ {
+ if ($1 ~ /VAR/) {
+ int_vars["int " substr($3,2,length($3)-2) ";"] = 1
+ if (++itab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ int_table[$0] = 1
+ }
+ }
+}
+/^(static| )*(const +)?CONFIG_STR_TABLE .*\{/,/\};/ {
+ if ($1 ~ /^VAR/) {
+ str_vars["char *" substr($3,2,length($3)-2) ";"] = 1
+ if (++stab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ str_table[$0] = 1
+ }
+ }
+}
+/^(static| )*(const +)?CONFIG_STR_FN_TABLE .*\{/,/\};/ {
+ if ($1 ~ /^VAR/) {
+ str_fn_vars["char *" substr($3,2,length($3)-2) ";"] = 1
+ $2 = "pcf_" $2
+ if (++stab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ str_fn_table[$0] = 1
+ }
+ }
+}
+/^(static| )*(const +)?CONFIG_RAW_TABLE .*\{/,/\};/ {
+ if ($1 ~ /^VAR/) {
+ raw_vars["char *" substr($3,2,length($3)-2) ";"] = 1
+ if (++rtab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ raw_table[$0] = 1
+ }
+ }
+}
+/^(static| )*(const +)?CONFIG_BOOL_TABLE .*\{/,/\};/ {
+ if ($1 ~ /^VAR/) {
+ bool_vars["int " substr($3,2,length($3)-2) ";"] = 1
+ if (++btab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ bool_table[$0] = 1
+ }
+ }
+}
+/^(static| )*(const +)?CONFIG_TIME_TABLE .*\{/,/\};/ {
+ if ($1 ~ /^VAR/) {
+ time_vars["int " substr($3,2,length($3)-2) ";"] = 1
+ if (++ttab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ time_table[$0] = 1
+ }
+ }
+}
+/^(static| )*(const +)?CONFIG_NINT_TABLE .*\{/,/\};/ {
+ if ($1 ~ /VAR/) {
+ nint_vars["int " substr($3,2,length($3)-2) ";"] = 1
+ if (++itab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ nint_table[$0] = 1
+ }
+ }
+}
+/^(static| )*(const +)?CONFIG_NBOOL_TABLE .*\{/,/\};/ {
+ if ($1 ~ /^VAR/) {
+ nbool_vars["int " substr($3,2,length($3)-2) ";"] = 1
+ if (++btab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ nbool_table[$0] = 1
+ }
+ }
+}
+/^(static| )*(const +)?CONFIG_LONG_TABLE .*\{/,/\};/ {
+ if ($1 ~ /VAR/) {
+ long_vars["long " substr($3,2,length($3)-2) ";"] = 1
+ if (++itab[$1 $2 $4 $5 $6 $7 $8 $9] == 1) {
+ long_table[$0] = 1
+ }
+ }
+}
+
+END {
+ # Print parameter declarations without busting old AWK's file limit.
+ print "cat >int_vars.h <<'EOF'"
+ for (key in int_vars)
+ print key
+ print "EOF"
+
+ print "cat >str_vars.h <<'EOF'"
+ for (key in str_vars)
+ print key
+ print "EOF"
+
+ print "cat >str_fn_vars.h <<'EOF'"
+ for (key in str_fn_vars)
+ print key
+ print "EOF"
+
+ print "cat >raw_vars.h <<'EOF'"
+ for (key in raw_vars)
+ print key
+ print "EOF"
+
+ print "cat >bool_vars.h <<'EOF'"
+ for (key in bool_vars)
+ print key
+ print "EOF"
+
+ print "cat >time_vars.h <<'EOF'"
+ for (key in time_vars)
+ print key
+ print "EOF"
+
+ print "cat >nint_vars.h <<'EOF'"
+ for (key in nint_vars)
+ print key
+ print "EOF"
+
+ print "cat >nbool_vars.h <<'EOF'"
+ for (key in nbool_vars)
+ print key
+ print "EOF"
+
+ print "cat >long_vars.h <<'EOF'"
+ for (key in long_vars)
+ print key
+ print "EOF"
+
+ # Print parameter initializations without busting old AWK's file limit.
+ print "sed 's/[ ][ ]*/ /g' >int_table.h <<'EOF'"
+ for (key in int_table)
+ print key
+ print "EOF"
+
+ print "sed 's/[ ][ ]*/ /g' >str_table.h <<'EOF'"
+ for (key in str_table)
+ print key
+ print "EOF"
+
+ print "sed 's/[ ][ ]*/ /g' >str_fn_table.h <<'EOF'"
+ for (key in str_fn_table)
+ print key
+ print "EOF"
+
+ print "sed 's/[ ][ ]*/ /g' >raw_table.h <<'EOF'"
+ for (key in raw_table)
+ print key
+ print "EOF"
+
+ print "sed 's/[ ][ ]*/ /g' >bool_table.h <<'EOF'"
+ for (key in bool_table)
+ print key
+ print "EOF"
+
+ print "sed 's/[ ][ ]*/ /g' >time_table.h <<'EOF'"
+ for (key in time_table)
+ print key
+ print "EOF"
+
+ print "sed 's/[ ][ ]*/ /g' >nint_table.h <<'EOF'"
+ for (key in nint_table)
+ print key
+ print "EOF"
+
+ print "sed 's/[ ][ ]*/ /g' >nbool_table.h <<'EOF'"
+ for (key in nbool_table)
+ print key
+ print "EOF"
+
+ print "sed 's/[ ][ ]*/ /g' >long_table.h <<'EOF'"
+ for (key in long_table)
+ print key
+ print "EOF"
+
+ # Flush output nicely.
+ exit(0);
+}