xref: /netbsd-src/external/gpl2/lvm2/dist/lib/misc/last-path-component.h (revision 404fbe5fb94ca1e054339640cabb2801ce52dd30)
1 /*	$NetBSD: last-path-component.h,v 1.1.1.1 2008/12/22 00:18:13 haad Exp $	*/
2 
3 /*
4  * Copyright (C) 2007 Red Hat, Inc. All rights reserved.
5  *
6  * This file is part of LVM2.
7  *
8  * This copyrighted material is made available to anyone wishing to use,
9  * modify, copy, or redistribute it subject to the terms and conditions
10  * of the GNU Lesser General Public License v.2.1.
11  *
12  * You should have received a copy of the GNU Lesser General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15  */
16 
17 /*
18  * Return the address of the last file name component of NAME.
19  * If NAME ends in a slash, return the empty string.
20  */
21 
22 #include <string.h>
23 
24 static inline char *last_path_component(char const *name)
25 {
26 	char const *slash = strrchr(name, '/');
27 	char const *res = slash ? slash + 1 : name;
28 
29 	return (char *)res;
30 }
31