]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/gen/basename.3
Remove $FreeBSD$: two-line nroff pattern
[FreeBSD/FreeBSD.git] / lib / libc / gen / basename.3
1 .\" $OpenBSD: basename.3,v 1.20 2007/05/31 19:19:28 jmc Exp $
2 .\"
3 .\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
4 .\"
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
8 .\"
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\"
17 .Dd May 22, 2017
18 .Dt BASENAME 3
19 .Os
20 .Sh NAME
21 .Nm basename
22 .Nd extract the base portion of a pathname
23 .Sh SYNOPSIS
24 .In libgen.h
25 .Ft char *
26 .Fn basename "char *path"
27 .Sh DESCRIPTION
28 The
29 .Fn basename
30 function returns the last component from the pathname pointed to by
31 .Fa path ,
32 deleting any trailing
33 .Sq \&/
34 characters.
35 .Sh IMPLEMENTATION NOTES
36 This implementation of
37 .Fn basename
38 uses the buffer provided by the caller to store the resulting pathname
39 component.
40 Other vendor implementations may return a pointer to internal storage
41 space instead.
42 The advantage of the former approach is that it ensures thread-safety,
43 while also placing no upper limit on the supported length of the
44 pathname.
45 .Sh RETURN VALUES
46 If
47 .Fa path
48 consists entirely of
49 .Sq \&/
50 characters, a pointer to the string
51 .Qq \&/
52 is returned.
53 If
54 .Fa path
55 is a null pointer or the empty string, a pointer to the string
56 .Qq \&.
57 is returned.
58 Otherwise,
59 it returns a pointer to the last component of
60 .Fa path .
61 .Sh SEE ALSO
62 .Xr basename 1 ,
63 .Xr dirname 1 ,
64 .Xr dirname 3
65 .Sh STANDARDS
66 The
67 .Fn basename
68 function conforms to
69 .St -xpg4.2 .
70 .Sh HISTORY
71 The
72 .Fn basename
73 function first appeared in
74 .Ox 2.2
75 and
76 .Fx 4.2 .
77 .Pp
78 In
79 .Fx 12.0 ,
80 this function was reimplemented to store its result in the provided
81 input buffer.
82 There is no longer any need to use the
83 .Fn basename_r
84 function.
85 .Sh AUTHORS
86 .An Nuxi, the Netherlands