1 /*
2  * Copyright (c) 1991-1994  Sony Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sublicense, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL SONY CORPORATION BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * Except as contained in this notice, the name of Sony Corporation
24  * shall not be used in advertising or otherwise to promote the sale, use
25  * or other dealings in this Software without prior written authorization
26  * from Sony Corporation.
27  *
28  */
29 
30 /*
31  * $SonyRCSfile: sj3lib.h,v $
32  * $SonyRevision: 1.1 $
33  * $SonyDate: 1994/06/03 08:03:57 $
34  */
35 
36 
37 #ifndef SJ3LIB_H
38 #define SJ3LIB_H
39 
40 #include <sys/types.h>
41 
42 #define SJ3_NORMAL_END         0
43 #define SJ3_SERVER_DEAD        (1 << 0)
44 
45 
46 
47 #define SJ3_CONNECT_ERROR      (1 << 1)
48 #define SJ3_ALREADY_CONNECTED  (1 << 2)
49 #define SJ3_CANNOT_OPEN_MDICT  (1 << 3)
50 #define SJ3_CANNOT_OPEN_UDICT  (1 << 4)
51 #define SJ3_CANNOT_OPEN_STUDY  (1 << 5)
52 #define SJ3_CANNOT_MAKE_UDIR   (1 << 6)
53 #define SJ3_CANNOT_MAKE_UDICT  (1 << 7)
54 #define SJ3_CANNOT_MAKE_STUDY  (1 << 8)
55 
56 
57 
58 #define SJ3_DISCONNECT_ERROR   (1 << 1)
59 #define SJ3_NOT_CONNECTED      (1 << 2)
60 #define SJ3_NOT_OPENED_MDICT   (1 << 3)
61 #define SJ3_NOT_OPENED_UDICT   (1 << 4)
62 #define SJ3_NOT_OPENED_STUDY   (1 << 5)
63 #define SJ3_CLOSE_MDICT_ERROR  (1 << 6)
64 #define SJ3_CLOSE_UDICT_ERROR  (1 << 7)
65 #define SJ3_CLOSE_STUDY_ERROR  (1 << 8)
66 
67 
68 
69 #define SJ3_DICT_ERROR      1
70 #define SJ3_DICT_LOCKED     2
71 #define SJ3_BAD_YOMI_STR    3
72 #define SJ3_BAD_KANJI_STR   4
73 #define SJ3_BAD_HINSI_CODE  5
74 
75 #define SJ3_WORD_EXIST      6
76 #define SJ3_DOUON_FULL      7
77 #define SJ3_DICT_FULL       8
78 #define SJ3_INDEX_FULL      9
79 #define SJ3_TOUROKU_FAILED  10
80 
81 #define SJ3_WORD_NOT_EXIST  6
82 #define SJ3_SYOUKYO_FAILED  10
83 
84 
85 
86 
87 #define SJ3_IKKATU_YOMI     512
88 
89 
90 
91 
92 #define SJ3_BUNSETU_YOMI    128
93 #define SJ3_BUNSETU_KANJI   512
94 
95 
96 
97 
98 #ifndef SJ3_WORD_ID_SIZE
99 # define SJ3_WORD_ID_SIZE   32
100 #endif
101 
102 typedef struct studyrec {
103  unsigned char dummy[SJ3_WORD_ID_SIZE];
104 } SJ3_STUDYREC;
105 
106 
107 
108 
109 typedef struct bunsetu {
110  int srclen;
111  int destlen;
112  unsigned char *srcstr;
113  unsigned char *deststr;
114  struct studyrec dcid;
115 } SJ3_BUNSETU;
116 
117 
118 
119 typedef struct douon {
120  unsigned char ddata[SJ3_BUNSETU_KANJI];
121  int  dlen;
122  SJ3_STUDYREC dcid;
123 } SJ3_DOUON;
124 
125 
126 
127 #define SJ3_H_NRMNOUN 1
128 #define SJ3_H_PRONOUN 12
129 #define SJ3_H_LNAME   21
130 #define SJ3_H_FNAME   22
131 #define SJ3_H_LOCNAME 24
132 #define SJ3_H_PREFIC  25
133 #define SJ3_H_RENTAI  26
134 #define SJ3_H_CONJUNC 27
135 #define SJ3_H_SUBNUM  29
136 #define SJ3_H_NUMERAL 30
137 #define SJ3_H_PREFIX  31
138 #define SJ3_H_POSTFIX 36
139 #define SJ3_H_ADVERB  45
140 #define SJ3_H_ADJECT  60
141 #define SJ3_H_ADJVERB 71
142 #define SJ3_H_SILVERB 80
143 #define SJ3_H_ZILVERB 81
144 #define SJ3_H_ONEVERB 90
145 #define SJ3_H_KAVERB  91
146 #define SJ3_H_GAVERB  92
147 #define SJ3_H_SAVERB  93
148 #define SJ3_H_TAVERB  94
149 #define SJ3_H_NAVERB  95
150 #define SJ3_H_BAVERB  96
151 #define SJ3_H_MAVERB  97
152 #define SJ3_H_RAVERB  98
153 #define SJ3_H_WAVERB  99
154 #define SJ3_H_SINGLE  189
155 
156 /* sj3.c */
157 int sj3_open(char *, char *);
158 
159 int sj3_open_with_list(char *, char *, int, char **, int *, int **);
160 
161 int sj3_close();
162 
163 int sj3_getkan(u_char *, SJ3_BUNSETU *, u_char *, int);
164 int sj3_getkan_euc(u_char *, SJ3_BUNSETU *, u_char *, int);
165 int sj3_getkan_mb(u_char *, SJ3_BUNSETU *, u_char *, int);
166 
167 int sj3_douoncnt(u_char *);
168 int sj3_douoncnt_euc(u_char *);
169 int sj3_douoncnt_mb(u_char *);
170 
171 int sj3_getdouon(u_char *, SJ3_DOUON *);
172 int sj3_getdouon_euc(u_char *, SJ3_DOUON *);
173 int sj3_getdouon_mb(u_char *, SJ3_DOUON *);
174 
175 int sj3_gakusyuu(SJ3_STUDYREC *);
176 
177 int sj3_gakusyuu2(u_char *, u_char *, SJ3_STUDYREC *);
178 int sj3_gakusyuu2_euc(u_char *, u_char *, SJ3_STUDYREC *);
179 int sj3_gakusyuu2_mb(u_char *, u_char *, SJ3_STUDYREC *);
180 
181 int sj3_touroku(u_char *, u_char *, int);
182 int sj3_touroku_euc(u_char *, u_char *, int);
183 int sj3_touroku_mb(u_char *, u_char *, int);
184 
185 int sj3_syoukyo(u_char *, u_char *, int);
186 int sj3_syoukyo_euc(u_char *, u_char *, int);
187 int sj3_syoukyo_mb(u_char *, u_char *, int);
188 
189 int sj3_getdict(u_char *);
190 int sj3_getdict_euc(u_char *);
191 int sj3_getdict_mb(u_char *);
192 
193 int sj3_nextdict(u_char *);
194 int sj3_nextdict_euc(u_char *);
195 int sj3_nextdict_mb(u_char *);
196 
197 int sj3_prevdict(u_char *);
198 int sj3_prevdict_euc(u_char *);
199 int sj3_prevdict_mb(u_char *);
200 
201 int sj3_lockserv();
202 
203 int sj3_unlockserv();
204 
205 extern int sj3_error_number;
206 
207 #ifdef SJ3LIB_INTERNAL
208 
209 #include "sj3lowlib.h"
210 #include "sjcompat.h"
211 
212 /* level1.c */
213 int sj3_set_timeout(int);
214 int sj3_make_connection(SJ3_CLIENT_ENV *, char *, char *, char *);
215 int sj3_erase_connection(SJ3_CLIENT_ENV *);
216 long sj3_open_dictionary(SJ3_CLIENT_ENV *, char *, char *);
217 int sj3_close_dictionary(SJ3_CLIENT_ENV *, long);
218 int sj3_open_study_file(SJ3_CLIENT_ENV *, char *, char *);
219 int sj3_close_study_file(SJ3_CLIENT_ENV *);
220 int sj3_get_id_size(SJ3_CLIENT_ENV *);
221 int sj3_lock_server(SJ3_CLIENT_ENV *);
222 int sj3_unlock_server(SJ3_CLIENT_ENV *);
223 int sj3_ikkatu_henkan(SJ3_CLIENT_ENV *, u_char *, u_char *, int, int);
224 int sj3_bunsetu_henkan(SJ3_CLIENT_ENV *, u_char *, int, u_char *, int);
225 int sj3_bunsetu_jikouho(SJ3_CLIENT_ENV *, u_char *, int, int);
226 int sj3_bunsetu_maekouho(SJ3_CLIENT_ENV *, u_char *, int, int);
227 int sj3_bunsetu_kouhosuu(SJ3_CLIENT_ENV *, u_char *, int, int);
228 int sj3_bunsetu_zenkouho(SJ3_CLIENT_ENV *, u_char *, int, SJ3_DOUON *, int);
229 int sj3_tango_gakusyuu(SJ3_CLIENT_ENV *, SJ3_STUDYREC *);
230 int sj3_bunsetu_gakusyuu(SJ3_CLIENT_ENV *, u_char *, u_char *, SJ3_STUDYREC *, int);
231 int sj3_tango_touroku(SJ3_CLIENT_ENV *, long, u_char *, u_char *, int, int);
232 int sj3_tango_sakujo(SJ3_CLIENT_ENV *, long, u_char *, u_char *, int, int);
233 int sj3_tango_syutoku(SJ3_CLIENT_ENV *, int, u_char *, int);
234 int sj3_tango_jikouho(SJ3_CLIENT_ENV *, int, u_char *, int);
235 int sj3_tango_maekouho(SJ3_CLIENT_ENV *, int, u_char *, int);
236 int sj3_make_dict_file(SJ3_CLIENT_ENV *, char *, int, int, int);
237 int sj3_make_study_file(SJ3_CLIENT_ENV *, char *, int, int, int);
238 int sj3_make_directory(SJ3_CLIENT_ENV *, char *);
239 int sj3_access(SJ3_CLIENT_ENV *, char *, int);
240 int sj3_who(SJ3_CLIENT_ENV *, SJ3_WHO_STRUCT *, int);
241 int sj3_quit(SJ3_CLIENT_ENV *);
242 int sj3_kill(SJ3_CLIENT_ENV *);
243 int sj3_version(SJ3_CLIENT_ENV *, char *, int);
244 
245 /* string.c */
246 int sj3_str_sjistoeuc(unsigned char *, int, unsigned char *, unsigned char *, int *);
247 int sj3_str_euctosjis(unsigned char *, int, unsigned char *, unsigned char *, int *);
248 int sj3_sjistoeuclen(unsigned char *, int);
249 #if !defined(__sony_news) || (defined(__sony_news) && !defined(SVR4))
250 int sj3_sjistoeuc(unsigned char *s, int, unsigned char *, int);
251 int sj3_euctosjis(unsigned char *s, int, unsigned char *, int);
252 void sj_euc2sjis(unsigned char *);
253 void sj_jis2sjis(unsigned char *);
254 void sj_sjis2euc(unsigned char *);
255 void sj_sjis2jis(unsigned char *);
256 unsigned short sj3_jis2sjis(unsigned short);
257 unsigned short sj3_jis2euc(unsigned short);
258 unsigned short sj3_sjis2jis(unsigned short);
259 unsigned short sj3_euc2sjis(unsigned short);
260 unsigned short sj3_sjis2euc(unsigned short);
261 #ifndef SVR4
262 int sj3_sjistoeuc(unsigned char *, int, unsigned char *, int);
263 int sj3_euctosjis(unsigned char *, int, unsigned char *, int);
264 #endif
265 #endif /* !defined(__sony_news) || (defined(__sony_news) && !defined(SVR4)) */
266 
267 #endif /* SJ3LIB_INTERNAL */
268 
269 #endif /* SJ3LIB_H */
270