diff options
author | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2006-05-22 05:12:18 +0000 |
---|---|---|
committer | Rene Mayrhofer <rene@mayrhofer.eu.org> | 2006-05-22 05:12:18 +0000 |
commit | aa0f5b38aec14428b4b80e06f90ff781f8bca5f1 (patch) | |
tree | 95f3d0c8cb0d59d88900dbbd72110d7ab6e15b2a /programs/_include/_include.in | |
parent | 7c383bc22113b23718be89fe18eeb251942d7356 (diff) | |
download | vyos-strongswan-aa0f5b38aec14428b4b80e06f90ff781f8bca5f1.tar.gz vyos-strongswan-aa0f5b38aec14428b4b80e06f90ff781f8bca5f1.zip |
Import initial strongswan 2.7.0 version into SVN.
Diffstat (limited to 'programs/_include/_include.in')
-rwxr-xr-x | programs/_include/_include.in | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/programs/_include/_include.in b/programs/_include/_include.in new file mode 100755 index 000000000..10a8a49e4 --- /dev/null +++ b/programs/_include/_include.in @@ -0,0 +1,102 @@ +#! /bin/sh +# implements nested file inclusion for control files, including wildcarding +# Copyright (C) 1998, 1999 Henry Spencer. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# RCSID $Id: _include.in,v 1.2 2004/03/15 21:03:06 as Exp $ +# +# Output includes marker lines for file changes: +# "#< filename lineno" signals entry into that file +# "#> filename lineno" signals return to that file +# The lineno is the line number of the *next* line. +# +# Errors are reported with a "#:message" line rather than on stderr. +# +# Lines which look like marker and report lines are never passed through. + +IPSEC_NAME="strongSwan" + +usage="Usage: $0 file ..." +me="ipsec _include" + +for dummy +do + case "$1" in + --inband) ;; # back compatibility + --help) echo "$usage" ; exit 0 ;; + --version) echo "$me $IPSEC_VERSION" ; exit 0 ;; + --) shift ; break ;; + -*) echo "$0: unknown option \`$1'" >&2 ; exit 2 ;; + *) break ;; + esac + shift +done + +case $# in +0) echo "$usage" >&2 ; exit 2 ;; +esac + +for f +do + if test ! -r "$f" + then + if test ! "$f" = "/etc/ipsec.conf" + then + echo "#:cannot open configuration file \'$f\'" + if test "$f" = "/etc/ipsec.secrets" + then + echo "#:Your secrets file will be created when you start $IPSEC_NAME for the first time." + fi + exit 1 + else + exit 1 + fi + fi +done + +awk 'BEGIN { + wasfile = "" +} +FNR == 1 { + print "" + print "#<", FILENAME, 1 + lineno = 0 + wasfile = FILENAME +} +{ + lineno++ + # lineno is now the number of this line +} +/^#[<>:]/ { + next +} +/^include[ \t]+/ { + orig = $0 + sub(/[ \t]+#.*$/, "") + if (NF != 2) { + msg = "(" FILENAME ", line " lineno ")" + msg = msg " include syntax error in \"" orig "\"" + print "#:" msg + exit 1 + } + newfile = $2 + if (newfile !~ /^\// && FILENAME ~ /\//) { + prefix = FILENAME + sub("[^/]+$", "", prefix) + newfile = prefix newfile + } + system("ipsec _include " newfile) + print "" + print "#>", FILENAME, lineno + 1 + next +} +{ print }' $* |