/src/libcups/cups/string-private.h
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // Private string definitions for CUPS. |
3 | | // |
4 | | // Copyright © 2021-2023 by OpenPrinting. |
5 | | // Copyright © 2007-2018 by Apple Inc. |
6 | | // Copyright © 1997-2006 by Easy Software Products. |
7 | | // |
8 | | // Licensed under Apache License v2.0. See the file "LICENSE" for more |
9 | | // information. |
10 | | // |
11 | | |
12 | | #ifndef _CUPS_STRING_PRIVATE_H_ |
13 | | # define _CUPS_STRING_PRIVATE_H_ |
14 | | # include "config.h" |
15 | | # include "base.h" |
16 | | # include <stdio.h> |
17 | | # include <stdlib.h> |
18 | | # include <stdarg.h> |
19 | | # include <string.h> |
20 | | # include <ctype.h> |
21 | | # include <errno.h> |
22 | | # include <locale.h> |
23 | | # include <time.h> |
24 | | # ifdef __cplusplus |
25 | | extern "C" { |
26 | | # endif // __cplusplus |
27 | | |
28 | | |
29 | | // |
30 | | // String pool structures... |
31 | | // |
32 | | |
33 | | # define _CUPS_STR_GUARD 0x12344321 |
34 | | |
35 | | typedef struct _cups_sp_item_s // String Pool Item |
36 | | { |
37 | | # ifdef DEBUG_GUARDS |
38 | | unsigned int guard; // Guard word |
39 | | # endif // DEBUG_GUARDS |
40 | | unsigned int ref_count; // Reference count |
41 | | char str[1]; // String |
42 | | } _cups_sp_item_t; |
43 | | |
44 | | |
45 | | // |
46 | | // Replacements for the ctype macros that are not affected by locale, since we |
47 | | // really only care about testing for ASCII characters when parsing files, etc. |
48 | | // |
49 | | // The _CUPS_INLINE definition controls whether we get an inline function body, |
50 | | // and external function body, or an external definition. |
51 | | // |
52 | | |
53 | | # if defined(__GNUC__) || __STDC_VERSION__ >= 199901L |
54 | | # define _CUPS_INLINE static inline |
55 | | # elif defined(_MSC_VER) |
56 | | # define _CUPS_INLINE static __inline |
57 | | # elif defined(_CUPS_STRING_C_) |
58 | | # define _CUPS_INLINE |
59 | | # endif // __GNUC__ || __STDC_VERSION__ |
60 | | |
61 | | # ifdef _CUPS_INLINE |
62 | | _CUPS_INLINE int // O - 1 on match, 0 otherwise |
63 | | _cups_isalnum(int ch) // I - Character to test |
64 | 14 | { |
65 | 14 | return ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')); |
66 | 14 | } Unexecuted instantiation: fuzzipp.c:_cups_isalnum Unexecuted instantiation: ipp.c:_cups_isalnum Unexecuted instantiation: globals.c:_cups_isalnum Unexecuted instantiation: thread.c:_cups_isalnum Unexecuted instantiation: usersys.c:_cups_isalnum Unexecuted instantiation: file.c:_cups_isalnum Unexecuted instantiation: http-addr.c:_cups_isalnum Unexecuted instantiation: string.c:_cups_isalnum Unexecuted instantiation: array.c:_cups_isalnum Unexecuted instantiation: http.c:_cups_isalnum Unexecuted instantiation: request.c:_cups_isalnum langprintf.c:_cups_isalnum Line | Count | Source | 64 | 14 | { | 65 | 14 | return ((ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')); | 66 | 14 | } |
Unexecuted instantiation: language.c:_cups_isalnum Unexecuted instantiation: transcode.c:_cups_isalnum Unexecuted instantiation: ipp-support.c:_cups_isalnum Unexecuted instantiation: http-support.c:_cups_isalnum Unexecuted instantiation: hash.c:_cups_isalnum Unexecuted instantiation: md5.c:_cups_isalnum Unexecuted instantiation: dnssd.c:_cups_isalnum Unexecuted instantiation: options.c:_cups_isalnum Unexecuted instantiation: http-addrlist.c:_cups_isalnum Unexecuted instantiation: auth.c:_cups_isalnum Unexecuted instantiation: tls.c:_cups_isalnum Unexecuted instantiation: dir.c:_cups_isalnum |
67 | | |
68 | | _CUPS_INLINE int // O - 1 on match, 0 otherwise |
69 | | _cups_isalpha(int ch) // I - Character to test |
70 | 0 | { |
71 | 0 | return ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')); |
72 | 0 | } Unexecuted instantiation: fuzzipp.c:_cups_isalpha Unexecuted instantiation: ipp.c:_cups_isalpha Unexecuted instantiation: globals.c:_cups_isalpha Unexecuted instantiation: thread.c:_cups_isalpha Unexecuted instantiation: usersys.c:_cups_isalpha Unexecuted instantiation: file.c:_cups_isalpha Unexecuted instantiation: http-addr.c:_cups_isalpha Unexecuted instantiation: string.c:_cups_isalpha Unexecuted instantiation: array.c:_cups_isalpha Unexecuted instantiation: http.c:_cups_isalpha Unexecuted instantiation: request.c:_cups_isalpha Unexecuted instantiation: langprintf.c:_cups_isalpha Unexecuted instantiation: language.c:_cups_isalpha Unexecuted instantiation: transcode.c:_cups_isalpha Unexecuted instantiation: ipp-support.c:_cups_isalpha Unexecuted instantiation: http-support.c:_cups_isalpha Unexecuted instantiation: hash.c:_cups_isalpha Unexecuted instantiation: md5.c:_cups_isalpha Unexecuted instantiation: dnssd.c:_cups_isalpha Unexecuted instantiation: options.c:_cups_isalpha Unexecuted instantiation: http-addrlist.c:_cups_isalpha Unexecuted instantiation: auth.c:_cups_isalpha Unexecuted instantiation: tls.c:_cups_isalpha Unexecuted instantiation: dir.c:_cups_isalpha |
73 | | |
74 | | _CUPS_INLINE int // O - 1 on match, 0 otherwise |
75 | | _cups_islower(int ch) // I - Character to test |
76 | 0 | { |
77 | 0 | return (ch >= 'a' && ch <= 'z'); |
78 | 0 | } Unexecuted instantiation: fuzzipp.c:_cups_islower Unexecuted instantiation: ipp.c:_cups_islower Unexecuted instantiation: globals.c:_cups_islower Unexecuted instantiation: thread.c:_cups_islower Unexecuted instantiation: usersys.c:_cups_islower Unexecuted instantiation: file.c:_cups_islower Unexecuted instantiation: http-addr.c:_cups_islower Unexecuted instantiation: string.c:_cups_islower Unexecuted instantiation: array.c:_cups_islower Unexecuted instantiation: http.c:_cups_islower Unexecuted instantiation: request.c:_cups_islower Unexecuted instantiation: langprintf.c:_cups_islower Unexecuted instantiation: language.c:_cups_islower Unexecuted instantiation: transcode.c:_cups_islower Unexecuted instantiation: ipp-support.c:_cups_islower Unexecuted instantiation: http-support.c:_cups_islower Unexecuted instantiation: hash.c:_cups_islower Unexecuted instantiation: md5.c:_cups_islower Unexecuted instantiation: dnssd.c:_cups_islower Unexecuted instantiation: options.c:_cups_islower Unexecuted instantiation: http-addrlist.c:_cups_islower Unexecuted instantiation: auth.c:_cups_islower Unexecuted instantiation: tls.c:_cups_islower Unexecuted instantiation: dir.c:_cups_islower |
79 | | |
80 | | _CUPS_INLINE int // O - 1 on match, 0 otherwise |
81 | | _cups_isspace(int ch) // I - Character to test |
82 | 0 | { |
83 | 0 | return (ch == ' ' || ch == '\f' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\v'); |
84 | 0 | } Unexecuted instantiation: fuzzipp.c:_cups_isspace Unexecuted instantiation: ipp.c:_cups_isspace Unexecuted instantiation: globals.c:_cups_isspace Unexecuted instantiation: thread.c:_cups_isspace Unexecuted instantiation: usersys.c:_cups_isspace Unexecuted instantiation: file.c:_cups_isspace Unexecuted instantiation: http-addr.c:_cups_isspace Unexecuted instantiation: string.c:_cups_isspace Unexecuted instantiation: array.c:_cups_isspace Unexecuted instantiation: http.c:_cups_isspace Unexecuted instantiation: request.c:_cups_isspace Unexecuted instantiation: langprintf.c:_cups_isspace Unexecuted instantiation: language.c:_cups_isspace Unexecuted instantiation: transcode.c:_cups_isspace Unexecuted instantiation: ipp-support.c:_cups_isspace Unexecuted instantiation: http-support.c:_cups_isspace Unexecuted instantiation: hash.c:_cups_isspace Unexecuted instantiation: md5.c:_cups_isspace Unexecuted instantiation: dnssd.c:_cups_isspace Unexecuted instantiation: options.c:_cups_isspace Unexecuted instantiation: http-addrlist.c:_cups_isspace Unexecuted instantiation: auth.c:_cups_isspace Unexecuted instantiation: tls.c:_cups_isspace Unexecuted instantiation: dir.c:_cups_isspace |
85 | | |
86 | | _CUPS_INLINE int // O - 1 on match, 0 otherwise |
87 | | _cups_isupper(int ch) // I - Character to test |
88 | 84.0k | { |
89 | 84.0k | return (ch >= 'A' && ch <= 'Z'); |
90 | 84.0k | } Unexecuted instantiation: fuzzipp.c:_cups_isupper Line | Count | Source | 88 | 48.6k | { | 89 | 48.6k | return (ch >= 'A' && ch <= 'Z'); | 90 | 48.6k | } |
Unexecuted instantiation: globals.c:_cups_isupper Unexecuted instantiation: thread.c:_cups_isupper Unexecuted instantiation: usersys.c:_cups_isupper Unexecuted instantiation: file.c:_cups_isupper Unexecuted instantiation: http-addr.c:_cups_isupper Line | Count | Source | 88 | 35.4k | { | 89 | 35.4k | return (ch >= 'A' && ch <= 'Z'); | 90 | 35.4k | } |
Unexecuted instantiation: array.c:_cups_isupper Unexecuted instantiation: http.c:_cups_isupper Unexecuted instantiation: request.c:_cups_isupper Unexecuted instantiation: langprintf.c:_cups_isupper Unexecuted instantiation: language.c:_cups_isupper Unexecuted instantiation: transcode.c:_cups_isupper Unexecuted instantiation: ipp-support.c:_cups_isupper Unexecuted instantiation: http-support.c:_cups_isupper Unexecuted instantiation: hash.c:_cups_isupper Unexecuted instantiation: md5.c:_cups_isupper Unexecuted instantiation: dnssd.c:_cups_isupper Unexecuted instantiation: options.c:_cups_isupper Unexecuted instantiation: http-addrlist.c:_cups_isupper Unexecuted instantiation: auth.c:_cups_isupper Unexecuted instantiation: tls.c:_cups_isupper Unexecuted instantiation: dir.c:_cups_isupper |
91 | | |
92 | | _CUPS_INLINE int // O - Converted character |
93 | | _cups_tolower(int ch) // I - Character to convert |
94 | 84.0k | { |
95 | 84.0k | return (_cups_isupper(ch) ? ch - 'A' + 'a' : ch); |
96 | 84.0k | } Unexecuted instantiation: fuzzipp.c:_cups_tolower Line | Count | Source | 94 | 48.6k | { | 95 | 48.6k | return (_cups_isupper(ch) ? ch - 'A' + 'a' : ch); | 96 | 48.6k | } |
Unexecuted instantiation: globals.c:_cups_tolower Unexecuted instantiation: thread.c:_cups_tolower Unexecuted instantiation: usersys.c:_cups_tolower Unexecuted instantiation: file.c:_cups_tolower Unexecuted instantiation: http-addr.c:_cups_tolower Line | Count | Source | 94 | 35.4k | { | 95 | 35.4k | return (_cups_isupper(ch) ? ch - 'A' + 'a' : ch); | 96 | 35.4k | } |
Unexecuted instantiation: array.c:_cups_tolower Unexecuted instantiation: http.c:_cups_tolower Unexecuted instantiation: request.c:_cups_tolower Unexecuted instantiation: langprintf.c:_cups_tolower Unexecuted instantiation: language.c:_cups_tolower Unexecuted instantiation: transcode.c:_cups_tolower Unexecuted instantiation: ipp-support.c:_cups_tolower Unexecuted instantiation: http-support.c:_cups_tolower Unexecuted instantiation: hash.c:_cups_tolower Unexecuted instantiation: md5.c:_cups_tolower Unexecuted instantiation: dnssd.c:_cups_tolower Unexecuted instantiation: options.c:_cups_tolower Unexecuted instantiation: http-addrlist.c:_cups_tolower Unexecuted instantiation: auth.c:_cups_tolower Unexecuted instantiation: tls.c:_cups_tolower Unexecuted instantiation: dir.c:_cups_tolower |
97 | | |
98 | | _CUPS_INLINE int // O - Converted character |
99 | | _cups_toupper(int ch) // I - Character to convert |
100 | 0 | { |
101 | 0 | return (_cups_islower(ch) ? ch - 'a' + 'A' : ch); |
102 | 0 | } Unexecuted instantiation: fuzzipp.c:_cups_toupper Unexecuted instantiation: ipp.c:_cups_toupper Unexecuted instantiation: globals.c:_cups_toupper Unexecuted instantiation: thread.c:_cups_toupper Unexecuted instantiation: usersys.c:_cups_toupper Unexecuted instantiation: file.c:_cups_toupper Unexecuted instantiation: http-addr.c:_cups_toupper Unexecuted instantiation: string.c:_cups_toupper Unexecuted instantiation: array.c:_cups_toupper Unexecuted instantiation: http.c:_cups_toupper Unexecuted instantiation: request.c:_cups_toupper Unexecuted instantiation: langprintf.c:_cups_toupper Unexecuted instantiation: language.c:_cups_toupper Unexecuted instantiation: transcode.c:_cups_toupper Unexecuted instantiation: ipp-support.c:_cups_toupper Unexecuted instantiation: http-support.c:_cups_toupper Unexecuted instantiation: hash.c:_cups_toupper Unexecuted instantiation: md5.c:_cups_toupper Unexecuted instantiation: dnssd.c:_cups_toupper Unexecuted instantiation: options.c:_cups_toupper Unexecuted instantiation: http-addrlist.c:_cups_toupper Unexecuted instantiation: auth.c:_cups_toupper Unexecuted instantiation: tls.c:_cups_toupper Unexecuted instantiation: dir.c:_cups_toupper |
103 | | # else |
104 | | extern int _cups_isalnum(int ch); |
105 | | extern int _cups_isalpha(int ch); |
106 | | extern int _cups_islower(int ch); |
107 | | extern int _cups_isspace(int ch); |
108 | | extern int _cups_isupper(int ch); |
109 | | extern int _cups_tolower(int ch); |
110 | | extern int _cups_toupper(int ch); |
111 | | # endif // _CUPS_INLINE |
112 | | |
113 | | |
114 | | // |
115 | | // Prototypes... |
116 | | // |
117 | | |
118 | | extern ssize_t _cups_safe_vsnprintf(char *buffer, size_t bufsize, const char *format, va_list args) _CUPS_PRIVATE; |
119 | | extern void _cups_strcpy(char *dst, const char *src) _CUPS_PRIVATE; |
120 | | extern int _cups_strcasecmp(const char *, const char *) _CUPS_PRIVATE; |
121 | | extern int _cups_strncasecmp(const char *, const char *, size_t n) _CUPS_PRIVATE; |
122 | | |
123 | | extern char *_cupsStrAlloc(const char *s) _CUPS_PRIVATE; |
124 | | extern void _cupsStrFlush(void) _CUPS_PRIVATE; |
125 | | extern void _cupsStrFree(const char *s) _CUPS_PRIVATE; |
126 | | extern char *_cupsStrRetain(const char *s) _CUPS_PRIVATE; |
127 | | extern size_t _cupsStrStatistics(size_t *alloc_bytes, size_t *total_bytes) _CUPS_PRIVATE; |
128 | | extern char *_cupsStrFormatd(char *buf, char *bufend, double number, struct lconv *loc) _CUPS_PRIVATE; |
129 | | extern double _cupsStrScand(const char *buf, char **bufptr, struct lconv *loc) _CUPS_PRIVATE; |
130 | | |
131 | | |
132 | | # ifdef __cplusplus |
133 | | } |
134 | | # endif // __cplusplus |
135 | | #endif // !_CUPS_STRING_PRIVATE_H_ |