summaryrefslogtreecommitdiff
path: root/source3/lib/xfile.c
diff options
context:
space:
mode:
authorJames Peach <jpeach@samba.org>2006-06-15 23:51:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:17:30 -0500
commit06491a4cb12d8753c63525b3ba4d754d2ab1e822 (patch)
tree305b4dbe67646ac5e09cfc599a66ea334acd69f9 /source3/lib/xfile.c
parentae2fb4f1093e28e4656371b9bbeb229fd1ed1ada (diff)
downloadsamba-06491a4cb12d8753c63525b3ba4d754d2ab1e822.tar.gz
samba-06491a4cb12d8753c63525b3ba4d754d2ab1e822.tar.bz2
samba-06491a4cb12d8753c63525b3ba4d754d2ab1e822.zip
r16274: Fix the smbclient prompting behaviour for both systems that have
libreadline and those that don't. We always use the built-in readline replacement for non-interactive mode. Interactive prompts are always emitted to stdout and non-interactive mode never prompts at all. Introduce x_fdup to avoid spuriously closing stdout when a logfile is specified on the command line and setup_logging is called a second time. (This used to be commit 848ac756f651a4be231e5635580c0fd5f3d3fa0e)
Diffstat (limited to 'source3/lib/xfile.c')
-rw-r--r--source3/lib/xfile.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/source3/lib/xfile.c b/source3/lib/xfile.c
index 71f8bdbcbb..ef33c7894f 100644
--- a/source3/lib/xfile.c
+++ b/source3/lib/xfile.c
@@ -123,6 +123,28 @@ XFILE *x_fopen(const char *fname, int flags, mode_t mode)
return ret;
}
+XFILE *x_fdup(const XFILE *f)
+{
+ XFILE *ret;
+ int fd;
+
+ fd = dup(x_fileno(f));
+ if (fd < 0) {
+ return NULL;
+ }
+
+ ret = SMB_CALLOC_ARRAY(XFILE, 1);
+ if (!ret) {
+ close(fd);
+ return NULL;
+ }
+
+ ret->fd = fd;
+ ret->open_flags = f->open_flags;
+ x_setvbuf(ret, NULL, X_IOFBF, XBUFSIZE);
+ return ret;
+}
+
/* simulate fclose() */
int x_fclose(XFILE *f)
{
@@ -220,7 +242,7 @@ size_t x_fwrite(const void *p, size_t size, size_t nmemb, XFILE *f)
}
/* at least fileno() is simple! */
-int x_fileno(XFILE *f)
+int x_fileno(const XFILE *f)
{
return f->fd;
}