Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : apps/entrance

Dir     : e17/apps/entrance/src/client


Modified Files:
        main.c util.c util.h 


Log Message:
refactoring from essien part 2

===================================================================
RCS file: /cvs/e/e17/apps/entrance/src/client/main.c,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -3 -r1.82 -r1.83
--- main.c      4 Jul 2006 02:54:51 -0000       1.82
+++ main.c      22 Jul 2006 09:00:42 -0000      1.83
@@ -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;
===================================================================
RCS file: /cvs/e/e17/apps/entrance/src/client/util.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- util.c      27 Jun 2004 19:33:28 -0000      1.4
+++ util.c      22 Jul 2006 09:00:43 -0000      1.5
@@ -1,3 +1,6 @@
+#include <string.h>
+#include <stdlib.h>
+#include "entrance.h"
 #include "util.h"
 #include <Evas.h>
 
@@ -73,4 +76,47 @@
 {
    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)
+{
+       char* sep = gstr_is_valid(gstr);
+
+       if(sep) {
+               *x = atoi((const char *) gstr);
+               *y = atoi((const char *) (sep + 1));
+               free(sep);
+       }
 }
===================================================================
RCS file: /cvs/e/e17/apps/entrance/src/client/util.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- util.h      16 Aug 2005 04:03:27 -0000      1.4
+++ util.h      22 Jul 2006 09:00:43 -0000      1.5
@@ -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-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to