4 #include <anthy/diclib.h>
5 #include <anthy/filemap.h>
6 #include <anthy/alloc.h>
7 #include <anthy/conf.h>
8 #include <anthy/logger.h>
9 #include "diclib_inner.h"
12 Ê£¿ô¥»¥¯¥·¥ç¥ó¤¬¥ê¥ó¥¯¤µ¤ì¤¿¼½ñ
16 struct filemapping *mapping;
19 static struct file_dic fdic;
22 anthy_file_dic_get_section(const char* section_name)
25 char* head = anthy_mmap_address(fdic.mapping);
27 int entry_num = anthy_dic_ntohl(*p++);
29 for (i = 0; i < entry_num; ++i) {
30 int hash_offset = anthy_dic_ntohl(*p++);
31 int key_len = anthy_dic_ntohl(*p++);
32 int contents_offset = anthy_dic_ntohl(*p++);
33 if (strncmp(section_name, head + hash_offset, key_len) == 0) {
34 return (void*)(head + contents_offset);
41 anthy_init_file_dic(void)
44 fn = anthy_conf_get_str("DIC_FILE");
46 anthy_log(0, "dictionary is not specified.\n");
50 /* ¼½ñ¤ò¥á¥â¥ê¾å¤Ëmap¤¹¤ë */
51 fdic.mapping = anthy_mmap(fn, 0);
53 anthy_log(0, "failed to init file dic.\n");
61 anthy_quit_file_dic(void)
63 anthy_munmap(fdic.mapping);