1 /*
2  *  $Id: jslib.h,v 1.5 2005/04/10 15:26:37 aonoto Exp $
3  */
4 
5 /*
6  * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
7  * This file is part of FreeWnn.
8  *
9  * Copyright Kyoto University Research Institute for Mathematical Sciences
10  *                 1987, 1988, 1989, 1990, 1991, 1992
11  * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
12  * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
13  * Copyright FreeWnn Project 1999, 2000
14  *
15  * Maintainer:  FreeWnn Project   <freewnn@tomo.gr.jp>
16  *
17  * This library is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU Lesser General Public
19  * License as published by the Free Software Foundation; either
20  * version 2 of the License, or (at your option) any later version.
21  *
22  * This library is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  * Lesser General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the
29  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30  * Boston, MA 02111-1307, USA.
31  */
32 
33 /*
34  *       Nihongo Henkan  Library Header File
35  */
36 
37 #ifndef WNN_JSLIB_H
38 #define WNN_JSLIB_H
39 
40 #ifndef _WNN_SETJMP
41 #define _WNN_SETJMP
42 #include <setjmp.h>
43 #endif
44 
45 #define JLIB_VERSION    0x4003
46 
47 #ifndef w_char
48 #define w_char  unsigned short
49 #endif /* w_char */
50 
51 /* ��ü�٥���(�ʻ��ֹ�)����� */
52 #define WNN_BUN_SENTOU  -1      /* ��ʸ�����Ƭ�ˤʤ���� */
53 #define WNN_ALL_HINSI   -2      /* �ʤ�Ǥ⤨���� */
54 /* ��ü�٥�������� */
55 #define WNN_VECT_KANREN 0       /* Ϣʸ���Ѵ��ν�ü�٥����� */
56 #define WNN_VECT_KANTAN 1       /* ñʸ���Ѵ��ν�ü�٥����� */
57 #define WNN_VECT_KANZEN 1       /* �������Ф��ν�ü�٥�����
58                                    ñʸ���Ѵ����Τ�Τ��������� */
59 #define WNN_VECT_BUNSETSU 2     /* Ϣʸ���Ѵ����Ρ���ʸ��ν�ü�٥����� */
60 #define WNN_VECT_NO     -1      /* ��ü�٥���1 ̵�� */
61 /* ʸ��ν�ü����³���� */
62 #define WNN_CONNECT_BK  1       /* ���ꤵ�줿��ü�٥���������³�Ǥ����� */
63 #define WNN_NOT_CONNECT_BK      0       /* */
64 /* ʸ�����ü����³���� */
65 #define WNN_CONNECT     1       /* ���ꤵ�줿(�ʻ졢��°��)����³�Ǥ����� */
66 #define WNN_SENTOU      2       /* ��ʸ�����Ƭ */
67 #define WNN_NOT_CONNECT 3       /* ��Ƭ�ˤʤ�ʤ�����������³�Ǥ��ʤ� */
68 #define WNN_GIJI        4       /* ����ʸ����ä��� */
69 
70 /* ����ʸ���ľ�������������� */
71 #define WNN_HIRAGANA    -1      /* �Ҥ餬�� */  /* �ɤߤΤޤ� */
72 #define WNN_KATAKANA    -11     /* �������� */
73 /* ���� */
74 #define WNN_NUM_HAN     -2      /* Ⱦ�ѿ��� */  /* �ɤߤΤޤ� */
75 #define WNN_NUM_ZEN     -12     /* ���ѿ��� */  /* ������ */
76 #define WNN_NUM_KAN     -13     /* ������ */    /* ���� */
77 #define WNN_NUM_KANSUUJI -15    /* ������ */    /* ɴ���� */
78 #define WNN_NUM_KANOLD  -16     /* ������ */    /* ��ɴ������ */
79 #define WNN_NUM_HANCAN  -17     /* Ⱦ�ѿ��� */  /* 1,234 */
80 #define WNN_NUM_ZENCAN  -18     /* ���ѿ��� */  /* ���������� */
81 /* �ѿ� */
82 #define WNN_ALP_HAN     -4      /* Ⱦ�� */      /* �ɤߤΤޤ� */
83 #define WNN_ALP_ZEN     -30     /* ���� */
84 /* ���� */
85 #define WNN_KIG_HAN     -5      /* Ⱦ�� */      /* �ɤߤΤޤ� */
86 #define WNN_KIG_JIS     -40     /* ����(JIS) */
87 #define WNN_KIG_ASC     -41     /* ����(ASC) */
88 
89 #define WNN_FT_DICT_FILE 1
90 #define WNN_FT_HINDO_FILE 2
91 #define WNN_FT_FUZOKUGO_FILE 3
92 
93 #define WNN_STATIC_DICT 1       /* static dict */
94 #define WNN_UD_DICT 2           /* updatable dict */
95 #define WNN_REV_DICT 3          /* Updatable Dictonary with Reverse Index */
96 #define WNN_REG_DICT 4          /* Regular Expressino Dictonary */
97 
98 /* for CHINESE PIN-IN : with Si Sheng (����) */
99 #define CWNN_REV_DICT           0x103   /* Updatable with Reverse Index */
100 
101 /* for CHINESE: Bi Xing (ɮ��) */
102 #define BWNN_REV_DICT           0x203   /* Updatable with Reverse Index */
103 
104 #define WNN_DIC_RDONLY  1
105 #define WNN_DIC_RW      0
106 
107 #define WNN_DIC_ADD_REV 1       /* ���Ѵ� */
108 #define WNN_DIC_ADD_NOR 0       /* �̾���Ѵ� */
109 
110 /* header file for dic_syurui */
111 #define WNN_FILE_NOT_EXIST -1
112 #define WNN_NOT_A_JISHO 0
113 /* KURI
114 #define WNN_USER_DIC 1
115 #define WNN_SYSTEM_DIC 3
116 */
117 #define WNN_HINDO_FILE 4
118 #define WNN_FUZOKUGO_FILE 5
119 
120 /* set_hindo operation */
121 #define WNN_HINDO_NOP -2
122 #define WNN_IMA_ON -3
123 #define WNN_IMA_OFF -4
124 #define WNN_HINDO_INC -3
125 #define WNN_HINDO_DECL -4
126 #define WNN_ENTRY_NO_USE -1
127 
128 /*      Wnn constant
129 */
130 #define WNN_HOSTLEN 16
131 #define WNN_ENVNAME_LEN 32
132 
133 /*      js_who  */
134 #define WNN_MAX_ENV_OF_A_CLIENT 32
135 
136 struct wnn_jwho
137 {
138   int sd;                       /* jserver ��Υ����åȥǥ�������ץ� */
139   char user_name[64];           /* �桼��̾ */
140   char host_name[64];           /* �ۥ���̾ */
141   int env[WNN_MAX_ENV_OF_A_CLIENT];     /* ���Υ��饤����Ȥ����Ѥ��Ƥ���
142                                            �Ķ��ֹ���������Ƥ���Ȥ���ˤϡ�-1 ������ */
143 };
144 typedef struct wnn_jwho WNN_JWHO;
145 
146 /*      js_env_list     */
147 #define WNN_MAX_JISHO_OF_AN_ENV 30
148 #define WNN_MAX_FILE_OF_AN_ENV 60
149 
150 struct wnn_env_info
151 {
152   int env_id;                   /* �Ķ��ֹ� */
153   char env_name[WNN_ENVNAME_LEN];       /* �Ķ�̾ */
154   int ref_count;                /* ���ȿ� */
155   /* struct wnn_param; */
156   int fzk_fid;                  /* ��°��Υե������ֹ� */
157   int jishomax;                 /* ���Ѥ��Ƥ��뼭��θĿ� */
158   int jisho[WNN_MAX_JISHO_OF_AN_ENV];   /* ���Ѥ��Ƥ��뼭��μ����ֹ档
159                                            �ǽ��jishomax�Ĥ�����̣������ */
160   int file[WNN_MAX_FILE_OF_AN_ENV];     /* ���δĶ��ˤĤʤ��äƤ���
161                                            �ե������ֹ�(�����Ƥ���Ȥ���ˤϡ�-1 ������) */
162 };
163 typedef struct wnn_env_info WNN_ENV_INFO;
164 
165 #define WNN_COMMENT_LEN 512     /* jisho no comment no nagasa */
166 #define WNN_F_NAMELEN 100
167 #define WNN_PASSWD_LEN 16       /* File Passwd Length */
168 
169 
170 struct wnn_dic_info
171 {
172   int dic_no;                   /* �����ֹ� */
173   int body;                     /* �������ΤΥե������ֹ� */
174   int hindo;                    /* ���٤Υե������ֹ� */
175   int rw;                       /* ������Ͽ��ǽ���ɤ���
176                                    (WNN_DIC_RW, WNN_DIC_RDONLY) */
177   int hindo_rw;                 /* ���٤�������ǽ���ɤ���
178                                    (WNN_DIC_RW, WNN_DIC_RDONLY) */
179   int enablef;                  /* ���������椫�ɤ���
180                                    (1 = ������, 0 = ��������) */
181   int nice;                     /* ������Ѵ�����ͥ���� */
182   int rev;                      /* ���Ѵ������ɤ���(1 = ���Ѵ�, 0 = ���Ѵ�) */
183 /* added H.T */
184   w_char comment[WNN_COMMENT_LEN];      /* ����Υ����� */
185   char fname[WNN_F_NAMELEN];    /* ����Υե�����̾ */
186   char hfname[WNN_F_NAMELEN];   /* ���٤Υե�����̾ */
187   char passwd[WNN_PASSWD_LEN];  /* ����Υѥ���� */
188   char hpasswd[WNN_PASSWD_LEN]; /* ���٤Υѥ���� */
189   int type;                     /* ����μ���(WNN_UD_DICT,WNN_STATIC_DICT) */
190   int gosuu;                    /* ����θ�� */
191   int localf;
192   int hlocalf;
193 };
194 
195 typedef struct wnn_dic_info WNN_DIC_INFO;
196 
197 struct wnn_file_stat
198 {
199   int type;                     /* �ե�����μ���
200                                    WNN_STATIC_DICT              �����������
201                                    WNN_UD_DICT          ��Ͽ��ǽ��������
202                                    WNN_HINDO_FILE               ���٥ե�����
203                                    WNN_FUZOKUGO_FILE    ��°��ե�����
204                                    WNN_NOT_A_JISHO              ����¾   */
205 };
206 
207 typedef struct wnn_file_stat WNN_FILE_STAT;
208 
209 /*      */
210 extern int wnn_errorno;         /* Wnn�Υ��顼�Ϥ����ѿ��������� */
211 
212 extern char *wnn_dic_types[];   /* "����","��Ͽ","���Ѵ�","����" */
213 
214 extern char *cwnn_dic_types[];  /* "����","��Ͽ","���Ѵ�","����" */
215 extern char *bwnn_dic_types[];  /* "����","��Ͽ","���Ѵ�","����" */
216 
217 #define FILE_ALREADY_READ -2
218 
219 /* ���ι�¤�Τϡ��饤�֥���������Ѥ����� */
220 struct wnn_jserver_id
221 {
222   int sd;
223   char js_name[40];
224   int js_dead;
225   jmp_buf js_dead_env;          /* �����Ф�������������Ǥ���env */
226   int js_dead_env_flg;          /* jd_server_dead_env��ͭ�����ݤ�  */
227 };
228 
229 typedef struct wnn_jserver_id WNN_JSERVER_ID;
230 
231 /* ���ι�¤�Τϡ��饤�֥���������Ѥ����� */
232 struct wnn_env
233 {
234   int env_id;
235   WNN_JSERVER_ID *js_id;
236   char lang[16];                /* for exsample "ja_JP" */
237 };
238 
239 typedef struct wnn_env WNN_ENV;
240 
241 struct wnn_param
242 {
243   int n;                        /* ��(��)ʸ����ϤΣ� */
244   int nsho;                     /* ��ʸ����ξ�ʸ��κ���� */
245   int p1;                       /* ��Ω������٤Υѥ�᡼�� */
246   int p2;                       /* ��ʸ��Ĺ�Υѥ�᡼�� */
247   int p3;                       /* ��Ω��Ĺ�Υѥ�᡼�� */
248   int p4;                       /* ���Ȥä���ӥåȤΥѥ�᡼�� */
249   int p5;                       /* ����Υѥ�᡼�� */
250   int p6;                       /* ��ʸ���ɾ���ͤΥѥ�᡼�� */
251   int p7;                       /* ��ʸ��Ĺ�Υѥ�᡼�� */
252   int p8;                       /* ��ʸ����Υѥ�᡼�� */
253   int p9;                       /* �����ʻ� ���������� */
254   int p10;                      /* �����ʻ� ���ʤ����� *//* CWNN:�ѿ������� */
255   int p11;                      /* �����ʻ� �ѿ������� *//* CWNN:��������� */
256   int p12;                      /* �����ʻ� ��������� *//* CWNN:����̤����� */
257   int p13;                      /* �����ʻ� �ij�̤����� *//* CWNN:�ij�̤����� */
258   int p14;                      /* �����ʻ� ��°������� *//* BWNN:No of koho */
259   int p15;                      /* �����ʻ� ����̤����� *//* CWNN:Not used */
260 };
261 
262 #ifdef nodef
263 struct wnn_dic_info_struct
264 {
265   int body_fid;
266   int hindo_fid;
267   int enablef;
268   int rw;
269   int hindo_rw;
270   int nice;
271 };
272 
273 typedef struct wnn_dic_info_struct WNN_DIC_INFO_STRUCT;
274 #endif
275 
276 struct wnn_file_info_struct
277 {
278   int fid;                      /* �ե������ֹ� */
279   char name[WNN_F_NAMELEN];     /* �ե�����̾ */
280   int localf;                   /* �����С������ȤΥե����뤫�ɤ���
281                                    1: �����С�������
282                                    0: ���饤����ȡ�������   */
283   int type;                     /* �ե�����μ��� */
284   int ref_count;                /* (�Ķ������)���ȿ� */
285 };
286 
287 typedef struct wnn_file_info_struct WNN_FILE_INFO_STRUCT;
288 
289 #define WNN_VECT_L      ((256+8*4-1)/(8*4) + 5) /***** !!!!! ****/
290 
291 struct wnn_sho_bunsetsu
292 {
293   int end;                      /* ����ʸ��� end char index */
294   int start;                    /* ����ʸ��� top char index */
295   int jiriend;                  /* ����ʸ��μ�Ω�� end char index */
296   int dic_no;                   /* ��Ω��μ�����Υ���ȥ��ֹ� */
297   int entry;                    /* ����ʸ��μ�Ω�켭�� entry */
298 
299   int hinsi;                    /* ��Ω���ʻ� */
300   int status;                   /* ��ʸ�����Ƭ�� */
301   int status_bkwd;              /* usiro ��ʸ�����³�Ǥ��뤫 */
302   int hindo;                    /* ���伫Ω������� */
303   int ima;                      /* ���伫Ω��κ��Ȥä���ӥå� */
304   int kangovect;                /* ��³�٥��ȥ�ơ��֥�ؤΥݥ��� */
305   int hyoka;                    /* ��ʸ��ɾ���� */
306   w_char *kanji;                /* ��Ω��ʸ���� */
307   w_char *yomi;                 /* ��Ω����ɤ�ʸ���� */
308   w_char *fuzoku;               /* ��°��ʸ���� */
309 /*
310  *���٤ˤĤ��Ƥϡ����٥ե����뤬���ꤵ��Ƥ�����ϡ�
311  *hindo = ���٥ե������(��)������ + �������(��)������
312  *ima = ���٥ե�����κ��Ȥä���ӥå�
313  *
314  *���٥ե����뤬���ꤵ��Ƥ��ʤ����ˤϡ�
315  *hindo = �������(��)�����͡�ima = ������κ��Ȥä���ӥå�
316  *�Ǥ��롣�����ǡ��������ͤȤϡ��׻������7�ӥåȤ˰��̤��줿�ͤǤ��롣
317  *���������ͤǤϤʤ��������ͤ��֤��Τϡ��Ѵ���̤ΥǥХå��Τ���Ǥ��롣
318  */
319 };
320 
321 struct wnn_dai_bunsetsu
322 {
323   int end;                      /* ����ʸ��� end char index */
324   int start;                    /* ����ʸ��� top char index */
325   struct wnn_sho_bunsetsu *sbn; /* ��ʸ����Ϸ�̤ؤΥݥ��� */
326   int hyoka;                    /* ��ʸ��ɾ���� */
327   int sbncnt;                   /* ��ʸ��� (������ξ��ϡ��������)
328                                    DSD_SBN�ϡ�*sbn ���� sbncnt �������� */
329 };
330 
331 struct wnn_jdata
332 {
333   int dic_no;                   /* �����ֹ� */
334   int serial;                   /* ������Υ���ȥ��ֹ� */
335   int hinshi;                   /* �ʻ��ֹ�(�ʻ��ֹ���ʻ�̾���б��ϡ�manual/etc
336                                    �β�����) */
337   int hindo;                    /* ���� */
338   int ima;                      /* ���Ȥä���ӥå� */
339   int int_hindo;                /* ���������� */
340   int int_ima;                  /* �����⡢���Ȥä���ӥå� */
341   w_char *yomi;                 /* �ɤߤ�ʸ���� */
342   w_char *kanji;                /* ����ʸ���� */
343   w_char *com;                  /* ����ȥ�Υ�����ʸ���� */
344 /*
345  *���٤ˤĤ��Ƥϡ����٥ե����뤬���ꤵ��Ƥ�����ϡ�
346  *hindo = ���٥ե������(����)�����͡�ima = ���٥ե�����κ��Ȥä���ӥå�
347  *int_hindo = �������(����)�����͡�int_ima = ������κ��Ȥä���ӥå�
348  *
349  *���٥ե����뤬���ꤵ��Ƥ��ʤ����ˤϡ�
350  *hindo = �������(����)�����͡�ima = ������κ��Ȥä���ӥå�
351  *int_hindo = -1��int_ima = -1
352  *
353  *���������ɤ���ξ��Ǥ⡢����ȥ꤬������ߤξ��֤λ��ˤϡ�
354  *hindo = -1, ima = 0 ���뤤�ϡ�
355  *int_hindo = -1, int_ima = 0 �Ȥʤ롣
356  *�����ǡ�(����)�����ͤȤϡ��׻������7�ӥåȤ˰��̤��줿�����ͤ��顢
357  *�ºݤ��ͤ����ꤷ���ͤǤ��롣
358  */
359 };
360 
361 struct wnn_ret_buf
362 {
363   int size;                     /* buf ���� alloc ����Ƥ����礭�� */
364   char *buf;                    /* malloc �ʤɤǤȤ�줿�ΰ� */
365 };
366 
367 
368 #define WNN_F_UNIQ_LEN  (sizeof(struct wnn_file_uniq))
369 
370 /* ���ι�¤�Τϡ��饤�֥���������Ѥ����� */
371 struct wnn_file_head
372 {
373   struct wnn_file_uniq
374   {
375     int time;
376     int dev;
377     int inode;
378     char createhost[WNN_HOSTLEN];
379   }
380   file_uniq;
381   struct wnn_file_uniq file_uniq_org;
382   int file_type;
383   char file_passwd[WNN_PASSWD_LEN];
384 };
385 
386 #define WNN_HINSI_NAME_LEN 64
387 
388 #define WNN_FILE_HEADER_LEN     (WNN_PASSWD_LEN + 8 + WNN_FILE_STRING_LEN + \
389                                  sizeof(struct wnn_file_uniq) * 2 + 4)
390                                 /*
391                                    8 is for future use
392                                    4 is for file_type.
393                                  */
394 
395 #ifndef JSERVER
396 /*
397   JSLIB function declaration
398 */
399 #define js_open(server, timeout)        js_open_lang(server, "ja_JP", timeout)
400 #define js_connect(server,env_name)     js_connect_lang(server, env_name, "ja_JP")
401 
402 extern WNN_JSERVER_ID *js_open_lang ();
403 extern int js_close ();
404 extern WNN_JSERVER_ID *js_change_current_jserver ();
405 extern struct wnn_env *js_connect_lang ();
406 extern int js_disconnect ();
407 extern int js_env_list ();
408 extern int js_param_set ();
409 extern int js_param_get ();
410 extern char *js_get_lang ();
411 /**************************************/
412 extern int js_access ();
413 extern int js_dic_add ();
414 extern int js_dic_delete ();
415 extern int js_dic_file_create ();
416 extern int js_dic_file_create_client ();
417 extern int js_dic_info ();
418 extern int js_dic_list ();
419 extern int js_dic_list_all ();
420 extern int js_dic_use ();
421 extern int js_env_exist ();
422 extern int js_env_sticky ();
423 extern int js_env_un_sticky ();
424 extern int js_file_comment_set ();
425 extern int js_file_discard ();
426 extern int js_file_info ();
427 extern int js_file_list ();
428 extern int js_file_list_all ();
429 extern int js_file_loaded ();
430 extern int js_file_loaded_local ();
431 extern int js_file_password_set ();
432 extern int js_file_read ();
433 extern int js_file_receive ();
434 extern int js_file_remove ();
435 extern int js_file_remove_client ();
436 extern int js_file_send ();
437 extern int js_file_stat ();
438 extern int js_file_write ();
439 extern void js_flush ();
440 extern int js_fuzokugo_get ();
441 extern int js_fuzokugo_set ();
442 extern int js_hindo_file_create ();
443 extern int js_hindo_file_create_client ();
444 extern int js_hindo_set ();
445 extern int js_hinsi_dicts ();
446 extern int js_hinsi_list ();
447 extern int js_hinsi_name ();
448 extern int js_hinsi_number ();
449 extern int js_hinsi_table_set ();
450 extern int js_isconnect ();
451 extern int js_kanren ();
452 extern int js_kantan_dai ();
453 extern int js_kantan_sho ();
454 extern int js_kanzen_dai ();
455 extern int js_kanzen_sho ();
456 extern int js_kill ();
457 extern int js_mkdir ();
458 extern int js_version ();
459 extern int js_who ();
460 extern int js_word_add ();
461 extern int js_word_comment_set ();
462 extern int js_word_delete ();
463 extern int js_word_info ();
464 extern int js_word_search ();
465 extern int js_word_search_by_env ();
466 
467 #endif
468 #endif  /* WNN_JSLIB_H */
469