16 |
Please see the file `COPYING' for the complete copyright notice. |
Please see the file `COPYING' for the complete copyright notice. |
17 |
|
|
18 |
c/realpath.c - 06/14/93 |
c/realpath.c - 06/14/93 |
19 |
|
c/realpath.c - 04/22/2003 - jfs |
20 |
|
applied patch from Jeff Grub changing realpath |
21 |
|
to my_realpath and adding upper bounds for buffers |
22 |
|
(libc already implements realpath, maybe it should be used if |
23 |
|
available) |
24 |
|
|
25 |
*/ |
*/ |
26 |
|
|
57 |
#ifdef __STDC__ |
#ifdef __STDC__ |
58 |
extern char *getwd(char * const); |
extern char *getwd(char * const); |
59 |
extern int readlink(char * const, char * const, const size_t); |
extern int readlink(char * const, char * const, const size_t); |
60 |
extern char *realpath(const char *, char [], int); |
extern char *my_realpath(const char *, char [], int); |
61 |
extern char *_realpath(char [], int); |
extern char *_realpath(char [], int); |
62 |
#else |
#else |
63 |
extern char *getwd(); |
extern char *getwd(); |
64 |
extern int readlink(); |
extern int readlink(); |
65 |
extern char *realpath(); |
extern char *my_realpath(); |
66 |
extern char *_realpath(); |
extern char *_realpath(); |
67 |
#endif |
#endif |
68 |
|
|
76 |
|
|
77 |
#ifdef __STDC__ |
#ifdef __STDC__ |
78 |
char * |
char * |
79 |
realpath(const char *path1, char path2[], int decomp) |
my_realpath(const char *path1, char path2[], int decomp) |
80 |
#else |
#else |
81 |
char *realpath(path1, path2, decomp) |
char *my_realpath(path1, path2, decomp) |
82 |
char *path1, *path2; |
char *path1, *path2; |
83 |
int decomp; |
int decomp; |
84 |
#endif |
#endif |
238 |
int argc; |
int argc; |
239 |
char **argv; |
char **argv; |
240 |
{ |
{ |
241 |
char path[1025]; |
char path[MAXPATHLEN+1]; |
242 |
char rpath[1025]; |
char rpath[MAXPATHLEN+1]; |
243 |
int decomp = 0; |
int decomp = 0; |
244 |
|
|
245 |
char **argp = argv; |
char **argp = argv; |
253 |
} |
} |
254 |
|
|
255 |
if(argc == 1){ |
if(argc == 1){ |
256 |
while(fgets(path, 1024, stdin)){ |
while(fgets(path, MAXPATHLEN, stdin)){ |
257 |
char *cp = strchr(path, '\n'); |
char *cp = strchr(path, '\n'); |
258 |
*cp = '\0'; |
*cp = '\0'; |
259 |
realpath(path, rpath, decomp); |
my_realpath(path, rpath, decomp); |
260 |
if(rpath[0]) |
if(rpath[0]) |
261 |
fprintf(stdout, "%s %s\n", path, rpath); |
fprintf(stdout, "%s %s\n", path, rpath); |
262 |
} |
} |
264 |
else { |
else { |
265 |
int i; |
int i; |
266 |
for(i=1;i<argc;i++){ |
for(i=1;i<argc;i++){ |
267 |
realpath(argp[i], rpath, decomp); |
my_realpath(argp[i], rpath, decomp); |
268 |
if(rpath[0]) |
if(rpath[0]) |
269 |
fprintf(stdout, "%s\n", rpath); |
fprintf(stdout, "%s\n", rpath); |
270 |
} |
} |
271 |
} |
} |
272 |
exit(0); |
exit(0); |
273 |
} |
} |
|
|
|