Merge branch 'release-1.0beta-refresh' into cmake_build

This commit is contained in:
Markus Makela
2014-09-23 10:42:47 +03:00

View File

@ -108,15 +108,10 @@ char *hostname = "localhost";
char *port = "6603"; char *port = "6603";
char *user = "admin"; char *user = "admin";
char *passwd = NULL; char *passwd = NULL;
int so, cmdlen; int so;
char *cmd;
int option_index = 0; int option_index = 0;
char c; char c;
cmd = malloc(1);
*cmd = 0;
cmdlen = 1;
while ((c = getopt_long(argc, argv, "h:p:P:u:v?", while ((c = getopt_long(argc, argv, "h:p:P:u:v?",
long_options, &option_index)) long_options, &option_index))
>= 0) >= 0)
@ -180,13 +175,27 @@ char c;
exit(1); exit(1);
} }
if (cmdlen > 1) if (optind < argc) {
{ int i, len = 0;
cmd[cmdlen - 2] = '\0'; /* Remove trailing space */ char *cmd;
for (i = optind; i < argc; i++) {
len += strlen(argv[i]) + 1;
}
cmd = malloc(len);
strcpy(cmd, argv[optind]);
for (i = optind +1; i < argc; i++) {
strcat(cmd, " ");
strcat(cmd, argv[i]);
}
if (access(cmd, R_OK) == 0) if (access(cmd, R_OK) == 0)
DoSource(so, cmd); DoSource(so, cmd);
else else
sendCommand(so, cmd); sendCommand(so, cmd);
free(cmd);
exit(0); exit(0);
} }
@ -391,7 +400,7 @@ char buf[20];
* Send a comamnd using the MaxScaled protocol, display the return data * Send a comamnd using the MaxScaled protocol, display the return data
* on standard output. * on standard output.
* *
* Input terminates with a lien containing jsut the text OK * Input terminates with a lien containing just the text OK
* *
* @param so The socket connect to MaxScale * @param so The socket connect to MaxScale
* @param cmd The command to send * @param cmd The command to send
@ -401,7 +410,7 @@ static int
sendCommand(int so, char *cmd) sendCommand(int so, char *cmd)
{ {
char buf[80]; char buf[80];
int i, j, newline = 0; int i, j, newline = 1;
write(so, cmd, strlen(cmd)); write(so, cmd, strlen(cmd));
while (1) while (1)