From 9c2f185242030573a301e1944295c3295a0146f4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Thu, 31 May 2001 18:35:14 +0000 Subject: merge from 2.2 (This used to be commit c827787d679b3bbf9f57ff6d5aaab150456b1662) --- source3/rpcclient/rpcclient.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 53d5b40698..537d324933 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -155,6 +155,23 @@ static void read_authfile ( return; } +static char* next_command (char** cmdstr) +{ + static pstring command; + char *p; + + if (!cmdstr || !(*cmdstr)) + return NULL; + + p = strchr(*cmdstr, ';'); + if (p) + *p = '\0'; + pstrcpy(command, *cmdstr); + *cmdstr = p; + + return command; +} + static void get_username (char *username) { if (getenv("USER")) @@ -648,18 +665,17 @@ static void usage(char *pname) cmd_set++; } - /* Do anything specified with -c */ - - if (cmdstr[0]) { - fstring cmd; - char *p = cmdstr; - - while(next_token(&p, cmd, ";", sizeof(fstring))) { - process_cmd(&cli, cmd); - } - - return 0; - } + /* Do anything specified with -c */ + if (cmdstr[0]) { + char *cmd; + char *p = cmdstr; + + while((cmd=next_command(&p)) != NULL) { + process_cmd(&cli, cmd); + } + + return 0; + } /* Loop around accepting commands */ -- cgit