Enlightenment CVS committal

Author  : onefang
Project : e17
Module  : apps/e_utils

Dir     : e17/apps/e_utils/src/bin/e17genmenu/src/bin


Modified Files:
        parse.c 


Log Message:
Use the new parser for .desktop files.

===================================================================
RCS file: 
/cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/parse.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- parse.c     3 Feb 2006 01:34:18 -0000       1.7
+++ parse.c     3 Feb 2006 21:28:36 -0000       1.8
@@ -119,11 +119,10 @@
 void
 parse_desktop_file(char *path)
 {
-   char *home, *eap_name, *key, *value;
-   char buffer[MAX_PATH];
-   int length, overwrite;
-   FILE *file;
+   char *home, *eap_name;
+   int overwrite;
    G_Eap *eap;
+   Ecore_Hash *desktop;
 
    home = get_home();
    overwrite = get_overwrite();
@@ -133,59 +132,41 @@
    fprintf(stderr, "Parsing Desktop File %s\n", path);
 #endif
 
-   file = fopen(path, "r");
-   if (!file)
-     {
-        fprintf(stderr, "ERROR: Cannot Open File %s \n", path);
-        return;
-     }
-
    eap = calloc(1, sizeof(G_Eap));
    eap->eap_name = strdup(eap_name);
    if (eap_name)
       free(eap_name);
 
-   key = NULL;
-   value = NULL;
-   *buffer = 0;
-
-   /* Read All Entries, Store In Struct */
-   while (fgets(buffer, sizeof(buffer), file) != NULL)
-     {
-        /* Skip Blank Lines */
-        if (!(*buffer) || (*buffer == '\n'))
-           continue;
-        /* Strip New Line Char */
-        if (buffer[(length = strlen(buffer) - 1)] == '\n')
-           buffer[length] = '\0';
-        key = strtok(buffer, "=");
-        value = strstr(buffer, "=");
-        value = strtok(value, "=");
-        if ((value != NULL) && (key != NULL))
-          {
-             if (!strcmp(key, "Name"))
-                eap->name = strdup(value);
-             if (!strcmp(key, "GenericName"))
-                eap->generic = strdup(value);
-             if (!strcmp(key, "Comment"))
-                eap->comment = strdup(value);
-             if (!strcmp(key, "Categories"))
-                eap->categories = strdup(value);
-             if (!strcmp(key, "Exec"))
-                eap->exec = strdup(value);
-             if (!strcmp(key, "Icon"))
-                eap->icon = strdup(value);
-             if (!strcmp(key, "StartupNotify"))
-                eap->startup = (!strcmp(value, "true")) ? "1" : "0";
-             if (!strcmp(key, "X-KDE-StartupNotify"))
-                eap->startup = (!strcmp(value, "true")) ? "1" : "0";
-             if (!strcmp(key, "Type"))
-                eap->type = strdup(value);
-          }
-        value = NULL;
-        key = NULL;
-     }
-   fclose(file);
+   desktop = parse_ini_file(path);
+   if (desktop)
+      {
+         Ecore_Hash *group;
+
+         group = (Ecore_Hash *) ecore_hash_get(desktop, "Desktop Entry");
+        if (group)
+           {
+              char *value;
+
+               value = (char *) ecore_hash_get(group, "Name");
+              if (value)   eap->name = strdup(value);
+               value = (char *) ecore_hash_get(group, "GenericName");
+              if (value)   eap->generic = strdup(value);
+               value = (char *) ecore_hash_get(group, "Comment");
+              if (value)   eap->comment = strdup(value);
+               value = (char *) ecore_hash_get(group, "Type");
+              if (value)   eap->type = strdup(value);
+               value = (char *) ecore_hash_get(group, "Categories");
+              if (value)   eap->categories = strdup(value);
+               value = (char *) ecore_hash_get(group, "Exec");
+              if (value)   eap->exec = strdup(value);
+               value = (char *) ecore_hash_get(group, "Icon");
+              if (value)   eap->icon = strdup(value);
+               value = (char *) ecore_hash_get(group, "X-KDE-StartupNotify");
+              if (value)   eap->startup = (!strcmp(value, "true")) ? "1" : "0";
+               value = (char *) ecore_hash_get(group, "StartupNotify");
+              if (value)   eap->startup = (!strcmp(value, "true")) ? "1" : "0";
+            }
+      }
 
    /* Check If We Process */
    if (!eap->type)




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to