Line | |
---|
1 | /* vi: set sw=4 ts=4: */
|
---|
2 |
|
---|
3 | /* BB_AUDIT SUSv3 N/A -- Apparently a busybox extension. */
|
---|
4 |
|
---|
5 | /* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
---|
6 | *
|
---|
7 | * Now does proper error checking on output and returns a failure exit code
|
---|
8 | * if one or more paths cannot be resolved.
|
---|
9 | *
|
---|
10 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
---|
11 | */
|
---|
12 |
|
---|
13 | #include "libbb.h"
|
---|
14 |
|
---|
15 | int realpath_main(int argc, char **argv);
|
---|
16 | int realpath_main(int argc, char **argv)
|
---|
17 | {
|
---|
18 | int retval = EXIT_SUCCESS;
|
---|
19 |
|
---|
20 | #if PATH_MAX > (BUFSIZ+1)
|
---|
21 | RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
|
---|
22 | # define resolved_path_MUST_FREE 1
|
---|
23 | #else
|
---|
24 | #define resolved_path bb_common_bufsiz1
|
---|
25 | # define resolved_path_MUST_FREE 0
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | if (--argc == 0) {
|
---|
29 | bb_show_usage();
|
---|
30 | }
|
---|
31 |
|
---|
32 | do {
|
---|
33 | argv++;
|
---|
34 | if (realpath(*argv, resolved_path) != NULL) {
|
---|
35 | puts(resolved_path);
|
---|
36 | } else {
|
---|
37 | retval = EXIT_FAILURE;
|
---|
38 | bb_perror_msg("%s", *argv);
|
---|
39 | }
|
---|
40 | } while (--argc);
|
---|
41 |
|
---|
42 | #if ENABLE_FEATURE_CLEAN_UP && resolved_path_MUST_FREE
|
---|
43 | RELEASE_CONFIG_BUFFER(resolved_path);
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | fflush_stdout_and_exit(retval);
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.