mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-30 03:32:53 +03:00
Remove vfs_url_t structure (replace with vfs_path_element_t)
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
3eafe7308a
commit
997876a109
@ -86,10 +86,10 @@ teardown (void)
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
#define ETALON_PATH_STR "/local/path/#test1:user:pass@some.host:12345/bla-bla/some/path/#test2:/#enc:KOI8-R/bla-bla/some/path#test3:/111/22/33"
|
||||
#define ETALON_SERIALIZED_PATH "g14:path-element-0p4:pathv12:/local/path/p10:class-namev7:localfs" \
|
||||
"g14:path-element-1p4:pathv18:bla-bla/some/path/p10:class-namev7:testfs1p11:raw_url_strv31:test1:user:pass@some.host:12345" \
|
||||
"g14:path-element-2p4:pathv17:bla-bla/some/pathp10:class-namev7:testfs2p8:encodingv6:KOI8-Rp11:raw_url_strv6:test2:" \
|
||||
"g14:path-element-3p4:pathv9:111/22/33p10:class-namev7:testfs3p11:raw_url_strv6:test3:"
|
||||
#define ETALON_SERIALIZED_PATH "g14:path-element-0p4:pathv12:/local/path/p10:class-namev7:localfsp4:portv1:0" \
|
||||
"g14:path-element-1p4:pathv18:bla-bla/some/path/p10:class-namev7:testfs1p11:raw_url_strv31:test1:user:pass@some.host:12345p4:portv1:0" \
|
||||
"g14:path-element-2p4:pathv17:bla-bla/some/pathp10:class-namev7:testfs2p8:encodingv6:KOI8-Rp11:raw_url_strv6:test2:p4:portv1:0" \
|
||||
"g14:path-element-3p4:pathv9:111/22/33p10:class-namev7:testfs3p11:raw_url_strv6:test3:p4:portv1:0"
|
||||
|
||||
START_TEST (test_path_serialize_deserialize)
|
||||
{
|
||||
|
@ -385,7 +385,7 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super)
|
||||
|
||||
CALL (free_archive) (me, super);
|
||||
#ifdef ENABLE_VFS_NET
|
||||
vfs_url_free (super->url);
|
||||
vfs_path_element_free (super->path_element);
|
||||
#endif
|
||||
g_free (super->name);
|
||||
g_free (super);
|
||||
|
@ -418,7 +418,9 @@ vfs_path_element_free (vfs_path_element_t * element)
|
||||
if (element == NULL)
|
||||
return;
|
||||
|
||||
vfs_url_free (element->url);
|
||||
g_free (element->user);
|
||||
g_free (element->password);
|
||||
g_free (element->host);
|
||||
g_free (element->path);
|
||||
g_free (element->encoding);
|
||||
|
||||
@ -526,15 +528,10 @@ vfs_path_serialize (const vfs_path_t * vpath, GError ** error)
|
||||
|
||||
mc_config_set_string_raw (cpath, groupname, "raw_url_str", element->raw_url_str);
|
||||
|
||||
if (element->url != NULL)
|
||||
{
|
||||
mc_config_set_bool (cpath, groupname, "has-url", TRUE);
|
||||
mc_config_set_string_raw (cpath, groupname, "url-user", element->url->user);
|
||||
mc_config_set_string_raw (cpath, groupname, "url-password", element->url->password);
|
||||
mc_config_set_string_raw (cpath, groupname, "url-host", element->url->host);
|
||||
mc_config_set_int (cpath, groupname, "url-port", element->url->port);
|
||||
mc_config_set_string_raw (cpath, groupname, "url-path", element->url->path);
|
||||
}
|
||||
mc_config_set_string_raw (cpath, groupname, "user", element->user);
|
||||
mc_config_set_string_raw (cpath, groupname, "password", element->password);
|
||||
mc_config_set_string_raw (cpath, groupname, "host", element->host);
|
||||
mc_config_set_int (cpath, groupname, "port", element->port);
|
||||
|
||||
g_free (groupname);
|
||||
}
|
||||
@ -600,16 +597,11 @@ vfs_path_deserialize (const char *data, GError ** error)
|
||||
|
||||
element->raw_url_str = mc_config_get_string_raw (cpath, groupname, "raw_url_str", NULL);
|
||||
|
||||
if (mc_config_get_bool (cpath, groupname, "has-url", FALSE))
|
||||
{
|
||||
element->url = g_new0 (vfs_url_t, 1);
|
||||
element->url->user = mc_config_get_string_raw (cpath, groupname, "url-user", NULL);
|
||||
element->url->password =
|
||||
mc_config_get_string_raw (cpath, groupname, "url-password", NULL);
|
||||
element->url->host = mc_config_get_string_raw (cpath, groupname, "url-host", NULL);
|
||||
element->url->port = mc_config_get_int (cpath, groupname, "url-port", 0);
|
||||
element->url->path = mc_config_get_string_raw (cpath, groupname, "url-path", NULL);
|
||||
}
|
||||
element->user = mc_config_get_string_raw (cpath, groupname, "user", NULL);
|
||||
element->password = mc_config_get_string_raw (cpath, groupname, "password", NULL);
|
||||
element->host = mc_config_get_string_raw (cpath, groupname, "host", NULL);
|
||||
element->port = mc_config_get_int (cpath, groupname, "port", 0);
|
||||
|
||||
vpath->path = g_list_append (vpath->path, element);
|
||||
|
||||
g_free (groupname);
|
||||
|
@ -17,6 +17,10 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *user;
|
||||
char *password;
|
||||
char *host;
|
||||
int port;
|
||||
char *path;
|
||||
struct vfs_class *class;
|
||||
char *encoding;
|
||||
@ -28,7 +32,6 @@ typedef struct
|
||||
} dir;
|
||||
|
||||
char *raw_url_str;
|
||||
struct vfs_url_struct *url;
|
||||
|
||||
struct vfs_s_super *current_super_block;
|
||||
} vfs_path_element_t;
|
||||
|
@ -383,17 +383,17 @@ vfs_mkstemps (char **pname, const char *prefix, const char *param_basename)
|
||||
* host.
|
||||
*/
|
||||
|
||||
vfs_url_t *
|
||||
vfs_path_element_t *
|
||||
vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
{
|
||||
vfs_url_t *url;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
char *pcopy;
|
||||
const char *pend;
|
||||
char *dir, *colon, *inner_colon, *at, *rest;
|
||||
|
||||
url = g_new0 (vfs_url_t, 1);
|
||||
url->port = default_port;
|
||||
path_element = g_new0 (vfs_path_element_t, 1);
|
||||
path_element->port = default_port;
|
||||
|
||||
pcopy = g_strdup (path);
|
||||
pend = pcopy + strlen (pcopy);
|
||||
@ -405,10 +405,10 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
while (*dir != PATH_SEP && *dir != '\0')
|
||||
dir++;
|
||||
if (*dir == '\0')
|
||||
url->path = g_strdup (PATH_SEP_STR);
|
||||
path_element->path = g_strdup (PATH_SEP_STR);
|
||||
else
|
||||
{
|
||||
url->path = g_strdup (dir);
|
||||
path_element->path = g_strdup (dir);
|
||||
*dir = '\0';
|
||||
}
|
||||
}
|
||||
@ -427,11 +427,11 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
{
|
||||
*inner_colon = '\0';
|
||||
inner_colon++;
|
||||
url->password = g_strdup (inner_colon);
|
||||
path_element->password = g_strdup (inner_colon);
|
||||
}
|
||||
|
||||
if (*pcopy != '\0')
|
||||
url->user = g_strdup (pcopy);
|
||||
path_element->user = g_strdup (pcopy);
|
||||
|
||||
if (pend == at + 1)
|
||||
rest = at;
|
||||
@ -440,7 +440,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
}
|
||||
|
||||
if ((flags & URL_USE_ANONYMOUS) == 0)
|
||||
url->user = vfs_get_local_username ();
|
||||
path_element->user = vfs_get_local_username ();
|
||||
|
||||
/* Check if the host comes with a port spec, if so, chop it */
|
||||
if (*rest != '[')
|
||||
@ -456,7 +456,7 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
}
|
||||
else
|
||||
{
|
||||
vfs_url_free (url);
|
||||
vfs_path_element_free (path_element);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -464,10 +464,10 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
if (colon != NULL)
|
||||
{
|
||||
*colon = '\0';
|
||||
if (sscanf (colon + 1, "%d", &url->port) == 1)
|
||||
if (sscanf (colon + 1, "%d", &path_element->port) == 1)
|
||||
{
|
||||
if (url->port <= 0 || url->port >= 65536)
|
||||
url->port = default_port;
|
||||
if (path_element->port <= 0 || path_element->port >= 65536)
|
||||
path_element->port = default_port;
|
||||
}
|
||||
else
|
||||
while (*(++colon) != '\0')
|
||||
@ -475,33 +475,18 @@ vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags)
|
||||
switch (*colon)
|
||||
{
|
||||
case 'C':
|
||||
url->port = 1;
|
||||
path_element->port = 1;
|
||||
break;
|
||||
case 'r':
|
||||
url->port = 2;
|
||||
path_element->port = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
url->host = g_strdup (rest);
|
||||
path_element->host = g_strdup (rest);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
vfs_url_free (vfs_url_t * url)
|
||||
{
|
||||
if (url != NULL)
|
||||
{
|
||||
g_free (url->user);
|
||||
g_free (url->password);
|
||||
g_free (url->host);
|
||||
g_free (url->path);
|
||||
g_free (url);
|
||||
}
|
||||
return path_element;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "lib/global.h"
|
||||
#include "path.h"
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
@ -31,15 +32,6 @@ typedef enum
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
typedef struct vfs_url_struct
|
||||
{
|
||||
char *user;
|
||||
char *password;
|
||||
char *host;
|
||||
int port;
|
||||
char *path;
|
||||
} vfs_url_t;
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
@ -47,8 +39,7 @@ typedef struct vfs_url_struct
|
||||
int vfs_finduid (const char *name);
|
||||
int vfs_findgid (const char *name);
|
||||
|
||||
vfs_url_t *vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags);
|
||||
void vfs_url_free (vfs_url_t * url);
|
||||
vfs_path_element_t *vfs_url_split (const char *path, int default_port, vfs_url_flags_t flags);
|
||||
int vfs_split_text (char *p);
|
||||
|
||||
int vfs_mkstemps (char **pname, const char *prefix, const char *basename);
|
||||
|
@ -64,7 +64,7 @@ struct vfs_s_super
|
||||
int ino_usage; /* Usage count of this superblock */
|
||||
int want_stale; /* If set, we do not flush cache properly */
|
||||
#ifdef ENABLE_VFS_NET
|
||||
vfs_url_t *url;
|
||||
vfs_path_element_t *path_element;
|
||||
#endif /* ENABLE_VFS_NET */
|
||||
|
||||
void *data; /* This is for filesystem-specific use */
|
||||
|
@ -430,17 +430,17 @@ fish_open_archive_pipeopen (struct vfs_s_super *super)
|
||||
{
|
||||
char gbuf[10];
|
||||
const char *argv[10]; /* All of 10 is used now */
|
||||
const char *xsh = (super->url->port == FISH_FLAG_RSH ? "rsh" : "ssh");
|
||||
const char *xsh = (super->path_element->port == FISH_FLAG_RSH ? "rsh" : "ssh");
|
||||
int i = 0;
|
||||
|
||||
argv[i++] = xsh;
|
||||
if (super->url->port == FISH_FLAG_COMPRESSED)
|
||||
if (super->path_element->port == FISH_FLAG_COMPRESSED)
|
||||
argv[i++] = "-C";
|
||||
|
||||
if (super->url->port > FISH_FLAG_RSH)
|
||||
if (super->path_element->port > FISH_FLAG_RSH)
|
||||
{
|
||||
argv[i++] = "-p";
|
||||
g_snprintf (gbuf, sizeof (gbuf), "%d", super->url->port);
|
||||
g_snprintf (gbuf, sizeof (gbuf), "%d", super->path_element->port);
|
||||
argv[i++] = gbuf;
|
||||
}
|
||||
|
||||
@ -451,18 +451,18 @@ fish_open_archive_pipeopen (struct vfs_s_super *super)
|
||||
* option breaks it for some)
|
||||
*/
|
||||
|
||||
if (super->url->user != NULL)
|
||||
if (super->path_element->user != NULL)
|
||||
{
|
||||
argv[i++] = "-l";
|
||||
argv[i++] = super->url->user;
|
||||
argv[i++] = super->path_element->user;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The rest of the code assumes it to be a valid username */
|
||||
super->url->user = vfs_get_local_username ();
|
||||
super->path_element->user = vfs_get_local_username ();
|
||||
}
|
||||
|
||||
argv[i++] = super->url->host;
|
||||
argv[i++] = super->path_element->host;
|
||||
argv[i++] = "echo FISH:; /bin/sh";
|
||||
argv[i++] = NULL;
|
||||
|
||||
@ -490,15 +490,15 @@ fish_open_archive_talk (struct vfs_class *me, struct vfs_s_super *super)
|
||||
|
||||
return FALSE;
|
||||
#if 0
|
||||
if (super->url->password == NULL)
|
||||
if (super->path_element->password == NULL)
|
||||
{
|
||||
char *p, *op;
|
||||
p = g_strdup_printf (_("fish: Password is required for %s"), super->url->user);
|
||||
p = g_strdup_printf (_("fish: Password is required for %s"), super->path_element->user);
|
||||
op = vfs_get_password (p);
|
||||
g_free (p);
|
||||
if (op == NULL)
|
||||
return FALSE;
|
||||
super->url->password = op;
|
||||
super->path_element->password = op;
|
||||
|
||||
}
|
||||
|
||||
@ -507,8 +507,8 @@ fish_open_archive_talk (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
size_t str_len;
|
||||
|
||||
str_len = strlen (super->url->password);
|
||||
if ((write (SUP.sockw, super->url->password, str_len) != (ssize_t) str_len)
|
||||
str_len = strlen (super->path_element->password);
|
||||
if ((write (SUP.sockw, super->path_element->password, str_len) != (ssize_t) str_len)
|
||||
|| (write (SUP->sockw, "\n", 1) != 1))
|
||||
return FALSE;
|
||||
}
|
||||
@ -564,11 +564,12 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
SUP->scr_env = fish_set_env (SUP->host_flags);
|
||||
|
||||
vfs_print_message (_("fish: Setting up current directory..."));
|
||||
super->url->path = fish_getcwd (me, super);
|
||||
vfs_print_message (_("fish: Connected, home %s."), super->url->path);
|
||||
super->path_element->path = fish_getcwd (me, super);
|
||||
vfs_print_message (_("fish: Connected, home %s."), super->path_element->path);
|
||||
#if 0
|
||||
super->name =
|
||||
g_strconcat ("/#sh:", super->url->user, "@", super->url->host, "/", (char *) NULL);
|
||||
g_strconcat ("/#sh:", super->path_element->user, "@", super->path_element->host, "/",
|
||||
(char *) NULL);
|
||||
#else
|
||||
super->name = g_strdup (PATH_SEP_STR);
|
||||
#endif
|
||||
@ -586,37 +587,49 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super,
|
||||
(void) archive_name;
|
||||
|
||||
super->data = g_new0 (fish_super_data_t, 1);
|
||||
super->url = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS);
|
||||
super->path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS);
|
||||
|
||||
if (strncmp (op, "rsh:", 4) == 0)
|
||||
super->url->port = FISH_FLAG_RSH;
|
||||
super->path_element->port = FISH_FLAG_RSH;
|
||||
|
||||
SUP->scr_ls = fish_load_script_from_file (super->url->host, FISH_LS_FILE, FISH_LS_DEF_CONTENT);
|
||||
SUP->scr_ls =
|
||||
fish_load_script_from_file (super->path_element->host, FISH_LS_FILE, FISH_LS_DEF_CONTENT);
|
||||
SUP->scr_exists =
|
||||
fish_load_script_from_file (super->url->host, FISH_EXISTS_FILE, FISH_EXISTS_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_EXISTS_FILE,
|
||||
FISH_EXISTS_DEF_CONTENT);
|
||||
SUP->scr_mkdir =
|
||||
fish_load_script_from_file (super->url->host, FISH_MKDIR_FILE, FISH_MKDIR_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_MKDIR_FILE,
|
||||
FISH_MKDIR_DEF_CONTENT);
|
||||
SUP->scr_unlink =
|
||||
fish_load_script_from_file (super->url->host, FISH_UNLINK_FILE, FISH_UNLINK_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_UNLINK_FILE,
|
||||
FISH_UNLINK_DEF_CONTENT);
|
||||
SUP->scr_chown =
|
||||
fish_load_script_from_file (super->url->host, FISH_CHOWN_FILE, FISH_CHOWN_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_CHOWN_FILE,
|
||||
FISH_CHOWN_DEF_CONTENT);
|
||||
SUP->scr_chmod =
|
||||
fish_load_script_from_file (super->url->host, FISH_CHMOD_FILE, FISH_CHMOD_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_CHMOD_FILE,
|
||||
FISH_CHMOD_DEF_CONTENT);
|
||||
SUP->scr_rmdir =
|
||||
fish_load_script_from_file (super->url->host, FISH_RMDIR_FILE, FISH_RMDIR_DEF_CONTENT);
|
||||
SUP->scr_ln = fish_load_script_from_file (super->url->host, FISH_LN_FILE, FISH_LN_DEF_CONTENT);
|
||||
SUP->scr_mv = fish_load_script_from_file (super->url->host, FISH_MV_FILE, FISH_MV_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_RMDIR_FILE,
|
||||
FISH_RMDIR_DEF_CONTENT);
|
||||
SUP->scr_ln =
|
||||
fish_load_script_from_file (super->path_element->host, FISH_LN_FILE, FISH_LN_DEF_CONTENT);
|
||||
SUP->scr_mv =
|
||||
fish_load_script_from_file (super->path_element->host, FISH_MV_FILE, FISH_MV_DEF_CONTENT);
|
||||
SUP->scr_hardlink =
|
||||
fish_load_script_from_file (super->url->host, FISH_HARDLINK_FILE,
|
||||
fish_load_script_from_file (super->path_element->host, FISH_HARDLINK_FILE,
|
||||
FISH_HARDLINK_DEF_CONTENT);
|
||||
SUP->scr_get =
|
||||
fish_load_script_from_file (super->url->host, FISH_GET_FILE, FISH_GET_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_GET_FILE, FISH_GET_DEF_CONTENT);
|
||||
SUP->scr_send =
|
||||
fish_load_script_from_file (super->url->host, FISH_SEND_FILE, FISH_SEND_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_SEND_FILE,
|
||||
FISH_SEND_DEF_CONTENT);
|
||||
SUP->scr_append =
|
||||
fish_load_script_from_file (super->url->host, FISH_APPEND_FILE, FISH_APPEND_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_APPEND_FILE,
|
||||
FISH_APPEND_DEF_CONTENT);
|
||||
SUP->scr_info =
|
||||
fish_load_script_from_file (super->url->host, FISH_INFO_FILE, FISH_INFO_DEF_CONTENT);
|
||||
fish_load_script_from_file (super->path_element->host, FISH_INFO_FILE,
|
||||
FISH_INFO_DEF_CONTENT);
|
||||
|
||||
return fish_open_archive_int (me, super);
|
||||
}
|
||||
@ -627,23 +640,23 @@ static int
|
||||
fish_archive_same (struct vfs_class *me, struct vfs_s_super *super,
|
||||
const char *archive_name, char *op, void *cookie)
|
||||
{
|
||||
vfs_url_t *url;
|
||||
vfs_path_element_t *path_element;
|
||||
int result;
|
||||
|
||||
(void) me;
|
||||
(void) archive_name;
|
||||
(void) cookie;
|
||||
|
||||
url = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS);
|
||||
path_element = vfs_url_split (strchr (op, ':') + 1, 0, URL_NOSLASH | URL_USE_ANONYMOUS);
|
||||
|
||||
if (url->user == NULL)
|
||||
url->user = vfs_get_local_username ();
|
||||
if (path_element->user == NULL)
|
||||
path_element->user = vfs_get_local_username ();
|
||||
|
||||
result = ((strcmp (url->host, super->url->host) == 0)
|
||||
&& (strcmp (url->user, super->url->user) == 0)
|
||||
&& (url->port == super->url->port)) ? 1 : 0;
|
||||
result = ((strcmp (path_element->host, super->path_element->host) == 0)
|
||||
&& (strcmp (path_element->user, super->path_element->user) == 0)
|
||||
&& (path_element->port == super->path_element->port)) ? 1 : 0;
|
||||
|
||||
vfs_url_free (url);
|
||||
vfs_path_element_free (path_element);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -836,8 +849,8 @@ fish_dir_load (struct vfs_class *me, struct vfs_s_inode *dir, char *remote_path)
|
||||
reply_code = fish_decode_reply (buffer + 4, 0);
|
||||
if (reply_code == COMPLETE)
|
||||
{
|
||||
g_free (super->url->path);
|
||||
super->url->path = g_strdup (remote_path);
|
||||
g_free (super->path_element->path);
|
||||
super->path_element->path = g_strdup (remote_path);
|
||||
vfs_print_message (_("%s: done."), me->name);
|
||||
return 0;
|
||||
}
|
||||
@ -1506,7 +1519,7 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
char gbuf[10];
|
||||
const char *flags = "";
|
||||
|
||||
switch (super->url->port)
|
||||
switch (super->path_element->port)
|
||||
{
|
||||
case FISH_FLAG_RSH:
|
||||
flags = ":r";
|
||||
@ -1515,16 +1528,17 @@ fish_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
flags = ":C";
|
||||
break;
|
||||
default:
|
||||
if (super->url->port > FISH_FLAG_RSH)
|
||||
if (super->path_element->port > FISH_FLAG_RSH)
|
||||
{
|
||||
g_snprintf (gbuf, sizeof (gbuf), ":%d", super->url->port);
|
||||
g_snprintf (gbuf, sizeof (gbuf), ":%d", super->path_element->port);
|
||||
flags = gbuf;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
name = g_strconcat ("/#sh:", super->url->user, "@", super->url->host, flags, "/",
|
||||
super->url->path, (char *) NULL);
|
||||
name =
|
||||
g_strconcat ("/#sh:", super->path_element->user, "@", super->path_element->host, flags,
|
||||
"/", super->path_element->path, (char *) NULL);
|
||||
func (name);
|
||||
g_free (name);
|
||||
}
|
||||
|
@ -321,40 +321,40 @@ ftpfs_translate_path (struct vfs_class *me, struct vfs_s_super *super, const cha
|
||||
* is supplied.
|
||||
*/
|
||||
|
||||
static vfs_url_t *
|
||||
static vfs_path_element_t *
|
||||
ftpfs_split_url (const char *path)
|
||||
{
|
||||
vfs_url_t *p;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
p = vfs_url_split (path, FTP_COMMAND_PORT, URL_USE_ANONYMOUS);
|
||||
path_element = vfs_url_split (path, FTP_COMMAND_PORT, URL_USE_ANONYMOUS);
|
||||
|
||||
if (p->user != NULL)
|
||||
if (path_element->user != NULL)
|
||||
{
|
||||
/* Look up user and password in netrc */
|
||||
if (ftpfs_use_netrc)
|
||||
ftpfs_netrc_lookup (p->host, &p->user, &p->password);
|
||||
ftpfs_netrc_lookup (path_element->host, &path_element->user, &path_element->password);
|
||||
}
|
||||
if (p->user == NULL)
|
||||
p->user = g_strdup ("anonymous");
|
||||
if (path_element->user == NULL)
|
||||
path_element->user = g_strdup ("anonymous");
|
||||
|
||||
/* Look up password in netrc for known user */
|
||||
if (ftpfs_use_netrc && p->user != NULL && p->password != NULL)
|
||||
if (ftpfs_use_netrc && path_element->user != NULL && path_element->password != NULL)
|
||||
{
|
||||
char *new_user = NULL;
|
||||
|
||||
ftpfs_netrc_lookup (p->host, &new_user, &p->password);
|
||||
ftpfs_netrc_lookup (path_element->host, &new_user, &path_element->password);
|
||||
|
||||
/* If user is different, remove password */
|
||||
if (new_user != NULL && strcmp (p->user, new_user) != 0)
|
||||
if (new_user != NULL && strcmp (path_element->user, new_user) != 0)
|
||||
{
|
||||
g_free (p->password);
|
||||
p->password = NULL;
|
||||
g_free (path_element->password);
|
||||
path_element->password = NULL;
|
||||
}
|
||||
|
||||
g_free (new_user);
|
||||
}
|
||||
|
||||
return p;
|
||||
return path_element;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -415,14 +415,14 @@ ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super)
|
||||
sock = ftpfs_open_socket (me, super);
|
||||
if (sock != -1)
|
||||
{
|
||||
char *cwdir = super->url->path;
|
||||
char *cwdir = super->path_element->path;
|
||||
|
||||
close (SUP->sock);
|
||||
SUP->sock = sock;
|
||||
super->url->path = NULL;
|
||||
super->path_element->path = NULL;
|
||||
|
||||
|
||||
if (ftpfs_login_server (me, super, super->url->password) != 0)
|
||||
if (ftpfs_login_server (me, super, super->path_element->password) != 0)
|
||||
{
|
||||
if (cwdir == NULL)
|
||||
return 1;
|
||||
@ -431,7 +431,7 @@ ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super)
|
||||
return sock == COMPLETE ? 1 : 0;
|
||||
}
|
||||
|
||||
super->url->path = cwdir;
|
||||
super->path_element->path = cwdir;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -535,7 +535,7 @@ ftpfs_free_archive (struct vfs_class *me, struct vfs_s_super *super)
|
||||
{
|
||||
if (SUP->sock != -1)
|
||||
{
|
||||
vfs_print_message (_("ftpfs: Disconnecting from %s"), super->url->host);
|
||||
vfs_print_message (_("ftpfs: Disconnecting from %s"), super->path_element->host);
|
||||
ftpfs_command (me, super, NONE, "QUIT");
|
||||
close (SUP->sock);
|
||||
}
|
||||
@ -571,11 +571,12 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char
|
||||
|
||||
SUP->isbinary = TYPE_UNKNOWN;
|
||||
|
||||
if (super->url->password != NULL) /* explicit password */
|
||||
op = g_strdup (super->url->password);
|
||||
if (super->path_element->password != NULL) /* explicit password */
|
||||
op = g_strdup (super->path_element->password);
|
||||
else if (netrcpass != NULL) /* password from netrc */
|
||||
op = g_strdup (netrcpass);
|
||||
else if (strcmp (super->url->user, "anonymous") == 0 || strcmp (super->url->user, "ftp") == 0)
|
||||
else if (strcmp (super->path_element->user, "anonymous") == 0
|
||||
|| strcmp (super->path_element->user, "ftp") == 0)
|
||||
{
|
||||
if (ftpfs_anonymous_passwd == NULL) /* default anonymous password */
|
||||
ftpfs_init_passwd ();
|
||||
@ -586,12 +587,12 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char
|
||||
{ /* ask user */
|
||||
char *p;
|
||||
|
||||
p = g_strdup_printf (_("FTP: Password required for %s"), super->url->user);
|
||||
p = g_strdup_printf (_("FTP: Password required for %s"), super->path_element->user);
|
||||
op = vfs_get_password (p);
|
||||
g_free (p);
|
||||
if (op == NULL)
|
||||
ERRNOR (EPERM, 0);
|
||||
super->url->password = g_strdup (op);
|
||||
super->path_element->password = g_strdup (op);
|
||||
}
|
||||
|
||||
if (!anon || MEDATA->logfile)
|
||||
@ -605,11 +606,12 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char
|
||||
/* Proxy server accepts: username@host-we-want-to-connect */
|
||||
if (SUP->proxy)
|
||||
name =
|
||||
g_strconcat (super->url->user, "@",
|
||||
super->url->host[0] == '!' ? super->url->host + 1 : super->url->host,
|
||||
g_strconcat (super->path_element->user, "@",
|
||||
super->path_element->host[0] ==
|
||||
'!' ? super->path_element->host + 1 : super->path_element->host,
|
||||
(char *) NULL);
|
||||
else
|
||||
name = g_strdup (super->url->user);
|
||||
name = g_strdup (super->path_element->user);
|
||||
|
||||
if (ftpfs_get_reply (me, SUP->sock, reply_string, sizeof (reply_string) - 1) == COMPLETE)
|
||||
{
|
||||
@ -636,7 +638,8 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = g_strdup_printf (_("FTP: Account required for user %s"), super->url->user);
|
||||
p = g_strdup_printf (_("FTP: Account required for user %s"),
|
||||
super->path_element->user);
|
||||
op = input_dialog (p, _("Account:"), MC_HISTORY_FTPFS_ACCOUNT, "");
|
||||
g_free (p);
|
||||
if (op == NULL)
|
||||
@ -657,14 +660,15 @@ ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, const char
|
||||
|
||||
default:
|
||||
SUP->failed_on_login = 1;
|
||||
wipe_password (super->url->password);
|
||||
super->url->password = NULL;
|
||||
wipe_password (super->path_element->password);
|
||||
super->path_element->password = NULL;
|
||||
|
||||
goto login_fail;
|
||||
}
|
||||
}
|
||||
|
||||
message (D_ERROR, MSG_ERROR, _("ftpfs: Login incorrect for user %s "), super->url->user);
|
||||
message (D_ERROR, MSG_ERROR, _("ftpfs: Login incorrect for user %s "),
|
||||
super->path_element->user);
|
||||
|
||||
login_fail:
|
||||
wipe_password (pass);
|
||||
@ -763,12 +767,12 @@ ftpfs_check_proxy (const char *host)
|
||||
static void
|
||||
ftpfs_get_proxy_host_and_port (const char *proxy, char **host, int *port)
|
||||
{
|
||||
vfs_url_t *url;
|
||||
vfs_path_element_t *path_element;
|
||||
|
||||
url = vfs_url_split (proxy, FTP_COMMAND_PORT, URL_USE_ANONYMOUS);
|
||||
*host = g_strdup (url->host);
|
||||
*port = url->port;
|
||||
vfs_url_free (url);
|
||||
path_element = vfs_url_split (proxy, FTP_COMMAND_PORT, URL_USE_ANONYMOUS);
|
||||
*host = g_strdup (path_element->host);
|
||||
*port = path_element->port;
|
||||
vfs_path_element_free (path_element);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -786,7 +790,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
(void) me;
|
||||
|
||||
/* Use a proxy host? */
|
||||
host = g_strdup (super->url->host);
|
||||
host = g_strdup (super->path_element->host);
|
||||
|
||||
if (host == NULL || *host == '\0')
|
||||
{
|
||||
@ -797,7 +801,7 @@ ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super)
|
||||
}
|
||||
|
||||
/* Hosts to connect to that start with a ! should use proxy */
|
||||
tmp_port = super->url->port;
|
||||
tmp_port = super->path_element->port;
|
||||
|
||||
if (SUP->proxy != NULL)
|
||||
ftpfs_get_proxy_host_and_port (ftpfs_proxy_host, &host, &tmp_port);
|
||||
@ -945,9 +949,9 @@ ftpfs_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
|
||||
}
|
||||
while (retry_seconds != 0);
|
||||
|
||||
super->url->path = ftpfs_get_current_directory (me, super);
|
||||
if (super->url->path == NULL)
|
||||
super->url->path = g_strdup (PATH_SEP_STR);
|
||||
super->path_element->path = ftpfs_get_current_directory (me, super);
|
||||
if (super->path_element->path == NULL)
|
||||
super->path_element->path = g_strdup (PATH_SEP_STR);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -962,9 +966,9 @@ ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super,
|
||||
|
||||
super->data = g_new0 (ftp_super_data_t, 1);
|
||||
|
||||
super->url = ftpfs_split_url (strchr (op, ':') + 1);
|
||||
super->path_element = ftpfs_split_url (strchr (op, ':') + 1);
|
||||
SUP->proxy = NULL;
|
||||
if (ftpfs_check_proxy (super->url->host))
|
||||
if (ftpfs_check_proxy (super->path_element->host))
|
||||
SUP->proxy = ftpfs_proxy_host;
|
||||
SUP->use_passive_connection = ftpfs_use_passive_connections;
|
||||
SUP->strict = ftpfs_use_unix_list_options ? RFC_AUTODETECT : RFC_STRICT;
|
||||
@ -982,20 +986,20 @@ static int
|
||||
ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super,
|
||||
const char *archive_name, char *op, void *cookie)
|
||||
{
|
||||
vfs_url_t *url;
|
||||
vfs_path_element_t *path_element;
|
||||
int result;
|
||||
|
||||
(void) me;
|
||||
(void) archive_name;
|
||||
(void) cookie;
|
||||
|
||||
url = ftpfs_split_url (strchr (op, ':') + 1);
|
||||
path_element = ftpfs_split_url (strchr (op, ':') + 1);
|
||||
|
||||
result = ((strcmp (url->host, super->url->host) == 0)
|
||||
&& (strcmp (url->user, super->url->user) == 0)
|
||||
&& (url->port == super->url->port)) ? 1 : 0;
|
||||
result = ((strcmp (path_element->host, super->path_element->host) == 0)
|
||||
&& (strcmp (path_element->user, super->path_element->user) == 0)
|
||||
&& (path_element->port == super->path_element->port)) ? 1 : 0;
|
||||
|
||||
vfs_url_free (url);
|
||||
vfs_path_element_free (path_element);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2023,9 +2027,9 @@ ftpfs_is_same_dir (struct vfs_class *me, struct vfs_s_super *super, const char *
|
||||
{
|
||||
(void) me;
|
||||
|
||||
if (super->url->path == NULL)
|
||||
if (super->path_element->path == NULL)
|
||||
return FALSE;
|
||||
return (strcmp (path, super->url->path) == 0);
|
||||
return (strcmp (path, super->path_element->path) == 0);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -2047,8 +2051,8 @@ ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, const cha
|
||||
ftpfs_errno = EIO;
|
||||
else
|
||||
{
|
||||
g_free (super->url->path);
|
||||
super->url->path = g_strdup (remote_path);
|
||||
g_free (super->path_element->path);
|
||||
super->path_element->path = g_strdup (remote_path);
|
||||
SUP->cwd_deferred = 0;
|
||||
}
|
||||
return r;
|
||||
@ -2206,8 +2210,9 @@ ftpfs_fill_names (struct vfs_class *me, fill_names_f func)
|
||||
const struct vfs_s_super *super = (const struct vfs_s_super *) iter->data;
|
||||
char *name;
|
||||
|
||||
name = g_strconcat ("/#ftp:", super->url->user, "@", super->url->host, "/",
|
||||
super->url->path, (char *) NULL);
|
||||
name =
|
||||
g_strconcat ("/#ftp:", super->path_element->user, "@", super->path_element->host, "/",
|
||||
super->path_element->path, (char *) NULL);
|
||||
func (name);
|
||||
g_free (name);
|
||||
}
|
||||
|
@ -1321,7 +1321,7 @@ static char *
|
||||
smbfs_get_path (smbfs_connection ** sc, const vfs_path_t * vpath)
|
||||
{
|
||||
char *remote_path = NULL;
|
||||
vfs_url_t *url;
|
||||
vfs_path_element_t *url;
|
||||
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, -1);
|
||||
char *path = path_element->path;
|
||||
|
||||
@ -1343,7 +1343,7 @@ smbfs_get_path (smbfs_connection ** sc, const vfs_path_t * vpath)
|
||||
if (*sc != NULL)
|
||||
remote_path = g_strdup (url->path);
|
||||
|
||||
vfs_url_free (url);
|
||||
vfs_path_element_free (url);
|
||||
}
|
||||
|
||||
if (remote_path == NULL)
|
||||
@ -1949,7 +1949,7 @@ smbfs_free (vfsid id)
|
||||
static void
|
||||
smbfs_forget (const char *path)
|
||||
{
|
||||
vfs_url_t *p;
|
||||
vfs_path_element_t *p;
|
||||
|
||||
if (strncmp (path, URL_HEADER, HEADER_LEN) != 0)
|
||||
return;
|
||||
@ -1981,7 +1981,7 @@ smbfs_forget (const char *path)
|
||||
}
|
||||
}
|
||||
|
||||
vfs_url_free (p);
|
||||
vfs_path_element_free (p);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user