Blame lib/careadlinkat.h

Packit Service fdd496
/* Read symbolic links into a buffer without size limitation, relative to fd.
Packit Service fdd496
Packit Service fdd496
   Copyright (C) 2011-2017 Free Software Foundation, Inc.
Packit Service fdd496
Packit Service fdd496
   This program is free software: you can redistribute it and/or modify
Packit Service fdd496
   it under the terms of the GNU General Public License as published by
Packit Service fdd496
   the Free Software Foundation; either version 3 of the License, or
Packit Service fdd496
   (at your option) any later version.
Packit Service fdd496
Packit Service fdd496
   This program is distributed in the hope that it will be useful,
Packit Service fdd496
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service fdd496
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service fdd496
   GNU General Public License for more details.
Packit Service fdd496
Packit Service fdd496
   You should have received a copy of the GNU General Public License
Packit Service fdd496
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit Service fdd496
Packit Service fdd496
/* Written by Paul Eggert, Bruno Haible, and Jim Meyering.  */
Packit Service fdd496
Packit Service fdd496
#ifndef _GL_CAREADLINKAT_H
Packit Service fdd496
#define _GL_CAREADLINKAT_H
Packit Service fdd496
Packit Service fdd496
#include <fcntl.h>
Packit Service fdd496
#include <unistd.h>
Packit Service fdd496
Packit Service fdd496
struct allocator;
Packit Service fdd496
Packit Service fdd496
/* Assuming the current directory is FD, get the symbolic link value
Packit Service fdd496
   of FILENAME as a null-terminated string and put it into a buffer.
Packit Service fdd496
   If FD is AT_FDCWD, FILENAME is interpreted relative to the current
Packit Service fdd496
   working directory, as in openat.
Packit Service fdd496
Packit Service fdd496
   If the link is small enough to fit into BUFFER put it there.
Packit Service fdd496
   BUFFER's size is BUFFER_SIZE, and BUFFER can be null
Packit Service fdd496
   if BUFFER_SIZE is zero.
Packit Service fdd496
Packit Service fdd496
   If the link is not small, put it into a dynamically allocated
Packit Service fdd496
   buffer managed by ALLOC.  It is the caller's responsibility to free
Packit Service fdd496
   the returned value if it is nonnull and is not BUFFER.
Packit Service fdd496
Packit Service fdd496
   The PREADLINKAT function specifies how to read links.  It operates
Packit Service fdd496
   like POSIX readlinkat()
Packit Service fdd496
   <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>
Packit Service fdd496
   but can assume that its first argument is the same as FD.
Packit Service fdd496
Packit Service fdd496
   If successful, return the buffer address; otherwise return NULL and
Packit Service fdd496
   set errno.  */
Packit Service fdd496
Packit Service fdd496
char *careadlinkat (int fd, char const *filename,
Packit Service fdd496
                    char *buffer, size_t buffer_size,
Packit Service fdd496
                    struct allocator const *alloc,
Packit Service fdd496
                    ssize_t (*preadlinkat) (int, char const *,
Packit Service fdd496
                                            char *, size_t));
Packit Service fdd496
Packit Service fdd496
/* Suitable value for careadlinkat's FD argument.  */
Packit Service fdd496
#if HAVE_READLINKAT
Packit Service fdd496
/* AT_FDCWD is declared in <fcntl.h>.  */
Packit Service fdd496
#else
Packit Service fdd496
/* Define AT_FDCWD independently, so that the careadlinkat module does
Packit Service fdd496
   not depend on the fcntl-h module.  We might as well use the same value
Packit Service fdd496
   as fcntl-h.  */
Packit Service fdd496
# ifndef AT_FDCWD
Packit Service fdd496
#  define AT_FDCWD (-3041965)
Packit Service fdd496
# endif
Packit Service fdd496
#endif
Packit Service fdd496
Packit Service fdd496
#endif /* _GL_CAREADLINKAT_H */