Re: [RFE][PATCH] Allow cd smb://, cd sh://, cd mc:// vfs requests
Jindrich Novy wrote: +} url_table[] = { {ftp://;, 6, /#ftp:}, + {mc://, 5, /#mc:}, + {smb://, 6, /#smb:}, + {sh://, 5, /#sh:}, Here I added {ssh://, 6, /#sh:}, + {a:, 2, /#a} +}; + char * vfs_translate_url (const char *url) { +int i; I changed this to size_t i. } prefixes[] = { {/#ftp:, 6}, -{/#mc:, 5}, {ftp://;, 6}, +{/#mc:, 5}, +{mc://, 5}, {/#smb:, 6}, -{/#sh:, 5} +{smb://, 6}, +{/#sh:, 5}, +{sh://, 5} I added ssh:// here as well. }; char *at, *inner_colon, *dir; size_t i; And finally committed the changed patch. Roland ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
[RFE][PATCH] Allow cd smb://, cd sh://, cd mc:// vfs requests
Hi, since we can access ftp filesystems either like cd /#ftp: or more intuitively like cd ftp:// it's not a bad idea IMNSHO to add such extensions also for other filesystems. The attached patch implements such an extension and it makes vfs_translate_url() more comprehensive in the way that the aliases are kept in a separate table. strip_password() is modified to take the change in account. Cheers, Jindrich -- Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/ ChangeLog: * vfs.c (vfs_translate_url): Add support for smb://, sh:// and mc:// filesystem requests. Introduced separate table for vfs aliases. * util.c (strip_password): Modifications to take the aliases into account while eliminating passwords. --- mc-4.6.1a-20050202/vfs/vfs.c.vfs-url 2004-11-16 17:16:08.0 +0100 +++ mc-4.6.1a-20050202/vfs/vfs.c 2005-02-07 13:03:06.660269240 +0100 @@ -981,15 +981,28 @@ vfs_fill_names (fill_names_f func) * Returns vfs path corresponding to given url. If passed string is * not recognized as url, g_strdup(url) is returned. */ + +static const struct { +const char *name; +size_t name_len; +const char *substitute; +} url_table[] = { {ftp://;, 6, /#ftp:}, + {mc://, 5, /#mc:}, + {smb://, 6, /#smb:}, + {sh://, 5, /#sh:}, + {a:, 2, /#a} +}; + char * vfs_translate_url (const char *url) { -if (strncmp (url, ftp://;, 6) == 0) - return g_strconcat (/#ftp:, url + 6, (char *) NULL); -else if (strncmp (url, a:, 2) == 0) - return g_strdup (/#a); -else - return g_strdup (url); +int i; + +for (i = 0; i sizeof (url_table)/sizeof (url_table[0]); i++) + if (!strncmp (url, url_table[i].name, url_table[i].name_len)) + return g_strconcat (url_table[i].substitute, url + url_table[i].name_len, (char*)NULL); + +return g_strdup (url); } int vfs_file_is_local (const char *filename) --- mc-4.6.1a-20050202/src/util.c.vfs-url 2004-12-02 21:08:06.0 +0100 +++ mc-4.6.1a-20050202/src/util.c 2005-02-07 13:19:53.830156144 +0100 @@ -432,10 +432,13 @@ strip_password (char *p, int has_prefix) const char *name; size_t len; } prefixes[] = { {/#ftp:, 6}, - {/#mc:, 5}, {ftp://;, 6}, + {/#mc:, 5}, + {mc://, 5}, {/#smb:, 6}, - {/#sh:, 5} + {smb://, 6}, + {/#sh:, 5}, + {sh://, 5} }; char *at, *inner_colon, *dir; size_t i; ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [RFE][PATCH] Allow cd smb://, cd sh://, cd mc:// vfs requests
Jindrich Novy wrote: Hi, since we can access ftp filesystems either like cd /#ftp: or more intuitively like cd ftp:// it's not a bad idea IMNSHO to add such extensions also for other filesystems. The attached patch implements such an extension and it makes vfs_translate_url() more comprehensive in the way that the aliases are kept in a separate table. strip_password() is modified to take the change in account. Cheers, Jindrich Jindrich, As you have already touched this part of the code, think about one more feature: replace /#ftp-like prefixes to ftp://-like on command line substitution (%d, %D, M-Enter, etc.) In most cases such substitution is used to form an argument of a command, i.e. rmp -i %D/%F, or lynx -dump %D . Currently, only internal cd command can eat /#ftp: . An ideal variant is: internal cd can handel both mc and general form, command line substitution should mostly use general form. I have a patch (written some years ago) for ftp://; case... -- Dmitry Butskoj [EMAIL PROTECTED] Saint-Petersburg, Russia Red Hat Certified Engineer 809003662809495 ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [RFE][PATCH] Allow cd smb://, cd sh://, cd mc:// vfs requests
Hello Dmitry, On Mon, 2005-02-07 at 16:14 +0300, buc wrote: Jindrich Novy wrote: since we can access ftp filesystems either like cd /#ftp: or more intuitively like cd ftp:// it's not a bad idea IMNSHO to add such extensions also for other filesystems. The attached patch implements such an extension and it makes vfs_translate_url() more comprehensive in the way that the aliases are kept in a separate table. strip_password() is modified to take the change in account. As you have already touched this part of the code, think about one more feature: replace /#ftp-like prefixes to ftp://-like on command line substitution (%d, %D, M-Enter, etc.) In most cases such substitution is used to form an argument of a command, i.e. rmp -i %D/%F, or lynx -dump %D . Currently, only internal cd command can eat /#ftp: . An ideal variant is: internal cd can handel both mc and general form, command line substitution should mostly use general form. I have a patch (written some years ago) for ftp://; case... I only wanted to propose a more intuitive way to access various VFSes to the most of users and to let them use the functionality ASAP. Some further work to let them make their life with mc more comfortable is welcome so if you have any pending patches similar to this problem, no one will be angry if you send them here ;) Cheers, Jindrich -- Jindrich Novy [EMAIL PROTECTED], http://people.redhat.com/jnovy/ ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel
Re: [RFE][PATCH] Allow cd smb://, cd sh://, cd mc:// vfs requests
Jindrich Novy wrote: Hello Dmitry, I only wanted to propose a more intuitive way to access various VFSes to the most of users and to let them use the functionality ASAP. Some further work to let them make their life with mc more comfortable is welcome so if you have any pending patches similar to this problem, no one will be angry if you send them here ;) Cheers, Jindrich My old patch attached. It locates the place where something should be done now, not for ftp only... -- Dmitry Butskoj [EMAIL PROTECTED] Saint-Petersburg, Russia Red Hat Certified Engineer 809003662809495 diff -Nrbu mc-4.6.0/src/util.c mc-4.6.0-OK/src/util.c --- mc-4.6.0/src/util.c 2003-11-13 18:25:13.0 +0300 +++ mc-4.6.0-OK/src/util.c 2003-11-13 18:22:23.0 +0300 @@ -186,6 +186,13 @@ *d++ = '.'; *d++ = '/'; } +else if (*s == '/' s[1] == '#' + !strncmp (s, /#ftp:, 6) +) { + strcpy (d, ftp://;); + s += 6; + d += 6; +} for (; *s; s++, d++) { switch (*s) { ___ Mc-devel mailing list http://mail.gnome.org/mailman/listinfo/mc-devel