1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

fix IM to display version string in "show instance status" (Bug #10229)

server-tools/instance-manager/buffer.h:
  fix for the valgring error
server-tools/instance-manager/commands.cc:
  sent the version string
server-tools/instance-manager/instance_options.cc:
  compute and store the version string
server-tools/instance-manager/instance_options.h:
  add a version string option, and added caching of the mysqld_path length
server-tools/instance-manager/options.cc:
  fix valgrind error
server-tools/instance-manager/parse_output.cc:
  Add an option to parse_output_and_get_value in order to be
  able to get the rest of the string after the found word in
  the output of popen() (E.g. a version string).
server-tools/instance-manager/parse_output.h:
  prototype changed
This commit is contained in:
unknown
2005-06-01 04:40:22 +04:00
parent 1c7b61e3ae
commit 26f03563f7
7 changed files with 130 additions and 36 deletions

View File

@ -32,10 +32,13 @@
word the word to look for (usually an option name)
result the buffer to store the next word (option value)
result_len self-explanatory
get_all_line flag, which is set if we want to get all the line after
the matched word.
DESCRIPTION
Parse output of the "command". Find the "word" and return the next one
if get_all_line is 0. Return the rest of the parsed string otherwise.
RETURN
0 - ok
@ -43,7 +46,8 @@
*/
int parse_output_and_get_value(const char *command, const char *word,
char *result, size_t result_len)
char *result, size_t result_len,
int get_all_line)
{
FILE *output;
uint wordlen;
@ -81,11 +85,19 @@ int parse_output_and_get_value(const char *command, const char *word,
an option value.
*/
linep+= lineword_len; /* swallow the previous one */
get_word((const char **) &linep, &lineword_len, NONSPACE);
if (result_len <= lineword_len)
goto err;
strncpy(result, linep, lineword_len);
result[lineword_len]= '\0';
if (!get_all_line)
{
get_word((const char **) &linep, &lineword_len, NONSPACE);
if (result_len <= lineword_len)
goto err;
strncpy(result, linep, lineword_len);
result[lineword_len]= '\0';
}
else
{
strncpy(result, linep, result_len);
result[result_len]= '\0'; /* safety */
}
goto pclose;
}
}