994
|
1 /* tools.h */
|
|
2 /*
|
|
3 * #defines for non-printing ASCII characters
|
|
4 */
|
|
5
|
|
6 #define NUL 0x00 /* ^@ */
|
|
7 #define EOS 0x00 /* end of string */
|
|
8 #define SOH 0x01 /* ^A */
|
|
9 #define STX 0x02 /* ^B */
|
|
10 #define ETX 0x03 /* ^C */
|
|
11 #define EOT 0x04 /* ^D */
|
|
12 #define ENQ 0x05 /* ^E */
|
|
13 #define ACK 0x06 /* ^F */
|
|
14 #define BEL 0x07 /* ^G */
|
|
15 #define BS 0x08 /* ^H */
|
|
16 #define HT 0x09 /* ^I */
|
|
17 #define LF 0x0a /* ^J */
|
|
18 #define NL '\n'
|
|
19 #define VT 0x0b /* ^K */
|
|
20 #define FF 0x0c /* ^L */
|
|
21 #define CR 0x0d /* ^M */
|
|
22 #define SO 0x0e /* ^N */
|
|
23 #define SI 0x0f /* ^O */
|
|
24 #define DLE 0x10 /* ^P */
|
|
25 #define DC1 0x11 /* ^Q */
|
|
26 #define DC2 0x12 /* ^R */
|
|
27 #define DC3 0x13 /* ^S */
|
|
28 #define DC4 0x14 /* ^T */
|
|
29 #define NAK 0x15 /* ^U */
|
|
30 #define SYN 0x16 /* ^V */
|
|
31 #define ETB 0x17 /* ^W */
|
|
32 #define CAN 0x18 /* ^X */
|
|
33 #define EM 0x19 /* ^Y */
|
|
34 #define SUB 0x1a /* ^Z */
|
|
35 #define ESC 0x1b /* ^[ */
|
|
36 #define FS 0x1c /* ^\ */
|
|
37 #define GS 0x1d /* ^] */
|
|
38 #define RS 0x1e /* ^^ */
|
|
39 #define US 0x1f /* ^_ */
|
|
40 #define SP 0x20 /* space */
|
|
41 #define DEL 0x7f /* DEL */
|
|
42
|
|
43 #define TRUE 1
|
|
44 #define FALSE 0
|
|
45 #define ERR -2
|
|
46
|
|
47 /* Definitions of meta-characters used in pattern matching
|
|
48 * routines. LITCHAR & NCCL are only used as token identifiers;
|
|
49 * all the others are also both token identifier and actual symbol
|
|
50 * used in the regular expression.
|
|
51 */
|
|
52
|
|
53 #define BOL '^'
|
1867
|
54 #undef EOL
|
994
|
55 #define EOL '$'
|
|
56 #define ANY '.'
|
|
57 #define LITCHAR 'L'
|
|
58 #define ESCAPE '\\'
|
|
59 #define CCL '[' /* Character class: [...] */
|
|
60 #define CCLEND ']'
|
|
61 #define NEGATE '~'
|
|
62 #define NCCL '!' /* Negative character class [^...] */
|
|
63 #define CLOSURE '*'
|
|
64 #define OR_SYM '|'
|
|
65 #define DITTO '&'
|
|
66 #define OPEN '('
|
|
67 #define CLOSE ')'
|
|
68
|
|
69 /* Largest permitted size for an expanded character class. (i.e. the class
|
|
70 * [a-z] will expand into 26 symbols; [a-z0-9] will expand into 36.)
|
|
71 */
|
|
72 #define CLS_SIZE 128
|
|
73
|
|
74 /*
|
|
75 * Tokens are used to hold pattern templates. (see makepat())
|
|
76 */
|
|
77 typedef char BITMAP;
|
|
78
|
|
79 typedef struct token {
|
|
80 char tok;
|
|
81 char lchar;
|
|
82 BITMAP *bitmap;
|
|
83 struct token *next;
|
|
84 } TOKEN;
|
|
85
|
|
86 #define TOKSIZE sizeof (TOKEN)
|
|
87
|
|
88 /*
|
|
89 * An absolute maximun for strings.
|
|
90 */
|
|
91
|
|
92 #define MAXSTR 132 /* Maximum numbers of characters in a line */
|
|
93
|
|
94 /* Macros */
|
|
95 #define max(a,b) ((a>b)?a:b)
|
|
96 #define min(a,b) ((a<b)?a:b)
|
|
97 #define toupper(c) (c>='a'&&c<='z'?c-32:c)
|
|
98
|