Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_file
Modified Files:
Ecore_File.h ecore_file_path.c
Log Message:
search for exe's properly :)
===================================================================
RCS file:
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/Ecore_File.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- Ecore_File.h 4 Sep 2005 18:54:32 -0000 1.14
+++ Ecore_File.h 28 Sep 2005 05:57:41 -0000 1.15
@@ -76,7 +76,8 @@
EAPI void ecore_file_monitor_del(Ecore_File_Monitor
*ecore_file_monitor);
EAPI const char *ecore_file_monitor_path_get(Ecore_File_Monitor
*ecore_file_monitor);
- EAPI int ecore_file_app_installed(const char *app);
+ EAPI int ecore_file_app_installed(const char *exe);
+ EAPI char *ecore_file_app_exe_get(const char *app);
EAPI int ecore_file_download(const char *url, const char *dst,
void (*completion_cb)(void *data,
===================================================================
RCS file:
/cvsroot/enlightenment/e17/libs/ecore/src/lib/ecore_file/ecore_file_path.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ecore_file_path.c 28 Sep 2005 02:27:23 -0000 1.10
+++ ecore_file_path.c 28 Sep 2005 05:57:41 -0000 1.11
@@ -47,60 +47,131 @@
if (!*p)
{
ecore_list_append(path, strdup(last));
- last = p+1;
+ last = p + 1;
}
-
}
if (p > last)
- ecore_list_append(path, last);
+ ecore_list_append(path, strdup(last));
free(env_path);
return path;
}
int
-ecore_file_app_installed(const char *app)
+ecore_file_app_installed(const char *exe)
{
char *dir;
char buf[PATH_MAX];
- char *file, *p;
- if (!app) return 0;
- if (ecore_file_exists(app) && ecore_file_can_exec(app)) return 1;
+ if (!exe) return 0;
+ if (ecore_file_can_exec(exe)) return 1;
ecore_list_goto_first(__ecore_file_path_bin);
while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL)
{
- snprintf(buf, sizeof(buf), "%s/%s", dir, app);
- if (ecore_file_exists(buf) && ecore_file_can_exec(buf))
+ snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
+ if (ecore_file_can_exec(buf))
return 1;
}
+ return 0;
+}
- /* Maybe the app has arguments */
- file = strdup(app);
- if (!file) return 0;
- while ((*file) && isspace(*file))
- file++;
-
- p = file;
- while ((*p) && !isspace(*p))
- p++;
- if ((*file) && (*p))
+char *
+ecore_file_app_exe_get(const char *app)
+{
+ char *p, *pp, *exe1 = NULL, *exe2 = NULL;
+ char *exe;
+ int in_quot_dbl = 0, in_quot_sing = 0;
+
+ p = (char *)app;
+ while ((*p) && (isspace(*p))) p++;
+ exe1 = p;
+ while (*p)
+ {
+ if (in_quot_sing)
+ {
+ if (*p == '\'')
+ in_quot_sing = 0;
+ }
+ else if (in_quot_dbl)
+ {
+ if (*p == '\"')
+ in_quot_dbl = 0;
+ }
+ else
+ {
+ if (*p == '\'')
+ in_quot_sing = 1;
+ else if (*p == '\"')
+ in_quot_dbl = 1;
+ if ((isspace(*p)) && (!((p > app) && (p[-1] != '\\'))))
+ break;
+ }
+ p++;
+ }
+ exe2 = p;
+ if (exe2 == exe1) return NULL;
+ exe = malloc(exe2 - exe1 + 1);
+ if (!exe) return NULL;
+ p = exe1;
+ in_quot_dbl = 0;
+ in_quot_sing = 0;
+ pp = exe;
+ while (*p)
{
- *p = '\0';
- if (ecore_file_exists(file) && ecore_file_can_exec(file)) return 1;
- ecore_list_goto_first(__ecore_file_path_bin);
- while ((dir = ecore_list_next(__ecore_file_path_bin)) != NULL)
+ if (in_quot_sing)
{
- snprintf(buf, sizeof(buf), "%s/%s", dir, file);
- if (ecore_file_exists(buf) && ecore_file_can_exec(buf))
+ if (*p == '\'')
+ in_quot_sing = 0;
+ else
{
- free(file);
- return 1;
+ *pp = *p;
+ pp++;
}
}
+ else if (in_quot_dbl)
+ {
+ if (*p == '\"')
+ in_quot_dbl = 0;
+ else
+ {
+ /* techcincally this is wrong. double quotes also accept
+ * special chars:
+ *
+ * $, `, \
+ */
+ *pp = *p;
+ pp++;
+ }
+ }
+ else
+ {
+ /* technically we should handle special chars:
+ *
+ * $, `, \, etc.
+ */
+ if ((p > app) && (p[-1] == '\\'))
+ {
+ if (*p != '\n')
+ {
+ *pp = *p;
+ pp++;
+ }
+ }
+ else if (*p == '\'')
+ in_quot_sing = 1;
+ else if (*p == '\"')
+ in_quot_dbl = 1;
+ else if (isspace(*p))
+ break;
+ else
+ {
+ *pp = *p;
+ pp++;
+ }
+ }
+ p++;
}
- free(file);
-
- return 0;
+ *pp = 0;
+ return exe;
}
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs