I know I said before that I'd take a look at them, and I know I did and
they looked good for the most part. Somehow I got distracted and never
got them committed. I remember thinking the two functions for getting
the geometries could be combined into a single one (since they were
almost duplicate, and were called in succession iirc).
Yeah, that was my original intent, but i thought it an overkill to
return a geometry struct, or returning values via passed in pointers
(doesn't feel too natural) or even a two int array (like pipe() does).
rephorm
okie dokie. this modified patch follows rephorms suggestion, so the
geometry parsing is now:
atog(const char*, int *, int*);
This seems to be inline with the rest of EFL apis.
the rest stays the same.
cheers,
Essien
diff -aur entrance/src/client/main.c entrance.cleanups/src/client/main.c
--- entrance/src/client/main.c 2006-07-05 20:52:08.000000000 +0100
+++ entrance.cleanups/src/client/main.c 2006-07-21 18:48:29.000000000 +0100
@@ -716,8 +716,6 @@
/* Parse command-line options */
while (1)
{
- char *t;
-
c = getopt_long(argc, argv, "hd:g:t:Tc:z:", d_opt, NULL);
if (c == -1)
break;
@@ -729,45 +727,22 @@
display = strdup(optarg);
break;
case 'g':
- t = strchr((const char *) optarg, 'x');
- if (!t || t >= (optarg + strlen(optarg)))
- {
- syslog(LOG_CRIT,
- "Invalid argument '%s' given for geometry. Exiting.",
- optarg);
- return (-1);
- }
- else
- {
- g_x = atoi((const char *) optarg);
- g_y = atoi((const char *) (t + 1));
- if (!g_x || !g_y)
- {
- syslog(LOG_CRIT,
- "Invalid argument '%s' given for geometry. Exiting.",
- optarg);
- return (-1);
- }
- fullscreen = 0;
- }
- break;
+ atog(optarg, &g_x, &g_y);
+
+ if (!g_x || !g_y)
+ {
+ syslog(LOG_CRIT,
+ "Invalid argument '%s' given for geometry. Exiting.",
+ optarg);
+ return (-1);
+ }
+
+ fullscreen = 0;
+ break;
case 't':
/* Allow arbitrary paths to theme files */
- t = strchr((const char *) optarg, '/');
- if (t)
- theme = strdup(optarg);
- else
- {
- theme = calloc(1, PATH_MAX);
- t = strrchr((const char *) optarg, '.');
- if (t && !strcmp(t, ".edj"))
- snprintf(theme, PATH_MAX, "%s/themes/%s", PACKAGE_DATA_DIR,
- optarg);
- else
- snprintf(theme, PATH_MAX, "%s/themes/%s.edj",
- PACKAGE_DATA_DIR, optarg);
- }
- break;
+ theme = theme_normalize_path(theme, optarg);
+ break;
case 'T':
testing = 1;
fullscreen = 0;
diff -aur entrance/src/client/util.c entrance.cleanups/src/client/util.c
--- entrance/src/client/util.c 2004-06-27 20:33:28.000000000 +0100
+++ entrance.cleanups/src/client/util.c 2006-07-21 18:48:29.000000000 +0100
@@ -1,3 +1,6 @@
+#include <string.h>
+#include <stdlib.h>
+#include "entrance.h"
#include "util.h"
#include <Evas.h>
@@ -74,3 +77,46 @@
if (ENTRANCE_DEBUG)
printf("%s\n", msg);
}
+
+char* theme_normalize_path(char *theme, const char * filename)
+{
+ char* t = strchr((const char *) filename, '/');
+ if (t)
+ theme = strdup(filename);
+ else
+ {
+ theme = calloc(1, PATH_MAX);
+ t = strrchr((const char *) filename, '.');
+ if (t && !strcmp(t, ".edj"))
+ snprintf(theme, PATH_MAX, "%s/themes/%s", PACKAGE_DATA_DIR,
+ filename);
+ else
+ snprintf(theme, PATH_MAX, "%s/themes/%s.edj",
+ PACKAGE_DATA_DIR, filename);
+ }
+
+ return theme;
+}
+
+
+char* gstr_is_valid(const char* gstr)
+{
+ char *t = strchr((const char *) gstr, 'x');
+ if (!t || t >= (gstr + strlen(gstr)))
+ {
+ return NULL;
+ }
+
+ return strdup(t);
+}
+
+void atog(const char* gstr, int *x, int *y) /*uhh.. i'm innocent honest :P*/
+{
+ char* sep = gstr_is_valid(gstr);
+
+ if(sep) {
+ *x = atoi((const char *) gstr);
+ *y = atoi((const char *) (sep + 1));
+ free(sep);
+ }
+}
diff -aur entrance/src/client/util.h entrance.cleanups/src/client/util.h
--- entrance/src/client/util.h 2005-08-16 05:03:27.000000000 +0100
+++ entrance.cleanups/src/client/util.h 2006-07-21 18:48:29.000000000 +0100
@@ -19,4 +19,7 @@
void entrance_edje_object_resize_intercept_cb(void *data, Evas_Object * o,
Evas_Coord w, Evas_Coord h);
+char* theme_normalize_path(char*, const char*);
+void atog(const char*, int *, int *);
+
#endif
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel