aboutsummaryrefslogtreecommitdiff
path: root/src/stardict-private.h
blob: 5d3ae6aaf0f70c1dacf65d7f917d6299ebef6175 (plain)
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
/*
 * stardict-private.h: internal StarDict API
 *
 * Copyright (c) 2013 - 2015, Přemysl Janouch <p.janouch@gmail.com>
 * All rights reserved.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 */

#ifndef STARDICTPRIVATE_H
#define STARDICTPRIVATE_H

/// Describes a single entry in the dictionary index.
typedef struct stardict_index_entry     StardictIndexEntry;

/// Describes a single entry in the synonyms index.
typedef struct stardict_synonym_entry   StardictSynonymEntry;


typedef enum stardict_version StardictVersion;
enum stardict_version { SD_VERSION_2_4_2, SD_VERSION_3_0_0 };

struct stardict_info
{
	gchar           * path;
	StardictVersion   version;

	gchar           * book_name;
	gulong            word_count;
	gulong            syn_word_count;
	gulong            idx_filesize;
	gulong            idx_offset_bits;
	gchar           * author;
	gchar           * email;
	gchar           * website;
	gchar           * description;
	gchar           * date;
	gchar           * same_type_sequence;

	gchar           * collation;
};

struct stardict_index_entry
{
	gchar           * name;             ///< The word in utf-8
	guint64           data_offset;      ///< Offset of the definition
	guint32           data_size;        ///< Size of the definition
	guint32           reverse_index;    ///< Word at this index before sorting
};

struct stardict_synonym_entry
{
	gchar           * word;             ///< A synonymous word
	guint32           original_word;    ///< The original word's index
};

struct stardict_ifo_key
{
	const gchar *name;                  ///< Name of the key
	enum {
		IFO_STRING,                     ///< A @code gchar * @endcode value
		IFO_NUMBER                      ///< A @code gulong @endcode value
	} type;                             ///< Type of the value
	size_t offset;                      ///< Offset within StardictInfo
};

/// Lists all the entries in StardictInfo.
extern const struct stardict_ifo_key _stardict_ifo_keys[];

/// Denotes the length of _stardict_ifo_keys.
extern gsize _stardict_ifo_keys_length;

#endif  // ! STARDICTPRIVATE_H