Traslated some chmod mgs related (for win32 support? not shure)
[midnight-commander.git] / vfs / util-alone.c
blob622a290eb553a8a9dc7b41378747d41812657dad
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 #include <stdlib.h>
12 #include <sys/types.h>
13 #ifdef HAVE_UNISTD_H
14 #include <unistd.h>
15 #endif
16 #include <fcntl.h>
17 #include <signal.h> /* my_system */
18 #include <limits.h> /* INT_MAX */
19 #include <sys/param.h>
20 #include <sys/types.h>
21 #include <sys/stat.h>
22 #include <stdarg.h>
23 #include <errno.h> /* my_system */
24 #ifndef OS2_NT
25 # include <pwd.h>
26 # include <grp.h>
27 #endif
28 #include <string.h>
29 #include <ctype.h>
30 #ifdef HAVE_SYS_SELECT_H
31 # include <sys/select.h>
32 #endif
34 #ifdef __linux__
35 # if defined(__GLIBC__) && (__GLIBC__ < 2)
36 # include <linux/termios.h> /* This is needed for TIOCLINUX */
37 # else
38 # include <termios.h>
39 # endif
40 # include <sys/ioctl.h>
41 #endif
43 #include <glib.h>
44 #include "../src/util.h"
45 #include "vfs.h"
46 #include "callback.h"
48 #ifndef VFS_STANDALONE
49 #error "This file should only be used in standalone VFS"
50 #endif
52 int source_route = 0;
53 int cd_symlinks = 0;
55 /* User's shell */
56 char *shell = "/bin/sh";
59 * We do not want/need many of midnight's functions, stub routines.
62 void
63 enable_interrupt_key (void)
67 void
68 disable_interrupt_key (void)
72 int got_interrupt (void)
74 return 0;
77 void
78 rotate_dash (void)
82 char *
83 load_anon_passwd (void)
85 return NULL;
88 static char (*callbacks[NUM_CALLBACKS])(char *msg) = { NULL, NULL, NULL, };
90 void
91 vfs_set_callback (int num, void *func)
93 if (num >= NUM_CALLBACKS)
94 vfs_die ("Attempt to set invalid callback.\n");
95 callbacks [num] = func;
98 static void
99 info_puts( char *s )
101 if (!callbacks [CALL_INFO])
102 fprintf (stderr, "%s\n", s);
103 else
104 callbacks [CALL_INFO](s);
107 static void
108 box_puts( char *s )
110 if (!callbacks [CALL_BOX])
111 fprintf (stderr, "%s\n", s);
112 else
113 callbacks [CALL_BOX](s);
116 char *
117 vfs_get_password (char *msg)
119 if (!callbacks [CALL_PASSWD])
120 return NULL;
121 else
122 callbacks [CALL_PASSWD](msg);
125 void
126 print_vfs_message (char *msg, ...)
128 char *str;
129 va_list args;
131 va_start (args,msg);
132 str = g_strdup_vprintf (msg, args);
133 va_end (args);
135 info_puts (str);
136 g_free (str);
139 void
140 wipe_password (char *passwd)
142 char *p = passwd;
144 if (p == NULL)
145 return;
147 for (;*p; p++)
148 *p = 0;
149 g_free (passwd);
153 exist_file (char *name)
155 return access (name, R_OK) == 0;
158 void
159 message_1s (int i, char *header, const char *c2)
161 char buf [4096];
163 snprintf (buf, sizeof (buf), "%s %s", header, c2);
164 box_puts (buf);
167 void
168 message_2s (int i, char *header, const char *c2, const char *c3)
170 char buf [4096];
172 snprintf (buf, sizeof (buf), "%s %s %s", header, c2, c3 );
173 box_puts (buf );
176 void
177 message_3s( int i, char *header, const char *c2, const char *c3, const char *c4)
179 char buf [4096];
181 snprintf (buf, sizeof (buf), "%s %s %s %s", header, c2, c3, c4);
182 box_puts (buf);
185 void message_1s1d (int flags, char *title, char *str, int d)
187 char buf [4096];
189 snprintf (buf, sizeof (buf), "%s %d", str, d);
190 box_puts (buf);
194 void vfs_init( void );
195 void ftpfs_init_passwd( void );
197 char *mc_home = LIBDIR;
199 void
200 mc_vfs_init( void )
202 vfs_init();
203 ftpfs_init_passwd();
206 void
207 mc_vfs_done( void )
209 vfs_shut();