1 /*---------------------------------------------------------------------------*\
2   NAME
3 	basename.c - replacement basename(3) function
4 
5   DESCRIPTION
6 
7         This source file contains a version of the basename() function.
8 
9   LICENSE
10 
11 	This source code is released under a BSD-style license. See the
12         LICENSE file for details.
13 
14   Copyright (c) 2006-2015 Brian M. Clapper, bmc@clapper.org
15 \*---------------------------------------------------------------------------*/
16 
17 /*---------------------------------------------------------------------------*\
18                                  Includes
19 \*---------------------------------------------------------------------------*/
20 
21 #include <stdio.h>
22 #include <string.h>
23 
24 /*---------------------------------------------------------------------------*\
25                               Public Routines
26 \*---------------------------------------------------------------------------*/
27 
basename(char * path)28 char *basename (char *path)
29 {
30     char *s = strrchr (path, '/');
31 
32     return (s == NULL) ? path : ++s;
33 }
34