1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

merge with 4.0

BitKeeper/etc/logging_ok:
  auto-union
BitKeeper/deleted/.del-Makefile.am:
  Delete: Docs/Images/Makefile.am
Build-tools/Bootstrap:
  Auto merged
Docs/Makefile.am:
  Auto merged
configure.in:
  Auto merged
include/mysql.h:
  Auto merged
innobase/dict/dict0dict.c:
  Auto merged
libmysql/libmysql.c:
  Auto merged
mysys/default.c:
  Auto merged
scripts/mysqld_safe.sh:
  Auto merged
sql/log.cc:
  Auto merged
mysql-test/t/mix_innodb_myisam_binlog.test:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_acl.cc:
  Auto merged
sql/sql_table.cc:
  Auto merged
client/mysqldump.c:
  merge with 4.0
  (This only reorders options)
sql/ha_innodb.cc:
  merge with 4.0 (Keep original code)
sql/time.cc:
  Note that part of this patch is done in my_time.c
This commit is contained in:
unknown
2004-11-12 11:17:53 +02:00
24 changed files with 352 additions and 116 deletions

View File

@ -60,15 +60,20 @@ DATADIR,
NullS,
};
#define default_ext ".cnf" /* extension for config file */
#ifdef __WIN__
#include <winbase.h>
#define windows_ext ".ini"
static const char *f_extensions[]= { ".ini", ".cnf", 0 };
#else
static const char *f_extensions[]= { ".cnf", 0 };
#endif
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);
@ -115,7 +120,8 @@ int load_defaults(const char *conf_file, const char **groups,
uint args_used=0;
int error= 0;
MEM_ROOT alloc;
char *ptr,**res;
char *ptr, **res, **ext;
DBUG_ENTER("load_defaults");
init_alloc_root(&alloc,512,0);
@ -163,8 +169,9 @@ 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;
if (error > 0)
{
@ -175,37 +182,40 @@ int load_defaults(const char *conf_file, const char **groups,
}
else if (dirname_length(conf_file))
{
if ((error= search_default_file(&args, &alloc, NullS, conf_file,
default_ext, &group)) < 0)
goto err;
for (ext= (char**) f_extensions; *ext; *ext++)
if ((error= search_default_file(&args, &alloc, NullS, conf_file,
&group)) < 0)
goto err;
}
else
{
#ifdef __WIN__
char system_dir[FN_REFLEN];
GetWindowsDirectory(system_dir,sizeof(system_dir));
if ((search_default_file(&args, &alloc, system_dir, conf_file,
windows_ext, &group)))
if ((search_default_file(&args, &alloc, system_dir, conf_file, &group)))
goto err;
#endif
#if defined(__EMX__) || defined(OS2)
if (getenv("ETC") &&
(search_default_file(&args, &alloc, getenv("ETC"), conf_file,
default_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)
{
if (search_default_file(&args, &alloc, *dirs, conf_file,
default_ext, &group) < 0)
&group) < 0)
goto err;
}
else if (defaults_extra_file)
{
if (search_default_file(&args, &alloc, NullS, defaults_extra_file,
default_ext, &group) < 0)
&group) < 0)
goto err; /* Fatal error */
}
}
@ -269,11 +279,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
@ -288,9 +315,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;
@ -484,10 +512,11 @@ 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];
char name[FN_REFLEN], **ext;
const char **dirs;
puts("\nDefault options are read from the following files in the given order:");
if (dirname_length(conf_file))
@ -496,27 +525,43 @@ void print_defaults(const char *conf_file, const char **groups)
{
#ifdef __WIN__
GetWindowsDirectory(name,sizeof(name));
printf("%s\\%s%s ",name,conf_file,have_ext ? "" : windows_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)
if (getenv("ETC"))
printf("%s\\%s%s ", getenv("ETC"), conf_file, default_ext);
{
const char *etc;
if ((etc= getenv("ETC")))
{
for (ext= (char**) f_extensions; *ext; *ext++)
printf("%s\\%s%s ", etc, conf_file, *ext);
}
}
#endif
for (dirs=default_directories ; *dirs; dirs++)
{
const char *pos;
char *end;
if (**dirs)
pos= *dirs;
else if (defaults_extra_file)
pos= defaults_extra_file;
else
continue;
end=convert_dirname(name, pos, NullS);
if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
*end++='.';
strxmov(end,conf_file,default_ext," ",NullS);
fputs(name,stdout);
for (ext= (char**) f_extensions; *ext; *ext++)
{
const char *pos;
char *end;
if (**dirs)
pos= *dirs;
else if (defaults_extra_file)
pos= defaults_extra_file;
else
continue;
end= convert_dirname(name, pos, NullS);
if (name[0] == FN_HOMELIB) /* Add . to filenames in home */
*end++='.';
strxmov(end, conf_file, *ext, " ", NullS);
fputs(name,stdout);
}
}
puts("");
}