gsasl  1.10.0
About: GNU SASL is an implementation of the Simple Authentication and Security Layer (SASL). Development version.
  Fossies Dox: gsasl-1.10.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

basename-lgpl.h
Go to the documentation of this file.
1 /* Extract the last component (base name) of a file name.
2 
3  Copyright (C) 1998, 2001, 2003-2006, 2009-2021 Free Software Foundation,
4  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 #ifndef _BASENAME_LGPL_H
20 #define _BASENAME_LGPL_H
21 
22 #include <stddef.h>
23 
24 #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
25 # define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
26 #endif
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 
33 /* Return the address of the last file name component of FILENAME.
34  If FILENAME has some trailing slash(es), they are considered to be
35  part of the last component.
36  If FILENAME has no relative file name components because it is a file
37  system root, return the empty string.
38  Examples:
39  FILENAME RESULT
40  "foo.c" "foo.c"
41  "foo/bar.c" "bar.c"
42  "/foo/bar.c" "bar.c"
43  "foo/bar/" "bar/"
44  "foo/bar//" "bar//"
45  "/" ""
46  "//" ""
47  "" ""
48  The return value is a tail of the given FILENAME; do NOT free() it! */
49 
50 /* This function was traditionally called 'basename', but we avoid this
51  function name because
52  * Various platforms have different functions in their libc.
53  In particular, the glibc basename(), defined in <string.h>, does
54  not consider trailing slashes to be part of the component:
55  FILENAME RESULT
56  "foo/bar/" ""
57  "foo/bar//" ""
58  * The 'basename' command eliminates trailing slashes and for a root
59  produces a non-empty result:
60  FILENAME RESULT
61  "foo/bar/" "bar"
62  "foo/bar//" "bar"
63  "/" "/"
64  "//" "/"
65  */
66 extern char *last_component (char const *filename) _GL_ATTRIBUTE_PURE;
67 
68 /* Return the length of the basename FILENAME.
69  Typically FILENAME is the value returned by base_name or last_component.
70  Act like strlen (FILENAME), except omit all trailing slashes. */
71 extern size_t base_len (char const *filename) _GL_ATTRIBUTE_PURE;
72 
73 
74 #ifdef __cplusplus
75 } /* extern "C" */
76 #endif
77 
78 #endif /* _BASENAME_LGPL_H */
char * last_component(char const *filename) _GL_ATTRIBUTE_PURE
Definition: basename-lgpl.c:30
size_t base_len(char const *filename) _GL_ATTRIBUTE_PURE
Definition: basename-lgpl.c:54
#define _GL_ATTRIBUTE_PURE
Definition: stdlib.in.h:108