VFS: move logfile member from vfs_s_subclass to vfs_class.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2019-05-20 07:50:09 +03:00
parent 94c0b79f37
commit 45bd20ab0b
5 changed files with 28 additions and 30 deletions

View File

@ -811,7 +811,7 @@ vfs_s_setctl (const vfs_path_t * vpath, int ctlop, void *arg)
return 1; return 1;
} }
case VFS_SETCTL_LOGFILE: case VFS_SETCTL_LOGFILE:
VFS_SUBCLASS (path_element->class)->logfile = fopen ((char *) arg, "w"); path_element->class->logfile = fopen ((char *) arg, "w");
return 1; return 1;
case VFS_SETCTL_FLUSH: case VFS_SETCTL_FLUSH:
VFS_SUBCLASS (path_element->class)->flush = 1; VFS_SUBCLASS (path_element->class)->flush = 1;
@ -1605,7 +1605,7 @@ vfs_s_select_on_two (int fd1, int fd2)
int int
vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char term) vfs_s_get_line (struct vfs_class *me, int sock, char *buf, int buf_len, char term)
{ {
FILE *logfile = VFS_SUBCLASS (me)->logfile; FILE *logfile = me->logfile;
int i; int i;
char c; char c;

View File

@ -147,6 +147,7 @@ typedef struct vfs_class
vfs_flags_t flags; vfs_flags_t flags;
const char *prefix; /* "fish:" */ const char *prefix; /* "fish:" */
int verrno; /* can't use errno because glibc2 might define errno as function */ int verrno; /* can't use errno because glibc2 might define errno as function */
FILE *logfile;
/* *INDENT-OFF* */ /* *INDENT-OFF* */
int (*init) (struct vfs_class * me); int (*init) (struct vfs_class * me);

View File

@ -116,7 +116,6 @@ struct vfs_s_subclass
GList *supers; GList *supers;
int inode_counter; int inode_counter;
dev_t rdev; dev_t rdev;
FILE *logfile;
int flush; /* if set to 1, invalidate directory cache */ int flush; /* if set to 1, invalidate directory cache */
/* *INDENT-OFF* */ /* *INDENT-OFF* */

View File

@ -272,7 +272,7 @@ fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, c
size_t cmd_len) size_t cmd_len)
{ {
ssize_t status; ssize_t status;
FILE *logfile = VFS_SUBCLASS (me)->logfile; FILE *logfile = me->logfile;
if (cmd_len == (size_t) (-1)) if (cmd_len == (size_t) (-1))
cmd_len = strlen (cmd); cmd_len = strlen (cmd);
@ -754,7 +754,6 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
struct vfs_s_super *super = dir->super; struct vfs_s_super *super = dir->super;
char buffer[BUF_8K] = "\0"; char buffer[BUF_8K] = "\0";
struct vfs_s_entry *ent = NULL; struct vfs_s_entry *ent = NULL;
FILE *logfile;
char *quoted_path; char *quoted_path;
int reply_code; int reply_code;
@ -762,10 +761,9 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
* Simple FISH debug interface :] * Simple FISH debug interface :]
*/ */
#if 0 #if 0
if (VFS_SUBCLASS (me)->logfile == NULL) if (me->logfile == NULL)
VFS_SUBCLASS (me)->logfile = fopen ("/tmp/mc-FISH.sh", "w"); me->logfile = fopen ("/tmp/mc-FISH.sh", "w");
#endif #endif
logfile = VFS_SUBCLASS (me)->logfile;
vfs_print_message (_("fish: Reading directory %s..."), remote_path); vfs_print_message (_("fish: Reading directory %s..."), remote_path);
@ -791,11 +789,11 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
me->verrno = ECONNRESET; me->verrno = ECONNRESET;
goto error; goto error;
} }
if (logfile != NULL) if (me->logfile != NULL)
{ {
fputs (buffer, logfile); fputs (buffer, me->logfile);
fputs ("\n", logfile); fputs ("\n", me->logfile);
fflush (logfile); fflush (me->logfile);
} }
if (strncmp (buffer, "### ", 4) == 0) if (strncmp (buffer, "### ", 4) == 0)
break; break;

View File

