-
Notifications
You must be signed in to change notification settings - Fork 16
/
dawgminify.h
62 lines (53 loc) · 1.77 KB
/
dawgminify.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
/**
* Copyright (C) 2014, David Everlöf
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DAWGMINIFY_H
#define DAWGMINIFY_H
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define BITS_IN_BYTE (8)
#define BITS_PER_CHAR (8)
/* FOR COMPRESSED DAWG */
#define WORD_MASK (0x00000001)
#define CHAR_MASK (0x0000FF00)
#define END_MASK (0x00000002)
#define WORD_MASK_LENGTH (0x00000001)
#define END_MASK_LENGTH (0x00000001)
#define CHAR_MASK_LENGTH (0x00000008)
/* FOR BLITZKREIG */
#define BYTES_PER_NODE (4)
#define KChildBitShift (10)
#define KChildIndexMask (0xFFFFFF00)
#define KLetterMask (0x000000FF)
#define KEndOfWordFlag (0x00000200)
#define KEndOfListFlag (0x00000100)
/* FOR NON-COMPRESSED DAWG */
/*
#define BYTES_PER_NODE (4)
#define KChildBitShift (8)
#define KChildIndexMask (0x0FFFFF00)
#define KLetterMask (0x000000FF)
#define KEndOfWordFlag (0x20000000)
#define KEndOfListFlag (0x10000000)
*/
char* encode(char* in, size_t in_size, size_t* out_size);
char* decode(char* in, size_t in_size, size_t* out_size);
char* read_file(const char* filename, long* size);
void trim(char *line);
#endif