aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/dict/dict.h
blob: 4359767470db1b656c52c886c6c1c42f3c174d07 (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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/* Runes for special purposes (0xe800-0xfdff is Private Use Area) */
enum {	NONE=0xe800,	/* Emit nothing */
	TAGS,		/* Start of tag */
	TAGE,		/* End of tag */
	SPCS,		/* Start of special character name */
	PAR,		/* Newline, indent */
	LIGS,		/* Start of ligature codes */

/* need to keep in sync with utils.c:/ligtab */
	LACU=LIGS,	/* Acute (´) ligatures */
	LGRV,		/* Grave (ˋ) ligatures */
	LUML,		/* Umlaut (¨) ligatures */
	LCED,		/* Cedilla (¸) ligatures */
	LTIL,		/* Tilde (˜) ligatures */
	LBRV,		/* Breve (˘) ligatures */
	LRNG,		/* Ring (˚) ligatures */
	LDOT,		/* Dot (˙) ligatures */
	LDTB,		/* Dot below (.) ligatures */
	LFRN,		/* Frown (⌢) ligatures */
	LFRB,		/* Frown below (̯) ligatures */
	LOGO,		/* Ogonek (˛) ligatures */
	LMAC,		/* Macron (¯) ligatures */
	LHCK,		/* Hacek (ˇ) ligatures */
	LASP,		/* Asper (ʽ) ligatures */
	LLEN,		/* Lenis (ʼ) ligatures */
	LBRB,		/* Breve below (̮) ligatures */
	LIGE,		/* End of ligature codes */

/* need to keep in sync with utils.c:/multitab */
	MULTI,		/* Start of multi-rune codes */
	MAAS=MULTI,	/* ʽα */
	MALN,		/* ʼα */
	MAND,		/* and */
	MAOQ,		/* a/q */
	MBRA,		/* <| */
	MDD,		/* .. */
	MDDD,		/* ... */
	MEAS,		/* ʽε */
	MELN,		/* ʼε */
	MEMM,		/* —— */
	MHAS,		/* ʽη */
	MHLN,		/* ʼη */
	MIAS,		/* ʽι */
	MILN,		/* ʼι */
	MLCT,		/* ct */
	MLFF,		/* ff */
	MLFFI,		/* ffi */
	MLFFL,		/* ffl */
	MLFL,		/* fl */
	MLFI,		/* fi */
	MLLS,		/* ll with swing */
	MLST,		/* st */
	MOAS,		/* ʽο */
	MOLN,		/* ʼο */
	MOR,		/* or */
	MRAS,		/* ʽρ */
	MRLN,		/* ʼρ */
	MTT,		/* ~~ */
	MUAS,		/* ʽυ */
	MULN,		/* ʼυ */
	MWAS,		/* ʽω */
	MWLN,		/* ʼω */
	MOE,		/* oe */
	MES,		/* em space */
	MULTIE		/* End of multi-rune codes */
};
#define Nligs (LIGE-LIGS)
#define Nmulti (MULTIE-MULTI)

typedef struct Entry Entry;
typedef struct Assoc Assoc;
typedef struct Nassoc Nassoc;
typedef struct Dict Dict;

struct Entry {
	char	*start;		/* entry starts at start */
	char	*end;		/* and finishes just before end */
	long	doff;		/* dictionary offset (for debugging) */
};

struct Assoc {
	char	*key;
	long	val;
};

struct Nassoc {
	long	key;
	long	val;
};

struct Dict {
	char	*name;			/* dictionary name */
	char	*desc;			/* description */
	char	*path;			/* path to dictionary data */
	char	*indexpath;		/* path to index data */
	long	(*nextoff)(long);	/* function to find next entry offset from arg */
	void	(*printentry)(Entry, int); /* function to print entry */
	void	(*printkey)(void);	/* function to print pronunciation key */
};

int	acomp(Rune*, Rune*);
Rune	*changett(Rune *, Rune *, int);
void	err(char*, ...);
void	fold(Rune *);
void	foldre(char*, char*);
Rune	liglookup(Rune, Rune);
long	lookassoc(Assoc*, int, char*);
long	looknassoc(Nassoc*, int, long);
void	outprint(char*, ...);
void	outrune(long);
void	outrunes(Rune *);
void	outchar(int);
void	outchars(char *);
void	outnl(int);
void	outpiece(char *, char *);
void	runescpy(Rune*, Rune*);
long	runetol(Rune*);
char	*dictfile(char*);

long	oednextoff(long);
void	oedprintentry(Entry, int);
void	oedprintkey(void);
long	ahdnextoff(long);
void	ahdprintentry(Entry, int);
void	ahdprintkey(void);
long	pcollnextoff(long);
void	pcollprintentry(Entry, int);
void	pcollprintkey(void);
long	pcollgnextoff(long);
void	pcollgprintentry(Entry, int);
void	pcollgprintkey(void);
long	movienextoff(long);
void	movieprintentry(Entry, int);
void	movieprintkey(void);
long	pgwnextoff(long);
void	pgwprintentry(Entry,int);
void	pgwprintkey(void);
void	rogetprintentry(Entry, int);
long	rogetnextoff(long);
void	rogetprintkey(void);
long	slangnextoff(long);
void	slangprintentry(Entry, int);
void	slangprintkey(void);
long	robertnextoff(long);
void	robertindexentry(Entry, int);
void	robertprintkey(void);
long	robertnextflex(long);
void	robertflexentry(Entry, int);
long	simplenextoff(long);
void	simpleprintentry(Entry, int);
void	simpleprintkey(void);
long	thesnextoff(long);
void	thesprintentry(Entry, int);
void	thesprintkey(void);
long	worldnextoff(long);
void	worldprintentry(Entry, int);
void	worldprintkey(void);

extern Biobuf	*bdict;
extern Biobuf	*bout;
extern int	linelen;
extern int	breaklen;
extern int	outinhibit;
extern int	debug;
extern Rune	multitab[][5];
extern Dict	dicts[];

#define asize(a) (sizeof (a)/sizeof(a[0]))