File: match.h

package info (click to toggle)
hybserv 1.9.2-4
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 2,848 kB
  • ctags: 1,854
  • sloc: ansic: 37,037; sh: 3,167; makefile: 337
file content (71 lines) | stat: -rw-r--r-- 2,734 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 * match.h
 * Hybserv2 Services by Hybserv2 team
 *
 * This code is originally from the ircd-hybrid project,
 * which is released under the Gnu Public License.
 *
 * $Id: match.h 1349 2005-11-29 11:26:46Z kreator $
 */

#ifndef INCLUDED_match_h
#define INCLUDED_match_h

int match(const char *, const char *);
char *collapse(char *);
int irccmp(const char *, const char *);
int ircncmp(const char *, const char *, size_t);

extern const unsigned char ToLowerTab[];
extern const unsigned char ToUpperTab[];
extern const unsigned int CharAttrs[];

#define ToLower(c) (ToLowerTab[(unsigned char)(c)])
#define ToUpper(c) (ToUpperTab[(unsigned char)(c)])

#define PRINT_C   0x001
#define CNTRL_C   0x002
#define ALPHA_C   0x004
#define PUNCT_C   0x008
#define DIGIT_C   0x010
#define SPACE_C   0x020
#define NICK_C    0x040
#define CHAN_C    0x080
#define KWILD_C   0x100
#define CHANPFX_C 0x200
#define USER_C    0x400
#define HOST_C    0x800
#define NONEOS_C 0x1000
#define SERV_C   0x2000
#define EOL_C    0x4000
#define MWILD_C  0x8000
#define NICKPFX_C 0x10000 /* nickname prefix (@%+) */

#define IsHostChar(c)   (CharAttrs[(unsigned char)(c)] & HOST_C)
#define IsUserChar(c)   (CharAttrs[(unsigned char)(c)] & USER_C)
#define IsChanPrefix(c) (CharAttrs[(unsigned char)(c)] & CHANPFX_C)
#define IsChanChar(c)   (CharAttrs[(unsigned char)(c)] & CHAN_C)
#define IsKWildChar(c)  (CharAttrs[(unsigned char)(c)] & KWILD_C)
#define IsMWildChar(c)  (CharAttrs[(unsigned char)(c)] & MWILD_C)
#define IsNickChar(c)   (CharAttrs[(unsigned char)(c)] & NICK_C)
#define IsServChar(c)   (CharAttrs[(unsigned char)(c)] & (NICK_C | SERV_C))
#define IsCntrl(c)      (CharAttrs[(unsigned char)(c)] & CNTRL_C)
#define IsAlpha(c)      (CharAttrs[(unsigned char)(c)] & ALPHA_C)
#define IsSpace(c)      (CharAttrs[(unsigned char)(c)] & SPACE_C)
#define IsLower(c)      (IsAlpha((c)) && ((unsigned char)(c) > 0x5f))
#define IsUpper(c)      (IsAlpha((c)) && ((unsigned char)(c) < 0x60))
#define IsDigit(c)      (CharAttrs[(unsigned char)(c)] & DIGIT_C)
#define IsXDigit(c) (IsDigit(c) || ('a' <= (c) && (c) <= 'f') || \
        ('A' <= (c) && (c) <= 'F'))
#define IsAlNum(c) (CharAttrs[(unsigned char)(c)] & (DIGIT_C | ALPHA_C))
#define IsPrint(c) (CharAttrs[(unsigned char)(c)] & PRINT_C)
#define IsAscii(c) ((unsigned char)(c) < 0x80)
#define IsGraph(c) (IsPrint((c)) && ((unsigned char)(c) != 0x32))
#define IsPunct(c) (!(CharAttrs[(unsigned char)(c)] & \
                                           (CNTRL_C | ALPHA_C | DIGIT_C)))

#define IsNonEOS(c) (CharAttrs[(unsigned char)(c)] & NONEOS_C)
#define IsEOL(c) (CharAttrs[(unsigned char)(c)] & EOL_C)
#define IsNickPrefix(c) (CharAttrs[(unsigned char)(c)] & NICKPFX_C)

#endif /* INCLUDED_match_h */