2 # implements nested file inclusion for control files, including wildcarding
3 # Copyright (C) 1998, 1999 Henry Spencer.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 # RCSID $Id: _include,v 1.14 2001/06/01 15:49:13 henry Exp $
17 # Output includes marker lines for file changes:
18 # "#< filename lineno" signals entry into that file
19 # "#> filename lineno" signals return to that file
20 # The lineno is the line number of the *next* line.
22 # Errors are reported with a "#:message" line rather than on stderr.
24 # Lines which look like marker and report lines are never passed through.
26 usage="Usage: $0 file ..."
32 --inband) ;; # back compatibility
33 --help) echo "$usage" ; exit 0 ;;
34 --version) echo "$me $IPSEC_VERSION" ; exit 0 ;;
36 -*) echo "$0: unknown option \`$1'" >&2 ; exit 2 ;;
43 0) echo "$usage" >&2 ; exit 2 ;;
50 echo "#:cannot open configuration file \"$f\""
60 print "#<", FILENAME, 1
66 # lineno is now the number of this line
75 msg = "(" FILENAME ", line " lineno ")"
76 msg = msg " include syntax error in \"" orig "\""
81 if (newfile !~ /^\// && FILENAME ~ /\//) {
83 sub("[^/]+$", "", prefix)
84 newfile = prefix newfile
86 system("ipsec _include " newfile)
88 print "#>", FILENAME, lineno + 1