Enlightenment CVS committal
Author : onefang
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_desktop
Modified Files:
Ecore_Desktop.h ecore_desktop.c ecore_desktop_menu.c
ecore_desktop_paths.c
Log Message:
Some debuggin', valgrindin', and constifyin`.
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/Ecore_Desktop.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- Ecore_Desktop.h 17 Aug 2006 20:24:36 -0000 1.11
+++ Ecore_Desktop.h 18 Aug 2006 21:52:33 -0000 1.12
@@ -88,23 +88,21 @@
/* Function Prototypes */
EAPI int ecore_desktop_paths_init(void);
char *ecore_desktop_paths_file_find(Ecore_List * paths,
- char *file, int sub,
- int (*func) (const
- void
+ const char *file, const int
sub,
+ int (*func) (void
*data,
- char
+ const char
*path),
- const void *data);
- char *ecore_desktop_paths_recursive_search(char *path, char
*d,
+ void *data);
+ char *ecore_desktop_paths_recursive_search(const char *path,
const char *file,
int (*dir_func)
- (const void *data,
- char *path),
- int (*func) (const
- void
+ (void *data,
+ const char *path),
+ int (*func) (void
*data,
- char
+ const
char
*path),
- const void *data);
+ void *data);
EAPI int ecore_desktop_paths_shutdown(void);
Ecore_Hash *ecore_desktop_paths_to_hash(const char *paths);
@@ -154,7 +152,7 @@
int element,
int level),
const void *data);
- void ecore_esktop_tree_dump(Ecore_Desktop_Tree * tree,
+ void ecore_desktop_tree_dump(Ecore_Desktop_Tree * tree,
int level);
void ecore_desktop_tree_del(Ecore_Desktop_Tree * tree);
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- ecore_desktop.c 17 Aug 2006 17:09:23 -0000 1.9
+++ ecore_desktop.c 18 Aug 2006 21:52:33 -0000 1.10
@@ -191,6 +191,8 @@
result->eap_name = malloc(strlen(value) + 5);
if (result->eap_name)
sprintf(result->eap_name, "%s.eap", value);
+ if (temp)
+ *temp = '.';
}
eap_name = result->eap_name;
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop_menu.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- ecore_desktop_menu.c 17 Aug 2006 17:09:23 -0000 1.7
+++ ecore_desktop_menu.c 18 Aug 2006 21:52:33 -0000 1.8
@@ -60,14 +60,14 @@
static int _ecore_desktop_menu_unxml(const void *data,
Ecore_Desktop_Tree * tree,
int element, int level);
-static int _ecore_desktop_menu_check_directory(const void *data,
- char *path);
-static int _ecore_desktop_menu_check_menu(const void *data,
- char *path);
-static int _ecore_desktop_menu_legacy_menu_dir(const void *data,
- char *path);
-static int _ecore_desktop_menu_legacy_menu(const void *data,
- char *path);
+static int _ecore_desktop_menu_check_directory(void *data,
+ const char *path);
+static int _ecore_desktop_menu_check_menu(void *data,
+ const char *path);
+static int _ecore_desktop_menu_legacy_menu_dir(void *data,
+ const char *path);
+static int _ecore_desktop_menu_legacy_menu(void *data,
+ const char *path);
static void _ecore_desktop_menu_unxml_rules(Ecore_Desktop_Tree * rules,
Ecore_Desktop_Tree * tree,
char type, char sub_type);
@@ -81,8 +81,8 @@
_ecore_desktop_menu_unxml_data
*unxml_data, char *app_dir,
Ecore_Hash * pool);
-static int _ecore_desktop_menu_check_app(const void *data,
- char *path);
+static int _ecore_desktop_menu_check_app(void *data,
+ const char *path);
static int _ecore_desktop_menu_merge(const void *data,
Ecore_Desktop_Tree * tree,
@@ -203,6 +203,7 @@
ecore_desktop_tree_foreach(menu_xml, 0,
_ecore_desktop_menu_generate,
&data);
+
data.unallocated = TRUE;
ecore_desktop_tree_foreach(menu_xml, 0,
_ecore_desktop_menu_generate,
@@ -562,7 +563,7 @@
}
static int
-_ecore_desktop_menu_check_directory(const void *data, char *path)
+_ecore_desktop_menu_check_directory(void *data, const char *path)
{
char *p;
Ecore_Desktop_Tree *merge;
@@ -584,7 +585,7 @@
}
static int
-_ecore_desktop_menu_check_menu(const void *data, char *path)
+_ecore_desktop_menu_check_menu(void *data, const char *path)
{
char *p;
Ecore_Desktop_Tree *merge;
@@ -606,10 +607,11 @@
}
static int
-_ecore_desktop_menu_legacy_menu_dir(const void *data, char *path)
+_ecore_desktop_menu_legacy_menu_dir(void *data, const char *path)
{
struct _ecore_desktop_menu_legacy_data *legacy_data;
Ecore_Desktop_Tree *menu;
+ char *temp_path;
int start;
int i, count = 0;
@@ -635,45 +637,50 @@
start = legacy_data->length;
count = 0;
- for (i = legacy_data->length; path[i] != '\0'; i++)
- {
- if (path[i] == '/')
- {
- if (count >= legacy_data->level)
- {
- path[i] = '\0';
- menu = _ecore_desktop_menu_create_menu();
- if (menu)
- {
- char temp[PATH_MAX];
-
- sprintf(temp, "<MENU < L> <%s> <>", &path[start]);
- menu->elements[0].element = strdup(temp);
- ecore_desktop_tree_track(menu,
+ temp_path = strdup(path);
+ if (temp_path)
+ {
+ for (i = legacy_data->length; temp_path[i] != '\0'; i++)
+ {
+ if (temp_path[i] == '/')
+ {
+ if (count >= legacy_data->level)
+ {
+ temp_path[i] = '\0';
+ menu = _ecore_desktop_menu_create_menu();
+ if (menu)
+ {
+ char temp[PATH_MAX];
+
+ sprintf(temp, "<MENU < L> <%s> <>",
&temp_path[start]);
+ menu->elements[0].element = strdup(temp);
+ ecore_desktop_tree_track(menu,
menu->elements[0].element);
- sprintf(temp, "<MENU_PATH %s/%s", legacy_data->menu,
- &path[legacy_data->length]);
- menu->elements[1].element = strdup(temp);
- ecore_desktop_tree_track(menu,
+ sprintf(temp, "<MENU_PATH %s/%s",
legacy_data->menu,
+ &temp_path[legacy_data->length]);
+ menu->elements[1].element = strdup(temp);
+ ecore_desktop_tree_track(menu,
menu->elements[1].element);
- ecore_desktop_tree_add_child(legacy_data->current, menu);
- /* This is not needed, but if it was, this is where it
would go.
- * sprintf(temp, "<AppDir %s/", path);
- * ecore_desktop_tree_extend(menu, temp);
- */
- sprintf(temp, "<DirectoryDir %s/", path);
- ecore_desktop_tree_extend(menu, temp);
-
- legacy_data->current = menu;
- legacy_data->level++;
- }
- path[i] = '/';
- }
- start = i + 1;
- count++;
- }
- }
+ ecore_desktop_tree_add_child(legacy_data->current,
menu);
+ /* This is not needed, but if it was, this is
where it would go.
+ * sprintf(temp, "<AppDir %s/", temp_path);
+ * ecore_desktop_tree_extend(menu, temp);
+ */
+ sprintf(temp, "<DirectoryDir %s/", temp_path);
+ ecore_desktop_tree_extend(menu, temp);
+
+ legacy_data->current = menu;
+ legacy_data->level++;
+ }
+ temp_path[i] = '/';
+ }
+ start = i + 1;
+ count++;
+ }
+ }
+ free(temp_path);
+ }
legacy_data->level = count;
@@ -681,10 +688,11 @@
}
static int
-_ecore_desktop_menu_legacy_menu(const void *data, char *path)
+_ecore_desktop_menu_legacy_menu(void *data, const char *path)
{
struct _ecore_desktop_menu_legacy_data *legacy_data;
- char *menu_path, *file;
+ char *menu_path;
+ char *file;
char temp[PATH_MAX];
int i, count = 0, menu_count = 0;
@@ -741,7 +749,7 @@
menu_count = strlen(menu_path);
if (menu_count)
menu_count++;
- file = &path[legacy_data->length + menu_count];
+ file = (char *) &path[legacy_data->length + menu_count];
count = strlen(file);
if (strcmp(".directory", file) == 0)
@@ -772,6 +780,9 @@
}
sprintf(temp, "%s%s", legacy_data->prefix, file);
ecore_hash_set(pool, strdup(temp), strdup(path));
+#ifdef DEBUG
+ printf("POOLING - _ecore_desktop_menu_legacy_menu(void *data, %s) - %s
- %s\n", path, file, temp);
+#endif
if (rules->size > 0)
{
rules = (Ecore_Desktop_Tree *) rules->elements[0].element;
@@ -779,6 +790,10 @@
ecore_desktop_tree_extend(rules, temp);
}
}
+#ifdef DEBUG
+ else
+ printf("PROBLEM - _ecore_desktop_menu_legacy_menu(void *data, %s) -
%s\n", path, file);
+#endif
return 0;
}
@@ -942,7 +957,7 @@
}
static int
-_ecore_desktop_menu_check_app(const void *data, char *path)
+_ecore_desktop_menu_check_app(void *data, const char *path)
{
char *p;
struct _ecore_desktop_menu_expand_apps_data *our_data;
@@ -963,8 +978,15 @@
if (file[i] == '/')
file[i] = '-';
ecore_hash_set(our_data->pool, file, strdup(path));
+#ifdef DEBUG
+ printf("POOLING - _ecore_desktop_menu_check_app(void *data,
%s) - %s\n", path, file);
+#endif
}
}
+#ifdef DEBUG
+ else
+ printf("PROBLEM - _ecore_desktop_menu_check_app(void *data, %s)\n",
path);
+#endif
}
return 1;
@@ -1425,6 +1447,9 @@
node = (Ecore_Hash_Node *) value;
key = (char *)node->key;
app = (char *)node->value;
+#ifdef DEBUG
+ printf("CHECKING %s - %s\n", key, app);
+#endif
if (!ecore_hash_get(pool, key))
ecore_hash_set(pool, strdup(key), strdup(app));
}
@@ -1456,16 +1481,16 @@
{
ecore_hash_set(generate_data->apps, key, strdup(app));
#ifdef DEBUG
- printf("INCLUDING %s%s\n",
- ((generate_data->unallocated) ? "UNALLOCATED " : ""), key);
+ printf("INCLUDING %s%s - %s\n",
+ ((generate_data->unallocated) ? "UNALLOCATED " : ""), key,
app);
#endif
}
else
{
ecore_hash_remove(generate_data->apps, key);
#ifdef DEBUG
- printf("EXCLUDING %s%s\n",
- ((generate_data->unallocated) ? "UNALLOCATED " : ""), key);
+ printf("EXCLUDING %s%s - %s\n",
+ ((generate_data->unallocated) ? "UNALLOCATED " : ""), key,
app);
#endif
}
}
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop_paths.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- ecore_desktop_paths.c 17 Aug 2006 20:24:36 -0000 1.8
+++ ecore_desktop_paths.c 18 Aug 2006 21:52:33 -0000 1.9
@@ -250,6 +250,8 @@
* only the first file found will be returned. If func is defined, then each
* file found will be passed to func, until func returns 1.
*
+ * The returned string will have to be freed eventually.
+ *
* @param type The type of directories to search.
* @param file The file to search for.
* @param sub Should we search sub directories.
@@ -257,9 +259,9 @@
* @param data A pointer to pass on to func.
*/
char *
-ecore_desktop_paths_file_find(Ecore_List * paths, char *file, int sub,
- int (*func) (const void *data, char *path),
- const void *data)
+ecore_desktop_paths_file_find(Ecore_List * paths, const char *file, const int
sub,
+ int (*func) (void *data, const char *path),
+ void *data)
{
char *path = NULL, *this_path;
char temp[PATH_MAX];
@@ -270,13 +272,14 @@
ecore_list_goto_first(paths);
while ((this_path = ecore_list_next(paths)) != NULL)
{
- sprintf(temp, "%s%s", this_path, file);
+ snprintf(temp, PATH_MAX, "%s%s", this_path, file);
if (stat(temp, &path_stat) == 0)
{
- /* FIXME: This is defensive but leaks. */
+ if (path)
+ free(path);
path = strdup(temp);
if (func)
- if (func(data, path))
+ if (func(data, temp))
break;
}
else if (sub)
@@ -536,11 +539,11 @@
}
char *
-ecore_desktop_paths_recursive_search(char *path, char *file,
- int (*dir_func) (const void *data,
- char *path),
- int (*func) (const void *data, char *path),
- const void *data)
+ecore_desktop_paths_recursive_search(const char *path, const char *file,
+ int (*dir_func) (void *data,
+ const char *path),
+ int (*func) (void *data, const char *path),
+ void *data)
{
char *fpath = NULL;
DIR *dir = NULL;
@@ -554,7 +557,7 @@
while ((script = readdir(dir)) != NULL)
{
struct stat script_stat;
- char info_text[4096];
+ char info_text[PATH_MAX];
sprintf(info_text, "%s%s", path, script->d_name);
if ((stat(info_text, &script_stat) == 0))
@@ -564,7 +567,7 @@
if ((strcmp(basename(info_text), ".") != 0)
&& (strcmp(basename(info_text), "..") != 0))
{
- sprintf(info_text, "%s%s/", path, script->d_name);
+ snprintf(info_text, PATH_MAX, "%s%s/", path,
script->d_name);
if (dir_func)
if (dir_func(data, info_text))
break;
@@ -581,7 +584,8 @@
{
if (strcmp(basename(info_text), file) == 0)
{
- /* FIXME: This is defensive but leaks. */
+ if (fpath)
+ free(fpath);
fpath = strdup(info_text);
if (func)
if (func(data, path))
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs