From 05385e158607f13d476fe5177742ac4c99f78c70 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Mon, 18 Jul 2011 16:11:00 +0400 Subject: [PATCH] Set logfile for smbfs using mc_setctl(). Signed-off-by: Andrew Borodin --- src/args.c | 12 ++++++------ src/vfs/smbfs/smbfs.c | 43 +++++++++++++++++++++++-------------------- src/vfs/smbfs/smbfs.h | 3 --- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/args.c b/src/args.c index a6007cc4a..15bd5063b 100644 --- a/src/args.c +++ b/src/args.c @@ -416,21 +416,21 @@ mc_setup_by_args (int argc, char *argv[]) const char *base; char *tmp; +#ifdef ENABLE_VFS_SMB + if (mc_args__debug_level != 0) + smbfs_set_debug (mc_args__debug_level); +#endif /* ENABLE_VFS_SMB */ + if (mc_args__netfs_logfile != NULL) { #ifdef ENABLE_VFS_FTP mc_setctl ("ftp://", VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile); #endif /* ENABLE_VFS_FTP */ #ifdef ENABLE_VFS_SMB - smbfs_set_debugf (mc_args__netfs_logfile); + mc_setctl ("smb://", VFS_SETCTL_LOGFILE, (void *) mc_args__netfs_logfile); #endif /* ENABLE_VFS_SMB */ } -#ifdef ENABLE_VFS_SMB - if (mc_args__debug_level != 0) - smbfs_set_debug (mc_args__debug_level); -#endif /* ENABLE_VFS_SMB */ - base = x_basename (argv[0]); tmp = (argc > 0) ? argv[1] : NULL; diff --git a/src/vfs/smbfs/smbfs.c b/src/vfs/smbfs/smbfs.c index c9c86dfec..583b21456 100644 --- a/src/vfs/smbfs/smbfs.c +++ b/src/vfs/smbfs/smbfs.c @@ -27,7 +27,7 @@ * \author Andrew V. Samoilov * \date 1997, 2002, 2003 * - * Namespace: exports init_smbfs, smbfs_set_debug(), smbfs_set_debugf() + * Namespace: exports init_smbfs, smbfs_set_debug() */ #include @@ -169,6 +169,24 @@ static dir_entry *single_entry; static struct cli_state *smbfs_do_connect (const char *server, char *share); /* --------------------------------------------------------------------------------------------- */ + +static void +smbfs_set_debugf (const char *filename) +{ + if (DEBUGLEVEL > 0) + { + FILE *outfile = fopen (filename, "w"); + if (outfile) + { + setup_logging ("", True); /* No needs for timestamp for each message */ + dbf = outfile; + setbuf (dbf, NULL); + pstrcpy (debugf, filename); + } + } +} + +/* --------------------------------------------------------------------------------------------- */ /* this function allows you to write: * char *s = g_strdup("hello, world"); * s = free_after(g_strconcat(s, s, (char *)0), s); @@ -350,24 +368,6 @@ smbfs_set_debug (int arg) } /* --------------------------------------------------------------------------------------------- */ - -void -smbfs_set_debugf (const char *filename) -{ - if (DEBUGLEVEL > 0) - { - FILE *outfile = fopen (filename, "w"); - if (outfile) - { - setup_logging ("", True); /* No needs for timestamp for each message */ - dbf = outfile; - setbuf (dbf, NULL); - pstrcpy (debugf, filename); - } - } -} - -/* --------------------------------------------------------------------------------------------- */ /********************** The callbacks ******************************/ static int @@ -1998,7 +1998,10 @@ smbfs_setctl (const vfs_path_t * vpath, int ctlop, void *arg) { case VFS_SETCTL_FORGET: smbfs_forget (path_element->path); - return 0; + break; + case VFS_SETCTL_LOGFILE: + smbfs_set_debugf ((const char *) arg); + break; } return 0; } diff --git a/src/vfs/smbfs/smbfs.h b/src/vfs/smbfs/smbfs.h index d8a9d430d..de9231988 100644 --- a/src/vfs/smbfs/smbfs.h +++ b/src/vfs/smbfs/smbfs.h @@ -27,11 +27,8 @@ typedef struct smb_authinfo /*** declarations of public functions ************************************************************/ - - void init_smbfs (void); void smbfs_set_debug (int arg); -void smbfs_set_debugf (const char *filename); smb_authinfo *vfs_smb_authinfo_new (const char *host, const char *share, -- 2.11.4.GIT