forked from abeluck/stegdetect
-
Notifications
You must be signed in to change notification settings - Fork 11
/
rpp.h
76 lines (58 loc) · 1.54 KB
/
rpp.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
72
73
74
75
76
/*
* This file is part of John the Ripper password cracker,
* Copyright (c) 1996-98 by Solar Designer
*/
/*
* Rules preprocessor.
*/
#ifndef _JOHN_RPP_H
#define _JOHN_RPP_H
#include "cfg.h"
#define RULE_BUFFER_SIZE 0x100
#define RULE_RANGES_MAX 8
#define RULE_WORD_SIZE 0x80
#define SECTION_RULES "List.Rules:"
#define SUBSECTION_SINGLE "Single"
#define SUBSECTION_WORDLIST "Wordlist"
#define ARCH_WORD u_int32_t
#define ARCH_BITS 32
#define ARCH_INDEX u_int32_t
/*
* Character range.
*/
struct rpp_range {
/* Character position in output rule */
char *pos;
/* Number of character values */
int count;
/* Current character value index */
int index;
/* Present characters bitmask for dupe checking */
ARCH_WORD mask[0x100 / ARCH_BITS];
/* Character values */
char chars[0x100];
};
/*
* Preprocessor context.
*/
struct rpp_context {
/* Current rule before preprocessing */
struct cfg_line *input;
/* Current rule after preprocessing */
char output[RULE_BUFFER_SIZE];
/* Number of character ranges in this rule */
int count;
/* Character ranges. I really hate to do it this way, but otherwise context
* management would be far more complicated. */
struct rpp_range ranges[RULE_RANGES_MAX];
};
/*
* Initializes the preprocessor's context for the supplied configuration file
* rules subsection. Returns a non-zero value on error (no rules found).
*/
extern int rpp_init(struct rpp_context *ctx, char *subsection);
/*
* Returns a preprocessed rule and moves to the next one.
*/
extern char *rpp_next(struct rpp_context *ctx);
#endif