summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2004-12-12 04:59:56 +0000
committerScott Ullrich <sullrich@pfsense.org>2004-12-12 04:59:56 +0000
commit528ae96e08c038ae88e7c5306f3e4efc875422f4 (patch)
treee669ae215a91ff300ecba828161e8ca7dbfb113e /etc
parent1a05a4ee81e1c19a69d86ce2b8ded287010a363e (diff)
downloadpfsense-528ae96e08c038ae88e7c5306f3e4efc875422f4.zip
pfsense-528ae96e08c038ae88e7c5306f3e4efc875422f4.tar.gz
Add tem field as array xml markers
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/xmlparse.inc58
1 files changed, 29 insertions, 29 deletions
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc
index 1fdadac..f6d5308 100644
--- a/etc/inc/xmlparse.inc
+++ b/etc/inc/xmlparse.inc
@@ -3,20 +3,20 @@
xmlparse.inc
functions to parse/dump configuration files in XML format
part of m0n0wall (http://m0n0.ch/wall)
-
+
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
-
+
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
@@ -30,46 +30,46 @@
*/
/* tags that are always to be handled as lists */
-$listtags = explode(" ", "rule user key subqueue dnsserver winsserver " .
+$listtags = explode(" ", "item field rule user key subqueue dnsserver winsserver " .
"encryption-algorithm-option hash-algorithm-option hosts tunnel onetoone " .
"staticmap route alias pipe queue shellcmd earlyshellcmd mobilekey " .
"servernat proxyarpnet passthrumac allowedip wolentry vlan");
function startElement($parser, $name, $attrs) {
global $depth, $curpath, $config, $havedata, $listtags;
-
+
array_push($curpath, strtolower($name));
-
+
$ptr =& $config;
foreach ($curpath as $path) {
$ptr =& $ptr[$path];
}
-
+
/* is it an element that belongs to a list? */
if (in_array(strtolower($name), $listtags)) {
-
+
/* is there an array already? */
if (!is_array($ptr)) {
/* make an array */
$ptr = array();
}
-
+
array_push($curpath, count($ptr));
-
+
} else if (isset($ptr)) {
/* multiple entries not allowed for this element, bail out */
die(sprintf("XML error: %s at line %d cannot occur more than once\n",
$name,
xml_get_current_line_number($parser)));
}
-
+
$depth++;
$havedata = $depth;
}
function endElement($parser, $name) {
global $depth, $curpath, $config, $havedata, $listtags;
-
+
if ($havedata == $depth) {
$ptr =& $config;
foreach ($curpath as $path) {
@@ -77,20 +77,20 @@ function endElement($parser, $name) {
}
$ptr = "";
}
-
+
array_pop($curpath);
if (in_array(strtolower($name), $listtags))
array_pop($curpath);
-
+
$depth--;
}
function cData($parser, $data) {
global $depth, $curpath, $config, $havedata;
-
+
$data = trim($data, "\t\n\r");
-
+
if ($data != "") {
$ptr =& $config;
foreach ($curpath as $path) {
@@ -116,16 +116,16 @@ function parse_xml_config($cffile, $rootobj) {
$curpath = array();
$depth = 0;
$havedata = 0;
-
+
$xml_parser = xml_parser_create();
-
+
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "cdata");
-
+
if (!($fp = fopen($cffile, "r"))) {
die("Error: could not open XML input\n");
}
-
+
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d\n",
@@ -134,18 +134,18 @@ function parse_xml_config($cffile, $rootobj) {
}
}
xml_parser_free($xml_parser);
-
+
if (!$config[$rootobj]) {
die("XML error: no $rootobj object found!\n");
}
-
+
return $config[$rootobj];
}
function dump_xml_config_sub($arr, $indent) {
global $listtags;
-
+
$xmlconfig = "";
foreach ($arr as $ent => $val) {
@@ -186,7 +186,7 @@ function dump_xml_config_sub($arr, $indent) {
}
}
}
-
+
return $xmlconfig;
}
@@ -194,11 +194,11 @@ function dump_xml_config($arr, $rootobj) {
$xmlconfig = "<?xml version=\"1.0\"?" . ">\n";
$xmlconfig .= "<$rootobj>\n";
-
+
$xmlconfig .= dump_xml_config_sub($arr, 1);
-
+
$xmlconfig .= "</$rootobj>\n";
-
+
return $xmlconfig;
}
OpenPOWER on IntegriCloud