New ecore_getopt callback to parse geometry size (WxH).

SVN revision: 40025
This commit is contained in:
Rafael Antognolli 2009-04-13 20:29:57 +00:00
parent af7c76de8c
commit 6129f4d71b
2 changed files with 26 additions and 0 deletions

View 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

View 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;
}