]> git.ipfire.org Git - thirdparty/cups.git/blame - cups/string-private.h
Update ipp documentation to reflect the behavior of configuring WiFi on IPP USB printers.
[thirdparty/cups.git] / cups / string-private.h
CommitLineData
ef416fc2 1/*
554aa7b7 2 * Private string definitions for CUPS.
ef416fc2 3 *
be3b49a3
MS
4 * Copyright © 2007-2018 by Apple Inc.
5 * Copyright © 1997-2006 by Easy Software Products.
ef416fc2 6 *
be3b49a3
MS
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more
8 * information.
ef416fc2 9 */
10
71e16022
MS
11#ifndef _CUPS_STRING_PRIVATE_H_
12# define _CUPS_STRING_PRIVATE_H_
ef416fc2 13
14/*
15 * Include necessary headers...
16 */
17
d3a97696 18# include "config.h"
ef416fc2 19# include <stdio.h>
a74454a7 20# include <stdlib.h>
ef416fc2 21# include <stdarg.h>
22# include <ctype.h>
71e16022 23# include <errno.h>
757d2cad 24# include <locale.h>
554aa7b7 25# include <time.h>
ef416fc2 26
e3586875 27# include <cups/versioning.h>
a74454a7 28
ef416fc2 29# ifdef HAVE_STRING_H
30# include <string.h>
31# endif /* HAVE_STRING_H */
32
33# ifdef HAVE_STRINGS_H
34# include <strings.h>
35# endif /* HAVE_STRINGS_H */
36
37# ifdef HAVE_BSTRING_H
38# include <bstring.h>
39# endif /* HAVE_BSTRING_H */
40
19dc16f7 41# if defined(_WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
21aa3f37
MS
42# define __CUPS_SSIZE_T_DEFINED
43# include <stddef.h>
44/* Windows does not support the ssize_t type, so map it to long... */
45typedef long ssize_t; /* @private@ */
19dc16f7 46# endif /* _WIN32 && !__CUPS_SSIZE_T_DEFINED */
21aa3f37 47
ef416fc2 48
ef416fc2 49/*
50 * C++ magic...
51 */
52
53# ifdef __cplusplus
54extern "C" {
55# endif /* __cplusplus */
56
57
4400e98d 58/*
59 * String pool structures...
60 */
61
745129be
MS
62# define _CUPS_STR_GUARD 0x12344321
63
4400e98d 64typedef struct _cups_sp_item_s /**** String Pool Item ****/
65{
745129be
MS
66# ifdef DEBUG_GUARDS
67 unsigned int guard; /* Guard word */
68# endif /* DEBUG_GUARDS */
4400e98d 69 unsigned int ref_count; /* Reference count */
426c6a59 70 char str[1]; /* String */
4400e98d 71} _cups_sp_item_t;
72
73
7cf5915e
MS
74/*
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.
7cf5915e
MS
77 *
78 * The _CUPS_INLINE definition controls whether we get an inline function body,
79 * and external function body, or an external definition.
80 */
81
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_)
87# define _CUPS_INLINE
88# endif /* __GNUC__ || __STDC_VERSION__ */
89
90# ifdef _CUPS_INLINE
91_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
92_cups_isalnum(int ch) /* I - Character to test */
93{
94 return ((ch >= '0' && ch <= '9') ||
95 (ch >= 'A' && ch <= 'Z') ||
96 (ch >= 'a' && ch <= 'z'));
97}
98
99_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
100_cups_isalpha(int ch) /* I - Character to test */
101{
102 return ((ch >= 'A' && ch <= 'Z') ||
103 (ch >= 'a' && ch <= 'z'));
104}
105
2d0a0f48
MS
106_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
107_cups_islower(int ch) /* I - Character to test */
108{
109 return (ch >= 'a' && ch <= 'z');
110}
111
7cf5915e
MS
112_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
113_cups_isspace(int ch) /* I - Character to test */
114{
115 return (ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch == '\t' ||
116 ch == '\v');
117}
118
119_CUPS_INLINE int /* O - 1 on match, 0 otherwise */
120_cups_isupper(int ch) /* I - Character to test */
121{
122 return (ch >= 'A' && ch <= 'Z');
123}
88f9aafc
MS
124
125_CUPS_INLINE int /* O - Converted character */
126_cups_tolower(int ch) /* I - Character to convert */
127{
128 return (_cups_isupper(ch) ? ch - 'A' + 'a' : ch);
129}
2d0a0f48
MS
130
131_CUPS_INLINE int /* O - Converted character */
132_cups_toupper(int ch) /* I - Character to convert */
133{
134 return (_cups_islower(ch) ? ch - 'a' + 'A' : ch);
135}
7cf5915e
MS
136# else
137extern int _cups_isalnum(int ch);
138extern int _cups_isalpha(int ch);
2d0a0f48 139extern int _cups_islower(int ch);
7cf5915e
MS
140extern int _cups_isspace(int ch);
141extern int _cups_isupper(int ch);
88f9aafc 142extern int _cups_tolower(int ch);
2d0a0f48 143extern int _cups_toupper(int ch);
7cf5915e
MS
144# endif /* _CUPS_INLINE */
145
146
ef416fc2 147/*
148 * Prototypes...
149 */
150
d3a97696 151extern ssize_t _cups_safe_vsnprintf(char *buffer, size_t bufsize, const char *format, va_list args) _CUPS_PRIVATE;
e3586875 152extern void _cups_strcpy(char *dst, const char *src) _CUPS_PRIVATE;
ef416fc2 153
154# ifndef HAVE_STRDUP
e3586875 155extern char *_cups_strdup(const char *) _CUPS_PRIVATE;
ef416fc2 156# define strdup _cups_strdup
157# endif /* !HAVE_STRDUP */
158
e3586875 159extern int _cups_strcasecmp(const char *, const char *) _CUPS_PRIVATE;
ef416fc2 160
e3586875 161extern int _cups_strncasecmp(const char *, const char *, size_t n) _CUPS_PRIVATE;
ef416fc2 162
163# ifndef HAVE_STRLCAT
e3586875 164extern size_t _cups_strlcat(char *, const char *, size_t) _CUPS_PRIVATE;
ef416fc2 165# define strlcat _cups_strlcat
166# endif /* !HAVE_STRLCAT */
167
168# ifndef HAVE_STRLCPY
e3586875 169extern size_t _cups_strlcpy(char *, const char *, size_t) _CUPS_PRIVATE;
ef416fc2 170# define strlcpy _cups_strlcpy
171# endif /* !HAVE_STRLCPY */
172
173# ifndef HAVE_SNPRINTF
e3586875 174extern int _cups_snprintf(char *, size_t, const char *, ...) _CUPS_FORMAT(3, 4) _CUPS_PRIVATE;
ef416fc2 175# define snprintf _cups_snprintf
176# endif /* !HAVE_SNPRINTF */
177
178# ifndef HAVE_VSNPRINTF
e3586875 179extern int _cups_vsnprintf(char *, size_t, const char *, va_list) _CUPS_PRIVATE;
ef416fc2 180# define vsnprintf _cups_vsnprintf
181# endif /* !HAVE_VSNPRINTF */
182
4400e98d 183/*
184 * String pool functions...
185 */
186
e3586875
MS
187extern char *_cupsStrAlloc(const char *s) _CUPS_PRIVATE;
188extern void _cupsStrFlush(void) _CUPS_PRIVATE;
189extern void _cupsStrFree(const char *s) _CUPS_PRIVATE;
190extern char *_cupsStrRetain(const char *s) _CUPS_PRIVATE;
191extern size_t _cupsStrStatistics(size_t *alloc_bytes, size_t *total_bytes) _CUPS_PRIVATE;
757d2cad 192
193
194/*
195 * Floating point number functions...
196 */
197
198extern char *_cupsStrFormatd(char *buf, char *bufend, double number,
e3586875 199 struct lconv *loc) _CUPS_PRIVATE;
757d2cad 200extern double _cupsStrScand(const char *buf, char **bufptr,
e3586875 201 struct lconv *loc) _CUPS_PRIVATE;
4400e98d 202
ef416fc2 203
554aa7b7
MS
204/*
205 * Date function...
206 */
207
e3586875 208extern char *_cupsStrDate(char *buf, size_t bufsize, time_t timeval) _CUPS_PRIVATE;
554aa7b7
MS
209
210
ef416fc2 211/*
212 * C++ magic...
213 */
214
215# ifdef __cplusplus
216}
217# endif /* __cplusplus */
218
219#endif /* !_CUPS_STRING_H_ */