1// Copyright 2016 The Fuchsia Authors
2// Copyright (c) 2008 Travis Geiselbrecht
3//
4// Use of this source code is governed by a MIT-style
5// license that can be found in the LICENSE file or at
6// https://opensource.org/licenses/MIT
7
8#include <ctype.h>
9
10int isblank(int c)
11{
12    return (c == ' ' || c == '\t');
13}
14
15int isspace(int c)
16{
17    return (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v');
18}
19
20int islower(int c)
21{
22    return ((c >= 'a') && (c <= 'z'));
23}
24
25int isupper(int c)
26{
27    return ((c >= 'A') && (c <= 'Z'));
28}
29
30int isdigit(int c)
31{
32    return ((c >= '0') && (c <= '9'));
33}
34
35int isalpha(int c)
36{
37    return isupper(c) || islower(c);
38}
39
40int isalnum(int c)
41{
42    return isalpha(c) || isdigit(c);
43}
44
45int isxdigit(int c)
46{
47    return isdigit(c) || ((c >= 'a') && (c <= 'f')) || ((c >= 'A') && (c <= 'F'));
48}
49
50int isgraph(int c)
51{
52    return ((c > ' ') && (c < 0x7f));
53}
54
55int iscntrl(int c)
56{
57    return ((c < ' ') || (c == 0x7f));
58}
59
60int isprint(int c)
61{
62    return ((c >= 0x20) && (c < 0x7f));
63}
64
65int ispunct(int c)
66{
67    return isgraph(c) && (!isalnum(c));
68}
69
70int tolower(int c)
71{
72    if ((c >= 'A') && (c <= 'Z'))
73        return c + ('a' - 'A');
74    return c;
75}
76
77int toupper(int c)
78{
79    if ((c >= 'a') && (c <= 'z'))
80        return c + ('A' - 'a');
81    return c;
82}
83
84