1 /* vi: set sw=4 ts=4: */
3 * Mini readlink implementation for busybox
5 * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
7 * Licensed under GPL v2, see file LICENSE in this tarball for details.
16 #define READLINK_FLAG_f (1 << 0)
18 int readlink_main(int argc, char **argv)
21 unsigned long opt = ENABLE_FEATURE_READLINK_FOLLOW ?
22 bb_getopt_ulflags(argc, argv, "f") : 0;
24 if (argc != (ENABLE_FEATURE_READLINK_FOLLOW ? optind + 1 : 2))
27 if (opt & READLINK_FLAG_f)
28 buf = realpath(argv[optind], NULL);
30 buf = xreadlink(argv[ENABLE_FEATURE_READLINK_FOLLOW ? optind : 1]);
36 if (ENABLE_FEATURE_CLEAN_UP) free(buf);