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
bdde67e5
Commit
bdde67e5
authored
Oct 18, 2004
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1
into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1
parents
85828f4a
5eedc72e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
24 deletions
+27
-24
ndb/include/mgmcommon/LocalConfig.hpp
ndb/include/mgmcommon/LocalConfig.hpp
+2
-2
ndb/src/common/mgmcommon/LocalConfig.cpp
ndb/src/common/mgmcommon/LocalConfig.cpp
+25
-22
No files found.
ndb/include/mgmcommon/LocalConfig.hpp
View file @
bdde67e5
...
@@ -53,14 +53,14 @@ struct LocalConfig {
...
@@ -53,14 +53,14 @@ struct LocalConfig {
void
printUsage
()
const
;
void
printUsage
()
const
;
void
setError
(
int
lineNumber
,
const
char
*
_msg
);
void
setError
(
int
lineNumber
,
const
char
*
_msg
);
bool
readConnectString
(
const
char
*
);
bool
readConnectString
(
const
char
*
,
const
char
*
info
);
bool
readFile
(
const
char
*
file
,
bool
&
fopenError
);
bool
readFile
(
const
char
*
file
,
bool
&
fopenError
);
bool
parseLine
(
char
*
line
,
int
lineNumber
);
bool
parseLine
(
char
*
line
,
int
lineNumber
);
bool
parseNodeId
(
const
char
*
buf
);
bool
parseNodeId
(
const
char
*
buf
);
bool
parseHostName
(
const
char
*
buf
);
bool
parseHostName
(
const
char
*
buf
);
bool
parseFileName
(
const
char
*
buf
);
bool
parseFileName
(
const
char
*
buf
);
bool
parseString
(
const
char
*
buf
,
char
*
line
);
bool
parseString
(
const
char
*
buf
,
BaseString
&
err
);
};
};
#endif // LocalConfig_H
#endif // LocalConfig_H
...
...
ndb/src/common/mgmcommon/LocalConfig.cpp
View file @
bdde67e5
...
@@ -40,7 +40,7 @@ LocalConfig::init(const char *connectString,
...
@@ -40,7 +40,7 @@ LocalConfig::init(const char *connectString,
//1. Check connectString
//1. Check connectString
if
(
connectString
!=
0
&&
connectString
[
0
]
!=
0
){
if
(
connectString
!=
0
&&
connectString
[
0
]
!=
0
){
if
(
readConnectString
(
connectString
)){
if
(
readConnectString
(
connectString
,
"connect string"
)){
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -59,7 +59,7 @@ LocalConfig::init(const char *connectString,
...
@@ -59,7 +59,7 @@ LocalConfig::init(const char *connectString,
char
buf
[
255
];
char
buf
[
255
];
if
(
NdbEnv_GetEnv
(
"NDB_CONNECTSTRING"
,
buf
,
sizeof
(
buf
))
&&
if
(
NdbEnv_GetEnv
(
"NDB_CONNECTSTRING"
,
buf
,
sizeof
(
buf
))
&&
strlen
(
buf
)
!=
0
){
strlen
(
buf
)
!=
0
){
if
(
readConnectString
(
buf
)){
if
(
readConnectString
(
buf
,
"NDB_CONNECTSTRING"
)){
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -91,7 +91,7 @@ LocalConfig::init(const char *connectString,
...
@@ -91,7 +91,7 @@ LocalConfig::init(const char *connectString,
{
{
char
buf
[
256
];
char
buf
[
256
];
snprintf
(
buf
,
sizeof
(
buf
),
"host=localhost:%s"
,
NDB_BASE_PORT
);
snprintf
(
buf
,
sizeof
(
buf
),
"host=localhost:%s"
,
NDB_BASE_PORT
);
if
(
readConnectString
(
buf
))
if
(
readConnectString
(
buf
,
"default connect string"
))
return
true
;
return
true
;
}
}
...
@@ -109,8 +109,10 @@ void LocalConfig::setError(int lineNumber, const char * _msg) {
...
@@ -109,8 +109,10 @@ void LocalConfig::setError(int lineNumber, const char * _msg) {
}
}
void
LocalConfig
::
printError
()
const
{
void
LocalConfig
::
printError
()
const
{
ndbout
<<
"Local configuration error"
<<
endl
ndbout
<<
"Configuration error"
<<
endl
;
<<
"Line: "
<<
error_line
<<
", "
<<
error_msg
<<
endl
<<
endl
;
if
(
error_line
)
ndbout
<<
"Line: "
<<
error_line
<<
", "
;
ndbout
<<
error_msg
<<
endl
<<
endl
;
}
}
void
LocalConfig
::
printUsage
()
const
{
void
LocalConfig
::
printUsage
()
const
{
...
@@ -140,7 +142,7 @@ const char *nodeIdTokens[] = {
...
@@ -140,7 +142,7 @@ const char *nodeIdTokens[] = {
const
char
*
hostNameTokens
[]
=
{
const
char
*
hostNameTokens
[]
=
{
"host://%[^:]:%i"
,
"host://%[^:]:%i"
,
"host=%[^:]:%i"
,
"host=%[^:]:%i"
,
"%[^:]:%i"
,
"%[^:
^=^
]:%i"
,
"%s %i"
,
"%s %i"
,
0
0
};
};
...
@@ -192,7 +194,7 @@ LocalConfig::parseFileName(const char * buf){
...
@@ -192,7 +194,7 @@ LocalConfig::parseFileName(const char * buf){
}
}
bool
bool
LocalConfig
::
parseString
(
const
char
*
connectString
,
char
*
line
){
LocalConfig
::
parseString
(
const
char
*
connectString
,
BaseString
&
err
){
char
*
for_strtok
;
char
*
for_strtok
;
char
*
copy
=
strdup
(
connectString
);
char
*
copy
=
strdup
(
connectString
);
NdbAutoPtr
<
char
>
tmp_aptr
(
copy
);
NdbAutoPtr
<
char
>
tmp_aptr
(
copy
);
...
@@ -212,15 +214,12 @@ LocalConfig::parseString(const char * connectString, char *line){
...
@@ -212,15 +214,12 @@ LocalConfig::parseString(const char * connectString, char *line){
if
(
found_other
=
parseFileName
(
tok
))
if
(
found_other
=
parseFileName
(
tok
))
continue
;
continue
;
if
(
line
)
err
.
assfmt
(
"Unexpected entry:
\"
%s
\"
"
,
tok
);
snprintf
(
line
,
150
,
"Unexpected entry:
\"
%s
\"
"
,
tok
);
return
false
;
return
false
;
}
}
if
(
!
found_other
)
{
if
(
!
found_other
)
{
if
(
line
)
err
.
appfmt
(
"Missing host/file name extry in
\"
%s
\"
"
,
connectString
);
snprintf
(
line
,
150
,
"Missing host/file name extry in
\"
%s
\"
"
,
connectString
);
return
false
;
return
false
;
}
}
...
@@ -235,7 +234,8 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
...
@@ -235,7 +234,8 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
FILE
*
file
=
fopen
(
filename
,
"r"
);
FILE
*
file
=
fopen
(
filename
,
"r"
);
if
(
file
==
0
){
if
(
file
==
0
){
snprintf
(
line
,
150
,
"Unable to open local config file: %s"
,
filename
);
snprintf
(
line
,
sizeof
(
line
),
"Unable to open local config file: %s"
,
filename
);
setError
(
0
,
line
);
setError
(
0
,
line
);
fopenError
=
true
;
fopenError
=
true
;
return
false
;
return
false
;
...
@@ -243,7 +243,7 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
...
@@ -243,7 +243,7 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
BaseString
theString
;
BaseString
theString
;
while
(
fgets
(
line
,
1024
,
file
)){
while
(
fgets
(
line
,
sizeof
(
line
)
,
file
)){
BaseString
tmp
(
line
);
BaseString
tmp
(
line
);
tmp
.
trim
(
"
\t\n\r
"
);
tmp
.
trim
(
"
\t\n\r
"
);
if
(
tmp
.
length
()
>
0
&&
tmp
.
c_str
()[
0
]
!=
'#'
){
if
(
tmp
.
length
()
>
0
&&
tmp
.
c_str
()[
0
]
!=
'#'
){
...
@@ -251,7 +251,7 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
...
@@ -251,7 +251,7 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
break
;
break
;
}
}
}
}
while
(
fgets
(
line
,
1024
,
file
))
{
while
(
fgets
(
line
,
sizeof
(
line
)
,
file
))
{
BaseString
tmp
(
line
);
BaseString
tmp
(
line
);
tmp
.
trim
(
"
\t\n\r
"
);
tmp
.
trim
(
"
\t\n\r
"
);
if
(
tmp
.
length
()
>
0
&&
tmp
.
c_str
()[
0
]
!=
'#'
){
if
(
tmp
.
length
()
>
0
&&
tmp
.
c_str
()[
0
]
!=
'#'
){
...
@@ -260,11 +260,12 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
...
@@ -260,11 +260,12 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
}
}
}
}
bool
return_value
=
parseString
(
theString
.
c_str
(),
line
);
BaseString
err
;
bool
return_value
=
parseString
(
theString
.
c_str
(),
err
);
if
(
!
return_value
)
{
if
(
!
return_value
)
{
BaseString
tmp
;
BaseString
tmp
;
tmp
.
assfmt
(
"Reading %s: %s"
,
filename
,
line
);
tmp
.
assfmt
(
"Reading %s: %s"
,
filename
,
err
.
c_str
()
);
setError
(
0
,
tmp
.
c_str
());
setError
(
0
,
tmp
.
c_str
());
}
}
...
@@ -273,12 +274,14 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
...
@@ -273,12 +274,14 @@ bool LocalConfig::readFile(const char * filename, bool &fopenError)
}
}
bool
bool
LocalConfig
::
readConnectString
(
const
char
*
connectString
){
LocalConfig
::
readConnectString
(
const
char
*
connectString
,
char
line
[
150
],
line2
[
150
];
const
char
*
info
){
bool
return_value
=
parseString
(
connectString
,
line
);
BaseString
err
;
bool
return_value
=
parseString
(
connectString
,
err
);
if
(
!
return_value
)
{
if
(
!
return_value
)
{
snprintf
(
line2
,
150
,
"Reading NDB_CONNECTSTRING
\"
%s
\"
: %s"
,
connectString
,
line
);
BaseString
err2
;
setError
(
0
,
line2
);
err2
.
assfmt
(
"Reading %d
\"
%s
\"
: %s"
,
info
,
connectString
,
err
.
c_str
());
setError
(
0
,
err2
.
c_str
());
}
}
return
return_value
;
return
return_value
;
}
}
...
...
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