Loading mysys/default.c +60 −30 Original line number Diff line number Diff line Loading @@ -68,7 +68,12 @@ static const char *f_extensions[]= { ".cnf", 0 }; static int search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc, const char *dir, const char *config_file, const char *ext, TYPELIB *group); TYPELIB *group); static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *ext, const char *config_file, TYPELIB *group); static char *remove_end_comment(char *ptr); Loading Loading @@ -164,15 +169,16 @@ int load_defaults(const char *conf_file, const char **groups, goto err; if (forced_default_file) { if ((error= search_default_file(&args, &alloc, "", forced_default_file, "", &group)) < 0) if ((error= search_default_file_with_ext(&args, &alloc, "", "", forced_default_file, &group)) < 0) goto err; } else if (dirname_length(conf_file)) { for (ext= (char**) f_extensions; *ext; *ext++) if ((error= search_default_file(&args, &alloc, NullS, conf_file, *ext, &group)) < 0) &group)) < 0) goto err; } else Loading @@ -180,32 +186,30 @@ int load_defaults(const char *conf_file, const char **groups, #ifdef __WIN__ char system_dir[FN_REFLEN]; GetWindowsDirectory(system_dir,sizeof(system_dir)); for (ext= (char**) f_extensions; *ext; *ext++) if ((search_default_file(&args, &alloc, system_dir, conf_file, *ext, &group))) if ((search_default_file(&args, &alloc, system_dir, conf_file, &group))) goto err; #endif #if defined(__EMX__) || defined(OS2) for (ext= (char**) f_extensions; *ext; *ext++) if (getenv("ETC") && (search_default_file(&args, &alloc, getenv("ETC"), conf_file, *ext, &group)) < 0) { const char *etc; if ((etc= getenv("ETC")) && (search_default_file(&args, &alloc, etc, conf_file, &group)) < 0) goto err; } #endif for (dirs=default_directories ; *dirs; dirs++) { if (**dirs) { for (ext= (char**) f_extensions; *ext; *ext++) if (search_default_file(&args, &alloc, *dirs, conf_file, *ext, &group) < 0) &group) < 0) goto err; } else if (defaults_extra_file) { for (ext= (char**) f_extensions; *ext; *ext++) if (search_default_file(&args, &alloc, NullS, defaults_extra_file, *ext, &group) < 0) &group) < 0) goto err; /* Fatal error */ } } Loading Loading @@ -267,11 +271,28 @@ void free_defaults(char **argv) } static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *config_file, TYPELIB *group) { char **ext; for (ext= (char**) f_extensions; *ext; *ext++) { int error; if ((error= search_default_file_with_ext(args, alloc, dir, *ext, config_file, group)) < 0) return error; } return 0; } /* Open a configuration file (if exists) and read given options from it SYNOPSIS search_default_file() search_default_file_with_ext() args Store pointer to found options here alloc Allocate strings in this object dir directory to read Loading @@ -286,9 +307,10 @@ void free_defaults(char **argv) 2 File is not a regular file (Warning) */ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *config_file, const char *ext, TYPELIB *group) static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *ext, const char *config_file, TYPELIB *group) { char name[FN_REFLEN+10],buff[4096],*ptr,*end,*value,*tmp; FILE *fp; Loading Loading @@ -482,7 +504,7 @@ static char *remove_end_comment(char *ptr) void print_defaults(const char *conf_file, const char **groups) { #ifdef __WIN__ bool have_ext=fn_ext(conf_file)[0] != 0; my_bool have_ext= fn_ext(conf_file)[0] != 0; #endif char name[FN_REFLEN], **ext; const char **dirs; Loading @@ -495,16 +517,24 @@ void print_defaults(const char *conf_file, const char **groups) { #ifdef __WIN__ GetWindowsDirectory(name,sizeof(name)); if (have_ext) if (!have_ext) { for (ext= (char**) f_extensions; *ext; *ext++) printf("%s\\%s%s ", name, conf_file, *ext); } else printf("%s\\%s ", name, conf_file); #endif #if defined(__EMX__) || defined(OS2) { const char *etc; if ((etc= getenv("ETC"))) { for (ext= (char**) f_extensions; *ext; *ext++) if (getenv("ETC")) printf("%s\\%s%s ", getenv("ETC"), conf_file, *ext); printf("%s\\%s%s ", etc, conf_file, *ext); } } #endif for (dirs=default_directories ; *dirs; dirs++) { Loading Loading
mysys/default.c +60 −30 Original line number Diff line number Diff line Loading @@ -68,7 +68,12 @@ static const char *f_extensions[]= { ".cnf", 0 }; static int search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc, const char *dir, const char *config_file, const char *ext, TYPELIB *group); TYPELIB *group); static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *ext, const char *config_file, TYPELIB *group); static char *remove_end_comment(char *ptr); Loading Loading @@ -164,15 +169,16 @@ int load_defaults(const char *conf_file, const char **groups, goto err; if (forced_default_file) { if ((error= search_default_file(&args, &alloc, "", forced_default_file, "", &group)) < 0) if ((error= search_default_file_with_ext(&args, &alloc, "", "", forced_default_file, &group)) < 0) goto err; } else if (dirname_length(conf_file)) { for (ext= (char**) f_extensions; *ext; *ext++) if ((error= search_default_file(&args, &alloc, NullS, conf_file, *ext, &group)) < 0) &group)) < 0) goto err; } else Loading @@ -180,32 +186,30 @@ int load_defaults(const char *conf_file, const char **groups, #ifdef __WIN__ char system_dir[FN_REFLEN]; GetWindowsDirectory(system_dir,sizeof(system_dir)); for (ext= (char**) f_extensions; *ext; *ext++) if ((search_default_file(&args, &alloc, system_dir, conf_file, *ext, &group))) if ((search_default_file(&args, &alloc, system_dir, conf_file, &group))) goto err; #endif #if defined(__EMX__) || defined(OS2) for (ext= (char**) f_extensions; *ext; *ext++) if (getenv("ETC") && (search_default_file(&args, &alloc, getenv("ETC"), conf_file, *ext, &group)) < 0) { const char *etc; if ((etc= getenv("ETC")) && (search_default_file(&args, &alloc, etc, conf_file, &group)) < 0) goto err; } #endif for (dirs=default_directories ; *dirs; dirs++) { if (**dirs) { for (ext= (char**) f_extensions; *ext; *ext++) if (search_default_file(&args, &alloc, *dirs, conf_file, *ext, &group) < 0) &group) < 0) goto err; } else if (defaults_extra_file) { for (ext= (char**) f_extensions; *ext; *ext++) if (search_default_file(&args, &alloc, NullS, defaults_extra_file, *ext, &group) < 0) &group) < 0) goto err; /* Fatal error */ } } Loading Loading @@ -267,11 +271,28 @@ void free_defaults(char **argv) } static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *config_file, TYPELIB *group) { char **ext; for (ext= (char**) f_extensions; *ext; *ext++) { int error; if ((error= search_default_file_with_ext(args, alloc, dir, *ext, config_file, group)) < 0) return error; } return 0; } /* Open a configuration file (if exists) and read given options from it SYNOPSIS search_default_file() search_default_file_with_ext() args Store pointer to found options here alloc Allocate strings in this object dir directory to read Loading @@ -286,9 +307,10 @@ void free_defaults(char **argv) 2 File is not a regular file (Warning) */ static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *config_file, const char *ext, TYPELIB *group) static int search_default_file_with_ext(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, const char *dir, const char *ext, const char *config_file, TYPELIB *group) { char name[FN_REFLEN+10],buff[4096],*ptr,*end,*value,*tmp; FILE *fp; Loading Loading @@ -482,7 +504,7 @@ static char *remove_end_comment(char *ptr) void print_defaults(const char *conf_file, const char **groups) { #ifdef __WIN__ bool have_ext=fn_ext(conf_file)[0] != 0; my_bool have_ext= fn_ext(conf_file)[0] != 0; #endif char name[FN_REFLEN], **ext; const char **dirs; Loading @@ -495,16 +517,24 @@ void print_defaults(const char *conf_file, const char **groups) { #ifdef __WIN__ GetWindowsDirectory(name,sizeof(name)); if (have_ext) if (!have_ext) { for (ext= (char**) f_extensions; *ext; *ext++) printf("%s\\%s%s ", name, conf_file, *ext); } else printf("%s\\%s ", name, conf_file); #endif #if defined(__EMX__) || defined(OS2) { const char *etc; if ((etc= getenv("ETC"))) { for (ext= (char**) f_extensions; *ext; *ext++) if (getenv("ETC")) printf("%s\\%s%s ", getenv("ETC"), conf_file, *ext); printf("%s\\%s%s ", etc, conf_file, *ext); } } #endif for (dirs=default_directories ; *dirs; dirs++) { Loading