1/* Copyright 1992 NEC Corporation, Tokyo, Japan.
2 *
3 * Permission to use, copy, modify, distribute and sell this software
4 * and its documentation for any purpose is hereby granted without
5 * fee, provided that the above copyright notice appear in all copies
6 * and that both that copyright notice and this permission notice
7 * appear in supporting documentation, and that the name of NEC
8 * Corporation not be used in advertising or publicity pertaining to
9 * distribution of the software without specific, written prior
10 * permission.  NEC Corporation makes no representations about the
11 * suitability of this software for any purpose.  It is provided "as
12 * is" without express or implied warranty.
13 *
14 * NEC CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
16 * NO EVENT SHALL NEC CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
18 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19 * OTHER TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
21 */
22
23/************************************************************************/
24/* THIS SOURCE CODE IS MODIFIED FOR TKO BY T.MURAI 1997
25/************************************************************************/
26
27
28#if !defined(lint) && !defined(__CODECENTER__)
29static char rcs_id[] = "@(#) 102.1 $Id: commondata.c 10525 2004-12-23 21:23:50Z korli $";
30#endif /* lint */
31
32#include "canna.h"
33#include <canna/mfdef.h>
34#include "patchlevel.h"
35#include <Beep.h>
36
37struct CannaConfig cannaconf;
38
39/* �������������������������������������������������������������������������������� */
40
41int defaultContext = -1;
42int defaultBushuContext = -1;
43
44/* ������������������������������������������������ */
45/*
46 * ������������������������������������������������������������������������������������������������������������������������������������
47 * ������������ RomeStruct ����������������������������������������������������������������������������������������...����
48 * ��������������������������������������������������������
49 */
50
51struct RkRxDic *romajidic, *englishdic;
52
53/* ������������������������������������������������������������ */
54
55int howToBehaveInCaseOfUndefKey = kc_normal;
56
57/*
58 * ����������������������������������������������������
59 */
60
61char saveapname[CANNA_MAXAPPNAME]; /* ����������������������������������������������������AP���� */
62
63/*
64 * irohacheck ������������������������������������������������������������������������
65 * irohacheck ���������������� verbose ��������������������
66 */
67
68int ckverbose = 0;
69
70/*
71 * ��������������������������������������������������������������������
72 */
73
74char *jrKanjiError = "";
75
76/*
77 * ����������������������������������������������������������������������������
78 */
79
80int iroha_debug = 0;
81
82/*
83 * ����������������������������������������������������������������
84 */
85
86int FirstTime = 1;
87
88/*
89* dictonary base path
90*/
91
92char basepath[256];
93
94/*
95 * ������������������������������������������������������������������������
96 */
97
98int (*jrBeepFunc)() = (int (*)())NULL;
99//int (*jrBeepFunc)() = (int (*)())beep();
100
101/*
102 * KC_INITIALIZE ��������������������������������������������
103 */
104
105BYTE *initfunc = (BYTE *)0;
106int howToReturnModeInfo = ModeInfoStyleIsString;
107char *RomkanaTable = (char *)NULL;
108char *EnglishTable = (char *)NULL;
109/* char *Dictionary = (char *)NULL; */
110struct dicname *RengoGakushu = (struct dicname *)NULL;
111struct dicname *KatakanaGakushu = (struct dicname *)NULL;
112struct dicname *HiraganaGakushu = (struct dicname *)NULL;
113
114int nKouhoBunsetsu = 16;
115
116int KeepCursorPosition = 0;
117
118int nothermodes = 0;
119
120keySupplement keysup[MAX_KEY_SUP];
121int nkeysup = 0;
122
123/*
124 * ������������������������������������������������������������������������������������������������������������������������
125 * ������������������������","����������������������������(����������������������������)
126 */
127
128char *CANNA_initfilename = (char *)NULL;
129
130/*
131 * ��������������������
132 */
133
134int protocol_version = -1;
135int server_version = -1;
136char *server_name = (char *)NULL;
137
138int chikuji_debug = 0;
139int auto_define = 0;
140
141int locale_insufficient = 0;
142
143void (*keyconvCallback)(...) = (void (*)(...))0;
144
145extraFunc *extrafuncp = (extraFunc *)NULL;
146struct dicname *kanjidicnames; /* .canna ������������������������������������������������ */
147char *kataautodic = (char *)NULL; /* ������������������������������������������������ */
148#ifdef HIRAGANAAUTO
149char *hiraautodic = (char *)NULL; /* ������������������������������������������������ */
150#endif
151
152static void freeUInfo(void);
153
154/* �������������������� */
155jrUserInfoStruct *uinfo = (jrUserInfoStruct *)NULL;
156
157/* ������������������������������������������������������������ */
158int standalone = 0;
159
160void
161InitCannaConfig(struct CannaConfig *cf)
162{
163  bzero(cf, sizeof(struct CannaConfig));
164  cf->CannaVersion = CANNA_MAJOR_MINOR;
165  cf->kouho_threshold = 2;
166  cf->strokelimit = STROKE_LIMIT;
167  cf->CursorWrap = 1;
168  cf->SelectDirect = 1;
169  cf->HexkeySelect = 1;
170  cf->ChBasedMove = 1;
171  cf->Gakushu = 1;
172  cf->grammaticalQuestion = 1;
173  cf->stayAfterValidate = 1;
174  cf->kCount = 1;
175  cf->hexCharacterDefiningStyle = HEX_USUAL;
176  cf->ChikujiContinue = 1;
177  cf->MojishuContinue = 1;
178  cf->kojin = 1;
179  cf->indexSeparator = DEFAULTINDEXSEPARATOR;
180  cf->allowNextInput = 1;
181  cf->chikujiRealBackspace = 1;
182  cf->BackspaceBehavesAsQuit = 1;
183  cf->doKatakanaGakushu = 1;
184  cf->doHiraganaGakushu = 1;
185  cf->auto_sync = 1;
186}
187
188static void freeUInfo (void);
189
190static void
191freeUInfo(void)
192{
193  if (uinfo) {
194    if (uinfo->uname)
195      free(uinfo->uname);
196    if (uinfo->gname)
197      free(uinfo->gname);
198    if (uinfo->srvname)
199      free(uinfo->srvname);
200    if (uinfo->topdir)
201      free(uinfo->topdir);
202    if (uinfo->cannafile)
203      free(uinfo->cannafile);
204    if (uinfo->romkanatable)
205      free(uinfo->romkanatable);
206    free(uinfo);
207    uinfo = (jrUserInfoStruct *)NULL;
208  }
209}
210
211/*
212  ������������������������������������������������
213*/
214void
215restoreBindings(void)
216{
217  InitCannaConfig(&cannaconf);
218
219  if (initfunc) free(initfunc);
220  initfunc = (BYTE *)NULL;
221
222  if (server_name) free(server_name);
223  server_name = (char *)NULL;
224
225  if (RomkanaTable) {
226    free(RomkanaTable);
227    RomkanaTable = (char *)NULL;
228  }
229  if (EnglishTable) {
230    free(EnglishTable);
231    EnglishTable = (char *)NULL;
232  }
233  romajidic = (struct RkRxDic *)NULL;
234  englishdic = (struct RkRxDic *)NULL;
235  RengoGakushu = (struct dicname *)NULL;
236  KatakanaGakushu = (struct dicname *)NULL;
237  HiraganaGakushu = (struct dicname *)NULL;
238  howToBehaveInCaseOfUndefKey = kc_normal;
239/*  kanjidicname[nkanjidics = 0] = (char *)NULL; ������������������������������������������������ */
240  kanjidicnames = (struct dicname *)NULL;
241  kataautodic = (char *)NULL;
242#ifdef HIRAGANAAUTO
243  hiraautodic = (char *)NULL;
244#endif
245  auto_define = 0;
246  saveapname[0] = '\0';
247  KeepCursorPosition = 0;
248
249  nothermodes = 0;
250  protocol_version = server_version = -1;
251  nKouhoBunsetsu = 16;
252  nkeysup = 0;
253  chikuji_debug = 0;
254  keyconvCallback = (void (*)(...))0;
255  locale_insufficient = 0;
256  freeUInfo();
257  standalone = 0;
258}
259