*** empty log message ***
[midnight-commander.git] / vfs / util-alone.c
blob6b0fe5c512c57c90295c300ce2aa11f1aaa50e60
1 /*
2 * Author: 1998 Pavel Machek <pavel@ucw.cz>
4 * This is for making midnight commander's vfs stuff compile stand-alone
6 * Namespace pollution: horrible
7 */
9 #include <config.h>
10 #include <stdio.h>
11 #if defined(__os2__) /* OS/2 need io.h! .ado */
12 # include <io.h>
13 #endif
14 #include <stdlib.h>
15 #include <sys/types.h>
16 #ifdef HAVE_UNISTD_H
17 #include <unistd.h>
18 #endif
19 #include <fcntl.h>
20 #include <signal.h> /* my_system */
21 #include <limits.h> /* INT_MAX */
22 #include <sys/param.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 #include <stdarg.h>
26 #include <errno.h> /* my_system */
27 #ifndef OS2_NT
28 # include <pwd.h>
29 # include <grp.h>
30 #endif
31 #include <string.h>
32 #include <ctype.h>
33 #ifdef HAVE_SYS_SELECT_H
34 # include <sys/select.h>
35 #endif
37 #ifdef __linux__
38 # if defined(__GLIBC__) && (__GLIBC__ < 2)
39 # include <linux/termios.h> /* This is needed for TIOCLINUX */
40 # else
41 # include <termios.h>
42 # endif
43 # include <sys/ioctl.h>
44 #endif
46 #include <glib.h>
47 #include "../src/util.h"
48 #include "vfs.h"
49 #include "callback.h"
51 #ifndef VFS_STANDALONE
52 #error "This file should only be used in standalone VFS"
53 #endif
55 int source_route = 0;
56 int cd_symlinks = 0;
58 /* User's shell */
59 char *shell = "/bin/sh";
62 * We do not want/need many of midnight's functions, stub routines.
65 void
66 enable_interrupt_key (void)
70 void
71 disable_interrupt_key (void)
75 int got_interrupt (void)
77 return 0;
80 void
81 rotate_dash (void)
85 char *
86 load_anon_passwd (void)
88 return NULL;
91 static char (*callbacks[NUM_CALLBACKS])(char *msg) = { NULL, NULL, NULL, };
93 void
94 vfs_set_callback (int num, void *func)
96 if (num >= NUM_CALLBACKS)
97 vfs_die ("Attempt to set invalid callback.\n");
98 callbacks [num] = func;
101 static void
102 info_puts( char *s )
104 if (!callbacks [CALL_INFO])
105 fprintf (stderr, "%s\n", s);
106 else
107 callbacks [CALL_INFO](s);
110 static void
111 box_puts( char *s )
113 if (!callbacks [CALL_BOX])
114 fprintf (stderr, "%s\n", s);
115 else
116 callbacks [CALL_BOX](s);
119 char *
120 vfs_get_password (char *msg)
122 if (!callbacks [CALL_PASSWD])
123 return NULL;
124 else
125 callbacks [CALL_PASSWD](msg);
128 void
129 print_vfs_message (char *msg, ...)
131 char *str;
132 va_list args;
134 va_start (args,msg);
135 str = g_strdup_vprintf (msg, args);
136 va_end (args);
138 info_puts (str);
139 g_free (str);
142 void
143 wipe_password (char *passwd)
145 char *p = passwd;
147 if (p == NULL)
148 return;
150 for (;*p; p++)
151 *p = 0;
152 g_free (passwd);
156 exist_file (char *name)
158 return access (name, R_OK) == 0;
161 void
162 message_1s (int i, char *header, const char *c2)
164 char buf [4096];
166 snprintf (buf, sizeof (buf), "%s %s", header, c2);
167 box_puts (buf);
170 void
171 message_2s (int i, char *header, const char *c2, const char *c3)
173 char buf [4096];
175 snprintf (buf, sizeof (buf), "%s %s %s", header, c2, c3 );
176 box_puts (buf );
179 void
180 message_3s( int i, char *header, const char *c2, const char *c3, const char *c4)
182 char buf [4096];
184 snprintf (buf, sizeof (buf), "%s %s %s %s", header, c2, c3, c4);
185 box_puts (buf);
188 void message_1s1d (int flags, char *title, char *str, int d)
190 char buf [4096];
192 snprintf (buf, sizeof (buf), "%s %d", str, d);
193 box_puts (buf);
197 void vfs_init( void );
198 void ftpfs_init_passwd( void );
200 char *mc_home = LIBDIR;
202 void
203 mc_vfs_init( void )
205 vfs_init();
206 ftpfs_init_passwd();
209 void
210 mc_vfs_done( void )
212 vfs_shut();