aboutsummaryrefslogtreecommitdiff
path: root/makedict/makedict.h
blob: b1bf5eb0b87e447459e7bfeb6acfc87f4ab65549 (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
/* This file is part of GNU Dico.
   Copyright (C) 1998-2018 Sergey Poznyakoff

   GNU Dico 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 3, or (at your option)
   any later version.

   GNU Dico 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 GNU Dico.  If not, see <http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <unistd.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <errno.h>
#include <stdarg.h>
#include <limits.h>
#include <dict.h>
#include <xdico.h>
#include <db.h>
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free
#include <obstack.h>
#include <xalloc.h>
#include <appi18n.h>

#define HIRAGANA_BYTE 0x24
#define KATAKANA_BYTE 0x25

#define UNCOMPRESS "gzip -d -c" 
#define UNCOMPRESSEXT ".gz"

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

/* This comes from <X11/Xutil.h> */
typedef struct {                /* normal 16 bit characters are two bytes */
    unsigned char byte1;
    unsigned char byte2;
} XChar2b;

struct dbidx;

typedef int (*get_key_fn)(DB *, const DBT *, const DBT *, DBT *);
typedef int (*cmp_key_fn)(DB *, const DBT *, const DBT *);
typedef int (*iter_fn)(struct dbidx *, unsigned, DictEntry *);

struct dbidx {
    char *name;
    get_key_fn get_key;
    cmp_key_fn cmp_key;
    iter_fn iter;
    DB *dbp;
    /* FIXME: What's more? */
};

extern char *dictdir;
extern char *kanjidict;
extern char *edict;
extern char *outdir;
extern char *dictname;
extern int verbose;
extern int maxstr8;
extern int maxstr16;
extern int maxbuflen8;
extern int maxbuflen16;
extern struct dbidx dbidx[];
extern unsigned numberofkanji, highestkanji, lowestkanji;
extern unsigned nedict;

void get_options(int argc, char **argv);

int compile (void);

DB *open_db(void);
void close_db(DB *);
void iterate_db(DB *);
void count_xref(DB *);

void open_secondary(DB *master, struct dbidx *idx);
int insert_dict_entry(DB *dbp, unsigned num, DictEntry *entry, size_t size);


FILE *open_compressed(char *dictname, int *pflag);

void  compile_kanjidic(DB *dbp);

/* romaji.c */
/* FIXME: Move these to the library. */
typedef int (*romaji_out_fn)(void *, const char *);

int kana_to_romaji(const XChar2b *input, size_t size, romaji_out_fn fun,
		   void *closure);
int kana_to_romaji_str(const XChar2b *input, size_t size, char **sptr);

/* getopt.m4 */
extern void print_help(void);
extern void print_usage(void);

Return to:

Send suggestions and report system problems to the System administrator.