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 $
12 #pragma ident "%Z%%M% %I% %E% SMI"
15 ** libsm string manipulation
22 # include <sm/varargs.h>
23 # include <string.h> /* strlc{py,at}, strerror */
25 /* return number of bytes left in a buffer */
26 #define SPACELEFT(buf, ptr) (sizeof buf - ((ptr) - buf))
28 extern int PRINTFLIKE(3, 4)
29 sm_snprintf
__P((char *, size_t, const char *, ...));
32 sm_match
__P((const char *_str
, const char *_pattern
));
35 sm_strdup
__P((char *));
38 sm_strndup_x
__P((const char *_str
, size_t _len
));
41 /* for "normal" data (free'd before end of process) */
43 sm_strdup_x
__P((const char *_str
));
45 /* for data that is supposed to be persistent. */
47 sm_pstrdup_x
__P((const char *_str
));
50 sm_strdup_tagged_x
__P((const char *str
, char *file
, int line
, int group
));
52 #else /* DO_NOT_USE_STRCPY */
54 /* for "normal" data (free'd before end of process) */
55 # define sm_strdup_x(str) strcpy(sm_malloc_x(strlen(str) + 1), str)
57 /* for data that is supposed to be persistent. */
58 # define sm_pstrdup_x(str) strcpy(sm_pmalloc_x(strlen(str) + 1), str)
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 */
65 sm_stringf_x
__P((const char *_fmt
, ...));
68 sm_vstringf_x
__P((const char *_fmt
, va_list _ap
));
71 sm_strlcpy
__P((char *_dst
, const char *_src
, ssize_t _len
));
74 sm_strlcat
__P((char *_dst
, const char *_src
, ssize_t _len
));
77 sm_strlcat2
__P((char *, const char *, const char *, ssize_t
));
81 sm_strlcpyn(char *dst
, ssize_t len
, int n
, ...);
83 sm_strlcpyn
__P((char *,
91 strerror
__P((int _errno
));
92 # endif /* !HASSTRERROR */
95 sm_strrevcmp
__P((const char *, const char *));
98 sm_strrevcasecmp
__P((const char *, const char *));
101 sm_strcasecmp
__P((const char *, const char *));
104 sm_strncasecmp
__P((const char *, const char *, size_t));
107 sm_strtoll
__P((const char *, char**, int));
110 sm_strtoull
__P((const char *, char**, int));
113 stripquotes
__P((char *));
115 #endif /* SM_STRING_H */