| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/areadlinkat.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count |
|---|---|---|
| 1 | /* areadlinkat.c -- readlinkat wrapper to return malloc'd link name | - |
| 2 | Unlike xreadlinkat, only call exit on failure to change directory. | - |
| 3 | - | |
| 4 | Copyright (C) 2001, 2003-2007, 2009-2018 Free Software Foundation, Inc. | - |
| 5 | - | |
| 6 | This program is free software: you can redistribute it and/or modify | - |
| 7 | it under the terms of the GNU General Public License as published by | - |
| 8 | the Free Software Foundation; either version 3 of the License, or | - |
| 9 | (at your option) any later version. | - |
| 10 | - | |
| 11 | This program is distributed in the hope that it will be useful, | - |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | - |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - |
| 14 | GNU General Public License for more details. | - |
| 15 | - | |
| 16 | You should have received a copy of the GNU General Public License | - |
| 17 | along with this program. If not, see <https://www.gnu.org/licenses/>. */ | - |
| 18 | - | |
| 19 | /* Written by Jim Meyering <jim@meyering.net>, | - |
| 20 | and Bruno Haible <bruno@clisp.org>, | - |
| 21 | and Eric Blake <ebb9@byu.net>. */ | - |
| 22 | - | |
| 23 | #include <config.h> | - |
| 24 | - | |
| 25 | /* Specification. */ | - |
| 26 | #include "areadlink.h" | - |
| 27 | - | |
| 28 | #include "careadlinkat.h" | - |
| 29 | - | |
| 30 | #if HAVE_READLINKAT | - |
| 31 | - | |
| 32 | /* Call readlinkat to get the symbolic link value of FILENAME relative to FD. | - |
| 33 | Return a pointer to that NUL-terminated string in malloc'd storage. | - |
| 34 | If readlinkat fails, return NULL and set errno (although failure to | - |
| 35 | change directory will issue a diagnostic and exit). | - |
| 36 | If allocation fails, or if the link value is longer than SIZE_MAX :-), | - |
| 37 | return NULL and set errno to ENOMEM. */ | - |
| 38 | - | |
| 39 | char * | - |
| 40 | areadlinkat (int fd, char const *filename) | - |
| 41 | { | - |
| 42 | return careadlinkat (fd, filename, NULL, 0, NULL, readlinkat); never executed: return careadlinkat (fd, filename, ((void *)0) , 0, ((void *)0) , readlinkat); | 0 |
| 43 | } | - |
| 44 | - | |
| 45 | #else /* !HAVE_READLINKAT */ | - |
| 46 | - | |
| 47 | /* It is more efficient to change directories only once and call | - |
| 48 | areadlink, rather than repeatedly call the replacement | - |
| 49 | readlinkat. */ | - |
| 50 | - | |
| 51 | # define AT_FUNC_NAME areadlinkat | - |
| 52 | # define AT_FUNC_F1 areadlink | - |
| 53 | # define AT_FUNC_POST_FILE_PARAM_DECLS /* empty */ | - |
| 54 | # define AT_FUNC_POST_FILE_ARGS /* empty */ | - |
| 55 | # define AT_FUNC_RESULT char * | - |
| 56 | # define AT_FUNC_FAIL NULL | - |
| 57 | # include "at-func.c" | - |
| 58 | # undef AT_FUNC_NAME | - |
| 59 | # undef AT_FUNC_F1 | - |
| 60 | # undef AT_FUNC_POST_FILE_PARAM_DECLS | - |
| 61 | # undef AT_FUNC_POST_FILE_ARGS | - |
| 62 | # undef AT_FUNC_RESULT | - |
| 63 | # undef AT_FUNC_FAIL | - |
| 64 | - | |
| 65 | #endif /* !HAVE_READLINKAT */ | - |
| Source code | Switch to Preprocessed file |