Glibing....
Wed Jan 27 03:09:48 1999 Timur I. Bakeyev <mc@bat.ru> * All around the source: Changed copy_strings() to g_strconcat(). Modi- fy last parameter in concat_dir_and_file() to "" - to prevent stack from disbalancing.
Этот коммит содержится в:
родитель
9a43865fa6
Коммит
e57da1f7b3
@ -1,8 +1,19 @@
|
||||
Wed Jan 27 03:09:48 1999 Timur I. Bakeyev <mc@bat.ru>
|
||||
|
||||
* All around the source: Changed copy_strings() to g_strconcat(). Modi-
|
||||
fy last parameter in concat_dir_and_file() to "" - to prevent stack from
|
||||
disbalancing.
|
||||
|
||||
1999-01-25 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* Makefile.am (libvfs_la_SOURCES): Added utilvfs.h.
|
||||
* Make-mc.in (VFSHDRS): Likewise.
|
||||
|
||||
Sat Jan 23 18:40:19 1999 Timur I. Bakeyev <mc@bat.ru>
|
||||
|
||||
* utilvfs.c (append_path_sep): Removed - concat_dir_and_file(dir, NULL);
|
||||
gives the same effect.
|
||||
|
||||
1999-01-21 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||
|
||||
* utilvfs.c (append_path_sep): Fixed, it was broken for paths
|
||||
|
@ -535,7 +535,7 @@ vfs_s_fullpath (vfs *me, vfs_s_inode *ino)
|
||||
vfs_die ("Implement me!");
|
||||
if ((!ino->ent) || (!ino->ent->dir) || (!ino->ent->dir->ent))
|
||||
ERRNOR (EAGAIN, NULL);
|
||||
return copy_strings (ino->ent->dir->ent->name, PATH_SEP_STR,
|
||||
return g_strconcat (ino->ent->dir->ent->name, PATH_SEP_STR,
|
||||
ino->ent->name, NULL);
|
||||
}
|
||||
|
||||
@ -912,7 +912,7 @@ vfs_s_fill_names (vfs *me, void (*func)(char *))
|
||||
char *name;
|
||||
|
||||
while (a){
|
||||
name = copy_strings ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL);
|
||||
name = g_strconcat ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL);
|
||||
(*func)(name);
|
||||
g_free (name);
|
||||
a = a->next;
|
||||
@ -938,7 +938,7 @@ vfs_s_dump (vfs *me, char *prefix, vfs_s_inode *ino)
|
||||
ent = ino->subdir;
|
||||
while (ent){
|
||||
char *s;
|
||||
s = copy_strings (prefix, "/", ent->name, NULL);
|
||||
s = g_strconcat (prefix, "/", ent->name, NULL);
|
||||
if (ent->name[0] == '.')
|
||||
printf ("%s IGNORED\n", s);
|
||||
else
|
||||
|
12
vfs/extfs.c
12
vfs/extfs.c
@ -65,7 +65,7 @@ static void extfs_fill_names (vfs *me, void (*func)(char *))
|
||||
char *name;
|
||||
|
||||
while (a){
|
||||
name = copy_strings (extfs_prefixes [a->fstype], "#",
|
||||
name = g_strconcat (extfs_prefixes [a->fstype], "#",
|
||||
(a->name ? a->name : ""), "/",
|
||||
a->current_dir->name, NULL);
|
||||
(*func)(name);
|
||||
@ -202,7 +202,7 @@ static FILE *open_archive (int fstype, char *name, struct archive **pparc)
|
||||
#endif
|
||||
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
||||
cmd = copy_strings (mc_extfsdir, extfs_prefixes [fstype],
|
||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes [fstype],
|
||||
" list ", local_name ? local_name : tmp, NULL);
|
||||
if (tmp)
|
||||
g_free (tmp);
|
||||
@ -562,7 +562,7 @@ void extfs_run (char *file)
|
||||
|
||||
archive_name = name_quote (get_archive_name(archive), 0);
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
||||
cmd = copy_strings (mc_extfsdir, extfs_prefixes [archive->fstype],
|
||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes [archive->fstype],
|
||||
" run ", archive_name, " ", q, NULL);
|
||||
g_free (mc_extfsdir);
|
||||
g_free (archive_name);
|
||||
@ -613,7 +613,7 @@ static void *extfs_open (vfs *me, char *file, int flags, int mode)
|
||||
archive_name = name_quote (get_archive_name (archive), 0);
|
||||
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
||||
cmd = copy_strings (mc_extfsdir, extfs_prefixes [archive->fstype],
|
||||
cmd = g_strconcat (mc_extfsdir, extfs_prefixes [archive->fstype],
|
||||
" copyout ",
|
||||
archive_name,
|
||||
" ", q, " ", entry->inode->local_filename, NULL);
|
||||
@ -675,7 +675,7 @@ static int extfs_close (void *data)
|
||||
g_free (p);
|
||||
|
||||
mc_extfsdir = concat_dir_and_file (mc_home, "extfs/");
|
||||
cmd = copy_strings (mc_extfsdir,
|
||||
cmd = g_strconcat (mc_extfsdir,
|
||||
extfs_prefixes [archive->fstype],
|
||||
" copyin ", archive_name, " ",
|
||||
file_name, " ",
|
||||
@ -750,7 +750,7 @@ static int extfs_chdir (vfs *me, char *path)
|
||||
if ((!entry) || (!S_ISDIR (entry->inode->mode)))
|
||||
return -1;
|
||||
entry->inode->archive->current_dir = entry;
|
||||
res = copy_strings (
|
||||
res = g_strconcat (
|
||||
entry->inode->archive->name, "#", extfs_prefixes [entry->inode->archive->fstype],
|
||||
"/", q, NULL);
|
||||
my_errno = 0;
|
||||
|
@ -179,7 +179,7 @@ pipeopen(vfs_s_super *super, char *path, char *argv[])
|
||||
static char *fish_getcwd(vfs *me, vfs_s_super *super)
|
||||
{
|
||||
if (command(me, super, WANT_STRING, "#PWD\npwd; echo '### 200'\n") == COMPLETE)
|
||||
return copy_strings(reply_str, "/", NULL);
|
||||
return g_strconcat (reply_str, "/", NULL);
|
||||
ERRNOR (EIO, NULL);
|
||||
}
|
||||
static int
|
||||
@ -226,7 +226,7 @@ open_archive_int (vfs *me, vfs_s_super *super)
|
||||
#endif
|
||||
if (!SUP.password){
|
||||
char *p, *op;
|
||||
p = copy_strings (" fish: Password required for ", SUP.user,
|
||||
p = g_strconcat (" fish: Password required for ", SUP.user,
|
||||
" ", NULL);
|
||||
op = vfs_get_password (p);
|
||||
g_free (p);
|
||||
@ -253,7 +253,7 @@ open_archive_int (vfs *me, vfs_s_super *super)
|
||||
SUP.home = fish_getcwd (me, super);
|
||||
print_vfs_message( "FISH: Connected, home %s.", SUP.home );
|
||||
#if 0
|
||||
super->name = copy_strings( "/#sh:", SUP.user, "@", SUP.host, "/", NULL );
|
||||
super->name = g_strconcat ( "/#sh:", SUP.user, "@", SUP.host, "/", NULL );
|
||||
#endif
|
||||
super->name = g_strdup(PATH_SEP_STR);
|
||||
|
||||
|
16
vfs/ftpfs.c
16
vfs/ftpfs.c
@ -229,7 +229,7 @@ command (struct connection *bucket, int wait_reply, char *fmt, ...)
|
||||
fmt_str = g_strdup_vprintf (fmt, ap);
|
||||
va_end (ap);
|
||||
|
||||
str = copy_strings (fmt_str, "\r\n", NULL);
|
||||
str = g_strconcat (fmt_str, "\r\n", NULL);
|
||||
g_free (fmt_str);
|
||||
|
||||
if (logfile){
|
||||
@ -320,7 +320,7 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
char *p;
|
||||
|
||||
if (!bucket->password){
|
||||
p = copy_strings (" FTP: Password required for ", quser (bucket),
|
||||
p = g_strconcat (" FTP: Password required for ", quser (bucket),
|
||||
" ", NULL);
|
||||
op = vfs_get_password (p);
|
||||
g_free (p);
|
||||
@ -335,7 +335,7 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
if (!anon || logfile)
|
||||
pass = g_strdup (op);
|
||||
else
|
||||
pass = copy_strings ("-", op, NULL);
|
||||
pass = g_strconcat ("-", op, NULL);
|
||||
wipe_password (op);
|
||||
|
||||
|
||||
@ -352,7 +352,7 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
g_free (host);
|
||||
if (proxypass)
|
||||
wipe_password (proxypass);
|
||||
p = copy_strings (" Proxy: Password required for ", proxyname, " ",
|
||||
p = g_strconcat (" Proxy: Password required for ", proxyname, " ",
|
||||
NULL);
|
||||
proxypass = vfs_get_password (p);
|
||||
g_free (p);
|
||||
@ -363,7 +363,7 @@ login_server (struct connection *bucket, char *netrcpass)
|
||||
}
|
||||
name = g_strdup (quser (bucket));
|
||||
#else
|
||||
name = copy_strings (quser (bucket), "@",
|
||||
name = g_strconcat (quser (bucket), "@",
|
||||
qhost (bucket)[0] == '!' ? qhost (bucket)+1 : qhost (bucket), NULL);
|
||||
#endif
|
||||
} else
|
||||
@ -1243,7 +1243,7 @@ retrieve_dir(struct connection *bucket, char *remote_path, int resolve_symlinks)
|
||||
else if (has_spaces)
|
||||
sock = open_data_connection (bucket, "LIST -la", ".", TYPE_ASCII, 0);
|
||||
else {
|
||||
char *path = copy_strings (remote_path, PATH_SEP_STR, ".", NULL);
|
||||
char *path = g_strconcat (remote_path, PATH_SEP_STR, ".", NULL);
|
||||
sock = open_data_connection (bucket, "LIST -la", path, TYPE_ASCII, 0);
|
||||
g_free (path);
|
||||
}
|
||||
@ -1560,9 +1560,9 @@ ftpfs_init_passwd(void)
|
||||
gethostname(hostname, sizeof(hostname));
|
||||
hp = gethostbyname(hostname);
|
||||
if (hp != NULL)
|
||||
ftpfs_anonymous_passwd = copy_strings (p, "@", hp->h_name, NULL);
|
||||
ftpfs_anonymous_passwd = g_strconcat (p, "@", hp->h_name, NULL);
|
||||
else
|
||||
ftpfs_anonymous_passwd = copy_strings (p, "@", hostname, NULL);
|
||||
ftpfs_anonymous_passwd = g_strconcat (p, "@", hostname, NULL);
|
||||
endpwent ();
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ static void mcfs_fill_names (vfs *me, void (*func)(char *))
|
||||
for (i = 0; i < MCFS_MAX_CONNECTIONS; i++){
|
||||
if (mcfs_connections [i].host == 0)
|
||||
continue;
|
||||
name = copy_strings ("/#mc:", mcfs_connections [i].user,
|
||||
name = g_strconcat ("/#mc:", mcfs_connections [i].user,
|
||||
"@", mcfs_connections [i].host, NULL);
|
||||
(*func) (name);
|
||||
g_free (name);
|
||||
|
@ -454,7 +454,7 @@ void do_readdir (void)
|
||||
|
||||
rpc_send (msock, RPC_INT, length, RPC_END);
|
||||
rpc_send (msock, RPC_BLOCK, length, dirent->d_name, RPC_END);
|
||||
fname = copy_strings (mcfs_DIR.names [handle],
|
||||
fname = g_strconcat (mcfs_DIR.names [handle],
|
||||
PATH_SEP_STR, dirent->d_name, NULL);
|
||||
n = lstat (fname, &st);
|
||||
send_status (n, errno);
|
||||
@ -1290,7 +1290,7 @@ void vfs_die( char *m )
|
||||
exit (1);
|
||||
}
|
||||
#ifdef HAVE_MAD
|
||||
char *copy_strings (const char *first, ...)
|
||||
char * mad_strconcat (const char *first, ...)
|
||||
{
|
||||
va_list ap;
|
||||
long len;
|
||||
|
@ -187,7 +187,7 @@ static void X_fill_names (vfs *me, void (*func)(char *))
|
||||
do {
|
||||
if ((bucket = lptr->data) != 0){
|
||||
|
||||
path_name = copy_strings ( X_myname, quser (bucket),
|
||||
path_name = g_strconcat ( X_myname, quser (bucket),
|
||||
"@", qhost (bucket),
|
||||
qcdir(bucket), NULL);
|
||||
(*func)(path_name);
|
||||
@ -226,8 +226,10 @@ s_get_path (struct connection **bucket, char *path, char *name)
|
||||
remote_path = NULL;
|
||||
}
|
||||
}
|
||||
g_free (host);
|
||||
g_free (user);
|
||||
if (host)
|
||||
g_free (host);
|
||||
if (user)
|
||||
g_free (user);
|
||||
if (pass)
|
||||
wipe_password (pass);
|
||||
|
||||
|
@ -95,7 +95,7 @@ static int tar_open_archive (vfs *me, char *name, vfs_s_super *archive)
|
||||
if (size > 0) {
|
||||
char *s;
|
||||
mc_close( result );
|
||||
s = copy_strings( archive->name, decompress_extension (type), NULL );
|
||||
s = g_strconcat ( archive->name, decompress_extension (type), NULL );
|
||||
result = mc_open (s, O_RDONLY);
|
||||
if (result == -1)
|
||||
message_2s (1, MSG_ERROR, _("Couldn't open tar archive\n%s"), s);
|
||||
|
@ -133,14 +133,14 @@ undelfs_get_path (char *dirname, char **ext2_fname, char **file)
|
||||
if (*p == '/'){
|
||||
*file = g_strdup (p+1);
|
||||
*p = 0;
|
||||
*ext2_fname = copy_strings ("/dev/", dirname, NULL);
|
||||
*ext2_fname = g_strconcat ("/dev/", dirname, NULL);
|
||||
*p = '/';
|
||||
return;
|
||||
}
|
||||
p--;
|
||||
}
|
||||
*file = g_strdup ("");
|
||||
*ext2_fname = copy_strings ("/dev/", dirname, NULL);
|
||||
*ext2_fname = g_strconcat ("/dev/", dirname, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -153,18 +153,6 @@ done:
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Returns allocated string with trailing PATH_SEP */
|
||||
char*
|
||||
append_path_sep (char *path)
|
||||
{
|
||||
int i = strlen (path);
|
||||
|
||||
if (path[i - 1] == PATH_SEP)
|
||||
return g_strndup (path, i);
|
||||
else
|
||||
return copy_strings (path, PATH_SEP_STR, NULL);
|
||||
}
|
||||
|
||||
#ifdef test_get_host_and_username
|
||||
struct tt {
|
||||
char *url;
|
||||
|
@ -1,22 +1,5 @@
|
||||
#include <config.h>
|
||||
#include "../src/fs.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include "../src/global.h"
|
||||
|
||||
#include "../src/tty.h" /* enable/disable interrupt key */
|
||||
#include "../src/main.h"
|
||||
|
||||
#include "../src/mem.h"
|
||||
#include "../src/util.h"
|
||||
#include "../src/mad.h"
|
||||
|
||||
|
||||
#define BUF_4K 4096
|
||||
#define BUF_1K 1024
|
||||
|
||||
#define BUF_LARGE BUF_1K
|
||||
#define BUF_MEDIUM 512
|
||||
#define BUF_SMALL 128
|
||||
#define BUF_TINY 64
|
||||
|
||||
char* append_path_sep (char *path);
|
||||
|
12
vfs/vfs.c
12
vfs/vfs.c
@ -509,7 +509,7 @@ mc_opendir (char *dirname)
|
||||
char *p = NULL;
|
||||
|
||||
/* We should make possible reading of the root directory in a tar file */
|
||||
dirname = p = append_path_sep (dirname);
|
||||
dirname = p = concat_dir_and_file (dirname, "");
|
||||
|
||||
dirname = vfs_canon (dirname);
|
||||
vfs = vfs_type (dirname);
|
||||
@ -712,9 +712,9 @@ vfs_canon (char *path)
|
||||
char *local, *result;
|
||||
|
||||
if (current_dir [strlen (current_dir) - 1] == PATH_SEP)
|
||||
local = copy_strings (current_dir, path, NULL);
|
||||
local = g_strconcat (current_dir, path, NULL);
|
||||
else
|
||||
local = copy_strings (current_dir, PATH_SEP_STR, path, NULL);
|
||||
local = g_strconcat (current_dir, PATH_SEP_STR, path, NULL);
|
||||
|
||||
result = vfs_canon (local);
|
||||
g_free (local);
|
||||
@ -737,7 +737,7 @@ vfs_ncs_getid (vfs *nvfs, char *dir, struct vfs_stamping **par)
|
||||
{
|
||||
vfsid nvfsid;
|
||||
|
||||
dir = append_path_sep (dir);
|
||||
dir = concat_dir_and_file (dir, "");
|
||||
|
||||
nvfsid = (*nvfs->getid)(nvfs, dir, par);
|
||||
|
||||
@ -881,7 +881,7 @@ mc_chdir (char *path)
|
||||
struct vfs_stamping *parent;
|
||||
|
||||
/* We should make possible reading of the root directory in a tar archive */
|
||||
path = p = append_path_sep (path);
|
||||
path = p = concat_dir_and_file (path, "");
|
||||
|
||||
a = current_dir; /* Save a copy for case of failure */
|
||||
current_dir = vfs_canon (path);
|
||||
@ -1764,7 +1764,7 @@ char *
|
||||
vfs_translate_url (char *url)
|
||||
{
|
||||
if (strncmp (url, "ftp://", 6) == 0)
|
||||
return copy_strings ("/#ftp:", url + 6, NULL);
|
||||
return g_strconcat ("/#ftp:", url + 6, NULL);
|
||||
else
|
||||
return g_strdup (url);
|
||||
}
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user