comparison lib-src/gnuclient.c @ 371:cc15677e0335 r21-2b1

Import from CVS: tag r21-2b1
author cvs
date Mon, 13 Aug 2007 11:03:08 +0200
parents 1d62742628b6
children 6240c7796c7a
comparison
equal deleted inserted replaced
370:bd866891f083 371:cc15677e0335
35 * 35 *
36 * (If gnuserv came bundled with your emacs, the README file is probably 36 * (If gnuserv came bundled with your emacs, the README file is probably
37 * ../etc/gnuserv.README relative to the directory containing this file) 37 * ../etc/gnuserv.README relative to the directory containing this file)
38 */ 38 */
39 39
40 #if 0
41 /* Hand-munged RCS header */
42 static char rcsid [] = "!Header: gnuclient.c,v 2.2 95/12/12 01:39:21 wing nene !";
43 #endif
44
40 #include "gnuserv.h" 45 #include "gnuserv.h"
41
42 char gnuserv_version[] = "gnuclient version " GNUSERV_VERSION;
43
44 #include "getopt.h" 46 #include "getopt.h"
45 47
46 #include <stdio.h> 48 #include <stdio.h>
47 #include <stdlib.h> 49 #include <stdlib.h>
48 #include <sys/types.h> 50 #include <sys/types.h>
175 { 177 {
176 int len; 178 int len;
177 179
178 fullpath[0] = '\0'; 180 fullpath[0] = '\0';
179 181
180 if (filename[0] && filename[0] == '/') 182 if (filename[0] && filename[0] != '/')
181 { 183 { /* relative filename */
182 /* Absolute (unix-style) pathname. Do nothing */
183 strcat (fullpath, filename);
184 }
185 #ifdef __CYGWIN32__
186 else if (filename[0] && filename[0] == '\\' &&
187 filename[1] && filename[1] == '\\')
188 {
189 /* This path includes the server name (something like
190 "\\server\path"), so we assume it's absolute. Do nothing to
191 it. */
192 strcat (fullpath, filename);
193 }
194 else if (filename[0] &&
195 filename[1] && filename[1] == ':' &&
196 filename[2] && filename[2] == '\\')
197 {
198 /* Absolute pathname with drive letter. Convert "<drive>:"
199 to "//<drive>/". */
200 strcat (fullpath, "//");
201 strncat (fullpath, filename, 1);
202 strcat (fullpath, &filename[2]);
203 }
204 #endif
205 else
206 {
207 /* Assume relative Unix style path. Get the current directory
208 and prepend it. FIXME: need to fix the case of DOS paths like
209 "\foo", where we need to get the current drive. */
210
211 strcat (fullpath, get_current_working_directory ()); 184 strcat (fullpath, get_current_working_directory ());
212 len = strlen (fullpath); 185 len = strlen (fullpath);
213 186
214 if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */ 187 if (len > 0 && fullpath[len-1] == '/') /* trailing slash already? */
215 ; /* yep */ 188 ; /* yep */
216 else 189 else
217 strcat (fullpath, "/"); /* nope, append trailing slash */ 190 strcat (fullpath, "/"); /* nope, append trailing slash */
218 /* Don't forget to add the filename! */ 191 } /* if */
219 strcat (fullpath,filename); 192
220 } 193 strcat (fullpath,filename);
194
221 } /* filename_expand */ 195 } /* filename_expand */
222 196
223 /* Encase the string in quotes, escape all the backslashes and quotes 197 /* Encase the string in quotes, escape all the backslashes and quotes
224 in string. */ 198 in string. */
225 static char * 199 static char *