Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / util / split_at.c
blob94310f906ddc2e1801a9224fe2914284dcba2f83
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* split_at 3
6 /* SUMMARY
7 /* trivial token splitter
8 /* SYNOPSIS
9 /* #include <split_at.h>
11 /* char *split_at(string, delimiter)
12 /* char *string;
13 /* int delimiter
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.
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 /*--*/
44 /* System libraries */
46 #include <sys_defs.h>
47 #include <string.h>
49 /* Utility library. */
51 #include "split_at.h"
53 /* split_at - break string at first delimiter, return remainder */
55 char *split_at(char *string, int delimiter)
57 char *cp;
59 if ((cp = strchr(string, delimiter)) != 0)
60 *cp++ = 0;
61 return (cp);
64 /* split_at_right - break string at last delimiter, return remainder */
66 char *split_at_right(char *string, int delimiter)
68 char *cp;
70 if ((cp = strrchr(string, delimiter)) != 0)
71 *cp++ = 0;
72 return (cp);