blob: da52590388b6e45fc8a5c332f3d8589d653c868a [file] [log] [blame]
Mark Whitley872138d2000-10-09 18:56:47 +00001/* vi: set sw=4 ts=4: */
2/*
3 * Mini readlink implementation for busybox
4 *
Eric Andersenbdfd0d72001-10-24 05:00:29 +00005 * Copyright (C) 2000,2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
Mark Whitley872138d2000-10-09 18:56:47 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
Mark Whitley872138d2000-10-09 18:56:47 +000023#include <errno.h>
24#include <unistd.h>
Eric Andersened3ef502001-01-27 08:24:39 +000025#include <stdlib.h>
Eric Andersencbe31da2001-02-20 06:14:08 +000026#include "busybox.h"
Mark Whitley872138d2000-10-09 18:56:47 +000027
28int readlink_main(int argc, char **argv)
29{
30 char *buf = NULL;
Mark Whitley8a633262001-04-30 18:17:00 +000031
32 /* no options, no getopt */
Mark Whitley872138d2000-10-09 18:56:47 +000033
34 if (argc != 2)
Eric Andersen67991cf2001-02-14 21:23:06 +000035 show_usage();
Mark Whitley872138d2000-10-09 18:56:47 +000036
Mark Whitley8a633262001-04-30 18:17:00 +000037 buf = xreadlink(argv[1]);
Eric Andersen28355a32001-05-07 17:48:28 +000038 if (!buf)
39 return EXIT_FAILURE;
Mark Whitley872138d2000-10-09 18:56:47 +000040 puts(buf);
Eric Andersenbdfd0d72001-10-24 05:00:29 +000041#ifdef CONFIG_FEATURE_CLEAN_UP
Mark Whitley8a633262001-04-30 18:17:00 +000042 free(buf);
43#endif
Mark Whitley872138d2000-10-09 18:56:47 +000044
45 return EXIT_SUCCESS;
46}