123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- /*
- * Author: 1998 Pavel Machek <pavel@ucw.cz>
- *
- * This is for making midnight commander's vfs stuff compile stand-alone
- *
- * Namespace pollution: horrible
- */
- #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 */
- #ifndef SCO_FLAVOR
- # include <sys/time.h> /* alex: sys/select.h defines struct timeval */
- #endif /* SCO_FLAVOR */
- #include <sys/param.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <stdarg.h>
- #include <errno.h> /* my_system */
- #ifdef SCO_FLAVOR
- # include <sys/timeb.h> /* alex: for struct timeb, used in time.h */
- #endif /* SCO_FLAVOR */
- #include <time.h>
- #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
- #include "../src/util.h"
- #include "vfs.h"
- #include "callback.h"
- #ifndef VFS_STANDALONE
- #error This has only sense when compiling standalone version
- #endif
- int source_route = 0;
- int cd_symlinks = 0;
- /*
- * Required functions to make mc's vfs layer compile stand-alone
- */
- void *do_xmalloc (int size)
- {
- void *m = malloc (size);
- if (!m)
- vfs_die ("Memory exhausted\n");
- return m;
- }
- /*
- * 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;
- }
- static char (*callbacks[NUM_CALLBACKS])(char *msg) = { NULL, NULL, NULL, };
- 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, ...)
- {
- char *str;
- va_list args;
- va_start (args,msg);
- str = g_strdup_vprintf (msg, args);
- va_end (args);
- info_puts (str);
- g_free (str);
- }
- void
- wipe_password (char *passwd)
- {
- char *p = passwd;
-
- for (;*p; p++)
- *p = 0;
- free (passwd);
- }
- int
- exist_file (char *name)
- {
- return access (name, R_OK) == 0;
- }
- void
- message_1s (int i, char *c1, char *c2)
- {
- char buf [4096];
- snprintf (buf, sizeof (buf), "%s %s", c1, c2);
- box_puts (buf);
- }
- void
- message_2s (int i, char *c1, char *c2, char *c3)
- {
- char buf [4096];
-
- snprintf (buf, sizeof (buf), "%s %s %s", c1, c2, c3 );
- box_puts (buf );
- }
- void
- message_3s( int i, char *c1, char *c2, char *c3, const char *c4 )
- {
- char buf [4096];
-
- snprintf (buf, sizeof (buf), "%s %s %s %s", c1, c2, c3, c4);
- box_puts (buf);
- }
- 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();
- }
|