1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* areadlink.c -- readlink wrapper to return the link name in malloc'd storage
4 Unlike xreadlink and xreadlink_with_size, don't ever call exit.
6 Copyright (C) 2001, 2003-2007, 2009-2013 Free Software Foundation, Inc.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* Written by Jim Meyering <jim@meyering.net>
22 and Bruno Haible <bruno@clisp.org>. */
27 #include "areadlink.h"
29 #include "careadlinkat.h"
34 /* Get the symbolic link value of FILENAME and put it into BUFFER, with
35 size BUFFER_SIZE. This function acts like readlink but has
36 readlinkat's signature. */
38 careadlinkatcwd (int fd, char const *filename, char *buffer,
41 /* FD must be AT_FDCWD here, otherwise the caller is using this
42 function in contexts it was not meant for. */
45 return readlink (filename, buffer, buffer_size);
48 /* Call readlink to get the symbolic link value of FILENAME.
49 Return a pointer to that NUL-terminated string in malloc'd storage.
50 If readlink fails, return NULL and set errno.
51 If allocation fails, or if the link value is longer than SIZE_MAX :-),
52 return NULL and set errno to ENOMEM. */
55 areadlink (char const *filename)
57 return careadlinkat (AT_FDCWD, filename, NULL, 0, NULL, careadlinkatcwd);