summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/parse_output.cc
diff options
context:
space:
mode:
authorunknown <petr@mysql.com>2005-06-01 04:40:22 +0400
committerunknown <petr@mysql.com>2005-06-01 04:40:22 +0400
commit26f03563f724b1bcab931d1120a56825135ce24c (patch)
tree9ad013e8ea02fb9d7bc9887be150da9b869ae2b7 /server-tools/instance-manager/parse_output.cc
parent1c7b61e3aef5227165a9957ead000e67935708b2 (diff)
downloadmariadb-git-26f03563f724b1bcab931d1120a56825135ce24c.tar.gz
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
Diffstat (limited to 'server-tools/instance-manager/parse_output.cc')
-rw-r--r--server-tools/instance-manager/parse_output.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/server-tools/instance-manager/parse_output.cc b/server-tools/instance-manager/parse_output.cc
index d6adb8079ce..8e083b0cd0d 100644
--- a/server-tools/instance-manager/parse_output.cc
+++ b/server-tools/instance-manager/parse_output.cc
@@ -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;
}
}