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