string.h revision 261363
1/* 2 * Copyright (c) 2000-2001, 2003 Proofpoint, 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.39 2013/11/22 20:51:31 ca Exp $ 10 */ 11 12/* 13** libsm string manipulation 14*/ 15 16#ifndef SM_STRING_H 17# define SM_STRING_H 18 19# include <sm/gen.h> 20# include <sm/varargs.h> 21# include <string.h> /* strlc{py,at}, strerror */ 22 23/* return number of bytes left in a buffer */ 24#define SPACELEFT(buf, ptr) (sizeof buf - ((ptr) - buf)) 25 26extern int PRINTFLIKE(3, 4) 27sm_snprintf __P((char *, size_t, const char *, ...)); 28 29extern bool 30sm_match __P((const char *_str, const char *_pattern)); 31 32extern char * 33sm_strdup __P((char *)); 34 35extern char * 36sm_strndup_x __P((const char *_str, size_t _len)); 37 38#if DO_NOT_USE_STRCPY 39/* for "normal" data (free'd before end of process) */ 40extern char * 41sm_strdup_x __P((const char *_str)); 42 43/* for data that is supposed to be persistent. */ 44extern char * 45sm_pstrdup_x __P((const char *_str)); 46 47extern char * 48sm_strdup_tagged_x __P((const char *str, char *file, int line, int group)); 49 50#else /* DO_NOT_USE_STRCPY */ 51 52/* for "normal" data (free'd before end of process) */ 53# define sm_strdup_x(str) strcpy(sm_malloc_x(strlen(str) + 1), str) 54 55/* for data that is supposed to be persistent. */ 56# define sm_pstrdup_x(str) strcpy(sm_pmalloc_x(strlen(str) + 1), str) 57 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 */ 61 62extern char * 63sm_stringf_x __P((const char *_fmt, ...)); 64 65extern char * 66sm_vstringf_x __P((const char *_fmt, va_list _ap)); 67 68extern size_t 69sm_strlcpy __P((char *_dst, const char *_src, ssize_t _len)); 70 71extern size_t 72sm_strlcat __P((char *_dst, const char *_src, ssize_t _len)); 73 74extern size_t 75sm_strlcat2 __P((char *, const char *, const char *, ssize_t)); 76 77extern size_t 78#ifdef __STDC__ 79sm_strlcpyn(char *dst, ssize_t len, int n, ...); 80#else /* __STDC__ */ 81sm_strlcpyn __P((char *, 82 ssize_t, 83 int, 84 va_dcl)); 85#endif /* __STDC__ */ 86 87# if !HASSTRERROR 88extern char * 89strerror __P((int _errno)); 90# endif /* !HASSTRERROR */ 91 92extern int 93sm_strrevcmp __P((const char *, const char *)); 94 95extern int 96sm_strrevcasecmp __P((const char *, const char *)); 97 98extern int 99sm_strcasecmp __P((const char *, const char *)); 100 101extern int 102sm_strncasecmp __P((const char *, const char *, size_t)); 103 104extern LONGLONG_T 105sm_strtoll __P((const char *, char**, int)); 106 107extern ULONGLONG_T 108sm_strtoull __P((const char *, char**, int)); 109 110extern void 111stripquotes __P((char *)); 112 113#endif /* SM_STRING_H */ 114