summaryrefslogtreecommitdiffstats
path: root/gl/basename-lgpl.h
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-09-18 20:59:46 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-09-18 20:59:46 (GMT)
commit0e70e81133c25274fe2dd2309556b41357dd759b (patch)
tree9a680b36788ee1ad4e7ecc5ccfeb4494db9fdc72 /gl/basename-lgpl.h
parentce355c80cf6054bfa5e1dcf81f9e2183ef963ee1 (diff)
parent2ddc75e69db5a3dd379c896d8420c9af20ec1cee (diff)
downloadmonitoring-plugins-0e70e81133c25274fe2dd2309556b41357dd759b.tar.gz
Merge branch 'master' into mysql_detect_mysqldumprefs/pull/1718/head
Diffstat (limited to 'gl/basename-lgpl.h')
-rw-r--r--gl/basename-lgpl.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/gl/basename-lgpl.h b/gl/basename-lgpl.h
new file mode 100644
index 0000000..5d996c1
--- /dev/null
+++ b/gl/basename-lgpl.h
@@ -0,0 +1,78 @@
1/* Extract the last component (base name) of a file name.
2
3 Copyright (C) 1998, 2001, 2003-2006, 2009-2023 Free Software Foundation,
4 Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file 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 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser 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
29extern "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 */
66extern 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. */
71extern 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 */