mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 10:04:32 +03:00
(ftpfs_command): minor optimization.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
6d3d6c9b45
commit
56081caaae
@ -477,30 +477,26 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
|
|||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char *cmdstr;
|
GString *cmdstr;
|
||||||
int status, cmdlen;
|
int status;
|
||||||
static int retry = 0;
|
static int retry = 0;
|
||||||
static int level = 0; /* ftpfs_login_server() use ftpfs_command() */
|
static int level = 0; /* ftpfs_login_server() use ftpfs_command() */
|
||||||
|
|
||||||
|
cmdstr = g_string_sized_new (32);
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
cmdstr = g_strdup_vprintf (fmt, ap);
|
g_string_vprintf (cmdstr, fmt, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
g_string_append (cmdstr, "\r\n");
|
||||||
|
|
||||||
cmdlen = strlen (cmdstr);
|
if (MEDATA->logfile != NULL)
|
||||||
cmdstr = g_realloc (cmdstr, cmdlen + 3);
|
|
||||||
strcpy (cmdstr + cmdlen, "\r\n");
|
|
||||||
cmdlen += 2;
|
|
||||||
|
|
||||||
if (MEDATA->logfile)
|
|
||||||
{
|
{
|
||||||
if (strncmp (cmdstr, "PASS ", 5) == 0)
|
if (strncmp (cmdstr->str, "PASS ", 5) == 0)
|
||||||
{
|
|
||||||
fputs ("PASS <Password not logged>\r\n", MEDATA->logfile);
|
fputs ("PASS <Password not logged>\r\n", MEDATA->logfile);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
size_t ret;
|
size_t ret;
|
||||||
ret = fwrite (cmdstr, cmdlen, 1, MEDATA->logfile);
|
|
||||||
|
ret = fwrite (cmdstr->str, cmdstr->len, 1, MEDATA->logfile);
|
||||||
(void) ret;
|
(void) ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,7 +505,7 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
|
|||||||
|
|
||||||
got_sigpipe = 0;
|
got_sigpipe = 0;
|
||||||
tty_enable_interrupt_key ();
|
tty_enable_interrupt_key ();
|
||||||
status = write (SUP->sock, cmdstr, cmdlen);
|
status = write (SUP->sock, cmdstr->str, cmdstr->len);
|
||||||
|
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
{
|
{
|
||||||
@ -522,15 +518,13 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
|
|||||||
level = 1;
|
level = 1;
|
||||||
status = ftpfs_reconnect (me, super);
|
status = ftpfs_reconnect (me, super);
|
||||||
level = 0;
|
level = 0;
|
||||||
if (status && (write (SUP->sock, cmdstr, cmdlen) > 0))
|
if (status && (write (SUP->sock, cmdstr->str, cmdstr->len) > 0))
|
||||||
{
|
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
got_sigpipe = 1;
|
got_sigpipe = 1;
|
||||||
}
|
}
|
||||||
g_free (cmdstr);
|
g_string_free (cmdstr, TRUE);
|
||||||
tty_disable_interrupt_key ();
|
tty_disable_interrupt_key ();
|
||||||
return TRANSIENT;
|
return TRANSIENT;
|
||||||
}
|
}
|
||||||
@ -549,16 +543,15 @@ ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
|
|||||||
level = 1;
|
level = 1;
|
||||||
status = ftpfs_reconnect (me, super);
|
status = ftpfs_reconnect (me, super);
|
||||||
level = 0;
|
level = 0;
|
||||||
if (status && (write (SUP->sock, cmdstr, cmdlen) > 0))
|
if (status && (write (SUP->sock, cmdstr->str, cmdstr->len) > 0))
|
||||||
{
|
|
||||||
goto ok;
|
goto ok;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
retry = 0;
|
retry = 0;
|
||||||
g_free (cmdstr);
|
g_string_free (cmdstr, TRUE);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
g_free (cmdstr);
|
|
||||||
|
g_string_free (cmdstr, TRUE);
|
||||||
return COMPLETE;
|
return COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user