@ -307,10 +307,10 @@ ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const cha
if (!FTP_SUPER (super)->remote_is_amiga) if (!FTP_SUPER (super)->remote_is_amiga)
return g_strdup (remote_path); return g_strdup (remote_path);
if (VFS_SUBCLASS (me)->logfile != NULL) if (me->logfile != NULL)
{ {
fprintf (VFS_SUBCLASS (me)->logfile, "MC -- ftpfs_translate_path: %s\n", remote_path); fprintf (me->logfile, "MC -- ftpfs_translate_path: %s\n", remote_path);
fflush (VFS_SUBCLASS (me)->logfile); fflush (me->logfile);
} }
/* strip leading slash(es) */ /* strip leading slash(es) */
@ -491,19 +491,19 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
va_end (ap); va_end (ap);
g_string_append (cmdstr, "\r\n"); g_string_append (cmdstr, "\r\n");
if (VFS_SUBCLASS (me)->logfile != NULL) if (me->logfile != NULL)
{ {
if (strncmp (cmdstr->str, "PASS ", 5) == 0) if (strncmp (cmdstr->str, "PASS ", 5) == 0)
fputs ("PASS <Password not logged>\r\n", VFS_SUBCLASS (me)->logfile); fputs ("PASS <Password not logged>\r\n", me->logfile);
else else
{ {
size_t ret; size_t ret;
ret = fwrite (cmdstr->str, cmdstr->len, 1, VFS_SUBCLASS (me)->logfile); ret = fwrite (cmdstr->str, cmdstr->len, 1, me->logfile);
(void) ret; (void) ret;
} }
fflush (VFS_SUBCLASS (me)->logfile); fflush (me->logfile);
} }
got_sigpipe = 0; got_sigpipe = 0;
@ -647,7 +647,7 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char
super->path_element->password = g_strdup (op); super->path_element->password = g_strdup (op);
} }
if (!anon || VFS_SUBCLASS (me)->logfile != NULL) if (!anon || me->logfile != NULL)
pass = op; pass = op;
else else
{ {
@ -675,11 +675,11 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char
ftp_super->strict = RFC_STRICT; ftp_super->strict = RFC_STRICT;
g_free (reply_up); g_free (reply_up);
if (VFS_SUBCLASS (me)->logfile != NULL) if (me->logfile != NULL)
{ {
fprintf (VFS_SUBCLASS (me)->logfile, "MC -- remote_is_amiga = %s\n", fprintf (me->logfile, "MC -- remote_is_amiga = %s\n",
ftp_super->remote_is_amiga ? "yes" : "no"); ftp_super->remote_is_amiga ? "yes" : "no");
fflush (VFS_SUBCLASS (me)->logfile); fflush (me->logfile);
} }
vfs_print_message ("%s", _("ftpfs: sending login name")); vfs_print_message ("%s", _("ftpfs: sending login name"));
@ -1658,10 +1658,10 @@ resolve_symlink_with_ls_options (struct vfs_class *me, struct vfs_s_super *super
if (fgets (buffer, sizeof (buffer), fp) == NULL) if (fgets (buffer, sizeof (buffer), fp) == NULL)
goto done; goto done;
if (VFS_SUBCLASS (me)->logfile != NULL) if (me->logfile != NULL)
{ {
fputs (buffer, VFS_SUBCLASS (me)->logfile); fputs (buffer, me->logfile);
fflush (VFS_SUBCLASS (me)->logfile); fflush (me->logfile);
} }
vfs_die ("This code should be commented out\n"); vfs_die ("This code should be commented out\n");
@ -1793,11 +1793,11 @@ ftpfs_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path
return (-1); return (-1);
} }
if (VFS_SUBCLASS (me)->logfile != NULL) if (me->logfile != NULL)
{ {
fputs (lc_buffer, VFS_SUBCLASS (me)->logfile); fputs (lc_buffer, me->logfile);
fputs ("\n", VFS_SUBCLASS (me)->logfile); fputs ("\n", me->logfile);
fflush (VFS_SUBCLASS (me)->logfile); fflush (me->logfile);
} }
ent = vfs_s_generate_entry (me, NULL, dir, 0); ent = vfs_s_generate_entry (me, NULL, dir, 0);