2 * "$Id: string-private.h 11173 2013-07-23 12:31:34Z msweet $"
4 * Private string definitions for CUPS.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
18 #ifndef _CUPS_STRING_PRIVATE_H_
19 # define _CUPS_STRING_PRIVATE_H_
22 * Include necessary headers...
36 # endif /* HAVE_STRING_H */
38 # ifdef HAVE_STRINGS_H
40 # endif /* HAVE_STRINGS_H */
42 # ifdef HAVE_BSTRING_H
44 # endif /* HAVE_BSTRING_H */
53 # endif /* __cplusplus */
57 * String pool structures...
60 # define _CUPS_STR_GUARD 0x12344321
62 typedef struct _cups_sp_item_s /**** String Pool Item ****/
65 unsigned int guard; /* Guard word */
66 # endif /* DEBUG_GUARDS */
67 unsigned int ref_count; /* Reference count */
68 char str[1]; /* String */
73 * Replacements for the ctype macros that are not affected by locale, since we
74 * really only care about testing for ASCII characters when parsing files, etc.
76 * The _CUPS_INLINE definition controls whether we get an inline function body,
77 * and external function body, or an external definition.
80 # if defined(__GNUC__) || __STDC_VERSION__ >= 199901L
81 # define _CUPS_INLINE static inline
82 # elif defined(_MSC_VER)
83 # define _CUPS_INLINE static __inline
84 # elif defined(_CUPS_STRING_C_)
86 # endif /* __GNUC__ || __STDC_VERSION__ */
89 _CUPS_INLINE int /* O - 1 on match, 0 otherwise */
90 _cups_isalnum(int ch) /* I - Character to test */
92 return ((ch >= '0' && ch <= '9') ||
93 (ch >= 'A' && ch <= 'Z') ||
94 (ch >= 'a' && ch <= 'z'));
97 _CUPS_INLINE int /* O - 1 on match, 0 otherwise */
98 _cups_isalpha(int ch) /* I - Character to test */
100 return ((ch >= 'A' && ch <= 'Z') ||
101 (ch >= 'a' && ch <= 'z'));
104 _CUPS_INLINE int /* O - 1 on match, 0 otherwise */
105 _cups_isspace(int ch) /* I - Character to test */
107 return (ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch == '\t' ||
111 _CUPS_INLINE int /* O - 1 on match, 0 otherwise */
112 _cups_isupper(int ch) /* I - Character to test */
114 return (ch >= 'A' && ch <= 'Z');
117 _CUPS_INLINE int /* O - Converted character */
118 _cups_tolower(int ch) /* I - Character to convert */
120 return (_cups_isupper(ch) ? ch - 'A' + 'a' : ch);
123 extern int _cups_isalnum(int ch);
124 extern int _cups_isalpha(int ch);
125 extern int _cups_isspace(int ch);
126 extern int _cups_isupper(int ch);
127 extern int _cups_tolower(int ch);
128 # endif /* _CUPS_INLINE */
135 extern void _cups_strcpy(char *dst, const char *src);
138 extern char *_cups_strdup(const char *);
139 # define strdup _cups_strdup
140 # endif /* !HAVE_STRDUP */
142 extern int _cups_strcasecmp(const char *, const char *);
144 extern int _cups_strncasecmp(const char *, const char *, size_t n);
146 # ifndef HAVE_STRLCAT
147 extern size_t _cups_strlcat(char *, const char *, size_t);
148 # define strlcat _cups_strlcat
149 # endif /* !HAVE_STRLCAT */
151 # ifndef HAVE_STRLCPY
152 extern size_t _cups_strlcpy(char *, const char *, size_t);
153 # define strlcpy _cups_strlcpy
154 # endif /* !HAVE_STRLCPY */
156 # ifndef HAVE_SNPRINTF
157 extern int _cups_snprintf(char *, size_t, const char *, ...)
158 __attribute__ ((__format__ (__printf__, 3, 4)));
159 # define snprintf _cups_snprintf
160 # endif /* !HAVE_SNPRINTF */
162 # ifndef HAVE_VSNPRINTF
163 extern int _cups_vsnprintf(char *, size_t, const char *, va_list);
164 # define vsnprintf _cups_vsnprintf
165 # endif /* !HAVE_VSNPRINTF */
168 * String pool functions...
171 extern char *_cupsStrAlloc(const char *s);
172 extern void _cupsStrFlush(void);
173 extern void _cupsStrFree(const char *s);
174 extern char *_cupsStrRetain(const char *s);
175 extern size_t _cupsStrStatistics(size_t *alloc_bytes, size_t *total_bytes);
179 * Floating point number functions...
182 extern char *_cupsStrFormatd(char *buf, char *bufend, double number,
184 extern double _cupsStrScand(const char *buf, char **bufptr,
194 # endif /* __cplusplus */
196 #endif /* !_CUPS_STRING_H_ */
199 * End of "$Id: string-private.h 11173 2013-07-23 12:31:34Z msweet $".