1 /*	$NetBSD: split_at.c,v 1.1.1.1 2009/06/23 10:09:01 tron Exp $	*/
2 
3 /*++
4 /* NAME
5 /*	split_at 3
6 /* SUMMARY
7 /*	trivial token splitter
8 /* SYNOPSIS
9 /*	#include <split_at.h>
10 /*
11 /*	char	*split_at(string, delimiter)
12 /*	char	*string;
13 /*	int	delimiter
14 /*
15 /*	char	*split_at_right(string, delimiter)
16 /*	char	*string;
17 /*	int	delimiter
18 /* DESCRIPTION
19 /*	split_at() null-terminates the \fIstring\fR at the first
20 /*	occurrence of the \fIdelimiter\fR character found, and
21 /*	returns a pointer to the remainder.
22 /*
23 /*	split_at_right() looks for the rightmost delimiter
24 /*	occurrence, but is otherwise identical to split_at().
25 /* DIAGNOSTICS
26 /*	The result is a null pointer when the delimiter character
27 /*	was not found.
28 /* HISTORY
29 /* .ad
30 /* .fi
31 /*	A split_at() routine appears in the TCP Wrapper software
32 /*	by Wietse Venema.
33 /* LICENSE
34 /* .ad
35 /* .fi
36 /*	The Secure Mailer license must be distributed with this software.
37 /* AUTHOR(S)
38 /*	Wietse Venema
39 /*	IBM T.J. Watson Research
40 /*	P.O. Box 704
41 /*	Yorktown Heights, NY 10598, USA
42 /*--*/
43 
44 /* System libraries */
45 
46 #include <sys_defs.h>
47 #include <string.h>
48 
49 /* Utility library. */
50 
51 #include "split_at.h"
52 
53 /* split_at - break string at first delimiter, return remainder */
54 
55 char   *split_at(char *string, int delimiter)
56 {
57     char   *cp;
58 
59     if ((cp = strchr(string, delimiter)) != 0)
60 	*cp++ = 0;
61     return (cp);
62 }
63 
64 /* split_at_right - break string at last delimiter, return remainder */
65 
66 char   *split_at_right(char *string, int delimiter)
67 {
68     char   *cp;
69 
70     if ((cp = strrchr(string, delimiter)) != 0)
71 	*cp++ = 0;
72     return (cp);
73 }
74