]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/string-private.h
2 * Private string definitions for CUPS.
4 * Copyright © 2007-2018 by Apple Inc.
5 * Copyright © 1997-2006 by Easy Software Products.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more
11 #ifndef _CUPS_STRING_PRIVATE_H_
12 # define _CUPS_STRING_PRIVATE_H_
15 * Include necessary headers...
27 # include <cups/versioning.h>
31 # endif /* HAVE_STRING_H */
33 # ifdef HAVE_STRINGS_H
35 # endif /* HAVE_STRINGS_H */
37 # ifdef HAVE_BSTRING_H
39 # endif /* HAVE_BSTRING_H */
41 # if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
42 # define __CUPS_SSIZE_T_DEFINED
44 /* Windows does not support the ssize_t type, so map it to long... */
45 typedef long ssize_t
; /* @private@ */
46 # endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */
55 # endif /* __cplusplus */
59 * String pool structures...
62 # define _CUPS_STR_GUARD 0x12344321
64 typedef struct _cups_sp_item_s
/**** String Pool Item ****/
67 unsigned int guard
; /* Guard word */
68 # endif /* DEBUG_GUARDS */
69 unsigned int ref_count
; /* Reference count */
70 char str
[1]; /* String */
75 * Replacements for the ctype macros that are not affected by locale, since we
76 * really only care about testing for ASCII characters when parsing files, etc.
78 * The _CUPS_INLINE definition controls whether we get an inline function body,
79 * and external function body, or an external definition.
82 # if defined(__GNUC__) || __STDC_VERSION__ >= 199901L
83 # define _CUPS_INLINE static inline
84 # elif defined(_MSC_VER)
85 # define _CUPS_INLINE static __inline
86 # elif defined(_CUPS_STRING_C_)
88 # endif /* __GNUC__ || __STDC_VERSION__ */
91 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
92 _cups_isalnum(int ch
) /* I - Character to test */
94 return ((ch
>= '0' && ch
<= '9') ||
95 (ch
>= 'A' && ch
<= 'Z') ||
96 (ch
>= 'a' && ch
<= 'z'));
99 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
100 _cups_isalpha(int ch
) /* I - Character to test */
102 return ((ch
>= 'A' && ch
<= 'Z') ||
103 (ch
>= 'a' && ch
<= 'z'));
106 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
107 _cups_islower(int ch
) /* I - Character to test */
109 return (ch
>= 'a' && ch
<= 'z');
112 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
113 _cups_isspace(int ch
) /* I - Character to test */
115 return (ch
== ' ' || ch
== '\f' || ch
== '\n' || ch
== '\r' || ch
== '\t' ||
119 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
120 _cups_isupper(int ch
) /* I - Character to test */
122 return (ch
>= 'A' && ch
<= 'Z');
125 _CUPS_INLINE
int /* O - Converted character */
126 _cups_tolower(int ch
) /* I - Character to convert */
128 return (_cups_isupper(ch
) ? ch
- 'A' + 'a' : ch
);
131 _CUPS_INLINE
int /* O - Converted character */
132 _cups_toupper(int ch
) /* I - Character to convert */
134 return (_cups_islower(ch
) ? ch
- 'a' + 'A' : ch
);
137 extern int _cups_isalnum(int ch
);
138 extern int _cups_isalpha(int ch
);
139 extern int _cups_islower(int ch
);
140 extern int _cups_isspace(int ch
);
141 extern int _cups_isupper(int ch
);
142 extern int _cups_tolower(int ch
);
143 extern int _cups_toupper(int ch
);
144 # endif /* _CUPS_INLINE */
151 extern ssize_t
_cups_safe_vsnprintf(char *buffer
, size_t bufsize
, const char *format
, va_list args
) _CUPS_PRIVATE
;
152 extern void _cups_strcpy(char *dst
, const char *src
) _CUPS_PRIVATE
;
155 extern char *_cups_strdup(const char *) _CUPS_PRIVATE
;
156 # define strdup _cups_strdup
157 # endif /* !HAVE_STRDUP */
159 extern int _cups_strcasecmp(const char *, const char *) _CUPS_PRIVATE
;
161 extern int _cups_strncasecmp(const char *, const char *, size_t n
) _CUPS_PRIVATE
;
163 # ifndef HAVE_STRLCAT
164 extern size_t _cups_strlcat(char *, const char *, size_t) _CUPS_PRIVATE
;
165 # define strlcat _cups_strlcat
166 # endif /* !HAVE_STRLCAT */
168 # ifndef HAVE_STRLCPY
169 extern size_t _cups_strlcpy(char *, const char *, size_t) _CUPS_PRIVATE
;
170 # define strlcpy _cups_strlcpy
171 # endif /* !HAVE_STRLCPY */
173 # ifndef HAVE_SNPRINTF
174 extern int _cups_snprintf(char *, size_t, const char *, ...) _CUPS_FORMAT(3, 4) _CUPS_PRIVATE
;
175 # define snprintf _cups_snprintf
176 # endif /* !HAVE_SNPRINTF */
178 # ifndef HAVE_VSNPRINTF
179 extern int _cups_vsnprintf(char *, size_t, const char *, va_list) _CUPS_PRIVATE
;
180 # define vsnprintf _cups_vsnprintf
181 # endif /* !HAVE_VSNPRINTF */
184 * String pool functions...
187 extern char *_cupsStrAlloc(const char *s
) _CUPS_PRIVATE
;
188 extern void _cupsStrFlush(void) _CUPS_PRIVATE
;
189 extern void _cupsStrFree(const char *s
) _CUPS_PRIVATE
;
190 extern char *_cupsStrRetain(const char *s
) _CUPS_PRIVATE
;
191 extern size_t _cupsStrStatistics(size_t *alloc_bytes
, size_t *total_bytes
) _CUPS_PRIVATE
;
195 * Floating point number functions...
198 extern char *_cupsStrFormatd(char *buf
, char *bufend
, double number
,
199 struct lconv
*loc
) _CUPS_PRIVATE
;
200 extern double _cupsStrScand(const char *buf
, char **bufptr
,
201 struct lconv
*loc
) _CUPS_PRIVATE
;
208 extern char *_cupsStrDate(char *buf
, size_t bufsize
, time_t timeval
) _CUPS_PRIVATE
;
217 # endif /* __cplusplus */
219 #endif /* !_CUPS_STRING_H_ */