Added more data fields to IdCard, new TrustAnchor class
[moonshot-ui.git] / src / moonshot-webp-parser.vala
1 namespace WebProvisioning
2
3   public IdCard card;
4
5   public void text_element_func (MarkupParseContext context,
6                                  string text,
7                                  size_t text_len) throws MarkupError
8   {
9     unowned SList<string> stack = context.get_element_stack ();
10     
11     if (stack.nth_data(0) == "display-name")
12     {
13       
14     }
15
16     
17   }
18
19   class WebProvisionParser
20   {
21     public WebProvisionParser (string path)
22     {
23       string text = "";
24       var file = File.new_for_path (path);
25     
26       try
27       {
28         var dis = new DataInputStream (file.read ());
29         string line;
30         while ((line = dis.read_line (null)) != null)
31           text += line;
32       }
33       catch (Error e)
34       {
35         error ("Could not retreive file size");
36       }
37       
38       MarkupParser parser = {null, null, text_element_func, null, null};
39       
40       var ctx = new MarkupParseContext(parser, 0, null, null);
41       
42       try
43       {
44         ctx.parse (text, text.length);
45       }
46       catch (Error e)
47       {
48         error ("Could not parse %s, invalid content", path);
49       } 
50     }
51   }
52
53   public static int main (string[] args)
54   {
55     if (args.length < 2)
56     {
57       error ("Usage %s [-a] WEB_PROVISIONING_FILE", args[0]);
58     }
59     
60     if (!FileUtils.test (args[1], FileTest.EXISTS | FileTest.IS_REGULAR))
61     {
62       error ("%s does not exist", args[1]);
63     }
64     
65     var webp = new WebProvisionParser (args[1]);
66
67     return 0;
68   }
69 }