summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/include/sm/string.h
blob: c9606629883c18b720b21f69c733cde4ff7b147e (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
 *	All rights reserved.
 *
 * By using this file, you agree to the terms and conditions set
 * forth in the LICENSE file which can be found at the top level of
 * the sendmail distribution.
 *
 *	$Id: string.h,v 1.1.1.1 2002/02/17 21:56:43 gshapiro Exp $
 */

/*
**  libsm string manipulation
*/

#ifndef SM_STRING_H
# define SM_STRING_H

# include <sm/gen.h>
# include <sm/varargs.h>
# include <string.h> /* strlc{py,at}, strerror */

/* return number of bytes left in a buffer */
#define SPACELEFT(buf, ptr)	(sizeof buf - ((ptr) - buf))

extern int PRINTFLIKE(3, 4)
sm_snprintf __P((
	char *,
	size_t,
	const char *,
	...));

extern bool
sm_match __P((
	const char *_str,
	const char *_pattern));

extern char *
sm_strdup __P((
	char *));

extern char *
sm_strndup_x __P((
	const char *_str,
	size_t _len));

/* for "normal" data (free'd before end of process) */
# define sm_strdup_x(str) strcpy(sm_malloc_x(strlen(str) + 1), str)

/* for data that is supposed to be persistent. */
# define sm_pstrdup_x(str) strcpy(sm_pmalloc_x(strlen(str) + 1), str)

# define sm_strdup_tagged_x(str, file, line, group) \
	strcpy(sm_malloc_tagged_x(strlen(str) + 1, file, line, group), str)

extern char *
sm_stringf_x __P((
	const char *_fmt,
	...));

extern char *
sm_vstringf_x __P((
	const char *_fmt,
	va_list _ap));

extern size_t
sm_strlcpy __P((
	char *_dst,
	const char *_src,
	ssize_t _len));

extern size_t
sm_strlcat __P((
	char *_dst,
	const char *_src,
	ssize_t _len));

extern size_t
sm_strlcat2 __P((
	char *,
	const char *,
	const char *,
	ssize_t));

extern size_t
#ifdef __STDC__
sm_strlcpyn(char *dst, ssize_t len, int n, ...);
#else /* __STDC__ */
sm_strlcpyn __P((char *,
	ssize_t,
	int,
	va_dcl));
#endif /* __STDC__ */

# if !HASSTRERROR
extern char *
strerror __P((
	int _errno));
# endif /* !HASSTRERROR */

extern int
sm_strrevcmp __P((
	const char *,
	const char *));

extern int
sm_strrevcasecmp __P((
	const char *,
	const char *));

extern int
sm_strcasecmp __P((
	const char *,
	const char *));

extern int
sm_strncasecmp __P((
	const char *,
	const char *,
	size_t));

extern LONGLONG_T
sm_strtoll __P((
	const char *,
	char**, int));

extern ULONGLONG_T
sm_strtoull __P((
	const char *,
	char**, int));

extern void
stripquotes __P((char *));

#endif /* SM_STRING_H */
OpenPOWER on IntegriCloud