void add_search_dirs (const char *path, const char *separator, const char *sysroot) { char **search_dirs; char **iter; GString *str = sysroot ? g_string_new("") : NULL; search_dirs = g_strsplit (path, separator, -1); iter = search_dirs; while (*iter) { const char *dir = *iter; if (str) { /* If sysroot is specified, assume search dirs are relative to it */ g_string_assign(str, sysroot); g_string_append(str, *iter); dir = str->str; } debug_spew ("Adding directory '%s' from PKG_CONFIG_PATH\n", dir); add_search_dir (dir); ++iter; } g_strfreev (search_dirs); if (str) { g_string_free(str, TRUE); } }
void std_search_path(void) { int i, n; /* Append standard search directories */ n = sizeof standard_search_dirs / sizeof standard_search_dirs[0]; for (i = 0; i < n; i++) add_search_dir(standard_search_dirs[i]); }
void add_search_path(char *path) { register char *cp, *dup; if (path == NULL) return; /* Add search directories from `path' */ path = dup = strdup(path); while ((cp = strsep(&path, ":")) != NULL) add_search_dir(cp); free(dup); }
static void on_add_search_volumes(GtkWidget* menu, FindFile* data) { const char* path; const GList* vols = vfs_volume_get_all_volumes(), *l; for( l = vols; l; l = l->next ) { VFSVolume* vol = (VFSVolume*)l->data; if ( vfs_volume_is_mounted( vol ) ) { path = vfs_volume_get_mount_point( vol ); if ( path && path[0] != '\0' ) add_search_dir( data, path ); } } }
static void add_search_dirs(void) { char *relpath; char path[PATH_MAX]; relpath = getenv("ANDROID_PRODUCT_OUT"); if (!relpath) { app_err("Warning: ANDROID_PRODUCT_OUT not set; " "using current directory.\n"); relpath = "."; } snprintf(path, PATH_MAX, "%s/%s", relpath, "system/lib"); add_search_dir(path); }
static void on_add_search_browse(GtkWidget* menu, FindFile* data) { GtkWidget* dlg = gtk_file_chooser_dialog_new( _("Select a folder"), GTK_WINDOW( data->win ), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL ); gtk_dialog_set_alternative_button_order( GTK_DIALOG( dlg ), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL ); if( gtk_dialog_run( GTK_DIALOG( dlg ) ) == GTK_RESPONSE_OK ) { char* path = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( dlg ) ); add_search_dir( data, path ); g_free( path ); } gtk_widget_destroy( dlg ); }
void add_search_dirs (const char *path, const char *separator) { char **search_dirs; char **iter; search_dirs = g_strsplit (path, separator, -1); iter = search_dirs; while (*iter) { debug_spew ("Adding directory '%s' from PKG_CONFIG_PATH\n", *iter); add_search_dir (*iter); ++iter; } g_strfreev (search_dirs); }
static void on_add_search_desktop(GtkWidget* menu, FindFile* data) { add_search_dir( data, vfs_get_desktop_dir() ); }
static void on_add_search_home(GtkWidget* menu, FindFile* data) { add_search_dir( data, g_get_home_dir() ); }
int main(int argc, char *argv[]) { struct Flag *tostdout, *overwrite; struct Option *extradirs; struct GModule *module; FILE *outstream; char *fontcapfile; struct stat status; int i; G_set_program_name(argv[0]); G_no_gisinit(); G_set_gisrc_mode(G_GISRC_MODE_MEMORY); module = G_define_module(); module->keywords = "general"; module->description = "Generates the font configuration file by scanning various directories " "for fonts"; overwrite = G_define_flag(); overwrite->key = 'o'; overwrite->description = "Overwrite font configuration file if already existing"; tostdout = G_define_flag(); tostdout->key = 's'; tostdout->description = "Write font configuration file to standard output instead of " "$GISBASE/etc"; extradirs = G_define_option(); extradirs->key = "extradirs"; extradirs->type = TYPE_STRING; extradirs->required = NO; extradirs->description = "Comma-separated list of extra directories to scan for " "Freetype-compatible fonts as well as the defaults (see documentation)"; if (argc > 1 && G_parser(argc, argv)) exit(EXIT_FAILURE); if (!tostdout->answer) { const char *gisbase = G_gisbase(); const char *alt_file = getenv("GRASS_FONT_CAP"); if (alt_file) fontcapfile = G_store(alt_file); else G_asprintf(&fontcapfile, "%s/etc/fontcap", gisbase); if (!stat(fontcapfile, &status)) { /* File exists? */ if (!overwrite->answer) G_fatal_error ("Fontcap file %s already exists; use -%c flag if you " "wish to overwrite it", fontcapfile, overwrite->key); } } searchdirs = NULL; numsearchdirs = 0; /* Prepare list of directories to search */ if (extradirs->answer) { #ifndef HAVE_FT2BUILD_H G_warning("This GRASS installation was compiled without Freetype support, extradirs parameter ignored"); #endif char *str = G_store(extradirs->answer); while ((str = strtok(str, ","))) { add_search_dir(str); str = NULL; } } i = -1; while (standarddirs[++i]) add_search_dir(standarddirs[i]); totalfonts = maxfonts = 0; fontcap = NULL; find_stroke_fonts(); find_freetype_fonts(); qsort(fontcap, totalfonts, sizeof(struct GFONT_CAP), compare_fonts); if (tostdout->answer) outstream = stdout; else { outstream = fopen(fontcapfile, "w"); if (outstream == NULL) G_fatal_error("Cannot open %s for writing: %s", fontcapfile, strerror(errno)); } for (i = 0; i < totalfonts; i++) fprintf(outstream, "%s|%s|%d|%s|%d|%s|\n", fontcap[i].name, fontcap[i].longname, fontcap[i].type, fontcap[i].path, fontcap[i].index, fontcap[i].encoding); fclose(outstream); exit(EXIT_SUCCESS); }