xref: /onnv-gate/usr/src/cmd/sendmail/db/os/os_rpath.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*-
2*0Sstevel@tonic-gate  * See the file LICENSE for redistribution information.
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * Copyright (c) 1997
5*0Sstevel@tonic-gate  *	Sleepycat Software.  All rights reserved.
6*0Sstevel@tonic-gate  */
7*0Sstevel@tonic-gate /*
8*0Sstevel@tonic-gate  * Copyright (c) 1998 by Sun Microsystems, Inc.
9*0Sstevel@tonic-gate  * All rights reserved.
10*0Sstevel@tonic-gate  */
11*0Sstevel@tonic-gate 
12*0Sstevel@tonic-gate #include "config.h"
13*0Sstevel@tonic-gate 
14*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
15*0Sstevel@tonic-gate 
16*0Sstevel@tonic-gate #ifndef lint
17*0Sstevel@tonic-gate static const char sccsid[] = "@(#)os_rpath.c	10.2 (Sleepycat) 10/24/97";
18*0Sstevel@tonic-gate static const char sccsi2[] = "%W% (Sun) %G%";
19*0Sstevel@tonic-gate #endif /* not lint */
20*0Sstevel@tonic-gate 
21*0Sstevel@tonic-gate #ifndef NO_SYSTEM_INCLUDES
22*0Sstevel@tonic-gate #include <string.h>
23*0Sstevel@tonic-gate #endif
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate #include "db_int.h"
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate /*
28*0Sstevel@tonic-gate  * __db_rpath --
29*0Sstevel@tonic-gate  *	Return the last path separator in the path or NULL if none found.
30*0Sstevel@tonic-gate  *
31*0Sstevel@tonic-gate  * PUBLIC: char *__db_rpath __P((const char *));
32*0Sstevel@tonic-gate  */
33*0Sstevel@tonic-gate char *
__db_rpath(path)34*0Sstevel@tonic-gate __db_rpath(path)
35*0Sstevel@tonic-gate 	const char *path;
36*0Sstevel@tonic-gate {
37*0Sstevel@tonic-gate 	const char *s, *last;
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate 	last = NULL;
40*0Sstevel@tonic-gate 	if (PATH_SEPARATOR[1] != '\0') {
41*0Sstevel@tonic-gate 		for (s = path; s[0] != '\0'; ++s)
42*0Sstevel@tonic-gate 			if (strchr(PATH_SEPARATOR, s[0]) != NULL)
43*0Sstevel@tonic-gate 				last = s;
44*0Sstevel@tonic-gate 	} else
45*0Sstevel@tonic-gate 		for (s = path; s[0] != '\0'; ++s)
46*0Sstevel@tonic-gate 			if (s[0] == PATH_SEPARATOR[0])
47*0Sstevel@tonic-gate 				last = s;
48*0Sstevel@tonic-gate 	return ((char *)last);
49*0Sstevel@tonic-gate }
50