Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
bbd7265a
Commit
bbd7265a
authored
Mar 29, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/cps/mysql/trees/mysql-5.0
parents
8b6b6d2c
c0477b02
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
13 deletions
+117
-13
mysys/default.c
mysys/default.c
+117
-13
No files found.
mysys/default.c
View file @
bbd7265a
...
@@ -73,7 +73,7 @@ static int search_default_file(Process_option_func func, void *func_ctx,
...
@@ -73,7 +73,7 @@ static int search_default_file(Process_option_func func, void *func_ctx,
static
int
search_default_file_with_ext
(
Process_option_func
func
,
static
int
search_default_file_with_ext
(
Process_option_func
func
,
void
*
func_ctx
,
void
*
func_ctx
,
const
char
*
dir
,
const
char
*
ext
,
const
char
*
dir
,
const
char
*
ext
,
const
char
*
config_file
);
const
char
*
config_file
,
int
recursion_level
);
static
void
init_default_directories
();
static
void
init_default_directories
();
static
char
*
remove_end_comment
(
char
*
ptr
);
static
char
*
remove_end_comment
(
char
*
ptr
);
...
@@ -124,7 +124,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
...
@@ -124,7 +124,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
if
(
forced_default_file
)
if
(
forced_default_file
)
{
{
if
((
error
=
search_default_file_with_ext
(
func
,
func_ctx
,
""
,
""
,
if
((
error
=
search_default_file_with_ext
(
func
,
func_ctx
,
""
,
""
,
forced_default_file
))
<
0
)
forced_default_file
,
0
))
<
0
)
goto
err
;
goto
err
;
if
(
error
>
0
)
if
(
error
>
0
)
{
{
...
@@ -402,7 +402,7 @@ static int search_default_file(Process_option_func opt_handler,
...
@@ -402,7 +402,7 @@ static int search_default_file(Process_option_func opt_handler,
int
error
;
int
error
;
if
((
error
=
search_default_file_with_ext
(
opt_handler
,
handler_ctx
,
if
((
error
=
search_default_file_with_ext
(
opt_handler
,
handler_ctx
,
dir
,
*
ext
,
dir
,
*
ext
,
config_file
))
<
0
)
config_file
,
0
))
<
0
)
return
error
;
return
error
;
}
}
return
0
;
return
0
;
...
@@ -422,6 +422,8 @@ static int search_default_file(Process_option_func opt_handler,
...
@@ -422,6 +422,8 @@ static int search_default_file(Process_option_func opt_handler,
ext Extension for configuration file
ext Extension for configuration file
config_file Name of configuration file
config_file Name of configuration file
group groups to read
group groups to read
recursion_level the level of recursion, got while processing
"!include" or "!includedir"
RETURN
RETURN
0 Success
0 Success
...
@@ -433,13 +435,20 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
...
@@ -433,13 +435,20 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
void
*
handler_ctx
,
void
*
handler_ctx
,
const
char
*
dir
,
const
char
*
dir
,
const
char
*
ext
,
const
char
*
ext
,
const
char
*
config_file
)
const
char
*
config_file
,
int
recursion_level
)
{
{
char
name
[
FN_REFLEN
+
10
],
buff
[
4096
],
curr_gr
[
4096
],
*
ptr
,
*
end
;
char
name
[
FN_REFLEN
+
10
],
buff
[
4096
],
curr_gr
[
4096
],
*
ptr
,
*
end
,
**
tmp_ext
;
char
*
value
,
option
[
4096
];
char
*
value
,
option
[
4096
],
tmp
[
FN_REFLEN
];
static
const
char
includedir_keyword
[]
=
"includedir"
;
static
const
char
include_keyword
[]
=
"include"
;
const
int
max_recursion_level
=
10
;
FILE
*
fp
;
FILE
*
fp
;
uint
line
=
0
;
uint
line
=
0
;
my_bool
found_group
=
0
;
my_bool
found_group
=
0
;
uint
i
;
MY_DIR
*
search_dir
;
FILEINFO
*
search_file
;
if
((
dir
?
strlen
(
dir
)
:
0
)
+
strlen
(
config_file
)
>=
FN_REFLEN
-
3
)
if
((
dir
?
strlen
(
dir
)
:
0
)
+
strlen
(
config_file
)
>=
FN_REFLEN
-
3
)
return
0
;
/* Ignore wrong paths */
return
0
;
/* Ignore wrong paths */
...
@@ -468,22 +477,117 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
...
@@ -468,22 +477,117 @@ static int search_default_file_with_ext(Process_option_func opt_handler,
if
((
stat_info
.
st_mode
&
S_IWOTH
)
&&
if
((
stat_info
.
st_mode
&
S_IWOTH
)
&&
(
stat_info
.
st_mode
&
S_IFMT
)
==
S_IFREG
)
(
stat_info
.
st_mode
&
S_IFMT
)
==
S_IFREG
)
{
{
fprintf
(
stderr
,
"warning: World-writ
e
able config file %s is ignored
\n
"
,
fprintf
(
stderr
,
"warning: World-writable config file %s is ignored
\n
"
,
name
);
name
);
return
0
;
return
0
;
}
}
}
}
#endif
#endif
if
(
!
(
fp
=
my_fopen
(
fn_format
(
name
,
name
,
""
,
""
,
4
),
O_RDONLY
,
MYF
(
0
))))
if
(
!
(
fp
=
my_fopen
(
fn_format
(
name
,
name
,
""
,
""
,
4
),
O_RDONLY
,
MYF
(
0
))))
return
0
;
/* Ignore wrong files */
return
0
;
/* Ignore wrong files */
while
(
fgets
(
buff
,
sizeof
(
buff
)
-
1
,
fp
))
while
(
fgets
(
buff
,
sizeof
(
buff
)
-
1
,
fp
))
{
{
line
++
;
line
++
;
/* Ignore comment and empty lines */
/* Ignore comment and empty lines */
for
(
ptr
=
buff
;
my_isspace
(
&
my_charset_latin1
,
*
ptr
)
;
ptr
++
)
;
for
(
ptr
=
buff
;
my_isspace
(
&
my_charset_latin1
,
*
ptr
);
ptr
++
)
{}
if
(
*
ptr
==
'#'
||
*
ptr
==
';'
||
!*
ptr
)
if
(
*
ptr
==
'#'
||
*
ptr
==
';'
||
!*
ptr
)
continue
;
continue
;
/* Configuration File Directives */
if
((
*
ptr
==
'!'
)
&&
(
recursion_level
<
max_recursion_level
))
{
/* skip over `!' and following whitespace */
for
(
++
ptr
;
my_isspace
(
&
my_charset_latin1
,
ptr
[
0
]);
ptr
++
)
{}
if
((
!
strncmp
(
ptr
,
includedir_keyword
,
sizeof
(
includedir_keyword
)
-
1
))
&&
my_isspace
(
&
my_charset_latin1
,
ptr
[
sizeof
(
includedir_keyword
)
-
1
]))
{
/* skip over "includedir" and following whitespace */
for
(
ptr
+=
sizeof
(
includedir_keyword
)
-
1
;
my_isspace
(
&
my_charset_latin1
,
ptr
[
0
]);
ptr
++
)
{}
/* trim trailing whitespace from directory name */
end
=
ptr
+
strlen
(
ptr
)
-
1
;
/*
This would work fine even if no whitespaces are met
since fgets() stores the newline character in the buffer
*/
for
(;
my_isspace
(
&
my_charset_latin1
,
*
(
end
-
1
));
end
--
)
{}
end
[
0
]
=
0
;
/* print error msg if there is nothing after !inludedir directive */
if
(
end
==
ptr
)
{
fprintf
(
stderr
,
"error: Wrong !includedir directive in config "
"file: %s at line %d
\n
"
,
name
,
line
);
goto
err
;
}
if
(
!
(
search_dir
=
my_dir
(
ptr
,
MYF
(
MY_WME
))))
goto
err
;
for
(
i
=
0
;
i
<
(
uint
)
search_dir
->
number_off_files
;
i
++
)
{
search_file
=
search_dir
->
dir_entry
+
i
;
ext
=
fn_ext
(
search_file
->
name
);
/* check extenstion */
for
(
tmp_ext
=
(
char
**
)
f_extensions
;
*
tmp_ext
;
*
tmp_ext
++
)
{
if
(
!
strcmp
(
ext
,
*
tmp_ext
))
break
;
}
if
(
*
tmp_ext
)
{
fn_format
(
tmp
,
search_file
->
name
,
ptr
,
""
,
MY_UNPACK_FILENAME
|
MY_SAFE_PATH
);
search_default_file_with_ext
(
opt_handler
,
handler_ctx
,
""
,
""
,
tmp
,
recursion_level
+
1
);
}
}
my_dirend
(
search_dir
);
}
else
if
((
!
strncmp
(
ptr
,
include_keyword
,
sizeof
(
include_keyword
)
-
1
))
&&
my_isspace
(
&
my_charset_latin1
,
ptr
[
sizeof
(
include_keyword
)
-
1
]))
{
/* skip over `include' and following whitespace */
for
(
ptr
+=
sizeof
(
include_keyword
)
-
1
;
my_isspace
(
&
my_charset_latin1
,
ptr
[
0
]);
ptr
++
)
{}
/* trim trailing whitespace from filename */
end
=
ptr
+
strlen
(
ptr
)
-
1
;
for
(;
my_isspace
(
&
my_charset_latin1
,
*
(
end
-
1
))
;
end
--
)
{}
end
[
0
]
=
0
;
if
(
end
==
ptr
)
{
fprintf
(
stderr
,
"error: Wrong !include directive in config "
"file: %s at line %d
\n
"
,
name
,
line
);
goto
err
;
}
search_default_file_with_ext
(
opt_handler
,
handler_ctx
,
""
,
""
,
ptr
,
recursion_level
+
1
);
}
continue
;
}
if
(
*
ptr
==
'['
)
/* Group name */
if
(
*
ptr
==
'['
)
/* Group name */
{
{
found_group
=
1
;
found_group
=
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment