Enlightenment CVS committal Author : onefang Project : e17 Module : apps/e_utils
Dir : e17/apps/e_utils/src/bin/e17genmenu/src/bin Modified Files: fdo_paths.c fdo_paths.h main.c Log Message: Add a callback function to the fdo search. =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/fdo_paths.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- fdo_paths.c 1 Feb 2006 19:03:21 -0000 1.1 +++ fdo_paths.c 1 Feb 2006 19:37:58 -0000 1.2 @@ -28,7 +28,7 @@ static void _fdo_paths_check_and_add(Fdo_Path_List * paths, char *path); static Fdo_Path_List *_fdo_paths_get(char *env, char *type, char *gnome_extra, char *kde); -static char *_fdo_paths_recursive_search(char *path, char *d); +static char *_fdo_paths_recursive_search(char *path, char *d, int (*func) (const void *data, char *path), const void *data); /* We need - config file full of paths @@ -314,7 +314,7 @@ } char * -fdo_paths_search_for_file(Fdo_Paths_Type type, char *file) +fdo_paths_search_for_file(Fdo_Paths_Type type, char *file, int (*func) (const void *data, char *path), const void *data) { int i; char *path = NULL; @@ -342,10 +342,15 @@ { sprintf(temp, "%s%s", paths->list[i], file); if (stat(temp, &path_stat) == 0) - path = strdup(temp); + { + path = strdup(temp); + if (func) + if (func(data, path)) + break; + } else - path = _fdo_paths_recursive_search(paths->list[i], file); - if (path) + path = _fdo_paths_recursive_search(paths->list[i], file, func, data); + if (path && (!func)) break; } @@ -353,7 +358,7 @@ } static char * -_fdo_paths_recursive_search(char *path, char *file) +_fdo_paths_recursive_search(char *path, char *file, int (*func) (const void *data, char *path), const void *data) { char *fpath = NULL; DIR *dir = NULL; @@ -380,15 +385,20 @@ { sprintf(info_text, "%s%s/", path, script->d_name); fpath = - _fdo_paths_recursive_search(info_text, file); + _fdo_paths_recursive_search(info_text, file, func, data); } } else { if (strcmp(basename(info_text), file) == 0) - fpath = strdup(info_text); + { + fpath = strdup(info_text); + if (func) + if (func(data, path)) + break; + } } - if (fpath) + if (fpath && (!func)) break; } } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/fdo_paths.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- fdo_paths.h 1 Feb 2006 19:03:22 -0000 1.1 +++ fdo_paths.h 1 Feb 2006 19:37:59 -0000 1.2 @@ -31,7 +31,7 @@ # endif void fdo_paths_init(); - char *fdo_paths_search_for_file(Fdo_Paths_Type type, char *file); + char *fdo_paths_search_for_file(Fdo_Paths_Type type, char *file, int (*func) (const void *data, char *path), const void *data); void fdo_paths_shutdown(); # ifdef __cplusplus =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e_utils/src/bin/e17genmenu/src/bin/main.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- main.c 1 Feb 2006 19:03:22 -0000 1.5 +++ main.c 1 Feb 2006 19:37:59 -0000 1.6 @@ -43,7 +43,7 @@ printf("FDO icon path = %s\n", fdo_paths_icons->list[i]); /* First, find the main menu file. */ - path = fdo_paths_search_for_file(FDO_PATHS_TYPE_MENU, menu); + path = fdo_paths_search_for_file(FDO_PATHS_TYPE_MENU, menu, NULL, NULL); if (path) { char *directory = "Applications.directory"; @@ -56,21 +56,21 @@ /* During the processing of the menu file, you will need to search for * .directory files, .desktop files, and icons. */ - path = fdo_paths_search_for_file(FDO_PATHS_TYPE_DIRECTORY, directory); + path = fdo_paths_search_for_file(FDO_PATHS_TYPE_DIRECTORY, directory, NULL, NULL); if (path) { printf("Path to %s is %s\n", directory, path); free(path); } - path = fdo_paths_search_for_file(FDO_PATHS_TYPE_DESKTOP, desktop); + path = fdo_paths_search_for_file(FDO_PATHS_TYPE_DESKTOP, desktop, NULL, NULL); if (path) { printf("Path to %s is %s\n", desktop, path); free(path); } - path = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, icon); + path = fdo_paths_search_for_file(FDO_PATHS_TYPE_ICON, icon, NULL, NULL); if (path) { printf("Path to %s is %s\n", icon, path); ------------------------------------------------------- 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