2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 function macro_file
() {
26 # Make the name uppercase.
31 for dir
in ${FIREWALL_MACROS_DIRS}; do
32 file="${dir}/${macro}"
34 if [ -r "${file}" ]; then
43 function macro_exists
() {
47 macro_file
${macro} &>/dev
/null \
48 && return ${EXIT_TRUE} ||
return ${EXIT_FALSE}
51 function macro_read
() {
55 # Make the name uppercase.
58 local file=$
(macro_file
${macro})
61 log DEBUG
"Parsing macro '${macro}' (${file})."
69 while read src dst proto sport dport
; do
70 # Skip lines that start with a "#".
71 [ "${src:0:1}" = "#" ] && continue
73 if [ "${src}" = "INCLUDE" ]; then
80 # Remove all the dashes.
81 for var
in src dst proto sport dport
; do
82 [ "${!var}" = "-" ] && continue
84 line
="${line} ${var}=\"${!var}\""
87 line
="$(echo ${line})"