File: defs.h

package info (click to toggle)
kdrill 6.5deb2-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,340 kB
  • sloc: ansic: 7,636; makefile: 47
file content (131 lines) | stat: -rw-r--r-- 3,727 bytes parent folder | download | duplicates (4)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * defs.h for kdrill
 *   Okay, I "lied".. this file has struct definitions, as
 *   well as the #defines
 *
 * See "externs.h" for the main global variables.
 */

#include <Xmd.h> /* for byte word width */
#include <Xlib.h> /* for XChar2b */

#if defined(BSD) || defined(__DARWIN__)
/* It's Really Important that you use either lrand48(), or random()
 * The old rand() function is just not random enough
 */
# define srand(a) srandom(a)
# define lrand48() random()

#endif /* BSD */

/* for reading in kanjidic lines */
#define MAXLINELEN 1024

#define NOKANJI 0x2266

/* when in random mode, if you have incorrect kanji guessed,
 * will specifically pick an incorrectly-guessed kanji
 * probability of (1/REPEACTFRACTION)
 */
#define REPEATFRACTION 4
/* number of times a missed kanji will be repeated on purpose */
#define REPEATTIMES 2
#define MAXREPEAT 10
/* how many possible answers are there? */
/* maximum of 9, since you can only have accelerator keys 1-9 */
#define NUMBEROFCHOICES 5

#define STATUSDISTANCE	10
#define BUTTONSWIDTH	120	/* for options buttons */
#define INPUTWIDTH	50
#define GRADEDISTANCE	14

#define ALLGRADES 0xfe
#define ABOVESIXGRADE 0x80
/* FULLWIDTH is startup size of an english translation button */
#define FULLWIDTH 370
#define KANJIWIDTH 50

/* MAXTRANSLATIONSALLOWED reflects the size of an array of pointer-to-translation,
 * and an array of booleans for the Usefile
 * We malloc for every actual entry read
 *
 * MIN/MAX KANJIALLOWED is a special subset of that.
 */
#define MINKANJIALLOWED 0x2000
#define MAXKANJIALLOWED 0x8000 /* start edict at this+1 */
/* Crud. edict actually overflowed when MAXTRANSLATIONS==0x18000 */
#define MAXTRANSLATIONSALLOWED 0x40000


/* MAXRADICALS is the approximate number of radicals that we know of, that
 * may be building blocks for a particular kanji.
 * DO NOT CONFUSE THIS with the number of kanji that may be
 * associated with a particular radical.
 * Which for some reason, I named MAXKRADPOST
 */
#define MAXRADICALS 250

#define MAXKRADPOST 3200

/* The following means the minimum active translations we must have available.
 * Otherwise, we assume an error in configuration
 */
#define HAVE_AT_LEAST 9

typedef struct translationstruct * TRANSLATION;

struct translationstruct {
	int kdrill_index; /* position in internal array */

	char *english;	/* english translation string.
			 * null-terminated.
			 * Can theoretically be any length, but
			 * since it will all be on a single-line
			 * text widget, that would be silly
			 */

	CARD16 Uindex;		/* because it seems to be the future */
				/* "Unicode" index */

	BITS16 Qindex;		/* for the "four corner" lookup method */
	BITS16 Sindex;		/* for SKIP: 2 bytes, see skipfromthree() */
	BITS16 Nindex;		/* for annoying "See Nxxxx" references */
				/* Nelson dictionary */
	BITS16 Hindex;		/* Halpern dictionary indexes */

	BITS16 frequency;		/* frequency that kanji is used */
	BYTE grade_level;	/* akin to  school class level */

	BYTE Strokecount;

	BITS16 incorrect;

	
	XChar2b *pronunciation;	/* kana, actually */
	XChar2b *kanji;		/* can be pointer to pronunciation */

	TRANSLATION nextk;

};




/********************************************************************

SO here's the format for the translation/dictionary file I have decided
on so far:

I changed specs. it will have to be in "kanjidic" format...

Two char high-bit-set identifier, followed by JIS number in hex.
Followed by stroke information? [HAS TO BE TERMINATED BY 'Gx', where
				  'x' is any number]
Followed by pronunciation guide, in kana.
Followed by various english translations, enclosed in {}

"kanjidic" often has multiple {} phrases. which leads to another nasty
hack  in readstructs()

*/