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