xref: /onnv-gate/usr/src/cmd/sendmail/include/sm/string.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers.
3*0Sstevel@tonic-gate  *	All rights reserved.
4*0Sstevel@tonic-gate  *
5*0Sstevel@tonic-gate  * By using this file, you agree to the terms and conditions set
6*0Sstevel@tonic-gate  * forth in the LICENSE file which can be found at the top level of
7*0Sstevel@tonic-gate  * the sendmail distribution.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  *	$Id: string.h,v 1.38 2003/10/10 17:56:57 ca Exp $
10*0Sstevel@tonic-gate  */
11*0Sstevel@tonic-gate 
12*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
13*0Sstevel@tonic-gate 
14*0Sstevel@tonic-gate /*
15*0Sstevel@tonic-gate **  libsm string manipulation
16*0Sstevel@tonic-gate */
17*0Sstevel@tonic-gate 
18*0Sstevel@tonic-gate #ifndef SM_STRING_H
19*0Sstevel@tonic-gate # define SM_STRING_H
20*0Sstevel@tonic-gate 
21*0Sstevel@tonic-gate # include <sm/gen.h>
22*0Sstevel@tonic-gate # include <sm/varargs.h>
23*0Sstevel@tonic-gate # include <string.h> /* strlc{py,at}, strerror */
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate /* return number of bytes left in a buffer */
26*0Sstevel@tonic-gate #define SPACELEFT(buf, ptr)	(sizeof buf - ((ptr) - buf))
27*0Sstevel@tonic-gate 
28*0Sstevel@tonic-gate extern int PRINTFLIKE(3, 4)
29*0Sstevel@tonic-gate sm_snprintf __P((char *, size_t, const char *, ...));
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate extern bool
32*0Sstevel@tonic-gate sm_match __P((const char *_str, const char *_pattern));
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate extern char *
35*0Sstevel@tonic-gate sm_strdup __P((char *));
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate extern char *
38*0Sstevel@tonic-gate sm_strndup_x __P((const char *_str, size_t _len));
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #if DO_NOT_USE_STRCPY
41*0Sstevel@tonic-gate /* for "normal" data (free'd before end of process) */
42*0Sstevel@tonic-gate extern char *
43*0Sstevel@tonic-gate sm_strdup_x __P((const char *_str));
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate /* for data that is supposed to be persistent. */
46*0Sstevel@tonic-gate extern char *
47*0Sstevel@tonic-gate sm_pstrdup_x __P((const char *_str));
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate extern char *
50*0Sstevel@tonic-gate sm_strdup_tagged_x __P((const char *str, char *file, int line, int group));
51*0Sstevel@tonic-gate 
52*0Sstevel@tonic-gate #else /* DO_NOT_USE_STRCPY */
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /* for "normal" data (free'd before end of process) */
55*0Sstevel@tonic-gate # define sm_strdup_x(str) strcpy(sm_malloc_x(strlen(str) + 1), str)
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate /* for data that is supposed to be persistent. */
58*0Sstevel@tonic-gate # define sm_pstrdup_x(str) strcpy(sm_pmalloc_x(strlen(str) + 1), str)
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate # define sm_strdup_tagged_x(str, file, line, group) \
61*0Sstevel@tonic-gate 	strcpy(sm_malloc_tagged_x(strlen(str) + 1, file, line, group), str)
62*0Sstevel@tonic-gate #endif /* DO_NOT_USE_STRCPY */
63*0Sstevel@tonic-gate 
64*0Sstevel@tonic-gate extern char *
65*0Sstevel@tonic-gate sm_stringf_x __P((const char *_fmt, ...));
66*0Sstevel@tonic-gate 
67*0Sstevel@tonic-gate extern char *
68*0Sstevel@tonic-gate sm_vstringf_x __P((const char *_fmt, va_list _ap));
69*0Sstevel@tonic-gate 
70*0Sstevel@tonic-gate extern size_t
71*0Sstevel@tonic-gate sm_strlcpy __P((char *_dst, const char *_src, ssize_t _len));
72*0Sstevel@tonic-gate 
73*0Sstevel@tonic-gate extern size_t
74*0Sstevel@tonic-gate sm_strlcat __P((char *_dst, const char *_src, ssize_t _len));
75*0Sstevel@tonic-gate 
76*0Sstevel@tonic-gate extern size_t
77*0Sstevel@tonic-gate sm_strlcat2 __P((char *, const char *, const char *, ssize_t));
78*0Sstevel@tonic-gate 
79*0Sstevel@tonic-gate extern size_t
80*0Sstevel@tonic-gate #ifdef __STDC__
81*0Sstevel@tonic-gate sm_strlcpyn(char *dst, ssize_t len, int n, ...);
82*0Sstevel@tonic-gate #else /* __STDC__ */
83*0Sstevel@tonic-gate sm_strlcpyn __P((char *,
84*0Sstevel@tonic-gate 	ssize_t,
85*0Sstevel@tonic-gate 	int,
86*0Sstevel@tonic-gate 	va_dcl));
87*0Sstevel@tonic-gate #endif /* __STDC__ */
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate # if !HASSTRERROR
90*0Sstevel@tonic-gate extern char *
91*0Sstevel@tonic-gate strerror __P((int _errno));
92*0Sstevel@tonic-gate # endif /* !HASSTRERROR */
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate extern int
95*0Sstevel@tonic-gate sm_strrevcmp __P((const char *, const char *));
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate extern int
98*0Sstevel@tonic-gate sm_strrevcasecmp __P((const char *, const char *));
99*0Sstevel@tonic-gate 
100*0Sstevel@tonic-gate extern int
101*0Sstevel@tonic-gate sm_strcasecmp __P((const char *, const char *));
102*0Sstevel@tonic-gate 
103*0Sstevel@tonic-gate extern int
104*0Sstevel@tonic-gate sm_strncasecmp __P((const char *, const char *, size_t));
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate extern LONGLONG_T
107*0Sstevel@tonic-gate sm_strtoll __P((const char *, char**, int));
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate extern ULONGLONG_T
110*0Sstevel@tonic-gate sm_strtoull __P((const char *, char**, int));
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate extern void
113*0Sstevel@tonic-gate stripquotes __P((char *));
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate #endif /* SM_STRING_H */
116