Created initial parser
authorAlberto Ruiz <aruiz@gnome.org>
Mon, 4 Jul 2011 12:38:29 +0000 (13:38 +0100)
committerAlberto Ruiz <aruiz@gnome.org>
Mon, 4 Jul 2011 12:38:29 +0000 (13:38 +0100)
src/moonshot-webp-parser.vala

index 497e77c..2865432 100644 (file)
@@ -7,10 +7,41 @@ namespace WebProvisioning
       
     }
   }
+  
+  public void start_element_func (MarkupParseContext context,
+                             string             element_name,
+                             string[]           attribute_names,
+                             string[]           attribute_values) throws MarkupError
+  {
+    debug ("Start: %s", element_name);
+  }
+
+  public void end_element_func (MarkupParseContext context,
+                           string             element_name) throws MarkupError
+  {
+    debug ("End: %s", element_name);
+  }
+  
+  public void text_element_func (MarkupParseContext context,
+                            string text,
+                            size_t text_len) throws MarkupError
+  {
+    debug ("Text element: %s", text); 
+/*    for (string i in context.get_element_stack ())
+    {
+      stdout.printf("%s\n", i);
+    }*/
+  }
+  
+  public void parser_error (MarkupParseContext context,
+                            Error              error)
+  {
+    debug ("error");
+  }
 
   public static int main (string[] args)
   {
-    int64 size;
+    string text = "";
     if (args.length < 2)
     {
       error ("Usage %s [-a] WEB_PROVISIONING_FILE", args[0]);
@@ -25,14 +56,19 @@ namespace WebProvisioning
     
     try
     {
-      var info = file.query_info ("standard::size", FileQueryInfoFlags.NONE);
-      size = info.get_size();
+      var dis = new DataInputStream (file.read ());
+      string line;
+      while ((line = dis.read_line (null)) != null)
+        text += line;
     }
     catch (Error e)
     {
       error ("Could not retreive file size");
     }
     
+    MarkupParser parser = {start_element_func, end_element_func, text_element_func, null, parser_error};
+    
+    
     return 0;
   }
 }