
#include <ctype.h>

#define NONE  0x00
#define ALPHA 0x01
#define DIGIT 0x02
#define LOWER 0x04
#define UPPER 0x08
#define SPECL 0x10
#define SPACE 0x20
#define PUNCT 0x40
#define GRAPH 0x80

// TODO.
static const unsigned char tab[256] = {
    GRAPH, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, GRAPH, GRAPH, GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, ALPHA|UPPER|SPECL,
    GRAPH|SPECL, SPECL, SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, GRAPH|SPECL, GRAPH|SPECL,
    SPACE, PUNCT|SPECL, PUNCT|SPECL, SPECL|GRAPH, SPECL, SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH,
    DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH,
    PUNCT|SPECL|GRAPH, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA,
    UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, SPECL|GRAPH|ALPHA, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH,
    PUNCT|SPECL|GRAPH, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA,
    LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH,
    DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER,
    ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER,
    ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER,
    ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER,
    ALPHA|LOWER, SPECL|GRAPH|PUNCT, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|SPECL, ALPHA|SPECL, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT,
    GRAPH, GRAPH|SPECL, GRAPH|SPECL, DIGIT|LOWER|SPECL, SPECL|GRAPH, DIGIT|LOWER|SPECL, GRAPH|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER|SPECL, ALPHA|UPPER|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER, ALPHA|UPPER|SPECL, GRAPH|SPECL, GRAPH|SPECL,
    GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL,
    GRAPH|SPECL, GRAPH|SPECL, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH
};

unsigned char isalnum(unsigned char c) {
    return tab[c] & (ALPHA | DIGIT);
}

unsigned char isalpha(unsigned char c) {
    return tab[c] & ALPHA;
}

unsigned char islower(unsigned char c) {
    return tab[c] & LOWER;
}

unsigned char isupper(unsigned char c) {
    return tab[c] & UPPER;
}

unsigned char isdigit(unsigned char c) {
    return tab[c] & DIGIT;
}

unsigned char isspecl(unsigned char c) {
    return tab[c] & SPECL;
}

unsigned char isspace(unsigned char c) {
    return tab[c] & SPACE;
}

unsigned char ispunct(unsigned char c) {
    return tab[c] & PUNCT;
}

unsigned char isgraph(unsigned char c) {
    return tab[c] & GRAPH;
}



