diff options
Diffstat (limited to 'etc/inc/xmlparse.inc')
-rw-r--r-- | etc/inc/xmlparse.inc | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc index 7c5a554..f8a90c1 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,18 @@ 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(); + $parsedattrs = array(); + $parsingattrs = true; + $ret = parse_xml_config_raw($rdfile, $rootobj); + $rdattributes = $parsedattrs[$rootobj]; + unset($parsedattrs); + unset($parsingattrs); + return $ret; +} + function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") { global $depth, $curpath, $parsedcfg, $havedata, $listtags; |