mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
lib: smbreadline xfile->stdio
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
c07a9b5beb
commit
899b0883c8
@ -24,7 +24,6 @@
|
|||||||
#include "system/select.h"
|
#include "system/select.h"
|
||||||
#include "system/readline.h"
|
#include "system/readline.h"
|
||||||
#include "libcli/smbreadline/smbreadline.h"
|
#include "libcli/smbreadline/smbreadline.h"
|
||||||
#include "lib/util/xfile.h"
|
|
||||||
|
|
||||||
#undef malloc
|
#undef malloc
|
||||||
|
|
||||||
@ -72,13 +71,13 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void)
|
|||||||
char **(completion_fn)(const char *text, int start, int end))
|
char **(completion_fn)(const char *text, int start, int end))
|
||||||
{
|
{
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
int fd = x_fileno(x_stdin);
|
int fd = fileno(stdin);
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
/* Prompt might be NULL in non-interactive mode. */
|
/* Prompt might be NULL in non-interactive mode. */
|
||||||
if (prompt) {
|
if (prompt) {
|
||||||
x_fprintf(x_stdout, "%s", prompt);
|
printf("%s", prompt);
|
||||||
x_fflush(x_stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
line = (char *)malloc(BUFSIZ);
|
line = (char *)malloc(BUFSIZ);
|
||||||
@ -94,7 +93,7 @@ static char *smb_readline_replacement(const char *prompt, void (*callback)(void)
|
|||||||
pfd.events = POLLIN|POLLHUP;
|
pfd.events = POLLIN|POLLHUP;
|
||||||
|
|
||||||
if (sys_poll_intr(&pfd, 1, 5000) == 1) {
|
if (sys_poll_intr(&pfd, 1, 5000) == 1) {
|
||||||
ret = x_fgets(line, BUFSIZ, x_stdin);
|
ret = fgets(line, BUFSIZ, stdin);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
SAFE_FREE(line);
|
SAFE_FREE(line);
|
||||||
}
|
}
|
||||||
@ -118,7 +117,7 @@ char *smb_readline(const char *prompt, void (*callback)(void),
|
|||||||
char *ret;
|
char *ret;
|
||||||
bool interactive;
|
bool interactive;
|
||||||
|
|
||||||
interactive = isatty(x_fileno(x_stdin)) || getenv("CLI_FORCE_INTERACTIVE");
|
interactive = isatty(fileno(stdin)) || getenv("CLI_FORCE_INTERACTIVE");
|
||||||
if (!interactive) {
|
if (!interactive) {
|
||||||
return smb_readline_replacement(NULL, callback, completion_fn);
|
return smb_readline_replacement(NULL, callback, completion_fn);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user