New ecore_getopt callback to parse geometry size (WxH).
authorantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 13 Apr 2009 20:29:57 +0000 (20:29 +0000)
committerantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 13 Apr 2009 20:29:57 +0000 (20:29 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@40025 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore/Ecore_Getopt.h
src/lib/ecore/ecore_getopt.c

index 41834de..3ce4436 100644 (file)
@@ -382,6 +382,7 @@ extern "C" {
 
   /* helper functions to be used with ECORE_GETOPT_CALLBACK_*() */
   EAPI unsigned char ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage);
+  EAPI unsigned char ecore_getopt_callback_size_parse(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage);
 
 
 #ifdef __cplusplus
index 060c02c..a9a6e3a 100644 (file)
@@ -1666,3 +1666,28 @@ ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser __UNUSED__, cons
 
    return 1;
 }
+
+/**
+ * Helper ecore_getopt callback to parse geometry size (WxH).
+ *
+ * Storage must be a pointer to @c Eina_Rectangle and will be used to
+ * store the two values passed in the given string and 0 in the x and y
+ * fields.
+ *
+ * @c callback_data value is ignored, you can safely use @c NULL.
+ */
+unsigned char
+ecore_getopt_callback_size_parse(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *desc, const char *str, void *data, Ecore_Getopt_Value *storage)
+{
+   Eina_Rectangle *v = (Eina_Rectangle *)storage->ptrp;
+
+   if (sscanf(str, "%dx%d", &v->w, &v->h) != 2)
+     {
+       fprintf(stderr, "ERROR: incorrect size value '%s'\n", str);
+       return 0;
+     }
+   v->x = 0;
+   v->y = 0;
+
+   return 1;
+}