~ubuntu-branches/ubuntu/natty/steam/natty

« back to all changes in this revision

Viewing changes to server/libraries/Module.pmod

  • Committer: Bazaar Package Importer
  • Author(s): Alain Schroeder
  • Date: 2005-05-14 16:33:35 UTC
  • Revision ID: james.westby@ubuntu.com-20050514163335-5v7lbxibmlww15dx
Tags: upstream-1.6.3
ImportĀ upstreamĀ versionĀ 1.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
mapping read_config(string cfg_data, string rtag)
 
2
{
 
3
    if ( !stringp(cfg_data) || strlen(cfg_data) == 0 )
 
4
        return 0;
 
5
    
 
6
    Parser.XML.Tree.Node node = Parser.XML.Tree.parse_input(cfg_data);
 
7
    
 
8
    if ( !objectp(node) )
 
9
        error("Failed to parse data.");
 
10
    
 
11
    mapping conf = ([ ]); 
 
12
    
 
13
    node = node->get_first_element(rtag);
 
14
    foreach(node->get_elements(), Parser.XML.Tree.Node n) { 
 
15
      string t = n->get_tag_name();
 
16
      string val = n->get_last_child()->get_text();
 
17
      if ( stringp(conf[t]) )
 
18
        conf[t] = ({ conf[t], val });
 
19
      else if ( arrayp(conf[t]) )
 
20
        conf[t] += ({ val });
 
21
      else
 
22
        conf[n->get_tag_name()] = val;
 
23
    }
 
24
    return conf;
 
25
}
 
26