forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictzip.h
108 lines (88 loc) · 2.58 KB
/
dictzip.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* Made up from data.h and other supplementary files of dictd-1.0.11 for the
* GoldenDict program.
*/
/* data.h --
* Created: Sat Mar 15 18:04:25 2003 by Aleksey Cheusov <[email protected]>
* Copyright 1994-2003 Rickard E. Faith ([email protected])
*
* 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 1, 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, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
*/
#ifndef _DICTZIP_H_
#define _DICTZIP_H_
#include <stdio.h>
#include <zlib.h>
#ifdef __WIN32
#include <windows.h>
#endif
#ifdef __cplusplus
extern "C"
{
#endif
/* Excerpts from defs.h */
#define DICT_CACHE_SIZE 5
typedef struct dictCache {
int chunk;
char *inBuffer;
int stamp;
int count;
} dictCache;
typedef struct dictData {
#ifdef __WIN32
HANDLE fd; /* file handle */
#else
FILE * fd; /* file descriptor */
#endif
unsigned long size; /* size of file */
int type;
const char *filename;
z_stream zStream;
int initialized;
int headerLength;
int method;
int flags;
time_t mtime;
int extraFlags;
int os;
int version;
int chunkLength;
int chunkCount;
int *chunks;
unsigned long *offsets; /* Sum-scan of chunks. */
const char *origFilename;
const char *comment;
unsigned long crc;
unsigned long length;
unsigned long compressedLength;
int stamp;
dictCache cache[DICT_CACHE_SIZE];
char errorString[512];
} dictData;
/* initialize .data file */
extern dictData *dict_data_open (
const char *filename, int computeCRC);
/* */
extern void dict_data_close (
dictData *data);
extern char *dict_data_read_ (
dictData *data,
unsigned long start, unsigned long end,
const char *preFilter,
const char *postFilter );
extern char *dict_error_str( dictData *data );
extern int mmap_mode;
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif /* _DICTZIP_H_ */