dpkg
1.21.11
lib
dpkg
c-ctype.h
Go to the documentation of this file.
1
/*
2
* libdpkg - Debian packaging suite library routines
3
* c-ctype.h - ASCII C locale-only functions
4
*
5
* Copyright © 2009-2014 Guillem Jover <guillem@debian.org>
6
*
7
* This is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19
*/
20
21
#ifndef LIBDPKG_C_CTYPE_H
22
#define LIBDPKG_C_CTYPE_H
23
24
#include <stdbool.h>
25
26
#include <
dpkg/macros.h
>
27
28
DPKG_BEGIN_DECLS
29
30
#define C_CTYPE_BIT(bit) (1 << (bit))
31
32
enum
c_ctype_bit
{
33
C_CTYPE_BLANK
=
C_CTYPE_BIT
(0),
34
C_CTYPE_WHITE
=
C_CTYPE_BIT
(1),
35
C_CTYPE_SPACE
=
C_CTYPE_BIT
(2),
36
C_CTYPE_UPPER
=
C_CTYPE_BIT
(3),
37
C_CTYPE_LOWER
=
C_CTYPE_BIT
(4),
38
C_CTYPE_DIGIT
=
C_CTYPE_BIT
(5),
39
40
C_CTYPE_ALPHA
=
C_CTYPE_UPPER
|
C_CTYPE_LOWER
,
41
C_CTYPE_ALNUM
=
C_CTYPE_ALPHA
|
C_CTYPE_DIGIT
,
42
};
43
44
bool
45
c_isbits
(
int
c,
enum
c_ctype_bit
bits);
46
50
static
inline
bool
51
c_isblank(
int
c)
52
{
53
return
c_isbits
(c,
C_CTYPE_BLANK
);
54
}
55
59
static
inline
bool
60
c_iswhite(
int
c)
61
{
62
return
c_isbits
(c,
C_CTYPE_WHITE
);
63
}
64
68
static
inline
bool
69
c_isspace(
int
c)
70
{
71
return
c_isbits
(c,
C_CTYPE_SPACE
);
72
}
73
77
static
inline
bool
78
c_isdigit(
int
c)
79
{
80
return
c_isbits
(c,
C_CTYPE_DIGIT
);
81
}
82
86
static
inline
bool
87
c_isupper(
int
c)
88
{
89
return
c_isbits
(c,
C_CTYPE_UPPER
);
90
}
91
95
static
inline
bool
96
c_islower(
int
c)
97
{
98
return
c_isbits
(c,
C_CTYPE_LOWER
);
99
}
100
104
static
inline
bool
105
c_isalpha(
int
c)
106
{
107
return
c_isbits
(c,
C_CTYPE_ALPHA
);
108
}
109
113
static
inline
bool
114
c_isalnum(
int
c)
115
{
116
return
c_isbits
(c,
C_CTYPE_ALNUM
);
117
}
118
122
static
inline
int
123
c_tolower(
int
c)
124
{
125
return
(c_isupper(c) ?
126
(
DPKG_STATIC_CAST
(
unsigned
char
, c) & ~0x20) | 0x20 : c);
127
}
128
129
DPKG_END_DECLS
130
131
#endif
c_ctype_bit
c_ctype_bit
Definition:
c-ctype.h:32
C_CTYPE_ALPHA
@ C_CTYPE_ALPHA
Definition:
c-ctype.h:40
C_CTYPE_WHITE
@ C_CTYPE_WHITE
Definition:
c-ctype.h:34
C_CTYPE_ALNUM
@ C_CTYPE_ALNUM
Definition:
c-ctype.h:41
C_CTYPE_BLANK
@ C_CTYPE_BLANK
Definition:
c-ctype.h:33
C_CTYPE_LOWER
@ C_CTYPE_LOWER
Definition:
c-ctype.h:37
C_CTYPE_SPACE
@ C_CTYPE_SPACE
Definition:
c-ctype.h:35
C_CTYPE_UPPER
@ C_CTYPE_UPPER
Definition:
c-ctype.h:36
C_CTYPE_DIGIT
@ C_CTYPE_DIGIT
Definition:
c-ctype.h:38
c_isbits
bool c_isbits(int c, enum c_ctype_bit bits)
Check if the character is bits ctype.
Definition:
c-ctype.c:183
C_CTYPE_BIT
#define C_CTYPE_BIT(bit)
Definition:
c-ctype.h:30
DPKG_BEGIN_DECLS
#define DPKG_BEGIN_DECLS
Definition:
macros.h:86
DPKG_END_DECLS
#define DPKG_END_DECLS
Definition:
macros.h:87
DPKG_STATIC_CAST
#define DPKG_STATIC_CAST(type, expr)
Cast an expression to a given type that works on C or C++.
Definition:
macros.h:117
macros.h
Generated by
1.9.4