2 * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers.
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.
9 * $Id: string.h,v 1.38 2003/10/10 17:56:57 ca Exp $
13 ** libsm string manipulation
20 # include <sm/varargs.h>
21 # include <string.h> /* strlc{py,at}, strerror */
23 /* return number of bytes left in a buffer */
24 #define SPACELEFT(buf, ptr) (sizeof buf - ((ptr) - buf))
26 extern int PRINTFLIKE(3, 4)
27 sm_snprintf
__P((char *, size_t, const char *, ...));
30 sm_match
__P((const char *_str
, const char *_pattern
));
33 sm_strdup
__P((char *));
36 sm_strndup_x
__P((const char *_str
, size_t _len
));
39 /* for "normal" data (free'd before end of process) */
41 sm_strdup_x
__P((const char *_str
));
43 /* for data that is supposed to be persistent. */
45 sm_pstrdup_x
__P((const char *_str
));
48 sm_strdup_tagged_x
__P((const char *str
, char *file
, int line
, int group
));
50 #else /* DO_NOT_USE_STRCPY */
52 /* for "normal" data (free'd before end of process) */
53 # define sm_strdup_x(str) strcpy(sm_malloc_x(strlen(str) + 1), str)
55 /* for data that is supposed to be persistent. */
56 # define sm_pstrdup_x(str) strcpy(sm_pmalloc_x(strlen(str) + 1), str)
58 # define sm_strdup_tagged_x(str, file, line, group) \
59 strcpy(sm_malloc_tagged_x(strlen(str) + 1, file, line, group), str)
60 #endif /* DO_NOT_USE_STRCPY */
63 sm_stringf_x
__P((const char *_fmt
, ...));
66 sm_vstringf_x
__P((const char *_fmt
, va_list _ap
));
69 sm_strlcpy
__P((char *_dst
, const char *_src
, ssize_t _len
));
72 sm_strlcat
__P((char *_dst
, const char *_src
, ssize_t _len
));
75 sm_strlcat2
__P((char *, const char *, const char *, ssize_t
));
79 sm_strlcpyn(char *dst
, ssize_t len
, int n
, ...);
81 sm_strlcpyn
__P((char *,
89 strerror
__P((int _errno
));
90 # endif /* !HASSTRERROR */
93 sm_strrevcmp
__P((const char *, const char *));
96 sm_strrevcasecmp
__P((const char *, const char *));
99 sm_strcasecmp
__P((const char *, const char *));
102 sm_strncasecmp
__P((const char *, const char *, size_t));
105 sm_strtoll
__P((const char *, char**, int));
108 sm_strtoull
__P((const char *, char**, int));
111 stripquotes
__P((char *));
113 #endif /* SM_STRING_H */