-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.h
71 lines (61 loc) · 1.37 KB
/
parser.h
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
#ifndef PARSER_H__
#define PARSER_H__
/*
bf_new definitions
*/
#define VERSION "0.2.8"
#define FILESAVE ".bf.save"
#define MAX_ELEM (256 /8)
#define MIN_STRUCT_ALIGNMENT 8
#ifdef DEBUG
#define DPRINTF printf
#else
#define DPRINTF(...)
#endif
#define MARKER_ON fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 2, 37, 40); // Set MARK on
#define MARKER_OFF fprintf(stderr, "%c[%d;%d;%dm", 0x1B, 0, 0, 0); // Revert back
typedef signed char s8;
typedef unsigned char u8;
typedef unsigned int u32;
typedef unsigned long long int u64;
typedef struct
__attribute__((packed, aligned(MIN_STRUCT_ALIGNMENT)))
{
u8 *word; // working word
u8 **idx; // many charset
u8 wlen; // word length = num of charsets
u8 mode; // requested mode (CHAR | HEX)
s8 work; // lock/sync for signals
u8 out_m; // output mode flag
u32 numw; // max num of words
} ctx;
enum flags
{
// for main mode
CHAR,
HEX,
// for scan() mode
PRINT,
IS_HEX,
FIND,
COUNT,
HEXDUMP,
MARK_ONE,
MARK_ALL,
// for output mode
BIN,
WORDLIST,
DRY_RUN, // default
QUIET,
// for signals
DONE,
DUMP,
INTR
};
void bin2stdout(ctx * const p);
void dump_matrix(ctx * const p);
void cleanup(ctx *p);
s8 parse_opt (int argc, char **argv, ctx *ctx);
s8 scan(const u8 *item, const u8 *l, const u8 smode, const u8 *dst);
s8 parse_file(ctx *ctx);
#endif // PARSER_H__