3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2, or (at your option)
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 showHelp(char const *cmd)
34 WRITE_MSG(1, "Usage: ");
39 "Display value of a symbolic link on standard output.\n"
41 "Please report bugs to " PACKAGE_BUGREPORT "\n");
49 "readlink " VERSION " -- display value of symlink\n"
50 "This program is part of " PACKAGE_STRING "\n\n"
51 "Copyright (C) 2004 Enrico Scholz\n"
52 VERSION_COPYRIGHT_DISCLAIMER);
57 int main (int argc, char *argv[])
59 char buf[PATH_MAX + 2];
64 if (strcmp(argv[1], "--help") ==0) showHelp(argv[0]);
65 if (strcmp(argv[1], "--version")==0) showVersion();
66 if (strcmp(argv[1], "--") ==0) ++idx;
69 WRITE_MSG(2, "No filename specified; use '--help' for more information\n");
70 else if ((len=readlink(argv[idx], buf, sizeof(buf)-2))==-1)
71 PERROR_Q("readlink: readlink", argv[idx]);