diff options
author | Erik Fonnesbeck <efonnes@gmail.com> | 2010-03-16 23:13:15 -0600 |
---|---|---|
committer | Erik Fonnesbeck <efonnes@gmail.com> | 2010-03-16 23:13:15 -0600 |
commit | 071d63b9ab639730ccbb2886adb9703c4d9a1c71 (patch) | |
tree | d9b42cd09663b7453445c9a284f305c361d4b08d /etc/inc/xmlparse.inc | |
parent | 441e6007989f3f9a835fd40ee606785edf300b2c (diff) | |
download | pfsense-071d63b9ab639730ccbb2886adb9703c4d9a1c71.zip pfsense-071d63b9ab639730ccbb2886adb9703c4d9a1c71.tar.gz |
Restore attribute support, but with some extra checks in the function that uses it.
Diffstat (limited to 'etc/inc/xmlparse.inc')
-rw-r--r-- | etc/inc/xmlparse.inc | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc index 7c5a554..85f18e7 100644 --- a/etc/inc/xmlparse.inc +++ b/etc/inc/xmlparse.inc @@ -59,14 +59,28 @@ function listtags_pkg() { return $ret; } +/* The following items will be treated as arrays in regdomain.xml */ +function listtags_rd() { + $ret = explode(" ", + "band country flags freqband netband rd " + ); + return $ret; +} + function startElement($parser, $name, $attrs) { - global $parsedcfg, $depth, $curpath, $havedata, $listtags; + global $parsedcfg, $depth, $curpath, $havedata, $listtags, $parsedattrs, $parsingattrs; array_push($curpath, strtolower($name)); $ptr =& $parsedcfg; + if (isset($parsingattrs) && !empty($attrs)) { + $attrptr =& $parsedattrs; + $writeattrs = true; + } foreach ($curpath as $path) { $ptr =& $ptr[$path]; + if (isset($writeattrs)) + $attrptr =& $attrptr[$path]; } /* is it an element that belongs to a list? */ @@ -80,11 +94,19 @@ function startElement($parser, $name, $attrs) { array_push($curpath, count($ptr)); + if (isset($writeattrs)) { + if (!is_array($attrptr)) + $attrptr = array(); + $attrptr[count($ptr)] = $attrs; + } + } 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))); + } else if (isset($writeattrs)) { + $attrptr = $attrs; } $depth++; @@ -154,6 +176,23 @@ function parse_xml_config_pkg($cffile, $rootobj, $isstring = "false") { return parse_xml_config_raw($cffile, $rootobj, $isstring); } +function parse_xml_regdomain(&$rdattributes, $rdfile = '/etc/regdomain.xml', $rootobj = 'regulatory-data') { + global $listtags, $parsedattrs, $parsingattrs; + $listtags = listtags_rd(); + if (isset($rdattributes)) { + $parsedattrs = array(); + $parsingattrs = true; + $ret = parse_xml_config_raw($rdfile, $rootobj); + if ($parsedattrs[$rootobj]) + $rdattributes = $parsedattrs[$rootobj]; + unset($parsedattrs); + unset($parsingattrs); + return $ret; + } else { + return parse_xml_config_raw($rdfile, $rootobj); + } +} + function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") { global $depth, $curpath, $parsedcfg, $havedata, $listtags; |