202b84f05cdeeae9d531f46895d9b6c0b49d6d3f
[debian/tar] / gnu / careadlinkat.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Read symbolic links into a buffer without size limitation, relative to fd.
4
5    Copyright (C) 2011-2013 Free Software Foundation, Inc.
6
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 3 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
15    GNU 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, see <http://www.gnu.org/licenses/>.  */
19
20 /* Written by Paul Eggert, Bruno Haible, and Jim Meyering.  */
21
22 #ifndef _GL_CAREADLINKAT_H
23 #define _GL_CAREADLINKAT_H
24
25 #include <fcntl.h>
26 #include <unistd.h>
27
28 struct allocator;
29
30 /* Assuming the current directory is FD, get the symbolic link value
31    of FILENAME as a null-terminated string and put it into a buffer.
32    If FD is AT_FDCWD, FILENAME is interpreted relative to the current
33    working directory, as in openat.
34
35    If the link is small enough to fit into BUFFER put it there.
36    BUFFER's size is BUFFER_SIZE, and BUFFER can be null
37    if BUFFER_SIZE is zero.
38
39    If the link is not small, put it into a dynamically allocated
40    buffer managed by ALLOC.  It is the caller's responsibility to free
41    the returned value if it is nonnull and is not BUFFER.
42
43    The PREADLINKAT function specifies how to read links.  It operates
44    like POSIX readlinkat()
45    <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>
46    but can assume that its first argument is the same as FD.
47
48    If successful, return the buffer address; otherwise return NULL and
49    set errno.  */
50
51 char *careadlinkat (int fd, char const *filename,
52                     char *buffer, size_t buffer_size,
53                     struct allocator const *alloc,
54                     ssize_t (*preadlinkat) (int, char const *,
55                                             char *, size_t));
56
57 /* Suitable value for careadlinkat's FD argument.  */
58 #if HAVE_READLINKAT
59 /* AT_FDCWD is declared in <fcntl.h>.  */
60 #else
61 /* Define AT_FDCWD independently, so that the careadlinkat module does
62    not depend on the fcntl-h module.  We might as well use the same value
63    as fcntl-h.  */
64 # ifndef AT_FDCWD
65 #  define AT_FDCWD (-3041965)
66 # endif
67 #endif
68
69 #endif /* _GL_CAREADLINKAT_H */