summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-09-10 11:08:57 +0000
committerAndrew Tridgell <tridge@samba.org>2001-09-10 11:08:57 +0000
commitb30e75692d68233448b3ad3d7ddd4b4ac423d3ab (patch)
treeed752b80838a33953632c7f3ffcaf0a71c47a7f5 /source3/lib
parentba8e3e03432ee7649a3f59ba8b37edbb32c34190 (diff)
downloadsamba-b30e75692d68233448b3ad3d7ddd4b4ac423d3ab.tar.gz
samba-b30e75692d68233448b3ad3d7ddd4b4ac423d3ab.tar.bz2
samba-b30e75692d68233448b3ad3d7ddd4b4ac423d3ab.zip
replaced stdio in many parts of samba with a XFILE. XFILE is a cut-down
replacemnt of stdio that doesn't suffer from the 8-bit filedescriptor limit that we hit with nasty consequences on some systems I would eventually prefer us to have a configure test to see if we need to replace stdio, but for now this code needs to be tested widely so I'm enabling it by default. (This used to be commit 1af8bf34f1caa3e7ec312d8109c07d32a945a448)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/cmd_interp.c14
-rw-r--r--source3/lib/debug.c34
-rw-r--r--source3/lib/readline.c6
-rw-r--r--source3/lib/util.c10
4 files changed, 22 insertions, 42 deletions
diff --git a/source3/lib/cmd_interp.c b/source3/lib/cmd_interp.c
index 1d31d78b94..fed3d65d62 100644
--- a/source3/lib/cmd_interp.c
+++ b/source3/lib/cmd_interp.c
@@ -198,16 +198,6 @@ do a (presumably graceful) quit...
****************************************************************************/
static uint32 cmd_quit(struct client_info *info, int argc, char *argv[])
{
-#ifdef MEM_MAN
- {
- extern FILE *dbf;
- smb_mem_write_status(dbf);
- smb_mem_write_errors(dbf);
- smb_mem_write_verbose(dbf);
- dbgflush();
- }
-#endif
-
free_connections();
exit(0);
@@ -927,7 +917,7 @@ static uint32 cmd_set(CLIENT_INFO *info, int argc, char *argv[])
BOOL interactive = True;
char *cmd_str = NULL;
int opt;
- extern FILE *dbf;
+ extern XFILE *dbf;
extern char *optarg;
static pstring servicesf = CONFIGFILE;
pstring term_code;
@@ -1048,7 +1038,7 @@ static uint32 cmd_set(CLIENT_INFO *info, int argc, char *argv[])
case 'E':
{
cmd_set_options |= CMD_DBG;
- dbf = stderr;
+ dbf = x_stderr;
break;
}
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 4dbeda2f73..9eb490c27e 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -79,7 +79,7 @@
* levels higher than DEBUGLEVEL will not be processed.
*/
-FILE *dbf = NULL;
+XFILE *dbf = NULL;
pstring debugf = "";
BOOL append_log = False;
@@ -308,7 +308,7 @@ void setup_logging(char *pname, BOOL interactive)
if (interactive) {
stdout_logging = True;
- dbf = stdout;
+ dbf = x_stdout;
}
#ifdef WITH_SYSLOG
else {
@@ -337,7 +337,7 @@ BOOL reopen_logs( void )
{
pstring fname;
mode_t oldumask;
- FILE *new_dbf = NULL;
+ XFILE *new_dbf = NULL;
BOOL ret = True;
if (stdout_logging)
@@ -351,20 +351,20 @@ BOOL reopen_logs( void )
pstrcpy( debugf, fname );
if (append_log)
- new_dbf = sys_fopen( debugf, "a" );
+ new_dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644);
else
- new_dbf = sys_fopen( debugf, "w" );
+ new_dbf = x_fopen( debugf, O_WRONLY|O_CREAT|O_TRUNC, 0644 );
if (!new_dbf) {
log_overflow = True;
DEBUG(0, ("Unable to open new log file %s: %s\n", debugf, strerror(errno)));
log_overflow = False;
- fflush(dbf);
+ x_fflush(dbf);
ret = False;
} else {
- setbuf(new_dbf, NULL);
+ x_setbuf(new_dbf, NULL);
if (dbf)
- (void) fclose(dbf);
+ (void) x_fclose(dbf);
dbf = new_dbf;
}
@@ -429,7 +429,7 @@ void check_log_size( void )
maxlog = lp_max_log_size() * 1024;
- if( sys_fstat( fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
+ if( sys_fstat( x_fileno( dbf ), &st ) == 0 && st.st_size > maxlog ) {
(void)reopen_logs();
if( dbf && get_file_size( debugf ) > maxlog ) {
pstring name;
@@ -456,7 +456,7 @@ void check_log_size( void )
startup or when the log level is increased from zero.
-dwg 6 June 2000
*/
- dbf = sys_fopen( "/dev/console", "w" );
+ dbf = x_fopen( "/dev/console", O_WRONLY, 0);
if(dbf) {
DEBUG(0,("check_log_size: open of debug file %s failed - using console.\n",
debugf ));
@@ -484,7 +484,7 @@ void check_log_size( void )
{
va_start( ap, format_str );
if(dbf)
- (void)vfprintf( dbf, format_str, ap );
+ (void)x_vfprintf( dbf, format_str, ap );
va_end( ap );
errno = old_errno;
return( 0 );
@@ -499,13 +499,13 @@ void check_log_size( void )
mode_t oldumask = umask( 022 );
if( append_log )
- dbf = sys_fopen( debugf, "a" );
+ dbf = x_fopen( debugf, O_WRONLY|O_APPEND|O_CREAT, 0644 );
else
- dbf = sys_fopen( debugf, "w" );
+ dbf = x_fopen( debugf, O_WRONLY|O_CREAT|O_TRUNC, 0644 );
(void)umask( oldumask );
if( dbf )
{
- setbuf( dbf, NULL );
+ x_setbuf( dbf, NULL );
}
else
{
@@ -554,10 +554,10 @@ void check_log_size( void )
{
va_start( ap, format_str );
if(dbf)
- (void)vfprintf( dbf, format_str, ap );
+ (void)x_vfprintf( dbf, format_str, ap );
va_end( ap );
if(dbf)
- (void)fflush( dbf );
+ (void)x_fflush( dbf );
}
errno = old_errno;
@@ -647,7 +647,7 @@ void dbgflush( void )
{
bufr_print();
if(dbf)
- (void)fflush( dbf );
+ (void)x_fflush( dbf );
} /* dbgflush */
/* ************************************************************************** **
diff --git a/source3/lib/readline.c b/source3/lib/readline.c
index 11d65a2b16..b03d37695e 100644
--- a/source3/lib/readline.c
+++ b/source3/lib/readline.c
@@ -49,14 +49,14 @@ static char *smb_readline_replacement(char *prompt, void (*callback)(void),
int end))
{
fd_set fds;
- extern FILE *dbf;
+ extern XFILE *dbf;
static pstring line;
struct timeval timeout;
int fd = fileno(stdin);
char *ret;
- fprintf(dbf, "%s", prompt);
- fflush(dbf);
+ x_fprintf(dbf, "%s", prompt);
+ x_fflush(dbf);
while (1) {
timeout.tv_sec = 5;
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 9b92e412d0..d1d052d4a0 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -630,16 +630,6 @@ BOOL yesno(char *p)
return(False);
}
-#ifdef HPUX
-/****************************************************************************
-this is a version of setbuffer() for those machines that only have setvbuf
-****************************************************************************/
- void setbuffer(FILE *f,char *buf,int bufsize)
-{
- setvbuf(f,buf,_IOFBF,bufsize);
-}
-#endif
-
/****************************************************************************
expand a pointer to be a particular size
****************************************************************************/