summaryrefslogtreecommitdiffstats
path: root/man-pages-posix-2013/man3p/basename.3p
diff options
context:
space:
mode:
Diffstat (limited to 'man-pages-posix-2013/man3p/basename.3p')
-rw-r--r--man-pages-posix-2013/man3p/basename.3p144
1 files changed, 144 insertions, 0 deletions
diff --git a/man-pages-posix-2013/man3p/basename.3p b/man-pages-posix-2013/man3p/basename.3p
new file mode 100644
index 0000000..9d81c23
--- /dev/null
+++ b/man-pages-posix-2013/man3p/basename.3p
@@ -0,0 +1,144 @@
+'\" et
+.TH BASENAME "3P" 2013 "IEEE/The Open Group" "POSIX Programmer's Manual"
+.SH PROLOG
+This manual page is part of the POSIX Programmer's Manual.
+The Linux implementation of this interface may differ (consult
+the corresponding Linux manual page for details of Linux behavior),
+or the interface may not be implemented on Linux.
+
+.SH NAME
+basename
+\(em return the last component of a pathname
+.SH SYNOPSIS
+.LP
+.nf
+#include <libgen.h>
+.P
+char *basename(char *\fIpath\fP);
+.fi
+.SH DESCRIPTION
+The
+\fIbasename\fR()
+function shall take the pathname pointed to by
+.IR path
+and return a pointer to the final component of the pathname, deleting
+any trailing
+.BR '/'
+characters.
+.P
+If the string pointed to by
+.IR path
+consists entirely of the
+.BR '/'
+character,
+\fIbasename\fR()
+shall return a pointer to the string
+.BR \(dq/\(dq .
+If the string pointed to by
+.IR path
+is exactly
+.BR \(dq//\(dq ,
+it is implementation-defined whether
+.BR '/'
+or
+.BR \(dq//\(dq
+is returned.
+.P
+If
+.IR path
+is a null pointer or points to an empty string,
+\fIbasename\fR()
+shall return a pointer to the string
+.BR \(dq.\(dq .
+.P
+The
+\fIbasename\fR()
+function may modify the string pointed to by
+.IR path ,
+and may return a pointer to internal storage. The returned pointer might
+be invalidated or the storage might be overwritten by a subsequent call to
+\fIbasename\fR().
+.P
+The
+\fIbasename\fR()
+function need not be thread-safe.
+.SH "RETURN VALUE"
+The
+\fIbasename\fR()
+function shall return a pointer to the final component of
+.IR path .
+.SH ERRORS
+No errors are defined.
+.LP
+.IR "The following sections are informative."
+.SH EXAMPLES
+.SS "Using basename(\|)"
+.P
+The following program fragment returns a pointer to the value
+.IR lib ,
+which is the base name of
+.BR /usr/lib .
+.sp
+.RS 4
+.nf
+\fB
+#include <libgen.h>
+\&...
+char *name = "/usr/lib";
+char *base;
+.P
+base = basename(name);
+\&...
+.fi \fR
+.P
+.RE
+.SS "Sample Input and Output Strings for basename(\|)"
+.P
+In the following table, the input string is the value pointed to by
+.IR path ,
+and the output string is the return value of the
+\fIbasename\fR()
+function.
+.TS
+center box tab(!);
+cB | cB
+lf5 | lf5.
+Input String!Output String
+_
+"/usr/lib"!"lib"
+"/usr/"!"usr"
+"/"!"/"
+"///"!"/"
+"//usr//lib//"!"lib"
+.TE
+.SH "APPLICATION USAGE"
+None.
+.SH RATIONALE
+None.
+.SH "FUTURE DIRECTIONS"
+None.
+.SH "SEE ALSO"
+.IR "\fIdirname\fR\^(\|)"
+.P
+The Base Definitions volume of POSIX.1\(hy2008,
+.IR "\fB<libgen.h>\fP"
+.P
+The Shell and Utilities volume of POSIX.1\(hy2008,
+.IR "\fIbasename\fR\^"
+.SH COPYRIGHT
+Portions of this text are reprinted and reproduced in electronic form
+from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
+-- Portable Operating System Interface (POSIX), The Open Group Base
+Specifications Issue 7, Copyright (C) 2013 by the Institute of
+Electrical and Electronics Engineers, Inc and The Open Group.
+(This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
+event of any discrepancy between this version and the original IEEE and
+The Open Group Standard, the original IEEE and The Open Group Standard
+is the referee document. The original Standard can be obtained online at
+http://www.unix.org/online.html .
+
+Any typographical or formatting errors that appear
+in this page are most likely
+to have been introduced during the conversion of the source files to
+man page format. To report such errors, see
+https://www.kernel.org/doc/man-pages/reporting_bugs.html .