Last change
on this file since 2437 was 1765, checked in by Bruno Cornec, 17 years ago |
Update to busybox 1.7.2
|
-
Property svn:eol-style
set to
native
|
File size:
1.0 KB
|
Line | |
---|
1 | /* vi: set sw=4 ts=4: */
|
---|
2 | /*
|
---|
3 | * Mini readlink implementation for busybox
|
---|
4 | *
|
---|
5 | * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
---|
6 | *
|
---|
7 | * Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
|
---|
8 | */
|
---|
9 |
|
---|
10 | #include <getopt.h>
|
---|
11 |
|
---|
12 | #include "libbb.h"
|
---|
13 |
|
---|
14 | int readlink_main(int argc, char **argv);
|
---|
15 | int readlink_main(int argc, char **argv)
|
---|
16 | {
|
---|
17 | char *buf;
|
---|
18 | char *fname;
|
---|
19 |
|
---|
20 | USE_FEATURE_READLINK_FOLLOW(
|
---|
21 | unsigned opt;
|
---|
22 | /* We need exactly one non-option argument. */
|
---|
23 | opt_complementary = "=1";
|
---|
24 | opt = getopt32(argv, "f");
|
---|
25 | fname = argv[optind];
|
---|
26 | )
|
---|
27 | SKIP_FEATURE_READLINK_FOLLOW(
|
---|
28 | const unsigned opt = 0;
|
---|
29 | if (argc != 2) bb_show_usage();
|
---|
30 | fname = argv[1];
|
---|
31 | )
|
---|
32 |
|
---|
33 | /* compat: coreutils readlink reports errors silently via exit code */
|
---|
34 | logmode = LOGMODE_NONE;
|
---|
35 |
|
---|
36 | if (opt) {
|
---|
37 | buf = realpath(fname, bb_common_bufsiz1);
|
---|
38 | } else {
|
---|
39 | buf = xmalloc_readlink_or_warn(fname);
|
---|
40 | }
|
---|
41 |
|
---|
42 | if (!buf)
|
---|
43 | return EXIT_FAILURE;
|
---|
44 | puts(buf);
|
---|
45 |
|
---|
46 | if (ENABLE_FEATURE_CLEAN_UP && !opt)
|
---|
47 | free(buf);
|
---|
48 |
|
---|
49 | fflush_stdout_and_exit(EXIT_SUCCESS);
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.