]>
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...
30 # endif /* HAVE_STRING_H */
32 # ifdef HAVE_STRINGS_H
34 # endif /* HAVE_STRINGS_H */
36 # ifdef HAVE_BSTRING_H
38 # endif /* HAVE_BSTRING_H */
40 # if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
41 # define __CUPS_SSIZE_T_DEFINED
43 /* Windows does not support the ssize_t type, so map it to long... */
44 typedef long ssize_t
; /* @private@ */
45 # endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */
54 # endif /* __cplusplus */
58 * String pool structures...
61 # define _CUPS_STR_GUARD 0x12344321
63 typedef struct _cups_sp_item_s
/**** String Pool Item ****/
66 unsigned int guard
; /* Guard word */
67 # endif /* DEBUG_GUARDS */
68 unsigned int ref_count
; /* Reference count */
69 char str
[1]; /* String */
74 * Replacements for the ctype macros that are not affected by locale, since we
75 * really only care about testing for ASCII characters when parsing files, etc.
77 * The _CUPS_INLINE definition controls whether we get an inline function body,
78 * and external function body, or an external definition.
81 # if defined(__GNUC__) || __STDC_VERSION__ >= 199901L
82 # define _CUPS_INLINE static inline
83 # elif defined(_MSC_VER)
84 # define _CUPS_INLINE static __inline
85 # elif defined(_CUPS_STRING_C_)
87 # endif /* __GNUC__ || __STDC_VERSION__ */
90 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
91 _cups_isalnum(int ch
) /* I - Character to test */
93 return ((ch
>= '0' && ch
<= '9') ||
94 (ch
>= 'A' && ch
<= 'Z') ||
95 (ch
>= 'a' && ch
<= 'z'));
98 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
99 _cups_isalpha(int ch
) /* I - Character to test */
101 return ((ch
>= 'A' && ch
<= 'Z') ||
102 (ch
>= 'a' && ch
<= 'z'));
105 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
106 _cups_islower(int ch
) /* I - Character to test */
108 return (ch
>= 'a' && ch
<= 'z');
111 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
112 _cups_isspace(int ch
) /* I - Character to test */
114 return (ch
== ' ' || ch
== '\f' || ch
== '\n' || ch
== '\r' || ch
== '\t' ||
118 _CUPS_INLINE
int /* O - 1 on match, 0 otherwise */
119 _cups_isupper(int ch
) /* I - Character to test */
121 return (ch
>= 'A' && ch
<= 'Z');
124 _CUPS_INLINE
int /* O - Converted character */
125 _cups_tolower(int ch
) /* I - Character to convert */
127 return (_cups_isupper(ch
) ? ch
- 'A' + 'a' : ch
);
130 _CUPS_INLINE
int /* O - Converted character */
131 _cups_toupper(int ch
) /* I - Character to convert */
133 return (_cups_islower(ch
) ? ch
- 'a' + 'A' : ch
);
136 extern int _cups_isalnum(int ch
);
137 extern int _cups_isalpha(int ch
);
138 extern int _cups_islower(int ch
);
139 extern int _cups_isspace(int ch
);
140 extern int _cups_isupper(int ch
);
141 extern int _cups_tolower(int ch
);
142 extern int _cups_toupper(int ch
);
143 # endif /* _CUPS_INLINE */
150 extern ssize_t
_cups_safe_vsnprintf(char *, size_t, const char *, va_list);
151 extern void _cups_strcpy(char *dst
, const char *src
);
154 extern char *_cups_strdup(const char *);
155 # define strdup _cups_strdup
156 # endif /* !HAVE_STRDUP */
158 extern int _cups_strcasecmp(const char *, const char *);
160 extern int _cups_strncasecmp(const char *, const char *, size_t n
);
162 # ifndef HAVE_STRLCAT
163 extern size_t _cups_strlcat(char *, const char *, size_t);
164 # define strlcat _cups_strlcat
165 # endif /* !HAVE_STRLCAT */
167 # ifndef HAVE_STRLCPY
168 extern size_t _cups_strlcpy(char *, const char *, size_t);
169 # define strlcpy _cups_strlcpy
170 # endif /* !HAVE_STRLCPY */
172 # ifndef HAVE_SNPRINTF
173 extern int _cups_snprintf(char *, size_t, const char *, ...) _CUPS_FORMAT(3, 4);
174 # define snprintf _cups_snprintf
175 # endif /* !HAVE_SNPRINTF */
177 # ifndef HAVE_VSNPRINTF
178 extern int _cups_vsnprintf(char *, size_t, const char *, va_list);
179 # define vsnprintf _cups_vsnprintf
180 # endif /* !HAVE_VSNPRINTF */
183 * String pool functions...
186 extern char *_cupsStrAlloc(const char *s
);
187 extern void _cupsStrFlush(void);
188 extern void _cupsStrFree(const char *s
);
189 extern char *_cupsStrRetain(const char *s
);
190 extern size_t _cupsStrStatistics(size_t *alloc_bytes
, size_t *total_bytes
);
194 * Floating point number functions...
197 extern char *_cupsStrFormatd(char *buf
, char *bufend
, double number
,
199 extern double _cupsStrScand(const char *buf
, char **bufptr
,
207 extern char *_cupsStrDate(char *buf
, size_t bufsize
, time_t timeval
);
216 # endif /* __cplusplus */
218 #endif /* !_CUPS_STRING_H_ */