]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/crypto/ctype.h
Fix header file include guard names
[thirdparty/openssl.git] / include / crypto / ctype.h
CommitLineData
a1df06b3
P
1/*
2 * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
a1df06b3
P
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10/*
11 * This version of ctype.h provides a standardised and platform
12 * independent implementation that supports seven bit ASCII characters.
13 * The specific intent is to not pass extended ASCII characters (> 127)
14 * even if the host operating system would.
15 *
16 * There is EBCDIC support included for machines which use this. However,
17 * there are a number of concerns about how well EBCDIC is supported
18 * throughout the rest of the source code. Refer to issue #4154 for
19 * details.
20 */
ae4186b0
DMSP
21#ifndef OSSL_CRYPTO_CTYPE_H
22# define OSSL_CRYPTO_CTYPE_H
a1df06b3
P
23
24# define CTYPE_MASK_lower 0x1
25# define CTYPE_MASK_upper 0x2
26# define CTYPE_MASK_digit 0x4
27# define CTYPE_MASK_space 0x8
28# define CTYPE_MASK_xdigit 0x10
29# define CTYPE_MASK_blank 0x20
30# define CTYPE_MASK_cntrl 0x40
31# define CTYPE_MASK_graph 0x80
32# define CTYPE_MASK_print 0x100
33# define CTYPE_MASK_punct 0x200
34# define CTYPE_MASK_base64 0x400
35# define CTYPE_MASK_asn1print 0x800
36
37# define CTYPE_MASK_alpha (CTYPE_MASK_lower | CTYPE_MASK_upper)
38# define CTYPE_MASK_alnum (CTYPE_MASK_alpha | CTYPE_MASK_digit)
39
40/*
41 * The ascii mask assumes that any other classification implies that
42 * the character is ASCII and that there are no ASCII characters
43 * that aren't in any of the classifications.
44 *
45 * This assumption holds at the moment, but it might not in the future.
46 */
47# define CTYPE_MASK_ascii (~0)
48
49# ifdef CHARSET_EBCDIC
50int ossl_toascii(int c);
51int ossl_fromascii(int c);
52# else
53# define ossl_toascii(c) (c)
54# define ossl_fromascii(c) (c)
55# endif
56int ossl_ctype_check(int c, unsigned int mask);
57int ossl_tolower(int c);
58int ossl_toupper(int c);
59
48102247 60int ascii_isdigit(const char inchar);
61
a1df06b3
P
62# define ossl_isalnum(c) (ossl_ctype_check((c), CTYPE_MASK_alnum))
63# define ossl_isalpha(c) (ossl_ctype_check((c), CTYPE_MASK_alpha))
64# ifdef CHARSET_EBCDIC
65# define ossl_isascii(c) (ossl_ctype_check((c), CTYPE_MASK_ascii))
66# else
67# define ossl_isascii(c) (((c) & ~127) == 0)
68# endif
69# define ossl_isblank(c) (ossl_ctype_check((c), CTYPE_MASK_blank))
70# define ossl_iscntrl(c) (ossl_ctype_check((c), CTYPE_MASK_cntrl))
71# define ossl_isdigit(c) (ossl_ctype_check((c), CTYPE_MASK_digit))
72# define ossl_isgraph(c) (ossl_ctype_check((c), CTYPE_MASK_graph))
73# define ossl_islower(c) (ossl_ctype_check((c), CTYPE_MASK_lower))
74# define ossl_isprint(c) (ossl_ctype_check((c), CTYPE_MASK_print))
75# define ossl_ispunct(c) (ossl_ctype_check((c), CTYPE_MASK_punct))
76# define ossl_isspace(c) (ossl_ctype_check((c), CTYPE_MASK_space))
77# define ossl_isupper(c) (ossl_ctype_check((c), CTYPE_MASK_upper))
78# define ossl_isxdigit(c) (ossl_ctype_check((c), CTYPE_MASK_xdigit))
79# define ossl_isbase64(c) (ossl_ctype_check((c), CTYPE_MASK_base64))
80# define ossl_isasn1print(c) (ossl_ctype_check((c), CTYPE_MASK_asn1print))
81
82#endif