diff options
author | Jeremy Allison <jra@samba.org> | 2007-12-06 17:16:33 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-12-06 17:16:33 -0800 |
commit | 1b92ea5559bfa00016103508feac9a06ea4b66ae (patch) | |
tree | c11509a3fc07e7c828e1b40e4259f80d1fc0bf2e /source3/lib/readline.c | |
parent | 9bd35ef153ef4b7f892dcf9e69c2232b940a9e18 (diff) | |
download | samba-1b92ea5559bfa00016103508feac9a06ea4b66ae.tar.gz samba-1b92ea5559bfa00016103508feac9a06ea4b66ae.tar.xz samba-1b92ea5559bfa00016103508feac9a06ea4b66ae.zip |
Remove pstrings from client/client.c by doing a large rewrite.
Mostly compiles....
Jeremy.
(This used to be commit c87f3eba9aa52f4ab25d77e2167262bf5c43b1a6)
Diffstat (limited to 'source3/lib/readline.c')
-rw-r--r-- | source3/lib/readline.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/source3/lib/readline.c b/source3/lib/readline.c index 7c127817be4..254f55c86a1 100644 --- a/source3/lib/readline.c +++ b/source3/lib/readline.c @@ -53,7 +53,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) char **(completion_fn)(const char *text, int start, int end)) { fd_set fds; - static char *line; + char *line = NULL; struct timeval timeout; int fd = x_fileno(x_stdin); char *ret; @@ -64,11 +64,9 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) x_fflush(x_stdout); } - if (line == NULL) { - line = (char *)SMB_MALLOC(BUFSIZ); - if (!line) { - return NULL; - } + line = (char *)SMB_MALLOC(BUFSIZ); + if (!line) { + return NULL; } while (1) { @@ -80,10 +78,14 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) if (sys_select_intr(fd+1,&fds,NULL,NULL,&timeout) == 1) { ret = x_fgets(line, BUFSIZ, x_stdin); + if (ret == 0) { + SAFE_FREE(line); + } return ret; } - if (callback) + if (callback) { callback(); + } } } @@ -91,7 +93,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void) Display the prompt and wait for input. Call callback() regularly. ****************************************************************************/ -char *smb_readline(const char *prompt, void (*callback)(void), +char *smb_readline(const char *prompt, void (*callback)(void), char **(completion_fn)(const char *text, int start, int end)) { char *ret; @@ -99,7 +101,7 @@ char *smb_readline(const char *prompt, void (*callback)(void), interactive = isatty(x_fileno(x_stdin)) || getenv("CLI_FORCE_INTERACTIVE"); if (!interactive) { - return smb_readline_replacement(NULL, callback, completion_fn); + return smb_readline_replacement(NULL, callback, completion_fn); } #if HAVE_LIBREADLINE @@ -167,7 +169,7 @@ int cmd_history(void) int i; hlist = history_list(); - + for (i = 0; hlist && hlist[i]; i++) { DEBUG(0, ("%d: %s\n", i, hlist[i]->line)); } @@ -177,4 +179,3 @@ int cmd_history(void) return 0; } - |