1 namespace WebProvisioning
3 class WebProvisionParser
5 public WebProvisionParser (string path)
11 public void start_element_func (MarkupParseContext context,
13 string[] attribute_names,
14 string[] attribute_values) throws MarkupError
16 debug ("Start: %s", element_name);
19 public void end_element_func (MarkupParseContext context,
20 string element_name) throws MarkupError
22 debug ("End: %s", element_name);
25 public void text_element_func (MarkupParseContext context,
27 size_t text_len) throws MarkupError
29 debug ("Text element: %s", text);
30 foreach (string elm in context.get_element_stack ())
32 stdout.printf("%s\n", elm);
37 public static int main (string[] args)
42 error ("Usage %s [-a] WEB_PROVISIONING_FILE", args[0]);
45 if (!FileUtils.test (args[1], FileTest.EXISTS | FileTest.IS_REGULAR))
47 error ("%s does not exist", args[1]);
50 var file = File.new_for_path (args[1]);
54 var dis = new DataInputStream (file.read ());
56 while ((line = dis.read_line (null)) != null)
61 error ("Could not retreive file size");
64 MarkupParser parser = {start_element_func, end_element_func, text_element_func, null, null};
66 var ctx = new MarkupParseContext(parser, 0, null, null);
70 ctx.parse (text, text.length);
74 error ("Could not parse %s, invalid content", args[1]);