/* * Author: 1998 Pavel Machek * * This is for making midnight commander's vfs stuff compile stand-alone * * Namespace pollution: horrible */ #include #include #if defined(__os2__) /* OS/2 need io.h! .ado */ # include #endif #include #include #ifdef HAVE_UNISTD_H #include #endif #include #include /* my_system */ #include /* INT_MAX */ #include #include #include #include #include /* my_system */ #ifndef OS2_NT # include # include #endif #include #include #ifdef HAVE_SYS_SELECT_H # include #endif #ifdef __linux__ # if defined(__GLIBC__) && (__GLIBC__ < 2) # include /* This is needed for TIOCLINUX */ # else # include # endif # include #endif #include #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; /* User's shell */ char *shell = "/bin/sh"; /* * 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; if (p == NULL) return; for (;*p; p++) *p = 0; g_free (passwd); } int exist_file (char *name) { return access (name, R_OK) == 0; } void message_1s (int i, char *header, const char *c2) { char buf [4096]; snprintf (buf, sizeof (buf), "%s %s", header, c2); box_puts (buf); } void message_2s (int i, char *header, const char *c2, const char *c3) { char buf [4096]; snprintf (buf, sizeof (buf), "%s %s %s", header, c2, c3 ); box_puts (buf ); } void message_3s( int i, char *header, const char *c2, const char *c3, const char *c4) { char buf [4096]; snprintf (buf, sizeof (buf), "%s %s %s %s", header, c2, c3, c4); box_puts (buf); } 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); } 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(); }