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