-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathd2.h
42 lines (35 loc) · 1.52 KB
/
d2.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
/*======================================================================
* Interface definition for a d2 dictionary
*======================================================================*/
#define MAXLEN 20
typedef struct _Dict *Dict;
typedef struct _Dictl *Dictl;
typedef struct _Dscan *Dscan;
extern Dict Dict_open(const char *stub);
extern int Dict_contains(Dict d, const char *word, int len);
#define Dict_isword Dict_contains /* Obsolete interface */
extern void Dict_close(Dict d);
extern Dictl Dictl_open(Dict d, int len);
extern Dictl Dictl_fopen(const char *filename);
extern int Dictl_contains(Dictl dl, const char *word);
#define Dictl_isword Dictl_contains /* Obsolete interface */
extern int Dictl_length(Dictl dl); /* Number of elements */
extern void Dictl_close(Dictl dl);
extern Dscan Dscan_open(Dict d, int len);
extern Dscan Dscan_openl(Dictl dl);
extern const char *Dscan_read(Dscan ds);
extern void Dscan_skip(Dscan ds, int skip);
extern void Dscan_close(Dscan ds);
typedef struct {
unsigned char nlet[26];
unsigned char nwild;
} Dpool;
#define dpool_clear(pp) memset(pp,0,sizeof(Dpool))
extern void dpool_add(Dpool *, const Dpool *);
#define dpool_add_char(pp,c) (isalpha(c) ? (pp)->nlet[toupper(c)-'A']++ : (pp)->nwild++)
#define dpool_add_wild(pp) ((pp)->nwild++)
extern void dpool_add_word(Dpool *, const char *);
extern int dpool_sub(Dpool *, const Dpool *);
extern int dpool_sub_char(Dpool *, int);
extern int dpool_sub_word(Dpool *, const char *);
extern void dpool_string(char *, const Dpool *, int /*cWild*/);