1998-05-26 09:08:10 +04:00
|
|
|
/*
|
1998-10-13 02:07:53 +04:00
|
|
|
* Author: 1998 Pavel Machek <pavel@ucw.cz>
|
|
|
|
*
|
1998-05-26 09:08:10 +04:00
|
|
|
* This is for making midnight commander's vfs stuff compile stand-alone
|
1998-10-13 02:07:53 +04:00
|
|
|
*
|
|
|
|
* Namespace pollution: horrible
|
1998-05-26 09:08:10 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#if defined(__os2__) /* OS/2 need io.h! .ado */
|
|
|
|
# include <io.h>
|
|
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <signal.h> /* my_system */
|
|
|
|
#include <limits.h> /* INT_MAX */
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <errno.h> /* my_system */
|
|
|
|
#ifndef OS2_NT
|
|
|
|
# include <pwd.h>
|
|
|
|
# include <grp.h>
|
|
|
|
#endif
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
# include <sys/select.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
# if defined(__GLIBC__) && (__GLIBC__ < 2)
|
|
|
|
# include <linux/termios.h> /* This is needed for TIOCLINUX */
|
|
|
|
# else
|
|
|
|
# include <termios.h>
|
|
|
|
# endif
|
|
|
|
# include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
|
2001-05-28 18:19:34 +04:00
|
|
|
#include <glib.h>
|
1998-05-26 09:08:10 +04:00
|
|
|
#include "../src/util.h"
|
|
|
|
#include "vfs.h"
|
|
|
|
#include "callback.h"
|
|
|
|
|
1998-09-03 23:43:38 +04:00
|
|
|
#ifndef VFS_STANDALONE
|
|
|
|
#error This has only sense when compiling standalone version
|
|
|
|
#endif
|
|
|
|
|
1998-05-26 09:08:10 +04:00
|
|
|
int source_route = 0;
|
|
|
|
int cd_symlinks = 0;
|
|
|
|
|
2001-05-28 18:19:34 +04:00
|
|
|
/* User's shell */
|
|
|
|
char *shell = "/bin/sh";
|
|
|
|
|
1998-05-26 09:08:10 +04:00
|
|
|
/*
|
|
|
|
* We do not want/need many of midnight's functions, stub routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
enable_interrupt_key (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
disable_interrupt_key (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int got_interrupt (void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
rotate_dash (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
load_anon_passwd (void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1998-09-03 23:43:38 +04:00
|
|
|
static char (*callbacks[NUM_CALLBACKS])(char *msg) = { NULL, NULL, NULL, };
|
1998-05-26 09:08:10 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
vfs_set_callback (int num, void *func)
|
|
|
|
{
|
|
|
|
if (num >= NUM_CALLBACKS)
|
|
|
|
vfs_die ("Attempt to set invalid callback.\n");
|
|
|
|
callbacks [num] = func;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
info_puts( char *s )
|
|
|
|
{
|
|
|
|
if (!callbacks [CALL_INFO])
|
|
|
|
fprintf (stderr, "%s\n", s);
|
|
|
|
else
|
|
|
|
callbacks [CALL_INFO](s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
box_puts( char *s )
|
|
|
|
{
|
|
|
|
if (!callbacks [CALL_BOX])
|
|
|
|
fprintf (stderr, "%s\n", s);
|
|
|
|
else
|
|
|
|
callbacks [CALL_BOX](s);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
vfs_get_password (char *msg)
|
|
|
|
{
|
|
|
|
if (!callbacks [CALL_PASSWD])
|
|
|
|
return NULL;
|
|
|
|
else
|
|
|
|
callbacks [CALL_PASSWD](msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
print_vfs_message (char *msg, ...)
|
|
|
|
{
|
1998-10-30 20:45:43 +03:00
|
|
|
char *str;
|
1998-05-26 09:08:10 +04:00
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start (args,msg);
|
1998-10-30 20:45:43 +03:00
|
|
|
str = g_strdup_vprintf (msg, args);
|
1998-05-26 09:08:10 +04:00
|
|
|
va_end (args);
|
1998-10-30 20:45:43 +03:00
|
|
|
|
|
|
|
info_puts (str);
|
|
|
|
g_free (str);
|
1998-05-26 09:08:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wipe_password (char *passwd)
|
|
|
|
{
|
|
|
|
char *p = passwd;
|
1999-01-29 06:23:03 +03:00
|
|
|
|
|
|
|
if (p == NULL)
|
|
|
|
return;
|
1998-05-26 09:08:10 +04:00
|
|
|
|
|
|
|
for (;*p; p++)
|
|
|
|
*p = 0;
|
1999-01-21 01:01:11 +03:00
|
|
|
g_free (passwd);
|
1998-05-26 09:08:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
exist_file (char *name)
|
|
|
|
{
|
|
|
|
return access (name, R_OK) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-05-28 18:19:34 +04:00
|
|
|
message_1s (int i, char *header, const char *c2)
|
1998-05-26 09:08:10 +04:00
|
|
|
{
|
|
|
|
char buf [4096];
|
1998-09-03 23:43:38 +04:00
|
|
|
|
2001-05-28 18:19:34 +04:00
|
|
|
snprintf (buf, sizeof (buf), "%s %s", header, c2);
|
1998-05-26 09:08:10 +04:00
|
|
|
box_puts (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-05-28 18:19:34 +04:00
|
|
|
message_2s (int i, char *header, const char *c2, const char *c3)
|
1998-05-26 09:08:10 +04:00
|
|
|
{
|
|
|
|
char buf [4096];
|
|
|
|
|
2001-05-28 18:19:34 +04:00
|
|
|
snprintf (buf, sizeof (buf), "%s %s %s", header, c2, c3 );
|
1998-05-26 09:08:10 +04:00
|
|
|
box_puts (buf );
|
|
|
|
}
|
|
|
|
|
1998-10-13 02:07:53 +04:00
|
|
|
void
|
2001-05-28 18:19:34 +04:00
|
|
|
message_3s( int i, char *header, const char *c2, const char *c3, const char *c4)
|
1998-05-26 09:08:10 +04:00
|
|
|
{
|
|
|
|
char buf [4096];
|
|
|
|
|
2001-05-28 18:19:34 +04:00
|
|
|
snprintf (buf, sizeof (buf), "%s %s %s %s", header, c2, c3, c4);
|
1998-05-26 09:08:10 +04:00
|
|
|
box_puts (buf);
|
|
|
|
}
|
1998-09-03 23:43:38 +04:00
|
|
|
|
2000-08-04 16:03:43 +04:00
|
|
|
void message_1s1d (int flags, char *title, char *str, int d)
|
|
|
|
{
|
|
|
|
char buf [4096];
|
|
|
|
|
|
|
|
snprintf (buf, sizeof (buf), "%s %d", str, d);
|
|
|
|
box_puts (buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-03 23:43:38 +04:00
|
|
|
void vfs_init( void );
|
|
|
|
void ftpfs_init_passwd( void );
|
|
|
|
|
|
|
|
char *mc_home = LIBDIR;
|
|
|
|
|
|
|
|
void
|
|
|
|
mc_vfs_init( void )
|
|
|
|
{
|
|
|
|
vfs_init();
|
|
|
|
ftpfs_init_passwd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
mc_vfs_done( void )
|
|
|
|
{
|
|
|
|
vfs_shut();
|
|
|
|
}
|