From ea4078e52e0b2a67831d36f9b78f950cadc2cbba Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Wed, 29 Jun 2011 21:52:01 +0400 Subject: [PATCH 1/5] Ticket #2361: VFS URI reimplementation Code cleanup: * (vfs_set_raw_current_dir): remove redundant check. * VFS: minor optimizations. * Fixed type of mode argument of vfs_class:chmod method. Signed-off-by: Andrew Borodin Signed-off-by: Slava Zanko --- lib/vfs/interface.c | 7 +++---- lib/vfs/path.c | 17 ++++------------- lib/vfs/path.h | 2 -- lib/vfs/vfs.c | 3 +-- lib/vfs/vfs.h | 2 +- src/vfs/extfs/extfs.c | 2 +- src/vfs/fish/fish.c | 4 ++-- src/vfs/ftpfs/ftpfs.c | 4 ++-- src/vfs/local/local.c | 2 +- src/vfs/sfs/sfs.c | 2 +- src/vfs/smbfs/smbfs.c | 4 ++-- 11 files changed, 18 insertions(+), 31 deletions(-) diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c index c939605e9..31b5702d7 100644 --- a/lib/vfs/interface.c +++ b/lib/vfs/interface.c @@ -269,8 +269,7 @@ mc_symlink (const char *name1, const char *path) if (vpath2 != NULL) { - vfs_path_element_t *path_element = - vfs_path_get_by_index (vpath1, vfs_path_elements_count (vpath1) - 1); + vfs_path_element_t *path_element = vfs_path_get_by_index (vpath1, -1); if (vfs_path_element_valid (path_element)) { result = @@ -330,8 +329,8 @@ int mc_##name (const char *fname1, const char *fname2) \ vfs_path_free(vpath1); \ return -1; \ }\ - path_element1 = vfs_path_get_by_index (vpath1, vfs_path_elements_count (vpath1) - 1); \ - path_element2 = vfs_path_get_by_index (vpath2, vfs_path_elements_count (vpath2) - 1); \ + path_element1 = vfs_path_get_by_index (vpath1, - 1); \ + path_element2 = vfs_path_get_by_index (vpath2, - 1); \ \ if (!vfs_path_element_valid (path_element1) || !vfs_path_element_valid (path_element2) || \ path_element1->class != path_element2->class) \ diff --git a/lib/vfs/path.c b/lib/vfs/path.c index 058e6fedd..9406ebf32 100644 --- a/lib/vfs/path.c +++ b/lib/vfs/path.c @@ -664,10 +664,7 @@ vfs_path_new (void) int vfs_path_elements_count (const vfs_path_t * vpath) { - if (vpath == NULL) - return 0; - - return (vpath->path != NULL) ? g_list_length (vpath->path) : 0; + return (vpath != NULL && vpath->path != NULL) ? g_list_length (vpath->path) : 0; } /* --------------------------------------------------------------------------------------------- */ @@ -683,19 +680,13 @@ vfs_path_elements_count (const vfs_path_t * vpath) vfs_path_element_t * vfs_path_get_by_index (const vfs_path_t * vpath, int element_index) { - vfs_path_element_t *element; - - if (vpath == NULL) - return NULL; + if (element_index < 0) + element_index += vfs_path_elements_count (vpath); if (element_index < 0) - element_index = vfs_path_elements_count (vpath) + element_index; - - element = g_list_nth_data (vpath->path, element_index); - if (element == NULL) vfs_die ("vfs_path_get_by_index: incorrect index!"); - return element; + return g_list_nth_data (vpath->path, element_index); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/vfs/path.h b/lib/vfs/path.h index cc294c4c9..980ab9869 100644 --- a/lib/vfs/path.h +++ b/lib/vfs/path.h @@ -33,8 +33,6 @@ typedef struct GIConv converter; DIR *info; } dir; - - struct vfs_s_super *current_super_block; } vfs_path_element_t; /*** global variables defined in .c file *********************************************************/ diff --git a/lib/vfs/vfs.c b/lib/vfs/vfs.c index 1a02c7553..c2ae6af70 100644 --- a/lib/vfs/vfs.c +++ b/lib/vfs/vfs.c @@ -379,8 +379,7 @@ vfs_get_raw_current_dir (void) void vfs_set_raw_current_dir (const vfs_path_t * vpath) { - if (current_path != NULL) - vfs_path_free (current_path); + vfs_path_free (current_path); current_path = (vfs_path_t *) vpath; } diff --git a/lib/vfs/vfs.h b/lib/vfs/vfs.h index db236a794..5319711f9 100644 --- a/lib/vfs/vfs.h +++ b/lib/vfs/vfs.h @@ -163,7 +163,7 @@ typedef struct vfs_class int (*lstat) (const vfs_path_t * vpath, struct stat * buf); int (*fstat) (void *vfs_info, struct stat * buf); - int (*chmod) (const vfs_path_t * vpath, int mode); + int (*chmod) (const vfs_path_t * vpath, mode_t mode); int (*chown) (const vfs_path_t * vpath, uid_t owner, gid_t group); int (*utime) (const vfs_path_t * vpath, struct utimbuf * times); diff --git a/src/vfs/extfs/extfs.c b/src/vfs/extfs/extfs.c index 62d5e47e2..0bc5e14a7 100644 --- a/src/vfs/extfs/extfs.c +++ b/src/vfs/extfs/extfs.c @@ -1177,7 +1177,7 @@ extfs_chown (const vfs_path_t * vpath, uid_t owner, gid_t group) /* --------------------------------------------------------------------------------------------- */ static int -extfs_chmod (const vfs_path_t * vpath, int mode) +extfs_chmod (const vfs_path_t * vpath, mode_t mode) { (void) vpath; (void) mode; diff --git a/src/vfs/fish/fish.c b/src/vfs/fish/fish.c index 8dfe4bb9d..5666cbdbd 100644 --- a/src/vfs/fish/fish.c +++ b/src/vfs/fish/fish.c @@ -1244,7 +1244,7 @@ fish_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2) /* --------------------------------------------------------------------------------------------- */ static int -fish_chmod (const vfs_path_t * vpath, int mode) +fish_chmod (const vfs_path_t * vpath, mode_t mode) { gchar *shell_commands = NULL; char buf[BUF_LARGE]; @@ -1262,7 +1262,7 @@ fish_chmod (const vfs_path_t * vpath, int mode) shell_commands = g_strconcat (SUP->scr_env, "FISH_FILENAME=%s FISH_FILEMODE=%4.4o;\n", SUP->scr_chmod, (char *) NULL); - g_snprintf (buf, sizeof (buf), shell_commands, rpath, mode & 07777); + g_snprintf (buf, sizeof (buf), shell_commands, rpath, (int) (mode & 07777)); g_free (shell_commands); g_free (rpath); return fish_send_command (path_element->class, super, buf, OPT_FLUSH); diff --git a/src/vfs/ftpfs/ftpfs.c b/src/vfs/ftpfs/ftpfs.c index 618632367..b9b2ed190 100644 --- a/src/vfs/ftpfs/ftpfs.c +++ b/src/vfs/ftpfs/ftpfs.c @@ -1981,12 +1981,12 @@ ftpfs_send_command (const vfs_path_t * vpath, const char *cmd, int flags) /* --------------------------------------------------------------------------------------------- */ static int -ftpfs_chmod (const vfs_path_t * vpath, int mode) +ftpfs_chmod (const vfs_path_t * vpath, mode_t mode) { char buf[BUF_SMALL]; int ret; - g_snprintf (buf, sizeof (buf), "SITE CHMOD %4.4o /%%s", mode & 07777); + g_snprintf (buf, sizeof (buf), "SITE CHMOD %4.4o /%%s", (int) (mode & 07777)); ret = ftpfs_send_command (vpath, buf, OPT_FLUSH); diff --git a/src/vfs/local/local.c b/src/vfs/local/local.c index 23c23313e..624e31258 100644 --- a/src/vfs/local/local.c +++ b/src/vfs/local/local.c @@ -141,7 +141,7 @@ local_lstat (const vfs_path_t * vpath, struct stat *buf) /* --------------------------------------------------------------------------------------------- */ static int -local_chmod (const vfs_path_t * vpath, int mode) +local_chmod (const vfs_path_t * vpath, mode_t mode) { vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, -1); diff --git a/src/vfs/sfs/sfs.c b/src/vfs/sfs/sfs.c index 24a85ae50..9055abe67 100644 --- a/src/vfs/sfs/sfs.c +++ b/src/vfs/sfs/sfs.c @@ -293,7 +293,7 @@ sfs_lstat (const vfs_path_t * vpath, struct stat *buf) /* --------------------------------------------------------------------------------------------- */ static int -sfs_chmod (const vfs_path_t * vpath, int mode) +sfs_chmod (const vfs_path_t * vpath, mode_t mode) { return chmod (sfs_redirect (vpath), mode); } diff --git a/src/vfs/smbfs/smbfs.c b/src/vfs/smbfs/smbfs.c index 3e0589b43..c9c86dfec 100644 --- a/src/vfs/smbfs/smbfs.c +++ b/src/vfs/smbfs/smbfs.c @@ -964,11 +964,11 @@ smbfs_closedir (void *info) /* --------------------------------------------------------------------------------------------- */ static int -smbfs_chmod (const vfs_path_t * vpath, int mode) +smbfs_chmod (const vfs_path_t * vpath, mode_t mode) { vfs_path_element_t *path_element = vfs_path_get_by_index (vpath, -1); - DEBUG (3, ("smbfs_chmod(path:%s, mode:%d)\n", path_element->path, mode)); + DEBUG (3, ("smbfs_chmod(path:%s, mode:%d)\n", path_element->path, (int) mode)); /* my_errno = EOPNOTSUPP; return -1; *//* cannot chmod on smb filesystem */ return 0; /* make mc happy */ From 12af8e5db060b2c0f47c5515b8134e05d009cf77 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 29 Jun 2011 13:12:19 +0300 Subject: [PATCH 2/5] fixed relative symlink operations. Symlink now stay relative Signed-off-by: Slava Zanko --- lib/vfs/interface.c | 2 +- lib/vfs/path.c | 26 +++++++++++++++++++++++--- lib/vfs/path.h | 7 +++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c index 31b5702d7..76fb4f216 100644 --- a/lib/vfs/interface.c +++ b/lib/vfs/interface.c @@ -265,7 +265,7 @@ mc_symlink (const char *name1, const char *path) if (vpath1 == NULL) return -1; - vpath2 = vfs_path_from_str (name1); + vpath2 = vfs_path_from_str_flags (name1, VPF_NO_CANON); if (vpath2 != NULL) { diff --git a/lib/vfs/path.c b/lib/vfs/path.c index 9406ebf32..ea4e01c88 100644 --- a/lib/vfs/path.c +++ b/lib/vfs/path.c @@ -607,15 +607,16 @@ vfs_path_to_str (const vfs_path_t * vpath) /* --------------------------------------------------------------------------------------------- */ /** - * Split path string to path elements. + * Split path string to path elements with flags for change parce process. * * @param path_str VFS-path + * @param flags flags for parser * * @return pointer to newly created vfs_path_t object with filled path elements array. */ vfs_path_t * -vfs_path_from_str (const char *path_str) +vfs_path_from_str_flags (const char *path_str, vfs_path_flag_t flags) { vfs_path_t *vpath; char *path; @@ -623,7 +624,11 @@ vfs_path_from_str (const char *path_str) if (path_str == NULL) return NULL; - path = vfs_canon (path_str); + if ((flags & VPF_NO_CANON) == 0) + path = vfs_canon (path_str); + else + path = g_strdup (path_str); + if (path == NULL) return NULL; @@ -637,6 +642,21 @@ vfs_path_from_str (const char *path_str) return vpath; } +/* --------------------------------------------------------------------------------------------- */ +/** + * Split path string to path elements. + * + * @param path_str VFS-path + * + * @return pointer to newly created vfs_path_t object with filled path elements array. + */ + +vfs_path_t * +vfs_path_from_str (const char *path_str) +{ + return vfs_path_from_str_flags (path_str, VPF_NONE); +} + /* --------------------------------------------------------------------------------------------- */ /* * Create new vfs_path_t object. diff --git a/lib/vfs/path.h b/lib/vfs/path.h index 980ab9869..16420d9de 100644 --- a/lib/vfs/path.h +++ b/lib/vfs/path.h @@ -7,6 +7,12 @@ /*** enums ***************************************************************************************/ +typedef enum +{ + VPF_NONE = 0, + VPF_NO_CANON = 1 +} vfs_path_flag_t; + /*** structures declarations (and typedefs of structures)*****************************************/ struct vfs_class; @@ -48,6 +54,7 @@ int vfs_path_elements_count (const vfs_path_t * path); char *vfs_path_to_str (const vfs_path_t * path); char *vfs_path_to_str_elements_count (const vfs_path_t * path, int elements_count); vfs_path_t *vfs_path_from_str (const char *path_str); +vfs_path_t *vfs_path_from_str_flags (const char *path_str, vfs_path_flag_t flags); vfs_path_element_t *vfs_path_get_by_index (const vfs_path_t * path, int element_index); vfs_path_element_t *vfs_path_element_clone (const vfs_path_element_t * element); From 32a9f8257d0417abb4083c801215b4d48ae4933a Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 29 Jun 2011 13:41:14 +0300 Subject: [PATCH 3/5] Deprecated parser now used just in Hotlist widget. Signed-off-by: Slava Zanko --- lib/tests/vfs/current_dir.c | 42 ------------------------- lib/tests/vfs/path_serialize.c | 2 +- lib/tests/vfs/vfs_path_string_convert.c | 8 ++--- lib/tests/vfs/vfs_s_get_path.c | 3 +- lib/vfs/path.c | 2 +- lib/vfs/path.h | 3 +- src/filemanager/hotlist.c | 38 +++++++++++++--------- 7 files changed, 34 insertions(+), 64 deletions(-) diff --git a/lib/tests/vfs/current_dir.c b/lib/tests/vfs/current_dir.c index c19e7b336..9e347899d 100644 --- a/lib/tests/vfs/current_dir.c +++ b/lib/tests/vfs/current_dir.c @@ -69,47 +69,6 @@ test_chdir(const vfs_path_t * vpath) strcmp(etalon, mc_get_current_wd(buffer,MC_MAXPATHLEN)) == 0, \ "\n expected(%s) doesn't equal \nto actual(%s)", etalon, buffer); -START_TEST (set_up_current_dir) -{ - static struct vfs_s_subclass test_subclass; - static struct vfs_class vfs_test_ops; - char buffer[MC_MAXPATHLEN]; - - vfs_s_init_class (&vfs_test_ops, &test_subclass); - - vfs_test_ops.name = "testfs"; - vfs_test_ops.flags = VFSF_NOLINKS; - vfs_test_ops.prefix = "test"; - vfs_test_ops.chdir = test_chdir; - - vfs_register_class (&vfs_test_ops); - - cd_and_check ("/dev/some.file#test", "/dev/some.file/test://"); - - cd_and_check ("/dev/some.file#test/bla-bla", "/dev/some.file/test://bla-bla"); - - cd_and_check ("..", "/dev/some.file/test://"); - - cd_and_check ("..", "/dev"); - - cd_and_check ("..", "/"); - - cd_and_check ("..", "/"); - - cd_and_check ("/dev/some.file/#test/bla-bla", "/dev/some.file/test://bla-bla"); - - cd_and_check ("..", "/dev/some.file/test://"); - - cd_and_check ("..", "/dev"); - - cd_and_check ("..", "/"); - - cd_and_check ("..", "/"); -} -END_TEST - -/* --------------------------------------------------------------------------------------------- */ - START_TEST (set_up_current_dir_url) { static struct vfs_s_subclass test_subclass; @@ -161,7 +120,6 @@ main (void) tcase_add_checked_fixture (tc_core, setup, teardown); /* Add new tests here: *************** */ - tcase_add_test (tc_core, set_up_current_dir); tcase_add_test (tc_core, set_up_current_dir_url); /* *********************************** */ diff --git a/lib/tests/vfs/path_serialize.c b/lib/tests/vfs/path_serialize.c index f86ddb985..cfe3a733a 100644 --- a/lib/tests/vfs/path_serialize.c +++ b/lib/tests/vfs/path_serialize.c @@ -115,7 +115,7 @@ START_TEST (test_path_serialize_deserialize) char *serialized_vpath; GError *error = NULL; - vpath = vfs_path_from_str (ETALON_PATH_STR); + vpath = vfs_path_from_str_flags (ETALON_PATH_STR, VPF_USE_DEPRECATED_PARSER); serialized_vpath = vfs_path_serialize (vpath, &error); vfs_path_free (vpath); diff --git a/lib/tests/vfs/vfs_path_string_convert.c b/lib/tests/vfs/vfs_path_string_convert.c index fd96c9390..ca063e990 100644 --- a/lib/tests/vfs/vfs_path_string_convert.c +++ b/lib/tests/vfs/vfs_path_string_convert.c @@ -87,7 +87,7 @@ START_TEST (test_vfs_path_from_to_string) vfs_path_t *vpath; size_t vpath_len; char *result; - vpath = vfs_path_from_str (ETALON_PATH_STR); + vpath = vfs_path_from_str_flags (ETALON_PATH_STR, VPF_USE_DEPRECATED_PARSER); vpath_len = vfs_path_elements_count(vpath); @@ -133,7 +133,7 @@ START_TEST (test_vfs_path_from_to_partial_string_by_class) { vfs_path_t *vpath; char *result; - vpath = vfs_path_from_str (ETALON_PATH_STR); + vpath = vfs_path_from_str_flags (ETALON_PATH_STR, VPF_USE_DEPRECATED_PARSER); result = vfs_path_to_str_elements_count(vpath, -1); @@ -203,7 +203,7 @@ END_TEST vfs_path_t *vpath; \ char *result; \ \ - vpath = vfs_path_from_str (input); \ + vpath = vfs_path_from_str_flags (input, VPF_USE_DEPRECATED_PARSER); \ result = vfs_path_to_str(vpath); \ fail_unless( result != NULL && strcmp(result, etalon) ==0, \ "\ninput : %s\nactual: %s\netalon: %s", input, result , etalon ); \ @@ -262,7 +262,7 @@ START_TEST (test_vfs_path_encoding_at_end) mc_global.sysconfig_dir = (char *) TEST_SHARE_DIR; load_codepages_list (); - vpath = vfs_path_from_str ("/path/to/file.ext#test1:/#enc:KOI8-R"); + vpath = vfs_path_from_str_flags ("/path/to/file.ext#test1:/#enc:KOI8-R", VPF_USE_DEPRECATED_PARSER); result = vfs_path_to_str(vpath); element = vfs_path_get_by_index(vpath, -1); diff --git a/lib/tests/vfs/vfs_s_get_path.c b/lib/tests/vfs/vfs_s_get_path.c index 3f9bf9d56..16686f805 100644 --- a/lib/tests/vfs/vfs_s_get_path.c +++ b/lib/tests/vfs/vfs_s_get_path.c @@ -125,7 +125,8 @@ START_TEST (test_vfs_s_get_path) struct vfs_s_super *archive; const char *result; - vfs_path_t *vpath = vfs_path_from_str("/" ETALON_VFS_NAME ARCH_NAME "#test1:/" ETALON_PATH); + vfs_path_t *vpath = vfs_path_from_str_flags ("/" ETALON_VFS_NAME ARCH_NAME "#test1:/" ETALON_PATH, + VPF_USE_DEPRECATED_PARSER); result = vfs_s_get_path (vpath, &archive, 0); diff --git a/lib/vfs/path.c b/lib/vfs/path.c index ea4e01c88..e070512ef 100644 --- a/lib/vfs/path.c +++ b/lib/vfs/path.c @@ -632,7 +632,7 @@ vfs_path_from_str_flags (const char *path_str, vfs_path_flag_t flags) if (path == NULL) return NULL; - if (vfs_path_is_str_path_deprecated (path)) + if ((flags & VPF_USE_DEPRECATED_PARSER) != 0 && vfs_path_is_str_path_deprecated (path)) vpath = vfs_path_from_str_deprecated_parser (path); else vpath = vfs_path_from_str_uri_parser (path); diff --git a/lib/vfs/path.h b/lib/vfs/path.h index 16420d9de..384a87d9c 100644 --- a/lib/vfs/path.h +++ b/lib/vfs/path.h @@ -10,7 +10,8 @@ typedef enum { VPF_NONE = 0, - VPF_NO_CANON = 1 + VPF_NO_CANON = 1, + VPF_USE_DEPRECATED_PARSER = 2 } vfs_path_flag_t; /*** structures declarations (and typedefs of structures)*****************************************/ diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c index fa797343e..65c8c7c50 100644 --- a/src/filemanager/hotlist.c +++ b/src/filemanager/hotlist.c @@ -1429,13 +1429,18 @@ hot_load_group (struct hotlist *grp) current_group = grp; break; case TKN_ENTRY: - CHECK_TOKEN (TKN_STRING); - label = g_strdup (tkn_buf->str); - CHECK_TOKEN (TKN_URL); - CHECK_TOKEN (TKN_STRING); - url = g_strdup (tkn_buf->str); - add2hotlist (label, url, HL_TYPE_ENTRY, LISTBOX_APPEND_AT_END); - SKIP_TO_EOL; + { + vfs_path_t *vpath; + CHECK_TOKEN (TKN_STRING); + label = g_strdup (tkn_buf->str); + CHECK_TOKEN (TKN_URL); + CHECK_TOKEN (TKN_STRING); + vpath = vfs_path_from_str_flags (tkn_buf->str, VPF_USE_DEPRECATED_PARSER); + url = vfs_path_to_str (vpath); + vfs_path_free (vpath); + add2hotlist (label, url, HL_TYPE_ENTRY, LISTBOX_APPEND_AT_END); + SKIP_TO_EOL; + } break; case TKN_COMMENT: label = g_strdup (tkn_buf->str); @@ -1481,13 +1486,18 @@ hot_load_file (struct hotlist *grp) current_group = grp; break; case TKN_ENTRY: - CHECK_TOKEN (TKN_STRING); - label = g_strdup (tkn_buf->str); - CHECK_TOKEN (TKN_URL); - CHECK_TOKEN (TKN_STRING); - url = g_strdup (tkn_buf->str); - add2hotlist (label, url, HL_TYPE_ENTRY, LISTBOX_APPEND_AT_END); - SKIP_TO_EOL; + { + vfs_path_t *vpath; + CHECK_TOKEN (TKN_STRING); + label = g_strdup (tkn_buf->str); + CHECK_TOKEN (TKN_URL); + CHECK_TOKEN (TKN_STRING); + vpath = vfs_path_from_str_flags (tkn_buf->str, VPF_USE_DEPRECATED_PARSER); + url = vfs_path_to_str (vpath); + vfs_path_free (vpath); + add2hotlist (label, url, HL_TYPE_ENTRY, LISTBOX_APPEND_AT_END); + SKIP_TO_EOL; + } break; case TKN_COMMENT: label = g_strdup (tkn_buf->str); From 2044d8f8534416782a1bdbb04a6f8aa29014f51f Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Thu, 30 Jun 2011 13:26:03 +0300 Subject: [PATCH 4/5] custom_canonicalize_pathname(): Removed old-style path handling. Signed-off-by: Slava Zanko --- lib/utilunix.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/lib/utilunix.c b/lib/utilunix.c index 26f3977f6..213adf3e3 100644 --- a/lib/utilunix.c +++ b/lib/utilunix.c @@ -695,26 +695,8 @@ custom_canonicalize_pathname (char *path, CANON_PATH_FLAGS flags) } if (*s == PATH_SEP) - { - /* skip VFS prefix */ - char *path_sep; - struct vfs_class *vclass; + break; - /* old parser mode */ - if (*(s + 1) != '#') - break; - - path_sep = strchr (s + 1, PATH_SEP); - if (path_sep != NULL) - *path_sep = '\0'; - - vclass = vfs_prefix_to_class (s + 2); - if (path_sep != NULL) - *path_sep = PATH_SEP; - - if (vclass == NULL) - break; - } s--; } From 0f249bd9b53fcbc26b325f5cdbf1595267999820 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Tue, 5 Jul 2011 16:05:15 +0300 Subject: [PATCH 5/5] Fixed errors while connect to IPv6 hosts Signed-off-by: Slava Zanko --- lib/vfs/path.c | 5 +++++ lib/vfs/path.h | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/vfs/path.c b/lib/vfs/path.c index e070512ef..bd37e3ca4 100644 --- a/lib/vfs/path.c +++ b/lib/vfs/path.c @@ -193,7 +193,11 @@ vfs_path_build_url_params_str (vfs_path_element_t * element) { if ((element->user != NULL) || (element->password != NULL)) g_string_append_c (buffer, '@'); + if (element->ipv6) + g_string_append_c (buffer, '['); g_string_append (buffer, element->host); + if (element->ipv6) + g_string_append_c (buffer, ']'); } if ((element->port) != 0 && (element->host != NULL)) @@ -314,6 +318,7 @@ vfs_path_url_split (vfs_path_element_t * path_element, const char *path) colon[0] = '\0'; colon[1] = '\0'; colon++; + path_element->ipv6 = TRUE; } } diff --git a/lib/vfs/path.h b/lib/vfs/path.h index 384a87d9c..6f54dfb21 100644 --- a/lib/vfs/path.h +++ b/lib/vfs/path.h @@ -29,6 +29,7 @@ typedef struct char *user; char *password; char *host; + gboolean ipv6; int port; char *path; struct vfs_class *class;