diff --git a/ChangeLog.n b/ChangeLog.n
index 5502cdee48a1748070362f48a0d3dbd3ad7ebc14..c0fffc679e524b3397cd51ac7980e5ec55172b36 100644
--- a/ChangeLog.n
+++ b/ChangeLog.n
@@ -1,3 +1,89 @@
+
+*************************************************************
+
+Wed Mar 13 01:49:35 PST 1996	Colin Meldrum	(colin@vapor)
+
+Makefile.hpprism-ja, Makefile.sun4-ja
+
+Makefile.rs6000
+	added SAVEEXPI and RESTEXPI for ICS
+
+Makefile.<ARCH>
+	added STD_DEFINES + AR defn for building Wnn
+	got rid of WNNLIB defns - now we build it and it's always in
+	clim-2.0/libwnn.a 
+
+Makefile.cobjs
+
+	changed mainxm.o not to only include stub-xt.o, stub-x.o and
+	stub-motif.o because they're the only ones that need to be in
+	mainxm.o - all the *support.o files are also included in the
+	distribution and can be linked in separately
+
+Makefile.defs
+	Added default SAVEEXP,RESTEXP
+	Added new SAVEEXPI,RESTEXPI for ICS
+	Added ICS-PRODUCT-FASLS + ICS-PRODUCT-OBJS
+
+Makefile.generic
+	Added ICS-PRODUCT-FASLS + ICS-PRODUCT-OBJS to compile, cat, clim
+	makclimobjs, makeclimfasls, install_obj + install_clim
+	fixed ucl/dcl.climsave bug in ucl.clim and xm-dcl rules
+	added new rules ucli.clim and xm-dcli rules
+	got rid of STATIC-WNN-OBJS-WITH-PWD hack
+
+clim/frames.lisp
+	frame-pointer-buttons-documentation removed 
+	frame-pointer-button-documentation added
+	frame-modifier-keys-documentation removed
+	frame-modifier-key-documentation added
+	
+demo/README
+	Got rid of reference to OpenLook
+
+demo/japanese-graphics-editor.lisp
+	fixed to work correctly with frame-modifier-key-documentation and
+	frame-pointer-button-documentation 
+
+misc/compile-1.lisp
+	always compile-system 'wnn - even if with non-ICS lisp - no fat
+	strings so not a problem
+
+silica/text-style.lisp
+	fixed device-fonts + text-style-mapping
+
+sys/sysdcl.lisp
+	Got rid of defn of ics-target-case which expanded into
+	comp::ics-target-ecase - now it's available using
+	excl:ics-target-case directly
+
+test/testdcl.lisp
+	added a missing :serial constraint
+
+tk/load-xm.lisp
+	for ICS load clim2:;climxm.so with *dlopen-mode* #x102
+	fixed sys:*toolkit-static* bug which could result in re-initialzing
+	the toolkit twice on restart
+
+tk-silica/xm-gadgets.lisp
+	fixed typo in find-widget-resource-initargs-for-sheet which was
+	causing text-fields not to work correctly in ICS CLIM.
+
+* Added Wnn jlib code under clim-2.0/wnn so we can build it for each port
+without having to go to an entire X11 distribution - new files
+
+	bcopy.c bdic.c commonhd.h config.h cplib.h demcom.h
+	jd_sock.h jdata.h jh.h jl.c jllib.h js.c jslib.h
+	msg.c msg.h pwd.c py_table.c rk_bltinfn.c rk_extvars.h 
+	rk_fundecl.h rk_header.h rk_macros.h rk_main.c rk_modread.c
+	rk_read.c rk_spclval.h rk_vars.c strings.c wnn_os.h wnn_string.h
+	wnnerrmsg.c wnnerror.h yincoding.c zy_table.c 
+
+wnn/load-wnn.lisp	
+
+	Error if you try to load-wnn into a dlfcn lisp and the code isn't
+	already statically linked
+
 *************************************************************
 
 Thu Feb 29 21:35:08 PST 1996	Colin Meldrum	(colin@vapor)
diff --git a/Makefile.alpha b/Makefile.alpha
index 690de92cbf0add970807418bbd4bdbe641d6723b..e7249e5baf99d8603b1a0820ecdd003495573d62 100644
--- a/Makefile.alpha
+++ b/Makefile.alpha
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.alpha,v 1.6 1995/05/17 19:47:10 colin Exp $
+# $fiHeader: Makefile.alpha,v 1.1 1996/01/23 06:46:22 duane Exp $
 #
 #  Makefile.alpha for CLIM 2.0
 #
@@ -8,6 +8,8 @@ include Makefile.defs
 Makefile=Makefile.alpha
 
 CFLAGS = -O -G 0 -taso -xtaso -xtaso_short -resumption_safe
+STD_DEFINES = -DDEC -DR5_XLIB -DSMT
+AR = ar cqls
 
 TKLIB=-lXm
 XTLIB=-lXt
@@ -21,7 +23,4 @@ PICFLAGS =
 SHAREFLAGS =
 MAKE_SHARED = make_shared
 
-SAVEEXP = echo no exports file in this port
-RESTEXP = echo no exports file in this port
-
 include Makefile.generic
diff --git a/Makefile.cobjs b/Makefile.cobjs
index bf723d2e68194279c17011469bbe4cb5e0d76dbb..c24e14b9b7255b8a7f1970f07fdf188bfe6094d7 100644
--- a/Makefile.cobjs
+++ b/Makefile.cobjs
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.cobjs,v 1.10 1995/10/17 05:00:54 colin Exp $
+# $fiHeader: Makefile.cobjs,v 1.12 1995/11/08 06:11:10 georgej Exp $
 #
 #  Makefile.cobj for CLIM 2.0
 #
@@ -64,12 +64,13 @@ climol.so: xlibsupport.o xtsupport.o olsupport.o
 		xlibsupport.o xtsupport.o olsupport.o \
 		$(IMPORTS) $(TKLIB) $(XTLIB) $(XLIB))
 
-# mainxm.o contains all foreign code required by Motif version of CLIM 
-# (including code extracted from licenced libXm.a) statically linked
+# mainxm.o contains foreign code from the libraries X11,Xt and Xm
+# required by Motif version of CLIM statically linked
 
-mainxm.o: $(ACL_MAIN_OBJ) $(PRODUCT-GENERIC-OBJS) $(STATIC-XM-OBJS) $(STATIC-WNN-OBJS)
+mainxm.o: $(ACL_MAIN_OBJ) $(PRODUCT-GENERIC-OBJS) $(STATIC-XM-OBJS) 
 	(eval '$(SET_LIBRARY_PATH)' ; \
 	ld -r $(LDFLAGS) -o mainxm.o \
 		$(ACL_MAIN_OBJ) \
-		$(PRODUCT-GENERIC-OBJS) $(STATIC-XM-OBJS) $(STATIC-WNN-OBJS) \
-		$(TKLIB) $(XTLIB) $(XLIB) $(WNNLIB) $(MOTIFXTRAS))
+		stub-xt.o stub-x.o stub-motif.o \
+		$(TKLIB) $(XTLIB) $(XLIB) $(MOTIFXTRAS))
+
diff --git a/Makefile.defs b/Makefile.defs
index 5edad15c9371e20370cf296f183e1003bf9bb352..dc1846a4630b3882ce9a9470e8e4b259810f9bcc 100644
--- a/Makefile.defs
+++ b/Makefile.defs
@@ -1,9 +1,9 @@
-# $fiHeader: Makefile.defs,v 1.34 1995/10/20 17:36:03 colin Exp $
+# $fiHeader: Makefile.defs,v 1.35 1996/03/01 05:41:26 colin Exp $
 #
 #  Makefile.defs for CLIM 2.0
 #
 
-CL	= /usr/fi/dcl-devel
+CL	= ../src/dcl
 CLOPTS	= -qq -batch -backtrace-on-error
 
 DEVICE	= /dev/null
@@ -52,6 +52,11 @@ OLDSPACE = 15000000
 NEWSPACE = 5000000
 PREMALLOCS = '-m 401408'
 
+SAVEEXP	= echo no exports file in this port
+RESTEXP = echo no exports file in this port
+SAVEEXPI = echo no exports file in this port
+RESTEXPI = echo no exports file in this port
+
 # Used for tags
 ALL_SRC = *.lisp */*.lisp *.cl */*.cl *.c */*.c *.h */*.h
 
@@ -98,12 +103,19 @@ SHARED-XM-OBJS= climxm.so
 STATIC-OL-OBJS= stub-olit.o olsupport.o
 SHARED-OL-OBJS= climol.so
 
+WNNLIB = libwnn.a
+STATIC-WNN-OBJS=stub-wnn.o $(WNNLIB)
+
 # The default is for statically linked Motif
 
 SYSTEM=		motif-clim
+
 PRODUCT-FASLS=  $(PRODUCT-GENERIC-FASLS) $(PRODUCT-XM-FASLS)
 PRODUCT-OBJS=	$(PRODUCT-GENERIC-OBJS) $(STATIC-XM-OBJS)
 
+ICS-PRODUCT-FASLS= $(PRODUCT-WNN-FASLS)
+ICS-PRODUCT-OBJS=  $(STATIC-WNN-OBJS)
+
 #
 # "Load time objects" -- these go into clim.fasl
 #
diff --git a/Makefile.generic b/Makefile.generic
index 37263d6457c3a9fe467097136ebef6d946fdaa8f..409740678ef94ebc3fccd0d22b16e8f82e4d23b7 100644
--- a/Makefile.generic
+++ b/Makefile.generic
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.generic,v 1.33 1995/11/08 06:11:13 georgej Exp $
+# $fiHeader: Makefile.generic,v 1.34 1996/03/01 05:41:30 colin Exp $
 #
 #  Makefile.generic for CLIM 2.0
 #
@@ -10,7 +10,7 @@ trained:
 
 FORCE:
 
-compile: FORCE $(PRODUCT-OBJS)
+compile: FORCE $(PRODUCT-OBJS) $(ICS-PRODUCT-OBJS)
 	(eval '$(SET_LIBRARY_PATH)' ; \
 	$(ECHO) " \
 	(progn \
@@ -34,7 +34,7 @@ compile: FORCE $(PRODUCT-OBJS)
 
 # Concatenation
 
-cat: $(PRODUCT-FASLS)
+cat: $(PRODUCT-FASLS) $(ICS-PRODUCT-FASLS)
 
 climg.fasl: $(GENERIC-FASLS)
 	$(CAT) $(GENERIC-FASLS) > $(TMP)/clim.fasl_`whoami`
@@ -112,7 +112,7 @@ clim1compat.fasl: $(CLIM1COMPAT-FASLS)
 
 # Building (loading and dumping)
 
-clim: FORCE $(PRODUCT-OBJS)
+clim: FORCE $(PRODUCT-OBJS) $(ICS-PRODUCT-OBJS)
 	-$(RM) -f $(CLIM)
 	(eval '$(SET_LIBRARY_PATH)' ; \
 	$(ECHO) " \
@@ -198,7 +198,7 @@ cleanobjs:
 
 clean:
 	find . -name '*.fasl' -print | xargs rm -f
-	rm -f *.o *.so slim slim.ol \
+	rm -f *.o *.so *.a slim slim.ol \
 	  	stub-motif.c stub-olit.c stub-xt.c stub-x.c stub-wnn.c
 	rm -f *.z *.Z *.gz *.ilt *.out
 
@@ -225,48 +225,73 @@ echo_TKLIB:
 echo_WNNLIB:
 	@echo $(WNNLIB)
 
-makeclimfasls: compile cat
+makeclimobjs: $(PRODUCT-OBJS) $(ICS-PRODUCT-OBJS)
 
 install_obj:
-	cp $(PRODUCT-OBJS) $(DEST)
-	
+	cp $(PRODUCT-OBJS) $(ICS-PRODUCT-OBJS) $(DEST)
+
+makeclimfasls: compile cat
+
 install_clim: install_obj
-	cp $(PRODUCT-FASLS) $(DEST)
+	cp $(PRODUCT-FASLS) $(ICS-PRODUCT-FASLS) $(DEST)
 
 echo_src_files:
 	@echo $(PRODUCT_SRC_FILES)
 
-makeclimobjs: $(PRODUCT-OBJS)
 
 ################## Lower level Makefile stuff
 
-# re: STATIC-WNN-OBJS + STATIC-WNN-OBJS-WITH-PWD
-# I'm sorry - but for the moment I can't think of a better way to do this
+xm-dcl	: stub-x.o stub-xt.o stub-motif.o \
+		 xlibsupport.o xtsupport.o xmsupport.o
+	cd $(CL_SRC) ; \
+	/bin/mv dcl dcl.climsave ; /bin/mv ucl ucl.climsave ; $(SAVEEXP) ; \
+	make initial_oldspace=$(OLDSPACE) oldspace=$(OLDSPACE) \
+		newspace=$(NEWSPACE) premallocs=$(PREMALLOCS) stubs=$(stubs) \
+		user_objects='$(PWD)/stub-x.o $(PWD)/stub-xt.o $(PWD)/stub-motif.o \
+		$(PWD)/xlibsupport.o $(PWD)/xmsupport.o $(PWD)/xtsupport.o \
+		$(CL_SRC)/code/excldep.o $(CL_SRC)/code/socket.o \
+		$(TKLIB) $(XTLIB) $(XLIB)' dcl ;\
+	/bin/mv dcl xm-dcl ; \
+	/bin/mv dcl.climsave dcl ; /bin/mv ucl.climsave ucl; $(RESTEXP)
+
 
-xm-dcl	: stub-x.o $(STATIC-WNN-OBJS) stub-xt.o stub-motif.o \
+xm-dcli	: stub-x.o stub-xt.o stub-motif.o stub-wnn.o \
 		 xlibsupport.o xtsupport.o xmsupport.o
-	cd $(CL_SRC) ; /bin/mv ucl ucl.climsave ; $(SAVEEXP) ;\
+	cd $(CL_SRC) ; \
+	/bin/mv dcli dcli.climsave ; /bin/mv ucli ucli.climsave ; $(SAVEEXPI) ; \
 	make initial_oldspace=$(OLDSPACE) oldspace=$(OLDSPACE) \
 		newspace=$(NEWSPACE) premallocs=$(PREMALLOCS) stubs=$(stubs) \
-		user_objects='$(PWD)/stub-x.o $(STATIC-WNN-OBJS-WITH-PWD) $(PWD)/stub-xt.o \
-		$(PWD)/stub-motif.o $(PWD)/xlibsupport.o $(PWD)/xmsupport.o \
-		$(PWD)/xtsupport.o $(CL_SRC)/code/excldep.o $(CL_SRC)/code/socket.o \
-		$(TKLIB) $(XTLIB) $(XLIB) $(WNNLIB)' dcl ;\
-	/bin/mv ucl.climsave ucl; $(RESTEXP)
+		user_objects='$(PWD)/stub-x.o $(PWD)/stub-xt.o $(PWD)/stub-motif.o \
+		$(PWD)/stub-wnn.o \
+		$(PWD)/xlibsupport.o $(PWD)/xmsupport.o $(PWD)/xtsupport.o \
+		$(CL_SRC)/code/excldep.o $(CL_SRC)/code/socket.o \
+		$(TKLIB) $(XTLIB) $(XLIB) $(PWD)/libwnn.a' dcli ;\
+	/bin/mv dcli xm-dcli ; \
+	/bin/mv dcli.climsave dcli ; /bin/mv ucli.climsave ucli; $(RESTEXPI)
+
+ucl.clim: stub-x.o stub-xt.o stub-motif.o \
+		 xlibsupport.o xtsupport.o xmsupport.o
+	cd $(CL_SRC) ; /bin/mv ucl ucl.climsave ; $(SAVEEXP) ; \
+	make stubs=$(stubs) \
+		user_objects=' \
+		$(PWD)/stub-x.o $(PWD)/stub-xt.o $(PWD)/stub-motif.o \
+		$(PWD)/xlibsupport.o $(PWD)/xmsupport.o $(PWD)/xtsupport.o \
+		$(TKLIB) $(XTLIB) $(XLIB) $(MOTIFXTRAS)' ucl ;\
+	/bin/mv ucl ucl.clim ; $(RESTEXP) ; /bin/mv ucl.climsave ucl
 
-ucl.clim: stub-x.o $(STATIC-WNN-OBJS) stub-xt.o stub-motif.o \
+ucli.clim: stub-x.o stub-xt.o stub-motif.o stub-wnn.o \
 		 xlibsupport.o xtsupport.o xmsupport.o
-	cd $(CL_SRC) ; /bin/mv ucl ucl.climsave ;\
-	/bin/mv dcl dcl.climsave ; $(SAVEEXP) ;\
+	cd $(CL_SRC) ; /bin/mv ucli ucli.climsave ; $(SAVEEXPI) ; \
 	make stubs=$(stubs) \
 		user_objects=' \
-		$(PWD)/stub-x.o $(STATIC-WNN-OBJS-WITH-PWD) $(PWD)/stub-xt.o\
-		$(PWD)/stub-motif.o \
+		$(PWD)/stub-x.o $(PWD)/stub-xt.o $(PWD)/stub-motif.o \
+		$(PWD)/stub-wnn.o \
 		$(PWD)/xlibsupport.o $(PWD)/xmsupport.o $(PWD)/xtsupport.o \
-		$(TKLIB) $(XTLIB) $(XLIB) $(WNNLIB) $(MOTIFXTRAS)' ucl ;\
-	/bin/mv ucl ucl.clim ; $(RESTEXP) ; /bin/mv ucl.climsave ucl ; \
-	/bin/mv dcl.climsave dcl
+		$(TKLIB) $(XTLIB) $(XLIB) $(PWD)/libwnn.a $(MOTIFXTRAS)' ucli ;\
+	/bin/mv ucli ucli.clim ; $(RESTEXPI) ; /bin/mv ucli.climsave ucli
 
 ################## End of make-dist stuff
 
 include Makefile.cobjs
+
+include Makefile.wnn
diff --git a/Makefile.hpprism b/Makefile.hpprism
index 29af641759d2cadef182a57ebdfad6db477ee2cc..d788cfe0206e5e1d52aa6e16913ff9990e061be6 100644
--- a/Makefile.hpprism
+++ b/Makefile.hpprism
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.hpprism,v 1.7 1995/05/17 19:47:06 colin Exp $
+# $fiHeader: Makefile.hpprism,v 1.8 1995/10/20 17:36:08 colin Exp $
 #
 #  Makefile.hpprism for CLIM 2.0
 #
@@ -7,19 +7,20 @@ include Makefile.defs
 
 Makefile=Makefile.hpprism
 
-CL=/usr/fi/climdcl-devel
+CL=../src/xm-dcl
 
 CFLAGS= -O -D_NO_PROTO -DSTRINGS_ALIGNED -DNO_REGEX -DNO_ISDIR \
 	-DUSE_RE_COMP -DUSER_GETWD -Wp,-H1280000
+STD_DEFINES = -DSYSV
+AR = ar clq
 
 TKLIB=/usr/lib/Motif1.2/libXm.a
 XTLIB=/usr/lib/X11R5/libXt.a
 XLIB=/usr/lib/X11R5/libX11.a
 
-XINCLUDES= -I/usr/include/Motif1.2 -I/usr/include/X11R5
+# not needed anymore - we make libwnn.a in clim-2.0
+#WNNLIB=/usr/fi/X11R5/lib/libwnn.a
 
-# This is needed on the HP, because it doesn't like double semicolons:
-SAVEEXP = echo no exports file in this port
-RESTEXP = echo no exports file in this port
+XINCLUDES= -I/usr/include/Motif1.2 -I/usr/include/X11R5
 
 include Makefile.generic
diff --git a/Makefile.rs6000 b/Makefile.rs6000
index 9387b33a9d3b0fe0e1dd29684b6581a888551470..54ce5a46c72128ece2dd4deb81f248637ca3d08d 100644
--- a/Makefile.rs6000
+++ b/Makefile.rs6000
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.rs6000,v 1.3 1995/05/17 19:47:08 colin Exp $
+# $fiHeader: Makefile.rs6000,v 1.4 1995/10/20 17:36:10 colin Exp $
 #
 #  Makefile.rs6000 for CLIM 2.0
 #
@@ -18,7 +18,7 @@ XINCLUDES= -I/usr/include
 PRODUCT-OBJS= $(PRODUCT-GENERIC-OBJS) $(STATIC-XM-OBJS) $(SHARED-XM-OBJS)
 MAKE_SHARED = make_shared
 
-CL= /usr/fi/climdcl-devel
+CL= ../src/xm-dcl
 
 # This should be defined in make-dist. For CLIM devel (ie making
 # slim images) we use climdcl-devel and don't use the shared library
@@ -28,5 +28,7 @@ stubs = c2stubs
 
 SAVEEXP = /bin/mv ucl.exp ucl.exp.climsave
 RESTEXP = /bin/mv ucl.exp.climsave ucl.exp
+SAVEEXPI = /bin/mv ucli.exp ucli.exp.climsave
+RESTEXPI = /bin/mv ucli.exp.climsave ucli.exp
 
 include Makefile.generic
diff --git a/Makefile.sgi4d-svr4 b/Makefile.sgi4d-svr4
index d452820de27f574e0685d5ca1a7628d223ed701c..69a67a7637811ec8722d066408b09b213963e367 100644
--- a/Makefile.sgi4d-svr4
+++ b/Makefile.sgi4d-svr4
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.sgi4d-svr4,v 1.6 1995/05/17 19:47:10 colin Exp $
+# $fiHeader: Makefile.sgi4d-svr4,v 1.7 1995/10/20 17:36:12 colin Exp $
 #
 #  Makefile.sigi4d-svr4 for CLIM 2.0
 #
@@ -19,7 +19,4 @@ PICFLAGS = -KPIC
 SHAREFLAGS = -shared -all
 MAKE_SHARED = ld
 
-SAVEEXP = echo no exports file in this port
-RESTEXP = echo no exports file in this port
-
 include Makefile.generic
diff --git a/Makefile.sun4 b/Makefile.sun4
index 614dea94a247b421fa72dff498c45e688273c992..0632eb9e3f93b1cd5029bd9239ec28d18f830ca4 100644
--- a/Makefile.sun4
+++ b/Makefile.sun4
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.sun4,v 1.11 1995/04/07 01:09:06 georgej Exp $
+# $fiHeader: Makefile.sun4,v 1.12 1995/05/17 19:47:11 colin Exp $
 #
 #  Makefile.sun4 for CLIM 2.0
 #
@@ -12,7 +12,10 @@ MOTIFHOME=/net/vapor/3rd/motif-1.2.4
 XINCLUDES=-I$(MOTIFHOME)/usr/include
 
 TKLIB=$(MOTIFHOME)/usr/lib/libXm.a
-XTLIB=$(MOTIFHOME)/usr/lib/libXt.a
-XLIB=$(MOTIFHOME)/usr/lib/libX11.a 
+XTLIB=/net/louie/malle/colin/X11R5/Ximp-libs/libXt.a
+XLIB=/net/louie/malle/colin/X11R5/Ximp-libs/libX11.a
+
+# not needed anymore - we make libwnn.a in clim-2.0
+#WNNLIB=/usr/fi/X11R5/lib/libwnn.a
 
 include Makefile.generic
diff --git a/Makefile.sun4-svr4 b/Makefile.sun4-svr4
index 97aa08f106ee1bc0203630e8680bd24f4c3483bb..44b06a90d43248599e69782f0cebc0259eadfe96 100644
--- a/Makefile.sun4-svr4
+++ b/Makefile.sun4-svr4
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.sun4-svr4,v 1.9 1995/10/20 17:36:18 colin Exp $
+# $fiHeader: Makefile.sun4-svr4,v 1.10 1996/03/01 05:41:34 colin Exp $
 #
 #  Makefile.sun4-svr4 for CLIM 2.0
 #
@@ -17,6 +17,9 @@ TKLIB=-lXm
 XTLIB=-lXt
 XLIB=-lX11
 
+# not needed anymore - we make libwnn.a in clim-2.0
+#WNNLIB=/net/ultra/export/home/colin/X11R6/contrib/programs/Xsi/Wnn/jlib/libwnn.a
+
 SET_LIBRARY_PATH= \
   LD_LIBRARY_PATH=/usr/dt/lib:/usr/openwin/lib:/usr/lib; export LD_LIBRARY_PATH
 
@@ -33,8 +36,7 @@ MOTIFXTRAS=-lgen
 PICFLAGS = -K pic
 SHAREFLAGS = -G
 MAKE_SHARED = ld
-
-SAVEEXP = echo no exports file in this port
-RESTEXP = echo no exports file in this port
+STD_DEFINES = -DSVR4 -DSYSV
+AR = ar cq
 
 include Makefile.generic
diff --git a/Makefile.sunx86 b/Makefile.sunx86
index 41162a8b94a57531b62df6b5d34c784e548fa0d8..c4f5408a3d14929b8b98d2f76534adad590596ad 100644
--- a/Makefile.sunx86
+++ b/Makefile.sunx86
@@ -1,4 +1,4 @@
-# $fiHeader: Makefile.sun4-svr4,v 1.8 1995/10/17 05:00:59 colin Exp $
+# $fiHeader: Makefile.sunx86,v 1.1 1996/01/23 06:46:25 duane Exp $
 #
 #  Makefile.sun4-svr4 for CLIM 2.0
 #
@@ -37,7 +37,4 @@ PICFLAGS = -K pic
 SHAREFLAGS = -G
 MAKE_SHARED = ld
 
-SAVEEXP = echo no exports file in this port
-RESTEXP = echo no exports file in this port
-
 include Makefile.generic
diff --git a/Makefile.wnn b/Makefile.wnn
new file mode 100644
index 0000000000000000000000000000000000000000..8cf1886df9284e0b240911e4db3e8f647cfc57a8
--- /dev/null
+++ b/Makefile.wnn
@@ -0,0 +1,72 @@
+# $fiHeader: $
+#
+#  Makefile.wnn for CLIM 2.0
+#
+# Makefile for the jlib part of Wnn4.2
+
+
+WNNFLAGS = -DJAPANESE -DCHINESE -DKOREAN -DLATIN -DWRITE_CHECK -DWNNDEFAULT
+
+WNN_OBJS= js.o wnnerrmsg.o jl.o \
+	msg.o yincoding.o py_table.o zy_table.o strings.o bcopy.o \
+	rk_bltinfn.o rk_main.o rk_modread.o rk_read.o rk_vars.o
+
+js.o: wnn/js.c wnn/bdic.c wnn/pwd.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o js.o wnn/js.c
+
+wnnerrmsg.o : wnn/wnnerrmsg.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o wnnerrmsg.o wnn/wnnerrmsg.c
+
+jl.o : wnn/jl.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o jl.o wnn/jl.c
+
+msg.o : wnn/msg.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o msg.o wnn/msg.c
+
+yincoding.o : wnn/yincoding.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o yincoding.o wnn/yincoding.c
+
+py_table.o : wnn/py_table.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o py_table.o wnn/py_table.c
+
+zy_table.o : wnn/zy_table.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o zy_table.o wnn/zy_table.c
+
+strings.o : wnn/strings.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o strings.o wnn/strings.c
+
+bcopy.o : wnn/bcopy.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o bcopy.o wnn/bcopy.c
+
+rk_bltinfn.o : wnn/rk_bltinfn.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o rk_bltinfn.o wnn/rk_bltinfn.c
+
+rk_main.o : wnn/rk_main.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o rk_main.o wnn/rk_main.c
+
+rk_modread.o : wnn/rk_modread.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o rk_modread.o wnn/rk_modread.c
+
+rk_read.o : wnn/rk_read.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o rk_read.o wnn/rk_read.c
+
+rk_vars.o : wnn/rk_vars.c
+	$(CC) -c $(WNNFLAGS) $(STD_DEFINES) $(CFLAGS) \
+		-o rk_vars.o wnn/rk_vars.c
+
+libwnn.a: $(WNN_OBJS)
+	$(AR) $@ $(WNN_OBJS)
+
diff --git a/clim/frames.lisp b/clim/frames.lisp
index 600e2e0ab88d8747908ee15d1fc490036105b71b..524ab43492db3b37e3a9d4ebff2b615b53ea7d92 100644
--- a/clim/frames.lisp
+++ b/clim/frames.lisp
@@ -1,6 +1,6 @@
 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: CLIM-INTERNALS; Base: 10; Lowercase: Yes -*-
 
-;; $fiHeader: frames.lisp,v 1.80 1995/10/20 17:37:29 colin Exp $
+;; $fiHeader: frames.lisp,v 1.81 1996/03/01 05:41:55 colin Exp $
 
 (in-package :clim-internals)
 
@@ -1417,13 +1417,21 @@
 	    (when string
 	      (write-string string stream))))))))
 
-(defmethod frame-pointer-buttons-documentation
-    ((frame standard-application-frame))
-  '("L" "M" "R"))
-
-(defmethod frame-modifier-keys-documentation
-    ((frame standard-application-frame))
-  '("h" "s" "m" "c" "sh"))
+(defmethod frame-pointer-button-documentation
+    ((frame standard-application-frame) button)
+  (case button
+    (:left "L")
+    (:middle "M")
+    (:right "R")))
+
+(defmethod frame-modifier-key-documentation
+    ((frame standard-application-frame) modifier)
+  (case modifier
+    (:shift "sh")
+    (:control "c")
+    (:meta "m")
+    (:super "s")
+    (:hyper "h")))
 
 (defun frame-document-highlighted-presentation-1
        (frame presentation input-context window x y stream)
@@ -1434,61 +1442,68 @@
 			  right  right-presentation  right-context)
 	(find-applicable-translators-for-documentation presentation input-context
 						       frame window x y modifier-state)
-      (destructuring-bind (l m r) (frame-pointer-buttons-documentation frame)
-	(let ((modifier-names (frame-modifier-keys-documentation frame)))
-	  (let* ((*print-length* 3)
-		 (*print-level* 2)
-		 (*print-circle* nil)
-		 (*print-array* nil)
-		 (*print-readably* nil)
-		 (*print-pretty* nil))
-	    (flet ((document-translator (translator presentation context-type
-					 button-name separator)
-		     ;; Assumes 5 modifier keys and the reverse ordering of *MODIFIER-KEYS*
-		     (let ((bit #o20)
-			   (shift-name modifier-names))
-		       (declare (type fixnum bit))
-		       (repeat 5	;length of shift-name
-			       (unless (zerop (logand bit modifier-state))
-				 (write-string (car shift-name) stream)
-				 (write-string "-" stream))
-			       (pop shift-name)
-			       (setq bit (the fixnum (ash bit -1)))))
-		     (write-string button-name stream)
-		     (document-presentation-translator translator presentation context-type
-						       frame nil window x y
-						       :stream stream
-						       :documentation-type :pointer)
-		     (write-string separator stream)))
-	      (declare (dynamic-extent #'document-translator))
-	      ;;--- The button names should be hard-wired in.  Consider 1-button
-	      ;;--- Macs and 2-button PCs...
-	      (when left
-		(let ((button-name (cond ((and (eq left middle)
-					       (eq left right))
-					  (setq middle nil
-						right nil)
-					  (format nil "~A,~A,~A: " l m r))
-					 ((eq left middle)
-					  (setq middle nil)
-					  (format nil "~A,~A: " l m))
-					 (t
-					  (format nil "~A: " l)))))
-		  (document-translator left left-presentation left-context
-				       button-name (if (or middle right) "; " "."))))
-	      (when middle
-		(let ((button-name (cond ((eq middle right)
-					  (setq right nil)
-					  (format nil "~A,~A: " m r))
-					 (t
-					  (format nil "~A: " m)))))
-		  (document-translator middle middle-presentation middle-context
-				       button-name (if right "; " "."))))
-	      (when right
-		(document-translator right right-presentation right-context
-				     (format nil "~A: " r) "."))
-	      ;; Return non-NIL if any pointer documentation was produced
-	      (or left middle right))))))))
+      (let* ((*print-length* 3)
+	     (*print-level* 2)
+	     (*print-circle* nil)
+	     (*print-array* nil)
+	     (*print-readably* nil)
+	     (*print-pretty* nil))
+	(flet ((document-translator (translator presentation context-type
+				     button-names separator)
+		 ;; Assumes 5 modifier keys and the reverse ordering of *MODIFIER-KEYS*
+		 (let ((bit #o20)
+		       (shift-name '(:hyper :super :meta :control :shift)))
+		   (declare (type fixnum bit))
+		   (repeat 5		;length of shift-name
+			   (unless (zerop (logand bit modifier-state))
+			     (write-string
+			      (frame-modifier-key-documentation frame
+								(car shift-name))
+			      stream)
+			     (write-string "-" stream))
+			   (pop shift-name)
+			   (setq bit (the fixnum (ash bit -1)))))
+		 (write-string
+		  (frame-pointer-button-documentation frame (car button-names))
+		  stream)
+		 (dolist (button-name (cdr button-names))
+		   (write-string "," stream)
+		   (write-string
+		    (frame-pointer-button-documentation frame button-name)
+		    stream))
+		 (write-string ": " stream)
+		 (document-presentation-translator translator presentation context-type
+						   frame nil window x y
+						   :stream stream
+						   :documentation-type :pointer)
+		 (write-string separator stream)))
+	  (declare (dynamic-extent #'document-translator))
+	  ;;--- The button names should be hard-wired in.  Consider 1-button
+	  ;;--- Macs and 2-button PCs...
+	  (when left
+	    (let ((button-name (cond ((and (eq left middle)
+					   (eq left right))
+				      (setq middle nil
+					    right nil)
+				      '(:left :middle :right))
+				     ((eq left middle)
+				      (setq middle nil)
+				      '(:left :middle))
+				     (t '(:left)))))
+	      (document-translator left left-presentation left-context
+				   button-name (if (or middle right) "; " "."))))
+	  (when middle
+	    (let ((button-name (cond ((eq middle right)
+				      (setq right nil)
+				      (list :middle :right))
+				     (t '(:middle)))))
+	      (document-translator middle middle-presentation middle-context
+				   button-name (if right "; " "."))))
+	  (when right
+	    (document-translator right right-presentation right-context
+				 '(:right) "."))
+	  ;; Return non-NIL if any pointer documentation was produced
+	  (or left middle right))))))
 
 ;; This is derived directly from FIND-APPLICABLE-TRANSLATORS
 (defun find-applicable-translators-for-documentation
diff --git a/demo/README b/demo/README
index e479dd93f99428ba2bf1b0371acfc5f9c18b7a50..598e9446837ed4ef60ce7fa7201f5cfef99bf566 100644
--- a/demo/README
+++ b/demo/README
@@ -2,14 +2,15 @@
 ;; copyright (c) 1985, 1986 Franz Inc, Alameda, CA  All rights reserved.
 ;; copyright (c) 1986-1991 Franz Inc, Berkeley, CA  All rights reserved.
 
-;; $fiHeader$
+;; $fiHeader: README,v 1.1 1994/12/04 23:59:19 colin Exp $
 
 To run the CLIM demos.
 
 1. Load the demos with:
 
-	(require :clim-demoxm) for Motif 
-	(require :clim-demool) for OpenLook
+	(require :clim-demoxm) 
 
-2. Evaluate (clim-demo:start-demo)
+2. To start, evaluate:
+	
+	 (clim-demo:start-demo)
 
diff --git a/demo/japanese-graphics-editor.lisp b/demo/japanese-graphics-editor.lisp
index 560c006ceb0c4e85ed5fd68f3147bc6e44e478bf..dec3e20d0c5d5df54a1e14474e2e6cf97d152810 100644
--- a/demo/japanese-graphics-editor.lisp
+++ b/demo/japanese-graphics-editor.lisp
@@ -1,6 +1,6 @@
 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: JAPANESE-GRAPHICS-EDITOR; Base: 10; Lowercase: Yes -*-
 
-;; $fiHeader: japanese-graphics-editor.lisp,v 1.1 1995/10/20 17:37:59 colin Exp $
+;; $fiHeader: japanese-graphics-editor.lisp,v 1.2 1996/03/01 05:42:32 colin Exp $
 
 (in-package :japanese-graphics-editor)
 
@@ -317,11 +317,22 @@
 (defmethod frame-menu-translator-documentation ((frame graphics-editor))
   "��˥塼")
 
-(defmethod frame-pointer-buttons-documentation ((frame graphics-editor))
-  '("��" "��" "��"))
-
-(defmethod frame-modifier-keys-documentation ((frame graphics-editor))
-  '("h" "s" "m" "c" "sh"))
+(defmethod frame-pointer-button-documentation ((frame graphics-editor) button)
+  (case button
+    (:left "��")
+    (:middle "��")
+    (:right "��")))
+
+;; Perhaps these need to be localized. At present this method is
+;; identical to that on standard-application-frame.
+
+(defmethod frame-modifier-key-documentation ((frame graphics-editor) modifier)
+  (case modifier
+    (:shift "sh")
+    (:control "c")
+    (:meta "m")
+    (:super "s")
+    (:hyper "h")))
 
 (defmethod read-frame-command ((frame graphics-editor) &key (stream *standard-input*))
   (read-command (frame-command-table frame) :use-keystrokes t :stream stream))
diff --git a/misc/compile-1.lisp b/misc/compile-1.lisp
index b141e3e64eb96356350fa685c4f67c2d60609586..98c9b40d79fdd1a7fdcc26d98a9b5ebb8fbc5cb1 100644
--- a/misc/compile-1.lisp
+++ b/misc/compile-1.lisp
@@ -19,7 +19,7 @@
 ;; Commercial Software developed at private expense as specified in
 ;; DOD FAR Supplement 52.227-7013 (c) (1) (ii), as applicable.
 ;;
-;; $fiHeader: compile-1.lisp,v 1.27 1994/12/04 23:59:48 colin Exp $
+;; $fiHeader: compile-1.lisp,v 1.29 1995/11/08 06:12:20 georgej Exp $
 
 (in-package :user)
 
@@ -58,7 +58,6 @@
     (tenuring
      (excl:load-system sys))
 
-    #+ics
     (progn
       (excl:compile-system 'wnn :include-components t)
       (excl:load-system 'wnn))
diff --git a/silica/text-style.lisp b/silica/text-style.lisp
index 79fbd9dd9558126bec447e63ced5ad43a2b1f5be..ddd22a7f046949767ecfd3950d8688a1bb2a6132 100644
--- a/silica/text-style.lisp
+++ b/silica/text-style.lisp
@@ -1,6 +1,6 @@
 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: SILICA; Base: 10; Lowercase: Yes -*-
 
-;; $fiHeader: text-style.lisp,v 1.23 1995/10/20 17:40:47 colin Exp $
+;; $fiHeader: text-style.lisp,v 1.24 1996/03/01 05:42:55 colin Exp $
 
 (in-package :silica)
 
@@ -39,11 +39,11 @@
     (with-slots (family face size) style
       (format stream "~S ~S ~S" family  (face-code->face face) size))))
 
-(defclass device-font ()
+(defclass device-font (text-style)
      ((display-device :initarg :display-device :reader device-font-display-device)
-      (font-name :initarg :font-name :reader device-font-name)))
+      (font-name :initarg :font-name :accessor device-font-name)))
 
-(defun make-device-font (display-device font-name)
+(defun make-device-font-text-style (display-device font-name)
   (make-instance 'device-font :display-device display-device :font-name font-name))
 
 (defmethod print-object ((df device-font) stream)
@@ -610,6 +610,18 @@
 		mapping)))
 	(setf (gethash style mapping-table) mapping)))))
 
+(defmethod (setf text-style-mapping) (mapping (port basic-port) (style device-font)
+				      &optional (character-set *standard-character-set*)
+						window)
+  ;;--- What about the character set when using device fonts?
+  (declare (ignore character-set window))
+  ;;--- EQL? TYPE-EQUAL?  This is too restrictive as it stands
+  (unless (eq port (device-font-display-device style))
+    (error "An attempt was made to map device font ~S on port ~S, ~@
+	    but it is defined for the port ~S"
+	   style port (device-font-display-device style)))
+  (setf (device-font-name style) mapping))
+
 ;;; This is broken up into two methods so any :AROUND method will only
 ;;; be called on the outermost recursion.
 
@@ -637,6 +649,7 @@
 	   style port (device-font-display-device style)))
   (device-font-name style))
 
+
 (defmethod text-style-mapping* ((port basic-port) style
 				&optional (character-set *standard-character-set*)
 					  window)
diff --git a/sys/sysdcl.lisp b/sys/sysdcl.lisp
index b7beb586bb516369a33a8e5fec908d9e3728b7f6..0e7342832ef80c134614eb24267291f446630970 100644
--- a/sys/sysdcl.lisp
+++ b/sys/sysdcl.lisp
@@ -1,6 +1,6 @@
 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: CL-USER; Base: 10; Lowercase: Yes -*-
 
-;; $fiHeader: sysdcl.lisp,v 1.49 1995/11/08 06:13:01 georgej Exp $
+;; $fiHeader: sysdcl.lisp,v 1.50 1996/03/01 05:43:02 colin Exp $
 
 (in-package :cl-user)
 
@@ -12,17 +12,7 @@
   (export '(excl::codeset-0 excl::codeset-1 excl::codeset-2 excl::codeset-3
 	    excl::string-to-euc excl::euc-to-string)
 	  (find-package :excl))
-  (export '(ff::euc-to-char* ff::char*-to-euc) (find-package :ff))
-  (export 'excl::ics-target-case (find-package :excl)))
-
-(let ((*enable-package-locked-errors* nil))
-  (defmacro excl::ics-target-case (&rest cases)
-    `(comp::ics-target-ecase
-      ,@cases
-      ,@(unless (assoc :+ics cases)
-	  '((:+ics nil)))
-      ,@(unless (assoc :-ics cases)
-	  '((:-ics nil))))))
+  (export '(ff::euc-to-char* ff::char*-to-euc) (find-package :ff)))
 
 "Copyright (c) 1990, 1991, 1992 Symbolics, Inc.  All rights reserved."
 
diff --git a/test/test-pkg.lisp b/test/test-pkg.lisp
index 20eecc5c6f6080341104666c23c652fab60c929f..974dbb5a1a9b2b3be6b881c1caa7a49b1979fa67 100644
--- a/test/test-pkg.lisp
+++ b/test/test-pkg.lisp
@@ -27,7 +27,7 @@
    #:find-user-interface-components
    #:get-avv-frame
    #:invoke-accept-values-button
-   #:note-test-failed 
+   #:note-test-failed
    #:note-test-succeeded
    #:notify-user-ok
    #:press-on-window
@@ -43,79 +43,3 @@
    #:with-waiting
    ))
 
-#+ignore
-(defun fixit ()
-  (interactive)
-  (beginning-of-buffer)
-  (query-replace "*frame-tests*" "clim-test:*frame-tests*")
-  (beginning-of-buffer)
-  (query-replace "abort-menu" "clim-test:abort-menu")
-  (beginning-of-buffer)
-  (query-replace "activate-push-button" "clim-test:activate-push-button")
-  (beginning-of-buffer)
-  (query-replace "benchmark-clim" "clim-test:benchmark-clim")
-  (beginning-of-buffer)
-  (query-replace "cannot-find-presentation-error" "clim-test:cannot-find-presentation-error")
-  (beginning-of-buffer)
-  (query-replace "change-gadget-value" "clim-test:change-gadget-value")
-  (beginning-of-buffer)
-  (query-replace "change-query-value" "clim-test:change-query-value")
-  (beginning-of-buffer)
-  (query-replace "click-on-presentation" "clim-test:click-on-presentation")
-  (beginning-of-buffer)
-  (query-replace "click-on-window" "clim-test:click-on-window")
-  (beginning-of-buffer)
-  (query-replace "define-activity-test" "clim-test:define-activity-test")
-  (beginning-of-buffer)
-  (query-replace "define-command-sequence" "clim-test:define-command-sequence")
-  (beginning-of-buffer)
-  (query-replace "define-frame-test" "clim-test:define-frame-test")
-  (beginning-of-buffer)
-  (query-replace "do-frame-test-with-profiling" "clim-test:do-frame-test-with-profiling")
-  (beginning-of-buffer)
-  (query-replace "do-frame-tests" "clim-test:do-frame-tests")
-  (beginning-of-buffer)
-  (query-replace "execute-one-command" "clim-test:execute-one-command")
-  (beginning-of-buffer)
-  (query-replace "exercise-frame" "clim-test:exercise-frame")
-  (beginning-of-buffer)
-  (query-replace "find-frame" "clim-test:find-frame")
-  (beginning-of-buffer)
-  (query-replace "find-menu" "clim-test:find-menu")
-  (beginning-of-buffer)
-  (query-replace "find-notify-user" "clim-test:find-notify-user")
-  (beginning-of-buffer)
-  (query-replace "find-user-interface-components" "clim-test:find-user-interface-components")
-  (beginning-of-buffer)
-  (query-replace "get-avv-frame" "clim-test:get-avv-frame")
-  (beginning-of-buffer)
-  (query-replace "invoke-accept-values-button" "clim-test:invoke-accept-values-button")
-  (beginning-of-buffer)
-  (query-replace "note-test-failed " "clim-test:note-test-failed ")
-  (beginning-of-buffer)
-  (query-replace "note-test-succeeded" "clim-test:note-test-succeeded")
-  (beginning-of-buffer)
-  (query-replace "notify-user-ok" "clim-test:notify-user-ok")
-  (beginning-of-buffer)
-  (query-replace "press-on-window" "clim-test:press-on-window")
-  (beginning-of-buffer)
-  (query-replace "release-on-window" "clim-test:release-on-window")
-  (beginning-of-buffer)
-  (query-replace "select-menu-item" "clim-test:select-menu-item")
-  (beginning-of-buffer)
-  (query-replace "test-it" "clim-test:test-it")
-  (beginning-of-buffer)
-  (query-replace "train-clim-2" "clim-test:train-clim-2")
-  (beginning-of-buffer)
-  (query-replace "wait-for-clim-input-state" "clim-test:wait-for-clim-input-state")
-  (beginning-of-buffer)
-  (query-replace "wait-for-frame-to-exit" "clim-test:wait-for-frame-to-exit")
-  (beginning-of-buffer)
-  (query-replace "with-frame-invocation" "clim-test:with-frame-invocation")
-  (beginning-of-buffer)
-  (query-replace "with-test-reporting" "clim-test:with-test-reporting")
-  (beginning-of-buffer)
-  (query-replace "with-test-success-expected" "clim-test:with-test-success-expected")
-  (beginning-of-buffer)
-  (query-replace "with-waiting" "clim-test:with-waiting")
-  )
diff --git a/test/testdcl.lisp b/test/testdcl.lisp
index adf02fffe0252c460d423176587c987ff0bad62a..20a1a571d3da6f7e8d4d9ee234a7c9fda1573faf 100644
--- a/test/testdcl.lisp
+++ b/test/testdcl.lisp
@@ -1,15 +1,16 @@
 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: CL-USER; Base: 10; Lowercase: Yes -*-
 
-;; $fiHeader: testdcl.lisp,v 1.2 1993/08/12 16:04:38 cer Exp $
+;; $fiHeader: testdcl.lisp,v 1.4 1994/11/23 23:29:08 smh Exp $
 
 (in-package #-ansi-90 :user #+ansi-90 :common-lisp-user)
 
 
 (defsystem testing
     (:default-pathname "clim2:;test;")
-  ("test-pkg")
-  ("test-driver" (:load-before-compile "test-pkg"))
-  ("test-clim-tests" (:load-before-compile "test-driver"))
-  ("test-clim" (:load-before-compile "test-driver"))
-  ("test-demos" (:load-before-compile "test-driver"))
-  )
+  (:serial
+   ("test-pkg")
+   ("test-driver" (:load-before-compile "test-pkg"))
+   ("test-clim-tests" (:load-before-compile "test-driver"))
+   ("test-clim" (:load-before-compile "test-driver"))
+   ("test-demos" (:load-before-compile "test-driver"))
+   ))
diff --git a/tk-silica/xm-gadgets.lisp b/tk-silica/xm-gadgets.lisp
index 1a4a24a680d1f26ea9005e2357530b86e9fe946d..3040ec1d986598c73f1dc1c262b933e696603208 100644
--- a/tk-silica/xm-gadgets.lisp
+++ b/tk-silica/xm-gadgets.lisp
@@ -17,7 +17,7 @@
 ;; Commercial Software developed at private expense as specified in
 ;; DOD FAR Supplement 52.227-7013 (c) (1) (ii), as applicable.
 ;;
-;; $fiHeader: xm-gadgets.lisp,v 1.91 1995/11/08 06:15:59 georgej Exp $
+;; $fiHeader: xm-gadgets.lisp,v 1.92 1996/03/01 05:44:12 colin Exp $
 
 (in-package :xm-silica)
 
@@ -2150,7 +2150,7 @@
 			 (sheet-text-style port sheet)))
 	 (font-list (text-style-mapping port text-style *all-character-sets*)))
     (excl:ics-target-case
-     (:ics (when (gadget-needs-font-set-p sheet)
+     (:+ics (when (gadget-needs-font-set-p sheet)
 	     (setq font-list
 	       (font-set-from-font-list port font-list)))))
     `(:font-list ,font-list ,@initargs)))
diff --git a/tk-silica/xt-silica.lisp b/tk-silica/xt-silica.lisp
index 4273143be84379eb2229b4c14e4480f30a1a837b..d1f3ac9512712287f32a41d3335cd1074f9413c7 100644
--- a/tk-silica/xt-silica.lisp
+++ b/tk-silica/xt-silica.lisp
@@ -19,7 +19,7 @@
 ;; Commercial Software developed at private expense as specified in
 ;; DOD FAR Supplement 52.227-7013 (c) (1) (ii), as applicable.
 ;;
-;; $fiHeader: xt-silica.lisp,v 1.100 1996/01/23 06:47:41 duane Exp $
+;; $fiHeader: xt-silica.lisp,v 1.101 1996/03/01 05:44:25 colin Exp $
 
 (in-package :xm-silica)
 
@@ -1405,7 +1405,7 @@
        (let ((font-name (if (stringp spec)
 			    spec
 			  text-style)))
-	 (silica::make-device-font port font-name))))))
+	 (make-device-font-text-style port font-name))))))
 
 ;;;--- Gadget activation deactivate
 
diff --git a/tk/load-xm.lisp b/tk/load-xm.lisp
index cf7a6319b3c39809146587ec79846bca16b34e0a..4df0796a08c7240574accf7df8bf497c63256887 100644
--- a/tk/load-xm.lisp
+++ b/tk/load-xm.lisp
@@ -17,7 +17,7 @@
 ;; Commercial Software developed at private expense as specified in
 ;; DOD FAR Supplement 52.227-7013 (c) (1) (ii), as applicable.
 ;;
-;; $fiHeader: load-xm.lisp,v 1.34 1995/06/21 21:24:17 georgej Exp $
+;; $fiHeader: load-xm.lisp,v 1.36 1995/11/08 06:14:05 georgej Exp $
 
 (in-package :user)
 
@@ -25,39 +25,46 @@
 
 #+dlfcn
 (progn
-  (defvar sys::*toolkit-static* nil)
 
-  (unless (ff:get-entry-point (ff:convert-to-lang "XmCreateMyDrawingArea")
-			      :note-shared-library-references nil)
-    (load "clim2:;climxm.so")))
+(defvar sys::*toolkit-static*
+    (or (ff:get-entry-point (ff:convert-to-lang "XmCreateMyDrawingArea")
+			    :note-shared-library-references nil)
+	(prog1 nil
+	  (let ((ff::*dlopen-mode* (excl:ics-target-case
+				    (:+ics #x102)
+				    (:-ics ff::*dlopen-mode*))))
+	    (load "clim2:;climxm.so")))))
+)
 
 #-dlfcn
 (progn
-  (defvar sys::*libtk-pathname* "Xm")
-  (defvar sys::*libxt-pathname* "Xt")
-
-  (unless (ff:get-entry-point (ff:convert-to-lang "XtToolkitInitialize"))
-    (load "clim2:;stub-motif.o"
-	  :system-libraries (list sys::*libtk-pathname*
-				  sys::*libxt-pathname*
-				  sys::*libx11-pathname*)
-	  :print t)
-    (load "clim2:;stub-xt.o"
-	  :system-libraries (list sys::*libxt-pathname*
-				  sys::*libx11-pathname*)
-	  :print t))
-
-  (unless (ff:get-entry-point (ff:convert-to-lang "XmCreateMyDrawingArea"))
-    (load "clim2:;xmsupport.o"
-	  :system-libraries (list sys::*libtk-pathname*
-				  sys::*libxt-pathname*
-				  sys::*libx11-pathname*)
-	  :print t))
-
-  (unless (ff:get-entry-point (ff:convert-to-lang "XtAppIntervalNextTimer"))
-    (load "clim2:;xtsupport.o"
-	  :system-libraries (list sys::*libxt-pathname*
-				  sys::*libx11-pathname*)
-	  :print t)))
+
+(defvar sys::*libtk-pathname* "Xm")
+(defvar sys::*libxt-pathname* "Xt")
+
+(unless (ff:get-entry-point (ff:convert-to-lang "XtToolkitInitialize"))
+  (load "clim2:;stub-motif.o"
+	:system-libraries (list sys::*libtk-pathname*
+				sys::*libxt-pathname*
+				sys::*libx11-pathname*)
+	:print t)
+  (load "clim2:;stub-xt.o"
+	:system-libraries (list sys::*libxt-pathname*
+				sys::*libx11-pathname*)
+	:print t))
+
+(unless (ff:get-entry-point (ff:convert-to-lang "XmCreateMyDrawingArea"))
+  (load "clim2:;xmsupport.o"
+	:system-libraries (list sys::*libtk-pathname*
+				sys::*libxt-pathname*
+				sys::*libx11-pathname*)
+	:print t))
+
+(unless (ff:get-entry-point (ff:convert-to-lang "XtAppIntervalNextTimer"))
+  (load "clim2:;xtsupport.o"
+	:system-libraries (list sys::*libxt-pathname*
+				sys::*libx11-pathname*)
+	:print t))
+)
 
 (pushnew :clim-motif *features*)
diff --git a/tk/widget.lisp b/tk/widget.lisp
index 58162a0ab05eb1d9457b3ef8922699a3e7cb3998..d0f3a6f01e3d8746c71757bcc7b1fde449c4115e 100644
--- a/tk/widget.lisp
+++ b/tk/widget.lisp
@@ -19,7 +19,7 @@
 ;; Commercial Software developed at private expense as specified in
 ;; DOD FAR Supplement 52.227-7013 (c) (1) (ii), as applicable.
 ;;
-;; $fiHeader: widget.lisp,v 1.40 1996/01/23 06:47:11 duane Exp $
+;; $fiHeader: widget.lisp,v 1.41 1996/03/01 05:43:38 colin Exp $
 
 (in-package :tk)
 
@@ -287,7 +287,7 @@
 
 ;; Could not think of anywhere better!
 
-(defvar *fallback-resources*
+(defparameter *fallback-resources*
     `("clim*dragInitiatorProtocolStyle: DRAG_NONE"
       "clim*dragreceiverprotocolstyle:	DRAG_NONE"
       ,@(excl:ics-target-case
diff --git a/utils/packages.lisp b/utils/packages.lisp
index bdb96d48e5979f6f1b292f921573baf721beb861..678599e7f123781bed42b5faa1be3fc314632438 100644
--- a/utils/packages.lisp
+++ b/utils/packages.lisp
@@ -1,6 +1,6 @@
 ;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Package: CL-USER; Base: 10; Lowercase: Yes -*-
 
-;; $fiHeader: packages.lisp,v 1.67 1995/10/20 17:42:09 colin Exp $
+;; $fiHeader: packages.lisp,v 1.68 1996/03/01 05:44:44 colin Exp $
 
 (in-package :common-lisp-user)
 
@@ -1547,6 +1547,7 @@
     *default-text-style*
     *undefined-text-style*
     invoke-with-text-style
+    make-device-font-text-style
     make-text-style
     merge-text-styles
     parse-text-style
@@ -2318,8 +2319,8 @@
     frame-state
     frame-top-level-sheet
     frame-menu-translator-documentation
-    frame-pointer-buttons-documentation
-    frame-modifier-keys-documentation
+    frame-pointer-button-documentation
+    frame-modifier-key-documentation
     generate-panes
     get-frame-pane
     interactor-pane
@@ -3030,7 +3031,6 @@
     layout-mixin
     line-editor-pane
     list-pane-selected-item-p
-    make-device-font
     make-frame-manager
     make-medium
     make-pane-arglist
diff --git a/wnn/bcopy.c b/wnn/bcopy.c
new file mode 100644
index 0000000000000000000000000000000000000000..d1cf6fe6f633c297426fe76d278e527e9a64f2b1
--- /dev/null
+++ b/wnn/bcopy.c
@@ -0,0 +1,91 @@
+/*
+ * $Id: bcopy.c,v 1.1 1996/03/13 09:56:28 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+*/
+#include "commonhd.h"
+
+#if defined(SYSVR2) && !defined(linux) && !defined(DGUX) && !defined(uniosu)
+
+void
+bcopy (b1, b2, length)
+register unsigned char *b1, *b2;
+register length;
+{
+    if (length <= 0)
+	return;
+    if (b1 < b2 && b1 + length > b2) {
+	b2 += length;
+	b1 += length;
+	while (length--) {
+	    *--b2 = *--b1;
+	}
+    } else {
+	memcpy(b2, b1, length);
+    }
+}
+ 
+void
+bzero (b, length)
+register unsigned char *b;
+register length;
+{
+    memset (b, 0, length);
+}
+
+int
+bcmp (b1, b2, length)
+register unsigned char *b1;
+register unsigned char *b2;
+register length;
+{
+    if (length == 0)
+	return 0;
+    return memcmp (b1, b2, length);
+}
+#endif	/* SYSVR2 */
diff --git a/wnn/bdic.c b/wnn/bdic.c
new file mode 100644
index 0000000000000000000000000000000000000000..198c2ced0cad1b62c34ecd5905aac1304eebb950
--- /dev/null
+++ b/wnn/bdic.c
@@ -0,0 +1,1401 @@
+/*
+ * $Id: bdic.c,v 1.1 1996/03/13 09:56:30 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/*
+  Binary (Updatable, Stable) dictionary common routine.
+*/
+
+#if defined(JSERVER) || defined(JS)
+#ifdef WRITE_CHECK
+#define BDIC_WRITE_CHECK
+#endif
+#endif /* defined(JSERVER) || defined(JS) */
+
+#ifdef UX386
+#include <X11/Xos.h>
+#else
+#include <sys/types.h>
+#endif
+#ifndef JS
+#include <sys/stat.h>
+#include <stdio.h>
+#include "commonhd.h"
+#include "jslib.h"
+#include "jh.h"
+#endif
+#include "jdata.h"
+#include "wnn_os.h"
+#include "wnn_string.h"
+
+#ifdef JSERVER
+#ifndef BDIC_WRITE_CHECK
+#define vputc(X, pt) ((pt)? putc((X), (pt)):xputc_cur(X))
+#endif /* !BDIC_WRITE_CHECK */
+#define vgetc(pt) ((pt)? getc((pt)):xgetc_cur())
+extern int xgetc_cur();
+#else
+#ifdef JS
+#ifndef BDIC_WRITE_CHECK
+#define vputc(X, pt) putc((X), (pt))
+#endif /* !BDIC_WRITE_CHECK */
+#define vgetc(pt) getc(pt)
+#else
+#define vputc(X, pt) putc((X), (pt))
+#define vgetc(pt) getc(pt)
+#endif
+#endif
+
+#ifndef min
+#define min(a, b) ((a > b)? b:a)
+#define max(a, b) ((a < b)? b:a)
+#endif
+
+#ifdef JS
+static
+#else
+extern
+#endif
+int output_file_header(), input_file_uniq(), output_header_jt(),
+#ifdef BDIC_WRITE_CHECK
+  put_short(), output_file_uniq(),
+#endif /* BDIC_WRITE_CHECK */
+  create_file_header(), input_file_header(), change_file_uniq1(),
+  output_header_hjt();
+
+#ifdef JS
+static
+#else
+extern
+#endif
+#ifdef BDIC_WRITE_CHECK
+void new_pwd();
+#else /* BDIC_WRITE_CHECK */
+void put_short(), output_file_uniq(), new_pwd();
+#endif /* BDIC_WRITE_CHECK */
+
+#ifdef BDIC_WRITE_CHECK
+#ifdef JSERVER
+extern void xputc_cur();
+
+static int
+vputc(c, fp)
+char c;
+FILE *fp;
+{
+    if (fp) {
+	if (fwrite(&c, sizeof(char), 1, fp) <= 0) return(-1);
+    } else {
+	xputc_cur(c);
+    }
+    return(0);
+}
+#else /* JSERVER */
+static int
+vputc(c, fp)
+char c;
+FILE *fp;
+{
+    if (fwrite(&c, sizeof(char), 1, fp) <= 0) return(-1);
+    return(0);
+}
+#endif /* JSERVER */
+#endif /* BDIC_WRITE_CHECK */
+
+#ifdef JS
+static
+#endif
+#ifdef BDIC_WRITE_CHECK
+int
+#else /* BDIC_WRITE_CHECK */
+void
+#endif /* BDIC_WRITE_CHECK */
+putnull(ofpter, n)
+register FILE *ofpter;
+register int n;
+{
+    for(;n;n--){
+#ifdef BDIC_WRITE_CHECK
+	if (vputc('\0', ofpter) == -1) return(-1);
+#else /* BDIC_WRITE_CHECK */
+	vputc('\0', ofpter);
+#endif /* BDIC_WRITE_CHECK */
+    }
+#ifdef BDIC_WRITE_CHECK
+    return(0);
+#endif /* BDIC_WRITE_CHECK */
+}
+
+#ifdef JS
+static
+#endif
+#ifdef BDIC_WRITE_CHECK
+int
+#else /* BDIC_WRITE_CHECK */
+void
+#endif /* BDIC_WRITE_CHECK */
+put_n_str(ofpter, c, n)
+register FILE *ofpter;
+register int n;
+register char *c;
+{
+    for(;n;n--){
+#ifdef BDIC_WRITE_CHECK
+	if (vputc(*c++, ofpter) == -1) return(-1);
+#else /* BDIC_WRITE_CHECK */
+	vputc(*c++, ofpter);
+#endif /* BDIC_WRITE_CHECK */
+    }
+#ifdef BDIC_WRITE_CHECK
+    return(0);
+#endif /* BDIC_WRITE_CHECK */
+}  
+
+#ifdef JS
+static
+#endif
+#ifdef BDIC_WRITE_CHECK
+int
+#else /* BDIC_WRITE_CHECK */
+void
+#endif /* BDIC_WRITE_CHECK */
+put_n_EU_str(ofpter, c, n)
+register FILE *ofpter;
+register w_char *c;
+register int n;
+{
+    for(;n;n--){
+#ifdef BDIC_WRITE_CHECK
+	if (put_short(ofpter, (int)(*c++)) == -1) return(-1);
+#else /* BDIC_WRITE_CHECK */
+	put_short(ofpter, (int)(*c++));
+#endif /* BDIC_WRITE_CHECK */
+    }
+#ifdef BDIC_WRITE_CHECK
+    return(0);
+#endif /* BDIC_WRITE_CHECK */
+}
+
+#ifdef JS
+static
+#endif
+#ifdef BDIC_WRITE_CHECK
+int
+#else /* BDIC_WRITE_CHECK */
+void
+#endif /* BDIC_WRITE_CHECK */
+put_short(ofpter, i)
+register FILE *ofpter;
+register int i;
+{
+#ifdef BDIC_WRITE_CHECK
+    if ((vputc(i >> 8, ofpter) == -1) ||
+	(vputc(i     , ofpter) == -1)) return(-1);
+    return(0);
+#else /* BDIC_WRITE_CHECK */
+    vputc(i >> 8, ofpter);
+    vputc(i     , ofpter);
+#endif /* BDIC_WRITE_CHECK */
+}
+
+#ifdef JS
+static
+#endif
+#ifdef BDIC_WRITE_CHECK
+int
+#else /* BDIC_WRITE_CHECK */
+void
+#endif /* BDIC_WRITE_CHECK */
+putint(ofpter, i)
+register FILE *ofpter;
+register int i;
+{
+#ifdef BDIC_WRITE_CHECK
+    if ((vputc(i >> 24, ofpter) == -1) ||
+	(vputc(i >> 16, ofpter) == -1) ||
+	(vputc(i >> 8 , ofpter) == -1) ||
+	(vputc(i      , ofpter) == -1)) return(-1);
+    return(0);
+#else /* BDIC_WRITE_CHECK */
+    vputc(i >> 24, ofpter);
+    vputc(i >> 16, ofpter);
+    vputc(i >> 8 , ofpter);
+    vputc(i      , ofpter);
+#endif /* BDIC_WRITE_CHECK */
+}
+
+#ifdef JS
+static
+#endif
+int
+getnull(ifpter, n)
+register FILE *ifpter;
+register int n;
+{
+    register int k;
+    
+    for(;n;n--){
+	k = vgetc(ifpter);
+	if(k == -1)return(-1);
+    }
+    return(0);
+}
+
+#ifdef JS
+static
+#endif
+int
+getnstr(ifpter, n, st)
+register FILE *ifpter;
+register int n;
+register char *st;
+{
+    int k;
+    
+    for(;n;n--){
+	k = vgetc(ifpter);
+	*st++ = k;
+	if(k == -1)return(-1);
+    }
+    return(0);
+}
+
+#if	!defined(JS) && !defined(JSERVER)
+int
+get_n_EU_str(ifpter, n, st)
+register FILE *ifpter;
+register int n;
+register w_char *st;
+{
+    register    int k;
+    extern int get_short();
+    
+    for(;n;n--){
+	k = get_short((short *)st++, ifpter);
+	if(k == -1)return(-1);
+    }
+    return(0);
+}
+
+int
+get_short(sp,ifpter)
+register short *sp;
+FILE *ifpter;
+{
+    register int i = 0;
+    register int k;
+    
+    i |= (k = vgetc(ifpter)) << 8;
+    if(k == -1)return(-1);
+    i |= (k = vgetc(ifpter));
+    if(k == -1)return(-1);
+    *sp = i;
+    return(0);
+}
+#endif
+
+#ifdef JS
+static
+#endif
+int
+getint(ip,ifpter)
+register FILE *ifpter;
+int *ip;
+{
+    register int i = 0;
+    register int k;
+    
+    i |= (k = vgetc(ifpter)) << 24;
+    if(k == -1)return(-1);
+    i |= (k = vgetc(ifpter)) << 16;
+    if(k == -1)return(-1);
+    i |= (k = vgetc(ifpter)) << 8;
+    if(k == -1)return(-1);
+    i |= (k = vgetc(ifpter));
+    if(k == -1)return(-1);
+    *ip = i;
+    return(0);
+}
+
+#ifndef JS
+void
+udytoS(yomi,tnum,hostart,tary)
+register w_char *yomi;
+register int tnum;
+char *hostart;
+register struct uind1 *tary;
+{
+    struct uind2 *hop;
+    int len;
+    
+    hop = (struct uind2 *)((char *)hostart + tary[tnum].pter);
+    yomi[0] = tary[tnum].yomi1 >> 16;
+    yomi[1] = tary[tnum].yomi1 & 0xffff;
+    if(yomi[1]){
+	yomi[2] = tary[tnum].yomi2 >> 16;
+	if(yomi[2]){
+	    yomi[3] = tary[tnum].yomi2 & 0xffff;
+	}
+    }
+    len = hop->yomi[0];
+    /*Strncpy(yomi + 4, (hop->yomi) + 1, len - 4);
+      In order not to use ../etc/strings.c*/
+    bcopy((char *)((hop->yomi) + 1), (char *)(yomi + 4),  max(0, ((len - 4)) * 2));
+    yomi[len] = 0;
+}
+#endif
+
+#ifdef BDIC_WRITE_CHECK
+static char *
+make_tmp_name(n)
+char *n;
+{
+    static char buf[256];
+
+    if (n == NULL || *n == '\0') return NULL;
+    sprintf(buf, "%s~", n);
+    return(buf);
+}
+
+static char *
+make_backup_name(n)
+char *n;
+{
+    static char buf[256];
+
+    if (n == NULL || *n == '\0') return NULL;
+    sprintf(buf, "%s#", n);
+    return(buf);
+}
+
+#ifdef nodef
+static char *
+make_backup_name(n)
+char *n;
+{
+    static char buf[256];
+    char base_name[64];
+    char *p;
+#ifndef SYSVR2
+    extern char *rindex();
+#else
+    extern char *strrchr();
+#endif
+
+    if (n == NULL || *n == '\0') return NULL;
+    strcpy(buf, n);
+#ifndef SYSVR2
+    if ((p = rindex(buf, '/')) == NULL) {
+#else
+    if ((p = strrchr(buf, '/')) == NULL) {
+#endif
+	strcpy(base_name, buf);
+	sprintf(buf, "#%s#", base_name);
+    } else {
+	p++;
+	strcpy(base_name, p);
+	*p = '\0';
+	strcat(buf, "#");
+	strcat(buf, base_name);
+	strcat(buf, "#");
+    }
+    return(buf);
+}
+#endif
+
+#ifdef JS
+static
+#endif
+void
+check_backup(n)
+char *n;
+{
+    char *p;
+
+    if ((p = make_tmp_name(n)) && (access(p, F_OK) != -1)) unlink(p);
+    if ((p = make_backup_name(n)) && (access(p, F_OK) != -1)) {
+	unlink(n);
+	link(p, n);
+	unlink(p);
+    }
+}
+
+static int
+copy_file_to_file(from, to)
+FILE *from, *to;
+{
+    char buf[1024];
+    int r_len, w_len, i;
+
+    for (;;) {
+	r_len = fread(buf, 1, 1024, from);
+	if (r_len <= 0) break;
+	for ( i = 0; i < r_len; i += w_len) {
+	    w_len = fwrite(&buf[i], 1, r_len - i, to);
+	    if (w_len <= 0) {
+		fseek(from, 0, 0);
+		fseek(to, 0, 0);
+		return(-1);
+	    }
+	    if (w_len >= r_len) break;
+	}
+    }
+    fseek(from, 0, 0);
+    fseek(to, 0, 0);
+    return(0);
+}
+
+#ifdef JS
+static
+#endif
+void
+delete_tmp_file(n)
+char *n;
+{
+    if (n && *n) unlink(n);
+}
+
+#ifdef JS
+static
+#endif
+char *
+make_backup_file(n)
+char *n;
+{
+    FILE *fp, *fp2;
+    char *p, *p2;
+
+    if ((p = make_backup_name(n)) == NULL) return(NULL);
+    if ((p2 = make_tmp_name(n)) == NULL) return(NULL);
+    if (((fp = fopen(p2, "w+")) == NULL) || ((fp2 = fopen(n, "r")) == NULL)) {
+	return NULL;
+    }
+    if (copy_file_to_file(fp2, fp) == -1) {
+	fclose(fp);
+	fclose(fp2);
+	return(NULL);
+    }
+    fclose(fp);
+    fclose(fp2);
+    if (access(p, F_OK) != -1) unlink(p);
+    link(p2, p);
+    unlink(p2);
+    return(p);
+}
+
+#ifdef JS
+static
+#endif
+char *
+make_tmp_file(n, copy, ret_fp)
+char *n;
+int copy;
+FILE **ret_fp;
+{
+    FILE *fp, *fp2;
+    struct wnn_file_head fh;
+    char *p;
+
+    p = make_tmp_name(n);
+    if ((fp = fopen(p, "w+")) == NULL) {
+	*ret_fp = NULL;
+	return NULL;
+    }
+    if (copy && (fp2 = fopen(n, "r")) != NULL) {
+	input_file_header(fp2, &fh);
+	fseek(fp2, 0, 0);
+	if ((copy_file_to_file(fp2, fp) == -1) ||
+	    (create_file_header(fp, fh.file_type, fh.file_passwd) == -1)) {
+	    fclose(fp);
+	    fclose(fp2);
+	    *ret_fp = NULL;
+	    return NULL;
+	}
+	fseek(fp, 0, 0);
+	fclose(fp2);
+    }
+    *ret_fp = fp;
+    return p;
+}
+
+#ifdef JS
+static
+#endif
+void
+move_tmp_to_org(tmp_name, org_name, copy)
+char *tmp_name, *org_name;
+int copy;
+{
+    FILE *org, *tmp;
+
+    if (copy) {
+	if (((tmp = fopen(tmp_name, "r")) == NULL)
+	    || ((org = fopen(org_name, "w+")) == NULL)) {
+	    return;
+	}
+	copy_file_to_file(tmp, org);
+	fclose(tmp);
+	fclose(org);
+    } else {
+	unlink(org_name);
+	link(tmp_name, org_name);
+    }
+    unlink(tmp_name);
+}
+#endif /* BDIC_WRITE_CHECK */
+
+#ifdef JS
+static
+#endif
+int
+create_file_header(ofpter, file_type, file_passwd)
+FILE *ofpter;
+int file_type;
+char *file_passwd;
+{
+    struct stat buf;
+    char hostname[WNN_HOSTLEN];
+    struct wnn_file_head fh;
+
+    if(fstat(fileno(ofpter), &buf) == -1){
+	return(-1);
+    }
+    gethostname(hostname, WNN_HOSTLEN);
+    hostname[WNN_HOSTLEN - 1] = '\0';
+
+    fh.file_uniq.time = (int)buf.st_ctime;
+    fh.file_uniq.dev = (int)buf.st_dev;
+    fh.file_uniq.inode = (int)buf.st_ino;
+    bzero(fh.file_uniq.createhost, WNN_HOSTLEN);
+    strcpy(fh.file_uniq.createhost, hostname);
+    
+    /* file_uniq_org */
+    fh.file_uniq_org.time = (int)buf.st_ctime;
+    fh.file_uniq_org.dev = (int)buf.st_dev;
+    fh.file_uniq_org.inode = (int)buf.st_ino;
+    bzero(fh.file_uniq_org.createhost, WNN_HOSTLEN);
+    strcpy(fh.file_uniq_org.createhost, hostname);
+
+    fh.file_type = file_type;
+    if(file_passwd){
+	strncpy(fh.file_passwd, file_passwd, WNN_PASSWD_LEN);
+    }else{
+	bzero(fh.file_passwd, WNN_PASSWD_LEN);
+    }
+    if(output_file_header(ofpter, &fh) == -1) return(-1);
+    return(0);
+}
+
+/* 128 Bytes File Header */
+
+#ifdef JS
+static
+#endif
+int
+output_file_header(ofpter, hp)
+FILE *ofpter;
+struct wnn_file_head *hp;
+{
+#ifdef BDIC_WRITE_CHECK
+    if ((put_n_str(ofpter, WNN_FILE_STRING, WNN_FILE_STRING_LEN) == -1) ||
+	(putint(ofpter, hp->file_type) == -1) ||
+	(output_file_uniq(&hp->file_uniq, ofpter) == -1) ||
+	(output_file_uniq(&hp->file_uniq_org, ofpter) == -1) ||
+	(put_n_str(ofpter, hp->file_passwd, WNN_PASSWD_LEN) == -1) ||
+	(putnull(ofpter, 36) == -1)) return(-1);		/* Future Use */
+#else /* BDIC_WRITE_CHECK */
+    put_n_str(ofpter, WNN_FILE_STRING, WNN_FILE_STRING_LEN);
+    putint(ofpter, hp->file_type);
+    output_file_uniq(&hp->file_uniq, ofpter);
+    output_file_uniq(&hp->file_uniq_org, ofpter);
+    put_n_str(ofpter, hp->file_passwd, WNN_PASSWD_LEN);
+    putnull(ofpter, 36);		/* Future Use */
+#endif /* BDIC_WRITE_CHECK */
+    return(0);
+}
+
+#ifdef JS
+static
+#endif
+int
+input_file_header(ifpter, hp)
+FILE *ifpter;
+struct wnn_file_head *hp;
+{
+
+    char wnn_file_string[WNN_FILE_STRING_LEN + 1];
+    int err = 0;
+    
+    getnstr(ifpter, WNN_FILE_STRING_LEN, wnn_file_string);
+    if(strncmp(wnn_file_string, WNN_FILE_STRING, WNN_FILE_STRING_LEN))
+	err = -1;
+    if(getint((&hp->file_type), ifpter) == -1) err = -1;
+    if(input_file_uniq(&(hp->file_uniq), ifpter) == -1) err = -1;
+    if(input_file_uniq(&(hp->file_uniq_org), ifpter) == -1) err = -1;
+    getnstr(ifpter, WNN_PASSWD_LEN, hp->file_passwd);
+    getnull(ifpter, 36);
+    return(err);
+}
+
+#ifdef JS
+static
+#endif
+#ifdef BDIC_WRITE_CHECK
+int
+#else /* BDIC_WRITE_CHECK */
+void
+#endif /* BDIC_WRITE_CHECK */
+output_file_uniq(funiq, ofpter)
+struct wnn_file_uniq *funiq;
+FILE *ofpter;
+{
+#ifdef BDIC_WRITE_CHECK
+    if ((putint(ofpter, funiq->time) == -1) ||
+	(putint(ofpter, funiq->dev) == -1) ||
+	(putint(ofpter, funiq->inode) == -1) ||
+	(put_n_str(ofpter, funiq->createhost,
+		   strlen(funiq->createhost)) == -1) ||
+	(putnull(ofpter, WNN_HOSTLEN - strlen(funiq->createhost)) == -1))
+	return(-1);
+    return(0);
+#else /* BDIC_WRITE_CHECK */
+    putint(ofpter, funiq->time);
+    putint(ofpter, funiq->dev);
+    putint(ofpter, funiq->inode);
+    put_n_str(ofpter, funiq->createhost, strlen(funiq->createhost));
+    putnull(ofpter, WNN_HOSTLEN - strlen(funiq->createhost));
+#endif /* BDIC_WRITE_CHECK */
+}
+
+#ifdef JS
+static
+#endif
+int
+input_file_uniq(funiq, ifpter)
+struct wnn_file_uniq *funiq;
+FILE *ifpter;
+{
+    if(
+       getint(&(funiq->time), ifpter) == -1 ||
+       getint(&(funiq->dev), ifpter) == -1 ||
+       getint(&(funiq->inode), ifpter) == -1 ||
+       getnstr(ifpter, WNN_HOSTLEN, funiq->createhost) == -1)
+	return(-1);
+    return(0);
+}
+
+#ifdef JS
+static
+#endif
+int
+check_inode(f, fh)
+FILE *f;
+struct wnn_file_head *fh;
+{
+    struct stat buf;
+    if(fstat(fileno(f), &buf) == -1){
+	return(-1);
+    }
+    if((int)buf.st_ino != fh->file_uniq.inode){
+	return(-1);
+    }
+    return(0);
+}
+
+#ifdef JS
+static
+#endif
+int
+change_file_uniq(fh, n)
+struct wnn_file_head *fh;
+char *n;
+{
+    int x;
+    FILE *fp;
+#ifdef BDIC_WRITE_CHECK
+    char *tmp, *backup = NULL;
+    backup = make_backup_file(n);
+    if ((tmp = make_tmp_file(n, 1, &fp)) == NULL) {
+	delete_tmp_file(backup);
+#else /* BDIC_WRITE_CHECK */
+    if((fp = fopen(n,"r+")) == NULL){
+#endif /* BDIC_WRITE_CHECK */
+	return(-1);
+    }
+#ifdef BDIC_WRITE_CHECK
+    if (change_file_uniq1(fp, fh->file_type, fh->file_passwd, &(fh->file_uniq)) == -1) {
+	fclose(fp);
+	delete_tmp_file(tmp);
+	delete_tmp_file(backup);
+	return(-1);
+    }
+#else /* BDIC_WRITE_CHECK */
+    change_file_uniq1(fp, fh->file_type, fh->file_passwd, &(fh->file_uniq));
+#endif /* BDIC_WRITE_CHECK */
+    fseek(fp, 0, 0);
+    x = input_file_header(fp, fh);/* It must not occur. */
+    fclose(fp);
+#ifdef BDIC_WRITE_CHECK
+    if(x == -1) {
+	delete_tmp_file(tmp);
+	delete_tmp_file(backup);
+	return(-1); 
+    }
+    move_tmp_to_org(tmp, n, 0);
+    delete_tmp_file(backup);
+#else /* BDIC_WRITE_CHECK */
+    if(x == -1) return(-1);
+#endif /* BDIC_WRITE_CHECK */
+    return(0);
+}    
+
+#ifdef JS
+static
+#endif
+int
+change_file_uniq1(ofpter, file_type, file_passwd, file_uniq)
+FILE *ofpter;
+int file_type;
+char *file_passwd;
+struct wnn_file_uniq *file_uniq;
+{
+    struct stat buf;
+    char hostname[WNN_HOSTLEN];
+    struct wnn_file_head fh;
+
+    if(fstat(fileno(ofpter), &buf) == -1){
+	return(-1);
+    }
+    gethostname(hostname, WNN_HOSTLEN);
+    hostname[WNN_HOSTLEN - 1] = '\0';
+
+    fh.file_uniq.time = (int)buf.st_ctime;
+    fh.file_uniq.dev = (int)buf.st_dev;
+    fh.file_uniq.inode = (int)buf.st_ino;
+    bzero(fh.file_uniq.createhost, WNN_HOSTLEN);
+    strcpy(fh.file_uniq.createhost, hostname);
+    
+    /* file_uniq_org */
+    fh.file_uniq_org.time = file_uniq->time;
+    fh.file_uniq_org.dev = file_uniq->dev;
+    fh.file_uniq_org.inode = file_uniq->inode;
+    bzero(fh.file_uniq_org.createhost, WNN_HOSTLEN);
+    strcpy(fh.file_uniq_org.createhost, file_uniq->createhost);
+
+    fh.file_type = file_type;
+    if(file_passwd){
+	strncpy(fh.file_passwd, file_passwd, WNN_PASSWD_LEN);
+    }else{
+	bzero(fh.file_passwd, WNN_PASSWD_LEN);
+    }
+    if(output_file_header(ofpter, &fh) == -1) return(-1);
+    return(0);
+}
+
+
+
+#ifdef JSERVER
+int
+f_uniq_cmp(a,b)
+char a[],b[];
+{
+    return  bcmp(a,b,sizeof(struct wnn_file_uniq));
+}
+#endif
+
+#if	!defined(JS) && !defined(JSERVER)
+void
+vputs(c, fp)
+register char *c;
+register FILE *fp;
+{
+    while(*c){
+	vputc(*c++, fp);
+    }
+}
+
+int
+vputws(w, fp)
+register w_char *w;
+register FILE *fp;
+{
+    register int n;
+    UCHAR tmp[LENGTHYOMI*3];
+    
+    n = wnn_sStrcpy(tmp, w);
+    vputs(tmp, fp);
+    return(n);
+}
+#endif
+
+
+extern char *wnn_get_hinsi_name();
+
+#if	!defined(JS) && !defined(JSERVER)
+int
+put_yomi_str(yomi, ofpter)
+w_char *yomi;
+FILE *ofpter;
+{
+    register int c;
+    register int i = 0;
+    UCHAR tmp[LENGTHYOMI*3], *p;
+
+    wnn_sStrcpy(tmp, yomi);
+    for(p = tmp;*p;p++){
+	c = (int)*p;
+	if(c == '\\'){
+	    vputc('\\', ofpter);
+	    vputc('\\', ofpter);
+	    i += 2;
+	}else if(c > 0x20){
+	    vputc(c, ofpter);
+	    i += 1;
+	}else{
+	    char tmp[8];
+	    sprintf(tmp , "\\0%o\\" , c);
+	    vputs(tmp, ofpter);
+	    i += strlen(tmp);
+	}
+    }
+    return(i);
+}
+#endif
+
+#ifndef JS
+void
+Get_knj2(kptr,kanji2, kouho, yomi, comment)
+UCHAR *kptr;
+int kanji2;
+w_char *kouho, *comment, *yomi;
+{
+	extern void get_kanji_str();
+
+	int tcnt;
+	for (tcnt = 0; tcnt < kanji2; tcnt++){
+		kptr += *kptr;
+	}
+	get_kanji_str(kptr, kouho, yomi, comment);
+	return;
+}
+
+void
+get_kanji_str(kptr, kanji, yomi, comment)
+UCHAR *kptr;
+w_char *kanji, *comment, *yomi;
+{
+    w_char *tmpy;
+    w_char *tmpk;
+    w_char *tmpc;
+    extern void Get_kanji_str_r();
+
+    Get_kanji_str_r(kptr, &tmpk, &tmpy, &tmpc);
+
+#ifdef CONVERT_from_TOP /* Don't warry. Only use in server and jutil */
+    if(kanji && tmpk)wnn_Strcpy(kanji, tmpk);
+    if(yomi && tmpy)wnn_Strcpy(yomi, tmpy);
+#else	/* conver from bottom */
+    if(kanji && tmpk)wnn_Sreverse(kanji, tmpk);
+    if(yomi && tmpy)wnn_Sreverse(yomi, tmpy);
+#endif	/* CONVERT_from_TOP */
+    if(comment && tmpc)wnn_Strcpy(comment, tmpc);
+}
+    
+
+void
+Get_kanji_str_r(kptr, tmpk, tmpy, tmpc)
+UCHAR *kptr;
+w_char **tmpk, **tmpy, **tmpc;
+{
+    int state = *(kptr + 1);
+    static w_char dmy = 0; /* Must not be allocated on Stack!! */
+    int adres;
+
+    if(state & FORWARDED){
+	/* Forward occures when comment-set is used */
+	adres = (*(w_char *)(kptr + 2)) << 16 | (*(w_char *)(kptr + 4));
+	Get_kanji_str_r(kptr + adres, tmpk, tmpy, tmpc);
+	return;
+    }
+/*    get_kanji_str_r(kptr, tmpk, tmpy, comment); */
+    if(state & HAS_YOMI){
+	*tmpy = ((w_char *)(kptr + 2));
+	*tmpk = *tmpy + wnn_Strlen(*tmpy) + 1;
+    }else{
+	*tmpy = &dmy;
+	*tmpk = ((w_char *)(kptr + 2));
+    }
+    if(state & HAS_COMMENT){
+	*tmpc = *tmpk + wnn_Strlen(*tmpk) + 1;
+    }else{
+	*tmpc = &dmy;
+    }
+}
+
+#ifdef nodef
+int
+Get_kanji_len(kptr, which)
+UCHAR *kptr;
+int which;
+{
+    w_char tmp[LENGTHYOMI];
+
+    if(which == D_KANJI){
+	get_kanji_str_r(kptr, tmp, NULL, NULL);
+    }else{
+	get_kanji_str_r(kptr, NULL, tmp, NULL);
+    }	
+    return(wnn_Strlen(tmp));
+}
+
+void
+get_kanji_str_r(kptr, kanji, yomi, comment)
+UCHAR *kptr;
+w_char *kanji, *comment, *yomi;
+{
+    w_char *c;
+    int n , k;
+    
+    n = *kptr++ - 1;
+    c = kanji;
+    if(comment)*comment = 0;
+    if(yomi)*yomi = 0;
+    for(k = 0 ; k < n ;) {
+	if(*kptr == DIC_COMMENT_CHAR){
+	    if(c) *c = 0;
+	    c = comment;
+	    kptr++;
+	    k++;
+	}else if(*kptr == DIC_YOMI_CHAR){
+	    if(c) *c = 0;
+	    c = yomi;
+	    kptr++;
+	    k++;
+	}else if(*kptr & 0x80){  /* kanji char */
+	    if(c) *c++ = ((int) *kptr << 8 | *(kptr + 1));
+	    kptr += 2;
+	    k+= 2;
+	}else{
+	    if(c) *c++ = *kptr;
+	    kptr++;
+	    k++;
+	}
+    }
+    if(c)*c = 0;
+}
+#endif
+
+UCHAR
+kanjiaddr(d0, kanji, yomi, comment)
+UCHAR *d0;
+w_char *kanji, *yomi, *comment;
+{
+    w_char *dest = (w_char *)(d0 + 2);
+    int state = 0;
+    w_char *pt;
+
+    if(yomi && *yomi){
+#ifdef CONVERT_from_TOP /* Don't warry. Only use in server and jutil */
+        pt = yomi;
+        for(;*pt;){
+            *dest++ = *pt++;
+        } 
+#else	/* conver from bottom */
+	pt = yomi + wnn_Strlen(yomi) - 1;
+	for(;pt >= yomi;){
+	    *dest++ = *pt--;
+	}
+#endif /* CONVERT_from_TOP */
+	state |= HAS_YOMI;
+	*dest++ = 0;
+    }
+
+#ifdef CONVERT_from_TOP /* Don't warry. Only use in server and jutil */
+    pt = kanji;
+    for(;*pt;){
+            *dest++ = *pt++;
+        } 
+#else	/* conver from bottom */
+    pt = kanji + wnn_Strlen(kanji) - 1;
+    for(;pt >= kanji;){
+	*dest++ = *pt--;
+    }
+#endif /* CONVERT_from_TOP */
+    *dest++ = 0;
+
+    if(comment && *comment){
+	pt = comment;
+	for(;*pt;){
+	    *dest++ = *pt++;
+	}
+	state |= HAS_COMMENT;
+	*dest++ = 0;
+    }
+    *d0 = (UCHAR)((UCHAR *)dest - d0);
+    *(d0 + 1) = state;
+    return(*d0);
+}	
+
+#endif
+
+
+#ifdef JS
+static
+#endif
+int
+create_null_dic(fn,comm, passwd, hpasswd, which)
+char  *fn;
+w_char *comm;
+char *passwd, *hpasswd;  /* not encoded passwd */
+int which;
+{
+    FILE *fp;
+    struct JT jt;
+    char epasswd[WNN_PASSWD_LEN];
+    extern void new_pwd();
+    
+    jt.total = 0;
+    jt.gosuu = 0;
+    if(hpasswd){
+	new_pwd(hpasswd, jt.hpasswd);
+    }else{
+	bzero(jt.hpasswd, WNN_PASSWD_LEN);
+    }
+    jt.syurui = which;
+    jt.maxserial = 0;
+    jt.maxtable = 0;
+    jt.maxhontai = (which == WNN_UD_DICT)? 4: 0;
+    jt.maxkanji = 0;
+    if(comm){
+	jt.maxcomment = wnn_Strlen(comm);
+    }else{
+	jt.maxcomment = 0;
+    }
+    jt.maxhinsi_list = 0;
+    jt.maxri1[D_YOMI] = 0;
+    jt.maxri1[D_KANJI] = 0;
+    jt.maxri2 = 0;
+
+    if((fp = fopen(fn, "w")) == NULL){
+	/*	error1( "Jserver:create_null_ud:No file %s.\n", fn); */
+	return(-1);
+    }
+    if(passwd){
+	new_pwd(passwd, epasswd);
+    }else{
+	bzero(epasswd, WNN_PASSWD_LEN);
+    }
+    if(create_file_header(fp, WNN_FT_DICT_FILE,epasswd) == -1 ||
+       output_header_jt(fp, &jt) == -1){
+	fclose(fp);return(-1);
+    }
+#ifdef BDIC_WRITE_CHECK
+    if (put_n_EU_str(fp, comm, jt.maxcomment) == -1) {
+	fclose(fp);
+	return(-1);
+    }
+#else /* BDIC_WRITE_CHECK */
+    put_n_EU_str(fp, comm, jt.maxcomment);
+#endif /* BDIC_WRITE_CHECK */
+    if(which == WNN_UD_DICT){
+#ifdef BDIC_WRITE_CHECK
+	if (putint(fp, 0) == -1) {	/* hontai[0] */
+	    fclose(fp);
+	    return(-1);
+	}
+#else /* BDIC_WRITE_CHECK */
+	putint(fp, 0);			/* hontai[0] */
+#endif /* BDIC_WRITE_CHECK */
+    }
+
+#ifdef	BSD42
+    fchmod(fileno(fp), 0664);
+    fclose(fp);
+#else	/* SYSV */
+    fclose(fp);
+    chmod(fn, 0664);
+#endif	/* BSD42 */
+    return(0);
+}
+
+
+#ifdef JS
+static
+#endif
+int
+create_hindo_file(funiq, fn, comm, passwd, serial)
+struct wnn_file_uniq *funiq;
+char *fn;
+w_char *comm;
+char *passwd;			/* Not encoded */
+int serial;
+{
+    FILE *fp;
+    struct HJT hjt;
+    char epasswd[WNN_PASSWD_LEN];
+    w_char tmp[1];
+
+    tmp[0] = 0;
+    if(comm == NULL) comm = tmp;
+    bcopy(funiq, &(hjt.dic_file_uniq), WNN_F_UNIQ_LEN);
+    hjt.maxcomment = wnn_Strlen(comm);
+    
+    hjt.maxserial = serial;
+
+    if((fp = fopen(fn, "w")) == NULL){
+	return(-1);
+    }
+    if(passwd){
+	new_pwd(passwd, epasswd);
+    }else{
+	bzero(epasswd, WNN_PASSWD_LEN);
+    }
+    if(create_file_header(fp, WNN_FT_HINDO_FILE, epasswd) == -1){fclose(fp);return(-1);}
+#ifdef BDIC_WRITE_CHECK
+    if ((output_header_hjt(fp, &hjt) == -1) ||
+	(put_n_EU_str(fp, comm, hjt.maxcomment) == -1) ||
+	(putnull(fp, serial) == -1)) {
+	fclose(fp);
+	return(-1);
+    }
+#else /* BDIC_WRITE_CHECK */
+    output_header_hjt(fp, &hjt);
+    put_n_EU_str(fp, comm, hjt.maxcomment);
+    putnull(fp, serial);
+#endif /* BDIC_WRITE_CHECK */
+
+#ifdef	BSD42
+    fchmod(fileno(fp), 0664);
+    fclose(fp);
+#else	/* SYSV */
+    fclose(fp);
+    chmod(fn, 0664);
+#endif	/* BSD42 */
+    return(0);
+}
+
+/* Header Total 128 Bytes */
+
+#ifndef	JS
+int
+input_header_jt(ifpter, jt1)
+FILE *ifpter;
+struct JT *jt1;
+{
+    if(
+       getint(&jt1->syurui , ifpter) == -1 ||
+       getint(&jt1->maxcomment, ifpter) == -1 ||
+       getint(&jt1->maxhinsi_list, ifpter) == -1 ||
+       getint(&jt1->maxserial , ifpter) == -1 ||
+       getint(&jt1->maxkanji , ifpter) == -1 ||
+       getint(&jt1->maxtable , ifpter) == -1 ||
+       getint(&jt1->maxhontai , ifpter) == -1 ||
+       getint(&jt1->gosuu , ifpter) == -1 ||
+       getnstr(ifpter, WNN_PASSWD_LEN, jt1->hpasswd) == -1 ||
+       getint(&jt1->total , ifpter) == -1 ||
+       getint(&jt1->maxri1[D_YOMI] , ifpter) == -1 ||
+       getint(&jt1->maxri1[D_KANJI] , ifpter) == -1 ||
+       getint(&jt1->maxri2, ifpter) == -1 ||
+       getnull(ifpter, 56 ) == -1)
+	return(-1);
+    return(0);
+}
+#endif
+
+#ifdef JS
+static
+#endif
+int
+output_header_jt(ofpter, jt1)
+FILE *ofpter;
+struct JT *jt1;
+{
+#ifdef BDIC_WRITE_CHECK
+    if ((putint(ofpter, jt1->syurui) == -1) ||
+	(putint(ofpter, jt1->maxcomment) == -1) ||
+	(putint(ofpter,  jt1->maxhinsi_list) == -1) ||
+	(putint(ofpter, jt1->maxserial) == -1) ||
+	(putint(ofpter, jt1->maxkanji) == -1) ||
+	(putint(ofpter, jt1->maxtable) == -1) ||
+	(putint(ofpter, jt1->maxhontai) == -1) ||
+	(putint(ofpter, jt1->gosuu) == -1) ||
+	(put_n_str(ofpter, jt1->hpasswd, WNN_PASSWD_LEN) == -1) ||
+	(putint(ofpter, jt1->total) == -1) ||
+	(putint(ofpter, jt1->maxri1[D_YOMI]) == -1) ||
+	(putint(ofpter, jt1->maxri1[D_KANJI]) == -1) ||
+	(putint(ofpter, jt1->maxri2) == -1) ||
+	(putnull(ofpter, 56) == -1)) return(-1);
+#else /* BDIC_WRITE_CHECK */
+    putint(ofpter, jt1->syurui);
+    putint(ofpter, jt1->maxcomment);
+    putint(ofpter,  jt1->maxhinsi_list);
+    putint(ofpter, jt1->maxserial);
+    putint(ofpter, jt1->maxkanji);
+    putint(ofpter, jt1->maxtable);
+    putint(ofpter, jt1->maxhontai);
+    putint(ofpter, jt1->gosuu);
+    put_n_str(ofpter, jt1->hpasswd, WNN_PASSWD_LEN);
+    putint(ofpter, jt1->total);
+    putint(ofpter, jt1->maxri1[D_YOMI]);
+    putint(ofpter, jt1->maxri1[D_KANJI]);
+    putint(ofpter, jt1->maxri2);
+    putnull(ofpter, 56);
+#endif /* BDIC_WRITE_CHECK */
+    return(0);
+}
+
+/* Header 64 Byte */
+#ifndef	JS
+int
+input_header_hjt(ifpter, hjt1)
+FILE *ifpter;
+struct HJT *hjt1;
+{
+    if(
+       input_file_uniq(&hjt1->dic_file_uniq, ifpter) == -1 ||  /* 7 * 4 */
+       getint(&hjt1->maxcomment, ifpter) == -1 ||
+       getint(&hjt1->maxserial, ifpter) == -1 ||
+       getnull(ifpter, 28) == -1)  {
+	return(-1);
+    }
+    return(0);
+}
+#endif
+
+#ifdef JS
+static
+#endif
+int
+output_header_hjt(ofpter, hjt1)
+FILE *ofpter;
+struct HJT *hjt1;
+{
+#ifdef BDIC_WRITE_CHECK
+    if ((output_file_uniq(&hjt1->dic_file_uniq, ofpter) == -1) ||
+	(putint(ofpter, hjt1->maxcomment) == -1) ||
+	(putint(ofpter, hjt1->maxserial) == -1) ||
+	(putnull(ofpter, 28) == -1)) return(-1);
+#else /* BDIC_WRITE_CHECK */
+    output_file_uniq(&hjt1->dic_file_uniq, ofpter);
+    putint(ofpter, hjt1->maxcomment);
+    putint(ofpter, hjt1->maxserial);
+    putnull(ofpter, 28);
+#endif /* BDIC_WRITE_CHECK */
+    return(0);
+}
+
+
+#if	!defined(JS) && !defined(JSERVER)
+/* Only use JUTIL */
+void
+Print_entry(yomi, kstr, cstr, hindo, ima, hinsi, serial, ofpter, esc_exp)
+w_char *yomi, *kstr,*cstr;
+int serial, hindo, ima, hinsi;
+FILE *ofpter;
+int esc_exp;
+{
+    register int len;
+    char *k;
+    char buf[32];
+    static w_char revy[LENGTHKANJI];
+    extern void kanji_esc_str();
+    
+    if(serial != -1){
+	sprintf(buf, "%d\t", serial);
+	vputs(buf, ofpter);
+    }
+
+    len = put_yomi_str(yomi, ofpter);
+    if(len < 8)vputc('\t' , ofpter);
+    if(len < 16)vputc('\t' , ofpter);
+    vputc('\t' , ofpter);
+    
+    if(esc_exp){
+#ifdef CONVERT_from_TOP /* Don't warry. Only use in jutil */
+	wnn_Strcpy(revy, yomi);
+#else	/* conver from bottom */
+	wnn_Sreverse(revy, yomi);
+#endif /* CONVERT_from_TOP */
+	kanji_esc_str(kstr, revy, wnn_Strlen(yomi));
+	len = put_yomi_str(kstr, ofpter);
+    }else{
+	len = vputws(kstr, ofpter); 
+    }
+    if(len < 8)vputc('\t' , ofpter);
+    if(len < 16)vputc('\t' , ofpter);
+    vputc('\t' , ofpter);
+    
+    k = wnn_get_hinsi_name(hinsi);
+    if(k){
+	vputs(k, ofpter);
+	if((int)strlen(k) < 8)vputc('\t' , ofpter);
+	vputc('\t' , ofpter);
+    }else{
+	sprintf(buf, "%d\t\t", hinsi);
+	vputs(buf, ofpter);
+    }
+    
+    if(ima) vputc('*', ofpter);
+    if(hindo == -1){  	/*  Real hindo == -1 means Not to use it */
+	vputs("-", ofpter);
+    }else{
+	sprintf(buf, "%d", hindo);
+	vputs(buf, ofpter);
+    }	
+    if(cstr && cstr[0]){
+	vputc('\t', ofpter);
+	len = vputws(cstr, ofpter); 
+    }
+    vputc('\n', ofpter);
+}
+#endif
+
+#ifdef BDIC_WRITE_CHECK
+#undef BDIC_WRITE_CHECK
+#endif
diff --git a/wnn/commonhd.h b/wnn/commonhd.h
new file mode 100644
index 0000000000000000000000000000000000000000..e153091b77ef28166e24b61d416470e2bca2f0a9
--- /dev/null
+++ b/wnn/commonhd.h
@@ -0,0 +1,298 @@
+/*
+ * $Id: commonhd.h,v 1.1 1996/03/13 09:56:32 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/****************
+ * Common header 
+ ****************/
+#include <stdio.h>
+#ifdef linux
+#include <unistd.h>
+#endif
+#define	JSERVER_VERSION	0x4200	/* minor version */
+#define	_SERVER_VERSION	"4.20"
+
+#include "wnnerror.h"
+
+#ifndef JS
+typedef  unsigned int  UINT;
+typedef  unsigned char UCHAR;
+#ifndef	w_char
+# define w_char unsigned short
+#endif	/* w_char */
+#endif /*JS */
+
+#ifdef TAIWANESE
+#ifndef	CHINESE
+#define CHINESE
+#endif
+#endif
+
+#ifdef	CHINESE
+#define	CONVERT_from_TOP
+#define	CONVERT_by_STROKE	/* ɮ��(Bi Xing) */
+#define	CONVERT_with_SiSheng	/* ����(Si Sheng) */
+#define NO_FZK			/* ��°��ϡ��ʤ� */
+#define NO_KANA			/* �Ҥ餬��(�ɤߤ�Ʊ������)�ϡ��ʤ� */
+#endif
+
+#ifdef KOREAN
+#define CONVERT_from_TOP
+#define NO_FZK
+#endif
+
+#ifdef luna
+#ifdef uniosu
+# ifndef	SYSVR2
+#  define	SYSVR2
+# endif
+# ifndef	TERMINFO
+#  define	TERMINFO
+# endif
+#else	/* if defined(MACH) || defined(uniosb) */
+# ifndef	BSD42
+#  define	BSD42
+# endif
+# ifndef	BSD43
+#  define	BSD43
+# endif
+#  if defined(luna68k)
+#   ifndef	BSD44
+#    define	BSD44
+#   endif
+#  endif /* defined(luna68k) */
+# ifndef	TERMCAP
+#  define	TERMCAP
+# endif
+#endif
+#else	/* defined(luna) */
+#if defined(sun) && !defined(SVR4)
+# ifndef	BSD42
+#  define	BSD42
+# endif
+# ifndef	TERMCAP
+#  define	TERMCAP
+# endif
+#else	/* sun else */
+#if defined(DGUX) || defined(linux)
+# ifndef	SYSVR2
+#  define	SYSVR2
+# endif
+# ifndef	TERMCAP
+#  define	TERMCAP
+# endif
+#else
+#if defined(SVR4) || defined(hpux) 
+# ifndef	SYSVR2
+#  define	SYSVR2
+# endif
+# ifndef	TERMINFO
+#  define	TERMINFO
+# endif
+# ifdef sun
+#  define SOLARIS
+# endif
+#else
+# ifndef	BSD43
+#  define	BSD43
+# endif
+# ifndef	BSD42
+#  define	BSD42
+# endif
+# ifndef	TERMCAP
+#  define	TERMCAP
+# endif
+#endif /* defined(SVR4) || defined(hpux) */
+#endif /* DGUX */
+#endif /* sun */
+#endif /* luna */
+
+#if defined(SYSVR2) || defined(sun)
+# define SRAND48
+#endif
+#if defined(SVR4) || defined(hpux)
+#ifndef F_OK
+#define F_OK	0
+#endif
+#ifndef R_OK
+#define R_OK	4
+#endif
+#endif
+
+#define MAXBUNSETSU	80
+#define LIMITBUNSETSU   400
+#define MAXJIKOUHO	400
+
+#define J_IUJIS 0
+#define J_EUJIS 1
+#define J_JIS   2
+#define J_SJIS  3
+
+#define C_IUGB	0
+#define C_EUGB	1
+
+#define C_ICNS11643  0
+#define C_ECNS11643  1
+#define C_BIG5  2
+
+#define K_IUKSC 0
+#define K_EUKSC 1
+#define K_KSC   2
+
+#ifndef	True
+#define	True	1
+#endif
+#ifndef	False
+#define	False	0
+#endif
+
+#define KANJI(x)	((x) & 0x80)
+
+
+#define Ctrl(X)		((X) & 0x1f)
+
+#define NEWLINE		Ctrl('J')
+#define CR		Ctrl('M')
+#define ESC		'\033'
+
+#ifdef luna
+#ifdef uniosu
+#define RUBOUT		0x08	/* BS */
+#else
+#define RUBOUT		'\177'
+#endif
+#else
+#define RUBOUT		'\177'
+#endif
+#define SPACE		' '
+
+
+#define JSPACE		0xa1a1
+#ifdef KOREAN
+#define BAR		0xA1aa	/* ��	*/
+#else
+#define BAR		0xA1BC	/* ��	*/
+#endif
+#define KUTEN_NUM	0xA1A3	/* ��	*/
+#define TOUTEN_NUM	0xA1A2	/* ��	*/
+#define S_NUM		0xA3B0	/* ��	*/
+#define E_NUM		0xA3B9	/* ��	*/
+#ifdef KOREAN
+#define S_HIRA		0xAAA1	/* ��	*/
+#define E_HIRA		0xAAF3	/* ��	*/
+#define S_KATA		0xABA1	/* ��	*/
+#define E_KATA		0xABF6	/* ��	*/
+#else
+#define S_HIRA		0xA4A1	/* ��	*/
+#define E_HIRA		0xA4F3	/* ��	*/
+#define S_KATA		0xA5A1	/* ��	*/
+#define E_KATA		0xA5F6	/* ��	*/
+#endif
+#define S_HANKATA	0x00A1	/* ��	*/
+#define E_HANKATA	0x00DF	/* ��    */
+
+#ifdef KOREAN
+#define S_JUMO		0xa4a1	/* �� */
+#define E_JUMO		0xa4fe	/* �� */
+#define S_HANGUL	0xb0a1	/* �� */
+#define E_HANGUL	0xc8fe	/* �� */
+#define S_HANJA		0xcaa1	/* ʡ */
+#define E_HANJA		0xfdfe	/* �� */
+
+#define ishanja(x)      ((unsigned)((x) - S_HANJA) <= (E_HANJA - S_HANJA))
+#define ishangul(x)     ((unsigned)((x) - S_HANGUL) <= (E_HANGUL - S_HANGUL))
+#endif
+
+#define HIRAP(X) ((X) >= S_HIRA && (X) <= E_HIRA)
+#define KATAP(X) (((X) >= S_KATA && (X) <= E_KATA) || ((X) == BAR))
+#define ASCIIP(X) ((X) < 0x7f)
+#define KANJIP(X) (!(HIRAP(X) || KATAP(X) || ASCIIP(X)))
+
+#define YOMICHAR(X) ((HIRAP(X)) || \
+		     ('0'<=(X)&&'9'>=(X)) || \
+		     ('A'<=(X)&&'Z'>=(X)) || \
+		     ('a'<=(X)&&'z'>=(X)) || \
+		     (BAR == X) \
+		    )
+#define HIRA_OF(X) ((KATAP(X) && !(BAR == (X)))? ((X) & ~0x0100) : (X))
+
+#ifdef	CONVERT_by_STROKE
+# define Q_MARK		'?'
+#endif	/* CONVERT_by_STROKE */
+
+#define LENGTHYOMI      256	/* jisho ni touroku suru yomi no nagasa */
+#define LENGTHKANJI     256	/* jisho ni touroku suru kanji no nagasa */
+#define LENGTHBUNSETSU  264    /* ʸ��κ���Ĺ */
+#define LENGTHCONV      512	/* �Ѵ���ǽ����ʸ���� */
+
+#define JISHOKOSUU     20	
+
+#define DIC_RDONLY 1   /* ���񤬥꡼�ɡ�����꡼�Ǥ��롣*/
+
+
+/* ʣ���Υե�����ˤޤ����ä��Ѥ����Ƥ���Хåե������������ */
+#define EXPAND_PATH_LENGTH 256 /* expand_expr()���Ѥ���Хåե��Υ����� */
+
+
+#define WNN_FILE_STRING "�ף��Υե�����"
+
+#define WNN_FILE_STRING_LEN 16
+
+
+#define F_STAMP_NUM 64
+#define FILE_ALREADY_READ -2
+#define FILE_NOT_READ -3
+
+/*	file ID	*/
+/*
+  Local Variables:
+  kanji-flag: t
+  End:
+*/
+
diff --git a/wnn/config.h b/wnn/config.h
new file mode 100644
index 0000000000000000000000000000000000000000..777aa8cdd001f755b809c5cb1ea6bea786e12f50
--- /dev/null
+++ b/wnn/config.h
@@ -0,0 +1,203 @@
+/*
+ * $Id: config.h,v 1.1 1996/03/13 09:56:34 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+#ifndef	LIBDIR
+#define	LIBDIR		"/usr/local/lib/wnn"
+#endif	/* LIBDIR */
+
+#ifdef TAIWANESE
+#ifndef CHINESE
+#define CHINESE
+#endif
+#endif
+
+#define WNN_USERNAME_ENV	"WNNUSER"
+#define WNN_JSERVER_ENV		"JSERVER"
+#define WNN_CSERVER_ENV		"CSERVER"
+#define WNN_KSERVER_ENV		"KSERVER"
+#define WNN_TSERVER_ENV		"TSERVER"
+#define WNN_J_LANG		"ja_JP"
+#define WNN_C_LANG		"zh_CN"
+#define WNN_K_LANG		"ko_KR"
+#define WNN_T_LANG		"zh_TW"
+#ifdef JAPANESE
+#define WNN_DEFAULT_LANG	WNN_J_LANG
+#define WNN_DEF_SERVER_ENV	WNN_JSERVER_ENV
+#else /* JAPANESE */
+#ifdef CHINESE
+#ifdef TAIWANESE
+#define WNN_DEFAULT_LANG	WNN_T_LANG
+#define WNN_DEF_SERVER_ENV	WNN_TSERVER_ENV
+#else /* TAIWANESE */
+#define WNN_DEFAULT_LANG	WNN_C_LANG
+#define WNN_DEF_SERVER_ENV	WNN_CSERVER_ENV
+#endif /* TAIWANESE */
+#else /* CHINESE */
+#ifdef KOREAN
+#define WNN_DEFAULT_LANG	WNN_K_LANG
+#define WNN_DEF_SERVER_ENV	WNN_KSERVER_ENV
+#else /* KOREAN */
+#define WNN_DEFAULT_LANG	WNN_J_LANG
+#define WNN_DEF_SERVER_ENV	WNN_JSERVER_ENV
+#endif /* KOREAN */
+#endif /* CHINESE */
+#endif /* JAPANESE */
+#define WNN_UUM_ENV  		"UUMRC"
+#define WNN_KEYBOARD_ENV	"KEYBOARD"
+#define WNN_COUNTDOWN_ENV	"UUM_COUNTDOWN"
+
+#define PATHNAMELEN	256
+
+/* for jserver */
+#ifndef	SERVER_INIT_FILE
+# ifdef JAPANESE
+#  define SERVER_INIT_FILE	"/ja_JP/jserverrc"
+# else /* JAPANESE */
+# ifdef	CHINESE
+# ifdef	TAIWANESE
+#  define SERVER_INIT_FILE	"/zh_TW/tserverrc"
+# else /* TAIWANESE */
+#  define SERVER_INIT_FILE	"/zh_CN/cserverrc"
+# endif /* TAIWANESE */
+# else /* CHINESE */
+# ifdef KOREAN
+#  define SERVER_INIT_FILE	"/ko_KR/kserverrc"
+# else /* KOREAN */
+#  define SERVER_INIT_FILE	"/ja_JP/jserverrc"	/* Default */
+# endif /* KOREAN */
+# endif /* CHINESE */
+# endif /* JAPANESE */
+#endif
+#define JSERVER_DIR		"/tmp"
+
+/* for uum */
+#define RCFILE			"/uumrc"	/* LIBDIR/@LANG/RCFILE */
+#define USR_UUMRC		"/.uumrc"
+#define RKFILE			"/rk/mode"	/* LIBDIR/@LANG/RKFILE */
+#define CPFILE			"/uumkey"	/* LIBDIR/@LANG/CPFILE */
+#define MESSAGEFILE		"/message_file"
+
+#define CONVERT_FILENAME	"/cvt_key_tbl"
+
+#define ENVRCFILE		"/wnnenvrc"
+#ifndef	HINSIDATA_FILE
+# define HINSIDATA_FILE		"/ja_JP/hinsi.data"
+#endif	/* HINSIDATA_FILE */
+
+#define USR_DIC_DIR_VAR "@USR"
+
+/*
+  if you wish to do flow control active for your tty,
+  define FLOW_CONTROL to 1.
+  note that this 'tty' means the tty from which wnn is invoked.
+ */
+
+#define FLOW_CONTROL 0
+
+#define C_LOCAL '!'		
+/* For Local File Name.
+   Local File Name is send as "Hostname!Filename" when C_LOCAL is '!'.
+   It is also used in jl_library to specify local file-name, that is,
+   file-names which start with this character are considered to be local.
+   */
+
+
+/*
+  define default kanji code system for your 'tty' side and 'pty' side.
+  'tty' side (TTY_KCODE) means 'your terminal's code'.
+  'pty' side (PTY_KCODE) means 'application's code'.
+ */
+
+#ifdef luna
+# ifdef uniosu
+#define TTY_KCODE J_EUJIS
+#define PTY_KCODE J_EUJIS
+# else	/* defined(MACH) || defined(uniosb) */
+#define TTY_KCODE J_EUJIS
+#define PTY_KCODE J_EUJIS
+# endif
+#else /* !luna */
+# ifdef DGUX
+#define TTY_KCODE J_EUJIS
+#define PTY_KCODE J_EUJIS
+# else /* !DGUX */
+#define TTY_KCODE J_JIS
+#define PTY_KCODE J_JIS
+# endif
+#endif
+
+#define TTY_CCODE C_EUGB
+#define PTY_CCODE C_EUGB
+#define TTY_TCODE C_BIG5
+#define PTY_TCODE C_BIG5
+
+#define TTY_HCODE K_EUKSC
+#define PTY_HCODE K_EUKSC
+
+/*
+  OPTIONS defines what options are available.
+  define it by modifying ALL_OPTIONS string.
+  if you wish to make some option abailable, leave that character unchanged.
+  else turn that character some non-option character, ex. '*'.
+  TAKE CARE NOT TO MOVE CHARACTER POSITION, ORDER, ETC!!
+
+  see sdefine.h for precise definition of ALL_OPTIONS. defines below
+  may be incorrect.
+
+#define GETOPTSTR   "hHujsUJSPxXk:c:r:l:D:n:vL:"
+#define ALL_OPTIONS "hHujsUJSPxXkcrlDnvL"
+
+#ifndef OPTIONS
+#define OPTIONS ALL_OPTIONS
+#endif
+ */
+
+#define	WNN_TIMEOUT	5	/* connect �κݤˣ����ԤĤ���� */
+#define	WNN_DISP_MODE_LEN	5	/* �⡼��ɽ����ɬ�פ�column�� */
diff --git a/wnn/cplib.h b/wnn/cplib.h
new file mode 100644
index 0000000000000000000000000000000000000000..d7350a5d52cb6fc7692aaf729f64cf709272295d
--- /dev/null
+++ b/wnn/cplib.h
@@ -0,0 +1,141 @@
+/*
+ * $Id: cplib.h,v 1.1 1996/03/13 09:56:36 colin Exp $
+ */
+/** 		Copyright OMRON Corporation. 1989, 1990, 1991, 1992, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its 
+ * documentation for any purpose is hereby granted without fee, provided 
+ * that all of the following conditions are satisfied:
+ *
+ * <1>	The above copyright notices appear in all copies
+ * <2>	Both the copyright notices and this permission notice appear in 
+ *	supporting documentation
+ * <3>	The name of "cWnn" isn't changed unless substantial modifications 
+ * 	are made
+ * <4>	Following words followed by the above copyright notices appear
+ *    	in all supporting documentation of software based on "cWnn":
+ *
+ * 	This software is based on the original version of cWnn developed 
+ *	by OMRON Corporation and Wnn developed by Kyoto University Research 
+ *	Institute for Mathematical Sciences (KURIMS), OMRON Corporation and 
+ * 	ASTEC Inc."
+ *
+ * <5>	The names of OMRON may not be used in advertising or publicity 
+ *	pertaining to distribution of the software without specific, written 
+ *	prior permission
+ *
+ *  OMRON Corporation makes no representations about the suitability of this 
+ *  software for any purpose.  It is provided "as is" without express or 
+ *  implied warranty.
+ *
+ *  Wnn consortium is one of distributors of the official Wnn source code
+ *  release.  Wnn consortium also makes no representations about the
+ *  suitability of this software for any purpose.  It is provided "as is"
+ *  without express or implied warranty.
+ *
+ *  OMRON AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ *  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ *  IN NO EVENT SHALL OMRON OR WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL,
+ *  INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ *  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ *  PERFORMANCE OF THIS SOFTWARE.
+ *
+ *  This sofeware is developed by OMRON Corporation, based on the original 
+ *  version of Wnn which was developed by Kyoto University Research Institute 
+ *  for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc. 
+ *
+ *  	Copyright Kyoto University Research Institute for Mathematical 
+ *		Sciences 1987,1988,1989,1990,1991, 1992
+ * 	Copyright OMRON Corporation 1987,1988,1989,1990,1991, 1992
+ *	Copyright ASTEC Inc. 1987, 1988,1989,1990,1991, 1992
+ *
+ *  Contact:	Tel:   	+81-75-951-5111
+ *		Fax:   	+81-75-955-2442
+ *		E-mail: zhong@ari.ncl.omron.co.jp
+**/
+/**  cWnn  Version 1.1	 **/
+
+
+#ifndef min
+#define min(a,b) ((int)(a) > (int)(b)? (b):(a))
+#endif 
+
+#define YIN_LEN         10
+#define PY_LEN          10      /*   'Chuang��', 'Zhuang��'  */
+#define PY_LEN_W        7       /* for w_char  */
+
+#define PY_MARK       'P'   /* for PinYincode: to know if need to change to */
+#define ZY_MARK       'Z'   /* for PinYincode: to know if need to change to */
+#define CWNN_PINYIN	0	/* For Pinyin */
+#define CWNN_ZHUYIN	1	/* For Zhuyin */
+
+
+#define  PY_EOF 	0x8ec0  /* PY_EOF is end charactor of one PinYin
+                       		         must be a 2 bytes code.  HUANG */
+#define  ZY_EOF_0	0x8ec0  /* ZhuYin end character(no sisheng): '��' */
+#define  ZY_EOF_1	0x8ec1	/* ZhuYin end character(sisheng 1 ): '��' */
+#define  ZY_EOF_2	0x8ec2	/* ZhuYin end character(sisheng 2 ): '��' */
+#define  ZY_EOF_3	0x8ec3	/* ZhuYin end character(sisheng 3 ): '��' */
+#define  ZY_EOF_4	0x8ec4	/* ZhuYin end character(sisheng 4 ): '��' */
+
+#define  isZY_EOF(X)  ( ((int)(X) >= ZY_EOF_0 && (int)(X) <= ZY_EOF_4 )? 1 : 0 )
+
+#define PY_NUM_SHENGMU	24		/* ShengMu table size of PinYin */
+#define PY_NUM_YUNMU	39		/* YunMu table size of PinYin */
+#define ZY_NUM_SHENGMU	24		/* ShengMu table size of ZhuYin */
+#define ZY_NUM_YUNMU	41		/* YunMu table size of ZhuYin */
+
+#define EMPTY_SHENG_RAW 0		/* position of ShengMu EMPTY in ShengMu
+					   table  */
+#define EMPTY_YUN_RAW 0			/* position of YunMu EMPTY in YunMu
+					   table  */
+#define X_SHENG_RAW	20		/* position of ShengMu X in ShengMu 
+					   table  */
+
+/* YINcode creating is based on PinYin */
+/* isyincod_d():  Check it is in the domain of Pinyin. To check if it is a 
+   Pinyin, you need to use cp_isyincod() wihich checks the PinYin table  */
+#define  _cwnn_isyincod_d(c)  ( ((c & 0x80) &&		\
+				(!(c & 0x8000)) &&		\
+				(c & 0x7f) >= 0x20 &&		\
+				(((int)c >> (int)8) & 0x7f) >= 0x20 )	\
+			      ?1:0 )	/* if is in YINcode's limite */
+
+#define _cwnn_sisheng(YINcod)	( ((YINcod & 0x100) == 0x100)?  \
+			   ((YINcod & 0x03 ) + 1): 0 )
+
+#define _cwnn_yincod_0(YINcod)    ((YINcod) & 0xfefc)
+
+/* Shengraw based on PinYin table */
+#define Shengraw(YINcod) (((int)((YINcod - 0x20a0) & 0x7c)>>(int)2) + 0x01)
+
+/* Yunraw based on PinYin table  */
+#define Yunraw(YINcod) 	((int)(((YINcod) - 0x20a0) & 0x7e00) >> (int)9)
+
+
+/* to see if the char is a start char of a pinyin without sisheng */
+#define py0_first_ch(X) (((int)(X)>'A' && (int)(X)<='Z' &&  \
+			  (X)!='E' && (X)!='O'&& \
+			  (X)!='I' && (X)!='U' && (X)!='V') || \
+			  (X)=='a'||(X)=='e'||(X)=='o' || (X)=='n'? 1: 0)
+
+/* to see if the char is a start char of a zhuyin */
+
+    /* for sisheng */
+#define S_S_YOMI(X)  	( ((int)(X&0xff)>=0xa1)&&((int)(X&0xff)<=0xbf))||((int)(X>>8)==0x8e)
+#define py_first_ch(X)	( py0_first_ch(X) || S_S_YOMI(X) )
+#define zy_first_ch(X)   ( ((int)(X&0xff) >= 0xc0 && (int)(X&0xff) <= 0xe9 && \
+			    ((int)(X>>(int)8)) == 0x8e) )
+
+#define _cwnn_has_sisheng(YINcod)	( (( (YINcod)& 0x0100) != 0 ) ?1:0)
+
+extern  unsigned char  last_mark;
+
+extern  char  	*py_shengmu_tbl[];  	/* PinYin ShengMu table */
+extern  char  	*py_yunmu_tbl[];	/* PinYin YunMu table   */
+extern  char  	*zy_shengmu_tbl[];	/* ZhuYin ShengMu table */
+extern  char  	*zy_yunmu_tbl[];	/* ZhuYin YunMu table   */
+
+extern  int  	pinyin_tbl[]; 		/* PinYin table		*/
+extern  int  	zhuyin_tbl[]; 		/* ZhuYin table 	*/
diff --git a/wnn/demcom.h b/wnn/demcom.h
new file mode 100644
index 0000000000000000000000000000000000000000..2448bf220263fd50b8eeaa8a3a6cdd0c1976afeb
--- /dev/null
+++ b/wnn/demcom.h
@@ -0,0 +1,130 @@
+/*
+ * $Id: demcom.h,v 1.1 1996/03/13 09:56:37 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/*
+	demcom.h
+	entry functions	definitions
+*/
+
+/*
+ *	Demon Commands
+ */
+#define	JS_VERSION	0x00
+#define	JS_OPEN		0x01
+/*	#define	JS_OPEN_IN	0x02	*/
+#define	JS_CLOSE	0x03
+#define	JS_CONNECT	0x05
+#define	JS_DISCONNECT	0x06
+#define	JS_ENV_EXIST	0x07
+#define	JS_ENV_STICKY	0x08
+#define	JS_ENV_UN_STICKY	0x09
+
+
+#define	JS_KANREN	0x11
+#define	JS_KANTAN_SHO	0x12
+#define	JS_KANZEN_SHO	0x13
+#define	JS_KANTAN_DAI	0x14
+#define	JS_KANZEN_DAI	0x15
+#define	JS_HINDO_SET	0x18
+
+
+#define	JS_DIC_ADD	0x21
+#define	JS_DIC_DELETE	0x22
+#define	JS_DIC_USE	0x23
+#define	JS_DIC_LIST	0x24
+#define	JS_DIC_INFO	0x25
+
+#define	JS_FUZOKUGO_SET	0x29
+#define	JS_FUZOKUGO_GET	0x30
+
+
+#define	JS_WORD_ADD	0x31
+#define	JS_WORD_DELETE	0x32
+#define	JS_WORD_SEARCH	0x33
+#define	JS_WORD_SEARCH_BY_ENV	0x34
+#define	JS_WORD_INFO	0x35
+#define JS_WORD_COMMENT_SET 0x36
+
+#define	JS_PARAM_SET	0x41
+#define	JS_PARAM_GET	0x42
+
+#define	JS_MKDIR	0x51
+#define	JS_ACCESS	0x52
+#define	JS_WHO		0x53
+#define	JS_ENV_LIST	0x55
+#define	JS_FILE_LIST_ALL	0x56
+#define	JS_DIC_LIST_ALL	0x57
+
+#define	JS_FILE_READ	0x61
+#define	JS_FILE_WRITE	0x62
+#define	JS_FILE_SEND	0x63
+#define	JS_FILE_RECEIVE	0x64
+
+#define	JS_HINDO_FILE_CREATE	0x65
+#define	JS_DIC_FILE_CREATE	0x66
+#define JS_FILE_REMOVE	0x67
+
+#define	JS_FILE_LIST	0x68
+#define	JS_FILE_INFO	0x69
+#define	JS_FILE_LOADED	0x6A
+#define	JS_FILE_LOADED_LOCAL	0x6B
+#define	JS_FILE_DISCARD	0x6C
+#define JS_FILE_COMMENT_SET 0x6D
+#define JS_FILE_PASSWORD_SET 0x6E /* 89/9/8 */
+
+#define	JS_FILE_STAT	0x6F
+#define JS_KILL		0x70
+
+#define	JS_HINDO_FILE_CREATE_CLIENT	0x71
+#define	JS_HINSI_LIST			0x72
+#define JS_HINSI_NAME	0x73
+#define JS_HINSI_NUMBER	0x74
+#define JS_HINSI_DICTS  0x75
+#define JS_HINSI_TABLE_SET 0x76
diff --git a/wnn/jd_sock.h b/wnn/jd_sock.h
new file mode 100644
index 0000000000000000000000000000000000000000..ea849c2e7247a95444b4b691e67ae525aafadb25
--- /dev/null
+++ b/wnn/jd_sock.h
@@ -0,0 +1,129 @@
+/*
+ * $Id: jd_sock.h,v 1.1 1996/03/13 09:56:39 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/*	jd_sock.h
+	jslib header file
+*/
+
+#ifdef UX386
+#undef	AF_UNIX
+#include <X11/Xos.h>
+#else
+#include <sys/types.h>
+#endif /* UX386 */
+#include <sys/socket.h>
+#ifdef	AF_UNIX
+#include <sys/un.h>
+#endif	/* AF_UNIX */
+
+#ifdef UX386
+#include <net/in.h>
+#else
+#include <netinet/in.h>
+#endif /* UX386 */
+
+#if	defined(uniosu) || defined(UX386)
+#include <net/netdb.h>	/* SX */
+#else
+#include <netdb.h>	/* SUN or BSD SYSV*/
+#endif /*uniosu */
+
+#ifdef TAIWANESE
+#ifndef CHINESE
+#define CHINESE
+#endif
+#endif
+
+#define	ERROR	-1
+
+#ifdef	JAPANESE	/* Japanese */
+# define WNN_PORT_IN	(0x5701)
+static char *sockname = "/tmp/jd_sockV4";	/* for jserver */
+# define LANG_NAME	"ja_JP"
+# define SERVERNAME	"wnn4"
+# define MESSAGE_FILE	"jserver.msg"
+#else	/* JAPANESE */
+
+#ifdef	CHINESE
+#ifdef	TAIWANESE		/* Traditional Chinese */
+# define WNN_PORT_IN	(0x5731)
+static char *sockname = "/tmp/td_sockV4";	/* for tserver */
+# define LANG_NAME	"zh_TW"
+# define SERVERNAME	"wnn4_Tw"
+# define MESSAGE_FILE	"tserver.msg"
+#else	/* TAIWANESE */		/* Simplified Chinese */
+# define WNN_PORT_IN	(0x5711)
+static char *sockname = "/tmp/cd_sockV4";	/* for cserver */
+# define LANG_NAME	"zh_CN"
+# define SERVERNAME	"wnn4_Cn"
+# define MESSAGE_FILE	"cserver.msg"
+#endif	/* TAIWANESE */
+#else	/* CHINESE */
+
+#ifdef	KOREAN			/* Korean *//* not yet */
+# define WNN_PORT_IN	(0x5721)
+static char *sockname = "/tmp/kd_sockV4";	/* for kserver */
+# define LANG_NAME	"ko_KR"
+# define SERVERNAME	"wnn4_Kr"
+# define MESSAGE_FILE	"kserver.msg"
+#else	/* KOREAN */
+
+# define WNN_PORT_IN	(0x5701)
+static char *sockname = "/tmp/jd_sockV4";	/* for jserver */
+# define LANG_NAME	"ja_JP"
+# define SERVERNAME	"wnn4"
+# define MESSAGE_FILE	"jserver.msg"
+#endif	/* KOREAN */
+#endif	/* CHINESE */
+#endif	/* JAPANESE */
+
+#define	S_BUF_SIZ	1024	/* NEVER change this */
+#define	R_BUF_SIZ	1024	/* NEVER change this */
+
diff --git a/wnn/jdata.h b/wnn/jdata.h
new file mode 100644
index 0000000000000000000000000000000000000000..53ad9ba97d20b3185fe6012fb80b1f87bb8f1cf7
--- /dev/null
+++ b/wnn/jdata.h
@@ -0,0 +1,279 @@
+/*
+ * $Id: jdata.h,v 1.1 1996/03/13 09:56:41 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+#ifndef	JS
+struct	jdata {
+  int	kanji1;
+  short	kanji2;			/* */
+  short   which ;		/* gyaku henkan? */
+  int	serial;			/* index is a serial number of the first 
+				 entry which is stored in this entry*/
+  int	kosuu;			/* this means the number of elements in this
+				 entry */
+  int	jishono;		/* jishono in which these entries are stored */
+  struct  jdata  *jptr;	/* pointer to another jdata which
+				 points out a jdata of the same yomi
+				 but (always)different jishono*/
+  unsigned short   *hinsi;
+#ifdef	CONVERT_with_SiSheng	/* Don't warry. Only use in server and jutil */
+/* It's only use CWNN : ���� */
+  unsigned short   *sisheng;
+  unsigned short   sisheng_int;
+#endif
+  UCHAR *hindo;			/* ���� */
+  UCHAR *hindo_in;		/* �������� */
+};
+#endif /* JS */
+
+struct JT {
+  unsigned int total;    /* �ȡ��������� */
+  int gosuu;
+  char hpasswd[WNN_PASSWD_LEN];
+  int syurui;
+
+  int maxcomment;
+  int maxhinsi_list;
+  int maxserial;
+  int maxtable;			/* For UD Dic */
+  int maxhontai;		/* For UD Dic  and Static Dic */
+  int maxkanji;
+  int maxri1[2];		/* For Rev Dic */
+  int maxri2;			/* For Rev Dic, is equal to maxserial */
+  
+
+  w_char *comment;
+  w_char *hinsi_list;
+
+  UCHAR *hindo;  /* ���� */
+#ifdef	CONVERT_with_SiSheng		/* Don't warry. Only use in server and jutil */
+/* It's only use CWNN : ���� */
+  unsigned short   *sisheng;
+  unsigned short   sisheng_int;
+#endif
+  unsigned short *hinsi;	/* bunpou data is stored here */
+  UCHAR *kanji;	/* kanji data is stored here */
+  struct uind1 *table; /* anothe tablefile for user jisho */
+  UCHAR *hontai;	/*  the tablefile (index-file) */
+  struct rind1 *ri1[2];  	/* For Rev Dic */
+  struct rind2 *ri2;		/* For Rev Dic */
+
+  short dirty;
+  short hdirty;
+
+/* ��������4�Ĥϡ� ��Ͽ��ǽ���񡢵��Ѵ���ǽ����ˤΤߴط����� */
+    int bufsize_kanji;    /* �����ΰ���礭�� */
+    int bufsize_serial;   /* ʸˡ�������ΰ���礭�� */
+    int bufsize_hontai;     /* ����ǥå���(hontai)���ΰ���礭��*/
+    int bufsize_table;     /*  ����ǥå���(table)���ΰ���礭��*/
+    int bufsize_ri1[2];  /* ���Ѵ���ǽ����� table ���ΰ���礭��  */
+
+  /* hinsi_list wo kakunou suru */
+  int maxnode;
+  struct wnn_hinsi_node *node;
+#ifdef	CONVERT_by_STROKE	/* Don't warry. Only use in server and jutil */
+/* Used for Bixing dic  */
+    struct b_node *bind;	/* index for yomi <--> kanji search*/
+    int		   max_bnode;	/* Max num of tuple     */
+    int		   bufsize_bnode;	/* BUFFER size of the b_node */
+#endif
+};
+
+struct HJT {
+  struct wnn_file_uniq dic_file_uniq;
+  int maxcomment;
+  int maxserial;
+
+  w_char *comment;
+  UCHAR *hindo;
+
+  short hdirty;
+  int bufsize_serial;
+};
+
+
+/*
+ * structures concerning UD dicts
+ */
+
+#define AL_INT(x) ((unsigned long)((char *)(x) + 3) & ((unsigned long)~0x3))
+
+
+#define ENDPTR 0  /* The end of (int) pointer list in uind2->next */
+#define RD_ENDPTR 0xffffffff  /* The end of (int) pointer list in rind2->next */
+
+struct uind1 {
+  int pter1;			/* pointer to uind1 */
+  int pter;			/* pinter to uind2 */
+  unsigned int yomi1;
+  unsigned int yomi2;
+};
+
+struct uind2 {
+  int next;			/* pointer to uind2 */
+  int serial;
+  int kanjipter;
+  w_char kosuu;
+  w_char yomi[1];		/* actually it is variable length */
+};
+
+/* MAXTABLE MAX... ha user file no ookisani kuwaete touroku no tame 
+   ni totteoku ookisa*/
+#define MAXTABLE 100		/* you can touroku MAXTABLE element without 
+				 realloc the jisho*/
+#define MAXHONTAI MAXTABLE * 4 * 4
+#define MAXKANJI MAXTABLE * 10
+#define MAXSERIAL MAXTABLE
+#define MAXBIND MAXTABLE * 4
+/* 
+ * structures concerning REV dicts.
+ */
+
+struct rind1 {
+  int pter1;			/* pointer to rind1 */
+  int pter;			/* pinter to rind2 */
+};
+
+struct rind2 {
+  int next[2];			/* pointer to rind2 */
+  int kanjipter;
+};
+
+/*
+ * Reverse Dict ni kansite, dotira wo hikuka?
+ */
+
+#define D_YOMI 0
+#define D_KANJI 1
+
+#define KANJI_str1(pter, which) (((which) == D_YOMI)?((w_char *)((pter) + 2)):\
+    ((w_char *)((pter) + 2) + Strlen((w_char *)((pter) + 2)) + 1))
+
+#define KANJI_str(p, which) ((*((p) + 1) & FORWARDED)? \
+    KANJI_str1(((*(w_char *)((p) + 2)) << 16 | (*(w_char *)((p) + 4))) \
+	       + (p),which): \
+    KANJI_str1((p), which))
+
+#define Get_kanji_len(pter, which) (Strlen(KANJI_str(pter, which)))
+
+/* 
+ * structures concerning SD dicts.
+ */
+
+#define ST_NORMAL 1
+#define ST_NOENT 2
+#define ST_NOPTER 3
+#define ST_SMALL 4
+#define ST_TABLE 5
+
+/*
+ *Concerning HINSI. But these may not be used.
+ */
+
+#define SAKUJO_HINSI 0xfffe /* sakujo sareta tango no hinsi */
+#define NANDEMO_EEYO 0xfffd /* nandemo maeni koreru to iu hinsi */
+
+/*
+ *Concerning KANJI and COMMENT.
+ */
+
+#define HAS_YOMI 1
+#define HAS_COMMENT 2
+#define FORWARDED 4
+
+/* #define SEPARATE_CHAR '\0'*/
+/* Choose character which do not appear as the first byte of w_char */
+
+#define DIC_YOMI_CHAR  1
+#define DIC_COMMENT_CHAR  2
+
+
+#define DIC_HIRAGANA "\\y"
+#define DIC_KATAKANA "\\k"
+
+/*#define	DIC_HANKAKU	"\\h"	*//* Ⱦ�� *//* �ɤߤΤޤ� */
+#define	DIC_ZENKAKU	"\\z"	/* ���� *//* ������ */
+#define	DIC_NUM_KAN	"\\chan"	/* ������ *//* ���� */
+#define	DIC_NUM_KANSUUJI "\\chas"	/* ������ *//* ɴ�󽽻� */
+#define	DIC_NUM_KANOLD	"\\chao"	/* ������ *//* ��ɴ������ */
+#define	DIC_NUM_HANCAN	"\\nhc"	/* Ⱦ�ѿ��� *//* 1,234 */
+#define	DIC_NUM_ZENCAN	"\\nzc"	/* ���ѿ��� *//* ���������� */
+#define DIC_HEX		"\\X"  /* \Xa4a2 */
+#define DIC_HEXc	"\\x"  /* \xa4a2 */
+#define DIC_OCT 	"\\0" /* \040   */
+#define DIC_ESC 	"\\\\" /* \\ = \  */
+
+#ifdef notuse
+/* �ѿ� */
+#define	WNN_ALP_HAN	-4	/* Ⱦ�� *//* �ɤߤΤޤ� */
+#define	WNN_ALP_ZEN	-30	/* ���� */
+/* ���� */
+#define	WNN_KIG_HAN	-5	/* Ⱦ�� *//* �ɤߤΤޤ� */
+#define	WNN_KIG_JIS	-40	/* ����(JIS) */
+#define	WNN_KIG_ASC	-41	/* ����(ASC) */
+#endif
+
+#ifdef	CONVERT_by_STROKE
+struct	b_node{
+	short	pter;			/* Point to Indix-2	*/
+	short	pter_son;		/* Ptr to first son	*/
+	short	pter_next;		/* Ptr to next brother	*/
+};
+
+struct	b_koho {
+	struct	b_koho	*previou;
+	int		value;
+	w_char		*p_yomi;
+	w_char		*p_kanji;
+	unsigned short	*p_hinsi;
+	UCHAR		*p_hindo;
+	int		serial;
+	int		dic_no;
+};
+#endif
diff --git a/wnn/jh.h b/wnn/jh.h
new file mode 100644
index 0000000000000000000000000000000000000000..95ae188384b9efcf35695803d5a1f6179e160813
--- /dev/null
+++ b/wnn/jh.h
@@ -0,0 +1,107 @@
+/*
+ * $Id: jh.h,v 1.1 1996/03/13 09:56:43 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/* 
+  header file for jisho structure program.
+*/
+
+/* The following defin and structure definition
+ * are concerned with ASCII (UJIS) files.
+ */
+
+#define COMMENT "\\comment"
+#define TOTAL "\\total"
+#define ASC_GIJI "\\giji"
+#define HINSI "\\hinsi"
+#ifdef CHINESE
+#define CHINSI "\\cixing"
+#define PINYIN "\\Pinyin"
+#define ZHUYIN "\\Zhuyin"
+#define BIXING "\\BiXing"
+#endif
+#define DIC_NO "\\dic_no"
+
+#define REV_NORMAL 2
+#define REVERSE 1
+#define NORMAL  0
+
+#ifndef	JS
+struct je {
+  w_char *yomi;
+  w_char *kan;			/* Historically kanji is used so use kan. */
+  w_char *comm;
+  UCHAR *kanji;
+  unsigned int hinsi;
+#ifdef	CONVERT_with_SiSheng
+  unsigned int ss;
+#endif
+  unsigned int hindo;
+  int serial;			/* Only used for rev_dic */
+};
+
+extern struct je **jeary;
+#endif	/* JS */
+
+extern w_char file_comment[];
+extern w_char hinsi_list[];
+
+/*
+ * Used in atod and others parameters.
+ */
+
+#define HEAP_PER_LINE 10	/* avelage of kanji + comment bytes */
+#define YOMI_PER_LINE 3		/* avelage of yomi length(in w_char)*/
+#define LINE_SIZE 1024
+#define BADLMAX 3		
+#define YOMI_KINDS (1 << 16)   /* Yomi characters Maximal */
+#define MAX_ENTRIES 70000	/* default of max-entries for atod */
+#define DEF_ENTRIES 10000
+
+#define HEAPINC 1000
diff --git a/wnn/jl-funs.lisp b/wnn/jl-funs.lisp
index d73471fb13160dbd755dbad5269a05bdfd8e9c96..5574a848742e05ac5d884354071e766d44506178 100644
--- a/wnn/jl-funs.lisp
+++ b/wnn/jl-funs.lisp
@@ -1,7 +1,7 @@
 ;; -*- mode: common-lisp; package: wnn -*-
 ;;
 ;;				-[Thu Nov 10 19:28:13 1994 by smh]-
-;; 
+;;
 ;; copyright (c) 1985, 1986 Franz Inc, Alameda, CA  All rights reserved.
 ;; copyright (c) 1986-1992 Franz Inc, Berkeley, CA  All rights reserved.
 ;;
@@ -20,7 +20,7 @@
 ;; 52.227-19 or DOD FAR Supplement 252.227-7013 (c) (1) (ii), as
 ;; applicable.
 ;;
-;; $fiHeader:$
+;; $fiHeader: jl-funs.lisp,v 1.1 1995/10/20 17:42:16 colin Exp $
 
 (in-package :wnn)
 
@@ -89,14 +89,14 @@
     :arg-checking nil)
 
 (defforeign 'jl_zenkouho
-    :arguments '(foreign-address 
+    :arguments '(foreign-address
 		 integer integer integer)
     :return-type :integer
     :call-direct t
     :arg-checking nil)
 
 (defforeign 'jl_zenkouho_dai
-    :arguments '(foreign-address 
+    :arguments '(foreign-address
 		 integer integer integer)
     :return-type :integer
     :call-direct t
diff --git a/wnn/jl.c b/wnn/jl.c
new file mode 100644
index 0000000000000000000000000000000000000000..23400c412992032ad320d9534f5f9ab696236f4f
--- /dev/null
+++ b/wnn/jl.c
@@ -0,0 +1,3245 @@
+/*
+ * $Id: jl.c,v 1.1 1996/03/13 09:56:47 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4
+ */
+/*
+	Nihongo Henkan Hi-level Library
+*/
+
+#include "commonhd.h"
+#include "config.h"
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef SYSVR2
+#   include <string.h>
+#endif
+#ifdef BSD42
+#   include <strings.h>
+#endif
+#include <sys/file.h>
+#include <ctype.h>
+#include <pwd.h>
+
+#include "wnnerror.h"
+#include "jd_sock.h"
+#include "jslib.h"
+#include "jllib.h"
+
+#include "msg.h"
+#include "wnn_string.h"
+extern struct msg_cat *wnn_msg_cat;
+
+
+#define MAXENVS 32
+
+#define MAXINCLUDE 10
+
+#define DEFAULT_BUN_LEN 3
+
+#define DEFAULT_ZENKOUHO_LEN 3
+
+#define DEFAULT_HEAP_LEN 3
+
+#define INCREMENT 2
+
+#define SHO 0
+#define DAI 1
+
+#define BUN 0
+#define ZENKOUHO 1   /* Must not change!, they are assigned to two bit flag */
+#define ZENKOUHO_DAI 3 /* DAI << 1 | ZENKOUHO */
+
+#define	if_dead_disconnect(env, ret) \
+{ \
+	if (wnn_errorno == WNN_JSERVER_DEAD) { \
+		jl_disconnect_if_server_dead(env);\
+		return(ret); \
+	} else { \
+		return(ret); \
+	} \
+}
+
+#define	if_dead_disconnect_b(buf, ret) \
+{ \
+	if (wnn_errorno == WNN_JSERVER_DEAD) { \
+		jl_disconnect_if_server_dead(buf->env);\
+		buf->env = 0; \
+		return(ret); \
+	} else { \
+		return(ret); \
+	} \
+}
+
+static struct wnn_ret_buf rb = {0, NULL};
+static struct wnn_ret_buf dicrb = {0, NULL};
+static struct wnn_ret_buf wordrb = {0, NULL};
+
+static int dumbhinsi;
+static w_char *mae_fzk;
+static int syuutanv;
+static int syuutanv1;
+
+#define CONFIRM  1
+#define CONFIRM1 2
+#define CREATE_WITHOUT_CONFIRM  3
+#define NO_CREATE 4
+
+int confirm_state;
+
+static void add_down_bnst();
+static int alloc_heap();
+static int call_error_handler();
+static int change_ascii_to_int();
+static int create_file();
+static int dai_end();
+static int expand_expr();
+static int expand_expr_all();
+static int file_discard();
+static int file_exist();
+static int file_read();
+static int file_remove();
+static int find_same_kouho();
+static int find_same_kouho_dai();
+static void free_bun();
+static void free_down();
+static void free_sho();
+static void free_zenkouho();
+static int get_c_jikouho();
+static int get_c_jikouho_dai();
+static int get_c_jikouho_from_zenkouho();
+static int get_c_jikouho_from_zenkouho_dai();
+static int get_pwd();
+static int insert_dai();
+static int insert_sho();
+static int make_dir1();
+static int make_dir_rec1();
+static void make_space_for();
+static void make_space_for_bun();
+static void make_space_for_zenkouho();
+static void message_out();
+static int ren_conv1();
+static void set_dai();
+static void set_sho();
+static int tan_conv1();
+
+/*
+ * Sub-routines to handle files, enviroments and connections.
+ */
+
+struct wnn_file_name_id {
+    struct wnn_file_name_id *next;
+    int id;
+    char name[1];
+};
+
+struct wnn_jl_env{
+    WNN_JSERVER_ID *js;
+    struct wnn_env *env;
+    char env_n[WNN_ENVNAME_LEN];
+    char server_n[WNN_HOSTLEN];
+    char lang[32];
+    int ref_cnt;
+    struct wnn_file_name_id *file;
+} envs[MAXENVS];
+
+/* 
+ * File management routines.
+ */
+
+static 
+struct wnn_jl_env *find_jl_env(env)
+register struct wnn_env *env;
+{
+    register int k;
+    for(k = 0 ; k < MAXENVS; k++){
+	if(envs[k].env == env) return(envs + k);
+    }
+    return(NULL);
+}
+
+
+static
+struct wnn_env *
+find_env_of_same_js_id(js_id)
+register WNN_JSERVER_ID *js_id;
+{
+    register int k;
+
+    for(k = 0 ; k < MAXENVS; k++){
+	if (envs[k].js == js_id){
+	    return(envs[k].env);
+	}
+    }
+    return(NULL);
+}
+
+static
+WNN_JSERVER_ID *
+find_same_server(server_n, lang)
+register char *server_n, *lang;
+{
+    register int k;
+
+    if (server_n == NULL || lang == NULL) return(NULL);
+    for(k = 0 ; k < MAXENVS; k++){
+	if(strncmp(envs[k].server_n, server_n, WNN_HOSTLEN - 1) == 0 &&
+	   strcmp(envs[k].lang, lang) == 0){
+	    return(envs[k].js);
+	}
+    }
+    return(NULL);
+}
+
+static int
+find_same_server_from_id(js)
+register WNN_JSERVER_ID *js;
+{
+    register int k;
+    for(k = 0 ; k < MAXENVS; k++){
+	if(envs[k].js == js) return(1);
+    }
+    return(0);
+}
+
+#ifdef nodef
+static
+delete_server_from_id(js)
+WNN_JSERVER_ID *js;
+{
+    int k;
+    for(k = 0 ; k < MAXENVS; k++){
+	if(envs[k].js == js) {
+		envs[k].js = 0;
+		strcpy(envs[k].server_n, "");
+		break;
+	}
+    }
+}
+#endif
+
+
+static
+struct wnn_env *
+find_same_env(js, env_n, lang)
+register WNN_JSERVER_ID *js;
+register char *env_n;
+char *lang;
+{
+    register int k;
+
+    if (env_n == NULL || lang == NULL) return(NULL);
+    for(k = 0 ; k < MAXENVS; k++){
+	if(envs[k].js == js && strcmp(envs[k].env_n, env_n) == 0
+			    && strcmp(envs[k].lang, lang) == 0){
+	    envs[k].ref_cnt++;
+	    return(envs[k].env);
+	}
+    }
+    return(NULL);
+}
+
+static char *
+env_name(env)
+register struct wnn_env *env;
+{
+    register int k;
+
+    for(k = 0 ; k < MAXENVS; k++){
+	if(envs[k].env == env){
+	    return(envs[k].env_n);
+	}
+    }
+    return(NULL);
+}
+
+
+static void
+add_new_env(js, env, env_n, server_n, lang)
+register WNN_JSERVER_ID *js;
+register struct wnn_env *env;
+char *env_n, *server_n, *lang;
+{
+    register int k;
+
+    for(k = 0 ; k < MAXENVS; k++){
+	if(envs[k].ref_cnt == 0){
+	    strncpy(envs[k].server_n, server_n, WNN_HOSTLEN - 1);
+	    envs[k].server_n[WNN_HOSTLEN - 1] = '\0';
+	    strcpy(envs[k].env_n, env_n);
+	    strcpy(envs[k].lang, lang);
+	    envs[k].js = js;
+	    envs[k].env = env;
+	    envs[k].ref_cnt = 1;
+	    envs[k].file = NULL;
+	    break;
+	}
+    }
+}
+
+static int
+delete_env(env)
+register struct wnn_env *env;
+{
+    register int k;
+
+    for(k = 0 ; k < MAXENVS; k++){
+	if(envs[k].env == env){
+	    if(--envs[k].ref_cnt == 0){
+		strcpy(envs[k].server_n, "");
+		strcpy(envs[k].env_n, "");
+		strcpy(envs[k].lang, "");
+		envs[k].js = NULL;
+		envs[k].env = NULL;
+		return(1);	/* Need To delete env */
+	    }else{
+		return(0);	/* Need not to delete env */
+	    }
+	}
+    }
+    return(-1);			/* This must not happen */
+}
+
+
+/* Routines to manipulate files */
+
+static int
+add_file_to_env(env, id, name)
+struct wnn_env *env;
+int id;
+register char *name;
+{
+    register struct wnn_file_name_id *f, *f1;
+    if((f = (struct wnn_file_name_id *)malloc(sizeof(struct wnn_file_name_id) +
+					     strlen(name) + 1)) == NULL){
+	wnn_errorno=WNN_ALLOC_FAIL;	return(-1);
+    }
+    strcpy(f->name, name);
+    f->id = id;
+    f1 = find_jl_env(env)->file;
+    f->next = f1;
+    find_jl_env(env)->file = f;
+    return(0);
+}
+    
+static char *
+find_file_name_from_id(env, id)
+struct wnn_env *env;
+register int id;
+{
+    register struct wnn_file_name_id *f;
+    f = find_jl_env(env)->file;
+    for(;f; f = f->next){
+	if(f->id == id){
+	    return(f->name);
+	}
+    }
+/*    wnn_errorno=WNN_FILE_NOT_READ_FROM_CLIENT; */
+    return(NULL);
+}
+
+static int
+delete_file_from_env(env, id)
+struct wnn_env *env;
+register int id;
+{
+    struct wnn_file_name_id *f;
+    register struct wnn_file_name_id **prev;
+    register struct wnn_jl_env *jl_env_p;
+
+    jl_env_p = find_jl_env(env);
+    if (!jl_env_p->file) return(0);
+    for(prev = &jl_env_p->file; f = *prev; prev = &f->next){
+	if (f->id == id) {
+	    *prev = f->next;
+	    free(f);
+	    return(0);
+	}
+    }
+    wnn_errorno=WNN_FILE_NOT_READ_FROM_CLIENT;
+    return(-1);
+}
+
+/*
+ * Libraries which handle Connection To Jserver
+ */
+
+struct wnn_env *
+jl_connect_lang(env_n, server_n, lang, wnnrc_n, error_handler, message_handler, timeout)
+register char *env_n, *server_n, *wnnrc_n, *lang;
+int  (*error_handler)(), (*message_handler)();
+int timeout;
+{
+    register WNN_JSERVER_ID	*js = NULL;
+    struct wnn_env *env;
+    int env_exist;
+    char p_lang[16];
+    register char *p, *l;
+    extern char *getenv();
+    extern char *_wnn_get_machine_of_serv_defs();
+
+    wnn_errorno = 0;
+    /* if lang not specified use $LANG */
+    if(!lang || !*lang){
+	lang = getenv("LANG");
+    }
+    if (!lang || !*lang){
+/* Sorry! Default is Japanese. :-) */
+	strcpy(p_lang, "ja_JP");
+    } else {
+	/* Use only [language]_[teritorry] */
+	for(p = p_lang, l = lang; *l != '@' && *l != '.' && *l != 0; p++, l++)
+	    *p = *l;
+	*p = 0;
+    }
+
+   /* To See serverdefs file when server_n is not specified. */
+    if(!server_n || !*server_n){
+	/* find server machine name from table by lang */
+	if (server_n = _wnn_get_machine_of_serv_defs(p_lang)) {
+	    if((js = find_same_server(server_n, p_lang)) == NULL){
+		if((js = js_open_lang(server_n, p_lang, timeout)) == NULL){
+		    server_n = NULL;
+		}
+	    }
+	}
+	if (!server_n || !*server_n) {
+	    server_n = "unix";
+	}
+    }
+
+    if (js == NULL) {
+	if((js = find_same_server(server_n, p_lang)) == NULL){
+	    if((js = js_open_lang(server_n, p_lang, timeout)) == NULL){
+		return(NULL);
+	    }
+    /*	js_hinsi_list(js); */
+	}
+    }
+    if ((env_exist = js_env_exist(js, env_n)) < 0)
+	return (NULL);
+    if((env = find_same_env(js, env_n, p_lang)) == NULL){ /* Incr ref_cnt */
+	if((env = js_connect_lang(js, env_n, p_lang)) == NULL){
+	    return(NULL);
+	}
+	add_new_env(js, env, env_n, server_n, p_lang);
+    }
+    if(env_exist == 0 && wnnrc_n){
+	jl_set_env_wnnrc(env, wnnrc_n, error_handler, message_handler);
+    }
+    return(env);
+}
+
+void
+jl_disconnect(env)
+register struct wnn_env *env;
+{
+    int ret;
+    wnn_errorno = 0;
+    if((ret = delete_env(env)) < 0){
+	return;
+    } else if (ret) {
+	js_disconnect(env);
+    }
+    if(!find_same_server_from_id(env->js_id)){
+	js_close(env->js_id);
+	env->js_id = 0;
+    }
+}
+
+int
+jl_isconnect_e(env)
+register struct wnn_env *env;
+{
+    if (js_isconnect(env) == 0)
+	return(1);
+    else
+	return (0);
+}
+
+/* JSERVER �������� env �� disconnect ���Ʋ�� */
+void
+jl_disconnect_if_server_dead(env)
+register struct wnn_env *env;
+{
+    register struct wnn_env *same_env;
+    int ret;
+
+    if((ret = delete_env(env)) < 0){
+	return;
+    } else if (ret) {
+	js_disconnect(env);
+    }
+    while ((same_env = find_env_of_same_js_id(env->js_id)) != 0) {
+	if(delete_env(same_env)){
+	    js_disconnect(same_env);
+	}
+	
+    }
+    js_close(env->js_id);
+    env->js_id = 0;
+}
+
+
+struct wnn_buf *
+jl_open_lang(env_n, server_n, lang, wnnrc_n, error_handler, message_handler, timeout)
+char *env_n, *server_n, *wnnrc_n, *lang;
+int  (*error_handler)(), (*message_handler)();
+int timeout;
+{
+    register int k, dmy;
+    register struct wnn_buf *buf;
+    struct wnn_env *env;
+
+    wnn_errorno = 0;
+    if(rb.size == 0) rb.buf = (char *)malloc((unsigned)(rb.size = 1024));
+
+#define ALLOC_SET(pter, type, size, size_var) \
+    ((pter) = ((type *)malloc((unsigned)(sizeof(type) * ((size_var) = (size))))))
+
+    if(!ALLOC_SET(buf, struct wnn_buf, 1, dmy)){
+	wnn_errorno=WNN_ALLOC_FAIL;return NULL;
+    }
+
+    buf->bun_suu = 0;
+    buf->zenkouho_suu = 0;
+    buf->zenkouho_daip = 0;
+    buf->c_zenkouho = -1;
+    buf->zenkouho_bun = -1;
+    buf->zenkouho_end_bun = -1;
+    buf->free_heap = NULL;
+    buf->heap = NULL;
+    buf->zenkouho_dai_suu = 0;
+    
+    if(!ALLOC_SET(buf->bun, WNN_BUN *, DEFAULT_BUN_LEN, buf->msize_bun) ||
+       !ALLOC_SET(buf->zenkouho_dai, int, DEFAULT_ZENKOUHO_LEN + 1, buf->msize_zenkouho) ||
+       !ALLOC_SET(buf->zenkouho, WNN_BUN *, DEFAULT_ZENKOUHO_LEN, buf->msize_zenkouho) ||
+       !ALLOC_SET(buf->down_bnst, WNN_BUN *, DEFAULT_BUN_LEN, buf->msize_bun)
+       ){
+	wnn_errorno=WNN_ALLOC_FAIL;return NULL;
+    }
+       
+    for(k = 0 ; k < DEFAULT_BUN_LEN ; k++){
+	buf->down_bnst[k] = NULL;
+    }
+
+    if(alloc_heap(buf, DEFAULT_HEAP_LEN) == -1){
+	return NULL;
+    }
+
+    env = jl_connect_lang(env_n, server_n, lang, wnnrc_n,
+			error_handler, message_handler, timeout);
+    buf->env = env;
+    return(buf);
+}
+    
+
+static int
+alloc_heap(buf, len)
+struct wnn_buf *buf;
+register int len;
+{
+    char **c;
+    register WNN_BUN *d;
+
+    if((c =(char **)malloc((unsigned)(len * sizeof(WNN_BUN) + sizeof(char *)))) == NULL){
+	wnn_errorno=WNN_ALLOC_FAIL;	return(-1);
+    }
+
+    *c = buf->heap;
+    buf->heap = (char *)c;
+    d = (WNN_BUN *)(c + 1);
+    for(--len; len > 0 ; len--, d++){
+	d->free_next = d + 1;
+    }
+    d->free_next = buf->free_heap;
+    buf->free_heap = (WNN_BUN *)(c + 1);
+    return(0);
+}
+
+void
+jl_close(buf)
+register struct wnn_buf *buf;
+{
+    register char *c, *next;
+    
+    wnn_errorno = 0;
+    if(buf == NULL) return;
+
+    if(buf->env){
+	jl_disconnect(buf->env);
+	buf->env = 0;
+    }
+
+    if(buf->bun) free((char *)buf->bun);
+    if(buf->zenkouho) free((char *)buf->zenkouho);
+    if(buf->zenkouho_dai) free((char *)buf->zenkouho_dai);
+    if(buf->down_bnst) free((char *)buf->down_bnst);
+    for(c = buf->heap; c; c = next) {
+	next = *(char **)c;
+	free(c);
+    }
+    free((char *)buf);
+}
+
+/*
+ * Conversion Libraries 
+ */
+
+int
+jl_ren_conv(buf, yomi, bun_no, bun_no2, use_maep)
+register struct wnn_buf *buf;
+register w_char *yomi;
+int bun_no, bun_no2;
+int use_maep;
+{
+    wnn_errorno = 0;
+    if(bun_no < 0) return(-1);
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0) bun_no2 = buf->bun_suu;
+    free_down(buf, bun_no, bun_no2);
+    return(ren_conv1(buf, yomi, bun_no, bun_no2, use_maep));
+}
+
+static int
+ren_conv1(buf, yomi, bun_no, bun_no2, use_maep)
+register struct wnn_buf *buf;
+w_char *yomi;
+register int bun_no, bun_no2;
+int use_maep;
+{
+    int dcnt;
+    struct wnn_dai_bunsetsu *dp;
+    int size;
+    w_char yomi1[LENGTHBUNSETSU];
+
+
+    if (yomi == NULL || *yomi == (w_char)0) return(0);
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0) bun_no2 = buf->bun_suu;
+
+    if (use_maep & WNN_USE_MAE && bun_no > 0) {
+	dumbhinsi = buf->bun[bun_no - 1]->hinsi;
+	jl_get_yomi(buf, bun_no - 1, bun_no, yomi1);
+	mae_fzk = yomi1 + buf->bun[bun_no - 1]->jirilen;
+    } else {
+	dumbhinsi = WNN_BUN_SENTOU;
+	mae_fzk = (w_char *)0;
+    }
+    if(use_maep & WNN_USE_ATO && bun_no2 < buf->bun_suu){
+	syuutanv = buf->bun[bun_no2]->kangovect;
+	syuutanv1 = WNN_VECT_KANREN;
+    }else{
+	syuutanv = WNN_VECT_KANREN;
+	syuutanv1 = WNN_VECT_NO;
+	if(bun_no2 < buf->bun_suu){
+	    buf->bun[bun_no2]->dai_top = 1;
+	}
+    }
+    if((dcnt = js_kanren(buf->env, yomi, dumbhinsi, mae_fzk,
+			 syuutanv, syuutanv1, WNN_VECT_BUNSETSU, &rb)) < 0){
+	if_dead_disconnect_b(buf, -1);
+    }
+
+    dp = (struct wnn_dai_bunsetsu *)rb.buf;
+
+    free_bun(buf, bun_no, bun_no2);
+
+    if(use_maep & WNN_USE_ATO && bun_no2 < buf->bun_suu){
+	buf->bun[bun_no2]->dai_top =
+	    (dp[dcnt-1].sbn[dp[dcnt-1].sbncnt-1].status_bkwd == WNN_CONNECT_BK)? 0:1;
+    }
+
+    size = insert_dai(buf, BUN, bun_no, bun_no2, dp, dcnt, 0);
+    if(buf->zenkouho_end_bun > bun_no && buf->zenkouho_bun < bun_no2){
+	free_zenkouho(buf);
+    }else if(buf->zenkouho_bun >= bun_no2){
+	buf->zenkouho_bun += size - bun_no2;
+	buf->zenkouho_end_bun += size - bun_no2;
+
+    }	
+    return(buf->bun_suu);
+}
+
+int
+jl_tan_conv(buf, yomi, bun_no, bun_no2, use_maep, ich_shop)
+register struct wnn_buf *buf;
+w_char *yomi;
+register int bun_no, bun_no2;
+int use_maep, ich_shop;
+{
+    wnn_errorno = 0;
+    if(bun_no < 0) return(-1);
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0) bun_no2 = buf->bun_suu;
+    free_down(buf, bun_no, bun_no2);
+    if(tan_conv1(buf, yomi, bun_no, bun_no2, use_maep, ich_shop) == -1)
+	return(-1);
+    return(buf->bun_suu);
+}
+
+static int
+tan_conv1(buf, yomi, bun_no, bun_no2, use_maep, ich_shop)
+register struct wnn_buf *buf;
+w_char *yomi;
+register int bun_no, bun_no2;
+int use_maep, ich_shop;
+{
+    int dcnt;
+    struct wnn_dai_bunsetsu *dp;
+    struct wnn_sho_bunsetsu *sp;
+    int ret;
+    w_char yomi1[LENGTHBUNSETSU];
+
+    if (yomi == NULL || *yomi == (w_char)0) return(0);
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0) bun_no2 = buf->bun_suu;
+
+    if (use_maep & WNN_USE_MAE && bun_no > 0) {
+	dumbhinsi = buf->bun[bun_no - 1]->hinsi;
+	jl_get_yomi(buf, bun_no - 1, bun_no, yomi1);
+	mae_fzk = yomi1 + buf->bun[bun_no - 1]->jirilen;
+    } else {
+	dumbhinsi = WNN_BUN_SENTOU;
+	mae_fzk = (w_char *)0;
+    }
+    if(use_maep & WNN_USE_ATO && bun_no2 < buf->bun_suu){
+	syuutanv = buf->bun[bun_no2]->kangovect;
+	syuutanv1 = WNN_VECT_KANTAN;
+    }else{
+	syuutanv = WNN_VECT_KANTAN;
+	syuutanv1 = WNN_VECT_NO;
+	if(bun_no2 < buf->bun_suu){
+	    buf->bun[bun_no2]->dai_top = 1;
+	}
+    }
+    if(ich_shop == WNN_SHO){
+	if((dcnt = js_kantan_sho(buf->env, yomi, dumbhinsi, mae_fzk,
+				 syuutanv, syuutanv1, &rb)) < 0){
+	    if_dead_disconnect_b(buf, -1);
+	}
+	sp = (struct wnn_sho_bunsetsu *)rb.buf;
+	if(use_maep & WNN_USE_ATO && bun_no2 < buf->bun_suu){
+	    buf->bun[bun_no2]->dai_top =
+		(sp[dcnt-1].status_bkwd == WNN_CONNECT_BK)? 0:1;
+	}
+	free_bun(buf, bun_no, bun_no2);
+	ret = insert_sho(buf, BUN, bun_no, bun_no2, sp, dcnt, 0);
+    }else{
+	if((dcnt = js_kantan_dai(buf->env, yomi,  dumbhinsi, mae_fzk,
+				 syuutanv, syuutanv1, &rb)) < 0){
+	    if_dead_disconnect_b(buf, -1);
+	}
+	dp = (struct wnn_dai_bunsetsu *)rb.buf;
+	if(use_maep & WNN_USE_ATO && bun_no2 < buf->bun_suu){
+	    buf->bun[bun_no2]->dai_top =
+		(dp[dcnt-1].sbn[dp[dcnt-1].sbncnt-1].status_bkwd == WNN_CONNECT_BK)? 0:1;
+	}
+	free_bun(buf, bun_no, bun_no2);
+	ret = insert_dai(buf, BUN, bun_no, bun_no2, dp, dcnt, 0);
+    }
+    if(buf->zenkouho_end_bun > bun_no && buf->zenkouho_bun < bun_no2){
+	free_zenkouho(buf);
+    }else if(buf->zenkouho_bun >= bun_no2){
+	buf->zenkouho_bun += ret - bun_no2;
+	buf->zenkouho_end_bun += ret - bun_no2;
+    }	
+    return(ret);
+}
+
+int
+jl_nobi_conv(buf, bun_no, ichbn_len, bun_no2, use_maep, ich_shop)
+register struct wnn_buf *buf;
+int ichbn_len, use_maep, ich_shop;
+register int bun_no, bun_no2;
+{
+    w_char yomi[LENGTHCONV], ytmp;
+    int ret;
+    int len1;
+
+    register WNN_BUN *b1;	/* �ؽ������ޤ������褦���ѹ����ޤ�����H.T. */
+
+    wnn_errorno = 0;
+    if(bun_no < 0) return(-1);
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0) bun_no2 = buf->bun_suu;
+    
+    len1 = jl_get_yomi(buf, bun_no, bun_no2, yomi);
+    ytmp = yomi[ichbn_len];
+    if(len1 < ichbn_len){
+	ichbn_len = len1;
+    }
+    yomi[ichbn_len] = 0;
+
+    if(buf->bun[bun_no]->nobi_top != 1){  /* need to add down_bnst */
+	if(buf->bun[bun_no]) add_down_bnst(buf, bun_no, buf->bun[bun_no]);
+	if(bun_no + 1 < buf->bun_suu){
+	    add_down_bnst(buf, bun_no, buf->bun[bun_no + 1]);
+			/* ���� bun_no �� down_bnst �˲ä���褦���ѹ� */
+	}
+    }
+    b1 = buf->down_bnst[bun_no];
+    buf->down_bnst[bun_no] = NULL;
+    free_down(buf, bun_no, bun_no2);
+
+    if((ret = tan_conv1(buf, yomi, bun_no, bun_no2, use_maep & WNN_USE_MAE, ich_shop)) == -1){
+	return(-1);
+    }
+    yomi[ichbn_len] = ytmp;    
+    if(ytmp){
+	int maep;
+	if(ich_shop){
+	    maep = use_maep & ~WNN_USE_MAE;
+	}else{
+	    maep = use_maep | WNN_USE_MAE;
+	}
+	if(ren_conv1(buf, yomi + ichbn_len, ret, ret, maep) == -1){
+	    return(-1);
+	}
+    }
+    buf->bun[bun_no]->nobi_top = 1;
+    buf->down_bnst[bun_no] = b1;
+
+    return(buf->bun_suu);
+}
+
+int
+jl_nobi_conv_e2(buf, env, bun_no, ichbn_len, bun_no2, use_maep, ich_shop)
+register struct wnn_buf *buf;
+struct wnn_env *env;
+int ichbn_len, use_maep, ich_shop;
+register int bun_no, bun_no2;
+{
+    w_char yomi[LENGTHCONV], ytmp;
+    int ret;
+    int len1;
+
+    wnn_errorno = 0;
+    if(bun_no < 0) return(-1);
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0) bun_no2 = buf->bun_suu;
+    
+    len1 = jl_get_yomi(buf, bun_no, bun_no2, yomi);
+    ytmp = yomi[ichbn_len];
+    if(len1 < ichbn_len){
+	ichbn_len = len1;
+    }
+    yomi[ichbn_len] = 0;
+
+    if(buf->bun[bun_no]->nobi_top != 1){  /* need to add down_bnst */
+	if(buf->bun[bun_no]) add_down_bnst(buf, bun_no, buf->bun[bun_no]);
+	if(bun_no + 1 < buf->bun_suu){
+	    if(ichbn_len < jl_yomi_len(buf, bun_no, bun_no + 1)){
+		add_down_bnst(buf, bun_no + 1, buf->bun[bun_no + 1]);
+		free_down(buf, bun_no + 2, bun_no2);
+	    }else{
+		add_down_bnst(buf, bun_no, buf->bun[bun_no + 1]);
+		free_down(buf, bun_no + 1, bun_no2);
+	    }
+	}
+    }
+
+    if((ret = tan_conv1(buf, yomi, bun_no, bun_no2, use_maep & WNN_USE_MAE, ich_shop)) == -1){
+	return(-1);
+    }
+
+    buf->env = env;
+
+    yomi[ichbn_len] = ytmp;    
+    if(ytmp){
+	int maep;
+	if(ich_shop){
+	    maep = use_maep & ~WNN_USE_MAE;
+	}else{
+	    maep = use_maep | WNN_USE_MAE;
+	}
+	if(ren_conv1(buf, yomi + ichbn_len, ret, ret, maep) == -1){
+	    return(-1);
+	}
+    }
+    buf->bun[bun_no]->nobi_top = 1;
+
+    return(buf->bun_suu);
+}
+
+int
+jl_kill(buf, bun_no, bun_no2)
+struct wnn_buf *buf;
+register int bun_no, bun_no2;
+{
+    wnn_errorno = 0;
+    if(bun_no < 0) return(0);
+    if(bun_no2 < bun_no || bun_no2 < 0) bun_no2 = buf->bun_suu;
+    free_zenkouho(buf);     /* toriaezu */
+    free_down(buf, bun_no, bun_no2);
+    free_bun(buf, bun_no, bun_no2);
+    bcopy((char *)&buf->bun[bun_no2], (char *)&buf->bun[bun_no],
+	 (buf->bun_suu - bun_no2) * sizeof(WNN_BUN *));
+    bcopy((char *)&buf->down_bnst[bun_no2], (char *)&buf->down_bnst[bun_no],
+	 (buf->bun_suu - bun_no2) * sizeof(WNN_BUN *));
+    buf->bun_suu -= bun_no2 - bun_no;
+    return(buf->bun_suu);
+}
+
+int
+jl_zenkouho(buf, bun_no, use_maep, uniq_level)
+register struct wnn_buf *buf;
+int bun_no, use_maep, uniq_level;
+{
+    int cnt;
+    w_char yomi[LENGTHBUNSETSU], yomi1[LENGTHBUNSETSU];
+    struct wnn_sho_bunsetsu *sp;
+    register int k;
+
+    wnn_errorno = 0;
+    jl_get_yomi(buf, bun_no, bun_no + 1, yomi);
+
+    if(bun_no == buf->zenkouho_bun &&
+       buf->zenkouho_daip == SHO) return(buf->c_zenkouho);
+    if (use_maep & WNN_USE_MAE && bun_no > 0) {
+	dumbhinsi = buf->bun[bun_no - 1]->hinsi;
+	jl_get_yomi(buf, bun_no - 1, bun_no, yomi1);
+	mae_fzk = yomi1 + buf->bun[bun_no - 1]->jirilen;
+    } else {
+	dumbhinsi = WNN_BUN_SENTOU;
+	mae_fzk = (w_char *)0;
+    }
+    if(use_maep & WNN_USE_ATO && bun_no + 1 < buf->bun_suu){
+
+	syuutanv = buf->bun[bun_no+1]->kangovect;
+	syuutanv1 = WNN_VECT_KANZEN;
+	buf->zenkouho_endvect = syuutanv;
+    }else{
+	syuutanv = WNN_VECT_KANZEN;
+	syuutanv1 = WNN_VECT_NO;
+	if(bun_no + 1 < buf->bun_suu){
+	    buf->bun[bun_no + 1]->dai_top = 1;
+	}
+	buf->zenkouho_endvect = -1;
+    }
+    if((cnt = js_kanzen_sho(buf->env, yomi, dumbhinsi, mae_fzk,
+			    syuutanv, syuutanv1, &rb)) < 0){
+	    if_dead_disconnect_b(buf, -1);
+    }
+
+    sp = (struct wnn_sho_bunsetsu *)rb.buf;
+    free_zenkouho(buf);
+    if((buf->bun[bun_no]->from_zenkouho & 1) == BUN){
+	set_sho(buf->bun[bun_no], &buf->zenkouho[0]);
+	buf->zenkouho_suu = 1;
+				/* Connection information of Old bunsetsu
+				 * May not be correct.
+				 */
+	k = get_c_jikouho(sp, cnt, buf->bun[bun_no]);
+	if(k >= 0){
+	    buf->zenkouho[0]->dai_top = (sp[k].status == WNN_CONNECT)? 0:1;
+	    buf->zenkouho[0]->dai_end = (sp[k].status_bkwd == WNN_CONNECT_BK)? 0:1;
+	}
+	if(uniq_level || k < 0){
+	    insert_sho(buf, ZENKOUHO, -1, -1, sp, cnt, uniq_level);
+	}else{
+	    insert_sho(buf, ZENKOUHO, -1, -1, sp, k, uniq_level);
+	    insert_sho(buf, ZENKOUHO, -1, -1, sp + k + 1, cnt - k - 1, uniq_level);
+	}
+	buf->c_zenkouho = 0;
+    }else{
+	insert_sho(buf, ZENKOUHO, -1, -1, sp, cnt, uniq_level);
+	k = get_c_jikouho_from_zenkouho(buf, buf->bun[bun_no]);
+	if(k < 0){
+	    k = 0;	/* Only when the kouho has been removed from dict. */
+	}
+	buf->c_zenkouho = k;
+    }
+    buf->zenkouho_bun = bun_no;
+    buf->zenkouho_end_bun = bun_no + 1;
+    buf->zenkouho_daip = SHO;
+    for(k = 0 ; k < buf->zenkouho_suu; k++){
+	if(buf->zenkouho[k]->ima && buf->zenkouho[k]->dic_no != -1){
+	    add_down_bnst(buf, bun_no, buf->zenkouho[k]);
+	}
+    }
+    return(buf->c_zenkouho);
+}
+
+int
+jl_zenkouho_dai(buf, bun_no, bun_no2, use_maep, uniq_level)
+register struct wnn_buf *buf;
+int bun_no, bun_no2, use_maep, uniq_level;
+{
+    int cnt;
+    w_char yomi[LENGTHBUNSETSU], yomi1[LENGTHBUNSETSU];
+    struct wnn_dai_bunsetsu *dp;
+    int tmp;
+    register int k;
+
+    wnn_errorno = 0;
+    if(bun_no2 > (tmp = dai_end(buf, bun_no)) ||
+	bun_no2 < 0) bun_no2 = tmp;
+    jl_get_yomi(buf,bun_no, bun_no2, yomi);
+
+    if(bun_no == buf->zenkouho_bun && buf->zenkouho_daip == DAI){
+	return(buf->c_zenkouho);
+    }
+    if (use_maep & WNN_USE_MAE && bun_no > 0) {
+	dumbhinsi = buf->bun[bun_no - 1]->hinsi;
+	jl_get_yomi(buf, bun_no - 1, bun_no, yomi1);
+	mae_fzk = yomi1 + buf->bun[bun_no - 1]->jirilen;
+    } else {
+	dumbhinsi = WNN_BUN_SENTOU;
+	mae_fzk = (w_char *)0;
+    }
+    if(use_maep & WNN_USE_ATO && bun_no2 < buf->bun_suu){
+	syuutanv = buf->bun[bun_no2]->kangovect;
+	syuutanv1 = WNN_VECT_KANZEN; 
+	buf->zenkouho_endvect = syuutanv;
+    }else{
+	syuutanv = WNN_VECT_KANZEN;
+	syuutanv1 = WNN_VECT_NO;
+	if(bun_no2 < buf->bun_suu){
+	    buf->bun[bun_no2]->dai_top = 1;
+	}
+	buf->zenkouho_endvect = -1;
+    }
+    if((cnt = js_kanzen_dai(buf->env, yomi, dumbhinsi, mae_fzk,
+			    syuutanv, syuutanv1, &rb)) < 0){
+	if_dead_disconnect_b(buf, -1);
+    }
+    dp = (struct wnn_dai_bunsetsu *)rb.buf;
+
+    free_zenkouho(buf);
+		/* Wander if it is OK, that is, only when all the
+		 * zenkouho's are got from zenkouho_dai, we need not move
+		 * the current dai-bunsetsu to the top of zenkouho's
+		 */
+    for(k = bun_no; k < bun_no2; k++){
+	if(buf->bun[k]->from_zenkouho != ZENKOUHO_DAI)break;
+    }
+    if(k != bun_no2){		/* move the current to the top. */
+	make_space_for(buf, ZENKOUHO, buf->zenkouho_suu, buf->zenkouho_suu, bun_no2 - bun_no);
+	set_dai(&buf->bun[bun_no], &buf->zenkouho[0], bun_no2 - bun_no);
+	buf->zenkouho_dai[0] = 0;
+	buf->zenkouho_dai[1] = bun_no2 - bun_no;
+	buf->zenkouho_dai_suu = 1;
+	buf->zenkouho_suu = bun_no2 - bun_no;
+	k = get_c_jikouho_dai(dp, cnt, buf->bun, bun_no);
+	if(k >= 0){
+	    buf->zenkouho[0]->dai_top = 
+		(dp[k].sbn->status == WNN_CONNECT)? 0:1;
+	    buf->zenkouho[bun_no2-bun_no-1]->dai_end = 
+		(dp[k].sbn[dp[k].sbncnt-1].status_bkwd == WNN_CONNECT_BK)? 0:1;
+	    /* KURI *//* USO*?*/
+	}
+	if(uniq_level || k < 0){
+	    insert_dai(buf, ZENKOUHO, -1, -1, dp, cnt, uniq_level);
+	}else{
+	    insert_dai(buf, ZENKOUHO, -1, -1, dp, k, uniq_level);
+	    insert_dai(buf, ZENKOUHO, -1, -1, dp + k + 1, cnt - k - 1, uniq_level);
+	}
+	buf->c_zenkouho = 0;
+    }else{
+	insert_dai(buf, ZENKOUHO, -1, -1, dp, cnt, uniq_level);
+	k = get_c_jikouho_from_zenkouho_dai(buf, buf->bun[bun_no]);
+	if(k < 0){
+	    k = 0;	/* Only when the kouho has been removed from dict. */
+	}
+	buf->c_zenkouho = k;
+    }
+    buf->zenkouho_bun = bun_no;
+    buf->zenkouho_end_bun = bun_no2;
+    buf->zenkouho_daip = DAI;
+    for(k = 0 ; k < buf->zenkouho_suu; k++){
+	if(buf->zenkouho[k]->ima && buf->zenkouho[k]->dic_no != -1){
+	    add_down_bnst(buf, bun_no, buf->zenkouho[k]);
+	}
+    }
+    return(buf->c_zenkouho);
+}
+
+int
+jl_set_jikouho(buf, offset)
+register struct wnn_buf *buf;
+register int offset;
+{
+    wnn_errorno = 0;
+    if(buf->zenkouho_suu <= 0)return(-1);
+    if(buf->zenkouho_daip != SHO){
+	return(-1);
+    }
+    offset = (offset + buf->zenkouho_suu) % buf->zenkouho_suu;
+    if(buf->zenkouho_bun+1 < buf->bun_suu && buf->zenkouho_endvect != -1)
+	buf->bun[buf->zenkouho_bun+1]->dai_top = buf->zenkouho[offset]->dai_end;
+    free_sho(buf, &buf->bun[buf->zenkouho_bun]);
+    set_sho(buf->zenkouho[offset], &buf->bun[buf->zenkouho_bun]);
+    buf->c_zenkouho = offset;
+    return(offset);
+}
+
+
+int
+jl_set_jikouho_dai(buf, offset)
+register struct wnn_buf *buf;
+int offset;
+{
+    register int st, end, bun, k;
+
+    wnn_errorno = 0;
+    if(buf->zenkouho_suu <= 0)return(-1);
+    if(buf->zenkouho_daip != DAI){
+	return(-1);
+    }
+    offset = (offset + buf->zenkouho_dai_suu) % buf->zenkouho_dai_suu;
+    if(buf->zenkouho_end_bun < buf->bun_suu && buf->zenkouho_endvect != -1)
+	buf->bun[buf->zenkouho_end_bun]->dai_top =
+		buf->zenkouho[buf->zenkouho_dai[offset+1]-1]->dai_end;
+    free_bun(buf, buf->zenkouho_bun, buf->zenkouho_end_bun);
+    st = buf->zenkouho_dai[offset];
+    end = buf->zenkouho_dai[offset + 1];
+    make_space_for(buf, BUN, buf->zenkouho_bun, buf->zenkouho_end_bun, end - st);
+    for(bun = buf->zenkouho_bun, k = st; k < end;){
+	set_sho(buf->zenkouho[k++], &buf->bun[bun++]);
+    }
+    buf->zenkouho_end_bun = buf->zenkouho_bun + end - st;
+    buf->c_zenkouho = offset;
+    return(offset);
+}
+
+int
+jl_update_hindo(buf, bun_no, bun_no2)  
+register struct wnn_buf *buf;
+int bun_no, bun_no2;
+{
+    register int k;
+    register WNN_BUN *wb;
+
+    wnn_errorno = 0;
+    if(bun_no < 0) return(-1);
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0) bun_no2 = buf->bun_suu;
+
+#ifdef JL_DEBUG
+    printf("\t\tDown Hindo\n");
+#endif
+    for(k = bun_no; k < bun_no2; k++){
+	if(buf->bun[k]->hindo_updated == 1) continue;
+	for(wb = buf->down_bnst[k]; wb; wb = wb->down){
+	    if(wb->bug == 1) break;
+	    wb->bug = 1;
+	    if(wb->dic_no != -1){
+		if(js_hindo_set(buf->env, wb->dic_no, wb->entry,
+				WNN_IMA_OFF, WNN_HINDO_NOP) == -1) {
+		    if (wnn_errorno == WNN_JSERVER_DEAD) {
+			jl_disconnect(buf->env);buf->env=0;return(-1);
+		    }
+		}
+#ifdef JL_DEBUG
+    display_bun(wb);
+#endif    	
+	    }
+	}
+    }
+    free_down(buf, bun_no, bun_no2);
+
+#ifdef JL_DEBUG
+    printf("\t\tUp Hindo\n");
+#endif
+    for(k = bun_no; k < bun_no2; k++){
+	if(buf->bun[k]->hindo_updated == 1) continue;
+	buf->bun[k]->hindo_updated = 1;
+	wb = buf->bun[k];
+#ifdef JL_DEBUG
+	display_bun(wb);
+#endif    	
+	if(js_hindo_set(buf->env, wb->dic_no, wb->entry,
+			 WNN_IMA_ON, WNN_HINDO_INC) == -1){
+	    if (wnn_errorno == WNN_JSERVER_DEAD) {
+		jl_disconnect(buf->env);buf->env=0;return(-1);
+	    }
+	}
+    }
+    return(0);
+}
+
+
+static w_char *
+wnn_area(bp, area, kanjip)
+WNN_BUN *bp;
+w_char *area;
+int kanjip;
+{
+    register WNN_BUN *bp1;
+    register w_char *c, *end;
+
+    for(bp1 = bp; bp1; bp1 = bp1->next){
+	if(bp1 != bp) c = (w_char *)bp1;
+	else c = bp1->yomi;
+	end = (w_char *)&bp1->next;
+	for(;c < end;){
+	    if(!kanjip){
+		if((*area++ = *c++) == 0){ area--; goto out;}
+	    }else{
+		if(*c++ == 0) kanjip--;
+	    }
+	}
+    }
+ out:
+    return(area);
+}	
+
+static int
+dai_end(buf, bun_no)
+register struct wnn_buf *buf;
+register int bun_no;
+{
+    bun_no++;
+    for(;bun_no < buf->bun_suu && !buf->bun[bun_no]->dai_top; bun_no++);
+    return(bun_no);
+}
+
+#define dai_end_zenkouho(buf, bun_no) (buf->zenkouho_dai[bun_no + 1])
+
+#ifdef	CONVERT_by_STROKE
+/* ɮ�� (Bi Xing) */
+void
+jl_get_zenkouho_yomi(buf, zen_num, area)
+register struct wnn_buf *buf;
+int zen_num;
+w_char *area;
+{
+    register int k, end;
+
+    wnn_errorno = 0;
+    if(!buf->zenkouho_daip){
+	wnn_area(buf->zenkouho[zen_num], area, WNN_YOMI);
+    }else{
+	end = dai_end_zenkouho(buf, zen_num);
+	for(k = buf->zenkouho_dai[zen_num]; k < end; k++){
+	    area = wnn_area(buf->zenkouho[k], area, WNN_KANJI);
+	}
+    }
+}
+#endif
+
+void
+jl_get_zenkouho_kanji(buf, zen_num, area)
+register struct wnn_buf *buf;
+int zen_num;
+w_char *area;
+{
+    register int k, end;
+
+    wnn_errorno = 0;
+    if(!buf->zenkouho_daip){
+	wnn_area(buf->zenkouho[zen_num], area, WNN_KANJI);
+    }else{
+	end = dai_end_zenkouho(buf, zen_num);
+	for(k = buf->zenkouho_dai[zen_num]; k < end; k++){
+	    area = wnn_area(buf->zenkouho[k], area, WNN_KANJI);
+	}
+    }
+}
+
+int
+wnn_get_area(buf, bun_no, bun_no2, area, kanjip)
+struct wnn_buf *buf;
+register int bun_no, bun_no2;
+w_char *area;
+int kanjip;
+{
+    register int k;
+    w_char *area1 = area;
+
+    if(bun_no < 0) return(0);
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0) bun_no2 = buf->bun_suu;
+
+    for(k = bun_no; k < bun_no2; k++){
+	area = wnn_area(buf->bun[k], area, kanjip);
+    }
+    return(area - area1);
+}
+
+#define JISHO 1
+#define HINDO 2
+
+/*********************************/
+int
+jl_dic_add_e(env,dic_name,hindo_name,rev, prio,rw, hrw, pwd_dic, pwd_hindo, error_handler, message_handler)
+register struct wnn_env *env;
+char *dic_name;
+char *hindo_name;
+int prio;
+int rw, hrw, rev;
+char *pwd_dic, *pwd_hindo;
+int  (*error_handler)(), (*message_handler)();
+{
+    char tmp[256];
+    char pwd[WNN_PASSWD_LEN], hpwd[WNN_PASSWD_LEN];
+    int fid, hfid = -1;
+    register int ret;
+
+
+    if(file_exist(env, dic_name) == -1) {
+	if (wnn_errorno == WNN_JSERVER_DEAD) {
+	    jl_disconnect(env);return(-1);
+	}
+	if((int)error_handler == WNN_NO_CREATE || 
+	   (rw == WNN_DIC_RDONLY)){
+	    sprintf(tmp, "%s \"%s\" %s",
+		    msg_get(wnn_msg_cat, 200, NULL, env->lang),
+		    dic_name,
+		    msg_get(wnn_msg_cat, 201, NULL, env->lang));
+		    /*
+		    "����ե����� \"%s\" ��̵���衣",
+		    */
+	    message_out(message_handler, tmp);
+	    wnn_errorno = WNN_NO_EXIST;
+	    return(-1);
+	}
+	sprintf(tmp, "%s \"%s\" %s%s",
+		msg_get(wnn_msg_cat, 200, NULL, env->lang),
+		dic_name,
+		msg_get(wnn_msg_cat, 201, NULL, env->lang),
+		msg_get(wnn_msg_cat, 202, NULL, env->lang));
+		/*
+		"����ե����� \"%s\" ��̵���衣���?(Y/N)",
+		*/
+	if((int)error_handler == WNN_CREATE || 
+	   call_error_handler(error_handler, tmp)){
+	    if(create_file(env, dic_name,JISHO, -1, /* -1 is dummy */
+			   pwd_dic, 
+			   (hindo_name && *hindo_name)? "": pwd_hindo,
+			   error_handler, message_handler) == -1) {
+		return(-1);
+	    }
+	}else{
+	    wnn_errorno = WNN_NO_EXIST;
+	    return(-1);
+	}
+    }
+    if((fid = file_read(env, dic_name)) == -1)
+	    if_dead_disconnect(env, -1);
+    if(hindo_name && *hindo_name){
+	if(file_exist(env, hindo_name) == -1) {
+	    if(wnn_errorno == WNN_JSERVER_DEAD)	{
+		jl_disconnect(env);return(-1);
+	    }
+	    if((int)error_handler == WNN_NO_CREATE ||
+	       (hrw == WNN_DIC_RDONLY)){
+		sprintf(tmp, "%s \"%s\" %s",
+			msg_get(wnn_msg_cat, 203, NULL, env->lang),
+			hindo_name,
+			msg_get(wnn_msg_cat, 201, NULL, env->lang));
+			/*
+			"���٥ե����� \"%s\" ��̵���衣",
+			*/
+		message_out(message_handler, tmp);
+		wnn_errorno = WNN_NO_EXIST;
+		return(-1);
+	    }
+	    sprintf(tmp, "%s \"%s\" %s%s",
+		    msg_get(wnn_msg_cat, 203, NULL, env->lang),
+		    hindo_name,
+		    msg_get(wnn_msg_cat, 201, NULL, env->lang),
+		    msg_get(wnn_msg_cat, 202, NULL, env->lang));
+		    /*
+		    "���٥ե����� \"%s\" ��̵���衣���?(Y/N)",
+		    */
+	    if((int)error_handler == WNN_CREATE || 
+	       call_error_handler(error_handler, tmp)){
+		if(create_file(env, hindo_name, HINDO, fid, 
+			       "", pwd_hindo, error_handler,
+			       message_handler) == -1) return(-1);
+	    }else{
+		wnn_errorno = WNN_NO_EXIST;
+		return(-1);
+	    }
+	}
+	if((hfid = file_read(env, hindo_name)) == -1){
+	    if_dead_disconnect(env, -1);
+	}
+    }
+    if(get_pwd(pwd_dic, pwd) == -1)return(-1);
+    if(get_pwd(pwd_hindo, hpwd) == -1)return(-1);
+    if((ret = js_dic_add(env, fid, hfid, rev, prio, rw, hrw, pwd, hpwd)) < 0){
+	if(wnn_errorno == WNN_JSERVER_DEAD){
+	    jl_disconnect(env);
+	    return(-1);
+	}else if(wnn_errorno == WNN_HINDO_NO_MATCH){
+	    if((int)error_handler == WNN_NO_CREATE){
+		return(-1);
+	    }
+	    sprintf(tmp,
+		    msg_get(wnn_msg_cat, 204, NULL, env->lang),
+		    hindo_name);
+		    /*
+		    "��������� \"%s\" ����������̵���衣���ľ��?(Y/N)",
+		    */
+	    if(!((int)error_handler == WNN_CREATE ||
+		 call_error_handler(error_handler, tmp))){
+		return(-1);
+	    }
+	    if(file_discard(env, hfid) == -1)
+		if_dead_disconnect(env, -1);
+	    if(file_remove(env->js_id, hindo_name, hpwd) == -1)
+		if_dead_disconnect(env, -1);
+	    if(create_file(env,hindo_name, HINDO, fid, NULL, pwd_hindo, WNN_CREATE, message_handler) == -1) return(-1);
+	    if((hfid = file_read(env, hindo_name)) == -1)
+		if_dead_disconnect(env, -1);
+	    if((ret = js_dic_add(env, fid, hfid, rev, prio, rw, hrw, pwd, hpwd))< 0)
+		if_dead_disconnect(env, -1);
+	}
+    }
+    return(ret);
+}
+
+
+int
+jl_dic_delete_e(env, dic_no)
+register struct wnn_env *env;
+register int dic_no;
+{
+    WNN_DIC_INFO dic;
+
+    if(js_dic_info(env,dic_no,&dic) < 0){
+	if_dead_disconnect(env, -1);
+    }
+    if(js_dic_delete(env, dic_no) < 0)
+	if_dead_disconnect(env, -1);
+    /*	dic Body	*/
+    if (file_discard(env,dic.body) < 0) {
+	if_dead_disconnect(env, -1);
+    }
+    /*	dic hindo	*/
+    if(dic.hindo != -1){
+	if (file_discard(env,dic.hindo) < 0){
+	    if_dead_disconnect(env, -1);
+	}
+    }
+    return(0);
+}
+
+static int
+get_pwd(pwd_dic, pwd)
+register char *pwd_dic, *pwd;
+{
+    FILE *fp;
+	    
+    if(pwd_dic && *pwd_dic){
+	if((fp = fopen(pwd_dic, "r")) == NULL){
+	    wnn_errorno = WNN_CANT_OPEN_PASSWD_FILE;
+	    return(-1);
+	}
+	fgets(pwd, WNN_PASSWD_LEN, fp);
+	fclose(fp);
+    }else {
+	pwd[0] = 0;
+    }
+    return(0);
+}
+
+static int
+create_pwd_file(env, pwd_file, error_handler, message_handler)
+register struct wnn_env *env;
+char *pwd_file;
+int  (*error_handler)(), (*message_handler)();
+{
+    FILE *fp;
+    char gomi[256];
+
+    if(pwd_file == NULL || *pwd_file == 0) return(0);
+    if(access(pwd_file, F_OK) != -1) return(0);
+    sprintf(gomi, "%s \"%s\" %s%s",
+	    msg_get(wnn_msg_cat, 205, NULL, env->lang),
+	    pwd_file,
+	    msg_get(wnn_msg_cat, 201, NULL, env->lang),
+	    msg_get(wnn_msg_cat, 202, NULL, env->lang));
+	    /*
+	    "password_file \"%s\" ��̵���衣���?(Y/N)",
+	    */
+    if(call_error_handler(error_handler,gomi) == 0){
+	wnn_errorno = WNN_NO_EXIST;
+	return(-1);
+    }
+    if((fp = fopen(pwd_file, "w")) == NULL){
+	wnn_errorno = WNN_CANT_OPEN_PASSWD_FILE;
+	message_out(message_handler, wnn_perror_lang(env->lang));
+	return(-1);
+    }
+#ifdef HITACHI
+    srand(time(0)+getuid());
+    fprintf(fp,"%d\n",rand());
+#else /* HITACHI */
+#ifdef SYSVR2
+    srand(time(0)+getuid());
+    fprintf(fp,"%d\n",rand());
+#else
+    srandom(time(0)+getuid());
+    fprintf(fp,"%d\n",random());
+#endif
+#endif /* HITACHI */
+    fclose(fp);
+#define	MODE_PWD (0000000 | 0000400)
+    chmod(pwd_file,MODE_PWD);
+    return(0);
+}
+
+
+/**	jl_fuzokugo_set	**/
+int
+jl_fuzokugo_set_e(env,fname)
+struct wnn_env *env;
+char *fname;
+{
+    register int fid, orgfid;
+    int	ret;
+
+    wnn_errorno = 0;
+    orgfid = js_fuzokugo_get(env);
+    /* If orgfid == -1, it must be
+       because no fuzokugo_file is set to the env
+       */
+    if((fid=file_read(env,fname)) == -1)
+	if_dead_disconnect(env, -1);
+    if ((ret = js_fuzokugo_set(env,fid)) < 0)
+	if_dead_disconnect(env, ret);
+    if(fid != orgfid && orgfid != -1){
+	js_file_discard(env, orgfid);
+    }
+    return(ret);
+}
+
+/**	jl_fuzokugo_get	**/
+int
+jl_fuzokugo_get_e(env, fname)
+register struct wnn_env *env;
+char *fname;
+{
+    WNN_FILE_INFO_STRUCT file;
+    int fid;
+    char *c;
+
+    wnn_errorno = 0;
+    fname[0] = 0;
+    if((fid = js_fuzokugo_get(env)) < 0)
+	if_dead_disconnect(env, -1);
+    if (js_file_info(env,fid,&file) < 0)
+	if_dead_disconnect(env, -1);
+    c = find_file_name_from_id(env, fid);
+    if(c == NULL){
+	c = file.name;
+    }
+    strcpy(fname, c);
+    return(fid);
+}
+
+/**	jl_dic_save	**/
+int
+jl_dic_save_e(env,dic_no)
+register struct wnn_env *env;
+int	dic_no;
+{
+    WNN_DIC_INFO dic;
+    WNN_FILE_INFO_STRUCT file;
+    char *c;
+
+    wnn_errorno = 0;
+    if(js_dic_info(env,dic_no,&dic) < 0)
+	    if_dead_disconnect(env, -1);
+    /*	dic Body	*/
+    c = find_file_name_from_id(env, dic.body);
+    if(c == NULL){
+	if(dic.localf){
+	    c = dic.fname;
+	}else{
+	    wnn_errorno=WNN_FILE_NOT_READ_FROM_CLIENT;
+	    return(-1); 
+	}
+    } 
+    if(c[0] != C_LOCAL){
+	if (js_file_write(env,dic.body,c) < 0) {
+	    if (wnn_errorno == WNN_JSERVER_DEAD) {
+		jl_disconnect_if_server_dead(env);
+		return(-1);
+	    }
+	}
+    }else{
+	if (js_file_receive(env,dic.body,c + 1) < 0) {
+	    if (wnn_errorno == WNN_JSERVER_DEAD) {
+		jl_disconnect_if_server_dead(env);
+		return(-1);
+	    }
+	}
+    }
+ /*	dic hindo	*/
+    if(dic.hindo != -1){
+	if (js_file_info(env,dic.hindo,&file) < 0)
+	    if_dead_disconnect(env, -1);
+	c = find_file_name_from_id(env, file.fid);
+	if(c == NULL){
+	    if(dic.hlocalf){
+		c = dic.hfname;
+	    }else{
+		wnn_errorno=WNN_FILE_NOT_READ_FROM_CLIENT;
+		return(-1);
+	    }
+	}
+	if(c[0] != C_LOCAL){
+	    if (js_file_write(env,dic.hindo,c) < 0) {
+		if_dead_disconnect(env, -1);
+	    }
+	}else{
+	    if (js_file_receive(env,dic.hindo,c + 1) < 0) {
+		if_dead_disconnect(env, -1);
+	    }
+	}
+    }
+    return(0);
+}
+
+int
+jl_dic_save_all_e(env)
+struct wnn_env *env;
+{
+    register WNN_DIC_INFO *dic;
+    register int k;
+    char *c;
+
+    register int cnt;
+
+    wnn_errorno = 0;
+    if((cnt = js_dic_list(env, &dicrb)) == -1)
+	    if_dead_disconnect(env, -1);
+    dic = (WNN_DIC_INFO *)dicrb.buf;
+    for(k = 0 ; k < cnt ; k++, dic++){
+	if((c = find_file_name_from_id(env, dic->body)) == NULL){
+	    if(dic->localf){
+		c = dic->fname;
+	    }else{
+		wnn_errorno=WNN_FILE_NOT_READ_FROM_CLIENT;
+	    }
+	}
+	if(c){
+	    if(c[0] != C_LOCAL){
+		if (js_file_write(env,dic->body,c) < 0) {
+		    if (wnn_errorno == WNN_JSERVER_DEAD) {
+			jl_disconnect_if_server_dead(env);
+			return(-1);
+		    }
+		}
+	    }else{
+		if (js_file_receive(env,dic->body,c + 1) < 0) {
+		    if (wnn_errorno == WNN_JSERVER_DEAD) {
+			jl_disconnect_if_server_dead(env);
+			return(-1);
+		    }
+		}
+	    }
+	}
+ /*	dic hindo	*/
+	if(dic->hindo != -1){
+	    c = find_file_name_from_id(env, dic->hindo);
+	    if(c == NULL){
+		if(dic->hlocalf){
+		    c = dic->hfname;
+		}else{
+		    wnn_errorno=WNN_FILE_NOT_READ_FROM_CLIENT;
+		}
+	    }
+	    if(c){
+		if(c[0] != C_LOCAL){
+		    if (js_file_write(env,dic->hindo,c) < 0) {
+			if (wnn_errorno == WNN_JSERVER_DEAD) {
+			    if_dead_disconnect(env, -1);
+			}
+		    }
+		}else{
+		    if (js_file_receive(env,dic->hindo,c + 1) < 0) {
+			if (wnn_errorno == WNN_JSERVER_DEAD) {
+			    if_dead_disconnect(env, -1);
+			}
+		    }
+		}
+	    }
+	}
+    }
+    if(wnn_errorno) return(-1);
+    return(0);
+}
+
+/*
+ *
+ * bun manipulate  routines
+ *
+ */
+
+static void
+free_sho(buf, wbp)
+register struct wnn_buf *buf;
+WNN_BUN **wbp;
+{
+    register WNN_BUN *wb;
+    wb = *wbp;
+
+    if(--wb->ref_cnt <= 0){
+	for(; wb;){
+	    wb->free_next = buf->free_heap;
+	    buf->free_heap = wb;
+	    wb = wb->next;
+	}
+    }
+    *wbp = NULL;
+}
+
+static void
+free_zenkouho(buf)
+register struct wnn_buf *buf;
+{
+    register int k;
+
+    for(k = 0 ; k < buf->zenkouho_suu; k++){
+	free_sho(buf, &buf->zenkouho[k]);
+    }
+    buf->zenkouho_suu = 0;
+    buf->zenkouho_dai_suu = 0;
+    buf->c_zenkouho = -1;
+    buf->zenkouho_bun = -1;
+    buf->zenkouho_end_bun = -1;
+}
+
+static void
+free_bun(buf, bun_no, bun_no2)
+struct wnn_buf *buf;
+register int bun_no, bun_no2;
+{
+    register int k;
+
+    for(k = bun_no; k < bun_no2; k++){
+	free_sho(buf, &buf->bun[k]);
+    }
+}
+
+static void
+free_down(buf, bun_no, bun_no2)
+struct wnn_buf *buf;
+int bun_no, bun_no2;
+{
+    register WNN_BUN **wbp, **wbp1;
+    int k;
+
+    for(k = bun_no; k < bun_no2; k++){
+	for(wbp = &buf->down_bnst[k]; *wbp; wbp = wbp1){
+	    wbp1 = &(*wbp)->down;
+	    free_sho(buf, wbp);
+	}
+    }
+}
+
+static
+WNN_BUN *
+get_new_bun(buf)
+register struct wnn_buf *buf;
+{
+    register WNN_BUN *wb;
+
+
+    if(buf->free_heap == NULL){
+	if(alloc_heap(buf, INCREMENT) == -1)return(NULL);
+    }
+    wb = buf->free_heap;
+    buf->free_heap = wb->free_next;
+    wb->free_next = NULL;
+    wb->daihyoka = -1;
+
+    return(wb);
+}
+
+static
+WNN_BUN *
+get_sho(buf, sb, zenp, daip)
+struct wnn_buf *buf;
+struct wnn_sho_bunsetsu *sb;
+int zenp, daip;
+{
+    register w_char *c, *end, *s;
+    register WNN_BUN *wb;
+    WNN_BUN *wb1;
+    int where = 1;
+    int len;
+
+    if((wb = get_new_bun(buf)) == NULL) return(NULL);
+
+    wb->jirilen = sb->jiriend - sb->start + 1;
+    wb->dic_no = sb->dic_no;
+    wb->entry = sb->entry;
+    wb->kangovect = sb->kangovect;
+    wb->hinsi = sb->hinsi;	
+    wb->hindo = sb->hindo;	
+    wb->ima = sb->ima;
+    wb->hindo_updated = 0;
+    wb->bug = 0;
+    wb->dai_top = 0;
+    wb->nobi_top = 0;
+    wb->ref_cnt = 1;		
+    wb->hyoka = sb->hyoka;
+    wb->down = NULL;
+    wb->from_zenkouho = daip << 1 | zenp;
+    len = wnn_Strlen(sb->fuzoku);
+    wb->yomilen = wnn_Strlen(sb->yomi) + len;
+    wb->kanjilen = wnn_Strlen(sb->kanji) + len;
+/*
+    wb->dai_top = (sb->status == WNN_CONNECT)? 0:1;
+��ʸ�����Ƭ�ʳ��ξ�ʸ��˴ؤ��Ƥϡ�status �Ϥ����ø����ͤ����äƤ��롣
+*/  
+    s = sb->yomi;
+
+    for(wb1 = wb; ;){
+	if(wb1 == wb) c = wb1->yomi;
+	else c = (w_char *)wb1;
+	end = (w_char *)&wb1->next;
+
+	for(; c < end;) {
+	    if((*c++ = *s++) == 0){
+		if(where == 1){
+		    where = 3;
+		    c--;
+		    s = sb->fuzoku;
+		}else if(where == 3){
+		    where = 0;
+		    s = sb->kanji;
+		}else if(where == 0){
+		    where = 4;
+		    c--;
+		    s = sb->fuzoku;
+		}else{
+		    goto out;
+		}
+	    }
+	}
+	wb1->next = get_new_bun(buf);
+	wb1 = wb1->next;
+    }
+    out:
+    wb1->next = NULL;
+    return(wb);
+}
+
+static void
+make_space_for(buf, zenp, bun_no, bun_no2, cnt)
+register struct wnn_buf *buf;
+int bun_no, bun_no2, zenp;
+int cnt;
+{
+    switch(zenp){
+    case BUN:
+	make_space_for_bun(buf,bun_no, bun_no2, cnt);
+	break;
+    case ZENKOUHO:
+	make_space_for_zenkouho(buf,bun_no, bun_no2, cnt);
+    }
+}
+
+static void
+make_space_for_bun(buf, bun_no, bun_no2, cnt)
+register struct wnn_buf *buf;
+int bun_no, bun_no2;
+int cnt;
+{
+    int newsize;
+    register int k;
+
+    newsize = buf->bun_suu + cnt - (bun_no2 - bun_no);
+
+#define Realloc(a, b) realloc((char *)(a), (unsigned)(b))
+
+    if(newsize > buf->msize_bun){
+	buf->bun = (WNN_BUN **)Realloc(buf->bun, newsize * sizeof(WNN_BUN *));
+	buf->down_bnst = (WNN_BUN **)Realloc(buf->down_bnst, newsize * sizeof(WNN_BUN *));
+	buf->msize_bun = newsize;
+    }
+
+
+    for(k = buf->bun_suu; k < newsize; k++){
+	buf->down_bnst[k] = NULL;
+    }
+    bcopy((char *)&buf->bun[bun_no2], (char *)&buf->bun[bun_no + cnt],
+	  (buf->bun_suu - bun_no2) * sizeof(WNN_BUN *));
+    bcopy((char *)&buf->down_bnst[bun_no2], (char *)&buf->down_bnst[bun_no + cnt],
+	  (buf->bun_suu - bun_no2) * sizeof(WNN_BUN *));
+    if(bun_no2 < bun_no + cnt){
+	bzero((char *)&buf->down_bnst[bun_no2], (bun_no + cnt - bun_no2) * sizeof(WNN_BUN *));
+    }
+    buf->bun_suu = newsize;
+}
+
+static void
+make_space_for_zenkouho(buf, bun_no, bun_no2, cnt)
+struct wnn_buf *buf;
+int bun_no, bun_no2;
+register int cnt;
+{
+    register int newsize;
+
+    newsize = buf->zenkouho_suu + cnt - (bun_no2 - bun_no);
+
+    if(newsize > buf->msize_zenkouho){
+	buf->zenkouho = (WNN_BUN **)Realloc(buf->zenkouho, newsize * sizeof(WNN_BUN *));
+	buf->zenkouho_dai = (int *)Realloc(buf->zenkouho_dai, (1 + newsize) * sizeof(int *));
+	buf->msize_zenkouho = newsize;
+    }
+    bcopy((char *)&buf->zenkouho[bun_no2],
+	  (char *)&buf->zenkouho[bun_no + cnt],
+	  (buf->zenkouho_suu - bun_no2) * sizeof(WNN_BUN *));
+    buf->zenkouho_suu = newsize;
+}
+
+
+static int
+insert_sho(buf, zenp, bun_no, bun_no2, sp, cnt, uniq_level)
+struct wnn_buf *buf;
+int bun_no, bun_no2;
+register struct wnn_sho_bunsetsu *sp;
+int cnt;
+int zenp;			/* daip */
+int uniq_level;			/* uniq is only supported when bun_no = -1
+				   and zenp == ZENKOUHO */
+{
+    register WNN_BUN **b;
+    register int k;
+
+    if(bun_no == -1){
+	bun_no = bun_no2 = (zenp == BUN)? buf->bun_suu: buf->zenkouho_suu;
+    }
+
+    /* It will make too big space when uniq_level > 0, but That's OK! */
+    make_space_for(buf, zenp, bun_no, bun_no2, cnt);
+
+    b = ((zenp == BUN)? buf->bun: buf->zenkouho) + bun_no;
+    for(k = bun_no ; k < bun_no + cnt ; k++, sp++){
+	if(uniq_level){
+	    if(find_same_kouho(sp, buf->zenkouho, b,uniq_level))continue;
+	}
+	*b = get_sho(buf, sp, zenp, SHO);
+	(*b)->dai_top = (sp->status == WNN_CONNECT)? 0:1;
+	if(zenp != BUN){
+	    if(buf->zenkouho_endvect != -1){
+		(*b)->dai_end = (sp->status_bkwd == WNN_CONNECT_BK)? 0:1;
+	    }else{
+		(*b)->dai_end = 1;
+	    }
+	}
+	b++;
+    }
+    if(uniq_level && zenp == ZENKOUHO){
+	buf->zenkouho_suu = b - buf->zenkouho;
+    }
+    return(cnt + bun_no);
+}
+
+	/* for zenkouho, assume bun_no = bun_no2 = zenkouho_suu */
+static int
+insert_dai(buf, zenp, bun_no, bun_no2, dp, dcnt, uniq_level)
+struct wnn_buf *buf;
+int bun_no, bun_no2;
+struct wnn_dai_bunsetsu *dp;
+int dcnt;
+int zenp;
+int uniq_level;
+{
+    register WNN_BUN **b, **b0;
+    register int k, l, m;
+    register int cnt = 0;
+    struct wnn_sho_bunsetsu *sp, *sp1;
+
+    if(bun_no == -1){
+	bun_no = bun_no2 = (zenp == BUN)? buf->bun_suu: buf->zenkouho_suu;
+    }
+
+    for(k = 0; k < dcnt ; k++){
+	cnt += dp[k].sbncnt;
+    }
+    make_space_for(buf, zenp, bun_no, bun_no2, cnt);
+				/* zenkouho_dai_suu must not be initialized */
+
+    b = ((zenp == BUN)? buf->bun: buf->zenkouho) + bun_no;
+
+    for(k = 0, m = buf->zenkouho_dai_suu ; k < dcnt; k++){
+	if(uniq_level){
+	    if(find_same_kouho_dai(&dp[k], buf, m, uniq_level))
+		continue;
+	}
+	sp = dp[k].sbn;
+	if(zenp == ZENKOUHO){
+	    buf->zenkouho_dai[m++] = b - buf->zenkouho;
+	}
+	b0 = b;
+	sp1 = sp;
+	for(l = 0 ; l < dp[k].sbncnt; l++){
+	    *b = get_sho(buf, sp, zenp, DAI);
+	    if(zenp == ZENKOUHO){
+		if (l == dp[k].sbncnt -1){
+		    if(buf->zenkouho_endvect != -1){
+			(*b)->dai_end = (sp->status_bkwd == WNN_CONNECT_BK)? 0:1;
+		    }else{
+			(*b)->dai_end = 0;
+		    }
+		}else{
+		    (*b)->dai_end = 0;
+		}
+	    }
+	    *b++;
+	    sp++;
+	}
+	(*b0)->dai_top = (sp1->status == WNN_CONNECT)? 0:1;
+	(*b0)->daihyoka = dp[k].hyoka;
+    }
+    if(zenp == ZENKOUHO){
+	buf->zenkouho_dai[m] = b - buf->zenkouho;
+	buf->zenkouho_suu = b - buf->zenkouho;
+	buf->zenkouho_dai_suu = m;
+    }
+    return(cnt + bun_no);
+}
+
+static void
+set_sho(b, p)
+register WNN_BUN *b;
+register WNN_BUN **p;
+{
+    b->ref_cnt++;
+    *p = b;
+}
+
+static void
+set_dai(b, p, n)
+register WNN_BUN **b;
+register WNN_BUN **p;
+register int n;
+{
+    for(;n;n--){
+	(*b)->ref_cnt++;
+	*p++ = *b++;
+    }
+}
+
+static int
+get_c_jikouho_from_zenkouho(buf, dest)
+struct wnn_buf *buf;
+WNN_BUN *dest;
+{
+    register int k;
+    w_char area[LENGTHKANJI];
+    w_char area1[LENGTHKANJI];
+    register WNN_BUN *b;
+
+    wnn_area(dest, area, WNN_KANJI);
+    for(k = 0; k < buf->zenkouho_suu; k++){
+	b = buf->zenkouho[k];
+	if(b->entry == dest->entry && b->dic_no == dest->dic_no){
+	    wnn_area(b, area1, WNN_KANJI);
+	    if(wnn_Strcmp(area, area1) == 0){
+		return(k);
+	    }
+	}
+    }
+    return(-1);
+}
+
+static int
+get_c_jikouho_from_zenkouho_dai(buf, dest)
+struct wnn_buf *buf;
+WNN_BUN *dest;
+{
+    register int k;
+    w_char area[LENGTHKANJI];
+    w_char area1[LENGTHKANJI];
+    register WNN_BUN *b;
+    register int l;
+
+    wnn_area(dest, area, WNN_KANJI);
+    for(k = 0; k < buf->zenkouho_dai_suu; k++){
+	b = buf->zenkouho[buf->zenkouho_dai[k]];
+	for(l = 0 ; l < buf->zenkouho_dai[k + 1]; l++, dest++, b++){
+	    if(b->entry != dest->entry || b->dic_no != dest->dic_no) break;
+	    wnn_area(b, area1, WNN_KANJI);
+	    if(wnn_Strcmp(area, area1) != 0){
+		break;
+	    }
+	}
+	if(l == buf->zenkouho_dai[k + 1]){
+	    return(k);
+	}
+    }
+    return(-1);
+}
+
+
+static int
+get_c_jikouho(sp, cnt, dest)
+struct wnn_sho_bunsetsu *sp;
+int cnt;
+WNN_BUN *dest;
+{
+    register int k;
+    register int len;
+    w_char area[LENGTHKANJI];
+
+    wnn_area(dest, area, WNN_KANJI);
+    for(k = 0; k < cnt; k++,sp++){
+	if(sp->entry == dest->entry && sp->dic_no == dest->dic_no
+	   && sp->kangovect == dest->kangovect){
+	    if(wnn_Strncmp(area, sp->kanji, len = wnn_Strlen(sp->kanji)) == 0 &&
+	       wnn_Strcmp(area + len, sp->fuzoku) == 0){
+		return(k);
+	    }
+	}
+    }
+    return(-1);
+}
+
+static int
+get_c_jikouho_dai(dp, cnt, dest, bun_no)
+struct wnn_dai_bunsetsu *dp;
+int cnt;
+WNN_BUN **dest;
+int bun_no;
+{
+    register int k, l;
+    register int len;
+    w_char area[LENGTHKANJI];
+    register struct wnn_sho_bunsetsu *sp;    
+
+    for(k = 0; k < cnt; k++,dp++){
+	sp = dp->sbn;
+	for(l = 0 ; l < dp->sbncnt; l++, sp++){
+	    if(sp->entry != (dest[bun_no + l])->entry ||
+	       sp->kangovect != (dest[bun_no + l])->kangovect ||
+	       sp->dic_no != (dest[bun_no + l])->dic_no){
+		break;
+	    }
+	    wnn_area(dest[bun_no + l], area, WNN_KANJI);
+	    if(wnn_Strncmp(area, sp->kanji, len = wnn_Strlen(sp->kanji)) != 0 ||
+	       wnn_Strcmp(area + len, sp->fuzoku) != 0){
+		break;
+	    }
+	}
+	if(l == dp->sbncnt) return(k);
+    }
+    return(-1);
+}
+
+
+static int
+find_same_kouho(sp, st, end, level)
+struct wnn_sho_bunsetsu *sp;
+register WNN_BUN **st, **end;
+int level;
+{
+    register int len;
+    w_char area[LENGTHKANJI];
+    register WNN_BUN *b;
+
+    if(level == WNN_UNIQ){
+	for(; st < end; st++){
+	    b = *st;
+	    if(sp->hinsi == b->hinsi){
+		wnn_area(b, area, WNN_KANJI);
+		if(wnn_Strncmp(area, sp->kanji, len = wnn_Strlen(sp->kanji)) == 0 &&
+		   wnn_Strcmp(area + len, sp->fuzoku) == 0){
+		    return(1);
+		}
+	    }
+	}
+    }else{ /* level = WNN_UNIQ_KNJ */
+	for(; st < end; st++){
+	    b = *st;
+	    wnn_area(b, area, WNN_KANJI);
+	    if(wnn_Strncmp(area, sp->kanji, len = wnn_Strlen(sp->kanji)) == 0 &&
+	       wnn_Strcmp(area + len, sp->fuzoku) == 0){
+		return(1);
+	    }
+	}
+    }	
+    return(0);
+}
+    
+static int
+find_same_kouho_dai(dp, buf, top, level)
+struct wnn_dai_bunsetsu *dp;
+struct wnn_buf *buf;
+int top;
+int level;
+{
+    int len;
+    register int k, l;
+    w_char area[LENGTHKANJI];
+    WNN_BUN *b;
+    register struct wnn_sho_bunsetsu *sp;
+
+    for(k = 0 ; k < top ; k++){
+	for(l = 0,sp = dp->sbn ; l < dp->sbncnt; l++, sp++){
+	    b = buf->zenkouho[buf->zenkouho_dai[k] + l];
+	    if(sp->end - sp->start + 1 != b->yomilen) break;/* From: tsuiki */
+	    if(level != WNN_UNIQ_KNJ){
+		if(sp->hinsi != b->hinsi) break;
+	    }
+	    wnn_area(b, area, WNN_KANJI);
+	    if(wnn_Strncmp(area, sp->kanji, len = wnn_Strlen(sp->kanji)) != 0 ||
+	       wnn_Strcmp(area + len, sp->fuzoku) != 0){
+		break;
+	    }
+	}
+	if(l == dp->sbncnt)
+	    return(1);
+    }
+    return(0);
+}
+
+int
+wnn_cnt_free(buf)
+struct wnn_buf *buf;
+{
+    register int n;
+    register WNN_BUN *b;
+
+    for(n = 0, b = buf->free_heap ;b;n++, b = b->free_next);
+    return(n);
+}
+
+
+struct wnn_jdata *
+jl_word_info_e(env, dic_no, entry)
+register struct wnn_env *env;
+int dic_no, entry;
+{
+    wnn_errorno = 0;
+    if (js_word_info(env,dic_no, entry, &wordrb) < 0)
+	if_dead_disconnect(env, NULL);
+    return((struct wnn_jdata *)(wordrb.buf));
+}    
+
+int
+jl_dic_list_e(env, dicinfo)
+struct wnn_env *env;
+WNN_DIC_INFO **dicinfo;
+{
+    WNN_DIC_INFO *info;
+    int cnt;
+    register int k;
+    register char *c;
+
+    wnn_errorno = 0;
+    if ((cnt = js_dic_list(env, &dicrb)) < 0)
+	if_dead_disconnect(env, -1);
+    info = (WNN_DIC_INFO *)(dicrb.buf);
+
+/* If the file is loaded from this client, change the file name to the one
+   used in loading it. */
+    for(k = 0 ; k < cnt ; k++){
+	c = find_file_name_from_id(env, info[k].body);
+	if(c != NULL){
+	    strcpy(info[k].fname, c);
+	}
+
+	c = find_file_name_from_id(env, info[k].hindo);
+	if(c != NULL){
+	    strcpy(info[k].hfname, c);
+	}
+    }
+    *dicinfo = info;
+    return(cnt);
+}
+
+
+static int
+sort_func_ws(a,b)
+register char *a, *b;
+{
+    int ah, bh, ai, bi, iah, ibh, iai, ibi;
+    ah = ((struct wnn_jdata *)a)->hindo;
+    bh = ((struct wnn_jdata *)b)->hindo;
+    iah = ((struct wnn_jdata *)a)->int_hindo;
+    ibh = ((struct wnn_jdata *)b)->int_hindo;
+    ai = ((struct wnn_jdata *)a)->ima;
+    bi = ((struct wnn_jdata *)b)->ima;
+    iai = ((struct wnn_jdata *)a)->int_ima;
+    ibi = ((struct wnn_jdata *)b)->int_ima;
+
+    if(ai == WNN_IMA_OFF && ah == WNN_ENTRY_NO_USE) return(1);
+    if(bi == WNN_IMA_OFF && bh == WNN_ENTRY_NO_USE) return(-1);
+    if(iai == WNN_IMA_OFF && iah == WNN_ENTRY_NO_USE) return(1);
+    if(ibi == WNN_IMA_OFF && ibh == WNN_ENTRY_NO_USE) return(-1);
+
+    if(ai != bi){
+	if(ai < bi) return(1);
+	return(-1);
+    }
+    if(iah >= 0){
+	ah += iah;
+	bh += ibh;
+    }
+    if(ah > bh)return(-1);
+    if(ah < bh)return(1);
+    return(0);
+}
+
+int
+jl_word_search_e(env,dic_no, yomi, jdp)
+register struct wnn_env *env;
+int dic_no;
+w_char *yomi;
+struct wnn_jdata **jdp;
+{
+    register int cnt;
+    struct wnn_jdata *jd;
+
+    wnn_errorno = 0;
+    if ((cnt = js_word_search(env,dic_no, yomi, &wordrb)) < 0)
+	if_dead_disconnect(env, -1);
+    jd = (struct wnn_jdata *)wordrb.buf;
+/*    for(cnt = 0 ; jd[cnt].dic_no != -1; cnt++); */
+    qsort((char *)jd,cnt,sizeof(struct wnn_jdata),sort_func_ws);
+    *jdp = jd;
+    return(cnt);
+}
+
+int 
+jl_word_search_by_env_e(env, yomi, jdp)
+register struct wnn_env *env;
+struct wnn_jdata **jdp;
+w_char *yomi;
+{
+    register int cnt;
+    struct wnn_jdata *jd;
+
+    wnn_errorno = 0;
+    if ((cnt = js_word_search_by_env(env, yomi, &wordrb)) < 0)
+	if_dead_disconnect(env, -1);
+    jd = (struct wnn_jdata *)wordrb.buf;
+/*    for(cnt = 0 ; jd[cnt].dic_no != -1; cnt++); */
+    qsort((char *)jd,cnt,sizeof(struct wnn_jdata),sort_func_ws);
+    *jdp = jd;
+    return(cnt);
+}
+
+#ifdef JL_DEBUG
+static void
+display_bun(b)
+WNN_BUN *b;
+{
+    w_char yomi[LENGTHBUNSETSU];
+    wnn_area(b, yomi, 1); putws(yomi);
+    printf("\t");
+    wnn_area(b, yomi, 0); putws(yomi);
+    printf("\t");
+    printf("Jirilen:%d Dic_no:%d Serial:%d Hinsi:%d Hindo:%c%d\n Hindo_Updated:%d Nobi_Top:%d Dai_top:%d Ref_cnt:%d Down:%d\n",
+	   b->jirilen, b->dic_no, b->entry, b->hinsi, 
+	   (b->ima )? '*':' ',
+	   b->hindo, b->hindo_updated, b->nobi_top, b->dai_top, b->ref_cnt, b->down);
+}
+#endif
+
+
+static void
+add_down_bnst(buf, k, b)
+register struct wnn_buf *buf;
+register int k;
+register WNN_BUN *b;
+{
+    if(b->down) return; /* In order to prevent roop! */
+    if(b == buf->down_bnst[k]) return; /* In order to prevent roop! */
+				/* It occurs when Zenkouho-->Nobi-conv */
+    b->down = buf->down_bnst[k];
+    buf->down_bnst[k] = b;
+    b->ref_cnt ++;
+}
+
+#ifdef JL_DEBUG
+static void
+print_jdata(jd)
+struct wnn_jdata *jd;
+{
+    putws(jd->kanji);
+    printf("\tDict:%d Serial:%d Hinsi:%s Hindo:%c%d ExHindo:%c%d\n",
+	   jd->dic_no, jd->serial, wnn_get_hinsi_name(jd->hinshi),
+	   (jd->ima)? '*':' ', jd->hindo,
+	   (jd->int_ima)? '*':' ', jd->int_hindo);
+}
+#endif
+
+#define REAL_PARAM(x) (strcmp(x, "-"))
+
+
+/** wnnrc �򸫤ƤΥѥ�᡼�������� */
+int
+jl_set_env_wnnrc(env, wnnrc_n, error_handler, message_handler)
+register struct wnn_env *env;
+char *wnnrc_n;
+int  (*error_handler)(), (*message_handler)();
+{
+    int level = 0;
+    int x;
+    wnn_errorno = 0;
+    if((int)error_handler ==  WNN_CREATE){
+	confirm_state = CREATE_WITHOUT_CONFIRM;
+    }else if((int)error_handler ==  WNN_NO_CREATE){
+	confirm_state = NO_CREATE;
+    }else{
+	confirm_state = CONFIRM;
+    }
+    x = jl_set_env_wnnrc1(env, wnnrc_n, error_handler, message_handler, level);
+    confirm_state = 0;
+    return(x);
+}	
+
+int
+jl_set_env_wnnrc1(env, wnnrc_n, error_handler, message_handler, level)
+register struct wnn_env *env;
+char *wnnrc_n;
+int  (*error_handler)(), (*message_handler)();
+int level;
+{
+    register int num;
+    char s[20][EXPAND_PATH_LENGTH];
+    char code[EXPAND_PATH_LENGTH];
+    char tmp[1024];
+    register FILE *fp;
+
+    wnn_errorno = 0;
+    if(level > MAXINCLUDE){
+	message_out(message_handler,
+		    msg_get(wnn_msg_cat, 206, NULL, env->lang));
+		    /*
+		    "include �Υ�٥뤬¿�᤮�ޤ���"
+		    */
+	return(-1);
+    }
+    if((fp = fopen(wnnrc_n, "r")) == NULL){
+	message_out(message_handler,
+		    msg_get(wnn_msg_cat, 207, NULL, env->lang), wnnrc_n);
+		    /*
+		    "file \"%s\"�� open �Ǥ��ޤ���",
+		    */
+	return(-1);
+    }
+    while(fgets(tmp,1024,fp  ) != NULL){
+	num = sscanf(tmp,
+	"%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s",code,
+		     s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],
+		     s[11],s[12],s[13],s[14],s[15],s[16],s[17],s[18],s[19]) ;
+	if (num <= 0) { 
+	    continue;
+	}
+	if(code[0] == ';'){
+	    continue;
+
+	}else if (strcmp(code, "include") == 0){
+	    expand_expr_all(s[0], env);
+	    if(jl_set_env_wnnrc1(env, s[0], error_handler, message_handler, level + 1) == -1){
+		fclose(fp);
+		return(-1);
+	    }
+	}else if (strcmp(code, "setdic") == 0){
+	    /* dic_add */
+	    int prio, rdonly, hrdonly, rev;
+	    int  (*error_handler1)() = (int (*)())0;
+	    expand_expr_all(s[0], env);
+	    if(num < 3 || !REAL_PARAM(s[1])){
+		s[1][0] = 0;
+	    }else{
+		expand_expr_all(s[1], env);
+	    }
+	    prio = (num >= 4 && REAL_PARAM(s[2]))? atoi(s[2]) : WNN_DIC_PRIO_DEFAULT;
+	    rdonly = (num >= 5 && REAL_PARAM(s[3]))? atoi(s[3]) : 0;
+	    hrdonly = (num >= 6 && REAL_PARAM(s[4]))? atoi(s[4]) : 0;
+	    if(num < 7 || !REAL_PARAM(s[5])) s[5][0] = 0;
+	    if(num < 8 || !REAL_PARAM(s[6])) s[6][0] = 0;
+	    rev = (num >= 9 && REAL_PARAM(s[7]))? atoi(s[7]) : 0;
+
+	    if(confirm_state == CONFIRM || confirm_state == CONFIRM1){
+		error_handler1 = error_handler;
+	    }else if (confirm_state == CREATE_WITHOUT_CONFIRM){
+
+		error_handler1 = (int (*)())WNN_CREATE;
+	    }else if (confirm_state == NO_CREATE){
+		error_handler1 = (int (*)())WNN_NO_CREATE;
+	    }
+	    if(jl_dic_add_e(env,s[0],s[1],rev, prio,rdonly, hrdonly, s[5], s[6],
+			    error_handler1, message_handler) == -1 
+	       && wnn_errorno != 0){
+		if (wnn_errorno != WNN_JSERVER_DEAD)
+		    message_out(message_handler,
+			"%s (%s) :%s\n", s[0], s[1], wnn_perror_lang(env->lang));
+		else
+		    message_out(message_handler, "%s\n", wnn_perror_lang(env->lang));
+		goto _Err_happend;
+	    }
+
+	}else if ((strcmp(code, "setfuzokugo") == 0) ||
+		  (strcmp(code, "setgrammar") == 0)){
+	    /* fuzokugo_set */
+	    expand_expr_all(s[0], env);
+	    if(jl_fuzokugo_set_e(env,s[0]) == -1){
+		if (wnn_errorno != WNN_JSERVER_DEAD)
+		    message_out(message_handler,
+			"%s :%s\n", s[0], wnn_perror_lang(env->lang));
+		else
+		    message_out(message_handler, "%s\n", wnn_perror_lang(env->lang));
+		goto _Err_happend;
+	    }
+	} else if (strcmp(code, "setparam") == 0){
+	    struct wnn_param para;
+	    /* setparam --- set parameter */
+	    change_ascii_to_int(s[0], &para.n);
+	    change_ascii_to_int(s[1], &para.nsho);
+	    change_ascii_to_int(s[2], &para.p1);
+	    change_ascii_to_int(s[3], &para.p2);
+	    change_ascii_to_int(s[4], &para.p3);
+	    change_ascii_to_int(s[5], &para.p4);
+	    change_ascii_to_int(s[6], &para.p5);
+	    change_ascii_to_int(s[7], &para.p6);
+	    change_ascii_to_int(s[8], &para.p7);
+	    change_ascii_to_int(s[9], &para.p8);
+
+	    change_ascii_to_int(s[10], &para.p9);
+	    change_ascii_to_int(s[11], &para.p10);
+	    change_ascii_to_int(s[12], &para.p11);
+	    change_ascii_to_int(s[13], &para.p12);
+	    change_ascii_to_int(s[14], &para.p13);
+	    change_ascii_to_int(s[15], &para.p14);
+	    change_ascii_to_int(s[16], &para.p15);
+
+	    if (js_param_set(env,&para) < 0) {
+		fclose(fp);
+		message_out(message_handler,
+		    msg_get(wnn_msg_cat, 208, NULL, env->lang), wnnrc_n);
+		    /*
+		    "�ե����� \"%s\" �ǴĶ�������ˡ����顼��ȯ����������ˡ��������ߤ��ޤ���\n",
+		    */
+		if_dead_disconnect(env, -1);
+	    }
+	} else if (strcmp(code, "confirm") == 0){
+	    confirm_state = CONFIRM;
+	}else if (strcmp(code, "confirm1") == 0){
+	    confirm_state = CONFIRM1;
+	}else if (strcmp(code, "create_without_confirm") == 0){
+	    confirm_state = CREATE_WITHOUT_CONFIRM;
+	}else if (strcmp(code, "no_create") == 0){
+	    confirm_state = NO_CREATE;
+	}
+    }
+    fclose(fp);
+    return(0);
+
+_Err_happend:
+    message_out(message_handler,
+		msg_get(wnn_msg_cat, 208, NULL, env->lang), wnnrc_n);
+		/*
+		"�ե����� \"%s\" �ǴĶ�������ˡ����顼��ȯ����������ˡ��������ߤ��ޤ���\n",
+		*/
+    fclose(fp);
+    return(-1);
+}
+
+static int
+expand_expr_all(s, env)
+struct wnn_env *env;
+register char *s;
+{
+    register char *c;
+
+    for(c = s; *c; c++){
+	if(*c == '~' || *c == '@'){
+	    if(expand_expr(c, env) == -1) return(-1);
+	}
+    }
+    return(0);
+}
+
+/* copy of js.c */
+static	char *
+getlogname()
+{
+ struct passwd *getpwuid();
+ return getpwuid(getuid())->pw_name;
+}
+
+
+static int
+expand_expr(s, env)
+struct wnn_env *env;
+ /**	~user��@HOME��@LIBDIR @ENV @USR ��Ÿ��(â����ʸ�������Ƭ�Τ�)��
+   �Ǥ��ʤ�����-1��
+   �֤ꡢ���ξ��s����Ȥ��塹�Ȥ��Τޤ�ޡ�s��Ĺ����256�Ȳ��ꤷ�Ƥ롣*/
+register char	*s;
+{
+	char	*p, *s1;
+	char	tmp[EXPAND_PATH_LENGTH];
+	int	noerr, expandsuc;
+	struct	passwd	*u;
+        extern char *getenv();
+	extern struct	passwd	*getpwnam();
+#if defined(SYSVR2) && !defined(AIXV3)
+	extern char * strchr();
+#endif
+
+	if(*s != '~' && *s != '@') return(0);
+	if((int)strlen(s) >= EXPAND_PATH_LENGTH) return(-1);
+
+	s1 = s;
+#ifdef BSD42
+	if(NULL != (p = index(++s1, '/'))){
+#else
+	if(NULL != (p = strchr(++s1, '/'))){
+#endif
+		strcpy(tmp, p);
+		*p = '\0';
+	} else *tmp = '\0';
+ /* �����ޤǤϽ�����s����Ƭ��s1�ģ�ʸ���ܡ�p�ĺǽ��'/'�Τ��ä��Ȥ���
+    �ʤ����ǰ�ö�ڤ�ˡ�tmp�Ĥ���ʸ�Υ��ԡ���*/
+
+	if(*s == '~'){
+		if(*s1){
+			noerr = expandsuc = 
+			(NULL != (u = getpwnam(s1)) &&
+			 (int)strlen(p = u -> pw_dir) + (int)strlen(tmp) <
+			 EXPAND_PATH_LENGTH );
+
+		} else {
+			noerr = expandsuc =
+			(NULL != (p = getenv("HOME")) &&
+			 (int)strlen(p) + (int)strlen(tmp) < EXPAND_PATH_LENGTH);
+		}
+
+	} else { /* then, *s must be '@' */
+		if(!strcmp(s1, "HOME")){
+			noerr = expandsuc = 
+			(NULL != (p = getenv("HOME")) &&
+			 (int)strlen(p) + (int)strlen(tmp) < EXPAND_PATH_LENGTH);
+		}else if(!strcmp(s1, "WNN_DIC_DIR")){
+	                char    buf[EXPAND_PATH_LENGTH];
+			expandsuc = 1;
+			noerr = 
+			    (NULL != (p = getenv("HOME")) &&
+			     (int)strlen(p) + (int)strlen(tmp) < EXPAND_PATH_LENGTH);
+			strcpy(buf, p);
+			strcat(buf, "/");
+
+			p = getenv("WNN_DIC_DIR");
+			if(p){
+			    strcat(buf, p);
+			}else{
+			    strcat(buf, "Wnn");
+			}
+			p = buf;
+		} else if (!strcmp(s1, "LIBDIR")){
+			noerr = expandsuc = 
+			((int)strlen(p= LIBDIR)+ (int)strlen(tmp) < EXPAND_PATH_LENGTH);
+		} else if (!strcmp(s1, "ENV")){  /* Added */
+			noerr = expandsuc = 
+			(NULL != (p = env_name(env)) &&
+			 (int)strlen(p)+ (int)strlen(tmp) < EXPAND_PATH_LENGTH);
+		}else if (!strcmp(s1, "USR")){
+			noerr = expandsuc = 
+			(NULL != (p = getlogname()) &&
+			 (int)strlen(p)+ (int)strlen(tmp) < EXPAND_PATH_LENGTH);
+		} else { /* @HOME, @LIBDIR @ENV igai ha kaenai */
+			noerr = 1; expandsuc = 0;
+		}
+	}
+
+	if(expandsuc) strcpy(s, p);
+	strcat(s, tmp);
+	return(noerr ? 0 : -1);
+}
+
+static int
+change_ascii_to_int(st,dp)
+register char *st;
+int *dp;
+{
+    register int total,flag;
+
+    total = 0;
+    flag = 0;
+    while(*st != NULL){
+	if (isdigit(*st)){
+	    total = total * 10 + (*st - '0');
+	} else if (*st == '+') {
+	    if (flag != 0) { return(-1); }
+	    flag = 1;
+	} else if (*st == '-') {
+	    if (flag != 0) { return(-1); }
+	    flag = -1;
+	} else { return(-1); }
+	st++;
+    }
+    if (flag == 0){
+	flag = 1;
+    }
+    *dp = total * flag;
+    return(1);
+}
+
+static int
+file_exist(env, n)
+struct wnn_env *env;
+char *n;
+{
+    if(n[0] == C_LOCAL){
+ 	wnn_errorno = 0;
+ 	return(access(n + 1, 4));
+     }else{
+	 return(js_access(env,n,4));
+    }
+}    
+
+static int
+create_file(env,n, d, fid, pwd_dic, pwd_hindo, error_handler, message_handler)
+register struct wnn_env *env;
+char *n;
+int d;
+int fid;
+char *pwd_dic, *pwd_hindo;
+int  (*error_handler)(), (*message_handler)();
+{
+    char pwd[WNN_PASSWD_LEN], hpwd[WNN_PASSWD_LEN];
+    int rev_dict_type;
+
+    if(
+       make_dir_rec1(env, n, error_handler, message_handler) == -1){
+	wnn_errorno = WNN_MKDIR_FAIL;
+	return(-1);
+    }
+    if(d == HINDO){
+	if(create_pwd_file(env, pwd_hindo, error_handler, message_handler) == -1)return(-1);
+	if(get_pwd(pwd_hindo, hpwd) == -1)return(-1);
+	if(n[0] == C_LOCAL){
+	    if(js_hindo_file_create_client(env, fid, n + 1, NULL, hpwd) == -1){
+		message_out(message_handler, wnn_perror_lang(env->lang));
+		if_dead_disconnect(env, -1);
+	    }else{
+		message_out(message_handler,
+			    "%s \"%s\" %s",
+			    msg_get(wnn_msg_cat, 203, NULL, env->lang),
+			    n,
+			    msg_get(wnn_msg_cat, 209, NULL, env->lang));
+			    /*
+			    "���٥ե����� \"%s\" ����ޤ�����",
+			    */
+		chown(n + 1, getuid(), -1); /* H.T. */
+		return(0);
+	    }
+	}else{
+	    if(js_hindo_file_create(env, fid, n, NULL, hpwd) == -1){
+		message_out(message_handler, wnn_perror_lang(env->lang));
+		if_dead_disconnect(env, -1);
+	    }else{
+		message_out(message_handler,
+			    "%s \"%s\" %s",
+			    msg_get(wnn_msg_cat, 203, NULL, env->lang),
+			    n,
+			    msg_get(wnn_msg_cat, 209, NULL, env->lang));
+			    /*
+			    "���٥ե����� \"%s\" ����ޤ�����",
+			    */
+		return(0);
+	    }
+	}
+    }else {
+	if(create_pwd_file(env, pwd_hindo, error_handler, message_handler) == -1)return(-1);
+	if(get_pwd(pwd_hindo, hpwd) == -1)return(-1);
+	if(create_pwd_file(env, pwd_dic, error_handler, message_handler) == -1)return(-1);
+	if(get_pwd(pwd_dic, pwd) == -1)return(-1);
+
+#ifdef	CONVERT_with_SiSheng
+	if(!strncmp(js_get_lang(env), WNN_C_LANG, 5) ||
+	   !strncmp(js_get_lang(env), WNN_T_LANG, 5))
+	    rev_dict_type = CWNN_REV_DICT;
+	else
+#endif
+	    rev_dict_type = WNN_REV_DICT;
+
+	if(n[0] == C_LOCAL){
+	    if(js_dic_file_create_client(env, n + 1, rev_dict_type,
+						NULL, pwd, hpwd) == -1){
+		message_out(message_handler, wnn_perror_lang(env->lang));
+		if_dead_disconnect(env, -1);
+	    }else{
+		message_out(message_handler,
+			    "%s \"%s\" %s",
+			    msg_get(wnn_msg_cat, 200, NULL, env->lang),
+			    n,
+			    msg_get(wnn_msg_cat, 209, NULL, env->lang));
+			    /*
+			    "����ե����� \"%s\" ����ޤ�����",
+			    */
+		chown(n + 1, getuid(), -1);
+		return(0);
+	    }
+	}else{
+	    if(js_dic_file_create(env, n, rev_dict_type, NULL, pwd, hpwd)== -1){
+		message_out(message_handler, wnn_perror_lang(env->lang));
+		if_dead_disconnect(env, -1);
+	    }else{
+		message_out(message_handler,
+			    "%s \"%s\" %s",
+			    msg_get(wnn_msg_cat, 200, NULL, env->lang),
+			    n,
+			    msg_get(wnn_msg_cat, 209, NULL, env->lang));
+			    /*
+			    "����ե����� \"%s\" ����ޤ�����",
+			    */
+		return(0);
+	    }
+	}
+    }
+}
+
+static int
+make_dir_rec1(env, path, error_handler, message_handler)
+struct wnn_env *env;
+register char *path;
+int  (*error_handler)(), (*message_handler)();
+{
+    char gomi[128];
+    register char *c;
+    for(c = path;*c;c++){
+	if(*c == '/'){
+	    strncpy(gomi,path,c - path);
+	    gomi[c - path] = 0;
+	    if(make_dir1(env, gomi, error_handler, message_handler) == -1){
+		return(-1);
+	    }
+	}
+    }
+    return(0);
+}
+
+static int
+make_dir1(env, dirname, error_handler, message_handler)
+register struct wnn_env *env;
+register char *dirname;
+int  (*error_handler)(), (*message_handler)();
+{
+    char gomi[128];
+    if(dirname[0] == C_LOCAL){
+	if(*(dirname + 1) == 0) return(0);
+	if(access(dirname + 1 , 0) == 0){ /* check for existence */
+	    return(0); /* dir already exists */ 
+	}
+    }else{
+	if(*dirname == 0) return(0);
+	if(js_access(env, dirname , 0) == 0){ /* check for existence */
+	    return(0); /* dir already exists */ 
+	}
+    }
+    if((int)error_handler != WNN_CREATE){
+	sprintf(gomi, "%s \"%s\" %s%s",
+		msg_get(wnn_msg_cat, 210, NULL, env->lang),
+		dirname,
+		msg_get(wnn_msg_cat, 201, NULL, env->lang),
+		msg_get(wnn_msg_cat, 202, NULL, env->lang));
+		/*
+		"directry \"%s\" ��̵���衣���?(Y/N)",
+		*/
+	if(call_error_handler(error_handler,gomi) == 0){
+	    wnn_errorno = WNN_MKDIR_FAIL;
+	    return(-1);
+	}
+    }
+    if(dirname[0] == C_LOCAL){  /* Create Directory */
+#define	MODE (0000000 | 0000777)
+#if defined(BSD42) || defined(uniosu)
+	if(mkdir(dirname + 1 , MODE ) != 0 ){
+	    wnn_errorno=WNN_MKDIR_FAIL;
+	    return(-1);
+	}
+#endif
+#if defined(SYSVR2) && !defined(uniosu)
+	char buf[256];
+	strcpy(buf , "/bin/mkdir ");
+	strcat(buf ,dirname + 1 );
+	if(system(buf) != 0){
+	    /*
+	    wnn_errorno=WNN_MKDIR_FAIL;
+	    return(-1);
+	    */
+	}
+#endif
+	chmod(dirname + 1,MODE);
+	chown(dirname + 1, getuid(), -1);
+    }else{
+	if(js_mkdir(env, dirname)){
+	    if_dead_disconnect(env, -1);
+	}
+    }
+    return(0);
+}
+
+
+static  int
+call_error_handler(error_handler, c)
+int (*error_handler)();
+char *c;
+{
+    register int x;
+    x = error_handler(c);
+    if(confirm_state == CONFIRM1){
+	if(x) confirm_state = CREATE_WITHOUT_CONFIRM;
+	else  confirm_state = NO_CREATE;
+    }
+    return(x);
+}
+
+static void
+message_out(message_handler, format, s1, s2, s3, s4, s5, s6, s7, s8)
+int (*message_handler)();
+char *format;
+int s1, s2, s3, s4, s5, s6, s7, s8;
+{
+    char buf[256];
+
+    if(message_handler){
+	sprintf(buf, format, s1, s2, s3, s4, s5, s6, s7, s8);
+	(*message_handler)(buf);
+    }
+}
+
+
+int
+jl_yomi_len(buf, bun_no, bun_no2) 
+struct wnn_buf *buf;
+register int bun_no, bun_no2;
+{
+    register int len = 0;
+
+    wnn_errorno = 0;
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0)
+	bun_no2 = buf->bun_suu;
+    for(;bun_no < bun_no2;bun_no++){
+	len += buf->bun[bun_no]->yomilen;
+    }
+    return(len);
+}
+
+
+int
+jl_kanji_len(buf, bun_no, bun_no2)
+struct wnn_buf *buf;
+register int bun_no, bun_no2;
+{
+    register int len = 0;
+
+    wnn_errorno = 0;
+    if(bun_no < 0) return(0); 
+    if(bun_no2 >= buf->bun_suu || bun_no2 < 0)
+	bun_no2 = buf->bun_suu;
+    for(;bun_no < bun_no2;bun_no++){
+	len += buf->bun[bun_no]->kanjilen;
+    }
+    return(len);
+}
+
+int wnn_word_use_initial_hindo = 0;
+
+int
+jl_word_use_e(env, dic_no, entry)
+register struct wnn_env *env;
+int dic_no, entry;
+{
+    register struct wnn_jdata *jd;
+
+    wnn_errorno = 0;
+    if(js_word_info(env,dic_no,entry, &rb) == -1)
+	if_dead_disconnect(env, -1);
+    jd = (struct wnn_jdata *)(rb.buf);
+    if(jd->hindo != -1){
+	if(js_hindo_set(env, dic_no, entry,WNN_IMA_OFF, WNN_ENTRY_NO_USE) == -1) {
+	    if_dead_disconnect(env, -1);
+	}
+    }else{
+	if(js_hindo_set(env, dic_no, entry,
+			(wnn_word_use_initial_hindo & 0x80) ?
+				WNN_IMA_ON : WNN_IMA_OFF ,
+			wnn_word_use_initial_hindo & 0x7f) == -1) {
+	    if_dead_disconnect(env, -1);
+	}
+    }
+    return(0);
+}    
+
+void
+jl_env_set(buf, env)
+register struct wnn_env *env;
+register struct wnn_buf *buf;
+{
+    wnn_errorno = 0;
+    buf->env = env;
+}
+
+
+struct wnn_env *
+jl_env_get(buf)
+register struct wnn_buf *buf;
+{
+
+    wnn_errorno = 0;
+    return(buf->env);
+}
+
+
+int
+jl_param_set_e(env, para)
+register struct wnn_env *env;
+struct wnn_param *para;
+{
+    register int x;
+
+    wnn_errorno = 0;
+    if((x = js_param_set(env, para)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+
+int
+jl_param_get_e(env, para)
+struct wnn_env *env;
+struct wnn_param *para;
+{
+    register int x;
+    wnn_errorno = 0;
+    if((x = js_param_get(env, para)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+
+
+int
+jl_dic_use_e(env, dic_no, flag)
+struct wnn_env *env;
+int	dic_no,flag;
+{
+    register int x;
+    wnn_errorno = 0;
+    if((x = js_dic_use(env, dic_no, flag)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+
+int
+jl_word_add_e(env, dic_no, yomi, kanji, comment, hinsi, init_hindo)
+struct wnn_env *env;
+int	dic_no;
+w_char	*yomi,*kanji,*comment;
+int	hinsi,init_hindo;
+
+{
+    register int x;
+    wnn_errorno = 0;
+    if((x = js_word_add(env, dic_no, yomi, kanji, comment, hinsi, init_hindo)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+
+int
+jl_word_delete_e(env, dic_no, entry)
+struct wnn_env *env;
+int	dic_no;
+int	entry;
+{
+    register int x;
+    wnn_errorno = 0;
+    if((x = js_word_delete(env, dic_no, entry)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+
+static int
+file_read(env, fname)
+struct wnn_env *env;
+char *fname;
+{
+    register int fid;
+    if(fname[0] == C_LOCAL){
+	fid = js_file_send(env, fname + 1);
+    }else{
+	fid = js_file_read(env, fname);
+    }
+    if(fid >= 0){
+	add_file_to_env(env, fid, fname);
+    }
+    return(fid);
+}
+
+static int
+file_remove(server, fname, pwd)
+register WNN_JSERVER_ID *server;
+char *fname;
+char *pwd;
+{
+    if(fname[0] == C_LOCAL){
+	return(js_file_remove_client(server, fname + 1, pwd));
+    }else{
+	return(js_file_remove(server, fname, pwd));
+    }
+}
+
+
+static int
+file_discard(env, fid)
+register struct wnn_env *env;
+register int fid;
+{
+    delete_file_from_env(env, fid);
+    return(js_file_discard(env, fid));
+}
+
+int
+jl_hinsi_number_e(env, name)
+register struct wnn_env *env;
+w_char *name;
+{
+    register int x;
+    wnn_errorno = 0;
+    if((x = js_hinsi_number(env->js_id, name)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+
+w_char *jl_hinsi_name_e(env, no)
+register struct wnn_env *env;
+register int no;
+{
+    wnn_errorno = 0;
+    if(js_hinsi_name(env->js_id, no, &rb) == -1)
+	if_dead_disconnect(env, NULL);
+    return ((w_char *)(rb.buf));
+}
+
+int
+jl_hinsi_list_e(env, dic_no, name, area)
+register struct wnn_env *env;
+int dic_no;
+w_char *name;
+w_char ***area;
+{
+    int x;
+    wnn_errorno = 0;
+    if((x = js_hinsi_list(env, dic_no, name, &rb)) == -1)
+	if_dead_disconnect(env, -1);
+    *area = (w_char **)(rb.buf);
+    return(x);
+}
+
+int
+jl_hinsi_dicts_e(env, no, area)
+register struct wnn_env *env;
+int no;
+int **area;
+{
+    int x;
+    wnn_errorno = 0;
+    if((x = js_hinsi_dicts(env, no, &rb)) == -1)
+	if_dead_disconnect(env, -1);
+    *area = (int *)(rb.buf);
+    return(x);
+}
+
+
+int
+jl_word_comment_set_e(env, dic_no, entry, comment)
+register struct wnn_env *env;
+int	dic_no,entry;
+w_char *comment;
+{
+    register int x;
+    wnn_errorno = 0;
+    if((x = js_word_comment_set(env, dic_no, entry, comment)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+
+int
+jl_dic_comment_set_e(env, dic_no, comment)
+register struct wnn_env *env;
+int dic_no;
+w_char *comment;
+{
+    register int x;
+    WNN_DIC_INFO dic;
+    WNN_FILE_INFO_STRUCT file;
+
+    wnn_errorno = 0;
+    if(js_dic_info(env,dic_no,&dic) < 0)
+	    if_dead_disconnect(env, -1);
+    /*	dic Body	*/
+    if (js_file_info(env,dic.body,&file) < 0)
+	    if_dead_disconnect(env, -1);
+    if((x = js_file_comment_set(env, file.fid, comment)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+
+#ifdef nodef  /*���̤δ֡����٥ե�����Υ����Ȥϥ桼���˸����ʤ���*/
+int
+jl_hindo_comment_set_e(env, dic_no, comment)
+register struct wnn_env *env;
+int dic_no;
+w_char *comment;
+{
+    register int x;
+    WNN_DIC_INFO dic;
+    WNN_FILE_INFO_STRUCT file;
+
+    wnn_errorno = 0;
+    if(js_dic_info(env,dic_no,&dic) < 0)
+	    if_dead_disconnect(env, -1);
+    /*	dic Body	*/
+    if(dic.hindo == -1){
+	wnn_errorno = WNN_NO_HINDO_FILE;
+	return(-1);
+    }
+    if (js_file_info(env,dic.hindo,&file) < 0)
+	    if_dead_disconnect(env, -1);
+    if((x = js_file_comment_set(env, file.fid, comment)) == -1)
+	if_dead_disconnect(env, -1);
+    return (x);
+}
+#endif
diff --git a/wnn/jllib.h b/wnn/jllib.h
new file mode 100644
index 0000000000000000000000000000000000000000..9b12deb53c8100b473450cf70b6c4e02e679d047
--- /dev/null
+++ b/wnn/jllib.h
@@ -0,0 +1,322 @@
+/*
+ * $Id: jllib.h,v 1.1 1996/03/13 09:56:49 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/*
+	Nihongo	Henkan	Library Header File
+*/
+
+#ifndef JLLIB
+#ifndef JSLIB
+#include "jslib.h"
+#endif
+
+#define JLLIB
+
+/*
+   �桼�����ץ������ϡ�ľ�ܤ��ι�¤�Τ����Ƥ򥢥���������ɬ�פ�̵���Ϥ���
+   �饤�֥��ؿ����Ѥ��뤳�ȡ�
+*/
+
+#define WNN_YOMI_SIZE 10
+
+typedef struct wnn_jl_bun WNN_BUN;
+
+struct wnn_jl_bun {
+	int	jirilen;	/* ����ʸ��μ�Ω�� */
+	int	dic_no;
+	int	entry;
+	int	kangovect;	/* ��³�٥��ȥ�ơ��֥�ؤΥݥ��� */
+	int	hinsi;		/* �ʻ� */
+	int	hindo  :16;		/* ����(������) */
+	int	ref_cnt :4;		/* ʸ��ꥹ�Ȥ˻Ȥ��Ƥ��� */
+	/* BUG FIX signed --> unsigned */
+	unsigned int ima :1;		/* ���Ȥä���ӥå� */
+	unsigned int hindo_updated :1;    /* ����ʸ������٤Ϲ�������Ƥ��� */
+	unsigned int nobi_top :1;	/* ���Ф��̤ߤ�Ԥä����򼨤���*/
+	/* egg �ߤ����˿��Ф��̤ߤ򷫤��֤��Ԥ����ˡ�����˸�������κ�
+	   �Ȥä��� �ӥåȤ� ��Ȥ��ƤϤʤ�ʤ���*/
+	unsigned int dai_top :1;	/* ��ʸ�����Ƭ */
+	unsigned int dai_end :1; /* ��ʸ���saigo *//* ������ nomi */
+	unsigned int from_zenkouho :2;	/*�����䤫�����򤵤줿ʸ�ᤫ�ɤ��� */
+	unsigned int bug :1;			/* BUG FIX �Ȥꤢ���� */
+	/* BUG FIX signed --> unsigned */
+	int 	hyoka;
+	int 	daihyoka;
+	short yomilen;
+	short kanjilen;
+	WNN_BUN *down; /* ���Ȥä���ӥåȤ���Ȥ��оݤ�ʸ�� */
+	w_char   yomi[WNN_YOMI_SIZE];        /* �ɤߡ����������롣�����ڤ�ʤ����ˤ�
+				    ���ˤĤʤ��� */
+	WNN_BUN *next;		/* ���Υ��ȥ饯�ȤؤΥݥ��� */
+	WNN_BUN *free_next;		/* ���Υ��ȥ饯�ȤؤΥݥ��� */
+};
+    
+
+struct wnn_buf {
+    struct wnn_env *env;	/* �� */
+    int bun_suu;		/* ʸ��� */
+    int zenkouho_suu;		/* ������ο� */
+    WNN_BUN **bun;		/* ʸ��ؤΥݥ��� */
+    WNN_BUN **down_bnst; /* ���Ȥä���ӥåȤ���Ȥ��оݤ�ʸ�� */
+
+    WNN_BUN **zenkouho;		/* ������ؤΥݥ��� */
+    int *zenkouho_dai;		/* daibunsetsu zenkouho */
+    int zenkouho_dai_suu;	/* daibunsetsu zenkouho suu */
+
+    short c_zenkouho;		/* �������桢���ܤ��Ƥ������ */
+    short zenkouho_daip;
+    int zenkouho_bun;		/* ��������äƤ���ʸ�� */
+    int zenkouho_end_bun;	/* ������(dai)���äƤ���Ǹ��ʸ�� */
+    int zenkouho_endvect;	/* ��������ä� endvect *//* ADD KURI */
+
+    WNN_BUN *free_heap;
+    char *heap;		/* linked list of alloced area */
+    int msize_bun;
+    int msize_zenkouho;
+};
+
+
+#define WNN_SHO 0
+#define WNN_DAI 1
+
+#define WNN_NO_USE    0
+#define WNN_USE_MAE   1
+#define WNN_USE_ATO   2
+#define WNN_USE_ZENGO (WNN_USE_MAE | WNN_USE_ATO)
+/* #define WNN_ZENGO_YUUSEN 4 */
+
+#define WNN_UNIQ_KNJ 2
+#define WNN_UNIQ 1
+#define WNN_NO_UNIQ  0
+
+#define WNN_NO_CREATE 0
+#define WNN_CREATE (-1)
+
+#define WNN_DIC_PRIO_DEFAULT 5
+
+#define WNN_YOMI 0
+#define WNN_KANJI 1
+
+#define jl_next(buf) jl_set_jikouho((buf), (buf)->c_zenkouho + 1)
+
+#define jl_previous(buf) jl_set_jikouho((buf), (buf)->c_zenkouho - 1)
+
+#define jl_next_dai(buf) jl_set_jikouho_dai((buf), (buf)->c_zenkouho + 1)
+
+#define jl_previous_dai(buf) jl_set_jikouho_dai((buf), (buf)->c_zenkouho - 1)
+
+#define jl_get_kanji(buf, bun_no, bun_no2, area)\
+                   wnn_get_area(buf, bun_no, bun_no2, area, WNN_KANJI)
+
+#define jl_get_yomi(buf, bun_no, bun_no2, area)\
+                   wnn_get_area(buf, bun_no, bun_no2, area, WNN_YOMI)
+
+#define jl_bun_suu(buf) ((buf)->bun_suu)
+
+#define jl_zenkouho_suu(buf) ((buf)->zenkouho_daip? (buf)->zenkouho_dai_suu:(buf)->zenkouho_suu)
+
+#define jl_zenkouho_bun(buf) ((buf)->zenkouho_bun)
+
+#define jl_c_zenkouho(buf) ((buf)->c_zenkouho)
+
+#define jl_zenkouho_daip(buf) ((buf)->zenkouho_daip)
+
+#define jl_dai_top(buf, k) ((buf)->bun[k]->dai_top)
+
+#define jl_jiri_len(buf, k) ((buf)->bun[k]->jirilen)
+
+#define jl_fuzoku_len(buf, k) \
+		(jl_yomi_len((buf), k, k+1) - jl_jiri_len((buf), k))
+
+#define jl_jiri_kanji_len(buf, k) \
+		(jl_kanji_len((buf), k, k+1) - jl_fuzoku_len((buf), k))
+
+/* Macros to create library functions from "_e" libraries */
+
+#define jl_env(buf) 	((buf)->env)
+
+#define jl_dic_add(buf,dic_name,hindo_name,rev, prio,rw, hrw, pwd_dic, pwd_hindo, error_handler, message_handler)\
+    jl_dic_add_e(jl_env(buf),dic_name,hindo_name,rev,prio,rw, hrw, pwd_dic,\
+		      pwd_hindo, error_handler, message_handler)
+
+#define jl_fuzokugo_set(buf, fname)  jl_fuzokugo_set_e(jl_env(buf), fname) 
+
+#define jl_fuzokugo_get(buf, fname)  jl_fuzokugo_get_e(jl_env(buf), fname) 
+
+
+#define jl_dic_save(buf,dic_no) jl_dic_save_e(jl_env(buf),dic_no)
+
+#define jl_dic_save_all(buf)	jl_dic_save_all_e(jl_env(buf))
+
+#define jl_dic_list(buf, dip)	jl_dic_list_e(jl_env(buf), dip)
+
+#define jl_word_search(buf,dic_no, yomi, jdp) \
+    jl_word_search_e(jl_env(buf),dic_no, yomi, jdp)
+
+#define jl_word_search_by_env(buf, yomi, jdp) \
+    jl_word_search_by_env_e(jl_env(buf), yomi, jdp)
+
+#define jl_word_use(buf, dic_no, entry) \
+    jl_word_use_e(jl_env(buf), dic_no, entry)
+
+
+#define jl_param_set(buf, param) jl_param_set_e(jl_env(buf), param)
+
+#define jl_param_get(buf, param) jl_param_get_e(jl_env(buf), param)
+
+#define jl_dic_delete(buf, dic_no) jl_dic_delete_e(jl_env(buf), dic_no)
+
+#define jl_dic_use(buf, dic_no, flag) jl_dic_use_e(jl_env(buf), dic_no, flag)
+
+#define jl_word_add(buf, dic, yomi, kanji, com, hinsi, hindo) \
+    jl_word_add_e(jl_env(buf), dic, yomi, kanji, com, hinsi, hindo)
+
+#define jl_word_delete(buf, dic, entry)\
+    jl_word_delete_e(jl_env(buf), dic, entry)
+
+#define jl_word_info(buf, dic_no, entry)\
+    jl_word_info_e(jl_env(buf), dic_no, entry)
+
+#define jl_inspect(buf, bun_no)\
+    jl_word_info(buf, (buf)->bun[bun_no]->dic_no,(buf)->bun[bun_no]->entry)
+
+#define jl_hinsi_number(buf, name) jl_hinsi_number_e(jl_env(buf), name)
+
+#define jl_hinsi_name(buf, no) jl_hinsi_name_e(jl_env(buf), no)
+
+#define jl_word_comment_set(buf, dic, entry, comm) \
+    jl_word_comment_set_e((buf)->env, dic, entry, comm)
+
+#define jl_dic_comment_set(buf, dic, comm) \
+    jl_dic_comment_set_e((buf)->env, dic, comm)
+
+#define jl_hinsi_list(buf, dic_no, name, area) \
+    jl_hinsi_list_e(jl_env(buf), dic_no, name, area)
+
+#define jl_hinsi_dicts(buf, no, area) \
+    jl_hinsi_dicts_e(jl_env(buf), no, area)
+
+#ifdef nodef  /*���̤δ֡����٥ե�����Υ����Ȥϥ桼���˸����ʤ���*/
+    #define jl_hindo_comment_set(buf, dic, comm) \
+        jl_hindo_comment_set_e((buf)->env, dic, comm)
+#endif
+
+#define jl_isconnect(buf)	jl_isconnect_e((buf)->env)
+
+#define jl_env_sticky(buf)	js_env_sticky((buf)->env)
+#define jl_env_sticky_e(env)	js_env_sticky(env)
+#define jl_env_un_sticky(buf)	js_env_un_sticky((buf)->env)
+#define jl_env_un_sticky_e(env)	js_env_un_sticky(env)
+
+/* for select server by useing $LANG */
+#define	jl_open(env_n, server_n, wnnrc_n, error_handler, message_handler, timeout) \
+    jl_open_lang(env_n, server_n, NULL, wnnrc_n, error_handler, message_handler, timeout)
+
+#define	jl_connect(env_n, server_n, wnnrc_n, error_handler, message_handler, timeout) \
+    jl_connect_lang(env_n, server_n, NULL, wnnrc_n, error_handler, message_handler, timeout)
+#define	jl_get_lang(buf)	js_get_lang((buf)->env)
+#define	jl_set_lang(buf, lang)	js_set_lang((buf)->env, lang)
+
+/* extern function defines */
+extern struct wnn_buf *jl_open_lang();
+extern struct wnn_env *jl_connect_lang();
+extern struct wnn_env *jl_env_get();
+extern struct wnn_jdata *jl_word_info_e();
+extern w_char *jl_hinsi_name_e();
+
+extern void jl_close();
+extern int jl_dic_add_e();
+extern int jl_dic_comment_set_e();
+extern int jl_dic_delete_e();
+extern int jl_dic_list_e();
+extern int jl_dic_save_all_e();
+extern int jl_dic_save_e();
+extern int jl_dic_use_e();
+extern void jl_disconnect();
+extern void jl_disconnect_if_server_dead();
+extern void jl_env_set();
+extern int jl_fuzokugo_get_e();
+extern int jl_fuzokugo_set_e();
+extern void jl_get_zenkouho_kanji();
+extern int jl_hinsi_dicts_e();
+extern int jl_hinsi_list_e();
+extern int jl_hinsi_number_e();
+extern int jl_isconnect_e();
+extern int jl_kanji_len();
+extern int jl_kill();
+extern int jl_nobi_conv();
+extern int jl_nobi_conv_e2();
+extern int jl_param_get_e();
+extern int jl_param_set_e();
+extern int jl_ren_conv();
+extern int jl_set_env_wnnrc();
+extern int jl_set_env_wnnrc1();
+extern int jl_set_jikouho();
+extern int jl_set_jikouho_dai();
+extern int jl_tan_conv();
+extern int jl_update_hindo();
+extern int jl_word_add_e();
+extern int jl_word_comment_set_e();
+extern int jl_word_delete_e();
+extern int jl_word_search_by_env_e();
+extern int jl_word_search_e();
+extern int jl_word_use_e();
+extern int jl_yomi_len();
+extern int jl_zenkouho();
+extern int jl_zenkouho_dai();
+extern int wnn_get_area();
+
+extern char *wnn_perror();
+extern char *wnn_perror_lang();
+
+#ifdef  CONVERT_by_STROKE
+extern void jl_get_zenkouho_yomi();
+#endif
+#endif	/* JLLIB */
diff --git a/wnn/js.c b/wnn/js.c
new file mode 100644
index 0000000000000000000000000000000000000000..4734b399f7e5a34825cad8f9c57f7610f6db0259
--- /dev/null
+++ b/wnn/js.c
@@ -0,0 +1,2612 @@
+/*
+ * $Id: js.c,v 1.1 1996/03/13 09:56:51 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4
+ */
+/*
+	Nihongo Henkan Library
+*/
+/*
+	entry functions
+
+	js_open_lang	js_close
+	js_change_current_jserver
+	js_connect_lang	js_disconnect
+	js_isconnect
+
+	js_param_get	js_param_set
+
+	js_access	js_mkdir
+
+	js_get_lang	js_set_lang
+
+
+extern	Variables
+	int	wnn_errorno;
+*/
+
+
+extern	char	*malloc();
+
+#include <stdio.h>
+#include <ctype.h>
+#ifdef UX386
+#include <X11/Xos.h>
+#else
+#include <fcntl.h>
+#endif
+#include <pwd.h>
+#ifndef UX386
+#include <sys/types.h>
+#endif
+#include <sys/stat.h>
+#include <errno.h>
+extern int errno;
+#include <signal.h>
+#include "jd_sock.h"
+#include "commonhd.h"
+#include "demcom.h"
+#include "config.h"
+
+#include "wnnerror.h"
+/*#include "commonhd.h"*/
+#include "jslib.h"
+#include "jh.h"
+
+#include "msg.h"
+
+#define JS			/* For include ../etc/bdic.c */
+#include "bdic.c"
+#include "pwd.c"
+
+char *malloc();
+
+#ifdef SYSVR2
+#define	bzero(adr,n)	memset((adr),0,(n))
+#endif
+
+int	wnn_errorno	=0;
+struct msg_cat *wnn_msg_cat = NULL;
+
+/*	j Lib.	*/
+
+static	int		current_sd;		/** �����å�fd	**/
+static	WNN_JSERVER_ID	*current_js = NULL;
+
+
+/*	Packet Buffers		*/
+static	unsigned char	snd_buf[S_BUF_SIZ];	/** ���� **/
+static	int	sbp=0;			/** �����Хåե����ݥ��󥿡� **/
+static	int	rbc= -1;		/** �����Хåե����ݥ��󥿡� **/
+
+#if defined(EAGAIN)
+# if defined(EWOULDBLOCK)
+# define ERRNO_CHECK(no) 	((no) == EAGAIN || (no) == EWOULDBLOCK)
+# else /* defined(EWOULDBLOCK) */
+# define ERRNO_CHECK(no)	((no) == EAGAIN)
+# endif /* defined(EWOULDBLOCK) */
+#else /* defined(EAGAIN) */
+# if defined(EWOULDBLOCK)
+# define ERRNO_CHECK(no)	((no) == EWOULDBLOCK)
+# else /* defined(EWOULDBLOCK) */
+# define ERRNO_CHECK(no)	(0)
+# endif /* defined(EWOULDBLOCK) */
+#endif /* defined(EAGAIN) */
+
+static void connect_timeout();
+static int _get_server_name();
+static int writen();
+static char *get_unixdomain_of_serv_defs(), *get_service_of_serv_defs();
+static int get_port_num_of_serv_defs();
+
+
+/*********	V4	*****************/
+/***
+	jserver_dead Macro
+***/
+
+static	jmp_buf	current_jserver_dead;
+
+#define	handler_of_jserver_dead(err_val) \
+{ \
+    if (current_js) { \
+	if(current_js->js_dead){wnn_errorno=WNN_JSERVER_DEAD;return err_val;}\
+	if(setjmp(current_jserver_dead)){ \
+		wnn_errorno=WNN_JSERVER_DEAD; \
+		return err_val; \
+	} \
+	wnn_errorno = 0; /* here initialize wnn_errorno; */    \
+    } \
+}
+
+static void
+set_current_js(server)
+register WNN_JSERVER_ID *server;
+{
+ current_js = server;
+ current_sd = current_js->sd;
+}
+
+/**	�ǡ���󤬻������Τ���θ����	**/
+static void
+demon_dead()
+{
+ current_js->js_dead= -1;
+ wnn_errorno= WNN_JSERVER_DEAD;
+ shutdown(current_sd, 2);
+ close(current_sd);
+#if DEBUG
+	fprintf(stderr,"jslib:JSERVER %s is Dead\n",current_js->js_name);
+#endif
+ if(current_js->js_dead_env_flg){
+	longjmp(current_js->js_dead_env,666);
+ }
+ longjmp(current_jserver_dead,666);
+/* never reach */
+}
+
+
+/**
+	�����åȤ򥪡��ץ󤷤�current_sd�˥����å�fd���֤�
+			(cd�Ȥ����Τϥ��ߥ�˥��������ǥХ�����̾��)
+**/
+static int
+cd_open(lang)
+register char *lang;
+{
+#ifdef AF_UNIX
+    int sd;
+    struct sockaddr_un saddr;		/** �����å� **/
+    char *sock_name = NULL;
+    saddr.sun_family = AF_UNIX;
+
+    /* find socket name from table by lang */
+    if (lang && *lang) {
+	if ((sock_name = get_unixdomain_of_serv_defs(lang)) == NULL) {
+	    sock_name = sockname;
+	}
+    } else {
+	sock_name = sockname;		/* Jserver */
+    }
+    strcpy(saddr.sun_path, sock_name);
+	    
+    if ((sd = socket(AF_UNIX,SOCK_STREAM, 0)) == ERROR) {
+#if DEBUG
+	xerror("jslib:Can't create socket.\n");
+#endif
+	return -1;
+    }
+    if (connect(sd,(caddr_t)&saddr,strlen(saddr.sun_path)+sizeof(saddr.sun_family)) == ERROR) {
+
+#if DEBUG
+	xerror("jslib:Can't connect socket.\n");
+#endif
+	close(sd);
+	return -1;
+    }
+    return sd;
+#else
+    return -1;
+#endif
+}
+
+static int
+cd_open_in(server, lang, timeout)
+register char *server;
+register char *lang;
+register int timeout;
+{
+    int sd;
+    struct sockaddr_in saddr_in;		/** �����å� **/
+    struct servent *sp = NULL;
+    register struct hostent *hp;
+    int serverNO, port_num;
+    int ret;
+    char pserver[64];
+    char sserver[64];
+    char *serv_name = NULL;
+
+    serverNO = _get_server_name(server, pserver);
+
+    /* find service name from table by lang */
+    if (lang && *lang) {
+	if ((serv_name = get_service_of_serv_defs(lang)) == NULL) {
+	    strcpy(sserver, SERVERNAME);
+	} else {
+	    strcpy(sserver, serv_name);
+	}
+    } else {
+/*
+	serv_name = SERVERNAME;
+*/
+	strcpy(sserver, SERVERNAME);
+    }
+/*
+    if ((sp = getservbyname(serv_name,"tcp")) != NULL) {
+*/
+    if ((sp = getservbyname(sserver,"tcp")) != NULL) {
+	serverNO += ntohs(sp->s_port);
+    } else {
+	if ((port_num = get_port_num_of_serv_defs(lang)) == -1) {
+	    serverNO += WNN_PORT_IN;
+	} else {
+	    serverNO += port_num;
+	}
+    }
+    if ((hp = gethostbyname(pserver)) == NULL) { return  -1; }
+    bzero((char *)&saddr_in,sizeof(saddr_in));
+    bcopy(hp->h_addr,(char *)&saddr_in.sin_addr, hp->h_length);
+    saddr_in.sin_family = AF_INET;
+    saddr_in.sin_port = htons(serverNO);
+    if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == ERROR){
+#if DEBUG
+	xerror("jslib:Can't create Inet socket.\n");
+#endif
+	return -1 ;
+    }
+
+    if (timeout != 0 && timeout > 0) {
+	signal(SIGALRM, connect_timeout);
+	alarm(timeout);
+    }
+    ret = connect(sd, (caddr_t)&saddr_in, sizeof(saddr_in));
+    if (timeout != 0 && timeout > 0) {
+	alarm(0);
+	signal(SIGALRM, SIG_IGN);
+    }
+    if (ret == ERROR) {
+#if DEBUG
+	xerror("jslib:Can't connect Inet socket.\n");
+#endif
+	close(sd);
+	return -1 ;
+    }
+    return sd;
+}
+
+static void
+connect_timeout()
+{
+}
+
+/* get server name and return serverNo */
+static int
+_get_server_name(server, pserver)
+char *server;
+char *pserver;
+{
+    register char *p;
+    strcpy(pserver, server);
+    p = pserver;
+    for( ; *p && *p != ':'; p++) ;
+    if (!*p) return(0);	/* does not have a colon */
+    *p = 0;
+    return(atoi(++p));
+}
+
+/*	Packet SND/RCV subroutines	*/
+static void put4com();
+
+/**	�ѥ��åȤΥإå���������	**/
+static void
+snd_head(cmd)
+int cmd;	/** cmd=���ޥ�� **/
+{
+ sbp=0;
+ put4com(cmd);
+ rbc= -1;
+}
+
+/**	�ѥ��åȤΥإå���������	**/
+static int
+snd_env_head(env,cmd)
+register struct wnn_env *env;
+int cmd;	/** cmd=���ޥ�� **/
+{
+ snd_head(cmd);
+ put4com(env->env_id);
+ return 0;
+}
+
+/**	�ѥ��åȤΥإå���������	**/
+static int
+snd_server_head(server,cmd)
+register WNN_JSERVER_ID *server;
+int cmd;	/** cmd=���ޥ�� **/
+{
+ snd_head(cmd);
+ return 0;
+}
+
+/**	�����Хåե���ե�å��夹��	**/
+static int
+snd_flush()
+{
+ if(sbp==0)return(-1);
+ writen(sbp);
+ sbp=0;
+ return(0);
+}
+
+static int
+writen(n)
+int n;
+{int cc,x;
+ for(cc=0;cc<n;){
+	errno = 0;
+	x=write(current_sd, &snd_buf[cc],n-cc );
+	if(x < 0) {
+	    if (ERRNO_CHECK(errno) || errno == EINTR) {
+		continue;
+	    } else {
+		demon_dead();
+		return -1;
+	    }
+	}
+	cc+=x;
+ }
+#if DEBUG
+	fprintf(stderr,"jslib:writen=%d\n",x);
+/*	dmp(snd_buf,x); */
+#endif
+ return(0);
+}
+
+/**	������1��������	**/
+static void
+put1com(c)
+int c;
+{
+ snd_buf[sbp++]=c;
+ if(sbp>=S_BUF_SIZ){ 
+	writen(S_BUF_SIZ);
+	sbp=0;
+ }
+}
+
+/**	������2��������	**/
+static void
+put2com(c)
+int c;
+{
+ put1com(c>>(8*1));
+ put1com(c       );
+}
+
+/**	������4��������	**/
+static void
+put4com(c)
+int c;
+{
+ put1com(c>>(8*3));
+ put1com(c>>(8*2));
+ put1com(c>>(8*1));
+ put1com(c       );
+}
+
+/**	�����Ф�ʸ���������	**/
+static void
+putwscom(p) register w_char *p;
+{
+ if(p==NULL){ put2com(0); return; }
+ while(*p)put2com(*p++);
+ put2com(0);
+}
+
+/**	�����Ф�ʸ���������	**/
+static void
+putscom(p) register char *p;
+{
+ if(p==NULL){ put1com(0); return; }
+ while(*p)put1com(*p++);
+ put1com(0);
+}
+
+/**	�����Ф���1�Х��ȼ�����	**/
+static int
+get1com()
+{static int rbp;
+ static	unsigned char	rcv_buf[R_BUF_SIZ];	/** ���� **/
+ if(rbc<=0){
+    while(1) {
+	errno = 0;
+	rbc = read(current_sd, rcv_buf, R_BUF_SIZ);
+	if(rbc <= 0) {
+	    if (ERRNO_CHECK(errno)) {
+		continue;
+	    } else if (rbc == 0) {
+		demon_dead();
+		return -1;
+	    } else {	/* cc == -1 */
+		if (errno != EINTR) {
+		    demon_dead();
+		    return -1;
+		}
+		continue;
+	    }
+	}
+	rbp=0;
+#if DEBUG
+	fprintf(stderr,"jslib:read:rbc=%d\n",rbc);
+/*	dmp(rcv_buf,rbc); */
+#endif
+	break;
+    }
+ }
+ rbc--;
+ return rcv_buf[rbp++] & 0xFF ;
+}
+
+/**	�����Ф���2�Х��ȼ�����	**/
+static int
+get2com()
+{register int h;
+ h=get1com();
+ return (h<<8) | get1com();
+}
+
+/**	�����Ф���4�Х��ȼ�����	**/
+static int
+get4com()
+{register int h1,h2,h3;
+ h1=get1com() << 24 ;
+ h2=get1com() << 16 ;
+ h3=get1com() <<  8 ;
+ return h1 | h2 | h3 | get1com();
+}
+
+/**	�����Ф�ʸ���������	**/
+static void
+getscom(p) register char *p;
+{
+ while(*p++= get1com())
+	;
+}
+
+/**	�����Ф�ʸ���������	**/
+static void
+getwscom(p) w_char register *p;
+{
+ while(*p++= get2com())
+	;
+}
+
+#ifdef nodef
+/* Moved from ../etc/string.c */
+/**	**/
+static
+int Strlen(s)
+register w_char *s;
+{
+    register int n;
+
+    for (n = 0;*s++ != 0;n++);
+    return n;
+}
+
+/**	**/
+static 
+w_char *Strcpy(s1,s2)
+register w_char *s1;
+register w_char *s2;
+{
+	register w_char *d;
+
+	for (d = s1;(*d++ = *s2++) != 0;);
+	return s1;
+}
+#endif
+
+
+/*	Debug Subroutines	*/
+#if DEBUG
+void
+xerror(s)char *s;
+{
+ fprintf(stderr,"%s\n",s);
+}
+
+void
+dmp(p,c)char *p;
+{
+ int i,j;
+ for(i=0;;i+=16){
+	for(j=0;j<16;j++){
+	    	if(c<=0){	fprintf(stderr,"\n"); return;}
+		fprintf(stderr,"%02x ",p[i+j]&0xFF);
+		c--;
+	}
+	fprintf(stderr,"\n");
+ }
+}
+
+#endif
+
+/*	get login name form /etc/passwd file	*/
+static char*	
+getlogname()
+{
+ struct passwd *getpwuid();
+ return getpwuid(getuid())->pw_name;
+}
+
+
+
+
+/*
+ *		Lib. Functions
+ *		raw lib.
+ */
+
+/***
+	js
+	��global
+***/
+
+/**	  jserver ����³���롣jserver_id ���֤���	**/
+WNN_JSERVER_ID *
+js_open_lang(server, lang, timeout)
+register char *server, *lang;
+register int timeout;
+{char *new_js;
+ char host[WNN_HOSTLEN],user[WNN_ENVNAME_LEN];
+ int x;
+
+ if (wnn_msg_cat == NULL){
+    char nlspath[64];
+    strcpy(nlspath, LIBDIR);
+    strcat(nlspath, "/%L/%N");
+    wnn_msg_cat = msg_open("libwnn.msg", nlspath, lang);
+    if(wnn_msg_cat == NULL){
+	fprintf(stderr, "libwnn: Cannot open message file for libwnn.a\n");
+    }
+ }
+ sbp=0;	/* init sndBufPointer */
+ if(!(new_js=(char *)malloc(sizeof(WNN_JSERVER_ID)))){
+ 				wnn_errorno=WNN_ALLOC_FAIL;return NULL;
+ }
+ current_js =(WNN_JSERVER_ID *) new_js;
+ if (server == NULL) {
+   current_js->js_name[0] = '\0';
+ } else {
+   strncpy(current_js->js_name, server, sizeof(current_js->js_name) - 1);
+   current_js->js_name[sizeof(current_js->js_name) - 1] = '\0';
+ }
+ current_js->js_dead= 0;
+ current_js->js_dead_env_flg= 0;
+/*
+ if(user == NULL || 0==strcmp(user,""))
+*/
+ strncpy(user, getlogname(), WNN_ENVNAME_LEN);
+ user[WNN_ENVNAME_LEN-1] = '\0';	/* truncate by WNN_ENVNAME_LEN */
+ if(server == NULL || 0==strcmp(server,"") || 0==strcmp(server,"unix")){
+   strcpy(host,"unix");
+   if((current_sd= cd_open(lang))==-1){
+	wnn_errorno=WNN_SOCK_OPEN_FAIL;free((char*)current_js);current_js=NULL;
+	return NULL;
+   }
+ }else{
+   gethostname(host,WNN_HOSTLEN);
+   host[WNN_HOSTLEN-1] = '\0';	/* truncate by WNN_HOSTLEN */
+   if((current_sd= cd_open_in(server, lang, timeout))==-1){
+	wnn_errorno=WNN_SOCK_OPEN_FAIL;free((char*)current_js);current_js=NULL;
+	return NULL;
+   }
+ }
+ current_js->sd= current_sd;
+ handler_of_jserver_dead(NULL);
+ snd_head(JS_OPEN);
+ put4com(JLIB_VERSION);		/* H.T. */
+ putscom(host);
+ putscom(user);
+ snd_flush();
+ if(get4com()==-1){
+     x = wnn_errorno=get4com();
+     js_close(current_js);		/* H.T. */
+     current_js = NULL;
+     wnn_errorno = x;
+     return NULL;
+ }
+ return current_js;
+}
+
+
+/**	�����åȤ򥯥���������	**/
+/**	  jserver �Ȥ���³�� close ���롣	**/
+int
+js_close(server)
+WNN_JSERVER_ID *server;
+{
+ register int x;
+ WNN_JSERVER_ID tmp_js_id;
+ if(server==0) return(-1);
+ tmp_js_id = *server;
+ free((char *)server);
+ current_js = &tmp_js_id;
+ current_sd = current_js->sd;
+/*	handler of jserver dead */
+ handler_of_jserver_dead(-1);
+ snd_head(JS_CLOSE);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno=get4com();
+ close(current_sd);
+ return x;
+}
+
+
+/*
+	jserver �Ȥδ֤� connection ��ĥ�ꡢƱ���� jserver �������˴�
+	�����롣env_name �˴���¸�ߤ���Ķ�����ꤷ�����ˤϤ��δĶ���
+	�֤���NULL ����ꤷ�����ˤϿ������Ķ����ä��֤���
+*/
+
+struct wnn_env *
+js_connect_lang(server, env_name, lang)
+register char *env_name;
+WNN_JSERVER_ID *server;
+char *lang;
+{
+    register int e_id;
+    register struct wnn_env *env;
+    void js_set_lang();
+
+    set_current_js(server);
+    if(!(env=(struct wnn_env *)malloc(sizeof(struct wnn_env)))){
+	    wnn_errorno=WNN_ALLOC_FAIL;return NULL;
+    }
+    handler_of_jserver_dead(NULL);
+    snd_head(JS_CONNECT);
+    putscom(env_name);
+    snd_flush();
+    e_id=get4com();
+    if(e_id==-1){ wnn_errorno= get4com(); free(env); return NULL; }
+    env->env_id = e_id;
+    env->js_id  = server;
+    strcpy(env->lang, lang);        /* set language name */
+    return env;
+}
+
+#ifdef	nodef
+/* set language value to env */
+void
+js_set_lang(env, lang)
+struct wnn_env *env;
+register char *lang;
+{
+    register char *p;
+    extern char *getenv();
+
+    /* if not specified language , use $LANG */
+    if (lang == 0 || *lang == 0)
+	lang = getenv("LANG");
+    if (lang == 0 || *lang == 0)
+	lang = WNN_DEFAULT_LANG;
+    for(p = env->lang; *lang != '.' && *lang != '@' && *lang != 0; lang++, p++)
+	*p = *lang;
+    *p = 0;
+}
+#endif
+
+/* get language value from env */
+char *
+js_get_lang(env)
+struct wnn_env *env;
+{
+	return(env->lang);
+}
+
+int
+js_env_exist(server,env_name)
+register char *env_name;
+register WNN_JSERVER_ID *server;
+{
+ set_current_js(server);
+ handler_of_jserver_dead(-1);
+ snd_head(JS_ENV_EXIST);
+ putscom(env_name);
+ snd_flush();
+ return(get4com());
+}
+
+int
+js_env_sticky(env)
+register struct wnn_env *env;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_ENV_STICKY);
+ snd_flush();
+ return(get4com());
+}
+
+int
+js_env_un_sticky(env)
+register struct wnn_env *env;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_ENV_UN_STICKY);
+ snd_flush();
+ return(get4com());
+}
+
+/**
+	  env �Ǽ������Ķ���̵������
+**/
+int
+js_disconnect(env)
+register struct wnn_env *env;
+{register int x;
+ struct wnn_env tmp_env;
+ if(env==0) return(-1);
+ tmp_env= *env;
+ /* ����ϡ�free ���ʤ��㤢����Τ����ɡ��꥽��������������ʤ�����
+    �ޤ���8�Х��Ȥ����顢���ߤ��Ĥ뤱�ɤ�����������
+ free((char *)env);
+ */
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(NULL);
+ snd_env_head(&tmp_env,JS_DISCONNECT);
+ snd_flush();
+ x=get4com();
+ if(x==-1){ wnn_errorno= get4com(); }
+ return x;
+}
+
+/**	�����Фȥ��ͥ��Ȥ��Ƥ��뤫	**/
+int
+js_isconnect(env)
+register struct wnn_env *env;
+{
+    if (env && env->js_id)
+	return(env->js_id->js_dead);
+    return(-1);
+}
+
+/**
+	  env �� �Ķ� �Ȥ��̿��Хåե��� flush ���롣
+**/
+void
+js_flush(env)
+struct wnn_env *env;
+{
+}
+
+
+
+/*	Parameter set/get	*/
+/**	�Ѵ� parameter �����ꤹ�롣	**/
+/**	js_param_set		**/
+int
+js_param_set(env,para)
+struct wnn_env *env;
+register struct wnn_param *para;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_PARAM_SET);
+ put4com(para->n);	/* ��(��)ʸ����ϤΣ� */
+ put4com(para->nsho);	/* ��ʸ����ξ�ʸ��κ���� */
+ put4com(para->p1);	/* ��������٤Υѥ�᡼�� */
+ put4com(para->p2);	/* ��ʸ��Ĺ�Υѥ�᡼�� */
+ put4com(para->p3);	/* ����Ĺ�Υѥ�᡼�� */
+ put4com(para->p4);	/* ���Ȥä���ӥåȤΥѥ�᡼�� */
+ put4com(para->p5);	/* ����Υѥ�᡼�� */
+ put4com(para->p6);	/* ��ʸ���ɾ���ͤΥѥ�᡼�� */
+ put4com(para->p7);	/* ��ʸ��Ĺ�Υѥ�᡼�� */
+ put4com(para->p8);	/* ��ʸ����Υѥ�᡼�� */
+
+ put4com(para->p9);	/* �����ʻ� ���������� */
+ put4com(para->p10);	/* �����ʻ� ���ʤ����� *//* CWNN �ѿ������� */
+ put4com(para->p11);	/* �����ʻ� �ѿ������� *//* CWNN ��������� */
+ put4com(para->p12);	/* �����ʻ� ��������� *//* CWNN ����̤����� */
+ put4com(para->p13);	/* �����ʻ� �ij�̤����� *//* CWNN �ij�̤����� */
+ put4com(para->p14);	/* �����ʻ� ��°������� *//* BWNN No of koho */
+ put4com(para->p15);	/* �����ʻ� ����̤����� *//* CWNN Not used */
+
+ snd_flush();
+ x=get4com();
+ if(x==-1){ wnn_errorno= get4com(); return -1; }
+ return 0;
+}
+
+/**	js_param_get		**/
+/**	env �Ǽ������Ķ����Ѵ� parameter ����Ф���	**/
+int
+js_param_get(env,para)
+struct wnn_env *env;
+register struct wnn_param *para;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_PARAM_GET);
+ snd_flush();
+ if(get4com() == -1){
+     wnn_errorno= get4com(); return -1;
+ }
+ para->n=get4com();	/* ��(��)ʸ����ϤΣ� */
+ para->nsho=get4com();	/* ��ʸ����ξ�ʸ��κ���� */
+ para->p1=get4com();	/* ��������٤Υѥ�᡼�� */
+ para->p2=get4com();	/* ��ʸ��Ĺ�Υѥ�᡼�� */
+ para->p3=get4com();	/* ����Ĺ�Υѥ�᡼�� */
+ para->p4=get4com();	/* ���Ȥä���ӥåȤΥѥ�᡼�� */
+ para->p5=get4com();	/* ����Υѥ�᡼�� */
+ para->p6=get4com();	/* ��ʸ���ɾ���ͤΥѥ�᡼�� */
+ para->p7=get4com();	/* ��ʸ��Ĺ�Υѥ�᡼�� */
+ para->p8=get4com();	/* ��ʸ����Υѥ�᡼�� */
+ para->p9=get4com();	/* �����ʻ� ���������� */
+ para->p10=get4com();	/* �����ʻ� ���ʤ����� */
+ para->p11=get4com();	/* �����ʻ� �ѿ������� */
+ para->p12=get4com();	/* �����ʻ� ��������� */
+ para->p13=get4com();	/* �����ʻ� �ij�̤����� */
+ para->p14=get4com();	/* �����ʻ� ��°������� */
+ para->p15=get4com();	/* �����ʻ� ����̤����� */
+
+ return 0;
+}
+
+/*
+	global File Operation
+*/
+/**	js_mkdir	**/
+int
+js_mkdir(env,path)
+struct wnn_env *env;
+char *path;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_MKDIR);
+ putscom(path);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_access	**/
+int
+js_access(env,path,amode)
+struct wnn_env *env;
+char *path;
+int amode;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_ACCESS);
+ put4com(amode);
+ putscom(path);
+ snd_flush();
+ x=get4com();
+ return x;
+}
+
+/**	js_file_list_all	**/
+static int rcv_file_list();
+
+int
+js_file_list_all(server,ret)
+WNN_JSERVER_ID *server;
+struct wnn_ret_buf *ret;
+{
+ set_current_js(server);
+ handler_of_jserver_dead(-1);
+ snd_server_head(server,JS_FILE_LIST_ALL);
+ snd_flush();
+ return rcv_file_list(ret);
+}
+
+
+/**	js_file_list	**/
+int
+js_file_list(env,ret)
+struct wnn_env *env;
+struct wnn_ret_buf *ret;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FILE_LIST);
+ snd_flush();
+ return rcv_file_list(ret);
+}
+
+static void re_alloc();
+
+static int
+rcv_file_list(ret)
+struct wnn_ret_buf *ret;
+{register int i,count;
+ WNN_FILE_INFO_STRUCT	*files;
+ count=get4com();
+ re_alloc(ret,sizeof(WNN_FILE_INFO_STRUCT)*count);
+ files=(WNN_FILE_INFO_STRUCT *)ret->buf;
+ for(i=0;i<count;i++){
+	files->fid= get4com();
+	files->localf= get4com();
+	files->ref_count= get4com();
+	files->type= get4com();
+	getscom(files->name);
+	files++;
+ }
+ return count;
+}
+
+/**	js_file_stat	**/
+int
+js_file_stat(env,path, s)
+struct wnn_env *env;
+char *path;
+WNN_FILE_STAT *s;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FILE_STAT);
+ putscom(path);
+ snd_flush();
+ x=get4com();
+ s->type = x;
+ return x;
+}
+
+
+/**	js_file_info	**/
+int
+js_file_info(env,fid,file)
+struct wnn_env *env;
+int fid;
+register WNN_FILE_INFO_STRUCT *file;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FILE_INFO);
+ put4com(fid);
+ snd_flush();
+ file->fid= fid;
+ x=get4com();
+ if(x==-1){
+     wnn_errorno= get4com();
+     return(-1);
+ }
+ getscom(file->name);
+ file->localf= get4com();
+ file->ref_count= get4com();
+ file->type= get4com();
+ return 0;
+}
+
+/**	js_file_loaded	**/
+int
+js_file_loaded(server,path)
+WNN_JSERVER_ID *server;
+char *path;
+{register int x;
+ set_current_js(server);
+ handler_of_jserver_dead(-1);
+ snd_server_head(server,JS_FILE_LOADED);
+ putscom(path);
+ snd_flush();
+ x=get4com();
+ return x;
+}
+
+/**	js_file_loaded_local	**/
+static int check_local_file();
+static int file_loaded_local();
+
+int
+js_file_loaded_local(server,path)
+WNN_JSERVER_ID *server;
+char *path;
+{int x;
+ set_current_js(server);
+ handler_of_jserver_dead(-1);
+
+ if(check_local_file(path) == -1) return (-1);
+ snd_server_head(server, JS_FILE_LOADED_LOCAL);
+ x=file_loaded_local(path);
+ if(x==-1){ return -1; }
+ return x;
+}
+
+static int
+check_local_file(path)
+char *path;
+{
+ register FILE *f;
+ register int x;
+ struct wnn_file_head fh;
+
+#ifdef WRITE_CHECK
+ check_backup(path);
+#endif /* WRITE_CHECK */
+ f=fopen(path,"r");
+ if(f == NULL){
+     wnn_errorno = WNN_OPENF_ERR;
+     return -1;
+ }
+ x=input_file_header(f, &fh);
+ if(x==-1){
+     fclose(f);
+     wnn_errorno = WNN_NOT_A_FILE;
+     return -1;
+ }
+ if(check_inode(f, &fh) == -1){
+     change_file_uniq(&fh, path);
+#ifdef WRITE_CHECK
+     fclose(f);
+     f=fopen(path,"r");
+     if(f == NULL){
+	 wnn_errorno = WNN_OPENF_ERR;
+	 return (-1);
+     }
+#endif /* WRITE_CHECK */
+     if(check_inode(f, &fh) == -1){
+	 fclose(f);
+	 wnn_errorno = WNN_INODE_CHECK_ERROR;
+	 return (-1);
+     }
+ }
+ fclose(f);
+ return 0;
+}
+
+
+static int
+file_loaded_local(path)
+char *path;
+{register int x,i;
+ FILE *f;
+ struct wnn_file_head fh;
+
+#ifdef WRITE_CHECK
+ check_backup(path);
+#endif /* WRITE_CHECK */
+ f=fopen(path,"r");
+ if(f == NULL){
+     wnn_errorno = WNN_OPENF_ERR;
+     return -1;
+ }
+ x=input_file_header(f, &fh);
+ if(x==-1){
+     fclose(f);
+     wnn_errorno = WNN_NOT_A_FILE;
+     return -1;
+ }
+ put4com(fh.file_uniq.time);
+ put4com(fh.file_uniq.dev);
+ put4com(fh.file_uniq.inode);
+ for(i=0;i<WNN_HOSTLEN;i++){
+	put1com(fh.file_uniq.createhost[i]);
+ }
+
+ snd_flush();
+ x=get4com();
+ fclose(f);
+ return x;
+}
+
+
+/**	js_hindo_file_create	**/
+int
+js_hindo_file_create(env,fid,fn,comment,hpasswd)
+struct wnn_env *env;
+int	fid;
+char *fn;
+w_char *comment;
+char *hpasswd;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_HINDO_FILE_CREATE);
+ put4com(fid);
+ putscom(fn);
+ putwscom(comment);
+ putscom(hpasswd);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_dic_file_create	**/
+int
+js_dic_file_create(env,fn,type,comment,passwd, hpasswd)
+struct wnn_env *env;
+char *fn;
+w_char *comment;
+char *passwd, *hpasswd;
+int type;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_DIC_FILE_CREATE);
+ putscom(fn);
+ putwscom(comment);
+ putscom(passwd);
+ putscom(hpasswd);
+ put4com(type);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+
+/**	js_file_discard	**/
+int
+js_file_discard(env,fid)
+struct wnn_env *env;
+int	fid;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FILE_DISCARD);
+ put4com(fid);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_file_read	**/
+int
+js_file_read(env,fn)
+struct wnn_env *env;
+char	*fn;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FILE_READ);
+ putscom(fn);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_file_write	**/
+int
+js_file_write(env,fid,fn)
+struct wnn_env *env;
+int	fid;
+char	*fn;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FILE_WRITE);
+ put4com(fid);
+ putscom(fn);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_file_receive	**/
+static int xget1com();
+static void xput1com();
+
+int
+js_file_receive(env,fid,fn)
+struct wnn_env *env;
+int	fid;
+char	*fn;
+{register int mode, x;
+ char file_name[1024];
+ char buf[1024];
+ FILE *f;
+ int n;
+ struct wnn_file_head fh;
+ int i;
+#ifdef WRITE_CHECK
+ char *tmp, *backup = NULL, tmp_x;
+ int tmp_err = 0;
+#endif /* WRITE_CHECK */
+
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FILE_RECEIVE);
+ put4com(fid);
+ snd_flush();
+/**/
+ getscom(file_name);
+ if(fn ==NULL || strcmp(fn,"")==0){
+     gethostname(buf, 1024);
+     n = strlen(buf);
+     buf[n] = C_LOCAL;
+     buf[n+1] = 0;
+     if(strncmp(buf, file_name, n + 1) == 0){
+	 fn = file_name + n + 1;
+     }
+ }
+#ifdef WRITE_CHECK
+ check_backup(fn);
+#endif /* WRITE_CHECK */
+ if((f = fopen(fn, "r")) == NULL){ /* New File */
+     fh.file_uniq.time = fh.file_uniq.dev = fh.file_uniq.inode = 0;
+ }else{			/* Old File Exists */
+     if(input_file_header(f, &fh) == -1){
+	 wnn_errorno=WNN_NOT_A_FILE;
+	 fclose(f);
+	 put4com(-1);snd_flush();
+	 return(-1);
+     }
+     fclose(f);
+ }
+ put4com(0);			/* Ack */
+ put4com(fh.file_uniq.time);
+ put4com(fh.file_uniq.dev);
+ put4com(fh.file_uniq.inode);
+ for(i=0;i<WNN_HOSTLEN;i++){
+     put1com(fh.file_uniq.createhost[i]);
+ }
+
+ snd_flush();
+
+ if((mode=get4com())==-1){ /* check stat */
+	wnn_errorno= get4com();
+	return -1;
+ }else if(mode==0){
+	return 0; /* need not saving */
+ }else if(mode == 1 || mode == 3){ /* mode == 3 means the file is a new one. */
+#ifdef WRITE_CHECK
+     backup = make_backup_file(fn);
+     if ((tmp = make_tmp_file(fn, 0, &f)) == NULL) {
+	 delete_tmp_file(backup);
+#else /* WRITE_CHECK */
+     if((f = fopen(fn, "w+")) == NULL){ 
+#endif /* WRITE_CHECK */
+	 wnn_errorno=WNN_FILE_WRITE_ERROR;
+	 put4com(-1);snd_flush();
+	 return(-1);
+     }
+ }else if(mode == 2){
+#ifdef WRITE_CHECK
+     backup = make_backup_file(fn);
+     if ((tmp = make_tmp_file(fn, 1, &f)) == NULL) {
+	 delete_tmp_file(backup);
+#else /* WRITE_CHECK */
+     if((f = fopen(fn, "r+")) == NULL){ /* New File */
+#endif /* WRITE_CHECK */
+	 wnn_errorno=WNN_FILE_WRITE_ERROR;
+	 put4com(-1);snd_flush();
+	 return(-1);
+     }
+ }
+ put4com(0); snd_flush(); /* ACK */
+ for(;;){
+	if((x=xget1com())== -1) break; /* EOF */
+#ifdef WRITE_CHECK
+	tmp_x = (char)x;
+	if (fwrite(&tmp_x, sizeof(char), 1, f) == -1) tmp_err = 1;
+#else /* WRITE_CHECK */
+	fputc(x,f);
+#endif /* WRITE_CHECK */
+ }
+ fclose(f);
+#ifdef WRITE_CHECK
+ if (tmp_err == 0) {
+     move_tmp_to_org(tmp, fn, 1);
+ } else {
+     delete_tmp_file(tmp);
+ }
+ delete_tmp_file(backup);
+#endif /* WRITE_CHECK */
+
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+#ifdef WRITE_CHECK
+ if (tmp_err) {
+     wnn_errorno = WNN_FILE_WRITE_ERROR;
+     return(-1);
+ }
+#endif /* WRITE_CHECK */
+
+ return x;
+}
+
+static int
+xget1com()
+{register int x;
+ if((x= get1com()) != 0xFF) return x;
+ if(get1com() == 0xFF) return -1; /* EOF */
+ return 0xFF;
+}
+
+/**	js_file_send	**/
+int
+js_file_send(env,fn)
+struct wnn_env *env;
+char	*fn;
+{register int x;
+ FILE *f;
+ int n;
+ char buf[1024],*b;
+ register int cc,i;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+
+ if(check_local_file(fn) == -1) return (-1);
+
+ snd_env_head(env,JS_FILE_SEND);
+ x=file_loaded_local(fn);
+ if(x!= -1){ /* file is already loaded */
+     if(get4com() == -1) {
+	 wnn_errorno= get4com();
+	 return(-1);
+     }
+     return x;
+ }
+
+ x=get4com();
+ if(x==-1){
+	wnn_errorno= get4com();
+	return -1;
+ }
+
+ gethostname(buf, 1024);
+ n = strlen(buf);
+ buf[n] = C_LOCAL;
+ strcpy(buf + n + 1,fn);
+ putscom(buf);
+
+#ifdef WRITE_CHECK
+ check_backup(fn);
+#endif /* WRITE_CHECK */
+ if((f=fopen(fn,"r"))== NULL){
+	xput1com(-1); /* EOF */
+	return -1;
+ }
+
+ /* send contents of file */
+ for(;;){
+	cc = fread(buf,1,1024,f);
+	if(cc <= 0) break; /* EOF */
+	for(b=buf,i=0;i<cc;i++){
+		xput1com((int)*b++ & 0xff);
+	}
+ }
+ fclose(f);
+ xput1com(-1); /* EOF */
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+static void
+xput1com(d)
+int d;
+{
+ if(d == -1){ put1com(0xFF); put1com(0xFF);return;/* EOF */}
+ put1com(d);
+ if(d == 0xFF){ put1com(0x00);}
+}
+
+
+/***	Dic. Operation for Env.	 ***/
+
+/**	js_dic_add	**/
+int
+js_dic_add(env,fid,hfid,rev, jnice,rw,hrw, pw1, pw2)
+struct wnn_env *env;
+int	fid,hfid,rev,jnice,rw,hrw;
+char *pw1, *pw2;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_DIC_ADD);
+ put4com(fid);
+ put4com(hfid);
+ put4com(jnice);
+ put4com(rw);
+ put4com(hrw);
+ putscom(pw1);
+ putscom(pw2);
+ put4com(rev);		/* rev is to add it as reverse dict */
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_dic_delete	**/
+int
+js_dic_delete(env,dicno)
+struct wnn_env *env;
+int	dicno;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_DIC_DELETE);
+ put4com(dicno);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_dic_use	**/
+int
+js_dic_use(env,dic_no,flag)
+struct wnn_env *env;
+int	dic_no,flag;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_DIC_USE);
+ put4com(dic_no);
+ put4com(flag);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_fuzokugo_set	**/
+int
+js_fuzokugo_set(env,fid)
+struct wnn_env *env;
+int	fid;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FUZOKUGO_SET);
+ put4com(fid);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_fuzokugo_get	**/
+int
+js_fuzokugo_get(env)
+struct wnn_env *env;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FUZOKUGO_GET);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_dic_list_all	**/
+static int rcv_dic_list();
+static void get_dic_info();
+
+int
+js_dic_list_all(server,ret)
+WNN_JSERVER_ID *server;
+struct wnn_ret_buf *ret;
+{
+ set_current_js(server);
+ handler_of_jserver_dead(-1);
+ snd_server_head(server,JS_DIC_LIST_ALL);
+ snd_flush();
+ return rcv_dic_list(ret);
+}
+
+
+/**	js_dic_list	**/
+int
+js_dic_list(env,ret)
+struct wnn_env *env;
+struct wnn_ret_buf *ret;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_DIC_LIST);
+ snd_flush();
+ return rcv_dic_list(ret);
+}
+
+static int
+rcv_dic_list(ret)
+struct wnn_ret_buf *ret;
+{register int i,count;
+ register WNN_DIC_INFO *dic;
+ count=get4com();
+ re_alloc(ret, sizeof(WNN_DIC_INFO)*(count + 1));
+
+ dic=(WNN_DIC_INFO *)ret->buf;
+ for(i=0;i<count;i++){
+     get_dic_info(dic);
+     dic++;
+ }
+ dic->dic_no = -1;
+ return count;
+}
+
+static void
+get_dic_info(dic)
+register WNN_DIC_INFO *dic;
+{
+	dic->dic_no =get4com();	/* dic_No */
+	dic->body =get4com();	/* body fid */
+	dic->hindo =get4com();	/* hindo fid */
+	dic->rw =get4com();	/* r/w */
+	dic->hindo_rw =get4com();	/* hindo r/w */
+	dic->enablef =get4com();	/* enable/disable */
+	dic->nice =get4com();	/* nice */
+	dic->rev = get4com();
+/* added H.T */
+	getwscom(dic->comment);
+	getscom(dic->fname);
+	getscom(dic->hfname);
+	getscom(dic->passwd);
+	getscom(dic->hpasswd);
+	dic->type = get4com();
+	dic->gosuu = get4com();
+	dic->localf = get4com();
+	dic->hlocalf = get4com();
+}
+
+/***	Dic. Operation by dic_No.	***/
+
+/**	js_word_add		**/
+int
+js_word_add(env,dic_no,yomi,kanji,comment,hinshi,init_hindo)
+struct wnn_env *env;
+int	dic_no;
+w_char	*yomi,*kanji,*comment;
+int	hinshi,init_hindo;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_WORD_ADD);
+ put4com(dic_no);
+ putwscom(yomi);
+ putwscom(kanji);
+ putwscom(comment);
+ put4com(hinshi);
+ put4com(init_hindo);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+/**	js_word_delete		**/
+int
+js_word_delete(env,dic_no,entry)
+struct wnn_env *env;
+int	dic_no;
+int	entry;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_WORD_DELETE);
+ put4com(dic_no);
+ put4com(entry);
+ snd_flush();
+ x=get4com();
+ if(x==-1)wnn_errorno= get4com();
+ return x;
+}
+
+
+/**	js_word_search		**/
+static int rcv_word_data();
+
+int
+js_word_search(env,dic_no,yomi,ret)
+struct wnn_env *env;
+int	dic_no;
+w_char	*yomi;
+struct wnn_ret_buf *ret;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_WORD_SEARCH);
+ put4com(dic_no);
+ putwscom(yomi);
+ snd_flush();
+
+ return (rcv_word_data(ret, yomi));
+}
+
+/**	js_word_search_by_env	**/
+int
+js_word_search_by_env(env,yomi,ret)
+struct wnn_env *env;
+w_char	*yomi;
+struct wnn_ret_buf *ret;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_WORD_SEARCH_BY_ENV);
+ putwscom(yomi);
+ snd_flush();
+
+ return (rcv_word_data(ret, yomi));
+}
+
+/**	js_word_info		**/
+int
+js_word_info(env,dic_no,entry,ret)
+struct wnn_env *env;
+int	dic_no,entry;
+struct wnn_ret_buf *ret;
+{register int x;
+ w_char yomi[LENGTHYOMI];
+
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_WORD_INFO);
+ put4com(dic_no);
+ put4com(entry);
+ snd_flush();
+ x=get4com();
+ if(x==-1){
+     wnn_errorno= get4com();
+     return(-1);
+ }
+ getwscom(yomi);
+ rcv_word_data(ret, yomi);
+ return(0);
+}
+
+int
+js_word_comment_set(env, dic_no, entry, comment)
+struct wnn_env *env;
+int	dic_no,entry;
+w_char *comment;
+{
+ register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_WORD_COMMENT_SET);
+ put4com(dic_no);
+ put4com(entry);
+ putwscom(comment);
+ snd_flush();
+ x=get4com();
+ if(x==-1){
+     wnn_errorno= get4com();
+     return(-1);
+ }
+ return(0);
+}    
+
+/**	rcv for word_search		**/
+static int
+rcv_word_data(ret, yomi)
+struct wnn_ret_buf *ret;
+w_char *yomi;			/* Yomi is not sent from server
+				 *  (at least for the time being).
+				 */
+{register int x, j_c,k_c;
+ w_char *k;
+ register struct wnn_jdata *jd;
+ register int cnt;
+
+ j_c = get4com();
+ k_c = get4com();
+ re_alloc(ret, sizeof(struct wnn_jdata)*(j_c + 1) + sizeof(w_char)*(k_c + j_c * 3 + j_c * wnn_Strlen(yomi)));
+ jd=(struct wnn_jdata *)ret->buf;
+ for(cnt = 0;;cnt++){
+	jd->dic_no = x = get4com();
+	if(x==-1) break;
+	jd->serial  = get4com();
+	jd->hinshi = get4com();
+	jd->hindo = get4com();	jd->ima = get4com();
+	jd->int_hindo = get4com();	jd->int_ima = get4com();
+	jd++;
+ }
+ jd++;
+ k= (w_char *)jd;
+ jd=(struct wnn_jdata *)ret->buf;
+ for(;;){
+	if(jd->dic_no==-1) break;
+
+	jd->yomi = k;		/* Copy Yomi */
+	wnn_Strcpy(k, yomi);
+	k+= wnn_Strlen(k)+1;
+
+	jd->kanji = k;		/* Get Kanji */
+	getwscom(k);
+	k+= wnn_Strlen(k)+1;
+
+	jd->com = k;		/* Get Comment */
+	getwscom(k);
+	k+= wnn_Strlen(k)+1;
+	jd++;
+ }
+ return cnt;
+}
+
+
+/**	js_dic_info	**/
+int
+js_dic_info(env,dic_no,ret)
+struct wnn_env *env;
+int	dic_no;
+register WNN_DIC_INFO *ret;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_DIC_INFO);
+ put4com(dic_no);
+ snd_flush();
+ x=get4com();
+ if(x==-1){ return get4com();}
+ get_dic_info(ret);
+ return dic_no;
+}
+
+
+/**	js_who		**/
+int
+js_who(server,ret)
+WNN_JSERVER_ID *server;
+struct wnn_ret_buf *ret;
+{register int i,j,c;
+ WNN_JWHO *w;
+ set_current_js(server);
+ handler_of_jserver_dead(-1);
+ snd_server_head(server,JS_WHO);
+ snd_flush();
+
+ c=get4com();
+ if(c==-1){ wnn_errorno= get4com();return -1;}
+
+ re_alloc(ret, sizeof(WNN_JWHO)*c);
+ w=(WNN_JWHO *)ret->buf;
+ for(i=0;i<c;i++){
+	w->sd=get4com();
+	getscom(w->user_name);
+	getscom(w->host_name);
+	for(j=0;j<WNN_MAX_ENV_OF_A_CLIENT;j++){
+		(w->env)[j]=get4com();
+	}
+	w++;
+ }
+ return(c);
+}
+
+/**	jserver ������ƤδĶ��˴ؤ����������롣
+	(���鵻)
+**/
+int
+js_env_list(server,ret)
+WNN_JSERVER_ID *server;
+struct wnn_ret_buf *ret;
+{register int i,j,c;
+ WNN_ENV_INFO *w;
+ set_current_js(server);
+ handler_of_jserver_dead(-1);
+ snd_server_head(server,JS_ENV_LIST);
+ snd_flush();
+
+ c=get4com();
+ if(c==-1){ wnn_errorno= get4com();return -1;}
+
+ re_alloc(ret, sizeof(WNN_ENV_INFO)*c);
+ w=(WNN_ENV_INFO *)ret->buf;
+ for(i=0;i<c;i++){
+	w->env_id = get4com();     
+	getscom(w->env_name);
+	w->ref_count=get4com();
+	w->fzk_fid=get4com();
+	w->jishomax=get4com();
+	for(j=0;j<WNN_MAX_JISHO_OF_AN_ENV;j++){
+		(w->jisho)[j]= get4com();
+	}
+	for(j=0;j<WNN_MAX_FILE_OF_AN_ENV;j++){
+		(w->file)[j]= get4com();
+	}
+	w++;
+ }
+ return(c);
+}
+
+/****
+
+****/
+int
+js_hindo_set(env,dic,entry,ima,hindo)
+struct wnn_env *env;
+int dic, entry, ima,hindo;
+{register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_HINDO_SET);
+
+ put4com(dic);
+ put4com(entry);
+ put4com(ima);
+ put4com(hindo);
+ snd_flush();
+ if((x=get4com())==-1){
+	wnn_errorno= get4com();return -1;
+ }
+ return x;
+}
+
+
+/****
+	Henkan
+****/
+
+static void
+put_fzk_vec(hinsi,fzk,vec,vec1)
+int hinsi;
+w_char *fzk;
+int vec;
+int vec1;
+{
+	put4com(hinsi);
+	putwscom(fzk);
+	put4com(vec);
+	put4com(vec1);
+}
+
+/**
+	kanren
+**/
+static int rcv_dai();
+static void rcv_sho_x();
+static void rcv_sho_kanji();
+
+int
+js_kanren(env,yomi,hinsi,fzk,vec,vec1,vec2,rb)
+struct wnn_env *env;
+w_char	*yomi;
+int	hinsi;
+w_char	*fzk;
+int	vec;
+int	vec1;
+int	vec2;
+struct wnn_ret_buf *rb;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+
+ snd_env_head(env,JS_KANREN);
+ putwscom(yomi);
+ put_fzk_vec(hinsi,fzk,vec,vec1);
+ put4com(vec2);
+ snd_flush();
+ return rcv_dai(rb);
+}
+
+/*	rcv dai		*/
+static int
+rcv_dai(ret)
+struct wnn_ret_buf *ret;
+{int dai_cnt,sho_sum,kanji_sum,d_size,s_size,k_size,x;
+ register int i;
+ struct wnn_dai_bunsetsu *dai_list;
+ register struct wnn_dai_bunsetsu *dp;
+ struct wnn_sho_bunsetsu *sho_list;
+ register struct wnn_sho_bunsetsu *sp;
+ w_char *kanji,*kp;
+
+ dai_cnt = get4com();
+ if(dai_cnt == -1){	/* error dayo */
+	wnn_errorno = get4com();
+	return -1;
+ }
+ sho_sum = get4com();
+ kanji_sum = get4com();
+
+ d_size=sizeof(struct wnn_dai_bunsetsu)*dai_cnt;
+ s_size=sizeof(struct wnn_sho_bunsetsu)*sho_sum;
+ k_size=sizeof(w_char)*kanji_sum;
+
+/* re_alloc(ret, d_size+s_size+k_size); Seems This cause Bug?? H.T.*/
+ re_alloc(ret, d_size+s_size+k_size); 
+
+ dai_list = ( struct wnn_dai_bunsetsu *) ret->buf;
+ sho_list = ( struct wnn_sho_bunsetsu *)((char *)ret->buf + d_size);
+ kanji = (w_char *)((char *)ret->buf + d_size + s_size);
+
+ for(dp = dai_list,i=0; i<dai_cnt; i++){
+	dp -> end = get4com();
+	dp -> start = get4com();
+	dp -> sbncnt = get4com();
+	dp -> hyoka = get4com();
+	dp++;
+ }
+
+ for(dp = dai_list, sp = sho_list, i=0; i<dai_cnt; i++){
+	dp -> sbn = sp;
+	x = dp -> sbncnt;
+	rcv_sho_x(sp,x);
+	sp += x;
+	dp++;
+ }
+
+ for(dp=dai_list, kp=kanji, i=0; i<dai_cnt; i++){
+	rcv_sho_kanji(dp -> sbn,dp -> sbncnt,&kp);
+	dp++;
+ }
+ return dai_cnt;
+}
+
+/*	rcv sho routines	*/
+static void
+rcv_sho_x(sho_list,sho_cnt)
+register struct wnn_sho_bunsetsu *sho_list;
+int sho_cnt;
+{register int i;
+ for(i=0;i<sho_cnt;i++){
+	sho_list -> end = get4com();
+	sho_list -> start = get4com();
+	sho_list -> jiriend = get4com();
+	sho_list -> dic_no = get4com();
+	sho_list -> entry = get4com();
+	sho_list -> hindo = get4com();
+	sho_list -> ima = get4com();
+	sho_list -> hinsi = get4com();
+	sho_list -> status = get4com();
+	sho_list -> status_bkwd = get4com();
+	sho_list ->kangovect = get4com();
+	sho_list -> hyoka = get4com();
+	sho_list++;
+ }
+}
+
+static void
+rcv_sho_kanji(sho_list,sho_cnt,kanji)
+struct wnn_sho_bunsetsu *sho_list;
+int sho_cnt;
+w_char **kanji;
+{
+ register w_char *k;
+ register int i, x;
+ k = *kanji;
+ for(i=0;i<sho_cnt;i++){
+	sho_list -> kanji = k;
+	getwscom(k);
+	x= wnn_Strlen(k);
+	k += x+1;
+
+	sho_list -> yomi = k;
+	getwscom(k);
+	x= wnn_Strlen(k);
+	k += x+1;
+
+	sho_list -> fuzoku = k;
+	getwscom(k);
+	x= wnn_Strlen(k);
+	k += x+1;
+	sho_list++;
+ }
+ *kanji = k;
+}
+
+
+static int
+rcv_sho(ret)
+struct wnn_ret_buf *ret;
+{register int sho_sum,kanji_sum,s_size,k_size;
+ struct wnn_sho_bunsetsu *sho_list;
+ w_char *kanji,*kp;
+
+ sho_sum = get4com();
+ if(sho_sum == -1){	/* error dayo */
+	wnn_errorno = get4com();
+	return -1;
+ }
+ kanji_sum = get4com();
+
+ s_size=sizeof(struct wnn_sho_bunsetsu)*sho_sum;
+ k_size=sizeof(w_char)*kanji_sum;
+
+ re_alloc(ret, s_size+k_size);
+
+ sho_list = ( struct wnn_sho_bunsetsu *)((char *)ret->buf);
+ kanji = (w_char *)((char *)ret->buf + s_size);
+
+ rcv_sho_x(sho_list,sho_sum);
+ kp=kanji;
+ rcv_sho_kanji(sho_list,sho_sum,&kp);
+ return sho_sum;
+}
+
+/**
+	kantan
+**/
+int
+js_kantan_dai(env,yomi,hinsi,fzk,vec,vec1,rb)
+struct wnn_env *env;
+w_char	*yomi;
+int	hinsi;
+w_char	*fzk;
+int	vec;
+int	vec1;
+struct wnn_ret_buf *rb;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+
+ snd_env_head(env,JS_KANTAN_DAI);
+ putwscom(yomi);
+ put_fzk_vec(hinsi,fzk,vec,vec1);
+ snd_flush();
+ 
+ return rcv_dai(rb);
+}
+
+int
+js_kantan_sho(env,yomi,hinsi,fzk,vec,vec1,rb)
+struct wnn_env *env;
+w_char	*yomi;
+int	hinsi;
+w_char	*fzk;
+int	vec;
+int	vec1;
+struct wnn_ret_buf *rb;
+{int sbncnt;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+
+ snd_env_head(env,JS_KANTAN_SHO);
+ putwscom(yomi);
+ put_fzk_vec(hinsi,fzk,vec,vec1);
+ snd_flush();
+ 
+ sbncnt = rcv_sho(rb);
+ return sbncnt;
+}
+
+/**
+	kanzen
+**/
+int
+js_kanzen_dai(env,yomi,hinsi,fzk,vec,vec1,rb)
+struct wnn_env *env;
+w_char	*yomi;
+int	hinsi;
+w_char	*fzk;
+int	vec;
+int	vec1;
+struct wnn_ret_buf *rb;
+{
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_KANZEN_DAI);
+ putwscom(yomi);
+ put_fzk_vec(hinsi,fzk,vec,vec1);
+ snd_flush();
+
+ return rcv_dai(rb);
+}
+
+
+int
+js_kanzen_sho(env,yomi,hinsi,fzk,vec,vec1,rb)
+struct wnn_env *env;
+w_char	*yomi;
+int	hinsi;
+w_char	*fzk;
+int	vec;
+int	vec1;
+struct wnn_ret_buf *rb;
+{int sbncnt;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_KANZEN_SHO);
+ putwscom(yomi);
+ put_fzk_vec(hinsi,fzk,vec,vec1);
+ snd_flush();
+
+ sbncnt = rcv_sho(rb);
+ return sbncnt;
+}
+
+/**	js_version		**/
+int
+js_version(server,serv,libv)
+int *serv,*libv;
+WNN_JSERVER_ID *server;
+{
+ set_current_js(server);
+ handler_of_jserver_dead(-1);
+ snd_server_head(server, JS_VERSION);
+ snd_flush();
+ *libv= JLIB_VERSION;
+ return *serv = get4com();
+}
+
+static void
+re_alloc(ret,size)
+register struct wnn_ret_buf *ret;
+int size;
+{
+ if(ret->size < size){
+	if(ret->buf)
+	    free((char *)ret->buf);
+	ret->buf = malloc(size);
+	ret->size = size;
+ }
+}
+
+
+int
+js_kill(server)
+WNN_JSERVER_ID *server;
+{
+    int x;
+    set_current_js(server);
+    handler_of_jserver_dead(-1);
+    snd_server_head(server, JS_KILL);
+    snd_flush();
+    x = get4com();
+    return(x);
+}
+
+
+int
+js_file_remove(server, n, pwd)
+WNN_JSERVER_ID *server;
+char *n, *pwd;
+{
+    register int x;
+    set_current_js(server);
+    handler_of_jserver_dead(-1);
+    snd_server_head(server,JS_FILE_REMOVE);
+    putscom(n);
+    putscom(pwd);
+    snd_flush();
+    if((x=get4com())==-1){
+	wnn_errorno= get4com();return -1;
+    }
+    return(x);
+}    
+
+int
+js_file_remove_client(server, n, pwd)
+WNN_JSERVER_ID *server;
+char *n, *pwd;
+{
+    struct wnn_file_head fh;
+    register FILE *fp;
+    set_current_js(server);
+    handler_of_jserver_dead(-1);
+    if(js_file_loaded_local(server, n) != -1){
+	wnn_errorno = WNN_FILE_IN_USE;
+	return(-1);
+    }
+#ifdef WRITE_CHECK
+    check_backup(n);
+#endif /* WRITE_CHECK */
+    if((fp=fopen(n,"r")) == NULL){
+	wnn_errorno = WNN_FILE_READ_ERROR;
+	return(-1);
+    }
+    if(input_file_header(fp, &fh) == -1){
+	fclose(fp);
+	return(-1);
+    }
+    fclose(fp);
+    if(!check_pwd(pwd, fh.file_passwd)){
+	wnn_errorno = WNN_INCORRECT_PASSWD;
+	return(-1);
+    }
+    if(unlink(n) == -1){
+	wnn_errorno = WNN_UNLINK;
+	return(-1);
+    }
+    return(0);
+}
+
+/**	js_dic_file_create_client	**/
+int
+js_dic_file_create_client(env,fn,type,com,passwd, hpasswd)
+struct wnn_env *env;
+int type;
+char *fn;
+w_char *com;
+char *passwd, *hpasswd;
+{
+    int x;
+    if(type != WNN_REV_DICT && 
+       type != CWNN_REV_DICT &&
+       type != BWNN_REV_DICT &&
+       type != WNN_UD_DICT){
+	wnn_errorno = WNN_NOT_A_UD;
+	return(-1);
+    }
+    x = create_null_dic(fn,com, passwd, hpasswd, type);
+    if(x == -1){
+	wnn_errorno = WNN_FILE_CREATE_ERROR;
+	return(-1);
+    }
+    return(0);
+}
+
+
+/**	js_hindo_file_create_client	**/
+int
+js_hindo_file_create_client(env,fid,fn,com,hpasswd)
+struct wnn_env *env;
+int	fid;
+char *fn;
+w_char *com;
+char *hpasswd;
+{
+    register int x;
+    struct wnn_file_uniq funiq;
+    int serial;
+    register int i;
+
+    if(env==0) return(-1);
+    set_current_js(env->js_id);
+    handler_of_jserver_dead(-1);
+    snd_env_head(env,JS_HINDO_FILE_CREATE_CLIENT);
+    put4com(fid);
+    snd_flush();
+    x = get4com();
+    if(x == -1){
+	wnn_errorno = get4com();
+	return(-1);
+    }
+    serial = get4com();
+    funiq.time = get4com();
+    funiq.dev =  get4com();
+    funiq.inode = get4com();
+    for(i=0;i<WNN_HOSTLEN;i++){
+	funiq.createhost[i]=get1com();
+    }
+/*    getscom(funiq.createhost); */
+    if(create_hindo_file(&funiq,fn,com,hpasswd,serial) == -1){
+	wnn_errorno = WNN_FILE_CREATE_ERROR;
+	return(-1);
+    }
+    return(0);
+}
+
+int
+js_file_comment_set(env, fid, comment)
+struct wnn_env *env;
+int fid;
+w_char *comment;
+{
+ register int x;
+ if(env==0) return(-1);
+ set_current_js(env->js_id);
+ handler_of_jserver_dead(-1);
+ snd_env_head(env,JS_FILE_COMMENT_SET);
+ put4com(fid);
+ putwscom(comment);
+ snd_flush();
+ x=get4com();
+ if(x==-1){
+     wnn_errorno= get4com();
+     return(-1);
+ }
+ return(0);
+}
+    
+
+/* 
+ * Hinsi Primitives
+ */
+
+int
+js_hinsi_name(server, no, rb)
+WNN_JSERVER_ID *server;
+int no;
+struct wnn_ret_buf *rb;
+{
+    register int size;
+
+    set_current_js(server);
+    handler_of_jserver_dead(-1);
+    snd_server_head(server,JS_HINSI_NAME);
+    put4com(no);
+    snd_flush();
+    if((size = get4com()) == -1){
+	wnn_errorno = get4com(); return(-1);
+    }
+    re_alloc(rb,sizeof(w_char)*(size + 1));
+    getwscom((w_char *)rb->buf);
+    return(0);
+}
+
+
+int 
+js_hinsi_number(server, name)
+WNN_JSERVER_ID *server;
+w_char *name;
+{
+    register int no;
+
+    set_current_js(server);
+    handler_of_jserver_dead(-1);
+    snd_server_head(server,JS_HINSI_NUMBER);
+    putwscom(name);
+    snd_flush();
+    if((no = get4com()) == -1){
+	wnn_errorno = get4com();
+	return(-1);
+    }
+    return(no);
+}
+
+
+int
+js_hinsi_list(env, dic_no, name, rb)
+struct wnn_env *env;
+int dic_no;
+w_char *name;
+struct wnn_ret_buf *rb;
+{
+    int size;
+    int count;
+    register w_char *s;
+    register w_char **r;
+    register int k;
+
+    if(env==0) return(-1);
+    set_current_js(env->js_id);
+    handler_of_jserver_dead(-1);
+    snd_env_head(env,JS_HINSI_LIST);
+    put4com(dic_no);
+    putwscom(name);
+    snd_flush();
+    if((count = get4com()) == -1){
+	wnn_errorno = get4com();
+	return(-1);
+    }
+    size = get4com();
+    re_alloc(rb,sizeof(w_char)*(size + 1) + count * sizeof(w_char *) );
+    r = (w_char **)rb->buf;
+    s = (w_char *)((w_char **)rb->buf + count);
+    for(k = 0 ; k < count ; k++){
+	*r++ = s;
+	getwscom(s);
+	s+= wnn_Strlen(s) + 1;
+    }
+    return(count);
+}
+
+
+int 
+js_hinsi_dicts(env, no,  rb)
+struct wnn_env *env;
+int no;
+struct wnn_ret_buf *rb;
+{
+    register int k, count;
+    int *p;
+
+    if(env==0) return(-1);
+    set_current_js(env->js_id);
+    handler_of_jserver_dead(-1);
+    snd_env_head(env,JS_HINSI_DICTS);
+    put4com(no);
+    snd_flush();
+    if((count = get4com()) == -1){
+	wnn_errorno = get4com();
+	return(-1);
+    }
+    re_alloc(rb,sizeof(int) * (count + 1));
+    p = (int *)rb->buf;
+
+    for(k = 0 ; k < count ; k++){
+	*p++ = get4com();
+    }
+    return(count);
+}
+
+
+char *wnn_dic_types[] = {"","����","��Ͽ","�հ�","����"};
+
+char *cwnn_dic_types[] = {"","�̶�","��¼","ƴ��","����"};
+char *bwnn_dic_types[] = {"","�̶�","��¼","����","����"};
+
+char *kwnn_dic_types[] = {"","����","���","����","����"};
+			/*    ͳ��   ����   ���   ��Ю */
+
+/* New primitives  9/8 */
+
+int
+js_file_password_set(env, fid, which, old, new)
+struct wnn_env *env;
+int fid;
+int which;			/* 1 for dic, 2 for hindo 3(0) for both*/
+char *old, *new;
+{
+    register int x;
+    if(env==0) return(-1);
+    set_current_js(env->js_id);
+    handler_of_jserver_dead(-1);
+    snd_env_head(env,JS_FILE_PASSWORD_SET);
+    put4com(fid);
+    put4com(which);
+    putscom(old);
+    putscom(new);
+    snd_flush();
+    x=get4com();
+    if(x==-1){
+	wnn_errorno= get4com();
+	return(-1);
+    }
+    return(0);
+}
+
+int
+js_hinsi_table_set(env, dic_no, hinsi_table)
+struct wnn_env *env;
+int dic_no;
+w_char *hinsi_table;
+{
+    int x;
+    if(env==0) return(-1);
+    set_current_js(env->js_id);
+    handler_of_jserver_dead(-1);
+    snd_env_head(env,JS_HINSI_TABLE_SET);
+    put4com(dic_no);
+    putwscom(hinsi_table);
+    snd_flush();
+    x=get4com();
+    if(x==-1){
+	wnn_errorno= get4com();
+	return(-1);
+    }
+    return(0);
+}
+
+#define	SERVERDEFS_FILE		"/serverdefs"
+
+#define	MACHINE_NAME		1
+#define	UNIXDOMAIN_NAME		2
+#define	SERVICE_NAME		3
+#define	SERVICE_PORT_NUM	4
+
+static char *
+get_serv_defs(lang, cnt)
+char *lang;
+int cnt;
+{
+    FILE *fp;
+    static char s[6][EXPAND_PATH_LENGTH];
+    char serv_defs[EXPAND_PATH_LENGTH];
+    char data[1024];
+    int num;
+
+    strcpy(serv_defs, LIBDIR);
+    strcat(serv_defs, SERVERDEFS_FILE);
+    if ((fp = fopen(serv_defs, "r")) == NULL) {
+	return(NULL);
+    }
+    while (fgets(data, 1024, fp) != NULL) {
+	num = sscanf(data, "%s %s %s %s %s %s %s",
+		     s[0],s[1],s[2],s[3],s[4],s[5],s[6]);
+	if ((num < 4) || s[0][0] == ';') { 
+	    continue;
+	}
+	if (!strncmp(lang, s[0], strlen(s[0]))) {
+	    fclose(fp);
+	    if (cnt == SERVICE_PORT_NUM && num < 5) return(NULL);
+	    if (strlen(s[cnt]) == strlen("NULL") && !strcmp(s[cnt], "NULL")) {
+		return(NULL);
+	    } else {
+		return(s[cnt]);
+	    }
+	}
+    }
+    fclose(fp);
+    return(NULL);
+}
+
+char *
+_wnn_get_machine_of_serv_defs(lang)
+char *lang;
+{
+    return(get_serv_defs(lang, MACHINE_NAME));
+}
+
+static char *
+get_unixdomain_of_serv_defs(lang)
+char *lang;
+{
+    return(get_serv_defs(lang, UNIXDOMAIN_NAME));
+}
+
+static char *
+get_service_of_serv_defs(lang)
+char *lang;
+{
+    return(get_serv_defs(lang, SERVICE_NAME));
+}
+
+static int
+get_port_num_of_serv_defs(lang)
+char *lang;
+{
+    char *port_char;
+
+    if ((port_char = get_serv_defs(lang, SERVICE_PORT_NUM)) == NULL) {
+	return(-1);
+    } else {
+	return(atoi(port_char));
+    }
+}
diff --git a/wnn/jslib.h b/wnn/jslib.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed4a8b4843026b27c363e0bd92f48a4a0baccc70
--- /dev/null
+++ b/wnn/jslib.h
@@ -0,0 +1,469 @@
+/*
+ * $Id: jslib.h,v 1.1 1996/03/13 09:56:53 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/*
+	Nihongo	Henkan	Library Header File
+*/
+#ifndef	JSLIB
+#ifndef	_WNN_SETJMP
+#define	_WNN_SETJMP
+#include <setjmp.h>
+#endif
+
+#define	JLIB_VERSION	0x4003
+
+#ifndef	w_char
+#define	w_char	unsigned short
+#endif	/* w_char */
+
+#define JSLIB
+
+/* ��ü�٥���(�ʻ��ֹ�)����� */
+#define	WNN_BUN_SENTOU	-1	/* ��ʸ�����Ƭ�ˤʤ���� */
+#define	WNN_ALL_HINSI	-2	/* �ʤ�Ǥ⤨���� */
+/* ��ü�٥�������� */
+#define	WNN_VECT_KANREN	0	/* Ϣʸ���Ѵ��ν�ü�٥����� */
+#define	WNN_VECT_KANTAN	1	/* ñʸ���Ѵ��ν�ü�٥����� */
+#define	WNN_VECT_KANZEN	1	/* �������Ф��ν�ü�٥����� 
+				   ñʸ���Ѵ����Τ�Τ���������*/ 
+#define WNN_VECT_BUNSETSU 2     /* Ϣʸ���Ѵ����Ρ���ʸ��ν�ü�٥�����*/
+#define	WNN_VECT_NO	-1	/* ��ü�٥���1 ̵�� */
+/* ʸ��ν�ü����³���� */
+#define	WNN_CONNECT_BK	1	/* ���ꤵ�줿��ü�٥���������³�Ǥ�����*/
+#define	WNN_NOT_CONNECT_BK	0	/* */
+/* ʸ�����ü����³���� */
+#define	WNN_CONNECT	1	/* ���ꤵ�줿(�ʻ졢��°��)����³�Ǥ�����*/
+#define	WNN_SENTOU	2	/* ��ʸ�����Ƭ */
+#define	WNN_NOT_CONNECT	3	/* ��Ƭ�ˤʤ�ʤ�����������³�Ǥ��ʤ� */
+#define	WNN_GIJI	4	/* ����ʸ����ä���*/
+
+/* ����ʸ���ľ�������򤷤����� */
+#define WNN_HIRAGANA	-1	/* �Ҥ餬�� *//* �ɤߤΤޤ� */
+#define WNN_KATAKANA	-11	/* �������� */
+/* ���� */
+#define	WNN_NUM_HAN	-2	/* Ⱦ�ѿ��� *//* �ɤߤΤޤ� */
+#define	WNN_NUM_ZEN	-12	/* ���ѿ��� *//* ������ */
+#define	WNN_NUM_KAN	-13	/* ������ *//* ���� */
+#define	WNN_NUM_KANSUUJI -15	/* ������ *//* ɴ�󽽻� */
+#define	WNN_NUM_KANOLD	-16	/* ������ *//* ��ɴ������ */
+#define	WNN_NUM_HANCAN	-17	/* Ⱦ�ѿ��� *//* 1,234 */
+#define	WNN_NUM_ZENCAN	-18	/* ���ѿ��� *//* ���������� */
+/* �ѿ� */
+#define	WNN_ALP_HAN	-4	/* Ⱦ�� *//* �ɤߤΤޤ� */
+#define	WNN_ALP_ZEN	-30	/* ���� */
+/* ���� */
+#define	WNN_KIG_HAN	-5	/* Ⱦ�� *//* �ɤߤΤޤ� */
+#define	WNN_KIG_JIS	-40	/* ����(JIS) */
+#define	WNN_KIG_ASC	-41	/* ����(ASC) */
+
+#define WNN_FT_DICT_FILE 1
+#define WNN_FT_HINDO_FILE 2
+#define WNN_FT_FUZOKUGO_FILE 3
+
+#define WNN_STATIC_DICT 1		/* static dict */
+#define WNN_UD_DICT 2			/* updatable dict */
+#define WNN_REV_DICT 3		/* Updatable Dictonary with Reverse Index */
+#define WNN_REG_DICT 4		/* Regular Expressino Dictonary */
+
+/* for CHINESE PIN-IN : with Si Sheng (����) */
+#define CWNN_REV_DICT		0x103	/* Updatable with Reverse Index */
+
+/* for CHINESE: Bi Xing (ɮ��) */
+#define BWNN_REV_DICT		0x203	/* Updatable with Reverse Index */
+
+#define	WNN_DIC_RDONLY	1
+#define	WNN_DIC_RW	0
+
+#define	WNN_DIC_ADD_REV 1	/* ���Ѵ� */
+#define	WNN_DIC_ADD_NOR 0	/* �̾���Ѵ� */
+
+/* header file for dic_syurui */
+#define WNN_FILE_NOT_EXIST -1
+#define WNN_NOT_A_JISHO 0
+/* KURI
+#define WNN_USER_DIC 1
+#define WNN_SYSTEM_DIC 3
+*/
+#define WNN_HINDO_FILE 4
+#define WNN_FUZOKUGO_FILE 5
+
+/* set_hindo operation */
+#define WNN_HINDO_NOP -2
+#define WNN_IMA_ON -3
+#define WNN_IMA_OFF -4
+#define WNN_HINDO_INC -3
+#define WNN_HINDO_DECL -4
+#define WNN_ENTRY_NO_USE -1
+
+/*	Wnn constant
+*/
+#define WNN_HOSTLEN 16
+#define WNN_ENVNAME_LEN 32
+
+/*	js_who	*/
+#define WNN_MAX_ENV_OF_A_CLIENT 32
+
+struct wnn_jwho {
+	int sd;   /* jserver ��Υ����åȥǥ�������ץ�*/
+	char user_name[64];   /* �桼��̾ */
+	char host_name[64];   /* �ۥ���̾ */
+	int  env[WNN_MAX_ENV_OF_A_CLIENT];  /* ���Υ��饤����Ȥ����Ѥ��Ƥ���
+				�Ķ��ֹ���󡣶����Ƥ���Ȥ����ˤϡ�-1 ������ */
+};
+typedef struct wnn_jwho WNN_JWHO;
+
+/*	js_env_list	*/
+#define WNN_MAX_JISHO_OF_AN_ENV 30
+#define WNN_MAX_FILE_OF_AN_ENV 60
+
+ struct wnn_env_info {
+        int	env_id;		/* �Ķ��ֹ� */
+	char	env_name[WNN_ENVNAME_LEN]; /* �Ķ�̾ */
+	int	ref_count;	/* ���ȿ� */
+	/* struct wnn_param; */
+	int	fzk_fid;	/* ��°��Υե������ֹ� */
+	int jishomax;		/* ���Ѥ��Ƥ��뼭��θĿ� */
+	int	jisho[WNN_MAX_JISHO_OF_AN_ENV];	/* ���Ѥ��Ƥ��뼭��μ����ֹ档
+					   �ǽ��jishomax�Ĥ�����̣������ */
+	int	file[WNN_MAX_FILE_OF_AN_ENV]; /* ���δĶ��ˤĤʤ��äƤ���
+				 �ե������ֹ�(�����Ƥ���Ȥ����ˤϡ�-1 ������) */
+};
+typedef struct wnn_env_info WNN_ENV_INFO;
+
+#define WNN_COMMENT_LEN 512     /* jisho no comment no nagasa */
+#define WNN_F_NAMELEN 100
+#define WNN_PASSWD_LEN 16  /* File Passwd Length */
+
+
+struct wnn_dic_info {
+	int dic_no;		/* �����ֹ� */
+	int body;		/* �������ΤΥե������ֹ� */
+	int hindo;		/* ���٤Υե������ֹ� */
+	int rw;			/* ������Ͽ��ǽ���ɤ���
+				   (WNN_DIC_RW, WNN_DIC_RDONLY) */
+	int hindo_rw;		/* ���٤�������ǽ���ɤ���
+				   (WNN_DIC_RW, WNN_DIC_RDONLY) */
+	int enablef;		/* ���񤬻����椫�ɤ���
+				   (1 = ������, 0 = ��������) */
+	int nice;		/* ������Ѵ�����ͥ���� */
+	int rev;		/* ���Ѵ������ɤ���(1 = ���Ѵ�, 0 = ���Ѵ�) */
+/* added H.T */
+	w_char comment[WNN_COMMENT_LEN];	/* ��������� */
+	char fname[WNN_F_NAMELEN]; /* ����Υե�����̾ */
+	char hfname[WNN_F_NAMELEN]; /* ���٤Υե�����̾ */
+	char passwd[WNN_PASSWD_LEN]; /* ����Υѥ���� */
+	char hpasswd[WNN_PASSWD_LEN]; /* ���٤Υѥ���� */
+	int type;		/* ������(WNN_UD_DICT,WNN_STATIC_DICT) */
+	int gosuu;		/* ����� */
+	int localf;
+	int hlocalf;
+};
+
+typedef struct wnn_dic_info WNN_DIC_INFO;
+
+struct wnn_file_stat {
+    int type;			/* �ե�����μ���
+		WNN_STATIC_DICT		�����������
+		WNN_UD_DICT		��Ͽ��ǽ��������
+		WNN_HINDO_FILE		���٥ե�����
+		WNN_FUZOKUGO_FILE	��°��ե�����
+		WNN_NOT_A_JISHO		����¾   */
+};
+
+typedef struct wnn_file_stat WNN_FILE_STAT;
+
+/*	*/
+extern	int	wnn_errorno;		/* Wnn�Υ��顼�Ϥ����ѿ�����𤵤�� */
+
+extern char *wnn_dic_types[];	/* "����","��Ͽ","���Ѵ�","����" */
+
+extern char *cwnn_dic_types[];	/* "����","��Ͽ","���Ѵ�","����" */
+extern char *bwnn_dic_types[];	/* "����","��Ͽ","���Ѵ�","����" */
+
+#define FILE_ALREADY_READ -2
+
+/* ���ι�¤�Τϡ��饤�֥���������Ѥ����� */
+struct wnn_jserver_id {
+	int	sd;
+	char	js_name[40];
+	int	js_dead;
+	jmp_buf js_dead_env;	/* �����Ф�������������Ǥ���env */
+	int	js_dead_env_flg; /* jd_server_dead_env��ͭ�����ݤ�  */
+};
+
+typedef struct wnn_jserver_id WNN_JSERVER_ID;
+
+/* ���ι�¤�Τϡ��饤�֥���������Ѥ����� */
+struct wnn_env {
+	int		env_id;
+	WNN_JSERVER_ID	*js_id;
+	char		lang[16];	/* for exsample "ja_JP" */
+};
+
+typedef struct wnn_env WNN_ENV;
+
+struct wnn_param {
+	int	n;	/* ��(��)ʸ����ϤΣ� */
+	int	nsho;	/* ��ʸ����ξ�ʸ��κ���� */
+	int 	p1;	/* ��Ω������٤Υѥ�᡼�� */
+	int 	p2;	/* ��ʸ��Ĺ�Υѥ�᡼�� */
+	int 	p3;	/* ��Ω��Ĺ�Υѥ�᡼�� */
+	int 	p4;	/* ���Ȥä���ӥåȤΥѥ�᡼�� */
+	int 	p5;	/* ����Υѥ�᡼�� */
+	int	p6;	/* ��ʸ���ɾ���ͤΥѥ�᡼�� */
+	int	p7;	/* ��ʸ��Ĺ�Υѥ�᡼�� */
+	int	p8;	/* ��ʸ����Υѥ�᡼�� */
+	int 	p9;	/* �����ʻ� ���������� */
+	int 	p10;	/* �����ʻ� ���ʤ����� *//* CWNN:�ѿ������� */
+	int 	p11;	/* �����ʻ� �ѿ������� *//* CWNN:��������� */
+	int 	p12;	/* �����ʻ� ��������� *//* CWNN:����̤����� */
+	int 	p13;	/* �����ʻ� �ij�̤����� *//* CWNN:�ij�̤����� */
+	int 	p14;	/* �����ʻ� ��°������� *//* BWNN:No of koho */
+	int 	p15;	/* �����ʻ� ����̤����� *//* CWNN:Not used */
+};
+
+#ifdef nodef
+struct wnn_dic_info_struct {
+	int	body_fid;
+	int	hindo_fid;
+	int	enablef;
+	int	rw;
+	int     hindo_rw;
+	int	nice;
+};
+
+typedef struct wnn_dic_info_struct WNN_DIC_INFO_STRUCT;
+#endif
+
+struct wnn_file_info_struct {
+	int	fid;		/* �ե������ֹ� */
+	char	name[WNN_F_NAMELEN]; /* �ե�����̾ */
+	int	localf;		/* �����С������ȤΥե����뤫�ɤ���
+				   1: ������������
+				   0: ���饤����ȡ�������   */
+	int	type;		/* �ե�����μ��� */
+	int	ref_count;	/* (�Ķ������)���ȿ� */
+};
+
+typedef struct wnn_file_info_struct WNN_FILE_INFO_STRUCT;
+
+#define WNN_VECT_L	((256+8*4-1)/(8*4) + 5)	/***** !!!!! ****/
+
+struct	wnn_sho_bunsetsu {
+	int	end;		/* ����ʸ��� end char index */
+	int	start;		/* ����ʸ��� top char index */
+	int	jiriend;	/* ����ʸ��μ�Ω�� end char index */
+	int	dic_no;		/* ��Ω��μ�����Υ���ȥ��ֹ� */
+	int	entry;		/* ����ʸ��μ�Ω�켭�� entry */
+
+	int	hinsi;		/* ��Ω���ʻ� */
+	int     status;		/* ��ʸ�����Ƭ�� */
+	int	status_bkwd;	/* usiro ��ʸ�����³�Ǥ��뤫 */
+	int 	hindo;		/* ���伫Ω������� */ 
+	int 	ima;		/* ���伫Ω��κ��Ȥä���ӥå� */ 
+	int	kangovect;	/* ��³�٥��ȥ�ơ��֥�ؤΥݥ��� */
+	int 	hyoka;		/* ��ʸ��ɾ���� */
+	w_char	*kanji;		/* ��Ω��ʸ���� */
+	w_char	*yomi;		/* ��Ω����ɤ�ʸ���� */
+	w_char	*fuzoku;	/* ��°��ʸ���� */
+/*
+ *���٤ˤĤ��Ƥϡ����٥ե����뤬���ꤵ��Ƥ�����ϡ�
+ *hindo = ���٥ե������(��)������ + �������(��)������
+ *ima = ���٥ե�����κ��Ȥä���ӥå�
+ *
+ *���٥ե����뤬���ꤵ��Ƥ��ʤ����ˤϡ�
+ *hindo = �������(��)�����͡�ima = ������κ��Ȥä���ӥå�
+ *�Ǥ��롣�����ǡ��������ͤȤϡ��׻������7�ӥåȤ˰��̤��줿�ͤǤ��롣
+ *���������ͤǤϤʤ��������ͤ��֤��Τϡ��Ѵ���̤ΥǥХå��Τ���Ǥ��롣
+ */
+};
+
+struct	wnn_dai_bunsetsu {
+	int	end;		/* ����ʸ��� end char index */
+	int	start;		/* ����ʸ��� top char index */
+	struct	wnn_sho_bunsetsu	*sbn;	/* ��ʸ����Ϸ�̤ؤΥݥ��� */
+	int 	hyoka;		/* ��ʸ��ɾ���� */
+	int	sbncnt;		/* ��ʸ��� (������ξ��ϡ��������)
+				   DSD_SBN�ϡ�*sbn ���� sbncnt �������� */
+};
+
+struct	wnn_jdata {
+	int	dic_no;		/* �����ֹ� */
+	int	serial;		/* ������Υ���ȥ��ֹ� */
+	int	hinshi;		/* �ʻ��ֹ�(�ʻ��ֹ���ʻ�̾���б��ϡ�manual/etc
+				   �β��򻲾�) */
+	int	hindo;		/* ���� */
+	int	ima;		/* ���Ȥä���ӥå� */
+	int	int_hindo;	/* ���������� */
+	int	int_ima;	/* �����⡢���Ȥä���ӥå� */
+	w_char   *yomi;		/* �ɤߤ�ʸ���� */
+	w_char	*kanji;		/* ����ʸ���� */
+	w_char	*com;		/* ����ȥ�Υ�����ʸ���� */
+/*
+ *���٤ˤĤ��Ƥϡ����٥ե����뤬���ꤵ��Ƥ�����ϡ�
+ *hindo = ���٥ե������(����)�����͡�ima = ���٥ե�����κ��Ȥä���ӥå�
+ *int_hindo = �������(����)�����͡�int_ima = ������κ��Ȥä���ӥå�
+ *
+ *���٥ե����뤬���ꤵ��Ƥ��ʤ����ˤϡ�
+ *hindo = �������(����)�����͡�ima = ������κ��Ȥä���ӥå�
+ *int_hindo = -1��int_ima = -1
+ *
+ *���������ɤ���ξ��Ǥ⡢����ȥ꤬������ߤξ��֤λ��ˤϡ�
+ *hindo = -1, ima = 0 ���뤤�ϡ�
+ *int_hindo = -1, int_ima = 0 �Ȥʤ롣
+ *�����ǡ�(����)�����ͤȤϡ��׻������7�ӥåȤ˰��̤��줿�����ͤ��顢
+ *�ºݤ��ͤ����ꤷ���ͤǤ��롣
+ */
+};
+
+struct	wnn_ret_buf {
+	int	size;		/* buf ���� alloc ����Ƥ����礭�� */
+	char	*buf;		/* malloc �ʤɤǤȤ�줿�ΰ� */
+};
+
+
+#define	WNN_F_UNIQ_LEN	(sizeof(struct wnn_file_uniq))
+
+/* ���ι�¤�Τϡ��饤�֥���������Ѥ����� */
+struct wnn_file_head {
+  struct wnn_file_uniq{
+    int time;
+    int dev;
+    int inode;
+    char createhost[WNN_HOSTLEN];
+  } file_uniq;
+  struct wnn_file_uniq file_uniq_org;
+  int file_type;
+  char file_passwd[WNN_PASSWD_LEN];
+};
+
+#define WNN_HINSI_NAME_LEN 64
+
+#define	WNN_FILE_HEADER_LEN	(WNN_PASSWD_LEN + 8 + WNN_FILE_STRING_LEN + \
+				 sizeof(struct wnn_file_uniq) * 2 + 4)
+				/*
+				  8 is for future use 
+				  4 is for file_type.
+				 */
+
+#ifndef	JSERVER
+/*
+  JSLIB function declaration
+*/
+#define	js_open(server, timeout)	js_open_lang(server, "ja_JP", timeout)
+#define	js_connect(server,env_name)	js_connect_lang(server, env_name, "ja_JP")
+
+extern	WNN_JSERVER_ID *js_open_lang();
+extern	int		js_close();
+extern	WNN_JSERVER_ID *js_change_current_jserver();
+extern	struct wnn_env *js_connect_lang();
+extern	int		js_disconnect();
+extern	int		js_env_list();
+extern	int		js_param_set();
+extern	int		js_param_get();
+extern	char	       *js_get_lang();
+/**************************************/
+extern int js_access();
+extern int js_dic_add();
+extern int js_dic_delete();
+extern int js_dic_file_create();
+extern int js_dic_file_create_client();
+extern int js_dic_info();
+extern int js_dic_list();
+extern int js_dic_list_all();
+extern int js_dic_use();
+extern int js_env_exist();
+extern int js_env_sticky();
+extern int js_env_un_sticky();
+extern int js_file_comment_set();
+extern int js_file_discard();
+extern int js_file_info();
+extern int js_file_list();
+extern int js_file_list_all();
+extern int js_file_loaded();
+extern int js_file_loaded_local();
+extern int js_file_password_set();
+extern int js_file_read();
+extern int js_file_receive();
+extern int js_file_remove();
+extern int js_file_remove_client();
+extern int js_file_send();
+extern int js_file_stat();
+extern int js_file_write();
+extern void js_flush();
+extern int js_fuzokugo_get();
+extern int js_fuzokugo_set();
+extern int js_hindo_file_create();
+extern int js_hindo_file_create_client();
+extern int js_hindo_set();
+extern int js_hinsi_dicts();
+extern int js_hinsi_list();
+extern int js_hinsi_name();
+extern int js_hinsi_number();
+extern int js_hinsi_table_set();
+extern int js_isconnect();
+extern int js_kanren();
+extern int js_kantan_dai();
+extern int js_kantan_sho();
+extern int js_kanzen_dai();
+extern int js_kanzen_sho();
+extern int js_kill();
+extern int js_mkdir();
+extern int js_version();
+extern int js_who();
+extern int js_word_add();
+extern int js_word_comment_set();
+extern int js_word_delete();
+extern int js_word_info();
+extern int js_word_search();
+extern int js_word_search_by_env();
+
+#endif
+#endif	/* JSLIB */
diff --git a/wnn/load-wnn.lisp b/wnn/load-wnn.lisp
index 78ea776f9877b73cbb3e75612c7f6aeb88e9bb8a..a82a0e866883d204b78c2f4f59a412005f0dc424 100644
--- a/wnn/load-wnn.lisp
+++ b/wnn/load-wnn.lisp
@@ -18,7 +18,7 @@
 ;; 52.227-19 or DOD FAR Supplement 252.227-7013 (c) (1) (ii), as
 ;; applicable.
 ;;
-;; $fiHeader: $
+;; $fiHeader: load-wnn.lisp,v 1.1 1995/10/20 17:42:19 colin Exp $
 
 (in-package :user)
 
@@ -34,6 +34,11 @@
 	  :system-libraries (list sys::*libwnn-pathname*)
 	  :print t)))
 
+#+dlfcn
+(unless (ff:get-entry-point (ff:convert-to-lang "jl_open_lang"))
+  (cerror "Continue without jlib"
+	  "Can't load jlib dynamically - need to rebuild Lisp"))
+
 (provide :wnn)
 (pushnew :wnn *features*)
 
diff --git a/wnn/msg.c b/wnn/msg.c
new file mode 100644
index 0000000000000000000000000000000000000000..8baf30d69e1e28e61b54a67198b951f7b462bdae
--- /dev/null
+++ b/wnn/msg.c
@@ -0,0 +1,419 @@
+/*
+ * $Id: msg.c,v 1.1 1996/03/13 09:56:56 colin Exp $
+ */
+/*
+ * Copyright 1989, 1990, 1991, 1992 by OMRON Corporation
+ * Copyright 1991, 1992 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of OMRON and MIT not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  OMRON and MIT make no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * OMRON, MIT AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OMRON, MIT OR WNN CONSORTIUM BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *      Author: Hiroshi Kuribayashi    OMRON Corporation
+ *                              kuri@omron.co.jp
+ */
+/*
+	struct msg_cat msg_open(name, nlspath, lang)
+	char *name;
+	char *nlspath;
+	char *lang;
+
+	char * msg_get(cd, id, s, lang)
+	struct msg_cat cd;
+	int id;
+	char *s;
+
+	void msg_close(cd)
+	struct msg_cat cd;
+
+	format of message file
+	    <message id>\t<message>
+*/
+
+#include <stdio.h>
+#include "commonhd.h"
+#include "wnn_os.h"
+#include "msg.h"
+
+extern char *getenv();
+
+static char *
+bsearch(ky, bs, nel, width, compar)
+char *ky;
+char *bs;
+unsigned long nel;
+unsigned long width;
+int (*compar)();
+{
+    char *key = ky;
+    char *base = bs;
+    int two_width = width + width;
+    char *last = base + width * (nel - 1);
+
+    register char *p;
+    register int ret;
+#ifdef hpux
+    register int tmp;
+#endif
+
+    while (last >= base) {
+	p = base + width * ((last - base)/two_width);
+	ret = (*compar)((void *)key, (void *)p);
+
+	if (ret == 0)
+	    return ((char *)p);	/* found */
+#ifdef hpux
+	if (ret < 0) {
+	    tmp = p;
+	    tmp -= width;
+	    last = tmp;
+	} else {
+	    tmp = p;
+	    tmp += width;
+	    base = tmp;
+	}
+#else /* hpux */
+	if (ret < 0)
+	    last = p - width;
+	else
+	    base = p + width;
+#endif /* hpux */
+    }
+    return ((char *) 0);	/* not found */
+}
+
+static char *
+getlang(lang)
+char *lang;
+{
+    static char tmp[32];
+    char *p;
+    int i;
+
+    if(lang == NULL || *lang == '\0'){
+#ifdef	HAS_SETLOCALE
+        lang = setlocale(LC_ALL, NULL);
+        if(lang == NULL || *lang == '\0')
+#endif
+	{
+	    lang = getenv("LC_MESSAGES");
+	    if(lang == NULL || *lang == '\0'){
+		lang = getenv("LANG");
+		if(lang == NULL || *lang == '\0'){
+		    lang = DEF_LANG;
+		}
+	    }
+	}
+    }
+    for (i = 0, p = lang; *p && *p != '.'; i++, p++) {
+	tmp[i] = *p;
+    }
+    tmp[i] = '\0';
+    return(tmp);
+    /*
+    return(lang);
+    */
+}
+
+static int
+_search(id, bd)
+register int id;
+register struct msg_bd *bd;
+{
+    return(id - bd->msg_id);
+}
+
+static void
+_escape(op, ip)
+register char *op, *ip;
+{
+    for( ; *ip != 0; ip++, op++){
+	if(*ip == '\\'){
+	    switch(*++ip){
+	    case 'n':
+		*op = '\n';
+		break;
+	    case 't':
+		*op = '\t';
+		break;
+	    case 'b':
+		*op = '\b';
+		break;
+	    case 'r':
+		*op = '\r';
+		break;
+	    case 'f':
+		*op = '\f';
+		break;
+	    case 'v':
+		*op = '\v';
+		break;
+	    case '0':
+		*op = 0;
+		break;
+	    /*
+	    case 'a':
+		*op = '\a';
+		break;
+	    case 'e':
+	    case 'E':
+	    case 'o':
+	    case 'd':
+	    case 'x':
+		break;
+	    */
+	    default:
+		*op = *ip;
+		break;
+	    }
+	} else {
+	    if (*ip == '\n') {
+		*op = '\0';
+	    } else {
+		*op = *ip;
+	    }
+	}
+    }
+    *op = 0;
+}
+
+static char *
+get_msg_bd(cd, id)
+register struct msg_cat *cd;
+register int id;
+{
+    register struct msg_bd *bd;
+    if(cd->msg_bd == 0 || cd->msg_cnt == 0)
+	return(NULL);
+    bd = (struct msg_bd *)
+	bsearch(id, cd->msg_bd, cd->msg_cnt, sizeof(struct msg_bd), _search);
+    if(bd == NULL)
+	return(NULL);
+    return(bd->msg);
+}
+
+/* expand
+	%N: the value of the name parameter passed to msg_open()
+	%L: the value of LANG
+	%l: the language element from LANG
+	%t: the territory element from LANG
+	%c: the codeset element from LANG
+	%%: a single % charctor 
+*/
+static int
+expand(op, ip, name, lang)
+register char *op, *ip, *name, *lang;
+{
+     if (!ip || !*ip) return(-1);
+     for( ; *ip != 0; ip++){
+	if(*ip == '%'){
+	    switch(*++ip){
+	    case 'N':
+		if (!name || !*name) return(-1);
+		strcpy(op, name);
+		op += strlen(name);
+		break;
+	    case 'L':
+		if (!lang || !*lang) return(-1);
+		strcpy(op, lang);
+		op += strlen(lang);
+		break;
+	    /*
+	    case 'l':
+		strcpy(op, language);
+		op += strlen(language);
+		break;
+	    case 't':
+		strcpy(op, terr);
+		op += strlen(terr);
+		break;
+	    case 'c':
+		strcpy(op, code);
+		op += strlen(code);
+		break;
+	    case '%':
+		strcpy(op, "%");
+		op += strlen("%");
+		break;
+	    */
+	    default:
+		break;
+	    }
+	 }else{
+	    *op = *ip;
+	    op++;
+	 }
+     }
+     *op = '\0';
+     return(0);
+}
+
+
+struct msg_cat *
+msg_open(name, nlspath, lang)
+char *name;
+char *nlspath;
+char *lang;
+{
+    struct msg_cat *cd;
+
+    char fn[128];
+    FILE *fp;
+    char data[1024];
+    char save[1024];
+    int msg_cnt = 0;
+    int msg_byte = 0;
+    register char *dp;
+    register struct msg_bd *bd;
+    register char *msg, *l;
+
+    l = getlang(lang);
+    if (name && *name == '/') {
+	strcpy(fn, name);
+    } else {
+	if (expand(fn, nlspath, name, l) == -1) {
+	    return(NULL);
+	}
+    }
+
+    if (!(cd = (struct msg_cat *)malloc(sizeof(struct msg_cat))))
+	return(NULL);
+
+    strcpy(cd->name, name);
+    strcpy(cd->lang, l);
+    strcpy(cd->nlspath, nlspath);
+    cd->nextp = NULL;
+    cd->msg_cnt = 0;
+
+    if((fp = fopen(fn, "r")) == NULL){
+	/* message file not found */
+	cd->msg_bd = 0;
+	return(cd);
+    }
+    for( ; ; ){
+	/* first: count bytes */
+	if(fgets(data, 1024, fp) == NULL)
+	    break;
+	if(*data == '#')
+	    continue;	/* comment */
+	for(dp = data ; *dp != '\t'; dp++);	/* msg_id:message\n */
+	dp++;
+	msg_byte += strlen(dp);
+	msg_cnt++;
+    }
+    rewind(fp);
+
+    cd->msg_cnt = msg_cnt;
+    if (!(bd = cd->msg_bd = (struct msg_bd *)
+	       malloc((sizeof(struct msg_bd)) * msg_cnt + msg_byte + 1))) {
+	fclose(fp);
+	free(cd);
+	return(NULL);
+    }
+    msg = (char *) bd + (sizeof(struct msg_bd)) * msg_cnt;
+
+    for( ; ; ){
+	/* second : get message */
+	if(fgets(data, 1024, fp) == NULL)
+	    break;
+	if(*data == '#')
+	    continue;	/* comment */
+	for(dp = data ; *dp != '\t'; dp++);	/* msg_id:message\n */
+	*dp = 0;
+	dp++;
+	bd->msg_id = atoi(data);
+	bd->msg = msg;
+	bd++;
+	_escape(save, dp);
+	strcpy(msg, save);
+	msg += strlen(save);
+	*msg = 0;
+	msg++;
+    }
+    fclose(fp);
+    return(cd);
+}
+
+char *
+msg_get(catd, id, msg, lang)
+struct msg_cat *catd;
+int	id;
+char	*msg;
+register char	*lang;
+{
+    register struct msg_cat *cd;
+    char ret[128];
+    register char *msg_bd;
+
+    if(catd == 0)
+	goto error;
+    cd = catd;
+    if(lang == 0 || *lang == '\0'){
+	lang = cd->lang;
+    } else {
+	for ( ; ; cd = cd->nextp) {
+	    if(strcmp(lang, cd->lang) == 0)
+		break;
+	    if(cd->nextp == 0) {
+		cd->nextp = msg_open(cd->name, cd->nlspath, lang);
+		cd = cd->nextp;
+		break;
+	    }
+	}
+    }
+
+    if(msg_bd = get_msg_bd(cd, id))
+	return(msg_bd);
+error:
+    if(msg != 0 && *msg != '\0')
+	return(msg);
+    sprintf(ret, "mes_id = %d: %s", id, DEF_MSG);
+    return(ret);
+}
+
+void
+msg_close(cd)
+register struct msg_cat *cd;
+{
+    if(cd->nextp)
+	msg_close(cd->nextp);
+    if(cd->msg_bd)
+	free(cd->msg_bd);
+    if(cd)
+	free(cd);
+}
+
+#ifdef	not_use
+/* test */
+main()
+{
+	struct msg_cat *cd;
+
+	cd = msg_open("msg","%L", "ja_JP");
+
+	printf(msg_get(cd, 5, "message not found\n", "ja_JP"), 555);
+	printf(msg_get(cd, 6, "message not found\n", "zh_CN"));
+	printf(msg_get(cd, -1, "", "ja_JP"), 555);
+	printf(msg_get(cd, 2, "message not found\n", "ja_JP"), "abc");
+	printf(msg_get(cd, 100, "message not found\n", "zh_CN"), "abc");
+}
+#endif	/* not_use */
diff --git a/wnn/msg.h b/wnn/msg.h
new file mode 100644
index 0000000000000000000000000000000000000000..44e3bef1d409c0f8518452c5283e59b725fcf725
--- /dev/null
+++ b/wnn/msg.h
@@ -0,0 +1,58 @@
+/*
+ * $Id: msg.h,v 1.1 1996/03/13 09:56:58 colin Exp $
+ */
+/*
+ * Copyright 1989, 1992 OMRON Corporation
+ * Copyright 1990, 1992 OMRON Corporation and Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of OMRON and MIT not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  OMRON and MIT make no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * OMRON, MIT AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OMRON, MIT OR WNN CONSORTIUM BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *      Author: Hiroshi Kuribayashi    OMRON Corporation
+ *                              kuri@omron.co.jp
+ */
+
+struct msg_bd {
+    int msg_id;
+    char *msg;
+};
+
+struct msg_cat {
+    char lang[32];
+    char name[64];
+    char nlspath[64];
+    int msg_cnt;
+    struct msg_cat *nextp;
+    struct msg_bd *msg_bd;
+    /*int encoding;*/
+};
+
+#define	DEF_MSG "Message not found.\n"
+/*
+#define	DEF_LANG "C"
+*/
+#define	DEF_LANG "ja_JP"
+
+extern struct msg_cat *msg_open();
+extern char *msg_get();
+extern void msg_close();
diff --git a/wnn/pwd.c b/wnn/pwd.c
new file mode 100644
index 0000000000000000000000000000000000000000..ca4dd077d92adf79ddd0cc508534c5f2e7df8643
--- /dev/null
+++ b/wnn/pwd.c
@@ -0,0 +1,101 @@
+/*
+ * $Id: pwd.c,v 1.1 1996/03/13 09:57:00 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/*
+  eval(crypt(PWD, "HA")) routine.
+*/
+#ifndef JS
+#include <stdio.h>
+#include "commonhd.h"
+#include "jslib.h"
+#include "wnn_os.h"
+#endif
+
+extern char *crypt();
+
+#ifdef JS
+static
+#endif
+void
+new_pwd(src, encd)
+char *src, *encd;
+{
+    int i, x,c;
+    char xx[2];
+    char *cr;
+
+    if(encd == NULL)encd = src;
+    if(strcmp(src, "") == 0){ bzero(encd, WNN_PASSWD_LEN);return;}
+    x = time(NULL);
+    xx[0] = x & 0x3f;
+    xx[1] = (x & 0x3f00) >> 8;
+    for (i = 0; i < 2; i++) {
+	c = xx[i] + '.';
+	if (c > '9')
+	    c += 7;
+	if (c > 'Z')
+	    c += 6;
+	xx[i] = c;
+    }
+    cr = crypt(src, xx);
+    bzero(encd, WNN_PASSWD_LEN);
+    strncpy(encd, cr, WNN_PASSWD_LEN);
+}
+
+#ifdef JS
+static
+#endif
+int
+check_pwd(src, encd)
+char *src, *encd;
+{
+    if(strcmp(encd, "") == 0) return(1);  /* No passwd */
+    return(!strncmp(encd, crypt(src, encd),WNN_PASSWD_LEN));
+}
diff --git a/wnn/py_table.c b/wnn/py_table.c
new file mode 100644
index 0000000000000000000000000000000000000000..c36fc609499cbec783b3b125f27c1f30b5045df9
--- /dev/null
+++ b/wnn/py_table.c
@@ -0,0 +1,149 @@
+/*
+ * $Id: py_table.c,v 1.1 1996/03/13 09:57:01 colin Exp $
+ */
+/** 		Copyright OMRON Corporation. 1989, 1990, 1991, 1992, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its 
+ * documentation for any purpose is hereby granted without fee, provided 
+ * that all of the following conditions are satisfied:
+ *
+ * <1>	The above copyright notices appear in all copies
+ * <2>	Both the copyright notices and this permission notice appear in 
+ *	supporting documentation
+ * <3>	The name of "cWnn" isn't changed unless substantial modifications 
+ * 	are made
+ * <4>	Following words followed by the above copyright notices appear
+ *    	in all supporting documentation of software based on "cWnn":
+ *
+ * 	This software is based on the original version of cWnn developed 
+ *	by OMRON Corporation and Wnn developed by Kyoto University Research 
+ *	Institute for Mathematical Sciences (KURIMS), OMRON Corporation and 
+ * 	ASTEC Inc."
+ *
+ * <5>	The names of OMRON may not be used in advertising or publicity 
+ *	pertaining to distribution of the software without specific, written 
+ *	prior permission
+ *
+ *  OMRON Corporation makes no representations about the suitability of this 
+ *  software for any purpose.  It is provided "as is" without express or 
+ *  implied warranty.
+ *
+ *  Wnn consortium is one of distributors of the official Wnn source code
+ *  release.  Wnn consortium also makes no representations about the
+ *  suitability of this software for any purpose.  It is provided "as is"
+ *  without express or implied warranty.
+ *
+ *  OMRON AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ *  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ *  IN NO EVENT SHALL OMRON OR WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL,
+ *  INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ *  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ *  PERFORMANCE OF THIS SOFTWARE.
+ *
+ *  This sofeware is developed by OMRON Corporation, based on the original 
+ *  version of Wnn which was developed by Kyoto University Research Institute 
+ *  for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc. 
+ *
+ *  	Copyright Kyoto University Research Institute for Mathematical 
+ *		Sciences 1987,1988,1989,1990,1991, 1992
+ * 	Copyright OMRON Corporation 1987,1988,1989,1990,1991, 1992
+ *	Copyright ASTEC Inc. 1987, 1988,1989,1990,1991, 1992
+ *
+ *  Contact:	Tel:   	+81-75-951-5111
+ *		Fax:   	+81-75-955-2442
+ *		E-mail: zhong@ari.ncl.omron.co.jp
+**/
+/**  cWnn  Version 1.1	 **/
+
+#include  <ctype.h>
+#include "commonhd.h"
+#ifdef CHINESE
+#include "cplib.h"
+
+/* pyshengmu_tbl[]: ShengMu table of Chinese PinYin */
+char 	*py_shengmu_tbl[PY_NUM_SHENGMU] = {
+	
+	"",  "B", "C",  "Ch", "D",  
+	"F", "G", "H",  "J",  "K", 
+	"L", "M", "N",  "P",  "Q", 
+	"R", "S", "Sh", "T",  "W",
+	"X", "Y", "Z",  "Zh" 
+	};
+	
+/* py_yunmu_tbl[]: YunMu table of Chinese ZhuYin */
+char 	*py_yunmu_tbl[PY_NUM_YUNMU*5] = {
+
+	"��",    "��",    "��",    "��",    "��",
+	"a��",    "����",    "����",    "����",    "����",
+	"ai��",   "��i��",   "��i��",   "��i��",   "��i��",
+	"an��",   "��n��",   "��n��",   "��n��",   "��n��",
+	"ang��",  "��ng��",  "��ng��",  "��ng��",  "��ng��",
+	"ao��",   "��o��",   "��o��",   "��o��",   "��o��",
+	"e��",    "����",    "����",    "����",    "����",
+	"ei��",   "��i��",   "��i��",   "��i��",   "��i��",
+	"en��",   "��n��",   "��n��",   "��n��",   "��n��",
+	"eng��",  "��ng��",  "��ng��",  "��ng��",  "��ng��",
+	"er��",   "��r��",   "��r��",   "��r��",   "��r��",
+	"i��",    "����",    "����",    "����",    "����",
+	"ia��",   "i����",   "i����",   "i����",   "i����",
+	"ian��",  "i��n��",  "i��n��",  "i��n��",  "i��n��",
+	"iang��", "i��ng��", "i��ng��", "i��ng��", "i��ng��",
+	"iao��",  "i��o��",  "i��o��",  "i��o��",  "i��o��",
+	"ie��",   "i����",   "i����",   "i����",   "i����",
+	"in��",   "��n��",   "��n��",   "��n��",   "��n��",
+	"ing��",  "��ng��",  "��ng��",  "��ng��",  "��ng��",
+	"iong��", "i��ng��", "i��ng��", "i��ng��", "i��ng��",
+	"iu��",   "i����",   "i����",   "i����",   "i����",
+	"m��",    "m��",    "m��",    "m��",    "m��",
+	"n��",    "n��",    "����",    "����",    "����",
+	"ng��",   "ng��",   "ng��",   "ng��",   "ng��",
+	"o��",    "����",    "����",    "����",    "����",
+	"ong��",  "��ng��",  "��ng��",  "��ng��",  "��ng��",
+	"ou��",   "��u��",   "��u��",   "��u��",   "��u��",
+	"u��",    "����",    "����",    "����",    "����",
+	"ua��",   "u����",   "u����",   "u����",   "u����",
+	"uai��",  "u��i��",  "u��i��",  "u��i��",  "u��i��",
+	"uan��",  "u��n��",  "u��n��",  "u��n��",  "u��n��",
+	"uang��", "u��ng��", "u��ng��", "u��ng��", "u��ng��",
+	"ue��",   "u����",   "u����",   "u����",   "u����",
+	"ui��",   "u����",   "u����",   "u����",   "u����",
+	"un��",   "��n��",   "��n��",   "��n��",   "��n��",
+	"uo��",   "u����",   "u����",   "u����",   "u����",
+	"����",    "����",    "����",    "����",    "����",
+	"��e��",   "������",   "������",   "������",   "������",
+	"0��",   "1��",   "2��",   "3��",   "4��",  /* for undefinited YunMu  */
+	};
+
+
+/* pinyin_tbl:  size is NUM_SHENGMU*NUM_YUNMU, including empty ShengMu */
+/*     and empty YunMu , and undefinited YunMu'-' */
+
+int  pinyin_tbl[PY_NUM_SHENGMU*PY_NUM_YUNMU] = {
+					    	
+  0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,
+  0,1,1,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,1,
+  0,1,1,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,
+  0,1,1,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,
+  0,1,1,1,1,1,1,1,1,1,0,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,
+  0,1,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,
+  0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,0,0,1,
+  0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,1,0,1,1,1,0,0,1,
+  0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,1,0,1,0,1,0,0,0,1,
+  0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,0,0,1,
+  0,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1,1,1,1,
+  0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,1,1,1,0,1,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,
+  0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,0,1,0,0,0,0,1,1,1,0,0,1,0,0,0,0,1,1,1,1,
+  0,1,1,1,1,1,0,1,1,1,0,1,0,1,0,1,1,1,1,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,
+  0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,1,0,1,0,1,0,0,0,1,
+  0,0,0,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,0,0,1,1,1,0,0,1,
+  0,1,1,1,1,1,1,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,
+  0,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,
+  0,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,
+  0,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,1,
+  0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,1,0,1,0,1,0,0,0,1,
+  0,1,0,1,1,1,1,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,0,0,1,1,1,1,0,0,1,0,1,0,1,0,0,0,1,
+  0,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,
+  0,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,0,0,1
+	};
+#endif /* CHINESE */
diff --git a/wnn/rk_bltinfn.c b/wnn/rk_bltinfn.c
new file mode 100644
index 0000000000000000000000000000000000000000..be3bc08f4b36900725cae96c3cbabee52175ec9c
--- /dev/null
+++ b/wnn/rk_bltinfn.c
@@ -0,0 +1,338 @@
+/*
+ * $Id: rk_bltinfn.c,v 1.1 1996/03/13 09:57:03 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_bltinfn.c
+						87.12. 6  �� ��
+
+	�Ѵ��Ѥ��Ȥ߹��ߴؿ��Τ���ʣ���ʤ�Τ�������Ƥ��롣
+	���Ѣ���Ⱦ�Ѥ��Ѵ������Ρ�
+***********************************************************************/
+/*	Version 3.0
+ */
+#include "commonhd.h"
+#include "config.h"
+#include "rk_header.h"
+
+ /* Ⱦ��ʸ���Υ����ɤ�define */
+#define HKCHOU	(HNKAK1 * 0x100 + 0xB0) /* �� */
+#define HKDKTN	(HNKAK1 * 0x100 + 0xDE) /* �� */
+#define HKHNDK	(HNKAK1 * 0x100 + 0xDF) /* �� */
+#define HKMARU	(HNKAK1 * 0x100 + 0xA1) /* �� */
+#define HKHRKG	(HNKAK1 * 0x100 + 0xA2) /* �� */
+#define HKTJKG	(HNKAK1 * 0x100 + 0xA3) /* �� */
+#define HKTTEN	(HNKAK1 * 0x100 + 0xA4) /* �� */
+#define HKNKPT	(HNKAK1 * 0x100 + 0xA5) /* �� */
+
+ /* ����ʸ���Υ����ɤ�define */
+#define CHOUON	(0xA1BC) /* �� */
+#define DAKUTN	(0xA1AB) /* �� */
+#define HNDAKU	(0xA1AC) /* �� */
+#define MNMARU	(0xA1A3) /* �� */ /* ̾���� MaNMARU�ʤޤ�ޤ�ˤ�ά */
+#define HRKKAG	(0xA1D6) /* �� */
+#define TJIKAG	(0xA1D7) /* �� */
+#define TOUTEN	(0xA1A2) /* �� */
+#define NKPOTU	(0xA1A6) /* �� */
+
+static char _lang[6];
+
+void
+romkan_set_lang(lang)
+char *lang;
+{
+	strncpy(_lang, lang, 5);
+	_lang[5] = 0;
+}
+
+ /** ASCIIʸ�������� */
+letter	to_zenalpha(l)
+letter	l;
+{
+	letter	retval;
+
+	static	uns_chr *data = (uns_chr *)
+	   "�����ɡ������ǡʡˡ��ܡ��ݡ������������������������������䡩\
+�����£ãģţƣǣȣɣʣˣ̣ͣΣϣУѣңӣԣգ֣ףأ٣ڡΡ�ϡ�����������\
+������������������������������Сáѡ�";
+
+#ifdef	CHINESE
+	static	uns_chr *data_cn = (uns_chr *)
+	   "���������磥����������������������������������������������������\
+�����£ãģţƣǣȣɣʣˣ̣ͣΣϣУѣңӣԣգ֣ףأ٣ڣۣ��ݣޣߣ������\
+�������������������������������������";
+#endif	/* CHINESE */
+#ifdef	KOREAN
+	static  uns_chr *data_ko = (uns_chr *)
+	   "����������������������������������������������������������������\
+�����£ãģţƣǣȣɣʣˣ̣ͣΣϣУѣңӣԣգ֣ףأ٣ڣۣܣݣޣߣ������\
+�������������������������������������";
+#endif  /* KOREAN */
+
+	if(' ' <= l && l <= '~') {
+		l = (l - ' ') << 1;
+#ifdef	CHINESE
+	    if(!strcmp(_lang, WNN_C_LANG) || !strcmp(_lang, WNN_T_LANG)){
+		retval = data_cn[l] << 8;
+		retval += data_cn[++l];
+	    } else
+#endif
+#ifdef  KOREAN
+	    if(!strcmp(_lang, WNN_K_LANG)){
+		retval = data_ko[l] << 8;
+		retval += data_ko[++l];
+	    } else
+#endif  /* KOREAN */
+	    {
+		retval = data[l] << 8;
+		retval += data[++l];
+	    }
+		return(retval);
+	} else return(l);
+}
+
+static	char	*hankdata[] = {
+	"��","��","��","��","��","��","��","��","��","��",
+	"��","����","��","����","��","����","��","����","��","����",
+	"��","����","��","����","��","����","��","����","��","����",
+	"��","����","��","����","��","��","�Ž�","��","�Î�","��","�Ď�",
+	"��","��","��","��","��",
+	"��","�ʎ�","�ʎ�","��","�ˎ�","�ˎ�","��","�̎�","�̎�",
+	"��","�͎�","�͎�","��","�Ύ�","�Ύ�",
+	"��","��","��","��","��",
+	"��","��","��","��","��","��",
+	"��","��","��","��","��",
+	"��","��","��","��","��","��",
+	"����","��","��"
+};  /* ���Ѥ������äƤ�Τ����� */
+
+ /**	���hankdata�����ºݤ˻Ȥ�Ⱦ�ѥ����ɤ�ɽ���Ƥ��ʤ��Ȥ����ºݤΤ�Τ�
+	�������롣���������˰������Ƥ� */
+void
+hank_setup()
+{
+	int	i;
+	char	*s, orig_hnkak1;
+
+	orig_hnkak1 = *hankdata[0];
+ /*	*hankdata[] �Ǥ�Ⱦ��ʸ���Σ��Х��ȤᡣȾ��ʸ���Σ��Х��Ȥ�������ۤʤ�
+	�褦��¾����˰ܿ�����Ȥ��ϡ�HNKAK1��define���Ѥ����OK��â��romkan��
+	���������Ⱦ��ʸ���ʤ��Υե�����ˤΤ�¸�ߡˤ⥳��С��Ȥ��ơ����ε���
+	�˹�碌��ۤ���˾�ޤ����������������ǥ����Ǥ��Υե��������������
+	������ˡ�Ⱦ��ʸ���ΰ��������ޤ������ʤ���礬����Τǡ��ä�
+	����С��Ȥ򤷤ʤ��Ȥ�ư���褦�˽��֤Ϥ��Ƥ��롣���줬������
+	hank_setup()�Ǥ��롣hankdata�ϡ����������� hank_setup()�ˤ�ä�
+	�ºݤ�Ⱦ�ѥ����ɤ�ľ����롣*/
+
+	if(orig_hnkak1 == (char)HNKAK1) return;
+	for(i = 0; i < numberof(hankdata); i++){
+		for(s = hankdata[i]; *s; s += 2)
+			if(*s == orig_hnkak1) *s = HNKAK1;
+	}
+}
+
+ /** ���ʢ�Ⱦ�ѥ������ʡ���̤���ʸ���ˤʤ뤳�Ȥ⤢�롣*/
+void
+to_hankata(in, outp)
+letter	in, **outp;
+{
+	uns_chr *p, c;
+	letter	*out;
+
+	out = *outp;
+	switch(in){
+		case CHOUON: *out++ = HKCHOU; break;
+		case DAKUTN: *out++ = HKDKTN; break;
+		case HNDAKU: *out++ = HKHNDK; break;
+		case MNMARU: *out++ = HKMARU; break;
+		case HRKKAG: *out++ = HKHRKG; break;
+		case TJIKAG: *out++ = HKTJKG; break;
+		case TOUTEN: *out++ = HKTTEN; break;
+		case NKPOTU: *out++ = HKNKPT; break;
+		default:
+			if(is_kata(in)){
+				for(p = (uns_chr *)hankdata[in - KATBGN];
+				    c = *p; p++)
+					*out++ = (c << 8) + *++p;
+			} else 
+			if(is_hira(in)){
+				for(p = (uns_chr *)hankdata[in - HIRBGN];
+				    c = *p; p++)
+					*out++ = (c << 8) + *++p;
+			} else {
+				*out++ = in;
+			}
+	}
+	*out = EOLTTR;
+	*outp = out;
+}
+
+ /**	Ⱦ�ѥ������ʢ��Ҥ餬�ʡ�â�������������ʸ�����ĤˤޤȤ�Ƥ�
+	����ʤ��Τ����ա�*/
+letter	to_zenhira(l)
+letter	l;
+{
+	letter	retval;
+
+	static	uns_chr *data = (uns_chr *)
+	   "���֡ס����򤡤�����������á���������������������������������\
+���ĤƤȤʤˤ̤ͤΤϤҤդؤۤޤߤ�������������󡫡�";
+
+#ifdef	CHINESE
+	static	uns_chr *data_cn = (uns_chr *)
+	   "�����������򤡤�����������á������������𤭤������Ȥ���������\
+���ĤƤȤʤˤ̤͵ĤϤҤդؤۤޤߤ��Ҳ��������������";
+#endif	/* CHINESE */
+
+	if(is_hankata(l)){
+		l = (l - HKKBGN) << 1;
+#ifdef	CHINESE
+	    if(!strcmp(_lang, WNN_C_LANG) || !strcmp(_lang, WNN_T_LANG)){
+		retval = data_cn[l] << 8;
+		retval += data_cn[++l];
+	    } else
+#endif
+	    {
+		retval = data[l] << 8;
+		retval += data[++l];
+	    }
+		return(retval);
+	} else return(l);
+}
+
+ /**	Ⱦ�ѥ������ʢ����ѡ�â�������������ʸ�����ĤˤޤȤ�Ƥ�
+	����ʤ��Τ����ա�*/
+letter	to_zenkata(l)
+letter	l;
+{
+	return(is_hankata(l) ? (l = to_zenhira(l), to_kata(l)) : l);
+}
+
+ /* �ӥåȥ٥����ι��� */
+#define bitvec(b0, b1, b2, b3, b4, b5, b6, b7) (			 \
+	(char)b0 | ((char)b1 << 1) | ((char)b2 << 2) | ((char)b3 << 3) | ((char)b4 << 4) | ((char)b5 << 5) | \
+	((char)b6 << 6) | ((char)b7 << 7)						 \
+)
+
+ /** char������ h ��ӥåȥ٥����ȸ��Ƥ�����i�ӥåȤ�����å����� */
+#define bitlook(h, i) (h[(i) >> 3] & (1 << ((i) & 7)))
+
+#define KATRPT	0xA1B3 /* �� */
+#define HIRRPT	0xA1B5 /* �� */
+#define KATA_U	0xA5A6 /* �� */
+#define KAT_VU	0xA5F4 /* �� */
+#define HIR_KA	0xA4AB /* �� */
+#define HIR_HO	0xA4DB /* �� */
+#define KAT_KA	0xA5AB /* �� */
+#define KAT_HO	0xA5DB /* �� */
+#define HIR_HA	0xA4CF /* �� */
+#define KAT_HA	0xA5CF /* �� */
+
+ /**	�����Ⱦ�����򤯤äĤ��롣��̤ϰ�������ʸ����*/
+void
+handakuadd(in, outp)
+letter	in, **outp;
+{
+	if((HIR_HA <= in && in <= HIR_HO) ? 0 == (in - HIR_HA) % 3 :
+	   (KAT_HA <= in && in <= KAT_HO && 0 == (in - KAT_HA) % 3)){
+		*(*outp)++ = in + 2;
+	} else {
+		*(*outp)++ = in;
+		*(*outp)++ = HNDAKU;
+	}
+	**outp = EOLTTR;
+}
+
+ /**	����������򤯤äĤ��롣��̤ϰ�������ʸ����*/
+void
+dakuadd(in, outp)
+letter	in, **outp;
+{
+	static	char	flgbit[] = {
+		bitvec(1, 0, 1, 0, 1, 0, 1, 0), /* ���������������� */
+		bitvec(1, 0, 1, 0, 1, 0, 1, 0), /* ���������������� */
+		bitvec(1, 0, 1, 0, 1, 0, 1, 0), /* ���������������� */
+		bitvec(0, 1, 0, 1, 0, 1, 0, 0), /* �äĤŤƤǤȤɤ� */
+		bitvec(0, 0, 0, 0, 1, 0, 0, 1), /* �ˤ̤ͤΤϤФѤ� */
+		bitvec(0, 0, 1, 0, 0, 1, 0, 0), /* �ӤԤդ֤פؤ٤� */
+		bitvec(1, 0, 0, 0, 0, 0, 0, 0)	/* �� */
+	};
+	letter	c;
+
+	if((HIR_KA <= in && in <= HIR_HO) ? (c = in - HIR_KA, 1) :
+	   (KAT_KA <= in && in <= KAT_HO && (c = in - KAT_KA, 1))){
+		if(bitlook(flgbit, c)){
+			*(*outp)++ = in + 1;
+		} else {
+			*(*outp)++ = in;
+			*(*outp)++ = DAKUTN;
+		}
+	} else switch(in){
+		case KATRPT:
+		case HIRRPT:
+			*(*outp)++ = in + 1; break;
+		case KATA_U:
+			*(*outp)++ = KAT_VU; break;
+		default:
+			*(*outp)++ = in;
+			*(*outp)++ = DAKUTN;
+	}
+	**outp = EOLTTR;
+}
+
+ /** in��Ϳ����줿�����ɤ�base�ʤο����ˤ���outp������롣*/
+void
+to_digit(in, base, outp)
+letter	in, base, **outp;
+{
+	letter	c, vtol();
+
+	if(c = in, c /= base) to_digit(c, base, outp);
+	*(*outp)++ = vtol(in % base);
+	**outp = EOLTTR;
+}
+
diff --git a/wnn/rk_extvars.h b/wnn/rk_extvars.h
new file mode 100644
index 0000000000000000000000000000000000000000..12808635153dd8ea04258f9bcbd8c1daaf41c818
--- /dev/null
+++ b/wnn/rk_extvars.h
@@ -0,0 +1,113 @@
+/*
+ * $Id: rk_extvars.h,v 1.1 1996/03/13 09:57:05 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_extvars.h
+						88. 6.16  �� ��
+
+	��İʾ�Υե�����ˤޤ����äƻȤ����ѿ���extern�����
+	����rk_vars.c�������
+***********************************************************************/
+/*	Version 3.0
+ */
+extern	char	rk_errstat;
+
+extern	int	flags;
+extern	jmp_buf env0;
+
+extern	FILE	*modefile;
+extern	char	nulstr[];
+
+extern	char	*hcurread, *mcurread, *curfnm, *curdir;
+extern	letter	*ltrbufbgn;
+extern	FILE	*nestfile[], **base;
+
+extern	struct	modestat
+{
+	modetyp	moderng;	/* �⡼�ɤξ��֤κ����͡ܣ� */
+	modetyp	curmode;	/* �⡼�ɤξ��� */
+} modesw[];
+
+extern	char	hyoshu[];
+extern	char	**modmeiptr, *modmeibgn[], *modmeimem, modmeimem_[];
+extern	char	**dspnamptr, *dspnambgn[], *dspcod, dspcod_[], *dspmod[][2];
+
+extern	char	**hyomeiorg, **hyomeiptr, *hyomeimem;
+extern	char	**pathmeiorg, **pathmeiptr, *pathareaorg, *pathmeimem;
+
+extern	int	usemaehyo[], usehyo[], useatohyo[], naibu_[], *naibu;
+
+extern	letter	*lptr;
+extern	letter	rk_input, disout[], rk_output[], keybuf[], urabuf[];
+extern	int	lastoutlen, lastkbflen;
+extern	letter	oneletter[], nil[];
+extern	int	hyonum;
+
+extern	struct funstr	/* �Ȥ߹��ߴؿ����������ݻ�����struct */
+{
+	char	*fnname;	/* �ؿ�̾ */
+	char	appear;		/* ���ϥ������������ϥ����������Хåե��Ĥ���
+				   �˽񤱤뤫�ɤ����Υե饰���ӥå� */
+	char	argnum;		/* �����θĿ� */
+	char	fntype;		/* ��̤Υ����� */
+} rk_funstr;
+
+extern	struct	dat	/* ���ϡ����ϡ��Хåե��Ĥ����ؤΥݥ��� */
+{
+	letter	*code[3];
+} rk_dat;
+
+extern	struct	hyo
+/* ��Ĥ��б�ɽ�Ρ��Ѵ��ǡ����ڤӳ��ѿ����Ѱ�Ρ���Ǽ���ؤΥݥ��󥿡�*/
+{
+	struct	dat	*data;
+	letter		**hensudef;
+} rk_hyo;
+
+extern	struct	funstr	func[];
+extern	struct	hyo	hyo_n[];
diff --git a/wnn/rk_fundecl.h b/wnn/rk_fundecl.h
new file mode 100644
index 0000000000000000000000000000000000000000..7c58b7d190dec97a1ac0f8e59f93571f4a5def69
--- /dev/null
+++ b/wnn/rk_fundecl.h
@@ -0,0 +1,66 @@
+/*
+ * $Id: rk_fundecl.h,v 1.1 1996/03/13 09:57:06 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_fundecl.h
+						87.10. 9  �� ��
+
+	�饤�֥��ؿ��η���������桼���˳��������include
+	�ե�����ϡ������rk_macros.h���ڤ�rk_spclval.h��
+***********************************************************************/
+/*	Version 3.0
+ */
+extern	letter	*ltrncpy();
+extern	int	ltrcmp(), ltrncmp();
+
+extern	int	romkan_init(), romkan_init2(), romkan_init3();
+extern	letter	romkan_getc(), *romkan_henkan(), romkan_next();
+extern	letter	romkan_ungetc(), romkan_unnext();
+extern	void	romkan_clear();
+extern	char	*romkan_dispmode();
+extern	char	rk_errstat; /* ����ϴؿ��ǤϤʤ��ѿ� */
diff --git a/wnn/rk_header.h b/wnn/rk_header.h
new file mode 100644
index 0000000000000000000000000000000000000000..a535fc64d7c53e0f9877a1c628444ba5c18138d9
--- /dev/null
+++ b/wnn/rk_header.h
@@ -0,0 +1,144 @@
+/*
+ * $Id: rk_header.h,v 1.1 1996/03/13 09:57:08 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_header.h
+						88. 5.20  �� ��
+
+	rk_main.c rk_read.c rk_modread.c rk_bltinfn.c�ζ��̥إå���
+	��Ǽ�äƤ���������礭���ʤɤ������
+***********************************************************************/
+/*	Version 3.0
+ */
+/*	make����ɬ�פ�define
+
+	BSD42		BSD�ˤ�strings.h����ѡ�string.h��Ȥ��������ס�
+	SYSVR2		System V�ˤ����������¤��줿toupper��tolower�����
+			�ʤʤ��Ƥ�ư����
+	MVUX		ECLIPSE MV�Ǥα�ž����define  IKIS����ưdefine�����
+
+	RKMODPATH="ʸ����"
+			����ʸ�����⡼�����ɽ�Υ������ѥ��δĶ��ѿ���
+			̾���ˤ���
+	WNNDEFAULT	��@LIBDIR�פ�ɸ������ɽ�Τ���ǥ��쥯�ȥ��ɽ����
+			�褦�ˤ���	
+	IKIS		Ⱦ�Ѳ�̾�Σ��Х����ܤ�0xA8�ʥǥե���Ȥ�0x8E�ˤˤ���
+
+	����¾ �ǥХå�����ɬ�פ˱����� KDSP��CHMDSP��define
+*/
+
+#ifdef MVUX
+#  define IKIS
+#endif
+
+#include <stdio.h>
+#ifdef BSD42
+#  include <strings.h>
+#  define strchr  index
+#  define strrchr rindex
+#else
+#  include <string.h>
+#endif
+#include "rk_macros.h"
+
+#define ESCCHR	'\033'
+#define BASEMX	(26 + 10)
+
+#define REALFN	200 /* ɽ�Υե�͡���κ���Ĺ */
+
+#ifdef KOREAN
+#define LINALL  30000 /* �б�ɽ�����ιԿ���� */
+#define SIZALL  300000 /* �б�ɽ������ɽ���κ��祵����*/
+#else
+#define LINALL	2000 /* �б�ɽ�����ιԿ���� */
+#define SIZALL	20000 /* �б�ɽ������ɽ���κ��祵������
+			ɽ��Ĥ��ѿ����Ѱ�Ĺ�ι�פȤ��Ƥ�ȤäƤ� */
+#endif
+
+#define LINSIZ	1000 /* �б�ɽ�ΰ�Ԥκ��祵���� */
+#define TRMSIZ	500 /* �б�ɽ�ΰ���ܤκ��祵������
+			�⡼��̾�κ�Ĺ�Ȥ��Ƥ�ȤäƤ� */
+#define KBFSIZ	100 /* �ܽ����Хåե��Υ����� */
+#define DSPLIN	256 /* �ǥХå��� */
+#define OUTSIZ	200 /* ���ϥХåե��Υ����� */
+#define RSLMAX	20 /* �ؿ����ͤȤ����֤�ʸ����κ�Ĺ */
+
+#define VARMAX	50 /* ɽ��Ĥ��ѿ��Ŀ� */
+#define VARTOT	2000 /* ��ɽ���ѿ��Ŀ��� */
+#define VARLEN	500 /* �ѿ�̾��Ĺ���η� */
+
+#define FILNST	20
+
+	/* rk_modread.c�ǻȤ�define */
+
+#define HYOMAX	40 /* �Ѵ��б�ɽ�κ���Ŀ� */
+#define HYOMEI	500 /* ɽ̾��ʸ������ */
+#define PTHMAX	30 /* �������ѥ��κ���Ŀ� */
+#define PTHMEI	800 /* �������ѥ�̾��ʸ������ */
+#define MODMAX	50 /* �⡼�ɤμ���� */
+#define MODMEI	300 /* �⡼�ɤ���ʸ���� */
+#define DMDMAX	40 /* �⡼��ɽ���μ���� */
+#define DMDCHR	250 /* �⡼��ɽ������ʸ���� */
+#define MDHMAX	2500 /* �⡼��ɽ�κ��祵���� */
+  /* �⡼��ɽ�κǽ��listscan�λ��ϡ����顼���θ���ơ��ꥹ��1�Ĥ�buffer��
+	ɽ�Υ�����ʬ��äƤ�����*/
+#define MDT1LN	200 /* �⡼������ꥹ��1�Ĥκ���Ĺ */
+#define NAIBMX	400 /* �⡼�����ɽ������ɽ���κ��祵���� */
+			/* Change KURI 200 --> 400 */
+
+#define ARGMAX	2 /* ���Ƚ�Ǵؿ��ΰ����κ���Ŀ� */
+
+ /* �ǥ��쥯�ȥ�̾�ζ��ڤ��define��UNIX�ѡˡ�UNIX�ʳ��δĶ��ǻȤ��ˤ�
+    ����ȡ�fixednamep()���ѹ���ɬ�פ������readmode()��getenv�ط��������ˡ�*/
+#define KUGIRI '/'
+
+ /* ���顼������ */
+#ifndef _WNN_SETJMP
+#define _WNN_SETJMP
+#include <setjmp.h>
+#endif
diff --git a/wnn/rk_macros.h b/wnn/rk_macros.h
new file mode 100644
index 0000000000000000000000000000000000000000..8e95744834ae2056017bc6fa87ea742046433370
--- /dev/null
+++ b/wnn/rk_macros.h
@@ -0,0 +1,108 @@
+/*
+ * $Id: rk_macros.h,v 1.1 1996/03/13 09:57:09 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_macros.h
+						87.11.17  �� ��
+
+    ���Ѵ��ǻȤäƤ���ޥ����ؿ�����rk_header.h ��include����Ƥ��롣
+    �����include����ȡ���ưŪ��rk_spclval.h��include����롣�桼����
+    �ץ������Ǥ����include����С�to_upper�ʤɤΥޥ������Ȥ��롣 
+***********************************************************************/
+/*	Version 3.0
+ */
+#ifndef RKMCRO
+
+#define RKMCRO
+#include "rk_spclval.h" /* ctype.h��Ȥ�ʤ��ޥ����ϡ��������������Ƥ��� */
+
+#ifndef MVUX
+#  include <ctype.h>
+#endif
+
+	/* �ޥ����ؿ����ʰ�����ʣ����ɾ�������Τ�¿���Τ����ա�*/
+
+ /* 7�ӥåȥ�����char�ѥޥ��� */
+#define isoctal(c) (isdigit(c) && (c) < '8') /* 8�ʤο����� */
+#define isnulsp(c) (isspace(c) || (c) == '\0') /* EOL���϶���ʸ���Ǥ��뤫 */
+
+  /* ��ʸ��������ʸ���Ѵ���������
+     SYSVR2�����  toupdown   7�ӥå�char��isascii������Ω���ϰϡ�
+		   _toupdown  ��ʸ����isalpha������Ω���ϰϡ�
+    ����¾�ξ��   toupdown		    ��				*/
+#ifdef SYSVR2
+#  define _toupdown(c) (isupper(c) ? _tolower(c) : _toupper(c))
+#  define toupdown(c) (isupper(c) ? _tolower(c) : toupper(c))
+#else
+#  define toupdown(c) (isupper(c) ? tolower(c) : toupper(c))
+#endif
+
+ /* ctype�ޥ������������ĥ������Ρ�letter���������ˤ�Ŭ�Ѳġ�
+    is_eolsp�������ȼ��Τ�Ρ�*/
+#define is_lower(l) (isascii(l) && islower(l))
+#define is_upper(l) (isascii(l) && isupper(l))
+#define is_alpha(l) (isascii(l) && isalpha(l))
+#define is_alnum(l) (isascii(l) && isalnum(l))
+#define is_digit(l) (isascii(l) && isdigit(l))
+#define is_octal(l) (isascii(l) && isoctal(l))
+#define is_xdigit(l) (isascii(l) && isxdigit(l))
+#define is_space(l) (isascii(l) && isspace(l))
+#define is_cntrl(l) (isascii(l) && iscntrl(l))
+#define is_nulsp(l) (isascii(l) && isnulsp(l))
+#define is_eolsp(l) (is_space(l) || (l) == EOLTTR)
+#ifdef SYSVR2
+#  define to_upper(l) (is_lower(l) ? _toupper(l) : (l))
+#  define to_lower(l) (is_upper(l) ? _tolower(l) : (l))
+#  define to_updown(l) (is_alpha(l) ? _toupdown(l) : (l))
+#else
+#  define to_upper(l) (is_lower(l) ? toupper(l) : (l))
+#  define to_lower(l) (is_upper(l) ? tolower(l) : (l))
+#  define to_updown(l) (is_alpha(l) ? toupdown(l) : (l))
+#endif
+
+#endif /* RKMCRO */
diff --git a/wnn/rk_main.c b/wnn/rk_main.c
new file mode 100644
index 0000000000000000000000000000000000000000..21ad0a4c01b1e16066aa03b8ad96c8c931fa908d
--- /dev/null
+++ b/wnn/rk_main.c
@@ -0,0 +1,1561 @@
+/*
+ * $Id: rk_main.c,v 1.1 1996/03/13 09:57:12 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_main.c
+						88. 6.10  �� ��
+
+	�����޻������Ѵ�������¾�����ϥ����ɤ��Ѵ�����ץ�����ࡣ
+	ASCII�����ɻ��Ѥ�����Ȥ��Ƥ��롣
+	���Υե�����ϡ��Ѵ��Υᥤ��롼����
+***********************************************************************/
+/*	Version 3.0
+ */
+#include "rk_header.h"
+#include "rk_extvars.h"
+#include "rk_fundecl.h"
+
+struct	matchpair /*	���ߥޥå�����Ƥ����ѿ����ֹ�ȡ��ޥå�����ʸ����
+			�Ȥ��ݻ���*/
+{
+	int	hennum;
+	letter	ltrmch;
+};
+
+letter	memory[SIZALL]; /* �Ѵ��б�ɽ�䡢�ѿ����Ѱ�ʤɤ�������ΰ� */
+struct	dat	data[LINALL]; /* �б�ɽ�ΰ�Ԥ��ȤΥǡ����ؤΥݥ��� */
+letter	*hensudefhyo[VARTOT]; /* �ѿ����Ȥ��Ѱ�ǡ����ؤΥݥ��� */
+struct	matchpair	henmatch[VARTOT]; /* �ѿ��Υޥå������򤿤�Ƥ��� */
+
+#ifdef KDSP
+#  ifdef MVUX
+letter	displine[DSPLIN]; /* �ǥХå���	 ɽ���ΰ��ʬ�򵭲� */
+#  endif
+#endif
+
+letter	*curdis;
+int	codein_len;
+letter	*codeout, *remainkbf;
+letter	ungetc_buf = EOLTTR; /* romkan_ungetc����ʸ�����򤷤Ƥ����Хåե� */
+letter	unnext_buf = EOLTTR; /* romkan_unnext��		   ��		  */
+
+letter	(*keyin_method)(); /* ��������ؿ��Υ��ɥ쥹 */
+int	(*bytcnt_method)(); /* �Х��ȥ�����ȴؿ��Υ��ɥ쥹 */
+int	(*kbytcnt_method)(); /* �������ϲ���ѥХ��ȥ�����ȴؿ��Υ��ɥ쥹 */
+char	prv_modfnm[REALFN] = "\0"; /* �⡼��ɽ̾�����Ϥ��Υѥ�̾�ˤ���¸ */
+	    /* ������꤬�����ø�! */
+
+#define DISOUT ((flags & RK_NONISE) ? rk_output : disout)
+ /* �ե饰���ͤ�romkan_init3()��������ꤵ�졢����RK_NONISE�ΥӥåȤ��ͤ�
+    ɸ���0�����ä�DISOUT��ɸ���ͤ�disout�������rk_output���Ѥ���ȡ���������
+    �ʽ���LTREOF�ˤ���ڽФ��ʤ���â�����������Ϥ������ɬ���������֤��褦��
+    ���Ƥ�����˸¤ꡢEOLTTR����֤��ˡ�*/
+
+char	eofflg; /* romkan_next()����LTREOF���褿�Ȥ��ˡ�romkan_henkan()���1
+		   �ˤ��롣������ͤ���0�ʤ��Ѵ��б�ɽ��(error)��̵�뤷�ơ�
+		   �ܽ����Хåե����̤���ꥳ���ɤ⡢����Ū���Ѵ������롣����
+		   LTREOF���褿�������̤ˤ�����Ϥ�Ф��褦�˻��ꤵ��Ƥ����
+		   ���ν�����Ԥ���â�������ν����ϵޤ����館���Դ����ˡ�����
+		   �������eofflg��2��*/
+
+letter	evalbuf[2][2][OUTSIZ];
+char	ebf_sw = 0;
+letter	saishu_out[OUTSIZ];
+letter	delchr, delchr2 = EOLTTR, nisedl; /* DEL�Υ���饯������Ĥޤǻ��Ƥ�*/
+
+modetyp	chgmod(), incmod(), decmod();
+
+
+/* letter���֤��ؿ�������ڤ�����ʰ����ˤ�char�Τ�Τ⺮���äƤ���� */
+
+static letter	mchedsrc();
+letter	romkan_next(), romkan_unnext();
+letter	romkan_getc(), romkan_ungetc(), *romkan_henkan();
+letter	to_zenalpha(), to_zenhira(), to_zenkata();
+ /* to_zenhira;kata �����������ʸ�����ޤȤ�ˤ��ʤ���*/
+
+void BUGreport();
+static void maeato_henkan(), add_at_eof(), rk_delete(),
+  set_rubout(), mchevl(), codeout_chg(), ltrevlcpy();
+int match();
+static int p_eq(), hen_ikisrc(), henkan_ok(), rk_rst(),
+  head_bytecount();
+extern void readdata(), romkan_reset(), hank_setup(), to_hankata(),
+  to_digit(), dakuadd(), handakuadd(), allchgmod();
+extern int ltov();
+
+static
+letter	*ltrcpy(lp1, lp2)
+letter	*lp1, *lp2;
+{
+	letter	*org;
+
+	org = lp1;
+	while((*lp1++ = *lp2++) != EOLTTR);
+	return(org);
+}
+
+#ifdef notuse
+letter	*ltrncpy(lp1, lp2, n) /* ������'EOLTTR'�򥻥å� */
+letter	*lp1, *lp2;
+int	n;
+{
+	letter	*org;
+
+	org = lp1;
+	for(; n; --n) if(EOLTTR == (*lp1++ = *lp2++)) return(org);
+	*lp1 = EOLTTR;
+	return(org);
+}
+#endif
+
+ /** letter����������˰�ʸ���Ĥʤ��� */
+static
+letter	*ltr1cat(lp, l)
+letter	*lp, l;
+{
+	letter	*org;
+
+	org = lp;
+	totail(lp);
+	*lp++ = l;
+	*lp = EOLTTR;
+	return(org);
+}
+
+ /** ʸ����������˰�ʸ���Ĥʤ��롣ltr1cat��char�� */
+char	*chrcat(s, c)
+char	*s, c;
+{
+	char	*org;
+
+	org = s;
+	strtail(s);
+	*s++ = c;
+	*s = '\0';
+	return(org);
+}
+
+static
+letter	*ltrcat(lp1, lp2)
+letter	*lp1, *lp2;
+{
+	letter	*org;
+
+	org = lp1;
+	totail(lp1);
+	ltrcpy(lp1, lp2);
+	return(org);
+}
+
+ /** letter����lp2�γ����ǤκǾ�̥ӥåȤ�Ω�ƤƤ��顢lp1�θ���ˤĤʤ��롣*/
+static
+letter	*bitup_ltrcat(lp1, lp2)
+letter	*lp1, *lp2;
+{
+	letter	*org;
+
+	org = lp1;
+	totail(lp1);
+
+	while((*lp1 = *lp2++) != EOLTTR) *lp1++ |= HG1BIT;
+	 /** lp2 ���������ƤκǾ�̥ӥåȤ�Ω�Ƥ롣*lp2��NISEBP(rk_spclval.h
+	     ��define)�ʤɤΤȤ��Ϻǽ餫��Ǿ�̤�Ω�äƤ뤫��褤 */
+
+	return(org);
+}
+
+ /** ltrcat�������ȡ���̤�ʸ����������˥ݥ��󥿤��äƤ�����*/
+letter	*ltrgrow(lp1, lp2)
+letter	*lp1, *lp2;
+{
+	totail(lp1);
+	while((*lp1 = *lp2++) != EOLTTR) lp1++;
+	return(lp1);
+}
+
+static int
+ltrlen(lp)
+letter	*lp;
+{
+	letter	*org;
+
+	for(org = lp; *lp != EOLTTR; lp++);
+	return(lp - org);
+}
+
+ /**	letter����κǸ��ʸ���ؤΥݥ��󥿤��֤���â����ʸ������Ф��Ƥ�
+	���Τޤ��֤���*/
+letter	*ltrend(lp)
+letter	*lp;
+{
+	return((*lp != EOLTTR) ? (lp + ltrlen(lp) - 1) : lp);
+}
+
+ /**	ʸ����κǸ��ʸ���ؤΥݥ��󥿤��֤���ltrend()��char�ǡ�ltrend()��
+	Ʊ�͡���ʸ����ΤȤ������㤬���롣*/
+char	*strend(s)
+char	*s;
+{
+	return(*s ? (s + strlen(s) - 1) : s);
+}
+
+int
+ltrcmp(lp1, lp2)
+letter	*lp1, *lp2;
+{
+	for(; *lp1 == *lp2; lp1++, lp2++) if(*lp1 == EOLTTR) return(0);
+	return(*lp1 > *lp2 ? 1 : -1);
+}
+
+#ifdef notuse
+int
+ltrncmp(lp1, lp2, n)
+letter	*lp1, *lp2;
+int	n;
+{
+	for(; n && *lp1 == *lp2; n--, lp1++, lp2++)
+		if(*lp1 == EOLTTR) return(0);
+	return(n == 0 ? 0 : (*lp1 > *lp2 ? 1 : -1));
+}
+
+letter	*ltr_index(lp, l)
+letter	l, *lp;
+{
+	for(; *lp != EOLTTR; lp++) if(*lp == l) return(lp);
+	return(NULL);
+}
+#endif
+
+static
+letter	*ltr_rindex(lp, l)
+letter	l, *lp;
+{
+	letter	*lp2;
+
+	for(lp += ltrlen(lp2 = lp); lp2 != lp; ) if(*--lp == l) return(lp);
+	return(NULL);
+}
+
+ /** ʸ�����������ʸ���򥫥åȤ��롣*/
+letter	*ltr1cut(lp)
+letter	*lp;
+{
+	int	l;
+
+	if(0 == (l = ltrlen(lp))) BUGreport(0); /* Illegal POP */
+	*(lp + --l) = EOLTTR;
+	return(lp);
+}
+
+ /** letter�ΰ�ʸ����Ĺ������ʸ������Ѵ����� */
+static
+letter	*ltr_to_ltrseq(lp, l)
+letter	*lp, l;
+{
+	*lp++ = l;
+	*lp-- = EOLTTR;
+	return(lp);
+}
+
+ /** char���󤫤�letter���ļ��Ф���â��'\0'��EOLTTR���Ѥ��� */
+letter	letterpick(lbfpptr)
+uns_chr **lbfpptr;
+{
+	letter	l = 0;
+	register int	i;
+
+	for(i = (*bytcnt_method)(*lbfpptr); i; i--)
+		l = (l << 8) + *(*lbfpptr)++;
+	return(l == 0 ? EOLTTR : l);
+}
+
+ /**	���Ϥ��줿�����ɤ�ʸ��ñ�̤ˤޤȤ�롣â��EOF��LTREOF��rk_spclval.h
+	�ˤ�����ˤ��Ѥ��롣*/
+letter	romkan_next()
+{
+	letter	in;
+	int	i, n;
+	uns_chr c;
+
+	  /* unnext����Ƥ�����ϡ��������Ф���*/
+	if(unnext_buf != EOLTTR)
+		return(in = unnext_buf, unnext_buf = EOLTTR, in);
+
+	if( (letter)EOF == (in = (*keyin_method)() )) return(LTREOF);
+	c = (in &= 0xff);
+	n = (*kbytcnt_method)(&c);
+	for(i = 1; i < n; i++) in = (in << 8) + ((*keyin_method)() & 0xff);
+	return(in);
+}
+
+ /*	letter��ʸ�� l ��char��ʸ�� c ����ӡ�����ɥޡ���Ʊ�Ρ�letter���
+	����ɥޡ�����EOLTTR��char��Τ�'\0'�ˤ���פȤߤʤ���*/
+#define ltrchreq(l, c) ((l) == ((c) != 0 ? (c) : EOLTTR))
+
+ /** letter��ʸ�����char��ʸ�������� â���羮��Ӥ����ʤ��Ȥ��Ƥ�� */
+int
+ltrstrcmp(l, s)
+register letter *l;
+register char	*s;
+{
+	for(; ltrchreq(*l, *s); l++, s++) if(*s == 0) return(0);
+	return((*l < (uns_chr)*s || *l == EOLTTR)? -1 : 1);
+}
+
+ /** �Ǹ�˥ޥå�����ʸ�� �Ĥޤ�urabuf�κǸ塣urabuf��������EOLTTR���֤� */
+static
+letter	lastmch()
+{
+	return(*(ltrend(urabuf)));
+}
+
+/* end of 'letter' functions */
+
+
+#ifdef	OMAKE
+ /** ��	 ��  ��
+	�ԣ֥��˥�Τ�����ʰ����û���ޤ�ˡ����������������λ��Ϥɤ줫��ġ�
+	-1�ʤ����Ƥ���Ϥ�������ʳ��ʤ鲿����Ϥ��ʤ���������ξ��⡢�ǡ���
+	�θĿ����֤���*/
+takeoka(i)
+int	i;
+{
+#define OPIMAX (numberof(opinion))
+
+    static char *opinion[] = {
+	"����ˡ�Υ����ɥ� �ѥ��ƥ�桼�ߡפ��ɤ����Ȥ���by�ݲ�",
+	"�ֵ�ư��Υ�����দ���פ��ϵ��Ԥ��ɤ����Ȥ���by����",
+	"����ˡ�Υ����� �ޥ����륨�ߡפ��ɤ����Ȥ���by�ݲ�",
+	"�ʻ��Ͱո��ˡ֥ޥ����륨�ߡ�������͡פ��ɤ����˥����by����",
+	"����ˡ��ŷ�� ���ꥣ�ߡ��ޥߡפ��ɤ����Ȥ���by�ݲ�",
+	"�֥���������פ��ɤ����Ȥ���by����",
+	"�֥ࡼ�ߥ�פ��ɤ����Ȥ���by����",
+	"�֥ޥ������פΥ����ɥ��ʡ����꡼�����ɤ����Ȥ���by����",
+	"�֥��ס��󤪤Ф���פ��ɤ����Ȥ���by��",
+	"�֤Ϥ���ʹ֥��㡼�ȥ륺�פ��ɤ����Ȥ���by�ٱ�",
+	"�ֱ���ε��Υƥå��ޥ�פ��ɤ����Ȥ���by����",
+	"���Ų��ʹ֥٥�פ��ɤ����Ȥ���by��",
+	"�֥���ץ��ξ����ϥ����פ��ɤ����Ȥ���by�ٱ�",
+	"�֤Ȥ��᤭�ȥ��ʥ��ȡפ��ɤ����Ȥ���by����",
+	"�֤������Υ��硼�פ��ɤ����Ȥ��ä��͡�byΩ�ڡʤĤ�����",
+	"�֤��ޤ��쥪��󥸡������ɡפ��ɤ����Ȥ���by����������",
+	"�֥��å������ܡסʡ֥��å������ܣǡפ�ޤ�ˤ��ɤ����Ȥ���by����",
+	"�֥ƥä����סʡ֤�����ҥ����פΤ��ȡˤ��ɤ����Ȥ���by����",
+	"�֥��������ޥ����ԥ졼���פ��ɤ����Ȥ���by����",
+	"�־�����������פ��ɤ����Ȥ���by����",
+	"����̩���⥴��󥸥㡼�פ��ɤ����Ȥ���by����",
+	"���������Ρˡ�Ŵ��28��פ��ɤ����Ȥ���by����"
+    };
+
+	if(i >= 0) printf("%s\n", opinion[i % OPIMAX]);
+	 else if(i == -1) for(i= 0; i< OPIMAX; i++) printf("%s\n",opinion[i]);
+	return(OPIMAX);
+}
+#endif	/* OMAKE */
+
+
+ /** �Ѵ��Хåե��Υ��ꥢ */
+void	romkan_clear()
+{
+#ifdef KDSP
+#  ifdef MVUX
+	*displine = EOLTTR;
+#  endif
+#endif
+	ungetc_buf = *keybuf = *urabuf = *disout = *rk_output = EOLTTR;
+	curdis = DISOUT;
+	lastoutlen = lastkbflen = 0;
+}
+
+ /**	ɽ���ɤ߹�����Ѵ��ν������򤹤롣��part 1��*/
+int
+romkan_init(modhyo, delchr_, chmoutf, keyinfn, bytcntfn)
+char	*modhyo, chmoutf;
+letter	delchr_;
+letter	(*keyinfn)();
+int	(*bytcntfn)(); /* �����ξܺ٤�romkan_init3�򻲾� */
+{
+	return(romkan_init2(modhyo, delchr_, chmoutf, keyinfn, bytcntfn,
+			    0, 0, 0));
+}
+
+#define ifflg(a, b) ((a) ? (b) : 0)
+
+ /**	ɽ���ɤ߹�����Ѵ��ν������򤹤롣��part 2: �������Ϥ��Ф�ɬ������
+	�֤��褦�ˤ��뤫�������Хåե��򥯥ꥢ���뤫�ɤ����ʤɤ����ġ�*/
+int
+romkan_init2
+(modhyo, delchr_, chmoutf, keyinfn, bytcntfn, keyackf, restartf, nonisecodf)
+char	*modhyo, chmoutf, keyackf, restartf, nonisecodf;
+letter	delchr_;
+letter	(*keyinfn)();
+int	(*bytcntfn)(); /* �����ξܺ٤�romkan_init3�򻲾� */
+{
+	return(romkan_init3(modhyo, delchr_, toNISE(delchr_), EOLTTR,
+			    keyinfn, bytcntfn, (int (*)())NULL,
+			    restartf,
+			    ifflg(chmoutf, RK_CHMOUT) |
+			    ifflg(keyackf, RK_KEYACK) |
+			    ifflg(nonisecodf, RK_NONISE) |
+			    RK_DSPNIL));
+}
+
+ /**	ɽ���ɤ߹�����Ѵ��ν������򤹤롣��part 3��*/
+int
+romkan_init3
+(modhyo, delchr_, nisedl_, delchr2_, keyinfn, bytcntfn, kbytcntfn, restartf,
+ flags_)
+char	*modhyo;	/* �⡼�����ɽ��̾���Ϥ��Υѥ�̾ */
+letter	delchr_;	/* DEL�Ȥ��ƻȤ������� */
+letter	nisedl_;	/* ��DEL�Ȥ��ƻȤ������� */
+letter	delchr2_;	/* DEL�Ȥ��ƻȤ������ɤ���Ĥ����礽�Τ⤦���� */
+letter	(*keyinfn)();	/* ��������ؿ� */
+int	(*bytcntfn)();	/* �Х��ȥ�����ȴؿ� */
+int	(*kbytcntfn)(); /* ��������β���ѥХ��ȥ�����ȴؿ���NULL����λ���
+			   bytcntfn��Ʊ����Τ��Ȥ��� */
+char	restartf;
+ /*	rk_rst()�⤫��ƤФ줿����Ω�ĥե饰�����줬Ω�Ĥȡ��Хåե��򥯥ꥢ
+	�����˺Ѥޤ������λ��ϥ��顼���л��Υ�å������⾯���ۤʤ� */
+int	flags_;
+ /* �ʲ��Υե饰�����Ѳġ�������rk_spclval.h�ˤ������
+	RK_CHMOUT:�⡼�ɥ����󥸤��Τ餻�륳���ɤ��֤�����
+	RK_KEYACK:����������Ф�ɬ���������֤���
+	RK_DSPNIL:romkan_disp(off)mode�Υǥե���Ȥ��ʸ����ˤ��뤫
+	RK_NONISE:�������ɤ�Ф��ʤ��褦�ˤ��뤫
+	RK_REDRAW:Wnn���ü�ե饰��redraw�ѤΥե饰��Ф����ɤ�����
+	RK_SIMPLD:delete��ư���ñ��ˤ��뤫
+	RK_VERBOS:verbose�⡼�ɤǵ�������
+ */
+{
+	int	errcod; /* ���ν�1�Τ� */
+
+	 /* �������ɤ�Ф����������romkan_clear�ǻȤ��Τǡ��ե饰�������
+	    ��ˤ�äƤ����ʤ��Ȥ����ʤ���*/
+	if((flags = flags_) & RK_VERBOS){
+		fprintf(stderr, "romkan_init invoked.\r\n");
+		fflush(stderr);
+	}
+
+#ifdef	OMAKE
+	if(modhyo == NULL) takeoka(-1); /* ���ޤ����̾�ϼ¹Ԥ���ʤ� */
+#endif	/* OMAKE */
+
+	keyin_method = keyinfn;
+	bytcnt_method = (bytcntfn == NULL ? head_bytecount : bytcntfn);
+	kbytcnt_method = (kbytcntfn == NULL ? bytcnt_method : kbytcntfn);
+	strcpy(prv_modfnm, modhyo);
+
+	delchr = delchr_;
+	nisedl = nisedl_;
+	delchr2 = delchr2_;
+ /**	�¤�DEL�Υ���饯������Ĥޤǻ��Ƥ롣����ܡ�delchr2�ϡ�̤�����
+	�Ȥ����ͤ�EOLTTR�ˤ�̵�뤵��롣����ʳ��ϡ�delchr2�����Ϥ�����
+	delchr�����Ϥ��줿�Τ�Ʊ�������񤤤򤹤롣*/
+
+	if((errcod = setjmp(env0)) != 0){
+		fprintf(stderr,"romkan_init failed.");
+		if(!restartf){
+			romkan_reset();
+		 /*	fprintf(stderr,
+			      "No conversion is currently performed."); */
+			fprintf(stderr, "\r\n");
+		} else {
+			fprintf(stderr,
+				"Conversion method was unchanged.\r\n");
+		}
+	} else {
+		readdata(memory, data, hensudefhyo, modhyo);
+		if(!restartf){
+			romkan_clear();
+			hank_setup();
+		}
+	}
+
+	if(!errcod && (flags & RK_VERBOS)){
+		fprintf(stderr, "romkan_init finished.\r\n");
+		fflush(stderr);
+	}
+	return(errcod); /* ���ェλ�ʤ�0 */
+}
+
+ /**	�Х��ȥ�����ȴؿ��Υǥե���ȡ�s�λؤ��Ƥ��������äƤ���Τ�
+	���Х��ȥ����ɤ����֤���
+	romkan_next�����ա�������Ǥϡ��Х��ȥ�����ȴؿ����ͤ�
+	�����ΰ�ʸ���ܤˤΤ߰�¸����Ȳ��ꤷ�Ƥ��롣*/
+static int
+head_bytecount(s)
+uns_chr *s;
+{
+#ifdef IKIS
+	return((*s <= 0xa0 || *s == 0xff)? 1 : 2);
+#else
+	return(((*s <= 0xa0 && *s != HNKAK1) || *s == 0xff)? 1 : 2);
+#endif
+}
+
+ /** �Ѵ����줿ʸ����缡�֤� */
+letter	romkan_getc()
+{
+	letter	l;
+
+	  /* ungetc����Ƥ�����ϡ��������Ф���*/
+	if(ungetc_buf != EOLTTR)
+		return(l = ungetc_buf, ungetc_buf = EOLTTR, l);
+
+	while(*curdis == EOLTTR){
+		 /* romkan_next()���ͤ�LTREOF�λ��⡢���Τޤ�������ɤ���*/
+		curdis = romkan_henkan(romkan_next());
+
+		 /* keyackflg����0�ʤ顢�������󤬤����ɬ�������֤�������
+		    ���ᡢ�֤��٤���Τ��ʤ�����EOLTTR���֤����Ȥˤ��롣*/
+		if(flags & RK_KEYACK) break;
+	}
+
+	if(EOLTTR != (l = *curdis)) curdis++;
+	return(l);
+	 /* ��ʪ��ʸ���ʤ顢HG1BIT��Ω�äƤ��롣*/
+	 /* ���̤ʥ�����(�㤨�е���BEEP�Ȥ���NISEBP)���֤��Ȥ������롣������
+	    rk_spclval.h���������Ƥ��롣*/
+}
+
+ /**	romkan_getc�β��̴ؿ��Ȥ��ơ����Ϥ��ʸ��������ä�
+	�Ѵ���̤�ʸ�������Ϥ��롣*/
+letter	*romkan_henkan(mae_in)
+letter	mae_in;
+{
+	letter	mae_out[2], *p;
+
+	/* if(*curdis != EOLTTR){p = curdis; curdis = nil; return(p);} */
+	/* ������Ǥ�mae_in��̵�뤵��� */
+	curdis = nil;
+
+	  /* ����������ؤ����ϤϾ�ˤ�����ʸ�� */
+	mae_out[0] = mae_out[1] = EOLTTR;
+
+	eofflg = rk_errstat = 0;
+	*rk_output = *disout = EOLTTR;
+
+	maeato_henkan(mae_in, mae_out, usemaehyo);
+	rk_input = *mae_out;
+
+	if(rk_input == LTREOF){
+		 /* LTREOF���褿��硢(error)��̵�뤷���ܽ����Хåե���������
+		    �����Ѵ����롣���Τ����eofflg��1�ˤ��롣���θ塢��̤�
+		    �����ˡ�LTREOF���褿�������̥����ɡʻ��ꤵ��Ƥ���Сˤȡ�
+		    LTREOF��Ĥʤ���*/
+		eofflg = 1;
+		match();
+
+		eofflg = 2;
+		add_at_eof(); /* codeout�ˡ�LTREOF���褿���Ф������ɤ����롣*/
+		ltr1cat(codeout, LTREOF);
+
+		ltrcat(disout, codeout);
+		ltrcat(rk_output, codeout);
+	} else if(rk_input == EOLTTR){
+		 /* EOLTTR���褿���⡢���Ʊ�ͤν�����Ԥ�����LTREOF��
+		    �Ĥʤ��ʤ����ʤ��������romkan_getc()��Ƥ�Ǥ������
+		    ������ʤ���romkan_next()��EOLTTR���֤��ʤ�����ˡ�*/
+		eofflg = 1;
+		match();
+	} else if(rk_input == delchr || rk_input == delchr2){
+	    /* delchr2��̤����ʤ餽���ͤ�EOLTTR�ʤΤ�rk_input���������ʤ���*/
+		rk_delete(rk_input);
+	} else {
+		ltr1cat(keybuf, rk_input);
+		ltr1cat(disout, toNISE(rk_input));
+		match();
+	}
+
+	if(!(flags & RK_CHMOUT)){
+	   /* chmoutflg��0�λ��ϡ�CHMSIG��Ф��ʤ���*/
+		for(p = DISOUT; ; p++){
+			while(*p == CHMSIG) ltrcpy(p, p + 1);
+			if(*p == EOLTTR) break;
+		}
+	}
+
+	if((flags & RK_REDRAW) && NULL != (p = ltr_rindex(disout, nisedl))){
+		for(p++; *p != EOLTTR || (ltr1cat(disout, REDRAW), 0); p++)
+			if(!isSPCL(*p)) break;
+	}
+	 /* wnn��redraw�Υե饰��Ω�äƤ��ơ�disout��nisedl�ʸ��ü쥳���ɤΤ�
+	    �ǽ���äƤ����顢REDRAW��Ф��ơ�Wnn���Ѵ��Ԥ�redraw�򤵤��롣*/
+
+	return(DISOUT);
+}
+
+
+ /* �ǥХå��Ѵؿ� */
+#ifdef KDSP
+#  ifdef MVUX
+
+void
+pridbg2(a, b, c)
+char	*a, *c;
+letter	*b;
+{
+	printf("%s", a); dump_fordbg(b); printf("%s", c);
+}
+
+int
+ltr_displen(l)
+letter	l;
+{
+	while(l >= 256) l >>= 8;
+
+	if(l == 0) return(0);
+	if(l < ' ') return(0);
+	if(168 <= l && l <= 170) return(1);
+	return(l > 160 ? 2 : 1);
+}
+
+void
+dump_fordbg(lp)
+letter	*lp;
+{
+	while(*lp != EOLTTR) printf("%x/", *lp++);
+}
+
+void
+print_fordbg(lp)
+letter	*lp;
+{
+	while(*lp != EOLTTR) putletter(*lp++ & ~HG1BIT);
+}
+
+void
+print_ltrseq(lp)
+letter	*lp;
+{
+	while(*lp != EOLTTR) print_ltr(*lp++ & ~HG1BIT);
+}
+
+void
+print_ltr(l)
+letter	l;
+{
+	letter	*disptail;
+	int	i;
+
+	if(!isSPCL(l)) l &= ~HG1BIT;
+
+	if(l == CHMSIG)
+#ifdef CHMDSP
+		printf("...mode=%s\n",romkan_dispmode())
+#endif
+		;
+	else
+#define BEEPCH	'\007'
+#define NEWLIN	'\n'
+	if(l == BEEPCH || l == NISEBP) putchar(BEEPCH);
+	else
+	if(l == NEWLIN){
+		*displine = *keybuf = *urabuf = EOLTTR;
+		lastoutlen = lastkbflen = 0;
+		putchar(l);
+	}
+	else
+	if(l == delchr || l == nisedl){
+		if(*displine == EOLTTR) putchar(BEEPCH);
+		 else {
+			disptail = ltrend(displine);
+			for(i = ltr_displen(*disptail); i; i--)
+				printf("\031 \031");
+			*disptail = EOLTTR;
+		}
+	}
+	else {
+		ltr1cat(displine, l);
+		putletter(l);
+	}
+}
+
+#  endif /* of #ifdef MVUX */
+#endif
+/* �ǥХå��Ѵؿ������ */
+
+
+ /** DEL�����Ϥ��줿�Ȥ��ν����򤹤� */
+static void
+rk_delete(input_del)
+letter	input_del;
+{
+	if(ltrlen(keybuf) > ((flags & RK_SIMPLD) ? 0 : lastkbflen)){
+		ltr1cut(keybuf);
+		set_rubout(disout, 1, nisedl);
+	} else {
+		if(*urabuf != EOLTTR && !(flags & RK_SIMPLD)){
+			ltr1cut(ltrcpy(keybuf, urabuf));
+			*urabuf = EOLTTR;
+
+			set_rubout(rk_output, lastoutlen, input_del);
+
+			set_rubout(disout, lastkbflen, nisedl);
+			bitup_ltrcat(ltrcat(disout, rk_output), keybuf);
+
+			lastkbflen = lastoutlen = 0;
+		} else {
+			set_rubout(disout, 1, input_del);
+			set_rubout(rk_output, 1, input_del);
+		}
+	}
+}
+
+ /**	letter���� lp1 �� lp2 �Υޥå����ߤ롣���ͤϡ�lp1��lp2��Ƭ����
+	���פλ� -1��lp1�ޤ��Ϥ���Ƭ����lp2�����פΤȤ��ϰ���Ĺ��lp2��
+	��ʸ����λ���ޤࡣ���ξ�����ͤ�0�ˡ�����ʳ��� -2��
+	lp2¦�˼����ޤޤ�Ƥ�����ɾ���򤹤롣lp1¦�ˤϼ���ޤ�ǤϤ��� */
+static int
+prefixp(lp1, lp2)
+letter	*lp1, *lp2;
+{
+	/* 1�ԥޥå������뤴�Ȥˡ��ޤ�match����򥯥ꥢ���Ƥ��顣
+	   �Ĥޤꡢhenmatch[0] . ltrmch = EOLTTR; �Ȥ��Ƥ�����*/
+
+	register int	mch_len = 0, d_len;
+
+	for(;;){
+		if(*lp2 == EOLTTR) return(mch_len);
+		if(*lp1 == EOLTTR) return(-1);
+		if((d_len = p_eq(&lp2, &lp1)) < 0) return(d_len);
+		mch_len += d_len;
+	}
+}
+
+ /** num���ܤ��ѿ������ˤ���ʸ���ȥޥå����Ƥ���Ȳ��ꤷ�ơ�����ʸ�����֤� */
+static
+letter	mchedsrc(num)
+int	num;
+{
+	struct	matchpair	*pairptr;
+
+	for(pairptr = henmatch; pairptr -> ltrmch != EOLTTR; pairptr++){
+		if(num == pairptr -> hennum)
+			return(pairptr -> ltrmch);
+	}
+	return(BUGreport(8), 0);
+}
+
+ /**	num���ܤ��ѿ���ʸ�� l �ȥޥå����뤫Ĵ�٤롣�����ѿ���unbound���ä�
+	���� l ��bind���롣�ޥå�������(bind�λ���ޤ�)1�����ʤ���0���֤� */
+static int
+mchsrc(num, l)
+int	num;
+letter	l;
+{
+	struct	matchpair	*pairptr;
+
+	if(hen_ikisrc(num, l) == 0) return(0);
+	for(pairptr = henmatch; pairptr -> ltrmch != EOLTTR; pairptr++){
+		if(num == pairptr -> hennum)
+			return(pairptr -> ltrmch == l);
+	}
+
+	pairptr -> ltrmch = l;
+	pairptr -> hennum = num;
+	(++pairptr) -> ltrmch = EOLTTR;
+	return(1);
+}
+
+ /**	l1p�����ñ�̤��ä�ɾ������ʸ��l2�Ȱ��פ��뤫�ɤ������֤���ɾ������
+	��̤���ʸ���ˤʤ�ʤ��ä��顢�������פ��ʤ���*/
+static int
+l_eq(l1p, l2)
+letter	*l1p, l2;
+{
+	letter	evlrsl[RSLMAX];
+
+	switch(SHUBET(*l1p)){
+		case 0: return(*l1p == l2);
+		case 1: return(mchsrc((int)LWRMSK(*l1p), l2));
+		case 2:
+			mchevl(&l1p, evlrsl);
+			return(evlrsl[0] == l2 && evlrsl[1] == EOLTTR);
+		default:
+			return(BUGreport(1), 0);
+	}
+}
+
+ /**	prefixp��ǻ���	 â�������ν���ϵա����ʤ�������ޤޤ줦��Τ�l1pp¦
+	�Τߡ�l1pp�����ñ�̤֤��ä�ɾ��������Τ�l2pp�Υޥå����ߤ롣����
+	��l2pp�ޤ��Ϥ���Ƭ���ȥޥå�����а���Ĺ���֤���l1pp��ɾ����̤���ʸ��
+	��λ���ޤࡣ���ξ�����ͤ�0�ˡ��դ�l1pp��ɾ����̤�Ƭ����l2pp���ޥ�
+	���������� -1���֤����ޥå������Ԥ��������ͤ� -2��*/
+static int
+p_eq(l1pp, l2pp)
+register letter **l1pp, **l2pp;
+{
+	int	num;
+	letter	evlrsl[RSLMAX], *rslptr;
+	register int	retval = -2;
+
+	 /*  l2pp¦�ˤϼ���ޤޤʤ�Ȧ */
+	if(!is_HON(**l2pp)){
+	    /*	if(is_HON(**l1pp)) retval = p_eq(l2pp, l1pp); else  */
+		BUGreport(9);
+	} else {
+		switch(SHUBET(**l1pp)){
+			case 0: /* ʸ��Ʊ�� */
+				retval = (*(*l1pp)++ == *(*l2pp)++ ? 1 : -2);
+				break;
+			case 1: /* �ѿ���ʸ�� */
+				num = LWRMSK(*(*l1pp)++);
+				retval = (mchsrc(num, *(*l2pp)++) ? 1 : -2);
+				break;
+			case 2: /* ����ʸ�� */
+				mchevl(l1pp, rslptr = evlrsl);
+				for(retval = 0; *rslptr != EOLTTR; retval++){
+					if(**l2pp == EOLTTR){
+						retval = -1; break;
+					} else if(*rslptr++ != *(*l2pp)++){
+						retval = -2; break;
+					}
+				}
+				break;
+			default:
+				BUGreport(2);
+		}
+	}
+
+	return(retval);
+}
+
+ /** l1p�����ñ��ɾ������l2p������� */
+static void
+mchevl(l1pp, l2p)
+letter	**l1pp, *l2p;
+{
+	letter	*l1p, tmpevl[RSLMAX];
+
+	l1p = *l1pp;
+
+	switch(SHUBET(*l1p)){
+		case 0: *l2p++ = *l1p++; break;
+		case 1: *l2p++ = mchedsrc((int)LWRMSK(*l1p++)); break;
+		case 2:	 /* toupper, tolower, error, �� */
+			switch(LWRMSK(*l1p++)){
+				case 2: mchevl(&l1p, tmpevl);
+					*l2p++ = to_upper(*tmpevl);
+					break;
+				case 3: mchevl(&l1p, tmpevl);
+					*l2p++ = to_lower(*tmpevl);
+					break;
+				case 4:
+					*l2p++ = CHMSIG;
+					*l2p++ = LWRMSK(*l1p++);
+					*l2p++ = 0; break; /* EOL�ǤϤʤ� */
+				case 5:
+					*l2p++ = CHMSIG;
+					*l2p++ = LWRMSK(*l1p++);
+					*l2p++ = 1; break;
+				case 6:
+					*l2p++ = CHMSIG;
+					*l2p++ = XY2INT(2, LWRMSK(*l1p++));
+					*l2p++ = 1; break;
+				case 7:
+					mchevl(&l1p, tmpevl);
+					*l2p++ = to_updown(*tmpevl);
+					break;
+				case 8:
+					mchevl(&l1p, tmpevl);
+					*l2p++ = to_zenalpha(*tmpevl);
+					break;
+				case 9:
+					mchevl(&l1p, tmpevl);
+					*l2p++ = to_hira(*tmpevl);
+					break;
+				case 10:
+					mchevl(&l1p, tmpevl);
+					*l2p++ = to_kata(*tmpevl);
+					break;
+				case 11:
+					mchevl(&l1p, tmpevl);
+					to_hankata(*tmpevl, &l2p);
+					break; /* �ü� */
+				case 12:
+					mchevl(&l1p, tmpevl);
+					*l2p++ = to_zenhira(*tmpevl);
+					break;
+				case 13:
+					mchevl(&l1p, tmpevl);
+					*l2p++ = to_zenkata(*tmpevl);
+					break;
+				case 14:
+					mchevl(&l1p, tmpevl);
+					*l2p = *tmpevl;
+					mchevl(&l1p, tmpevl);
+					*l2p += *tmpevl;
+					LWRCUT(*l2p++);
+					break;
+				case 15:
+					mchevl(&l1p, tmpevl);
+					*l2p = *tmpevl;
+					mchevl(&l1p, tmpevl);
+					*l2p -= *tmpevl;
+					LWRCUT(*l2p++);
+					break;
+				case 16:
+					mchevl(&l1p, tmpevl);
+					*l2p = *tmpevl;
+					mchevl(&l1p, tmpevl);
+					*l2p *= *tmpevl;
+					LWRCUT(*l2p++);
+					break;
+				case 17:
+					mchevl(&l1p, tmpevl);
+					*l2p = *tmpevl;
+					mchevl(&l1p, tmpevl);
+					if(! *tmpevl) *l2p = LTRHUG;
+					 else *l2p /= *tmpevl;
+					LWRCUT(*l2p++);
+					break;
+				case 18:
+					mchevl(&l1p, tmpevl);
+					*l2p = *tmpevl;
+					mchevl(&l1p, tmpevl);
+					if(! *tmpevl) *l2p = LTRHUG;
+					 else *l2p %= *tmpevl;
+					LWRCUT(*l2p++);
+					break;
+				 /* 19��21��30�ϡ������������ȶ�ʸ����
+				    �����Ǥʤ���UNUSDC��ʸ����Ȥ����֤���*/
+				case 19:
+					mchevl(&l1p, tmpevl);
+					if(lastmch() != *tmpevl)
+						*l2p++ = UNUSDC;
+					break;
+				case 20:
+					if(! modesw[LWRMSK(*l1p++)] . curmode)
+						*l2p++ = UNUSDC;
+					break;
+				case 21:
+					if(modesw[LWRMSK(*l1p++)] . curmode)
+						*l2p++ = UNUSDC;
+					break;
+				case 22:
+					*l2p++ = REASIG;
+					break;
+				case 23:
+					*l2p++ = delchr;
+					break;
+				case 24:
+					*l2p++ = CHMSIG;
+					*l2p++ = XY2INT(1, 0);
+					 /* ����ǡ�all�פ�ɽ�� */
+					*l2p++ = 0; break;
+				case 25:
+					*l2p++ = CHMSIG;
+					*l2p++ = XY2INT(1, 0);
+					*l2p++ = 1; break;
+				case 26:
+					mchevl(&l1p, tmpevl);
+					*l2p = *tmpevl;
+					mchevl(&l1p, tmpevl);
+					*l2p &= *tmpevl;
+					LWRCUT(*l2p++);
+					break;
+				case 27:
+					mchevl(&l1p, tmpevl);
+					*l2p = *tmpevl;
+					mchevl(&l1p, tmpevl);
+					*l2p |= *tmpevl;
+					LWRCUT(*l2p++);
+					break;
+				case 28:
+					mchevl(&l1p, tmpevl);
+					*l2p = ~(*tmpevl);
+					LWRCUT(*l2p++);
+					break;
+				case 29:
+					*l2p++ = URBFCL;
+					break;
+				case 30:
+					if(eofflg != 2 || *keybuf != EOLTTR)
+						*l2p++ = UNUSDC;
+					break;
+				case 31:
+					{
+						letter	code, basenum;
+
+						mchevl(&l1p, tmpevl);
+						code = *tmpevl;
+						mchevl(&l1p, tmpevl);
+						if((basenum = *tmpevl) <= 1 ||
+						   BASEMX < basenum)
+							basenum = 10;
+						to_digit(code, basenum, &l2p);
+					}
+					break;
+				case 32:
+					mchevl(&l1p, tmpevl);
+					dakuadd(*tmpevl, &l2p);
+					break; /* �ü� */
+				case 33:
+					mchevl(&l1p, tmpevl);
+					handakuadd(*tmpevl, &l2p);
+					break; /* �ü� */
+				case 34:
+					mchevl(&l1p, tmpevl);
+					*l2p++ = ltov(*tmpevl);
+					break;
+				case 35:
+					*l2p++ = ERRCOD;
+					break;
+			     /*	case 36: omitted */
+				case 37:
+					*l2p++ = CHMSIG;
+					*l2p++ = LWRMSK(*l1p++);
+					*l2p++ = *l1p++; break;
+				case 38:
+					*l2p++ = CHMSIG;
+					*l2p++ = XY2INT(2, LWRMSK(*l1p++));
+					*l2p++ = *l1p++; break;
+				case 39:
+					*l2p++ = CHMSIG;
+					*l2p++ = XY2INT(3, LWRMSK(*l1p++));
+					*l2p++ = *l1p++; break;
+				case 40:
+					{
+						letter	modnum;
+
+						modnum = LWRMSK(*l1p++);
+						if(modesw[modnum] . curmode !=
+						   *l1p++)
+							*l2p++ = UNUSDC;
+						break;
+					}
+				case 41:
+					{
+						letter	modnum;
+
+						modnum = LWRMSK(*l1p++);
+						if(modesw[modnum] . curmode ==
+						   *l1p++)
+							*l2p++ = UNUSDC;
+						break;
+					}
+				case 42:
+					{
+						letter	modnum;
+
+						modnum = LWRMSK(*l1p++);
+						if(modesw[modnum] . curmode >=
+						   *l1p++)
+							*l2p++ = UNUSDC;
+						break;
+					}
+				case 43:
+					{
+						letter	modnum;
+
+						modnum = LWRMSK(*l1p++);
+						if(modesw[modnum] . curmode <=
+						   *l1p++)
+							*l2p++ = UNUSDC;
+						break;
+					}
+				case 44:
+					mchevl(&l1p, tmpevl);
+					*l2p++ = SENDCH;
+					*l2p++ = *tmpevl;
+					break;
+				default:/* case 0�ڤӾ嵭�ʳ� */;
+					BUGreport(7);
+			}
+	}
+
+	*l2p = EOLTTR;
+	*l1pp = l1p;
+}
+
+ /** num���ܤ��ѿ����Ѱ褬ʸ�� l ��ޤफ�ɤ������֤� */
+static int
+hen_ikisrc(num, l)
+int	num;
+letter	l;
+{
+	letter	*defptr;
+
+	defptr = hyo_n[hyonum] . hensudef[num];
+	if(*defptr == VARRNG){
+		for(defptr++; *defptr != EOLTTR; )
+			if(*defptr++ <= l && l <= *defptr++) return(1);
+		return(0);
+	}
+
+	for(; *defptr != EOLTTR; defptr++){
+		if(l == *defptr) return(1);
+	}
+	return(0);
+}
+
+ /**	�Ѵ��Υᥤ��롼�����ܽ�����Ԥ������Ĥ��Ǥ˸�������äƤ��롣
+	���ʤߤ��������ϡ�romkan_getc�β��̴ؿ�romkan_henkan����ǡ�
+	���δؿ���Ƥ����ˤ�äƤ��롣
+	���δؿ��ϡ�romkan_next�����ʸ������٤˸ƤФ�롣�ƤӽФ��줿ľ���
+	output�϶�ʸ����disout�ˤ����ϥ����ɰ�ʸ�������äƤ��롣
+	���δؿ���������ʸ�����󤬡�romkan_henkan���Ϥꡢ
+	romkan_getc�ϡ������ʸ�����Ȥ�ʬ�򤷤��֤���
+	(error)�ǥ��顼�������������줿����0���֤������ェλ����1���֤� */
+int
+match()
+{
+	int	henkanflg = 0, okcode = 0, chm_exist;
+	letter	*p;
+	letter	urabufcreate[KBFSIZ], orgkeybuf[KBFSIZ], kbftail[KBFSIZ];
+	letter	*urabufjunbi, *outcutptr, *dis_end;
+
+	if(*keybuf == EOLTTR){
+		*urabuf = EOLTTR;
+		return(1);
+	}
+
+	ltrcpy(urabufjunbi = orgkeybuf, keybuf);
+	outcutptr = rk_output;
+
+	while((okcode = henkan_ok()) > 0){
+		henkanflg = 1;
+
+		codeout_chg();
+		ltrcat(rk_output, codeout);
+
+		ltrcpy(kbftail, keybuf + codein_len);
+		ltrcat(ltrcpy(keybuf, remainkbf), kbftail);
+
+		if(okcode == 2){
+			ltrcpy(urabufjunbi = urabufcreate, keybuf);
+			totail(outcutptr);
+		}
+	}
+
+	if(okcode == 0){
+		ltr1cut(ltrcpy(keybuf, orgkeybuf));
+		ltr_to_ltrseq(disout, NISEBP);
+		*rk_output = EOLTTR;
+		return(0);
+	}
+	if(henkanflg){
+		ltrcpy(urabuf, urabufjunbi);
+
+		set_rubout(disout, ltrlen(orgkeybuf) - 1, nisedl);
+
+		dis_end = disout;
+		totail(dis_end);
+		ltrcpy(dis_end, rk_output);
+
+		 /* �⡼�ɥ����󥸤�ľ�����Τ餻�뤿�� CHMSIG�����
+		    ��flags���RK_CHMOUT��Ω�äƤʤ��ȡ����Ȥǰ�ʸ�����Ĥ�
+		    ʬ�򤹤�����ǡ�CHMSIG�򥫥åȡˡ�
+		    â����rk_output����ϡ�CHMSIG��ȴ����
+		    �ޤ���CHMSIG�������ˣ��󤷤����Ϥ��ʤ�
+		    �ʣ���ʾ夢�äƤ⡢����ˤޤȤ�ơ��������֤��ˡ�*/
+		for(chm_exist = 0, p = rk_output; ; p++){
+			while(*p == CHMSIG){
+				chm_exist = 1;
+				if(ltrcpy(p, p + 1) < outcutptr) outcutptr--;
+			}
+			if(*p == EOLTTR) break;
+		}
+		if(chm_exist){
+		 /* CHMSIG�򣱤ĤˤޤȤ᤿��Τ�dis_end�ˤĤʤ�ľ����
+		    ����ifʸ�򥫥åȤ���С�CHMSIG�ΤȤ�ޤȤ�Ϥ��ʤ� */
+			ltr1cat(ltrcpy(dis_end, rk_output), CHMSIG);
+		}
+
+		bitup_ltrcat(disout, keybuf);
+		lastoutlen = ltrlen(outcutptr);
+		lastkbflen = ltrlen(keybuf);
+	}
+	return(1);
+}
+
+ /**	LTREOF�����ä��Ȥ��ˡ������Ф��褦�˻��ꤵ��Ƥ��뤫Ĵ�٤ơ�
+	codeout�򤽤η�̤�ʸ����ʻ��꤬�ʤ��ä����������ˤ˥ݥ���Ȥ��롣
+	Ķ�ޤ����館�ǡ��ü쥳�������ϰ���̵�뤹�롣*/
+static void
+add_at_eof()
+{
+	register struct dat	*datptr;
+	register int	i;
+	int	hyoseq;
+	letter	evlrsl[RSLMAX], *p;
+
+	for(hyoseq = 0; (hyonum = usehyo[hyoseq]) != -1; hyoseq++){
+		for(i = 0, datptr = hyo_n[hyonum] . data;
+		    NULL != (p = datptr[i] . code[0]); i++){
+			henmatch[0] . ltrmch = EOLTTR;
+			while(*p != EOLTTR){
+				switch(SHUBET(*p)){
+					case 0: /* ʸ�� */
+					case 1: /* �ѿ� */
+					 /* ����餬������ϡ�NULL�Ȥ�
+					    �ޥå������ʤ���*/
+						goto Pass;
+					case 2: /* �� */
+						mchevl(&p, evlrsl);
+						if(*evlrsl != EOLTTR)
+							goto Pass;
+					 /* ���ϥ��������ˡ�ɾ�������
+					    ��ʸ����ˤʤ��Τ���¾�ˤϤʤ�
+					    ���Ȥ�����*/
+				}
+			}
+
+			ltrevlcpy(codeout = p = evalbuf[0][0],
+				  datptr[i] . code[1]);
+			while(*p != EOLTTR){
+				if(isSPCL(*p)) ltrcpy(p, p + 1);
+				 else p++;
+			}
+			codeout_chg();
+			return;
+
+Pass:			;
+		}
+	}
+	codeout = nil;
+}
+
+ /**	���ޥå����ߤ롣���ͤϡ��ޥå����Ƴ��ꤷ�����1�ʥ⡼�ɥ����󥸤�
+	�����äƤ������2�ˡ��ޥå�������̤����λ�-1���ޥå����ʤ��ä���0��
+	�¹���ϡ��ѿ� l �ˡ�����ޤǤ˰��פ���Ĺ���κǹ⵭Ͽ������Ƥ��ꡢ
+	���Ĺ�����פ����Τ����Ĥ��뤴�Ȥˡ�����򹹿����롣l���ͤϡ��ޥå�
+	���Ƥ��Ƥ�0�ˤʤ뤳�Ȥ⤢�롣p_eq() �ڤ� prefixp() ������ʸ�򻲾ȡ�*/
+static int
+henkan_ok()
+{
+	register struct dat	*datptr;
+	register int	i, k;
+	int	l, j, hyoseq;
+	char	urabuf_clrf; /* �⡼�ɥ����󥸤ʤɤǡ�urabuf�򥯥ꥢ����ɬ�פ�
+				���������Ϥ��줬Ω�������η�̡�henkan_ok()
+				��1���֤��٤��Ȥ�����2���֤�������򸫤ơ�
+				match()��urabuf�ʤɤ�Ĵ���򤹤롣*/
+	register letter *p;
+
+	if(*keybuf == EOLTTR) return(-1);
+
+	for(l = -1, hyoseq = 0; (hyonum = usehyo[hyoseq]) != -1; hyoseq++){
+		for(i = 0, datptr = hyo_n[hyonum] . data;
+		    NULL != (p = datptr[i] . code[0]); i++){
+			henmatch[0] . ltrmch = EOLTTR;
+			switch(k = prefixp(keybuf, p)){
+				case -2: break;
+				case -1:
+					if(eofflg != 0) break;
+				 /* eofflg��Ω�äƤ����顢̤����β�ǽ����
+				    �ΤƤ롣*/
+
+					return(-1);
+				default:
+					if(k > l){
+						ebf_sw = !ebf_sw;
+						for(j = 1; j <= 2; j++){
+							ltrevlcpy(
+							 evalbuf[ebf_sw][j-1],
+							 datptr[i] . code[j]);
+						}
+
+						l = k;
+					}
+			}
+		}
+	}
+
+	if(l >= 0){
+		codein_len = l;
+		codeout = evalbuf[ebf_sw][0];
+		remainkbf = evalbuf[ebf_sw][1];
+
+		for(urabuf_clrf = 0, p = codeout; *p != EOLTTR;){
+			switch(*p){
+				case CHMSIG:
+					p++;
+			 /* codeout��1�Х����ܤ˴ؿ��Υ����å��ȥ⡼���ֹ桢
+			    2�Х����ܤ˥⡼�ɤο����֤����äƤ� */
+					switch(SHUBET(*p)){
+						case 0:
+							chgmod((int)*p,
+							   (modetyp)*(p + 1));
+							break;
+						case 1:
+							allchgmod((modetyp)
+								    *(p + 1));
+							break;
+						case 2:
+							incmod((int)LWRMSK(*p)
+							  ,(modetyp)*(p + 1));
+							break;
+						case 3:
+							decmod((int)LWRMSK(*p)
+							  ,(modetyp)*(p + 1));
+							break;
+					}
+					ltrcpy(p, p + 2);
+					 /* CHMSIG�����Ĥ���1,2�Х�����cut */
+
+					urabuf_clrf = 1;
+					break;
+				case URBFCL:
+				 /* urabuf�Υ��ꥢ������Ū�˻��ꤹ�� */
+					urabuf_clrf = 1;
+					ltrcpy(p, p + 1);
+					break;
+				default:
+					p++;
+			}
+		}
+
+		if(*codeout == ERRCOD){
+			if(eofflg == 0){
+				rk_errstat = 1;
+				return(0);
+			}
+
+			 /* (error)�Ǥ��äơ�������eofflg��Ω�äƤ��顢keybuf
+			    �������ޤǡ����Τޤ޽Ф���*/
+			codein_len = ltrlen(keybuf);
+			codeout = ltrcpy(evalbuf[ebf_sw][0], keybuf);
+			remainkbf = nil;
+			rk_errstat = 2;
+
+			return(1);
+		}
+	   /* (error)��ñ�ȤǤ����񤱤ʤ��Τǡ����顼���ФϤ���ǽ�ʬ��*/
+
+		if(*codeout == REASIG){
+			*codeout = (rk_rst() != 0 ? EOLTTR : CHMSIG);
+			 /* ��read�ǥ���ä���⡼�ɥ����󥸤����ΤϤ��ʤ� */
+
+			urabuf_clrf = 1;
+		}
+	   /* ɽ�κ�read��â�������줬�����ä����Ȥ򳰤��Τ餻��Τ�CHMSIG��
+	      ���Υ����ɤ��Τ�Τϳ��ؽФʤ���(restart)�ϡ�(error)Ʊ�͡�
+	      ñ�ȤǤ����񤱤ʤ��Τǡ����ФϤ���ǽ�ʬ��*/
+
+		return(urabuf_clrf ? 2 : 1);
+	}
+
+	 /* ɽ�˸���Ƥ��ʤ������ɤϤ��Τޤ��֤� */
+
+	codein_len = 1;
+	*(codeout = oneletter) = *keybuf;
+	remainkbf = nil;
+	return(1);
+}
+
+ /* rk_rst��ǻȤ��ޥ��� */
+#define taihi(X, Y, N) {for(i = 0; i < N; i++) X[i] = Y[i];}
+#define recov(X, Y, N) taihi(Y, X, N)
+
+ /**	ɽ��ưŪ���ɤ߹��ߤ򤹤롣���ߤ�����ɽ�����������򤷡�����Ʊ��
+	�ǥ��쥯�ȥ�ʤˡ����ߤΤȤ�������ˤ���ɽ���ɤ߹��ࡣ�⤷��
+	�ɤ߹�����˥��顼�򸡽Ф���С���Ȥ������ǡ��������褷��0���֤���*/
+static int
+rk_rst()
+{
+	register int	i;
+	int	j;
+
+	letter	memoryt[SIZALL];
+	struct	dat	datat[LINALL];
+	struct	hyo	hyo_nt[HYOMAX];
+	letter	*hensudefhyot[VARTOT];
+	struct	modestat	modeswt[MODMAX];
+	char	hyoshut[HYOMAX];
+	char	*modmeibgnt[MODMAX], modmeimem_t[MODMEI];
+	char	*dspnambgnt[DMDMAX], dspcod_t[DMDCHR];
+	int	usemaehyot[HYOMAX], usehyot[HYOMAX], useatohyot[HYOMAX];
+	int	naibu_t[NAIBMX];
+	char	*dspmodt[2][2];
+
+	taihi(memoryt,		memory,		SIZALL);
+	taihi(datat,		data,		LINALL);
+	taihi(hyo_nt,		hyo_n,		HYOMAX);
+	taihi(hensudefhyot,	hensudefhyo,	VARTOT);
+	taihi(modeswt,		modesw,		MODMAX);
+	taihi(hyoshut,		hyoshu,		HYOMAX);
+	taihi(modmeibgnt,	modmeibgn,	MODMAX);
+	taihi(modmeimem_t,	modmeimem_,	MODMEI);
+	taihi(dspnambgnt,	dspnambgn,	DMDMAX);
+	taihi(dspcod_t,		dspcod_,	DMDCHR);
+	taihi(usemaehyot,	usemaehyo,	HYOMAX);
+	taihi(usehyot,		usehyo,		HYOMAX);
+	taihi(useatohyot,	useatohyo,	HYOMAX);
+	taihi(naibu_t,		naibu_,		NAIBMX);
+	for(i = 0; i < 2; i++)
+		for(j = 0; j < 2; j++)	dspmodt[i][j] = dspmod[i][j];
+
+	if(0 == romkan_init3(prv_modfnm, delchr, nisedl, delchr2,
+			     keyin_method, bytcnt_method, kbytcnt_method, 1,
+			     flags & ~RK_VERBOS))
+		return(0); /* ���ェλ */
+
+	recov(memoryt,		memory,		SIZALL);
+	recov(datat,		data,		LINALL);
+	recov(hyo_nt,		hyo_n,		HYOMAX);
+	recov(hensudefhyot,	hensudefhyo,	VARTOT);
+	recov(modeswt,		modesw,		MODMAX);
+	recov(hyoshut,		hyoshu,		HYOMAX);
+	recov(modmeibgnt,	modmeibgn,	MODMAX);
+	recov(modmeimem_t,	modmeimem_,	MODMEI);
+	recov(dspnambgnt,	dspnambgn,	DMDMAX);
+	recov(dspcod_t,		dspcod_,	DMDCHR);
+	recov(usemaehyot,	usemaehyo,	HYOMAX);
+	recov(usehyot,		usehyo,		HYOMAX);
+	recov(useatohyot,	useatohyo,	HYOMAX);
+	recov(naibu_t,		naibu_,		NAIBMX);
+	for(i = 0; i < 2; i++)
+		for(j = 0; j < 2; j++)	dspmod[i][j] = dspmodt[i][j];
+	return(1);
+}
+
+ /** lp2����ɾ����������ʸ�����lp1�˥��ԡ� */
+static void
+ltrevlcpy(lp1, lp2)
+letter	*lp1, *lp2;
+{
+	while(*lp2 != EOLTTR){
+		mchevl(&lp2, lp1);
+		totail(lp1);
+	}
+	*lp1 = EOLTTR;
+}
+
+static void
+set_rubout(lp, n, del)
+ /** lp�� ��del��n�Ĥ���򥻥åȤ��롣������ del �� 'delchr'��'nisedl' */
+letter	*lp, del;
+int	n;
+{
+	for(; n; n--) *lp++ = del;
+	*lp = EOLTTR;
+}
+
+ /** ���줬�¹Ԥ��줿��Х���â���¹ԤϤ��Τޤ�³�� */
+void
+BUGreport(n)
+int	n;
+{
+	fprintf(stderr, "\r\nromkan-Bug%d!!\r\n", n);
+}
+
+ /** ������(mae_in��mae_out)���ϸ����(ato_in��ato_out)��Ԥ���*/
+static void
+maeato_henkan(in, outp, m_a_hyo)
+letter	in;		/* ���Ϥΰ�ʸ�� */
+letter	*outp;		/* ���ϤϤ��������� */
+int	*m_a_hyo;	/* �ɤ����������ɽ�����򤵤�Ƥ��뤫�ξ��� */
+{
+	struct	dat	*datptr;
+	int	i, hyoseq;
+	letter	*curdat;
+
+	if(isSPCL(in)){
+	 /* LTREOF��CHMSIG���褦��Τǡ��ü쥳���ɤϤ��Τޤ��֤��褦��
+	    �ٹ����Ƥ����ʤ��Ȥ����ʤ���*/
+		ltr_to_ltrseq(outp, in);
+		return;
+	}
+
+	for(hyoseq = 0; (hyonum = m_a_hyo[hyoseq]) != -1; hyoseq++){
+		for(i = 0, datptr = hyo_n[hyonum] . data;
+		    NULL != (curdat = datptr[i] . code[0]); i++){
+			henmatch[0] . ltrmch = EOLTTR;
+			if(!l_eq(curdat, in)) continue;
+
+			ltrevlcpy(outp, datptr[i] . code[1]);
+			return;
+		}
+	}
+	ltr_to_ltrseq(outp, in);
+}
+
+ /** ����� */
+static void
+codeout_chg()
+{
+	letter	*saishu_outp;
+
+	*(saishu_outp = saishu_out) = EOLTTR;
+
+	for(; *codeout != EOLTTR; codeout++){
+		maeato_henkan(*codeout, saishu_outp, useatohyo);
+		totail(saishu_outp);
+	}
+
+	codeout = saishu_out;
+}
+
+ /** ��ʸ���ץå��塦�Хå� */
+letter	romkan_ungetc(l)
+letter	l;
+{
+	return(ungetc_buf = l);
+}
+
+ /** romkan_next���Ф���ʸ���ץå��塦�Хå� */
+letter	romkan_unnext(l)
+letter	l;
+{
+	return(unnext_buf = l);
+}
+
+ /**	delete�Ȥ��ƻȤ�����饯��������ʵ�delete��ˡ������¹Ը��
+	romkan_clear��¹Ԥ��Ƥ����ʤ��Ⱥ���Τ�Ȥˤʤ�ޤ���*/
+/*	���ѻߡ�
+void
+romkan_setdel(delchr_, nisedl_)
+letter	delchr_, nisedl_;
+{
+	delchr = delchr_;
+	nisedl = nisedl_;
+}
+*/
diff --git a/wnn/rk_modread.c b/wnn/rk_modread.c
new file mode 100644
index 0000000000000000000000000000000000000000..9d946d7f55d60f01c72c1a544320ae2c5dfd8f33
--- /dev/null
+++ b/wnn/rk_modread.c
@@ -0,0 +1,1187 @@
+/*
+ * $Id: rk_modread.c,v 1.1 1996/03/13 09:57:14 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/**********************************************************************
+			rk_modread.c
+						88. 6.16  �� ��
+
+	�⡼�����ɽ���ɤ߹��ߤ�ô������ץ�����ࡣ
+***********************************************************************/
+/*	Version 3.0
+ */
+#include "rk_header.h"
+#include "rk_extvars.h"
+#ifdef WNNDEFAULT
+#  include "config.h"
+ /* �ޥ���LIBDIR������ʤΤ�������ˡ�����ѥ�����ϡ��إå��ե������
+    �������ѥ��ˡ�Wnn�Υ��󥯥롼�ɥե�����Τ��꤫�����ꤷ�Ƥ������ȡ�*/
+#endif
+#include <pwd.h>
+
+#define Terminator 0 /* int�����naibu[]�ˤν��ߥ����� */
+
+char	*getenv();
+#if defined(uniosu)
+extern	struct	passwd	*getpwnam();
+#endif
+extern	char	*chrcat(), *strend(), *ename();
+extern	void	romkan_clear();
+char	*modhyopath;
+
+static void cond_evl(), mystrcpy(),
+  rd_bcksla(), rd_ctrl(), hyouse(), look_choose();
+void choosehyo();
+static int mystrcmp(), read1tm(), mod_evl(), fnmsrc_tourk(), dspnamsrc_tourk(),
+  scan1tm(), modsrc_tourk(), chk_get_int(), pathsrc_tourk(),
+  modnamchk(), ctov(), look_cond(), evlcond(), chkchar_getc(); 
+static char codeeval();
+extern void ERRMOD(), ERMOPN(), BUGreport();
+extern int filnamchk();
+
+struct	kwdpair {
+	 /* ������ɤȤ�������ɽ�����б���Ϳ���빽¤�Ρ�����ɽ����
+	    �����ʤ���Τ��Ф��Ƥ�0��Ϳ�����Ƥ��롣*/
+	char	*name;
+	int	code;
+} modfn[] = {
+	"defmode",	0,
+	"if",		XY2INT(2, 0),
+	"when",		XY2INT(2, 1),
+	"path",		0,
+	"search",	0,
+	"on_dispmode",	XY2INT(5, 0),
+	"off_dispmode", XY2INT(5, 1),
+	"on_unchg",	XY2INT(6, 0),
+	"off_unchg",	XY2INT(6, 1),
+	NULL
+}; /* ���򸫤� ����������ɽ�Ϥޤ�������Ĥ���Τ� */
+
+struct	kwdpair modcond[] = {
+	"not",	XY2INT(3, 0),
+	"and",	XY2INT(3, 1),
+	"or",	XY2INT(3, 2),
+	"true", XY2INT(3, 3),
+	"false",XY2INT(3, 4),
+	"=",	XY2INT(3, 5),
+	"!=",	XY2INT(3, 6),
+	"<",	XY2INT(3, 7),
+	">",	XY2INT(3, 8),
+	NULL
+};
+int	condarg[] = {1, 2, 2, 0, 0, 2, 2, 2, 2}; /* ���Ƚ�Ǵؿ��ΰ����Ŀ� */
+
+struct	kwdpair swstat[] = {
+	"on",	0,
+	"off",	0,
+	NULL
+};
+ /* 1��2^24��ϥ⡼��̾��4��2^24��ϥ⡼��ɽ��ʸ����7��2^24��ϥ⡼�ɾ�����
+    ��������ɽ���˻ȤäƤ��� */
+
+ /** ������ɡ�if, and�ʤɡˤ������ʤ�Τ������å����������ֹ���֤� */
+static int
+kwdsrc(hyo, wd)
+struct	kwdpair *hyo;	/* �ɤΥ������ɽ��Ȥ��� */
+char	*wd;		/* �����å�����륭����� */
+{
+	int	i;
+
+	for(i = 0; hyo[i] . name != NULL; i++)
+		if(!mystrcmp(hyo[i] . name, wd)) return(i);
+	ERRMOD(9);
+	 /*NOTREACHED*/
+}
+
+ /** �⡼��ɽ���ɤ߹��� */
+void
+readmode(modfname)
+char	*modfname; /* �⡼��ɽ��̾ */
+{
+	char	buf[MDHMAX], *bufp;
+#ifdef RKMODPATH
+	char	*genv, *pathenv, *pathp;
+#endif
+
+	mcurread = buf; /* ���顼������ */
+
+#ifdef RKMODPATH
+	if(!fixednamep(modfname) &&
+	   NULL != (pathenv = genv = getenv(RKMODPATH)) && *genv != '\0'){
+	 /* PATH�˾��ʤ��Ȥ��ĤΥ������ѥ��������� */
+		for(;;){
+			 /* �������ѥ��γơ���������ΰ�ˤϡ�pathmeimem�����
+			    ���Ƥ��롣��ǡ��������ѥ�����Ƭ�ˡ��⡼��ɽ�Τ���
+			    �ǥ��쥯�ȥ�����ꤹ��Τǡ������ص��Τ���⤢��*/
+			for(pathp = pathmeimem; *genv != ':' && *genv; genv++)
+				*pathp++ = *genv;
+			*pathp = '\0';
+
+			if(*(strend(pathmeimem)) != KUGIRI) *pathp++ = KUGIRI;
+			 /* path�ζ��ڤ��DG��MV�ˤǤ��äƤ�'/' */
+
+			strcpy(pathp, modfname);
+			if(NULL != (modefile = fopen(pathmeimem, "r"))){
+				 /* Now Mode-hyo found */
+				if(flags & RK_VERBOS)
+					fprintf(stderr,
+					"romkan: using Mode-hyo %s ...\r\n",
+						pathmeimem);
+				curdir = pathmeimem; /* ���λ����Ǥϥե�����̾
+					���ߤ��������Ȥǥѥ�̾�����ˤʤ� */
+				curfnm = ename(modfname);
+				break;
+			}
+
+			if(*genv != ':'){ /* Mode-hyo not found */
+				if(flags & RK_VERBOS){
+					fprintf(stderr, "no %s in ",modfname);
+					for(genv = pathenv; *genv; genv++){
+						fputc((*genv == ':' ?
+						      ' ' : *genv), stderr);
+					}
+					fprintf(stderr, ".\n");
+				}
+				ERMOPN(0);
+			} else genv++; /* coutinues searching Mode-hyo */
+		}
+	} else
+#endif
+	{
+		if(NULL == (modefile = fopen(modfname, "r"))) ERMOPN(0);
+		if(flags & RK_VERBOS)
+			fprintf(stderr, "romkan: using Mode-hyo %s ...\r\n",
+				modfname);
+		strcpy(pathmeimem, modfname);
+	}
+
+	 /* �������ѥ�����Ƭ�ˡ��⡼��ɽ�Τ���ǥ��쥯�ȥ�����ꤷ�Ƥ��롣*/
+	*(ename(pathmeimem)) = '\0';
+	modhyopath = *pathmeiptr++ = pathmeimem;
+	*pathmeiptr = NULL;
+	strtail(pathmeimem);
+	*(pathareaorg = ++pathmeimem) = '\0';
+	 /* pathareaorg�ϡ�pathmeimem_[]�Τ����⡼��ɽ�Τ���ǥ��쥯�ȥ�̾��
+	    ��Ǽ�����Ĥ����ʬ����Ƭ��ؤ���*/
+
+	while(bufp = buf, read1tm(&bufp, 0)) mod_evl(buf);
+	fclose(modefile);
+}
+
+ /**	���ꤵ�줿�ʥ������ѥ��򸫤�ɬ�פΤʤ��˥ե�����̾���Ф��Ƥ���0��
+	�֤������ߤΤȤ����� / ./ ../ �Τɤ줫�ǻϤޤ��ΤȤ��Ƥ��뤬�ʺ�Ԥ�
+	���ǡˡ�Ŭ�����Ѥ��Ƥ褤��strchr(s,'/')!=NULL �Ȥ��������ɤ����� */
+int
+fixednamep(s)
+char	*s;
+{
+	return(!strncmp("/",s,1)|| !strncmp("./",s,2)|| !strncmp("../",s,3));
+}
+
+ /**	�⡼��ɽ�ΰ줫���ޤ�ʥꥹ�ȡ��ե�����̾���⡼��ɽ��ʸ����ˤ�
+	��᤹�롣�֤��ͤϡ�defmode,search�ڤ�path�λ�0������ʳ��ʤ�1��*/
+static int
+mod_evl(s)
+char	*s; /* �⡼��ɽ������ɽ������ؤΥݥ��� */
+{
+	char	md1[MDT1LN], *bgn, *end;
+	int	num, retval = 1;
+
+	if(*s != '('){
+		if(*s != '"'){
+			num = fnmsrc_tourk(s);
+			*naibu++ = XY2INT(4, num);
+		} else {
+			s++;
+			if(*(end = strend(s)) != '"') ERRMOD(10);
+			*end = '\0';
+			num = dspnamsrc_tourk(s);
+			*naibu++ = XY2INT(5, 0);
+			*naibu++ = num;
+		}
+	} else {
+		s++;
+		scan1tm(&s, md1, 1);
+		switch(num = kwdsrc(modfn, md1)){
+			case 0: /* defmode */
+				retval = 0;
+				scan1tm(&s, md1, 1); /* modename */
+				num = modsrc_tourk(md1, 0);
+				if(scan1tm(&s, md1, 0) == 0){
+				 /* ���on-off�ˤĤ��Ʋ���񤤤Ƥʤ�����
+				    default��off */
+					modesw[num] . moderng = 2;
+					modesw[num] . curmode = 0;
+					break;
+				}
+
+				if(*md1 == '('){
+					char	tmp[MDT1LN], *s;
+					unsigned int	i, j;
+
+					s = md1 + 1;
+
+					scan1tm(&s, tmp, 1);
+					if(chk_get_int(tmp, &i, 0) != 0)
+						ERRMOD(8);
+					modesw[num] . moderng = i;
+					scan1tm(&s, tmp, 1);
+					if(chk_get_int(tmp, &j,
+						  modesw[num] . moderng) != 0)
+						ERRMOD(8);
+					modesw[num] . curmode = j;
+					if(
+#ifdef ModeNotInt
+					   modesw[num] . moderng != i ||
+					   modesw[num] . curmode != j ||
+#endif
+					   i == 1 || (i != 0 && j >= i)){
+					   	ERRMOD(8);
+					}
+					scan1tm(&s, tmp, 2);
+				} else {
+					switch(kwdsrc(swstat, md1)){
+						case 0: modesw[num] . curmode
+								= 1; break;
+						case 1: modesw[num] . curmode
+								= 0; break;
+					}
+					modesw[num] . moderng = 2;
+				}
+				scan1tm(&s, md1, 2); /* �����err */
+				break;
+			case 1: /* if */
+			case 2: /* when */
+				*naibu++ = modfn[num] . code;
+				scan1tm(&s, md1, 1); /* condition */
+				cond_evl(md1);
+				while(scan1tm(&s, md1, 0)){
+					if(mod_evl(md1) == 0) ERRMOD(17);
+				}
+				*naibu++ = Terminator;
+				break;
+			case 3: /* path */
+				*(pathmeimem = pathareaorg) = '\0';
+				*(pathmeiptr = pathmeiorg) = NULL;
+			case 4: /* search */
+				retval = 0;
+				if(hyomeiptr != hyomeiorg) ERRMOD(11);
+				 /* �������ѥ��λ���ϥե�����̾�νи����
+				    ��Ԥ��ʤ���Фʤ�ʤ��Ȥ��Ƥ�����*/
+
+				while(scan1tm(&s, md1, 0)){/* find pathname */
+					pathsrc_tourk(md1);
+				}
+				break;
+			case 5: /* on_dispmode */
+			case 6: /* off_dispmode */
+				*naibu++ = modfn[num] . code;
+				scan1tm(&s, md1, 1); /* dispmode string */
+
+				if(*(bgn = md1) != '"') ERRMOD(12);
+				bgn++;
+				if(*(end = strend(bgn)) != '"') ERRMOD(10);
+				*end = '\0';
+				*naibu++ = dspnamsrc_tourk(bgn);
+				scan1tm(&s, md1, 2); /* �����err */
+				break;
+			case 7: /* on_unchg */
+			case 8: /* off_unchg */
+				*naibu++ = modfn[num] . code;
+				scan1tm(&s, md1, 2); /* �����err */
+				break;
+		}
+
+	}
+	*naibu = Terminator;
+	return(retval);
+}
+
+ /** ��P�ʥ⡼��̾ ����not,and�ʤɤμ��˰�Ĥ��� */
+static void
+cond_evl(cod)
+char	*cod; /* ��P������ɽ������ؤΥݥ��� */
+{
+	char	md1[MDT1LN];
+	unsigned int	num;
+	int	i; 
+
+	if(is_digit(*cod) || *cod == '-'){
+		*naibu++ = XY2INT(7, 0);
+		if(0 != chk_get_int(cod, &num, 0)) ERRMOD(4);
+		*naibu++ = num;
+	} else if(*cod != '('){
+		num = modsrc_tourk(cod, 1);
+		*naibu++ = XY2INT(1, num);
+	} else {
+		cod++;
+		scan1tm(&cod, md1, 1); /* not;and;or */
+		num = kwdsrc(modcond, md1);
+		*naibu++ = XY2INT(3, num);
+		for(i = condarg[num]; i; i--){
+			scan1tm(&cod, md1, 0);
+			cond_evl(md1);
+		}
+		scan1tm(&cod, md1, 2);
+	}
+	*naibu = Terminator;
+}
+
+ /**	s�ǻ��ꤵ�줿�ե�����̾������Ͽ��õ�����ʤ������Ͽ��â��������Ͽ��
+	�ɤ����Υ����å��ϸ�̩�ǤϤʤ������㤨�С�Ʊ���ե�����Ǥ⡢
+	�ѥ�̾�դ���̵���ȤǤϡ�Ʊ���ȸ��ʤ��ˡ��ե�����̾������Ͽ���ɤ���
+	�����å�����Τϡ���������Τ����Ʊ��ɽ���ɤ߹���Τ��ɤ�����
+	�����ʤΤǡ�����ʳ��ˤ��̤˺������Ϥʤ���*/
+static int
+fnmsrc_tourk(s)
+char	*s;
+{
+	int	n;
+
+	for(n = 0; hyomeiorg[n] != NULL; n++)
+		if(!mystrcmp(hyomeiorg[n], s)) return(n);
+
+	if(hyomeiorg + n != hyomeiptr) BUGreport(101);
+
+	*hyomeiptr++ = hyomeimem;
+	*hyomeiptr = NULL;
+	mystrcpy(hyomeimem, s);
+	if(!(hyoshu[n] = filnamchk(hyomeimem))) ERRMOD(3);
+	strtail(hyomeimem);
+	*++hyomeimem = '\0';
+	return(n);
+}
+
+ /**	s�ǻ��ꤵ�줿�������ѥ�̾������Ͽ��õ�����ʤ������Ͽ��â����fnmsrc_
+	tourk()Ʊ�͡�����Ͽ���ɤ����Υ����å��ϸ�̩�ǤϤʤ�������ʤ���*/
+static int
+pathsrc_tourk(s)
+char	*s;
+{
+	int	n;
+	char	fnm_addsla[MDT1LN];
+
+	mystrcpy(fnm_addsla, s);
+	if( !(*fnm_addsla == '\0' || *(strend(fnm_addsla)) == KUGIRI))
+		chrcat(fnm_addsla, KUGIRI);
+	 /* �ѥ�̾��'/'�ǽ���äƤʤ���С�������ղä��롣*/
+
+	for(n = 0; pathmeiorg[n] != NULL; n++)
+		if(!strcmp(pathmeiorg[n], fnm_addsla)) return(n);
+
+	if(pathmeiorg + n != pathmeiptr) BUGreport(104);
+
+	*pathmeiptr++ = pathmeimem;
+	*pathmeiptr = NULL;
+	strcpy(pathmeimem, fnm_addsla);
+
+	strtail(pathmeimem);
+
+	*++pathmeimem = '\0';
+	return(n);
+}
+
+ /** s�ǻ��ꤵ�줿�⡼��ɽ��ʸ���󤬴���Ͽ��õ�����ʤ������Ͽ */
+static int
+dspnamsrc_tourk(s)
+char	*s;
+{
+	int	n;
+
+	for(n = 0; dspnambgn[n] != NULL; n++)
+		if(!mystrcmp(dspnambgn[n], s)) return(n);
+
+	if(dspnambgn + n != dspnamptr) BUGreport(103);
+
+	*dspnamptr++ = dspcod;
+	*dspnamptr = NULL;
+	mystrcpy(dspcod, s);
+	strtail(dspcod);
+	*++dspcod = '\0';
+	return(n);
+}
+
+ /**	��Ͽ����Ƥ���⡼��̾���椫�顢s�ǻ��ꤵ�줿�⡼��̾��õ����*np ��
+	�⡼���ֹ椬���롣���Ĥ���ʤ��ȸ��⡼��̾�����������롣���ξ��
+	���ͤ�0��*/
+static int
+modnam_src(s, np)
+char	*s;
+int	*np;
+{
+	for(*np = 0; modmeibgn[*np] != NULL; (*np)++ )
+		if(!mystrcmp(modmeibgn[*np], s)) return(1);
+	return(0);
+}
+
+ /**	s�ǻ��ꤵ�줿�⡼��̾��õ�����ʤ������Ͽ��â����flg����0�ʤ顢
+	���Ĥ���ʤ���Х��顼 */
+static int
+modsrc_tourk(s, flg)
+char	*s;
+int	flg;
+{
+	int	n;
+
+	if(modnam_src(s, &n)) return(n);
+
+	if(flg) ERRMOD(5);
+
+	if(modmeibgn + n != modmeiptr) BUGreport(102);
+
+	*modmeiptr++ = modmeimem;
+	*modmeiptr = NULL;
+	mystrcpy(modmeimem, s);
+	if(!modnamchk(modmeimem)) ERRMOD(4);
+	strtail(modmeimem);
+	*++modmeimem = '\0';
+	return(n);
+}
+
+ /** �ե����뤫���ʸ���ɤ�ʶ���ʸ�������Ф��ˡ��ɤ��ʸ����EOF�ʤ�0���֤� */
+static char
+fspcpass()
+{
+	register int	c;
+
+	while(EOF != (c = chkchar_getc(modefile)) && is_nulsp(c));
+	return(c == EOF ? '\0' : c);
+}
+
+ /**	�⡼��ɽ�ˤ϶���ʸ���ʳ��Υ���ȥ�����ʸ�������ǤϺ�����ʤ���Τ�
+	���롣�����äƤ������ϥ����å����Ĥġ�getc��Ԥ���*/
+static int
+chkchar_getc(f)
+FILE	*f;
+{
+	register int	c;
+
+	c = getc(f);
+	if(is_cntrl(c) && !isspace(c)){
+		sprintf(mcurread, "\\%03o", c);
+		ERRMOD(16);
+	}
+	return(c);
+}	
+
+static int
+modehyo_getc()
+{
+	return(chkchar_getc(modefile));
+}
+
+static int
+modehyo_ungetc(c)
+register int	c;
+{
+	return(ungetc(c, modefile));
+}
+
+ /**	soc��̾�Υ桼���Υ������󡦥ǥ��쥯�ȥ�̾��dest�����졢*dest�ˤ���
+	������ؤ����롣â��soc������ʤ鼫ʬ�Υ������󡦥ǥ��쥯�ȥ�̾��
+	NULL�ʤ鼫ʬ�Υۡ��ࡦ�ǥ��쥯�ȥ�̾��������ξ��⡢����������
+	���⤷�ʤ������ͤϡ���������-1��getenv("HOME")���Ի�������-2�ˡ�*/
+static int
+get_hmdir(dest, soc)
+char	**dest, *soc;
+{
+	struct	passwd	*usr;
+	char	*p;
+
+	if(soc == NULL){
+		if(NULL == (p = getenv("HOME"))) return(-2);
+	} else {
+		if(NULL == (usr = (*soc? getpwnam(soc) : getpwuid(getuid()))))
+			return(-1);
+		p = usr -> pw_dir;
+	}
+	strcpy(*dest, p);
+	strtail(*dest);
+	return(0);
+}
+
+ /**	�⡼��ɽ���б�ɽ��Ρ��ե�����̾����ʬ���ɤ߹��ߡ���Ƭ�� @ ���� ~ ��
+	���ϡ��ü������Ԥ��������ϡ�����ɤ߹��ߡ�����ᤷ��ʸ������Ф���
+	�ؿ��ȡ���̤�����륨�ꥢ�����ϤؤΥݥ��󥿡������ɤޤ��ʸ���������
+	�ݥ��󥿡����ͤϡ����ェλ��0��@HOME�ǥۡ��ࡦ�ǥ��쥯�ȥ꤬���ʤ���
+	1��@�Τ��Ȥ��Ѥʤ�Τ��褿��2��~�Ǽ�ʬ�Υۡ��ࡦ�ǥ��쥯�ȥ꤬���ʤ�
+	��3��~�Τ��Ȥ�¸�ߤ��ʤ��桼��̾���褿��4��*/
+int
+readfnm(readchar_func, unreadc_func, readstr_func, areap, lastcptr)
+register int	(*readchar_func)(), (*unreadc_func)(), (*readstr_func)();
+char	**areap;
+int	*lastcptr;
+{
+	char	*head;
+	register int	c;
+
+	c = (*readchar_func)();
+	if(c == '@'){ /* @HOME, @MODEDIR, @LIBDIR */
+		*(*areap)++ = c;
+		head = *areap;
+		(*readstr_func)(areap, 1);
+
+		if(mystrcmp("HOME", head) == 0){
+			*areap = --head;
+			if(get_hmdir(areap, (char *)NULL) != 0){
+				*areap = head;
+				return(1);
+			}
+		} else
+		if(mystrcmp("MODEDIR", head) == 0){
+			strcpy(*areap = --head, modhyopath);
+			if(KUGIRI== *(*areap= strend(*areap))) **areap = '\0';
+		} else
+#ifdef WNNDEFAULT
+		if(mystrcmp("LIBDIR", head) == 0){
+			strcpy(*areap = --head, LIBDIR);
+			strtail(*areap);
+		} else
+#endif
+		{
+			*areap = --head;
+			return(2);
+		}
+
+	} else
+	if(c == '~'){ /* ~user */
+		int	err;
+			
+		*(*areap)++ = c;
+		head = *areap;
+		(*readstr_func)(areap, 1);
+
+		mystrcpy(head, head);
+		*areap = head - 1;
+		if((err = get_hmdir(areap, (*head ? head : NULL)))!= 0){
+			*areap = --head;
+			return(err == -2 ? 3 : 4);
+		}
+
+	} else {
+		(*unreadc_func)(c);
+	}
+
+	*lastcptr = (*readstr_func)(areap, 0);
+	return(0);
+}
+
+ /**	�⡼��ɽ�����ʸ��ʬ���Ф���Ȥ򡢶��򡦳�̤Τɤ줫
+	����EOF�����ޤ�³���롣flg & 01����0�ʤ顢'/'����Ƥ�
+	����롣���ͤϡ������ɤޤ��ʸ����*/
+static int
+rd_string(readfile, sptr, flg)
+register FILE	*readfile;
+char	**sptr;
+int	flg;
+{
+	int	c;
+
+	while(EOF != (c = chkchar_getc(readfile)) &&
+	      !(is_nulsp(c) || c == '(' || c == ')') &&
+	      !(flg & 01 && c == KUGIRI)){
+		switch(c){
+			case '\\': rd_bcksla(readfile, sptr); break;
+			case '^': rd_ctrl(readfile, sptr); break;
+			default: *(*sptr)++ = c;
+		}
+	}
+	**sptr = '\0';
+	return(ungetc(c, readfile));
+}
+
+static int
+rd_str_from_modefile(sptr, flg)
+char	**sptr;
+int	flg;
+{
+	return(rd_string(modefile, sptr, flg));
+}
+
+
+ /**	�⡼��ɽ����Хå�����å�������ΰ�ʸ��ʬ����Ф���'\��8�ʡ�;'
+	�η���ľ����â������Ƭ��'\\'�ϴ����ɤޤ줿���ȡ�*/
+static void
+rd_bcksla(readfile, sptr)
+register FILE	*readfile;
+char	**sptr;
+{
+	int	c, code = 0, digflg = 0;
+
+	switch(c = chkchar_getc(readfile)){
+		case 'n':
+			code = '\n'; digflg = 1; break;
+		case 't':
+			code = '\t'; digflg = 1; break;
+		case 'b':
+			code = '\b'; digflg = 1; break;
+		case 'r':
+			code = '\r'; digflg = 1; break;
+		case 'f':
+			code = '\f'; digflg = 1; break;
+		case 'e':
+		case 'E':
+			code = ESCCHR; digflg = 1; break;
+		case 'o':
+			while(c = chkchar_getc(readfile), is_octal(c)){
+				code <<= 3;
+				code += ctov(c);
+				digflg = 1;
+			}
+			if(c != ';') ungetc(c, readfile);
+			break;
+		case 'd':
+			while(c = chkchar_getc(readfile), is_digit(c)){
+				code *= 10;
+				code += ctov(c);
+				digflg = 1;
+			}
+			if(c != ';') ungetc(c, readfile);
+			break;
+		case 'x':
+			while(c = chkchar_getc(readfile), is_xdigit(c)){
+				code <<= 4;
+				code += ctov(c);
+				digflg = 1;
+			}
+			if(c != ';') ungetc(c, readfile);
+			break;
+		default:
+			if(is_octal(c)){
+				digflg = 1;
+				code = ctov(c);
+				while(c= chkchar_getc(readfile), is_octal(c)){
+					code <<= 3;
+					code += ctov(c);
+				}
+				if(c != ';') ungetc(c, readfile);
+			} else {
+				code = c;
+				digflg = 1;
+			}
+	}
+
+	if(digflg == 0) ERRMOD(7);
+	sprintf(*sptr, "\\%o;", code);
+	strtail(*sptr);
+}
+
+ /**	�⡼��ɽ���饳��ȥ����륳���ɷ����ΰ�ʸ��ʬ����Ф���
+	'\��8�ʡ�;' �η���ľ����â������Ƭ��'^'�ϴ����ɤޤ줿���ȡ�*/
+static void
+rd_ctrl(readfile, sptr)
+register FILE	*readfile;
+char	**sptr;
+{
+	int	c;
+
+	if(!(' ' <= (c = chkchar_getc(readfile)) && c < '\177')) ERRMOD(7);
+	if(c == '?') c = '\177'; else c &= 0x1f;
+
+	sprintf(*sptr, "\\%o;", c);
+	strtail(*sptr);
+}
+
+ /**	�⡼��ɽ�ΰ줫���ޤ�ʥꥹ�ȡ��ե�����̾���⡼��ɽ��ʸ����ˤ�
+	�ڤ�Ф������κݡ��ü��ɽ����'^','\'�ˤ��ˤϡ�'\��8�ʡ�;' ��
+	����ľ����flg����0�ʤ顢EOF�ǥ��顼�򵯤�����')'��0���֤���*/
+static int
+read1tm(sptr, flg)
+char	**sptr; /* �⡼��ɽ������ɽ������ؤΥݥ��󥿤ؤΥݥ��󥿡�
+		   rd_bcksla()��rd_ctrl()��codeeval()�Ǥ�Ʊ�� */
+int	flg;
+{
+	int	c, err, retval = 1;
+	char	*s;
+
+	s = *sptr;
+
+	while((c = fspcpass()) == ';'){
+	  /* ����ʸ�򸡽Ф����顢�����ޤǤȤФ��ƺƻ�ԡ�*/
+		while((c = chkchar_getc(modefile)) != '\n' && c != EOF);
+	}
+
+	switch(c){
+		case '\0': /* EOF��ɽ�� */
+			if(flg) ERRMOD(0);
+			 else retval = 0;
+			break;
+		case ')':
+			if(flg) retval = 0;
+			 else ERRMOD(1);
+			break;
+		case '(':
+			*s++ = c;
+			*s++ = ' ';
+			while(read1tm(&s, 1)) *s++ = ' ';
+			*s++ = ')';
+			break;
+		case '"':
+			*s++ = c;
+			while((c = chkchar_getc(modefile)) != '"'){
+				switch(c){
+					case EOF : ERRMOD(0);
+					case '\\': rd_bcksla(modefile, &s);
+						   break;
+					case '^' : rd_ctrl(modefile, &s);
+						   break;
+					default	 : *s++ = c;
+				}
+			}
+			*s++ = '"';
+			break;
+		default:
+			ungetc(c, modefile);
+		 /* ��Ƭ�� @ ���� ~ �λ��ϡ��ü������*/
+			err = readfnm(modehyo_getc, modehyo_ungetc,
+				      rd_str_from_modefile, &s, &c);
+			if(err){
+				mcurread = s;
+				switch(err){
+					case 1:
+					case 3: ERRMOD(13);
+					case 2: ERRMOD(14);
+					case 4: ERRMOD(15);
+				}
+			}
+
+			if(c == EOF && flg) ERRMOD(0);
+			if(c == ')' && !flg) ERRMOD(1);
+	}
+
+	*s = '\0';
+	*sptr = s;
+	return(retval);
+}
+
+ /**	8��10��16�ʥ������ѤΥ���饯����ºݤΥ����ɤ�ľ�������ϤΥ����å���
+	���ʤ���*/
+static int
+ctov(c)
+char	c;
+{
+	if(is_upper(c)) return(c - 'A' + 10);
+	if(is_lower(c)) return(c - 'a' + 10);
+	return(c - '0');
+}
+
+ /**	�ꥹ�Ȥ���Ȥ�scan�����ѡ�')'��0���֤���EOL����ʤ��Ϥ���
+	flg == 1 �ΤȤ������Ф��˼��Ԥ����饨�顼��
+	flg == 2 �ΤȤ������Ф������������饨�顼��
+	�ü�ʥ�����ɽ���ϴ������� '\��8�ʡ�;' �η���ľ�äƤ���Ȧ��*/
+static int
+scan1tm(socp, dest, flg)
+char	**socp, *dest;
+	 /* socp�λؤ��Ƥ���ݥ��󥿤��ؤ��Ƥ���꤫����Ф���dest������롣
+	    ���θ塢socp���ؤ��Ƥ���ݥ��󥿤�ʤ�롣*/
+int	flg;
+{
+	char	c;
+	int	retval = 1;
+
+	while(c = *(*socp)++, is_nulsp(c)) if(c == '\0') ERRMOD(6);
+	switch(c){
+		case ')':
+			retval = 0;
+			break;
+		case '(':
+			*dest++ = c;
+			*dest++ = ' ';
+			while(scan1tm(socp, dest, 0)){
+				strtail(dest);
+				*dest++ = ' ';
+			}
+			*dest++ = ')';
+			break;
+		case '"':
+			*dest++ = c;
+			while((c = *dest++ = *(*socp)++) != '"'){
+				if(c == '\\'){ /* '\��8�ʡ�;'�β�� */
+					while(c = *dest++ = *(*socp)++,
+					      is_octal(c));
+				}
+			}
+			break;
+		default:
+			*dest++ = c;
+			while(!is_nulsp(**socp)) *dest++ = *(*socp)++;
+	}
+
+	*dest = '\0';
+	if((flg == 1 && retval == 0) || (flg == 2 && retval == 1)) ERRMOD(6);
+	return(retval);
+}
+
+ /** �⡼��̾�Ȥ��������������å����ѿ�������ʤäƤ���Ф��� */
+static int
+modnamchk(s)
+char	*s;
+{
+	if(is_digit(*s)) return(0);
+	for(; *s; s++) if(!is_alnum(*s) && *s != '_') return(0);
+	return(1);
+}
+
+#define modu1(a, b) ((b) ? ((a) % (b)) : (a))
+#define curmod(num) (modesw[num] . curmode)
+#define modrng(num) (modesw[num] . moderng)
+
+ /**	num���ܤΥ⡼�ɤ�����󥸤����Ѵ�ɽ������ľ�������� mode ���ͤ�0�ʤ�
+	�⡼�ɤ�off��1�ʤ�on���뤳�Ȥˤʤ롣�ʤ�����mode���ͤ��֤���*/
+modetyp	chgmod(num, mode)
+int	num;
+modetyp mode;
+{
+	modetyp oldmod;
+
+	oldmod = curmod(num);
+	curmod(num) = modu1(mode, modrng(num));
+	choosehyo();
+	return(oldmod);
+}
+
+ /** ���⡼�ɤ�ޤȤ���ڤ��ؤ��� */
+void
+allchgmod(mode)
+modetyp	mode;
+{
+	int	i;
+
+	for(i = 0; modmeibgn[i] != NULL; i++){
+		curmod(i) = modu1(mode, modrng(i));
+	}
+	choosehyo();
+}
+
+ /**	num���ܤΥ⡼�ɤ���ꤷ�����������󥯥���Ȥ�����mode���ͤ��֤���*/
+modetyp	incmod(num, dmode)
+int	num;
+modetyp	dmode;
+{
+	modetyp	oldmod, newmod;
+
+	newmod = oldmod = curmod(num);
+	newmod += dmode;
+	if(oldmod > newmod) newmod -= modrng(num);
+	return(chgmod(num, newmod));
+}
+
+ /**	num���ܤΥ⡼�ɤ���ꤷ���������ǥ�����Ȥ�����mode���ͤ��֤����Թ�
+	�ˤ�ꡢincmod�Ȥ��̤��Ѱդ��ʤ��ƤϤʤ�ʤ���*/
+modetyp	decmod(num, dmode)
+int	num;
+modetyp	dmode;
+{
+	modetyp	oldmod, newmod;
+
+	newmod = oldmod = curmod(num);
+	newmod -= dmode;
+	if(oldmod < newmod) newmod += modrng(num);
+	return(chgmod(num, newmod));
+}
+
+ /**	name��̾�Υ⡼�ɤ��ʤ������0���֤�������Ф��Υ⡼���ֹ桦�ڤӤ���
+	���֤κ����͡ܣ��ȸ��ߤξ��֤��äƤ��� */
+int
+romkan_getmode(name, nump, modep, moderngp)
+char	*name;
+int	*nump;
+modetyp	*modep, *moderngp;
+{
+	if(!modnam_src(name, nump)) return(-1);
+	*modep = curmod(*nump);
+	*moderngp = modrng(*nump);
+	return(0);
+}
+
+ /**	name��̾�Υ⡼�ɤ��ʤ������0���֤�������Ф��ξ��֤򥻥åȤ���
+	�Ѵ�ɽ�������θ塢����֤�������0���֤���*/
+int
+romkan_setmode(name, modep)
+char	*name;
+modetyp	*modep;
+{
+	modetyp	oldmode, moderng;
+	int	modenum;
+
+	if(romkan_getmode(name, &modenum, &oldmode, &moderng)!= 0) return(-1);
+	chgmod(modenum, *modep);
+	*modep = oldmode;
+	return(0);
+}
+
+ /** �Ѵ�ɽ�Υ��ꥢ */
+void
+romkan_reset()
+{
+	naibu_[0] = Terminator;
+	choosehyo();
+	romkan_clear();
+}
+
+ /** �Ѵ��б�ɽ�������Ԥ� */
+void
+choosehyo()
+{
+	int	*naibup, i;
+
+	naibup = naibu_;
+	usemaehyo[0] = usehyo[0] = useatohyo[0] = -1;
+	for(i = 0; i < 2; i++){
+		dspmod[1][i] = dspmod[0][i];
+		dspmod[0][i] = NULL;
+	}
+
+	look_choose(&naibup, 1);
+}
+
+ /**	�⡼��ɽ������������缡���Ƥ���������ɽ������ڤӥ⡼��ɽ��ʸ�����
+	�����ԤäƤ�����â��flg��0�ʤ饹���åפ������ */
+static void
+look_choose(naibupp, flg)
+int	**naibupp;   /* �⡼��ɽ������ɽ������ؤΥݥ��󥿤ؤΥݥ��󥿡�
+			look_cond()��evlcond()�Ǥ�Ʊ�� */
+int	flg;
+{
+	int	*naibup, naibu1, naibu2, branch, lcrsl;
+
+	naibup = *naibupp;
+
+	while((naibu1 = *naibup++) != Terminator){
+		switch(SHUBET(naibu1)){
+			case 4: /* ɽ̾ */
+				if(flg) hyouse(LWRMSK(naibu1));
+				break;
+			case 2: /* ��P */
+				branch = LWRMSK(naibu1); /* if;when */
+				lcrsl = look_cond(&naibup, flg);
+				if(branch == 0 && lcrsl) flg = 0;
+				break;
+			case 5: /* romkan��on��off�����줾���
+				   �⡼��ɽ��ʸ���� */
+				naibu2 = *naibup++;
+				if(flg) dspmod[0][LWRMSK(naibu1)] =
+							    dspnambgn[naibu2];
+				break;
+			case 6: /* romkan�����줾��on��off���Υ⡼��ɽ��
+				   ʸ��������Τޤޤ� */
+				if(flg) dspmod[0][LWRMSK(naibu1)] = 
+						    dspmod[1][LWRMSK(naibu1)];
+				break;
+			default:
+				BUGreport(6);
+		}
+	}
+
+	*naibupp = naibup;
+}
+
+ /**	*naibupp ��������ɽ������Ǿ�P��ɽ���Ȥ�����ؤ��Ƥ���Ȧ�ʤΤǡ�
+	�����ɾ���������ʤ餽��³�����ᤷ�ˤ��������ʤ��ɤ����Ф���
+	���ͤϡ��ǽ��ɾ��������P�ο����͡�*/
+static int
+look_cond(naibupp, flg)
+int	**naibupp, flg;
+{
+	int	*naibup, condrsl;
+
+	naibup = *naibupp;
+
+	condrsl = evlcond(&naibup); /* ɬ��ɾ�����ʤ��Ȥ����ʤ����� */
+	flg = flg && condrsl;
+	look_choose(&naibup, flg);
+
+	*naibupp = naibup;
+	return(flg);
+}
+
+ /** ��P�ο����ͤ�ɾ��  ���ͤ�0��1�Ȥϸ¤�� */
+static int
+evlcond(naibupp)
+int	**naibupp;
+{
+	int	*naibup, naibu1, retval = -1, tmpval[ARGMAX], i, imax;
+
+	naibup = *naibupp;
+
+	naibu1 = *naibup++;
+	switch(SHUBET(naibu1)){
+		case 7: /* ���� */
+			retval = *naibup++; break;
+		case 1: /* �⡼��̾ */
+			retval = modesw[LWRMSK(naibu1)] . curmode; break;
+		case 3: /* and�ʤ� */
+			imax =	condarg[LWRMSK(naibu1)];
+			for(i = 0; i < imax; i++)
+				tmpval[i] = evlcond(&naibup);
+			switch(LWRMSK(naibu1)){
+			 /* �夫����true,false,not,and,or */
+				case 0: retval = !tmpval[0]; break;
+				case 1: retval = tmpval[0]&& tmpval[1]; break;
+				case 2: retval = tmpval[0]|| tmpval[1]; break;
+				case 3: retval = 1; break;
+				case 4: retval = 0; break;
+				case 5: retval = (tmpval[0] == tmpval[1]);
+					break;
+				case 6: retval = (tmpval[0] != tmpval[1]);
+					break;
+				case 7: retval = ((unsigned int)tmpval[0] <
+						  (unsigned int)tmpval[1]);
+					break;
+				case 8: retval = ((unsigned int)tmpval[0] >
+						  (unsigned int)tmpval[1]);
+					break;
+			}
+			break;
+	}
+
+	*naibupp = naibup;
+	return(retval);
+}
+
+ /** num���ܤ�ɽ�򡢻��Ѥ����ΤȤ�����Ͽ���롣�����ܡ�������ζ��̤⤹�� */
+static void
+hyouse(num)
+int	num;
+{
+	int	*ptr;
+
+	switch(hyoshu[num]){
+		case 1: ptr = usemaehyo; break;
+		case 2: ptr = usehyo; break;
+		case 3: ptr = useatohyo; break;
+		default: BUGreport(11); return;
+	}
+	for(; *ptr != -1; ptr++) if(*ptr == num) return;
+	*ptr = num;
+	*++ptr = -1;
+}
+
+ /** strcmp��Ʊ��  â����'\��8�ʡ�;'���᤹�롣*/
+static int
+mystrcmp(s1, s2)
+char	*s1, *s2;
+{
+	char	c1, c2;
+
+	while((c1 = codeeval(&s1)) == (c2 = codeeval(&s2)))
+		if(c1 == '\0') return(0);
+	return(c1 > c2 ? 1 : -1);
+}
+
+ /** strcpy��Ʊ�� â��'\��8�ʡ�;'���᤹�롣s1 <= s2�ʤ�����ư���Ϥ� */
+static void
+mystrcpy(s1, s2)
+char	*s1, *s2;
+{
+	while(*s1++ = codeeval(&s2));
+}
+
+ /**	��ʸ���β���Ԥ������̤�ʸ���Ϥ��Τޤޡ�'\��8�ʡ�;'�ϼºݤΥ����ɤ�
+	ľ�������θ塢ʸ����ؤΥݥ��󥿤��ʸ��ʬ�ʤ�Ƥ����ʾ��ʤ��Ȥ�
+	���Х���ʬ�ʤळ�Ȥ��ݾڤ����Ϥ��ˡ�*/
+static char
+codeeval(sptr)
+register char	**sptr;
+{
+	register char	c;
+	char	code = 0;
+
+	if((c = *(*sptr)++) != '\\') return(c);
+	while(c = *(*sptr)++, is_octal(c)){
+		code <<= 3;
+		code += ctov(c);
+	}
+	if(c != ';') BUGreport(12);
+	return(code);
+}
+
+ /** romkan��on���Υ⡼��ɽ��ʸ������֤��ؿ���̵����Ǥ��ä�RK_DSPNIL�ե饰��
+     Ω�äƤ�����϶�ʸ������֤���*/
+
+char	*romkan_dispmode()
+{
+	return(dspmod[0][0] == NULL && (flags & RK_DSPNIL) ?
+	       nulstr : dspmod[0][0]);
+}
+
+ /** romkan��off���Υ⡼��ɽ��ʸ������֤��ؿ���̵����Ǥ��ä�RK_DSPNIL�ե饰
+     ��Ω�äƤ�����϶�ʸ������֤���*/
+char	*romkan_offmode()
+{
+	return(dspmod[0][1] == NULL && (flags & RK_DSPNIL) ?
+	       nulstr : dspmod[0][1]);
+}
+
+ /** ʸ����10�������ʤ餽�β��򤷡������Ǥʤ������0���֤� */
+static int
+chk_get_int(p, ip, range)
+char	*p;
+unsigned int	*ip;
+modetyp range;
+{
+	int	sgn = 1;
+	modetyp	out;
+
+	if(*p == '-'){
+		p++;
+		sgn = -1;
+	}
+	for(out = 0; *p; p++){
+		if(!is_digit(*p)) return(-1);
+#if defined(UX386) || defined(sun386)
+		out = out * 10;
+#else
+		out *= 10;
+#endif
+		out += ctov(*p);
+	}
+	if(range != 0) out %= range;
+	if(sgn == -1 && out != 0) out = range - out;
+	*ip = out;
+	return(0);
+}
diff --git a/wnn/rk_read.c b/wnn/rk_read.c
new file mode 100644
index 0000000000000000000000000000000000000000..b2348a453d14136a935c9c4695b0e6984e168f75
--- /dev/null
+++ b/wnn/rk_read.c
@@ -0,0 +1,1389 @@
+/*
+ * $Id: rk_read.c,v 1.1 1996/03/13 09:57:16 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_read.c
+						88. 6.11  �� ��
+
+	rk_main.c �����ʡ��Ѵ��б�ɽ���ɤ߹��ߤ�ô����
+***********************************************************************/
+/*	Version 3.0
+ */
+#include "rk_header.h"
+#include "rk_extvars.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+letter	onescan(), *rangekettei();
+char	*ename();
+
+extern	letter	*ltrgrow(), *ltrend(), letterpick(), *ltr1cut();
+extern	char	*chrcat(), *strend();
+
+static int termsscan(), evalandcpy(), eval1cpy(), partscan(),
+  evlis(), atermscan(), serfun(), hensrc_tourk(), blankpass(),
+  modsrcL(), chkL_get_int();
+static void ERRLIN(), ERHOPN(), readhyo(),
+  ltr1tostr(), ERRHYO(), vchk(), rangeset(), de_bcksla(), 
+  listscan(), singleqscan(), doubleqscan();
+extern void BUGreport(), choosehyo(), readmode();
+extern int ltrcmp(), ltrstrcmp(), readfnm(), fixednamep();
+
+#define IHENSU (1 << 24) /* ����ɽ���ξ�̣��Х��Ȥǡ��ѿ���ɽ�� */
+#define IKANSU (2 << 24) /*	      ��	      �ؿ���ɽ�� */
+#define IMODNM (3 << 24) /*	      ��	      �⡼��̾��ɽ�� */
+
+#define ENDOF_NestFileArea ((FILE *)~0)
+	 /** include�ե�����Υǥ�������ץ���Ǽ���ꥢ�Υ���ɥޡ���*/
+
+
+ /**	����ɤ߹��ߡ�������ɤ߹��ޤʤ�������EOF�ˤĤ������ä���0���֤���
+	â��include���θ���Ƥ��롣�б�ɽ�ˤ϶���ʸ���ʳ��Υ���ȥ�����ʸ����
+	���ǤϺ�����ʤ���ΤȤ��������äƤ���������å����롣*/
+int
+readln(buf)
+uns_chr *buf;
+{
+	register uns_chr *p;
+	register int	c;
+
+	if(NULL == *base){
+		*buf = '\0';
+		return(0);
+	}
+
+	p = buf;
+	while(1){
+		while(EOF == (c = getc(*base))){
+			fclose(*base);
+			if(NULL == *--base){
+				c = EOF;
+				break;
+			}
+		}
+		if(c == EOF || c == '\n') break;
+
+		if(is_cntrl(c) && !isspace(c)){
+			sprintf(hcurread, "\\%03o", c);
+			ERRLIN(21);
+		}
+		*p++ = c;
+	}
+	*p = '\0';
+	return(p != buf || c != EOF);
+}
+
+letter	*memptr, *ltrbufptr, *hensumei, *hen_iki, *term, **henptr;
+letter	*dummy;
+struct	dat	*datptr;
+struct	hensuset
+{
+	unsigned	regdflg : 1;	/* ����Ͽ���ѿ���ɽ�� */
+	unsigned	curlinflg : 1;	/* ���߹Ԥ˴��Ф��ѿ���ɽ�� */
+	unsigned	constflg : 1; /* ����Ȥ���������줿���Ȥ�ɽ�� */
+	letter		*name;
+	letter		*range;
+} *hentourkptr, *henorg;
+
+ /** Ϳ����줿�ե����뤬�ǥ��쥯�ȥ�ʤ���0���֤� */
+int
+isdir(fnm)
+char	*fnm;
+{
+	struct	stat	statbuf;
+/*
+	return(stat(fnm, &statbuf) == 0 && (statbuf.st_mode & S_IFDIR));
+*/
+	return(stat(fnm, &statbuf) == 0 && ((statbuf.st_mode & S_IFMT) == S_IFDIR));
+}
+
+ /**	name��Ϳ����줿̾���Ѵ��б�ɽ�򥪡��ץ󤹤롣����̾�ȸ��ʤ���ʤ�
+	̾����fixednamep()���ȡˤ��Ф��Ƥϡ��������ѥ��򸫤롣���ξ�硢
+	�����ץ�����������顢�ѥ�̾�� *dirnamptr��������֤롣����¾�ξ���
+	*dirnamptr�˶�ʸ�������롣*errcod�ˤϼ��Υ��顼�����ɤ����롣
+	Ϳ����줿�ե����뤬�ǥ��쥯�ȥ�λ�1�ʥ������ѥ���õ��������3�ˡ�
+	�ե�����򥪡��ץ�Ǥ��ʤ���2��Ʊ4�ˡ�*/
+FILE	*trytoopen(name, dirnamptr, errptr)
+char	*name, **dirnamptr;
+int	*errptr;
+{
+	char	**src, taio_fnm[REALFN];
+	FILE	*opened;
+
+	*dirnamptr = nulstr;
+	*errptr = 0;
+
+	if(fixednamep(name)){
+		if(isdir(name)){
+			*errptr = 1;
+			return(NULL);
+		}
+		if(NULL == (opened = fopen(name, "r"))){
+			*errptr = 2;
+			return(NULL);
+		}
+		if(flags & RK_VERBOS){
+			fprintf(stderr, "romkan: using Taio-hyo %s ...\r\n",
+				name);
+		}
+		return(opened);
+	} else {
+		for(src = pathmeiorg; *src != NULL; src++){
+			strcpy(taio_fnm, (*dirnamptr = *src));
+			strcat(taio_fnm, name);
+
+			if(isdir(taio_fnm)){
+				*errptr = 3;
+				return(NULL);
+			}
+			if(NULL == (opened = fopen(taio_fnm, "r"))) continue;
+
+			 /* Now Taio-hyo found */
+			if(flags & RK_VERBOS)
+				fprintf(stderr,
+					"romkan: using Taio-hyo %s ...\r\n",
+					taio_fnm);
+			return(opened);
+		}
+		if(flags & RK_VERBOS){ /* Taio-hyo not found */
+			char	*p, *q;
+
+			fprintf(stderr, "no %s in", name);
+			for(src = pathmeiorg; *src != NULL; src++){
+				fputc(' ', stderr);
+				q = *src;
+				if(*q == KUGIRI && *(q + 1) == '\0') q++;
+				 else q = strend(q);
+				for(p = *src; p < q; p++)
+					fputc(*p, stderr);
+			}
+			fprintf(stderr, ".\n");
+		}
+		*dirnamptr = nulstr;
+		*errptr = 4;
+		return(NULL);
+	}
+}
+
+ /** ɽ�������ɤ߹��� */
+void
+readdata(memory, data, hensudefhyo, modf)
+letter	*memory;	/* �б�ɽ������ɽ����������������Ƭ���Ϥ��Ϥ���� */
+struct	dat	*data;	/* �б�ɽ�ιԤ��ȤΥǡ������������������� */
+letter	**hensudefhyo;	/* �ѿ�����Υǡ������������������� */
+char	*modf;		/* �⡼�����ɽ��̾���Ϥ��Υѥ�̾�����äƤ��� */
+{
+	int	i, j;
+	char	*hyomeibgn[HYOMAX];
+	 /* ɽ��̾�ؤΥݥ��󥿤���������� */
+	char	hyomeimem_[HYOMEI];
+	 /* ɽ��̾�μºݤ�ʸ�������������� */
+	char	*pathmeibgn[PTHMAX];
+	 /* �������ѥ�̾�ؤΥݥ��󥿤���������� */
+	char	pathmeimem_[PTHMEI];
+	 /* �������ѥ�̾�μºݤ�ʸ�������������� */
+	char	modfnm[REALFN];
+	 /* �⡼��ɽ�Υե�����̾�򤳤��إ��Ԥ� �Τ��ˤϤ��Υѥ�̾������ */
+
+	memptr = memory;
+	datptr = data;
+	henptr = hensudefhyo;
+	*(pathmeiptr = pathmeiorg = pathmeibgn) = NULL;
+	*(pathmeimem = pathmeimem_) = '\0';
+	*(hyomeiptr = hyomeiorg = hyomeibgn) = NULL;
+	*(hyomeimem = hyomeimem_) = '\0';
+	*(modmeiptr = modmeibgn) = NULL;
+	*(modmeimem = modmeimem_) = '\0';
+	*(dspnamptr = dspnambgn) = NULL;
+	*(dspcod = dspcod_) = '\0';
+	*(naibu = naibu_) = '\0';
+
+	strcpy(modfnm, modf);
+	     /* modfnm��Ϳ�����ե�����̾���ѥ�̾����Ϳ����줿�顢�ǥե���Ȥ�
+		�⡼��ɽ̾"mode"��Ĥʤ���KUGIRI��ǥ��쥯�ȥ�ζ��ڤ�ʸ�� */
+
+	if(*modfnm == '\0' || *(strend(modfnm)) == KUGIRI){
+		strcat(modfnm, "mode");
+	} else if(isdir(modfnm)){
+		chrcat(modfnm, KUGIRI);
+		strcat(modfnm, "mode");
+	}
+
+	curdir = nulstr;
+	readmode(curfnm = modfnm);
+
+	for(i = 0; hyomeiorg[i] != NULL; i++){
+		int	err;
+
+		for(j = 0; j < FILNST; j++) nestfile[j] = NULL;
+		nestfile[FILNST - 1] = ENDOF_NestFileArea;
+		base = nestfile + 1;
+
+		*base = trytoopen(curfnm = hyomeiorg[i], &curdir, &err);
+		if(err){
+			switch(err){
+				case 1:
+				case 3: ERHOPN(1);
+				case 2:
+				case 4: ERHOPN(0);
+			}
+		}
+		readhyo(i);
+	}
+
+	hyo_n[i] . data = NULL;
+	choosehyo();
+}
+
+ /** �ե�����̾����ѥ�̾���������ʬ����Ƭ���֤���*/
+char	*ename(s)
+char	*s;
+{
+	char	*p;
+
+	p = strrchr(s, KUGIRI);
+	return(p == NULL ? s : p + 1);
+}
+
+ /**	�ե�����̾�Υ����å�����Ƭ�ʥѥ�̾�Ͻ����ˤ�'1'��'3'�Ǥʤ��Ȥ����ʤ���
+	�����ʤ�Τʤ�1��3�������ܡ������ɽ�ζ��̤�ɽ���ˤ��֤��������Ǥʤ���
+	0���֤���*/
+int
+filnamchk(s)
+char	*s;
+{
+	char	c;
+
+	c = *(ename(s)) - '0';
+	return((1 <= c && c <= 3) ? c : 0);
+}
+
+ /**	linbuf�����äƤ���unsigned char�����letter����ˤ���ltrbuf������롣
+	����ɥޡ�����EOLTTR�ˤʤ롣flg����0�λ��ϡ���Ƭ�ζ���ʸ�������Ф���*/
+void
+ustrtoltr(linbuf, ltrbuf, flg)
+uns_chr *linbuf;
+int	flg;
+register letter *ltrbuf;
+{
+	register letter l;
+
+	if(flg){
+		while(l = letterpick(&linbuf), is_eolsp(l)){
+			if(l == EOLTTR){
+				*ltrbuf = EOLTTR;
+				return;
+			}
+		}
+		*ltrbuf++ = l;
+	}
+	while((*ltrbuf++ = letterpick(&linbuf)) != EOLTTR);
+}
+
+ /**	letter�����ʸ����˥���С��ȡ���ĤΥݥ��󥿤�Ʊ�����ϤǤ��äƤ�
+	ư����ݾڤ��뤳�ȡ�*/
+void
+ltrtostr(ltrbuf, linbuf)
+char	*linbuf;
+letter	*ltrbuf;
+{
+	letter	l;
+
+	while((l = *ltrbuf++) != EOLTTR) ltr1tostr(l, &linbuf);
+	*linbuf = '\0';
+}
+
+ /** letter��ʸ����˥���С��� */
+static void
+ltr1tostr(l, sptr)
+char	**sptr;
+letter	l;
+{
+	int	i;
+
+	for(i = 0; i < 3 && 0 == (l & (0xff000000)); i++) l <<= 8;
+	for(; i < 4; i++){
+		*(*sptr)++ = (char)(l >> 24);
+		l <<= 8;
+	}
+}
+
+ /** �ѿ��Ρָ��߹Դ��Хե饰�פ����ƥ��ꥢ */
+void
+hen_useflgclr(hensu)
+struct	hensuset	*hensu;
+{
+	for(; hensu -> name != NULL; hensu++)
+		hensu -> curlinflg = 0; /* ���߹Ԥ�̤�� */
+}
+
+ /** �б�ɽ����ɤ߹��� */
+static void
+readhyo(n)
+int	n;
+{
+	uns_chr linbuf[LINSIZ];
+	letter	ltrbuf[LINSIZ], *lp;
+	letter	termbuf[SIZALL]; /* ���顼���θ���ơ�ɽ�Υ�����ʬ��äƤ���*/
+	letter	dummybuf[TRMSIZ], hensumei_[VARLEN], hen_iki_[SIZALL];
+	struct	hensuset	hensu[VARMAX];
+	int	m, hyosw, rsltyp[3];
+
+	hcurread = (char *)linbuf; /* ���顼������ */
+	ltrbufbgn = ltrbuf;
+
+	*(hensumei = hensumei_) = EOLTTR;
+	*(hen_iki = hen_iki_) = EOLTTR;
+	(henorg = hentourkptr = hensu) -> name = NULL;
+	dummy = dummybuf;
+
+	hyo_n[n] . hensudef = henptr;
+	hyo_n[n] . data = datptr;
+
+	hyosw = hyoshu[n];
+	while(readln(linbuf)){
+		hen_useflgclr(henorg);
+		ustrtoltr(linbuf, ltrbuf, 1);
+		ltrbufptr = ltrbuf;
+
+		for(m = 0; termsscan(&ltrbufptr, term = termbuf, 1); m++){
+			 /* m�ϡ������ܤι��ܤ򸫤Ƥ��뤫��ɽ�� */
+			if(*term == ';') break; /* ����� */
+			if(m == 3) ERRLIN(15);
+			if(m != 0 && rsltyp[0] == 4) ERRLIN(12);
+
+			datptr -> code[m] = memptr;
+			if((rsltyp[m] = evalandcpy(&term, m)) == 4){
+				if(m) ERRLIN(14);
+			 /* ����Ϻǽ�ι��ܤˤ������ʤ���
+			    funstr[]��appear�ե饰�Ǥ�����å����Ƥ��뤬
+			    ����Τ���˰�������ˤ�����å�������Ƥ�����*/
+			} else {
+			 /* ����λ��ˤ�����ɽ���ؤΥݥ��󥿤Ͽʤ�ʤ� */
+				totail(memptr);
+				memptr++;
+			}
+		}
+
+		if(m != 0 && rsltyp[0] != 4){
+			for( /* m=? */ ; m < 3; m++){
+				datptr -> code[m] = nil;
+				rsltyp[m] = -1; /* doesn't exist */
+			}
+			datptr++;
+
+ /* rsltyp: 0=ʸ���� 1=ʸ����Ϣ 2=�ǡ���Ϣ 3=��ǽ�� 4=����� -1=¸�ߤ��� */
+			switch(hyosw){
+		   /* ����������ϡ�ɽ�����Ƥ����¤����롣����򸡺� */
+				case 1:
+					if(!(rsltyp[0] == 0 &&
+					     rsltyp[1] == 0 && 
+					     rsltyp[2] == -1
+					    ))
+						ERRLIN(17);
+					break;
+				case 2:
+					if(rsltyp[1] == 3 && rsltyp[2] != -1)
+						ERRLIN(19);
+					break;
+				case 3:
+					if(!(rsltyp[0] == 0 &&
+					     (rsltyp[1] == 0 ||
+					      rsltyp[1] == 1) &&
+					     rsltyp[2] == -1
+					    ))
+						ERRLIN(18);
+					break;
+				default:
+					BUGreport(10);
+			}
+
+		}
+	}
+
+	(datptr++) -> code[0] = NULL;
+
+		/* �ѿ���Ͽ�����ǤޤȤ�Ƥ��� */
+	for(lp = hen_iki_; lp < hen_iki; ) *memptr++ = *lp++;
+	for(hentourkptr = henorg; hentourkptr -> name != NULL;
+	    hentourkptr++){
+		if(hentourkptr -> regdflg == 0) ERRHYO(0);
+		*henptr++ = memptr - (lp - hentourkptr -> range);
+	}
+	*henptr++ = NULL;
+
+	/* ������ fclose(*base); �����ס�readln��Ǥ���Ǥ��� */
+}
+
+ /**	�Ѵ��б�ɽ�ι��ܰ�Ĥ򡢲�ᤷ�ơ����������Υǡ������ꥢ�˥��ԡ����롣
+	�֤��ͤϡ���ᤷ�����ܤ�ʸ����ʤ�0������ʳ���ʸ����Ϣ�ʤ�1������ʳ�
+	�ǥǡ���Ϣ�ʤ�2����ǽ��ʤ�3�������ʤ�4������ʳ��ϥ��顼��*/
+static int
+evalandcpy(socp, m)
+register letter **socp; /* ���ܤؤΥݥ��󥿡ʤؤΥݥ��󥿡�*/
+int	m;   /* �б�ɽ�β����ܤι��ܤ򸫤Ƥ��뤫��ɽ�������ϥ���������
+		���Ƥ���Ȥ���0�����ϥ��������ʤ�1���Хåե��Ĥ����ʤ�2 */
+{
+#define TYPMAX	5
+
+	char	exist[TYPMAX], total;
+	 /* exist�ϡ����줾�쥿����0��4�ι�νи��Υե饰��eval1cpy()���ȡˡ�
+	    total�����ΤȤ��Ƥνи��ե饰���ɤ���⡢1=̤�� 2=���� ����¾��
+	    ���ϲ�2�ӥå�0 */
+	int	type;
+
+#define TIME_0(flag) ((flag) == 1)
+#define TIME_1(flag) ((flag) == 2)
+#define TIME_n(flag) (((flag) & 3) == 0)
+
+	total = 1;
+	for(type = 0; type < TYPMAX; type++) exist[type] = 1;
+
+	while(!is_eolsp(**socp)){
+		if(!(0 <= (type = eval1cpy(socp, m, 0)) && type < TYPMAX))
+			BUGreport(3);
+		exist[type] <<= 1;
+		total <<= 1;
+	}
+
+	if(TIME_0(total))
+		BUGreport(13); /* ���ܤ����ʤ�evalandcpy�ϼ¹Ԥ��ʤ�Ȧ */
+	if(!TIME_0(exist[3]) || !TIME_0(exist[4])){
+		if(TIME_n(total)) ERRLIN(9);
+		return(type); /* 3����4��type���ͤ��ݻ����Ƥ���Ȧ */
+	}
+	if(TIME_1(total) && TIME_1(exist[0])) return(0);
+	return(!TIME_0(exist[2]) ? 2 : 1);
+}
+
+ /**	�б�ɽ�ι��ܤ���ι��Ĥ��ᤷ�����������Υǡ������ꥢ�˥��ԡ�����
+	����Υ����ס�ʸ����=0 ʸ�����=1 �ü�ؿ���=2 ��ǽ��=3 �����=4�ˤ�
+	�֤���flg����0�ʤ顢�Ƶ�Ū�˸ƤФ줿���Ȥ��̣�������ξ�硢
+	���߹Ԥ�̤�Ф��ѿ��򸡽Ф����饨�顼���ޤ���m����0�ΤȤ������ϥ�������
+	�ʳ��ν�򸫤Ƥ�����ˤ⡢���߹Ԥ�̤�Ф��ѿ��򸡽Ф����饨�顼��*/
+static int
+eval1cpy(socp, m, flg)
+letter	**socp; /* flg�ʳ��ΰ����ΰ�̣��evalandcpy��Ʊ�� */
+int	m, flg;
+{
+	letter	t1buf[TRMSIZ], *t1bufp;
+
+	t1bufp = t1buf;
+
+	*memptr = EOLTTR;
+	switch(partscan(socp, t1bufp)){
+		case 1: /* ñʸ�� */
+			memptr = ltrgrow(memptr, t1bufp);
+			*memptr = EOLTTR;
+			return(0);
+		case 2: /* ����ʸ�� */
+			t1bufp++;
+			*memptr++ = onescan(&t1bufp, dummy);
+			*memptr = EOLTTR;
+			return(0);
+		case 3: /* ����ʸ���� */
+			t1bufp++;
+			while(*t1bufp != '"'){
+				*memptr++ = onescan(&t1bufp, dummy);
+			}
+			*memptr = EOLTTR;
+			return(1);
+		case 0: /* �ꥹ�� */
+			return(evlis(m, &t1bufp, flg));
+			 /* evlis��� *memptr = EOLTTR; �򤷤Ƥ��롣*/
+		default:
+			BUGreport(4);
+			return(-1);
+			 /*NOTREACHED*/
+	}
+	/*NOTREACHED*/
+}
+
+#define bitchk(x, n) ((x) & (1 << (n)))
+
+#define get_ltr(lp) (*(lp)++)
+#define unget_ltr(l, lp) (*--(lp) = (l))
+
+ /** global�ʥݥ��󥿤���ؤ���Ƥ���letter�󤫤��ʸ����äƤ��롣*/
+letter	get1ltr()
+{
+	return(get_ltr(lptr));
+}
+
+letter	unget1ltr(l)
+letter	l;
+{
+	return(unget_ltr(l, lptr));
+}
+
+int int_get1ltr() {return((int)(get1ltr()));}
+int int_unget1ltr(c) letter c; {return((int)(unget1ltr((letter) c)));}
+ /** �������Ȥ��ξ�ʤ����ʤ��ؿ��η���cast���Ǥ��ʤ��Ρ�
+    ��(int ()) get1ltr�פȽ񤭤����� */
+
+ /**	include�ե�����̾��letter���string�˼��Ф���Ȥ�letter��ν����
+	�ޤ�³���롣flg & 01����0�ʤ顢'/'�Ǥ⽪λ��*/
+letter	getfrom_dblq(socp, destp, flg)
+letter	**socp;
+char	**destp;
+int	flg;
+{
+	letter	l;
+
+	while(**socp != EOLTTR && !(flg & 01 && **socp == KUGIRI)){
+		if (**socp == '\\') *(*destp)++ = '\\';
+		l = onescan(socp, dummy);
+		ltr1tostr(l, destp);
+	}
+	*(*destp)++ = '\0';
+	return(**socp);
+}
+
+int
+getfrom_lptr(sptr, flg)
+char	**sptr;
+int	flg;
+{
+	return((int)getfrom_dblq(&lptr, sptr, flg));
+}
+
+ /**	�ꥹ�Ȥ��ᤷ������ɽ���ˤ��롣���ͤϡ����Υꥹ�ȤΥ����פ�ɽ������
+	ʸ���ѿ�������ʸ���ؿ���:0 ʸ����ؿ���:1 �ü�ؿ���:2
+	��ǽ��:3 �����:4 */
+static int
+evlis(m, socp, flg)
+letter	**socp; /* �����ΰ�̣��eval1cpy�򻲾� */
+int	m, flg;
+{
+	int	fnnum, hennum, i;
+	letter	t1buf[TRMSIZ];
+
+	(*socp)++; /* '('�򥹥��å� */
+	atermscan(socp, t1buf, 3);
+
+	fnnum = serfun(t1buf);
+	if(fnnum != -1 && !bitchk(func[fnnum] . appear, m)) ERRLIN(14);
+	 /* m���ͤˤ�äơ�����ƤϤ����ʤ���ؤνи����ɤ������Ƥ��롣*/
+
+	switch(fnnum){ /* default�ν�ʳ��� func[fnnum].argnum��ȤäƤʤ� */
+		case -1: /* �ѿ� */
+			vchk(t1buf);
+			atermscan(socp, dummy, 2); /* �����ERR */
+			hennum = hensrc_tourk(t1buf, ((m==0 && !flg)? 0 : 1));
+			*memptr++ = (henorg[hennum] . constflg ? 
+				     *(henorg[hennum].range) : hennum|IHENSU);
+			break;
+
+		case 0: /* fn No.0 defvar */
+			atermscan(socp, t1buf, 3);
+			if(*t1buf == '('){
+				letter	*soc2, t1buf2[TRMSIZ], t1buf3[TRMSIZ];
+				letter	*common_hen;
+
+				atermscan(socp, t1buf3, 3);
+
+				soc2 = t1buf + 1; /* skip '(' */
+
+				atermscan(&soc2, t1buf2, 3);
+				vchk(t1buf2);
+				if(-1 != serfun(t1buf2)) ERRLIN(11);
+				hennum = hensrc_tourk(t1buf2, 2);
+				common_hen = rangekettei(hennum, t1buf3);
+
+				while(atermscan(&soc2, t1buf2, 0)){
+					vchk(t1buf2);
+					if(-1 != serfun(t1buf2)) ERRLIN(11);
+					hennum = hensrc_tourk(t1buf2, 2);
+					rangeset(hennum, common_hen);
+				}
+			} else {
+				vchk(t1buf);
+				if(-1 != serfun(t1buf)) ERRLIN(11);
+				hennum = hensrc_tourk(t1buf, 2);
+			  /* defvar��defconst���ѿ�̾�ν�ʣ���򤱤뤿�� */
+				atermscan(socp, t1buf, 3);
+				rangekettei(hennum, t1buf);
+			}
+			atermscan(socp, dummy, 2);
+			break;
+		case 36: /* fn No.36 defconst */
+			atermscan(socp, t1buf, 3);
+			vchk(t1buf);
+			if(-1 != serfun(t1buf)) ERRLIN(11);
+
+			hennum = hensrc_tourk(t1buf, 6);
+			  /* defvar��defconst���ѿ�̾��ʣ���򤱤뤿�� */
+
+			rangeset(hennum, hen_iki);
+
+			blankpass(socp, 1);
+			if(*(*socp)++ != '\'') ERRLIN(8);
+			*hen_iki++ = onescan(socp, dummy);
+			(*socp)++; /*��'�פ��Ĥ��Ƥ��뤳�Ȥθ����ϺѤ�Ǥ���*/
+			*hen_iki++ = EOLTTR; /* needed? */
+			*hen_iki = EOLTTR;
+
+			atermscan(socp, dummy, 2);
+			break;
+
+		case 1: /* fn No.1 include */
+			{
+				char	fnmtmparea[REALFN], *s, *dirnamptr;
+				int	dummyc = 0, err;
+
+				blankpass(socp, 1);
+				if(3 != partscan(socp, t1buf)) ERRLIN(22);
+				atermscan(socp, dummy, 2);
+				 /* ;ʬ�ˤ����ERR */
+
+				ltr1cut(lptr = t1buf + 1);
+				*(s = fnmtmparea) = '\0';
+				err = readfnm(int_get1ltr, int_unget1ltr,
+					      getfrom_lptr, &s, &dummyc);
+
+				if(err){
+					hcurread = s;
+					switch(err){
+						case 1:
+						case 3: ERRLIN(25);
+						case 2: ERRLIN(26);
+						case 4: ERRLIN(27);
+					}
+				}
+				de_bcksla(fnmtmparea, fnmtmparea);
+
+				if(*++base == ENDOF_NestFileArea){
+					base--;
+					ERRLIN(23);
+				}
+				*base= trytoopen(fnmtmparea, &dirnamptr,&err);
+				if(err){
+					switch(err){
+						case 1:
+						case 3:
+						case 2:
+						case 4: base--;
+							ERRLIN(24);
+					}
+				}
+			}
+			break;
+
+		 /* �⡼��̾��Ĥ�����˼���� */
+		case 4: /* fn No.4��6 off,on,switch */
+		case 5:
+		case 6:
+		case 20: /* fn No.20,21 if,unless */
+		case 21:
+			*memptr++ = fnnum | IKANSU;
+			atermscan(socp, t1buf, 3);
+			*memptr++ = modsrcL(t1buf) | IMODNM;
+			atermscan(socp, t1buf, 2);
+			break;
+
+		 /* �⡼��̾��ʸ�� ��Ĥ��Ĥ�����˼���� */
+		case 37: /* fn No.37��43 setmode�ʤ� */
+		case 38:
+		case 39:
+		case 40:
+		case 41:
+		case 42:
+		case 43:
+			{
+				int	err, n;
+				modetyp	stat;
+
+				*memptr++ = fnnum | IKANSU;
+				atermscan(socp, t1buf, 3);
+				*memptr++ = (n = modsrcL(t1buf))| IMODNM;
+				atermscan(socp, t1buf, 3);
+				err = chkL_get_int(t1buf, &stat,
+							 modesw[n] . moderng);
+				if(err != 0) ERRLIN(29);
+				*memptr++ = stat;
+				atermscan(socp, t1buf, 2);
+				break;
+			}
+
+		 /* ���̡ʰ�������ʤ���Τ�ޤ�� */
+		default: /* toupper,tolower�� */
+			*memptr++ = fnnum | IKANSU;
+			*memptr = EOLTTR;
+			for(i = 0; i < func[fnnum] . argnum; i++){
+				blankpass(socp, 1);
+				if(eval1cpy(socp, m, 1) != 0) ERRLIN(13);
+			}
+			atermscan(socp, dummy, 2); /* ;ʬ�ˤ����ERR */
+			break;
+	}
+	*memptr = EOLTTR;
+	return(fnnum == -1 ? 0 : func[fnnum] . fntype);
+}
+
+ /** ʸ������Ρ�\�פ�ȴ�� */
+static void
+de_bcksla(s, r)
+char	*s, *r;
+{
+	for(; *s; *r++ = *s++) if(*s == '\\') s++;
+	*r = '\0';
+}
+
+ /**	defvar�����������shiki������ˤ��ᤷ�ơ������ѿ����Ѱ����ꤹ�롣
+	�ѿ���κǸ�˥���ɥޡ�������������롣���ͤϡ��Ѱ���Ǽ����
+	��ؤΥݥ��󥿡�*/
+letter	*rangekettei(num, shiki)
+letter	*shiki;
+int	num; /* �Ѱ����ꤷ�ĤĤ����ѿ��������ֹ� */
+{
+	letter	hyoukabuf[TRMSIZ];
+
+	rangeset(num, hen_iki);
+	*hen_iki = EOLTTR;
+
+	if(*shiki++ != '(') ERRLIN(8);
+	atermscan(&shiki, hyoukabuf, 1);
+
+	if(!ltrstrcmp(hyoukabuf, "all")){
+		*hen_iki++ = VARRNG;
+		*hen_iki++ = 0;
+		*hen_iki++ = LTRHUG; /* �Ѱ����ʸ�� */
+		*hen_iki++ = EOLTTR;
+		*hen_iki = EOLTTR;
+		atermscan(&shiki, dummy, 2); /* ;ʬ�ˤ����ERR */
+	} else 
+	if(!ltrstrcmp(hyoukabuf, "between")){
+		int	i;
+
+		*hen_iki++ = VARRNG;
+		while(blankpass(&shiki, 1), *shiki != ')'){
+			for(i = 1; i <= 2; i++){
+				switch(*shiki){
+					case '\'':
+						shiki++;
+						*hen_iki++ =
+						       onescan(&shiki, dummy);
+						shiki++;
+						break;
+					case ')':
+					case '"':
+					case '(': ERRLIN(8);
+					default:
+						*hen_iki++ = *shiki++;
+				}
+				if(i < 2){
+					if(!is_eolsp(*shiki)) ERRLIN(8);
+					blankpass(&shiki, 1);
+				}
+			}
+		}
+		*hen_iki++ = EOLTTR;
+		*hen_iki = EOLTTR;
+	} else
+	if(!ltrstrcmp(hyoukabuf, "list")){
+		while(blankpass(&shiki, 1), *shiki != ')'){
+			switch(*shiki){
+				case '"':
+				case '(': ERRLIN(8);
+				case '\'':
+					shiki++;
+					*hen_iki++ = onescan(&shiki, dummy);
+					shiki++; /* �����ˡ�'�פ��Ĥ��Ƥ��뤫
+					 �ɤ����θ����Ϥ⤦�Ѥ�Ǥ��롣*/
+					break;
+				default:
+					*hen_iki++ = *shiki++;
+			}
+			if(!is_eolsp(*shiki)) ERRLIN(8);
+		}
+		*hen_iki++ = EOLTTR;
+		*hen_iki = EOLTTR;
+	} else {
+		ERRLIN(8); /* ����Ϥ���¾�ι�ʸ�����ͽ��Ǥ��ä� */
+	}
+
+	return(henorg[num] . range);
+}
+
+ /**	num���ܤ��ѿ����Ѱ��ؤ��٤��ݥ��󥿤λؤ������ꤷ�������ѿ���
+	����Ͽ���֤ˤ��롣*/
+static void
+rangeset(num, range)
+letter	*range; /* �Ѱ��������Υݥ��� */
+int	num;
+{
+	henorg[num] . range = range;
+	henorg[num] . regdflg = 1;
+}
+
+ /**	name�ǻ��ꤵ�줿̾���ѿ���õ�����ʤ������Ͽ���ѿ�̾�κǸ��
+	����ɥޡ�������������롣
+	flg & 01����0�λ�������̾���ѿ������߹Ԥ�̤�Фʤ饨�顼��const�Ȥ���
+	����Ͽ�λ�������ˡ��ޤ� flg & 02����0�λ�������̾���ѿ���������ʤ�
+	���顼��defvar�ν�ʣ�����å��ѡˡ�flg & 04����0�ʤ�const�Ȥ�����Ͽ��*/
+static int
+hensrc_tourk(name, flg)
+letter	*name;
+int	flg;
+{
+	int	i;
+
+	for(i = 0; henorg[i] . name != NULL; i++){
+		if(ltrcmp(henorg[i] . name, name)) continue;
+		 /* found */
+		if(flg & 04) ERRLIN(28);
+		if(flg & 02 && henorg[i] . regdflg != 0) ERRLIN(10);
+		if(flg & 01 && henorg[i] . curlinflg == 0 &&
+				 henorg[i] . constflg == 0)
+			ERRLIN(5);
+		henorg[i] . curlinflg = 1;
+		return(i);
+	}
+	if(henorg + i != hentourkptr) BUGreport(5);
+
+	 /* �������褿�Ȥ������Ȥϡ���Ф��ѿ��Ȥ������ȡ�������flg & 01��
+	    ��0�ʤ饨�顼��*/
+	if(flg & 01) ERRLIN(5);
+	hentourkptr -> name = hensumei;
+	hentourkptr -> curlinflg = 1;
+	hentourkptr -> regdflg = 0; /* ��Ф�����range��def��̤����Ȧ */
+	hentourkptr -> constflg = ((flg & 04) != 0);
+	(++hentourkptr) -> name = NULL;
+	hensumei = ltrgrow(hensumei, name);
+	*++hensumei = EOLTTR;
+
+	return(i);
+}
+
+ /** �Ȥ߹��ߴؿ�����ǽ̾���Ф��ƤϤ����ֹ�򡢤����Ǥʤ���Τʤ�-1���֤� */
+static int
+serfun(lp)
+register letter *lp; /* �ؿ�����ǽ̾�⤷�����ѿ�̾ */
+{
+	register int	i;
+
+	for(i = 0; func[i] . fnname != NULL; i++){
+		if(! ltrstrcmp(lp, func[i] . fnname)) return(i);
+	}
+	return(-1);
+}
+
+ /** �ѿ���̾���Υ����å� ���������ȥ��顼 */
+static void
+vchk(lp)
+letter	*lp;
+{
+	if(is_digit(*lp)) ERRLIN(3);
+	for(; *lp != EOLTTR; lp++){
+	  /*	if(is_lower(*lp)) *lp = to_upper(*lp);	*/
+		if(!is_alnum(*lp) && *lp != '_') ERRLIN(3);
+	}
+}
+
+ /**	����ܤ���Ф������Ф������������1���֤���flg����0�λ��ϡ�')'��
+	���Ĥ���ȥ��顼��';'�Ϥ�������ǰ���ܰ�����*/
+static int
+termsscan(socp, dest, flg)
+register letter **socp, *dest;
+	 /* socp�λؤ��Ƥ���ݥ��󥿤��ؤ��Ƥ���꤫����Ф���dest������롣
+	    ���θ塢socp���ؤ��Ƥ���ݥ��󥿤�ʤ�롣���Υե������ **scan()
+	    �Ȥ����ؿ������Ƥ����ʤäƤ롣*/
+int	flg;
+{
+	letter	*bgn;
+
+	bgn = dest;
+
+	if(blankpass(socp, 0) == 0){
+		if(flg && **socp == ';'){
+			*dest++ = *(*socp)++;
+		} else
+		while(!is_eolsp(**socp)){
+			if(**socp == ')'){
+				if(flg) ERRLIN(0);
+				break;
+			} else {
+				partscan(socp, dest);
+				totail(dest);
+			}
+		}
+	}
+
+	*dest = EOLTTR;
+	return(bgn != dest);
+}
+
+ /**	�ꥹ�Ȱ�Ĥ���ñ���ΰ�ޤȤޤ����Ф�������������1���֤���
+	flg��1�ΤȤ���')'�����Ĥ���ȥ��顼��
+	flg��2�ΤȤ������Ф������������饨�顼��
+	flg��3�ΤȤ������Ф��˼��Ԥ����饨�顼��*/
+static int
+atermscan(socp, dest, flg)
+register letter **socp, *dest;
+int	flg;
+{
+	letter	*bgn;
+	int	found;
+
+	bgn = dest;
+
+	if(blankpass(socp, 0) == 0){
+		if(**socp == '('){
+			listscan(socp, dest);
+			totail(dest);
+		} else {
+			while(!is_eolsp(**socp) && **socp != '('){
+				if(**socp == ')'){
+					if(flg == 1) ERRLIN(0);
+					break;
+				} else {
+					partscan(socp, dest);
+					totail(dest);
+				}
+			}
+		}
+	}
+
+	*dest = EOLTTR;
+
+	found = (bgn != dest);
+	if((!found && flg == 3) || (found && flg == 2)) ERRLIN(7);
+	return(found);
+}
+
+ /**	���Ĥ���Ф������Ф�����Τ��ꥹ�Ȥʤ����ͤ�0��ñʸ���ʤ�1��
+	����ʸ���ʤ�2������ʸ����ʤ�3��*/
+static int
+partscan(socp, dest)
+register letter **socp, *dest;
+{
+	switch(**socp){
+		case '(':
+			listscan(socp, dest);
+			return(0);
+		case '\'':
+			singleqscan(socp, dest);
+			return(2);
+		case '"':
+			doubleqscan(socp, dest);
+			return(3);
+		default:
+			*dest++ = *(*socp)++;
+			*dest = EOLTTR;
+			return(1);
+	}
+}
+
+ /** ���󥰥륯������ɽ����Ĥ���Ф���*/
+static void
+singleqscan(socp, dest)
+letter	**socp, *dest;
+{
+	*dest++ = *(*socp)++;
+	onescan(socp, dest);
+	totail(dest);
+	if((*dest++ = *(*socp)++) != '\'') ERRLIN(1);
+
+	*dest = EOLTTR;
+}
+
+ /** ���֥륯������ɽ����Ĥ���Ф���*/
+static void
+doubleqscan(socp, dest)
+letter	**socp, *dest;
+{
+	*dest++ = *(*socp)++;
+	while(**socp != '"'){
+		if(**socp == EOLTTR) ERRLIN(1);
+		onescan(socp, dest);
+		totail(dest);
+	}
+	*dest++ = *(*socp)++;
+
+	*dest = EOLTTR;
+}
+
+ /**	8��10��16�ʥ������ѥ���饯����ºݤΥ����ɤ�ľ�������ϤΥ����å���
+	��������ʸ���ȿ����ʳ������Ϥ��Ф��Ƥ�ñ��0���֤���*/
+int
+ltov(l)
+letter	l;
+{
+	if(is_upper(l)) return(l - 'A' + 10);
+	if(is_lower(l)) return(l - 'a' + 10);
+	if(is_digit(l)) return(l - '0'); else return(0);
+}
+
+ /** ltov�ε� */
+letter	vtol(l)
+letter	l;
+{
+	if(BASEMX <= l) return('*');
+	return(l + (l < 10 ? '0' : 'A' - 10));
+}
+
+ /**	���󥰥롦���֥륯�����Ȥ���Ǥΰ�ʸ�����Ф���
+	��^�פˤ�륳��ȥ����륳����ɽ������\�פˤ��8��10��16��ɽ���ˤ�
+	�б�����\��ɽ���ϡ���\��o����d����x�Ͽ������¤ӡ�;�ϡפǤ��롣*/
+letter	onescan(socp, dest)
+letter	**socp, *dest;
+{
+	letter	l, realcode;
+	int	digflg;
+
+	switch(realcode = *dest++ = *(*socp)++){
+		case '^':
+			if(!(' ' <= (l = *(*socp)++) && l < '\177'))ERRLIN(2);
+			realcode = ((*dest++ = l) == '?' ? '\177' : l & 0x1f);
+			break;
+		case '\\':
+			digflg = 0;
+			switch(**socp){
+				case 'n':
+					*dest++ = *(*socp)++; realcode = '\n';
+					break;
+				case 't':
+					*dest++ = *(*socp)++; realcode = '\t';
+					break;
+				case 'b':
+					*dest++ = *(*socp)++; realcode = '\b';
+					break;
+				case 'r':
+					*dest++ = *(*socp)++; realcode = '\r';
+					break;
+				case 'f':
+					*dest++ = *(*socp)++; realcode = '\f';
+					break;
+				case 'e':
+				case 'E':
+					*dest++ = *(*socp)++; realcode=ESCCHR;
+					break;
+				case 'o':
+					*dest++ = *(*socp)++;
+					for(realcode = 0; is_octal(**socp);){
+						digflg = 1;
+						realcode <<= 3;
+						realcode += ltov
+						       (*dest++ = *(*socp)++);
+					}
+					if(!digflg) ERRLIN(2);
+					if(**socp== ';') *dest++ = *(*socp)++;
+					break;
+				case 'x':
+					*dest++ = *(*socp)++;
+					for(realcode = 0; is_xdigit(**socp);){
+						digflg = 1;
+						realcode <<= 4;
+						realcode += ltov
+						       (*dest++ = *(*socp)++);
+					}
+					if(!digflg) ERRLIN(2);
+					if(**socp== ';') *dest++ = *(*socp)++;
+					break;
+				case 'd':
+					*dest++ = *(*socp)++;
+					for(realcode = 0; is_digit(**socp);){
+						digflg = 1;
+						realcode *= 10;
+						realcode += ltov
+						       (*dest++ = *(*socp)++);
+					}
+					if(!digflg) ERRLIN(2);
+					if(**socp== ';') *dest++ = *(*socp)++;
+					break;
+				default:
+					if(is_octal(**socp)){
+						for(realcode = 0;
+						    is_octal(**socp);){
+							realcode <<= 3;
+							realcode += ltov(
+							*dest++ = *(*socp)++);
+						}
+						if(**socp == ';')
+							*dest++ = *(*socp)++;
+					} else {
+						realcode= *dest++= *(*socp)++;
+					}
+			}
+			break;
+		default: ;
+	}
+
+	*dest = EOLTTR;
+	return(realcode);
+}
+	
+ /**	letter�������Ƭ�ˤ������򥹥��åפ��롣
+	������ã�����顢flg��0�ΤȤ���1���֤��������Ǥʤ��ȥ��顼��*/
+static int
+blankpass(pptr, flg)
+register letter **pptr;
+	 /* letter����Υݥ��󥿤ؤΥݥ��󥿡����줬�ؤ��Ƥ����Τ�ʤ�� */
+int	flg;
+{
+	while(is_eolsp(**pptr)){
+		if(EOLTTR == **pptr){
+			if(flg) ERRLIN(4);
+			return(1);
+		}
+		(*pptr)++;
+	}
+	return(0);
+}
+
+ /** �ꥹ�Ȱ�ļ��Ф� */
+static void
+listscan(socp, dest)
+register letter **socp, *dest;
+{
+	int	eofreach;
+
+	*dest++ = *(*socp)++; /* = '(' */
+	*dest++ = ' ';
+	
+	while(eofreach = blankpass(socp, 0), **socp != ')'){
+		if(eofreach){
+			if(! readln((uns_chr *)hcurread)) ERRLIN(20);
+			ustrtoltr((uns_chr *)hcurread, (*socp= ltrbufbgn), 1);
+			 /* list����ǹԤ��ڤ�Ƥ����硢����ɲ��ɤ߹��ߤ�
+			    ���롣uns_chr�ѤΥХåե��⡢letter�ѤΤ�Τ⡢
+			    ������ʪ����Ƭ��������Ѥ��Ƥ���Τ����ա��ޤ���
+			    ���顼����������硢 ���顼�ΰ��֤ˤ�����餺��
+			    ���߹ԤȤ���ɽ�������Τϡ��Ǹ���ɤޤ줿�ԤΤ�*/
+		} else {
+			termsscan(socp, dest, 0);
+			totail(dest);
+			*dest++ = ' ';
+		}
+	}
+	*dest++ = *(*socp)++; /* = ')' */
+	*dest = EOLTTR;
+}
+
+ /** lp�ǻ��ꤵ�줿�⡼��̾��õ�������Ĥ���ʤ��ȥ��顼 */
+static int
+modsrcL(lp)
+letter	*lp;
+{
+	int	n;
+
+	for(n = 0; modmeibgn[n] != NULL; n++)
+		if(!ltrstrcmp(lp, modmeibgn[n])) return(n);
+
+	ERRLIN(16);
+	 /*NOTREACHED*/
+	return(-1);
+}
+
+ /** chk_get_int��rk_modread.c�ˤ�letter�� */
+static int
+chkL_get_int(lp, ip, range)
+letter	*lp;
+modetyp	*ip;
+modetyp range;
+{
+	int	sgn = 1;
+	modetyp	out;
+
+	if(*lp == '-'){
+		lp++;
+		sgn = -1;
+	}
+	for(out = 0; *lp != EOLTTR; lp++){
+		if(!is_digit(*lp)) return(-1);
+#if defined(UX386) || defined(sun386)
+		out = out * 10;
+#else
+		out *= 10;
+#endif
+		out += ltov(*lp);
+	}
+	if(range != 0) out %= range;
+	if(sgn == -1 && out != 0) out = range - out;
+	*ip = out;
+	return(0);
+}
+
+ /**	������ϡ�ɽ�ɤ߹��ߤǥ���ä����˷ٹ𤹤�롼����n�ϥ��顼�����ɡ�
+	�ޤ����������ơ�romkan_init�Υ��顼�����ɤȤ��ơ�longjmp��ͳ��
+	1���֤���*/
+
+void
+ERMOPN(n) /* �⡼�����ɽ�������ץ�Ǥ��ʤ� */
+unsigned int	n;
+{
+	static	char	*ermes[] = {
+ /*  0 */	"Can't open Mode-hyo",
+		"Unprintable error"
+	};
+
+	if(n >= numberof(ermes)) n = 1;
+
+	fprintf(stderr, "\r\nMode-hyo %s ---\r\n", curfnm);
+	fprintf(stderr, "%d: %s.\r\n", n, ermes[n]);
+	longjmp(env0, 1);
+}
+
+static void
+ERHOPN(n) /* �Ѵ��б�ɽ�������ץ�Ǥ��ʤ� */
+unsigned int	n;
+{
+	static	char	*ermes[] = {
+ /*  0 */	"Can't open Taio-hyo",
+		"Is a directory",
+		"Unprintable error"
+	};
+
+	if(n >= numberof(ermes)) n = 2;
+
+	fprintf(stderr, "\r\nTaio-hyo %s%s ---\r\n", curdir, curfnm);
+	fprintf(stderr, "%d: %s.\r\n", n, ermes[n]);
+	longjmp(env0, 1);
+}
+
+void
+ERRMOD(n) /* �⡼�����ɽ�Υ��顼 */
+unsigned int	n;
+{
+	static	char	*ermes[] = {
+ /*  0 */	"Table incomplete",
+		"')' mismatch",
+		"Unprintable error",
+		"Illegal filename",
+		"Illegal modename",
+ /*  5 */	"Undefined mode",
+		"Illegal content(s) of list",
+		"Illegal ^,\\o,\\x or \\d expression",
+		"Illegal defmode",
+		"Unrecognized keyword",
+ /* 10 */	"Incomplete string",
+		"Search path specified after filename",
+		"Argument must be a string",
+		"Can't get home directory",
+		"Illegal @-keyword",
+ /* 15 */	"User doesn't exist",
+		"Illegal character",
+		"Defmode or set-path placed wrong"
+	};
+
+	if(n >= numberof(ermes)) n = 2;
+
+	fprintf(stderr, "\r\nMode-hyo %s%s ---\r\n%s\r\n",
+		curdir, curfnm, mcurread);
+	fprintf(stderr, "%d: %s.\r\n", n, ermes[n]);
+	fclose(modefile);
+	longjmp(env0, 1);
+}
+
+static void
+ERRLIN(n) /* �Ѵ��б�ɽ�Υ��顼 */
+unsigned int	n;
+{
+	static	char	*ermes[] = {
+ /*  0 */	"')' mismatch",
+		"Incomplete single-quote or double-quote expression",
+		"Illegal ^,\\o,\\x or \\d expression",
+		"Illegal variable name",
+		"Incomplete line",
+ /*  5 */	"Evaluation of unbound variable",
+		"Unprintable error",
+		"Too many or too few contents of list",
+		"Illegal defvar/defconst",
+		"Faculity or declaration joined other item(s)",
+ /* 10 */	"Duplicate defvar/defconst",
+		"Variable/constant name conflicts with Function name",
+		"A line contains both declaration and other output item(s)",
+		"Argument isn't a letter",
+		"Function, faculity or declaration in illegal place",
+ /* 15 */	"More than 3 items",
+		"Undefined mode",
+		"Against the restriction of pre-transform table",
+		"Against the restriction of after-transform table",
+		"Item comes after faculity",
+ /* 20 */	"Incomplete list",
+		"Illegal character",
+		"Illegal include",
+		"Too many levels of 'include' nest",
+		"Can't open include file",
+ /* 25 */	"Can't get home directory",
+		"Illegal @-keyword",
+		"User doesn't exist",
+		"Constant must be defined before used",
+		"Illegal mode status"
+	};
+
+	if(n >= numberof(ermes)) n = 6;
+
+	fprintf(stderr, "\r\nTaio-hyo %s%s ---\r\n%s\r\n",
+		curdir, curfnm, hcurread);
+	fprintf(stderr, "%d: %s.\r\n", n, ermes[n]);
+
+	while(NULL != *base) fclose(*base--);
+
+	longjmp(env0, 1);
+}
+
+static void
+ERRHYO(n) /* ERRLIN��Ʊ�͡��б�ɽ�Υ��顼��������Ԥ����θ���Ǥʤ�
+ ���Τ򸫤ʤ��Ȥ狼��ʤ����ꡣ���νꡢ��̤����ѿ��νи��פΤߡ�*/
+unsigned int	n;
+{
+	static	char	*ermes[] = {
+ /*  0 */	"Undefined variable was found",
+		"Unprintable error"
+	};
+
+	if(n >= numberof(ermes)) n = 1;
+
+	fprintf(stderr, "\r\nTaio-hyo %s%s ---\r\n", curdir, curfnm);
+	fprintf(stderr, "%d: %s.\r\n", n, ermes[n]);
+
+	while(NULL != *base) fclose(*base--);
+
+	longjmp(env0, 1);
+}
diff --git a/wnn/rk_spclval.h b/wnn/rk_spclval.h
new file mode 100644
index 0000000000000000000000000000000000000000..663aabcc9c92809d82c552b413df52369a6da3ba
--- /dev/null
+++ b/wnn/rk_spclval.h
@@ -0,0 +1,188 @@
+/*
+ * $Id: rk_spclval.h,v 1.1 1996/03/13 09:57:18 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_spclval.h
+						88. 6. 9  �� ��
+
+	���Ѵ��ǻȤäƤ����ü���ͤ�����ʳ����ˤ�Ф��ˡ��ޥ���
+	�ؿ��⡢ctype.h��Ȥ���ΰʳ��Ϥ�������������Ƥ��롣
+	rk_macros.h ��include����Ƥ��롣
+***********************************************************************/
+/*	Version 3.0
+ */
+#ifndef EOLTTR
+
+typedef unsigned int	letter; /* ʸ���ϰ��̤ˤ��η���ɽ�� */
+typedef unsigned char	uns_chr;
+
+typedef unsigned char	modetyp;
+#define	ModeNotInt /* ���modetyp��unsigned int��꾮��������typedef�����
+			�����餳���define���Ʋ�������*/
+/* #define ModeHasBuf */
+
+#define LTRHUG	(~(0xff000000))
+	/* ����ɽ�� �ڤӵ�ʸ���������letter�μ����������� */
+
+
+	/* �ʲ�����������ͤϡ��Ǿ�̥Х��Ȥ�255�Ǥʤ���Фʤ�ʤ���
+	   �����Τ��������˽Ф�Τ� EOLTTR��CHMSIG��NISEBP��LTREOF��REDRAW��
+	   SENDCH�ʵ��ǥ꡼�ȤȤ���NISEDL��Ȥ�����NISEDL��ˡ�*/
+
+#define EOLTTR	((letter)-1) /* ʸ����ν�ü��ɽ�������� */
+			/* �������Ϥ����ä���ɬ�����������ɤ��֤����֤ˤ���
+			   �����ȡ��ä��֤��٤���Τ��ʤ����Ϥ�����֤���*/
+#define ERRCOD	((letter)-2) /* (error)��ɽ������������ */
+#define CHMSIG	((letter)-3) /* �⡼�ɥ����󥸤�ɽ�������� */
+#define NISEBP	((letter)-4) /* ���顼�ٹ��Ѥε�BEL������ */
+#define VARRNG	((letter)-5) /* �Ѱ褬��Ĥ�ʸ���δ֤Ǥ���Τ򼨤�����������*/
+#define UNUSDC	((letter)-6) /* �ޥå����Ԥ����뤿������������� */
+#define REASIG	((letter)-7) /* ɽ�κ�������׵᤹�뤿������������� */
+#define URBFCL	((letter)-8) /* ΢�Хåե�������Ū���ꥢ���׵᤹������������*/
+#define LTREOF	((letter)-9) /* romkan_next()��Ʊgetc()��EOF��������֤����
+				�ʤǤ����EOF��Ʊ���ˤ��������ġ�*/
+#define REDRAW	((letter)-10)/* Wnn���Ѵ��Ԥ�redraw���׵᤹���ü쥳���� */
+#define NISEDL	((letter)-11)/* ���ǥ꡼�ȤȤ��������Ȥ������ͤΤ���˽���
+				���줿�����â�����Ȥ������ʤ���лȤ�ʤ��Ƥ�
+				�����ˡ��ѿ�nisedl�˥��åȤ��ƻȤ� */
+#define SENDCH	((letter)-12)/* �Ѵ��Хåե������ʤ顢����ʸ����̵����
+				�������褦Wnn���׵᤹�륨�������ץ����ɡ�*/
+
+
+	/* romkan_init3()�ΰ����Υե饰�˻Ȥ��� */
+
+#define RK_CHMOUT 0x1	/* �⡼�ɥ����󥸤��Τ餻�륳���ɤ��֤����� */
+#define RK_KEYACK 0x2	/* ����������Ф�ɬ���������֤��� */
+#define RK_DSPNIL 0x4	/* �⡼��ɽ��ʸ����̵����λ��˶�ʸ������֤����ʥǥ�
+			   ����Ȥ�NULL�ˡ��ߴ����ݻ��Τ��� */
+#define RK_NONISE 0x8	/* �������ɤ�Ф��ʤ��褦�ˤ��뤫 */
+#define RK_REDRAW 0x10	/* Wnn���ü�ե饰��redraw�ѤΥե饰��Ф����ɤ�����*/
+#define RK_SIMPLD 0x20	/* delete��ư���ñ��ˤ��뤫 */
+#define RK_VERBOS 0x40	/* ���Ѥ���ɽ�ΰ������ݡ��Ȥ��뤫 */
+
+
+	/* �����ɤζ��̤˻Ȥ��ޥ��� */
+
+#define HG1BIT	(0x80000000) /* �Ǿ�̥ӥåȤ��� */
+#define SHUBET(X) ((letter)(X) >> (int)24)
+			      /* ����ɽ���ǡ��壱�Х��Ȥ����ɽ���˻ȤäƤ� */
+#define LWRMSK(X) ((X) & ~(0xff000000)) /* �壱�Х��Ȥ������ */
+#define LWRCUT(X) ((X) &= ~(0xff000000)) /* �壱�Х��Ȥ������ */
+#define XY2INT(X, Y) (((X) << (int)24) | (Y)) /* ���줬���󤷤�Y��ɾ�����ʤ����Ȥ�
+	��¸���ƽ񤤤Ƥ���ս꤬����  ���ա� */
+
+#define is_HON(X) (SHUBET(X) == 0) /* ��ʪ��ʸ���� */
+#define NAIBEX(X) (0 < SHUBET(X) && SHUBET(X) < 0x80) /* ����ɽ���򼨤��ͤ� */
+#define isNISE(X) (SHUBET(X) == 0x80) /* ��ʪ��ʸ�����ʺǾ�̥ӥåȤ�Ω�ġ� */
+#define isSPCL(X) (SHUBET(X) == 0xff) /* rk_spclval.h�����������ͤ��ɤ���*/
+ /* NISEDL�ʤɤ�ޤ᤿����ʸ���Ǥ��뤫�ɤ�����Ƚ�ꤹ��ˤϡ�~is_HON(X) ����
+    isNISE(X) || isSPCL(X) �Ȥ���Ƚ�ꤷ�ʤ��Ȥ����ʤ���*/
+
+#define toNISE(X) ((X) | HG1BIT)
+#define to_HON(X) ((X) & ~HG1BIT)
+
+ /* �ߴ����Τ����Ѱդ��Ƥ�����̾ */
+#define REALCD(X) is_HON(X)
+#define NISECD(X) isNISE(X)
+#define SPCLCD(X) isSPCL(X)
+
+
+	 /** Ⱦ��ʸ���Υ����ɤ�define */
+
+#ifndef HNKAK1
+#  ifdef IKIS
+#    define HNKAK1 0xA8
+#  else
+#    define HNKAK1 0x8E
+#  endif
+#endif
+
+	/** rk_bltinfn.c ���䴰�Τ���Υޥ���
+	    �ʰ�����ʣ����ɾ�������Τ�¿���Τ����ա�*/
+
+#define HKKBGN	(HNKAK1 * 0x100 + 0xA1) /* Ⱦ�ѥ��ʤζ��� */
+#define HKKEND	(HNKAK1 * 0x100 + 0xDF) /*     ��    Ⱦ���� */
+#define HIRBGN	(0xA4A1) /* �� */
+#define HIREND	(0xA4F3) /* �� */  /* �Ҥ餬�ʡ�"��"��"��" */
+#define KATBGN	(0xA5A1) /* �� */
+#define KATEND	(0xA5F6) /* �� */  /* �������ʡ�"��"��"��"��"��" */
+
+#define _to_kata(l) ((l) + (KATBGN - HIRBGN)) /** �������ʤء���������¡�*/
+#define _to_hira(l) ((l) - (KATBGN - HIRBGN)) /** �Ҥ餬�ʤء���������¡�*/
+#define is_hira(l) (HIRBGN <= (l) && (l) <= HIREND) /** �Ҥ餬�ʤ��� */
+#define is_kata(l) (KATBGN <= (l) && (l) <= KATEND) /** �������ʤ��� */
+#define is_kata2(l) (_to_kata(HIRBGN) <= (l) && (l) <= _to_kata(HIREND))
+				/** �б�����Ҥ餬�ʤΤ��륫�����ʤ��� */
+#define to_kata(l) (is_hira(l) ? _to_kata(l) : (l)) /** �������ʤ� */
+#define to_hira(l) (is_kata2(l) ? _to_hira(l) : (l))
+			/** �Ҥ餬�ʤء��֥������פϥ������ʤΤޤ޻Ĥ롣*/
+#define is_hankata(l) (HKKBGN <= (l) && (l) <= HKKEND)
+				/** Ⱦ�ѥ��ʡʶ����ʤɤ�ޤ�ˤ��� */
+
+
+
+	/* ����¾�Υޥ����ؿ����ʰ�����ʣ����ɾ�������Τ�¿���Τ����ա�*/
+
+#define numberof(array) (sizeof(array) / sizeof(*array))
+
+ /* �ݥ��󥿤�letter����������ؤ�äƤ�����letter *lp */
+#define totail(lp) {while(*(lp) != EOLTTR) (lp)++;}
+
+ /* ʸ����ؤΥݥ��󥿤򤽤�ʸ����κǸ����ء�totail��char�ǡ�char *sp */
+#define strtail(sp) {while(*(sp)) (sp)++;}
+
+	/* ������romkan_init3 */
+#define romkan_init4(pathname, delchr, nisedl, keyin, bytecount, flg) \
+	romkan_init3(pathname, delchr, nisedl, EOLTTR, \
+		     keyin, bytecount, bytecount, 0, flg)
+
+#define romkan_init5(pathname, delchr, keyin, bytecount, flg) \
+	romkan_init4(pathname, delchr, toNISE(delchr), keyin, bytecount, flg)
+
+
+#endif	/* of ifndef EOLTTR */
diff --git a/wnn/rk_vars.c b/wnn/rk_vars.c
new file mode 100644
index 0000000000000000000000000000000000000000..014a46cd47b5e0f25c00b3d2e0b5142b8f90a38b
--- /dev/null
+++ b/wnn/rk_vars.c
@@ -0,0 +1,198 @@
+/*
+ * $Id: rk_vars.c,v 1.1 1996/03/13 09:57:20 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/***********************************************************************
+			rk_vars.c
+						88. 6.16  �� ��
+
+	�ץ�����������İʾ�Υե�����ˤޤ����äƻȤ��ѿ���
+	�ޤȤ��������Ƥ��롣
+***********************************************************************/
+/*	Version 3.0
+ */
+#include "rk_header.h"
+#include "rk_extvars.h"
+
+char	rk_errstat = 0; /* (error)�ˤ�äƥ��顼�������������줿��1��â��
+			   (eofflg)��Ω�äƤ������������ޤǤζ������Ͻ�����
+			   �����ä�����2�ˤˤʤ롣romkan_henkan()�¹Ԥ��Ȥ�
+			   ��������롣����ϥ桼���ˤⳫ����*/
+
+int	flags = 0;
+ /* �ʲ��Υե饰��OR��
+	RK_CHMOUT �⡼�ɥ����󥸤��Τ餻�뤫�Υե饰 
+	RK_KEYACK ����������Ф�ɬ�������֤����Υե饰 
+	RK_DSPNIL romkan_disp(off)mode�����ͤΥǥե���Ȥ���ʸ����Ǥ��뤫��
+		  �ե饰��Ω���ʤ���Хǥե���Ȥ�NULL���ߴ����Τ���romkan_
+		  init2�ޤǤϤ��줬Ω�ġ�
+	RK_NONISE �������ɤ�Ф��ʤ��褦�ˤ��뤫�Υե饰
+	RK_REDRAW Wnn�ǻȤ��ü�ʥե饰�����줬Ω�äƤ����硢romkan_henkan
+		  �η�̤Ȥ���disout��nisedl�ʵ�ʪ��del�˰ʸ夬�ü쥳���ɤΤ�
+		  �ǽ����ʸ�����֤äƤ����顢���θ����REDRAW��Ĥʤ���Wnn
+		  ���Ѵ��Ԥ�redraw�򤹤뤿���ɬ�פ����֡�
+	RK_SIMPLD delete��ư���ñ��ˤ��뤫�Υե饰
+	RK_VERBOS verbose�ǵ��������Υե饰
+ */
+
+jmp_buf env0;
+
+FILE	*modefile; /* �⡼�����ɽ�Υե����� */
+char	nulstr[1] = {'\0'};
+
+char	*hcurread, *mcurread; /* �Ѵ�ɽ���⡼��ɽ�θ��߹�buf�ؤΥݥ��� */
+char	*curfnm, *curdir; /* �����ɤ�Ǥ��Ѵ�ɽ���⡼��ɽ��̾�ȥǥ��쥯�ȥꡣ
+     â��curdir�ϡ��������ѥ����ܤ��Ƥ���ɽ�Υ����ץ�������������Τ�ͭ�� */
+letter	*ltrbufbgn; /* �������letter�ΥХåե�����Ƭ��ؤ� */
+  /* �����ޤĤϡ�readdata()�ʤɤδؿ���ǥ����������������������Ƭ���
+     �������äơ����δؿ���ȴ������Ǥ������ͤ�Ȥ�ʤ��褦��ʬ���ա��äˡ�
+     ���顼�ٹ�롼����ʤɤǤϡ�longjmp����������ˤ�����print��Ԥ�����
+     �ʥ��顼�����Ѥ˻ȤäƤ���Τϡ��夫��͸Ĥޤǡˡ�*/
+FILE	*nestfile[FILNST], **base; /* �Ѵ��б�ɽ�Υե����� */
+
+struct	modestat modesw[MODMAX];
+
+char	hyoshu[HYOMAX]; /* ɽ�μ��̡������ܡ������ɽ�ζ��̡ˤ���������� */
+char	**modmeiptr, *modmeibgn[MODMAX]; /* �⡼��̾���Ф�����Ʊ�ͤΥǡ���*/
+char	*modmeimem, modmeimem_[MODMEI]; /*		��		*/
+char	**dspnamptr, *dspnambgn[DMDMAX];
+				/* �⡼��ɽ��ʸ������Ф���Ʊ�ͤΥǡ��� */
+char	*dspcod, dspcod_[DMDCHR]; /*		��		*/
+char	*dspmod[2][2] = {NULL, NULL, NULL, NULL};
+	 /* ���ߵڤӰ�����Ρ�romkan�򤽤줾��on��off���Ƥ�����Υ⡼��ɽ��
+	    ʸ����ؤΥݥ��󥿡�romkan_dispmode()���֤��ͤ�dspmod[0][0]��*/
+
+char	**hyomeiorg, **hyomeiptr;
+	 /* ɽ��̾�ؤΥݥ��󥿤���������� *hyomeibgn[HYOMAX] �� readdata() ��
+	    �Ȥ�����������Ƭ�ڤ���������ǤؤΥݥ��� */
+char	*hyomeimem;
+	 /* ɽ��̾�μºݤ�ʸ�������������� hyomeimem_[HYOMEI] �� readdata()
+	    �ǻȤ�����������������ǤؤΥݥ��� */
+char	**pathmeiorg, **pathmeiptr;
+	 /* �б�ɽ�Υ������ѥ�̾�ؤΥݥ��󥿤���������� *pathmeibgn[PTHMAX]��
+	    readdata() �ǻȤ�����������Ƭ�ڤ���������ǤؤΥݥ��� */
+char	*pathareaorg, *pathmeimem;
+	 /* �嵭�������ѥ�̾�μºݤ�ʸ�������������� pathmeimem_[PTHMEI] ��
+	    readdata() �ǻȤ�����������Ƭ�ڤ���������ǤؤΥݥ��󥿡�
+	    â��pathmeimem_����Ƭ�ˤϥ⡼��ɽ�Τ���ǥ��쥯�ȥ��̾�����ꡢ��
+	    �ǻȤ��Τǡ�pathareaorg�ˤϤ���³���Υ��ꥢ����Ƭ�����Ϥ����롣*/
+
+int	usemaehyo[HYOMAX], usehyo[HYOMAX], useatohyo[HYOMAX];
+	 /* �����ܡ������ɽ�Τɤ줬���򤵤�Ƥ��뤫�Υǡ��� */
+int	naibu_[NAIBMX], *naibu; /* �⡼��ɽ������ɽ������������� */
+
+letter	*lptr; /* letter�ؤ����ѥݥ��� */
+
+letter	rk_input; /* ���ϡ�3�Х��ȤޤǤ��ѹ��ʤ����б��� */
+letter	disout[OUTSIZ]; /* �ܽ�������ν��ϤΥХåե� */
+letter	rk_output[OUTSIZ]; /* ���������ν��ϡʺǽ����ϡˤΥХåե� */
+letter	keybuf[KBFSIZ], urabuf[KBFSIZ]; /* �ܽ����Хåե��Ȥ��������ΰ� */
+int	lastoutlen, lastkbflen;
+letter	oneletter[2] = {EOLTTR, EOLTTR}, nil[1] = {EOLTTR};
+int	hyonum;
+
+#define bit3(x, y, z) ((x) | ((y) << 1) | ((z) << 2))
+
+struct	funstr	func[] = /* �ؿ����ɲäˤϤ����� mchevl(), evlis() �򤤤��� */
+{
+/*			�����ο���-1�Ĥ�����̤���ѡ�
+	  ̾		    �и�     ��	 �����ס�0:ʸ���ؿ� 1:ʸ����ؿ�
+	  ��		     ��	     ��	 ��	 2:�ü�ؿ� 3:��ǽ 4:��� */
+	"defvar",	bit3(1,0,0), -1, 4, /*	0 */
+	"include",	bit3(1,0,0), -1, 4,
+	"toupper",	bit3(1,1,1),  1, 0,
+	"tolower",	bit3(1,1,1),  1, 0,
+	"off",		bit3(0,1,0), -1, 2,
+	"on",		bit3(0,1,0), -1, 2, /*	5 */
+	"switch",	bit3(0,1,0), -1, 2,
+	"toupdown",	bit3(1,1,1),  1, 0,
+	"tozenalpha",	bit3(1,1,1),  1, 0,
+	"tohira",	bit3(1,1,1),  1, 0,
+	"tokata",	bit3(1,1,1),  1, 0, /* 10 */
+	"tohankata",	bit3(1,1,1),  1, 1,
+	"tozenhira",	bit3(1,1,1),  1, 0,
+	"tozenkata",	bit3(1,1,1),  1, 0,
+	"+",		bit3(1,1,1),  2, 0,
+	"-",		bit3(1,1,1),  2, 0, /* 15 */
+	"*",		bit3(1,1,1),  2, 0,
+	"/",		bit3(1,1,1),  2, 0,
+	"%",		bit3(1,1,1),  2, 0,
+	"last=",	bit3(1,0,0),  1, 2,  /* ľ���Υޥå�������==������? */
+	"if",		bit3(1,0,0), -1, 2, /* 20 */
+	"unless",	bit3(1,0,0), -1, 2,
+	"restart",	bit3(0,1,0),  0, 3,
+	"delchr",	bit3(1,1,1),  0, 0,  /* delchr���֤����������ޥ�� */
+	"alloff",	bit3(0,1,0),  0, 2,  /* ���⡼�ɤ򤤤äڤ��OFF */
+	"allon",	bit3(0,1,0),  0, 2, /* 25 */
+	"bitand",	bit3(1,1,1),  2, 0,
+	"bitor",	bit3(1,1,1),  2, 0,
+	"bitnot",	bit3(1,1,1),  1, 0,
+	"!",		bit3(0,1,0),  0, 2,  /* ΢�Хåե�������Ū���ꥢ */
+	"atEOF",	bit3(1,0,0),  0, 2, /* 30 */
+	"todigit",	bit3(1,1,1),  2, 1,
+	"dakuadd",	bit3(1,1,1),  1, 1,  /* �������ղ� */
+	"handakuadd",	bit3(1,1,1),  1, 1,  /* Ⱦ�������ղ� */
+	"value",	bit3(1,1,1),  1, 0,
+	"error",	bit3(0,1,0),  0, 3, /* 35 */
+	"defconst",	bit3(1,0,0), -1, 4,
+	"setmode",	bit3(0,1,0), -1, 2,
+	"mode+",	bit3(0,1,0), -1, 2,
+	"mode-",	bit3(0,1,0), -1, 2,
+	"mode=",	bit3(1,0,0), -1, 2, /* 40 */
+	"mode!=",	bit3(1,0,0), -1, 2,
+	"mode<",	bit3(1,0,0), -1, 2,
+	"mode>",	bit3(1,0,0), -1, 2,
+	"send",		bit3(0,1,0),  1, 1,  /* ��� */
+	NULL
+};
+	/* last=��unless�� ���ϥ����ɤΰ��֤ˤ����֤�����ʸ����ؿ������ʤΤ�
+			�ܽ���ɽ�ˤ����񤱤ʤ���*/
+	/* +,-,*,/,bitand,bitor,bitnot�� 3�Х���ʬ�α黻��Ԥ���*/
+	/* atEOF�� �ե����������Ǥ�����ư�����ꤹ�뤿��Τ�Ρ�â��������
+		ư����Դ�����*/
+
+struct	hyo	hyo_n[HYOMAX]; /* ɽ���Ȥ��Ѱ衦�б��ǡ����γ������� */
diff --git a/wnn/strings.c b/wnn/strings.c
new file mode 100644
index 0000000000000000000000000000000000000000..1e6fc83e8067afed152e2d9ff803bef0c977164b
--- /dev/null
+++ b/wnn/strings.c
@@ -0,0 +1,376 @@
+/*
+ * $Id: strings.c,v 1.1 1996/03/13 09:57:22 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/*
+	long strings library. Copyed from GMW programs!!
+*/
+#include <stdio.h>
+#include "commonhd.h"
+#include "wnn_string.h"
+
+#define NULL	0
+
+#define is_half_width(c)	(! is_full_width(c))
+#define is_full_width(c)	(((c) & 0xff00))
+#define is_gaiji(c)		(is_full_width(c) && ! ((c) & 0x8080))
+#define is_jis_kanji(c)		(((c) & 0x8080) == 0x8080)
+
+w_char *wnn_Strcat(s1,s2)
+register w_char *s1;
+register w_char *s2;
+{
+	register w_char *d;
+
+	for (d = s1;*d++ != 0;);
+	for (--d;(*d++ = *s2++) != 0;);
+	return s1;
+}
+
+w_char *wnn_Strncat(s1,s2,n)
+register w_char *s1;
+register w_char *s2;
+register int n;
+{
+	register w_char *d;
+
+	for (d = s1;*d++ != 0;);
+	for (--d;n > 0 && (*d++ = *s2++) != 0;n--);
+	if (n <= 0) {
+		*d = 0;
+		return d;
+	} else {
+		return --d;
+	}
+}
+
+int wnn_Strcmp(s1,s2)
+register w_char *s1;
+register w_char *s2;
+{
+  for (;*s1 != 0 && *s1 == *s2;s1++, s2++);
+  if(*s1 > *s2) return 1;
+  if(*s1 == *s2) return 0;
+  return(-1);
+/*  return (int)(*s1 - *s2);  Since w_char, it is always positive */
+}
+
+/* s1 is substr of s2?  then return 1*/
+int wnn_Substr(s1, s2)
+register w_char *s1;
+register w_char *s2;
+{
+  for (;*s1 != 0 && *s1 == *s2;s1++, s2++);
+  return (int)(!*s1);
+}
+
+
+
+int wnn_Strncmp(s1,s2,n)
+register w_char *s1;
+register w_char *s2;
+register int n;
+{
+  if(n == 0)return(0);
+  for (;n > 0 && *s1++ == *s2++;n--);
+  return (int)(*--s1 - *--s2);
+}
+
+w_char *wnn_Strcpy(s1,s2)
+register w_char *s1;
+register w_char *s2;
+{
+	register w_char *d;
+
+	for (d = s1;(*d++ = *s2++) != 0;);
+	return s1;
+}
+
+w_char *wnn_Strncpy(s1,s2,n)
+register w_char *s1;
+register w_char *s2;
+register int n;
+{
+/*
+	register w_char *d;
+
+	for (d = s1;n > 0;n--) {
+		*d++ = *s2++;
+	}
+	return s1;
+*/
+    if (s2 > s1) {
+	for ( ; n-- > 0; ) {
+	    *s1++ = *s2++;
+	}
+    } else if (s2 < s1) {
+	s1 += n - 1;
+	s2 += n - 1;
+	for ( ; n-- > 0; ) {
+	    *s1-- = *s2--;
+	}
+    }
+    return s1;
+}
+
+int wnn_Strlen(s)
+register w_char *s;
+{
+	register int n;
+
+	for (n = 0;*s++ != 0;n++);
+	return n;
+}
+
+void
+wnn_Sreverse(d, s)
+w_char *d, *s;
+{
+  w_char *s0;
+
+  s0 = s;
+  for(;*s++;);
+  s--;
+  for(;--s >= s0;){
+    *d++ = *s;
+  }
+  *d = 0;
+}
+
+#ifdef nodef
+w_char *wnn_Index(s,c)
+register w_char *s;
+register w_char c;
+{
+	while (*s != c) {
+		if (*s++ == 0) return 0;
+	}
+	return s;
+}
+
+w_char *wnn_Rindex(s,c)
+register w_char *s;
+register w_char c;
+{
+	register w_char *p = 0;
+
+	while (*s != 0) {
+		if (*s++ == c) p = s-1;
+	}
+	return p;
+}
+
+w_char *wnn_Strpbrk(s1,s2)
+register w_char *s1;
+register w_char *s2;
+{
+	register w_char *p;
+
+	while (*s1 != 0) {
+		for (p = s2;*p != 0;p++) {
+			if (*s1++ == *p) return s1-1;
+		}
+	}
+	return 0;
+}
+
+int wnn_Strspn(s1,s2)
+register w_char *s1;
+register w_char *s2;
+{
+	register w_char *p;
+	register int n;
+
+	while (*s1 != 0) {
+		for (p = s2;*p != 0;p++) {
+			if (*s1++ == *p) {
+				n = 1;
+				while (*s1 != 0) {
+					for (p = s2;*p != 0;p++) {
+						if (*s1++ == *p) {
+							n++;
+							break;
+						}
+					}
+					if (*p == 0) {
+						return n;
+					}
+				}
+				return n;
+			}
+		}
+	}
+	return 0;
+}
+
+int wnn_Strcspn(s1,s2)
+register w_char *s1;
+register w_char *s2;
+{
+	register w_char *p;
+	register int n;
+
+	while (*s1 != 0) {
+		for (p = s2;*p != 0;p++) {
+			if (*s1++ != *p) {
+				n = 1;
+				while (*s1 != 0) {
+					for (p = s2;*p != 0;p++) {
+						if (*s1++ != *p) {
+							n++;
+							break;
+						}
+					}
+					if (*p == 0) {
+						return n;
+					}
+				}
+				return n;
+			}
+		}
+	}
+	return 0;
+}
+
+w_char *wnn_Strtok(s1,s2)
+register w_char *s1;
+register w_char *s2;
+{
+	static w_char *p = 0,*s;
+	static w_char c;
+	register int i,j,n;
+
+	if (s1 == 0) {
+		if (p == 0) return 0;
+		*p = c;
+	} else {
+		p = s1;
+	}
+	n = wnn_Strlen(p) - (j = wnn_Strlen(s2));
+	for (i = 0;i <= n;i++) {
+		if (wnn_Strncmp(p++,s2,j) == 0) {
+			s = p+j-1;
+			break;
+		}
+	}
+	if (i > n) return 0;
+	for (;i <= n;i++) {
+		if (wnn_Strncmp(p++,s2,j) == 0) {
+			p--;
+			c = *p;
+			*p = 0;
+			break;
+		}
+	}
+	return s;
+}
+
+int wnn_Strwidth(buf)
+w_char *buf;
+{
+  register int width;
+
+	for (width = 0;*buf != 0;buf++) {
+		if (is_full_width(*buf)) {
+			width += 2;
+		} else {
+			width++;
+		}
+	}
+	return width;
+}
+
+int wnn_Strnwidth(buf,n)
+w_char *buf;
+int n;
+{
+	register int width,i;
+
+	for (width = 0,i = 0;i < n;buf++,i++) {
+		if (is_full_width(*buf)) {
+			width += 2;
+		} else {
+			width++;
+		}
+	}
+	return width;
+}
+
+void
+wnn_delete_ss2(s, n)
+register unsigned int *s;
+register int n;
+{
+    register unsigned int x;
+
+    for(; n != 0 && (x = *s); n--, s++){
+	if ((x & 0xff00) == 0x8e00) *s &= ~0xff00;
+	if (x == 0xffffffff) break;
+    }
+}
+
+void
+wnn_delete_w_ss2(s, n)
+register w_char *s;
+register int n;
+{
+    register w_char x;
+
+    for(; n != 0 && (x = *s); n--, s++){
+	if ((x & 0xff00) == 0x8e00) *s &= ~0xff00;
+    }
+}
+
+int
+wnn_byte_count(in)
+register int in;
+{
+    return(((in <= 0xa0 && in != 0x00 && in != 0x8e) || in == 0xff) ? 1 : 2);
+}
+#endif /* nodef */
diff --git a/wnn/wnn_os.h b/wnn/wnn_os.h
new file mode 100644
index 0000000000000000000000000000000000000000..250626339535b7148f966a420c2d76402d226aee
--- /dev/null
+++ b/wnn/wnn_os.h
@@ -0,0 +1,112 @@
+/*
+ * $Id: wnn_os.h,v 1.1 1996/03/13 09:57:23 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1992
+ * Copyright OMRON Corporation. 1992
+ * Copyright ASTEC, Inc. 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifndef _WNN_OS_
+#define _WNN_OS_
+
+/* OS dependent */
+
+#include <signal.h>
+
+#ifdef SYSVR2
+#include <fcntl.h>
+#include <string.h>
+#define index	strchr
+#ifndef re_signal
+# define re_signal(x, y) signal((x), (y))
+#endif
+#else
+# define re_signal(x, y)
+#endif
+
+#if defined(SYSVR2) || defined(UX386)
+#include <sys/param.h>
+#define getdtablesize() (NOFILE)        /* sys/param.h must be included */
+#ifndef SIGCHLD
+# define SIGCHLD SIGCLD
+#endif
+#endif
+
+#include <sys/types.h>
+#include <sys/file.h>
+
+#ifdef BSD42
+#include <strings.h>
+#endif
+
+#ifdef TERMINFO
+#include <curses.h>
+#include <term.h>
+#endif
+
+
+/*
+  if your system has wait3() system call define HAVE_WAIT3.
+  wait3() doesn't have to be fully supported.
+  uum uses only NULL for the 3rd parameter rusage.
+ */
+
+#if !defined(UX386) && !defined(SVR4) && !defined(hpux) && !defined(AIXV3)
+#define HAVE_WAIT3
+#endif
+
+#if defined(luna) && !defined(SIGNALRETURNSINT)
+#define SIGNALRETURNSINT
+#endif
+
+#ifndef SIGNALRETURNSINT
+typedef void intfntype;
+#define SIGNAL_RETURN	return
+#else
+typedef int intfntype;
+#define SIGNAL_RETURN	return(0)
+#endif
+typedef intfntype (*intfnptr)();
+
+#endif	/* _WNN_OS_ */
diff --git a/wnn/wnn_string.h b/wnn/wnn_string.h
new file mode 100644
index 0000000000000000000000000000000000000000..0f2532bbcdec4ca8f110761ef23f6dcb110826a6
--- /dev/null
+++ b/wnn/wnn_string.h
@@ -0,0 +1,74 @@
+/*
+ * $Id: wnn_string.h,v 1.1 1996/03/13 09:57:25 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1991, 1992
+ * Copyright OMRON Corporation. 1991, 1992
+ * Copyright ASTEC, Inc. 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifndef _WNN_STRING_
+#define _WNN_STRING_
+
+extern int wnn_sStrcpy();
+extern int wnn_Sstrcpy();
+extern void wnn_Sreverse();
+extern char * wnn_Stos();
+extern char *wnn_sStrncpy();
+extern w_char *wnn_Strcat();
+extern w_char *wnn_Strncat();
+extern int wnn_Strcmp();
+extern int wnn_Substr();
+extern int wnn_Strncmp();
+extern w_char *wnn_Strncpy();
+extern int wnn_Strlen();
+extern w_char *wnn_Strcpy();
+extern void wnn_delete_w_ss2();
+extern int wnn_byte_count();
+#ifndef JS
+extern int check_pwd();
+#endif
+#ifdef CHINESE
+extern int wnn_Sstrcat();
+#endif
+#endif
diff --git a/wnn/wnnerrmsg.c b/wnn/wnnerrmsg.c
new file mode 100644
index 0000000000000000000000000000000000000000..7e68b89c499a396ecd3e53203a2a84992bd49e74
--- /dev/null
+++ b/wnn/wnnerrmsg.c
@@ -0,0 +1,226 @@
+/*
+ * $Id: wnnerrmsg.c,v 1.1 1996/03/13 09:57:26 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+#include <stdio.h>
+#include "jslib.h"
+#include "commonhd.h"
+#include "wnn_os.h"
+#include "msg.h"
+
+#ifdef	not_use
+char *wnn_errormsg[] ={
+"no_error 0",
+"�ե����뤬¸�ߤ��ޤ���",		/*WNN_NO_EXIST	1 */
+"no_error 2",
+"����alloc�Ǽ��Ԥ��ޤ�����",		/*WNN_MALLOC_ERR	3 */
+"no_error 4",
+"����ǤϤ���ޤ���",		/*WNN_NOT_A_DICT	5  */
+"���٥ե�����ǤϤ���ޤ���",	/*WNN_NOT_A_HINDO_FILE	6  */
+"��°��ե�����ǤϤ���ޤ���",	/*WNN_NOT_A_FUZOKUGO_FILE 7  */
+"no_error 8",
+"����ơ��֥뤬���դǤ���",	/*WNN_JISHOTABLE_FULL	9*/
+"���٥ե����뤬�����ꤵ�줿��������٥ե�����ǤϤ���ޤ���",
+				 /*WNN_HINDO_NO_MATCH	10 */
+"no_error 11",
+"no_error 12",
+"no_error 13",
+"no_error 14",
+"no_error 15",
+"�ե����뤬�����ץ�Ǥ��ޤ���",	/*WNN_OPENF_ERR		16*/
+"���������٥ե�����ǤϤ���ޤ���",		/* WNN_NOT_HINDO_FILE	17 */
+"��������°��ե�����ǤϤ���ޤ���",	/* WNN_NOT_FZK_FILE 18 */
+"��°��θĿ����٥���Ĺ���ʤɤ�¿�᤮�ޤ���",	/* WNN_FZK_TOO_DEF 19 */
+"�����ֹ�μ���ϡ��Ȥ��Ƥ��ޤ���",	/*WNN_DICT_NOT_USED	20 */
+"no_error 21",
+"no_error 22",
+"no_error 23",
+"��°��ե���������Ƥ�����������ޤ���", /* WNN_BAD_FZK_FILE  24     */
+"�����ʻ��ֹ椬�۾�Ǥ�hinsi.data������������ޤ���", /*WNN_GIJI_HINSI_ERR 25 */
+"̤������ʻ줬��ü�ʻ�Ȥ����������Ƥ��ޤ���", /*WNN_NO_DFE_HINSI 26*/
+"��°��ե����뤬�ɤ߹��ޤ�Ƥ��ޤ���", /*WNN_FZK_FILE_NO_LOAD	27 */
+"no_error 28",
+"no_error 29",
+"����Υ�����ȥ꤬¿�᤮�ޤ���",	/*WNN_DIC_ENTRY_FULL	30*/
+"�Ѵ����褦�Ȥ���ʸ����Ĺ�᤮�ޤ���",	/*WNN_LONG_MOJIRETSU	31 */
+"��°������ΰ褬��­���Ƥ��ޤ���",	/*WNN_WKAREA_FULL	32 */
+"no_error 33",
+"�������ΰ褬��­���Ƥ��ޤ���",		/* WNN_JKTAREA_FULL 34 */
+"���䤬 1 �Ĥ���ޤ���Ǥ��� ",	/* WNN_NO_KOUHO 35 */
+"no_error 36",
+"no_error 37",
+"no_error 38",
+"no_error 39",
+"�ɤߤ�Ĺ�᤮�ޤ���",			/*WNN_YOMI_LONG	40 */
+"������Ĺ�᤮�ޤ���",			/*WNN_KANJI_LONG	41 */
+"���ꤵ�줿����ϡ���Ͽ��ǽ�ǤϤ���ޤ���", /*WNN_NOT_A_UD	42 */
+"�ɤߤ�Ĺ����0�Ǥ���",			/*WNN_NO_YOMI	43 */
+"���ꤵ�줿����ϡ��հ�����ǽ�ǤϤ���ޤ���", /* WNN_NOT_A_REV	44 */
+"�꡼�ɥ���꡼�μ������Ͽ/������褦�Ȥ��ޤ�����",	/*WNN_RDONLY	45 */
+"�Ķ���¸�ߤ��ʤ��������Ͽ���褦�Ȥ��ޤ�����", /* WNN_DICT_NOT_IN_ENV 46 */
+"no_error 47",
+"no_error 48",
+"�꡼�ɥ���꡼�����٤��ѹ����褦�Ȥ��ޤ�����", /* WNN_RDONLY_HINDO 49 */
+"���ꤵ�줿ñ�줬¸�ߤ��ޤ���",	/*WNN_WORD_NO_EXIST	50 */
+"no_error 51",
+"no_error 52",
+"no_error 53",
+"no_error 54",
+"no_error 55",
+"no_error 56",
+"no_error 57",
+"no_error 58",
+"no_error 59",
+"����alloc�Ǽ��Ԥ��ޤ�����",		/*WNN_MALLOC_INITIALIZE	60 */
+"no_error 61",
+"no_error 62",
+"no_error 63",
+"no_error 64",
+"no_error 65",
+"no_error 66",
+"no_error 67",
+"�����Υ��顼��������ޤ�����",		/* WNN_SOME_ERROR 68 */
+"�Х���ȯ�����Ƥ������ͤǤ���",		/*WNN_SONOTA 69 */
+"�����Ф����Ǥ��ޤ���",		/*WNN_JSERVER_DEAD 70 */
+"alloc�˼��Ԥ��ޤ�����",	/*WNN_ALLOC_FAIL	71 */
+"�����Ф���³�Ǥ��ޤ���Ǥ�����",	/*WNN_SOCK_OPEN_FAIL	72 */
+"�̿��ץ��ȥ���ΥС�����󤬹�äƤ��ޤ���", /* WNN_BAD_VERSION	73 */
+"���饤����Ȥ����������Ķ��ǤϤ���ޤ���", /* WNN_BAD_ENV 74 */
+"no_error 75",
+"no_error 76",
+"no_error 77",
+"no_error 78",
+"no_error 79",
+"�ǥ��쥯�ȥ���뤳�Ȥ��Ǥ��ޤ���",	/* WNN_MKDIR_FAIL	80	*/
+"no_error 81",
+"no_error 82",
+"no_error 83",
+"no_error 84",
+"no_error 85",
+"no_error 86",
+"no_error 87",
+"no_error 88",
+"no_error 89",
+"�ե�������ɤ߹��ळ�Ȥ��Ǥ��ޤ���",		/* WNN_FILE_READ_ERROR	90*/
+"�ե������񤭽Ф����Ȥ��Ǥ��ޤ���",		/* WNN_FILE_WRITE_ERROR	91*/
+"���饤����Ȥ��ɤ߹�����ե�����ǤϤ���ޤ���",	/* WNN_FID_ERROR 92*/
+"����ʾ�ե�������ɤ߹��ळ�Ȥ��Ǥ��ޤ���",	/* WNN_NO_MORE_FILE	93*/
+"�ѥ���ɤ��ְ�äƤ��ޤ���",		/* WNN_INCORRECT_PASSWD    94   */
+"�ե����뤬�ɤ߹��ޤ�Ƥ��ޤ��� ", /*WNN_FILE_IN_USE    	95 */
+"�ե����뤬����Ǥ��ޤ��� ", /*WNN_UNLINK    		96 */
+"�ե����뤬��������ޤ���", /*WNN_FILE_CREATE_ERROR	97 */
+"�ף��Υե�����Ǥ���ޤ���", /*WNN_NOT_A_FILE		98	*/
+"�ե������I-node��FILE_UNIQ����פ���������Ǥ��ޤ���", /*WNN_INODE_CHECK_ERROR   99 */
+
+"�ʻ�ե����뤬�礭�᤮�ޤ���",		/* WNN_TOO_BIG_HINSI_FILE 100 */
+"�ʻ�ե����뤬�礭�᤮�ޤ���",		/* WNN_TOO_LONG_HINSI_FILE_LINE 101  */
+"�ʻ�ե����뤬¸�ߤ��ޤ���",		/* WNN_NO_HINSI_DATA_FILE 102 */
+"�ʻ�ե���������Ƥ��ְ�äƤ��ޤ���",	/* WNN_BAD_HINSI_FILE 103 */
+"no_error 104",
+"�ʻ�ե����뤬�ɤ߹��ޤ�Ƥ��ޤ���",	/* WNN_HINSI_NOT_LOADED 105*/
+"�ʻ�̾���ְ�äƤ��ޤ���",		/* WNN_BAD_HINSI_NAME 106 */
+"�ʻ��ֹ椬�ְ�äƤ��ޤ���",		/* WNN_BAD_HINSI_NO 107 */
+"no_error 108",
+"�������ϥ��ݡ��Ȥ���Ƥ��ޤ���", /*NOT_SUPPORTED_OPERATION 109 Not Used*/
+"�ѥ���ɤ����äƤ���ե����뤬�����ץ�Ǥ��ޤ���", /*WNN_CANT_OPEN_PASSWD_FILE 110  */
+/* ��������Υ��顼  */
+"uumrc�ե����뤬¸�ߤ��ޤ���", /*WNN_RC_FILE_NO_EXIST    111 Not Used*/
+"uumrc�ե�����η��������äƤ��ޤ���", /* WNN_RC_FILE_BAD_FORMAT  112 Not Used*/
+"����ʾ�Ķ����뤳�ȤϤǤ��ޤ���", /* WNN_NO_MORE_ENVS  113 */
+"���Υ��饤����Ȥ��ɤ߹�����ե�����Ǥ���ޤ���", /* WNN_FILE_NOT_READ_FROM_CLIENT 114 */
+"��������٥ե����뤬�Ĥ��Ƥ��ޤ���", /*WNN_NO_HINDO_FILE 115 */
+"�ѥ���ɤΥե����뤬��������ޤ���" /*WNN_CANT_CREATE_PASSWD_FILE 116*/
+};
+
+int wnn_errormsg_len = sizeof(wnn_errormsg) / sizeof(char *);
+
+extern	int	wnn_errorno;
+static char msg[] = ":BAD ERRORNO!!! ";
+
+char *wnn_perror()
+{
+static char msgarea[100];
+
+  if((wnn_errorno < 0) || (wnn_errorno > sizeof(wnn_errormsg) / sizeof(char *))){
+    sprintf(msgarea , "%d"  , wnn_errorno);
+    strcat(msgarea , msg);
+    return(msgarea);
+  }
+  return(wnn_errormsg[wnn_errorno]);
+}
+#endif	/* not_use */
+
+extern	int	wnn_errorno;
+extern struct msg_cat *wnn_msg_cat;
+static char msg[] = ":BAD ERRORNO!!! ";
+
+char *
+wnn_perror_lang(lang)
+char *lang;
+{
+    static char msgarea[100];
+
+    sprintf(msgarea , "%d"  , wnn_errorno);
+    strcat(msgarea , msg); 
+    return(msg_get(wnn_msg_cat, wnn_errorno, msgarea, lang));
+}
+
+char *
+wnn_perror()
+{
+    return(wnn_perror_lang(NULL));
+}
+
+/*
+  Local Variables:
+  eval: (setq kanji-flag t)
+  eval: (setq kanji-fileio-code 0)
+  eval: (mode-line-kanji-code-update)
+  End:
+*/
diff --git a/wnn/wnnerror.h b/wnn/wnnerror.h
new file mode 100644
index 0000000000000000000000000000000000000000..b9e1662bfcafdc9b566d70e8decf90a0f62f8bae
--- /dev/null
+++ b/wnn/wnnerror.h
@@ -0,0 +1,160 @@
+/*
+ * $Id: wnnerror.h,v 1.1 1996/03/13 09:57:28 colin Exp $
+ */
+/*
+ * Copyright Kyoto University Research Institute for Mathematical Sciences
+ *                 1987, 1988, 1989, 1990, 1991
+ * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991
+ * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that all of the following conditions are satisfied:
+ *
+ * 1) The above copyright notices appear in all copies
+ * 2) Both those copyright notices and this permission notice appear
+ *    in supporting documentation
+ * 3) The name of "Wnn" isn't changed unless substantial modifications
+ *    are made, or
+ * 3') Following words followed by the above copyright notices appear
+ *    in all supporting documentation of software based on "Wnn":
+ *
+ *   "This software is based on the original version of Wnn developed by
+ *    Kyoto University Research Institute for Mathematical Sciences (KURIMS),
+ *    OMRON Corporation and ASTEC Inc."
+ *
+ * 4) The names KURIMS, OMRON and ASTEC not be used in advertising or
+ *    publicity pertaining to distribution of the software without
+ *    specific, written prior permission
+ *
+ * KURIMS, OMRON and ASTEC make no representations about the suitability
+ * of this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Wnn consortium is one of distributors of the official Wnn source code
+ * release.  Wnn consortium also makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * KURIMS, OMRON, ASTEC AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL KURIMS, OMRON, ASTEC OR
+ * WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*	Version 4.0
+ */
+/* file �ط��Υ��顼 */
+#define WNN_FILE_READ_ERROR	90 /* �ե�������ɤ߹��ळ�Ȥ��Ǥ��ޤ��� */
+#define WNN_FILE_WRITE_ERROR	91 /* �ե������񤭽Ф����Ȥ��Ǥ��ޤ��� */
+#define WNN_FID_ERROR		92 /* ���饤����Ȥ��ɤ߹�����ե�����ǤϤ���ޤ��� */
+#define WNN_NO_MORE_FILE	93 /* ����ʾ�ե�������ɤ߹��ळ�Ȥ��Ǥ��ޤ���*/
+#define WNN_INCORRECT_PASSWD    94 /* �ѥ���ɤ��ְ�äƤ��ޤ��� */
+#define WNN_FILE_IN_USE    	95 /* �ե����뤬�ɤ߹��ޤ�Ƥ��ޤ��� */
+#define WNN_UNLINK    		96 /* �ե����뤬����Ǥ��ޤ��� */
+#define WNN_FILE_CREATE_ERROR	97 /* �ե����뤬��������ޤ���*/
+#define WNN_NOT_A_FILE		98	/*�ף��Υե�����Ǥ���ޤ���*/
+#define WNN_INODE_CHECK_ERROR   99 /* �ե������I-node��FILE_UNIQ����פ���������Ǥ��ޤ��� */
+
+/*	V3	*/
+/* �����ɲôط��Υ��顼 */
+#define WNN_NO_EXIST		1	/*�ե����뤬¸�ߤ��ޤ���*/
+#define WNN_MALLOC_ERR		3	/*����alloc�Ǽ��Ԥ��ޤ�����*/
+#define WNN_NOT_A_DICT		5 	/*����ǤϤ���ޤ���*/
+#define WNN_NOT_A_HINDO_FILE	6	/*���٥ե�����ǤϤ���ޤ���*/
+#define WNN_NOT_A_FUZOKUGO_FILE	7	/*��°��ե�����ǤϤ���ޤ���*/
+#define WNN_JISHOTABLE_FULL	9	/*����ơ��֥뤬���դǤ���*/
+#define WNN_HINDO_NO_MATCH	10	/*���٥ե����뤬�����ꤵ�줿�����
+					  ���٥ե�����ǤϤ���ޤ���*/
+#define WNN_OPENF_ERR		16	/*�ե����뤬�����ץ�Ǥ��ޤ���*/
+#define WNN_NOT_HINDO_FILE	17	/*���������٥ե�����Ǥ���ޤ���*/
+#define WNN_NOT_FZK_FILE	18	/*��������°��ե�����Ǥ���ޤ���*/
+#define WNN_FZK_TOO_DEF		19	/*��°��θĿ����٥���Ĺ���ʤɤ�
+					  ¿�᤮�ޤ�*/
+/* �������ط��Υ��顼 */
+#define WNN_DICT_NOT_USED	20	/*�����ֹ�μ���ϡ��Ȥ��Ƥ��ޤ���*/
+
+/* �Ѵ����Υ��顼 */
+#define WNN_BAD_FZK_FILE  24      /*��°��ե���������Ƥ�����������ޤ���*/
+#define WNN_GIJI_HINSI_ERR	25	/*�����ʻ��ֹ椬�۾�Ǥ�
+					  hinsi.data������������ޤ���*/
+#define WNN_NO_DFE_HINSI	26	/*̤������ʻ줬��ü�ʻ�Ȥ���
+					  �������Ƥ��ޤ� Not Used*/
+#define WNN_FZK_FILE_NO_LOAD	27	/*��°��ե����뤬�ɤ߹��ޤ�Ƥ��ޤ���*/
+
+/* jishobiki.c */
+#define WNN_DIC_ENTRY_FULL	30	/*����Υ�����ȥ꤬¿�᤮�ޤ���*/
+#define WNN_LONG_MOJIRETSU	31	/*�Ѵ����褦�Ȥ���ʸ����Ĺ�᤮�ޤ���*/
+#define WNN_WKAREA_FULL		32	/*��°������ΰ褬��­���Ƥ��ޤ���*/
+#define WNN_JKTAREA_FULL 	34	/*�������ΰ褬��­���Ƥ��ޤ���*/
+#define WNN_NO_KOUHO		35	/*���䤬 1 �Ĥ���ޤ���Ǥ���*/
+
+/* ñ����Ͽ���Υ��顼 */
+#define WNN_YOMI_LONG		40	/*�ɤߤ�Ĺ�᤮�ޤ���*/
+#define WNN_KANJI_LONG		41	/*������Ĺ�᤮�ޤ���*/
+#define WNN_NOT_A_UD		42 /*���ꤵ�줿����ϡ���Ͽ��ǽ�ǤϤ���ޤ���*/
+#define WNN_NO_YOMI		43	/*�ɤߤ�Ĺ����0�Ǥ���*/
+#define WNN_NOT_A_REV		44 /*���ꤵ�줿����ϡ��հ�����ǽ�ǤϤ���ޤ���*/
+#define WNN_RDONLY		45	/*�꡼�ɥ���꡼�μ������Ͽ���褦�Ȥ��ޤ�����*/
+#define WNN_DICT_NOT_IN_ENV	46	/*�Ķ���¸�ߤ��ʤ��������Ͽ���褦�Ȥ��ޤ�����*/
+
+/* ���ٹ����Υ��顼 */
+#define WNN_RDONLY_HINDO	49 /* �꡼�ɥ���꡼�����٤��ѹ����褦�Ȥ��ޤ����� */
+
+/* ñ���������ʻ������Υ��顼 */
+/*
+WNN_RDONLY
+*/
+#define WNN_WORD_NO_EXIST	50	/*���ꤵ�줿ñ�줬¸�ߤ��ޤ���*/
+
+/* ������λ��Υ��顼 */
+#define WNN_MALLOC_INITIALIZE	60	/*����alloc�Ǽ��Ԥ��ޤ�����*/
+
+#define WNN_SOME_ERROR		68	/* �����Υ��顼��������ޤ�����*/
+#define WNN_SONOTA		69	/*�Х���ȯ�����Ƥ������ͤǤ���Not Used*/
+#define WNN_JSERVER_DEAD	70	/*�����Ф����Ǥ��ޤ���(jlib)*/
+#define WNN_ALLOC_FAIL		71	/*alloc�˼���(jlib)*/
+#define WNN_SOCK_OPEN_FAIL	72	/*jd_begin��socket��open�˼���(jlib)*/
+#define WNN_BAD_VERSION		73	/*�̿��ץ��ȥ���ΥС�����󤬹�äƤ��ޤ���*/
+#define WNN_BAD_ENV		74      /*���饤����Ȥ����������Ķ��ǤϤ���ޤ���*/
+
+#define WNN_MKDIR_FAIL		80	/* �ǥ��쥯�ȥ����»�ʤä� */
+
+
+/*�ʻ�ե����� */
+#define WNN_TOO_BIG_HINSI_FILE 100 	/*�ʻ�ե����뤬�礭�᤮�ޤ���*/
+#define WNN_TOO_LONG_HINSI_FILE_LINE 101		/*�ʻ�ե����뤬�礭�᤮�ޤ���*/
+#define WNN_NO_HINSI_DATA_FILE 102	/*�ʻ�ե����뤬¸�ߤ��ޤ��� */
+#define WNN_BAD_HINSI_FILE 103	       /*�ʻ�ե���������Ƥ��ְ�äƤ��ޤ���*/
+
+#define WNN_HINSI_NOT_LOADED 105 	/* �ʻ�ե����뤬�ɤ߹��ޤ�Ƥ��ޤ���*/
+#define WNN_BAD_HINSI_NAME 106		/* �ʻ�̾���ְ�äƤ��ޤ� */
+#define WNN_BAD_HINSI_NO 107		/* �ʻ��ֹ椬�ְ�äƤ��ޤ� */
+
+#define NOT_SUPPORTED_OPERATION 109 /*�������ϥ��ݡ��Ȥ���Ƥ��ޤ���Not Used*/
+
+/* 
+ *
+ *  jl �ʹ���饤�֥��ˤΥ��顼
+ * 
+ */
+
+#define WNN_CANT_OPEN_PASSWD_FILE 110  /* �ѥ���ɤ����äƤ���ե����뤬
+					 �����ץ�Ǥ��ޤ���(jl) */
+/* ��������Υ��顼  */
+#define WNN_RC_FILE_NO_EXIST 111 /* uumrc�ե����뤬¸�ߤ��ޤ���(jl) Not Used*/
+#define WNN_RC_FILE_BAD_FORMAT 112 /* uumrc�ե�����η��������äƤ��ޤ�(jl)Not Used */
+#define WNN_NO_MORE_ENVS  113 /* ����ʾ�Ķ����뤳�ȤϽ���ޤ���*/
+#define WNN_FILE_NOT_READ_FROM_CLIENT 114 /* ���Υ��饤����Ȥ��ɤ߹�����ե�����Ǥ���ޤ���*/
+#define WNN_NO_HINDO_FILE 115 /* ��������٥ե����뤬�Ĥ��Ƥ��ޤ���*/
+
+#define WNN_CANT_CREATE_PASSWD_FILE 116 /*�ѥ���ɤΥե����뤬��������ޤ���*/
+/*
+  Local Variables:
+  kanji-flag: t
+  End:
+*/
diff --git a/wnn/yincoding.c b/wnn/yincoding.c
new file mode 100644
index 0000000000000000000000000000000000000000..ae9e23bd477025c54d165137c913555149e40d33
--- /dev/null
+++ b/wnn/yincoding.c
@@ -0,0 +1,941 @@
+/*
+ * $Id: yincoding.c,v 1.1 1996/03/13 09:57:29 colin Exp $
+ */
+/** 		Copyright OMRON Corporation. 1989, 1990, 1991, 1992
+ *
+ * Permission to use, copy, modify, distribute and sell this software and its 
+ * documentation for any purpose is hereby granted without fee, provided 
+ * that all of the following conditions are satisfied:
+ *
+ * <1>	The above copyright notices appear in all copies
+ * <2>	Both the copyright notices and this permission notice appear in 
+ *	supporting documentation
+ * <3>	The name of "cWnn" isn't changed unless substantial modifications 
+ * 	are made
+ * <4>	Following words followed by the above copyright notices appear
+ *    	in all supporting documentation of software based on "cWnn":
+ *
+ * 	This software is based on the original version of cWnn developed 
+ *	by OMRON Corporation and Wnn developed by Kyoto University Research 
+ *	Institute for Mathematical Sciences (KURIMS), OMRON Corporation and 
+ * 	ASTEC Inc."
+ *
+ * <5>	The names of OMRON may not be used in advertising or publicity 
+ *	pertaining to distribution of the software without specific, written 
+ *	prior permission
+ *
+ *  OMRON Corporation makes no representations about the suitability of this 
+ *  software for any purpose.  It is provided "as is" without express or 
+ *  implied warranty.
+ *
+ *  Wnn consortium is one of distributors of the official Wnn source code
+ *  release.  Wnn consortium also makes no representations about the
+ *  suitability of this software for any purpose.  It is provided "as is"
+ *  without express or implied warranty.
+ *
+ *  OMRON AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ *  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ *  IN NO EVENT SHALL OMRON OR WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL,
+ *  INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ *  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ *  PERFORMANCE OF THIS SOFTWARE.
+ *
+ *  This sofeware is developed by OMRON Corporation, based on the original 
+ *  version of Wnn which was developed by Kyoto University Research Institute 
+ *  for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc. 
+ *
+ *  	Copyright Kyoto University Research Institute for Mathematical 
+ *		Sciences 1987,1988,1989,1990,1991, 1992
+ * 	Copyright OMRON Corporation 1987,1988,1989,1990,1991, 1992
+ *	Copyright ASTEC Inc. 1987, 1988,1989,1990,1991, 1992
+ *
+ *  Contact:	Tel:   	+81-75-951-5111
+ *		Fax:   	+81-75-955-2442
+ *		E-mail: zhong@ari.ncl.omron.co.jp
+**/
+/**  cWnn  Version 1.1	 **/
+
+#include  <stdio.h>
+#include  <ctype.h>
+#include  "commonhd.h"
+#ifdef CHINESE
+#ifdef SYSVR2
+#include  <string.h>
+#endif
+#ifdef BSD42
+#include  <strings.h>
+#endif
+#include  "cplib.h"
+#include  "rk_spclval.h"
+#include  "jh.h"
+#include  "wnn_string.h"
+
+extern char  *py_table[];
+extern char  *zy_table[];
+unsigned char last_mark;     /* Using to reme previous auto_state() */
+
+/* copied from old sstrings.c */
+static int
+cwnn_sStrcpy(c , w)
+register char *c;
+register w_char *w;
+{
+    char *c0 = c;
+    for(;*w != 0 ; w++){
+	if ((*w & 0x8080) == 0x8000) {
+	    *c++ = 0x8f;
+	    *c++ = (char)((*w & 0xff00) >> 8);
+	    *c++ = (char)((*w & 0x007f) | 0x0080);
+	} else {
+	  if (*w & 0xff00)
+	    *c++ = (char)((*w & 0xff00) >> 8);
+	  else if (*w & 0x80)
+	    *c++ = 0x8e;
+	  *c++ = (char)(*w & 0x00ff);
+	}
+    }
+    *c = '\0';
+    return (c - c0);
+}
+
+
+static int
+cwnn_Sstrcpy(w , c )
+w_char *w;
+unsigned char *c;
+{
+    w_char *w0 = w;
+
+    for(;*c;){
+	if (*c & 0x80) {
+	    if (*c == 0x8e) {
+		c++;
+		*w++ = (unsigned short)*c++;
+	    } else if (*c == 0x8f) {
+		c++;
+		*w = (unsigned short)(*c++ << 8);
+		*w++ |= (unsigned short)(*c++ & 0x7f);
+	    } else {
+		*w = (unsigned short)(*c++ << 8);
+		*w++ |= (unsigned short)*c++;
+	    }
+	} else {
+	    *w++ = (unsigned short)*c++;
+	}
+    }
+    *w = 0;
+    return(w - w0);
+}
+
+static int
+cwnn_Sstrcat(w , c )
+w_char *w;
+unsigned char *c;
+{
+    w_char *w0 = w;
+
+    for ( ; *w; w++);
+
+    for(;*c;){
+	if (*c & 0x80) {
+	    if (*c == 0x8e) {
+		c++;
+		*w++ = (unsigned short)*c++;
+	    } else if (*c == 0x8f) {
+		c++;
+		*w = (unsigned short)(*c++ << 8);
+		*w++ |= (unsigned short)(*c++ & 0x7f);
+	    } else {
+		*w = (unsigned short)(*c++ << 8);
+		*w++ |= (unsigned short)*c++;
+	    }
+	} else {
+	    *w++ = (unsigned short)*c++;
+	}
+    }
+    *w = 0;
+    return(w - w0);
+}
+
+/********** py_yunmu(), zy_yunmu(): if yuyin with YunMu, return YunMu's 
+	position in YunMu table. after that, you must calculate its 
+	real yun_raw static	   if without YunMu, return -1  
+***********/
+static int  py_yunmu(yuyin)
+register char	*yuyin;
+{
+register int	i;
+  for ( i = (PY_NUM_YUNMU*5)- 1; i >= 0 ; i-- ){
+    if ( strncmp(yuyin, py_yunmu_tbl[i], strlen(py_yunmu_tbl[i])) == 0 ) 
+	return(i);
+    }
+  return(-1);
+}
+
+static int  zy_yunmu(yuyin)
+register char	*yuyin;
+{
+register int	i;
+  for ( i = (ZY_NUM_YUNMU*5)- 1; i >= 0 ; i-- ){
+    if ( strncmp(yuyin, zy_yunmu_tbl[i], strlen(zy_yunmu_tbl[i])) == 0 ) 
+	return(i);
+    }
+  return(-1);
+}
+
+/* is_pinyin():  if is PinYin with Shengmu,	return 1   */
+/*		if is PinYin without Shengmu ,   return 0   */
+/*		else			     	return -1  */
+
+static int is_pinyin(sheng_raw, yun_raw)
+register int 	sheng_raw;
+register int	yun_raw;
+{
+
+    	 if ( (sheng_raw >= 0) && (sheng_raw < PY_NUM_SHENGMU) && 
+	     (yun_raw >= 0) && (yun_raw < PY_NUM_YUNMU)  &&
+	     ( pinyin_tbl[sheng_raw * PY_NUM_YUNMU + yun_raw] == 1) )  {
+		if ( sheng_raw == EMPTY_SHENG_RAW ) 
+			return(0);
+		else 	return(1);
+		}
+    else return(-1);
+
+}
+
+/* is_zhuyin():  if is ZhuYin with Shengmu: 	return 1   */
+/*               if is ZhuYin without Shengmu: 	return 0   */
+/*				    	 else:	return -1  */
+
+static int is_zhuyin(sheng_raw, yun_raw)
+register int 	sheng_raw;
+register int	yun_raw;
+{
+
+    if ( (sheng_raw >= 0) && (sheng_raw < ZY_NUM_SHENGMU) && 
+	 (yun_raw >= 0) && (yun_raw < ZY_NUM_YUNMU)  &&
+	 ((zhuyin_tbl[sheng_raw * ZY_NUM_YUNMU + yun_raw] & 0x8000) == 0x8000) )
+	if ( sheng_raw == EMPTY_SHENG_RAW )
+		return ( 0);
+	else 	return(1);
+    return(-1);
+}
+/* py_shengmu(), zy_shengmu(): 
+	if yuyin with ShengMu, return Shengmu's position
+ 	in ShengMu table.  if without ShengMu, return -1  
+*/
+static int py_shengmu(yuyin)
+register char	*yuyin;
+{
+register int	i;
+  for ( i = PY_NUM_SHENGMU - 1; i > 0;  i-- )  {
+    if ( strncmp(yuyin, py_shengmu_tbl[i], strlen(py_shengmu_tbl[i])) == 0 ) 
+	return (i);
+  }
+  return ( -1);
+}
+
+static int zy_shengmu(yuyin)
+register char	*yuyin;
+{
+   register int	i;
+   for ( i = ZY_NUM_SHENGMU - 1; i > 0;  i-- )  {
+    if ( strncmp(yuyin, zy_shengmu_tbl[i], strlen(zy_shengmu_tbl[i])) == 0 ) 
+	return (i);
+   }
+  return (-1);
+}
+
+#ifdef nodef
+static void getstr_pzy(lstr, yincod, which)
+register letter *lstr;
+register w_char  yincod;
+int which;
+{
+register letter  *ltmp;
+
+	ltmp = lstr;
+	for (; *lstr; lstr++)  
+
+	if ((which == CWNN_PINYIN) && ((*lstr & 0x0000ffff) == PY_EOF ))
+		break;
+	else 
+	if ((which == CWNN_ZHUYIN) && (isZY_EOF(*lstr & 0x0000ffff)) )
+		break;
+	lstr++;
+        *ltmp++ = yincod;
+        for (; *lstr; lstr++)
+                *ltmp++ = *lstr;
+        *ltmp = 0;
+}
+#endif
+  	
+/* create_yincod(): input:  
+	raw in ShengMu table of PinYin, raw in YunMu table of PinYin,
+  	sisheng	 output: yincod: if is PinYin, otherwise:0. 
+*/
+
+static w_char
+create_yincod(sheng_raw, yun_raw, ss)
+register int	sheng_raw;
+register int	yun_raw;
+register int	ss;
+{
+    int ret = 0;
+    if (is_pinyin(sheng_raw, yun_raw ) == 1)  		/*Has Shengmu*/
+ 	ret = 0x0080 + (((yun_raw<<1)+0x20)<<8) +
+			((sheng_raw-1)<<2) + 0x20;
+    else if (is_pinyin(sheng_raw, yun_raw ) == 0) 	/*Not Shengmu */
+	ret = 0x0080 + (((yun_raw<<1)+0x20)<<8) +
+			((X_SHENG_RAW-1)<<2) + 0x20;	/*Rent this */
+    else return(ret);
+    if ((ss>0)&&(ss<=4))
+    	ret += 0x0100 + ss - 1 ;
+    return(ret);
+}
+
+/* pzy_yincod() 
+	in:     The param is expected to be a PinYin or a ZhuYin.
+	return:  a Yin_code is returned, if it is a PinYin or a ZhuYin.
+	otherwise, 0 is returned, 
+*/
+static int
+pzy_get_sheng_yun(yuyin, ss, sheng_raw, yun_raw, which)
+register char  *yuyin;          /* one PinYin or ZhuYin with end of character */
+register int   *ss;        	/* get SiSheng from PinYin or ZhuYin */
+register int   *sheng_raw;      /* position in ShengMu table */
+int   *yun_raw;        /* position in YunMu table */
+int which;
+{
+/*
+  register int     j;
+*/
+  register char    *pzytmp;
+
+  *ss = -1;
+  *sheng_raw = -1;
+  *yun_raw = -1;
+
+  pzytmp = yuyin;
+
+    if ( which == CWNN_PINYIN ){	/* for Pinyin case */
+
+  	if ((*sheng_raw = py_shengmu(pzytmp)) == -1 ) {  /* no ShengMu  */
+	    if ( (*yun_raw = py_yunmu(pzytmp)) == -1 )  
+		return(0);
+	    else  {
+		pzytmp += strlen(py_yunmu_tbl[*yun_raw]);
+		*sheng_raw = 0;
+		*ss = *yun_raw % 5;
+		*yun_raw = *yun_raw / 5;
+		return(pzytmp - yuyin);
+	    }
+  	} else { 		/* has ShengMu */ 
+/*
+	    for ( j = 0; (int)j < (int)strlen(py_shengmu_tbl[*sheng_raw]); j++) 
+		pzytmp++;
+*/
+	    pzytmp += strlen(py_shengmu_tbl[*sheng_raw]);
+	    if (strlen(pzytmp) == 0 )  return(0);
+	    if ( (*yun_raw = py_yunmu(pzytmp)) != -1 ) {
+		pzytmp += strlen(py_yunmu_tbl[*yun_raw]);
+	    	*ss = *yun_raw % 5;
+	    	*yun_raw = *yun_raw / 5;
+	    	return(pzytmp - yuyin);
+	    } else {
+	   	   pzytmp = yuyin;
+	   	   if ( (*yun_raw = py_yunmu(pzytmp)) == -1 ) 
+			return(0);
+	    	   else {
+			pzytmp += strlen(py_yunmu_tbl[*yun_raw]);
+			*sheng_raw = 0;
+	    		*ss = *yun_raw % 5;
+	    		*yun_raw = *yun_raw / 5;
+	    		return(pzytmp - yuyin);
+		   }
+	    }
+  	}	/* has ShengMu when Pinyin*/
+    }	
+    else {				/* for Zhuyin case */
+
+  	if ((*sheng_raw = zy_shengmu(pzytmp)) == -1 ) {   /* no ShengMu  */
+	    if ( (*yun_raw = zy_yunmu(pzytmp)) == -1 )  
+		return(0);
+	    else  {
+		pzytmp += strlen(zy_yunmu_tbl[*yun_raw]);
+		*sheng_raw = 0;
+		*ss = *yun_raw % 5;
+		*yun_raw = *yun_raw / 5;
+		return(pzytmp - yuyin);
+	     }
+  	} else { 		/* has ShengMu */
+/*
+ 	    for ( j = 0; (int)j < (int)strlen(zy_shengmu_tbl[*sheng_raw]); j++) 
+		pzytmp++;
+*/
+	    pzytmp += strlen(zy_shengmu_tbl[*sheng_raw]);
+	    if (strlen(pzytmp) == 0 )  return(0);
+	    if ( (*yun_raw = zy_yunmu(pzytmp)) != -1 ) {
+		pzytmp += strlen(zy_yunmu_tbl[*yun_raw]);
+	   	*ss = *yun_raw % 5;
+	     	*yun_raw = *yun_raw / 5;
+	     	return(pzytmp - yuyin);
+	    } else {
+	   	pzytmp = yuyin;
+		if ( (*yun_raw = zy_yunmu(pzytmp)) == -1 ) 
+			return(0);
+		else {
+			pzytmp += strlen(zy_yunmu_tbl[*yun_raw]);
+			*sheng_raw = 0;
+	    		*ss = *yun_raw % 5;
+	    		*yun_raw = *yun_raw / 5;
+	    		return(pzytmp - yuyin);
+		}
+	    }
+	}	/* has ShengMu when Zhuyin */
+    }	/* which */
+}
+
+static w_char pzy_yincod(one_yuyin, len)
+register char *one_yuyin;
+register int *len;
+{
+  int     ss[1];
+  int     sheng_raw[1];
+  int     yun_raw[1];
+  register  int	    zytmp;
+  register int ret;
+
+  *len = 0;
+    /* for Pinyin */ 
+    if(ret = pzy_get_sheng_yun(one_yuyin, ss, sheng_raw, yun_raw, CWNN_PINYIN)) 
+	if ( is_pinyin(sheng_raw[0], yun_raw[0]) != -1  ) {
+	    *len = ret;
+	    return(create_yincod(sheng_raw[0], yun_raw[0], ss[0]));
+	}
+    /* for Zhuyin */	
+    if(ret = pzy_get_sheng_yun(one_yuyin, ss, sheng_raw, yun_raw, CWNN_ZHUYIN)){
+	zytmp = zhuyin_tbl[sheng_raw[0] * ZY_NUM_YUNMU + yun_raw[0]];
+	if ( is_zhuyin(sheng_raw[0], yun_raw[0]) != -1 )  {
+	    if ((zytmp & 0x0080 ) == 0x0080) {
+		sheng_raw[0] = (zytmp >>8) & 0x7f;
+		yun_raw[0] = zytmp & 0x7f;
+	    }
+	    *len = ret;
+	    return(create_yincod(sheng_raw[0], yun_raw[0], ss[0]));
+	}
+    }
+return(0);	/* Otherwise, Not a Pinyin nor Zhuyin  */
+}
+
+/* ltoScpy():  copy strings from letter type to w_char type */
+
+static int ltoScpy(w,l)
+register w_char *w;
+register letter *l;
+{
+  register w_char *w0 = w;
+
+    for(;*l;l++){
+	if (/* ((*l & 0x0000ffff) == PY_EOF) || isZY_EOF(*l & 0x0000ffff)
+	    ||*/ (*l == EOLTTR)) /* add by Kuwari */
+	       break;
+        *w++ = (*l & 0x0000ffff);
+    }
+    *w = (w_char)0;
+    return(w - w0);
+}
+
+/* find_pinyin():  	find a YuYin in a string.  if there is a YuYin.
+	 it must be at the tail of string.  return point of start YuYin
+	 else return -1 eg. ;abcdHuang. 'Huang.' is a PinYin & return 5
+	 012345
+*/
+static int
+find_pinyin(str)
+register char	*str;
+{
+register char 	*py_zy_tmp;
+register int	i;
+register int	pnt ;
+int len;
+    pnt = -1;
+    if ((((*(str+strlen(str)-2)<<8)&0xff00)|
+			(*(str+strlen(str)-1)&0x00ff))!= PY_EOF)
+	return( -1 );
+    for ( i = strlen(str) - 1; i >= 0; i-- ) {
+	if ( (int)(strlen(str) - i) > PY_LEN )  
+		return( pnt );
+	py_zy_tmp = str + i;
+	if ( pzy_yincod(py_zy_tmp, &len) != 0 )
+		pnt = i;
+    }
+    return (pnt);
+}
+
+static int
+find_zhuyin(str)
+register char	*str;
+{
+register char 	*py_zy_tmp;
+register int	i;
+register int	pnt ;
+int len;
+   pnt = -1;
+   if (!isZY_EOF(((*(str+strlen(str)-2)<<8)&0xff00)|
+				(*(str+strlen(str)-1)&0x00ff)))
+	return( -1 );
+   for ( i = strlen(str) - 1; i >= 0; i-- ) {
+	if ( (int)(strlen(str) - i) > PY_LEN )  
+		return( pnt );
+	py_zy_tmp = str + i;
+	if ( pzy_yincod(py_zy_tmp, &len) != 0 )
+		pnt = i;
+   }
+   return (pnt);
+}
+
+/* get_one_zhuyin(): get one ZhuYin from ZhuYin strings */
+/* get_one_pinyin(): get one PinYin from PinYin strings */
+static int
+get_one_pinyin(pinzhuyin_str,one_pinzhuyin)
+register unsigned char *pinzhuyin_str;
+register char *one_pinzhuyin;
+{
+register w_char  chrtmp;
+for (; (chrtmp = (((*pinzhuyin_str<<8)&0xff00)|(*(pinzhuyin_str+1)&0x00ff))) 
+	!= PY_EOF && *pinzhuyin_str != 0;pinzhuyin_str++)  
+    *one_pinzhuyin++ = *pinzhuyin_str;
+   if (chrtmp == PY_EOF)   
+	{
+	*one_pinzhuyin++ = *pinzhuyin_str;
+	pinzhuyin_str++;
+	*one_pinzhuyin++ = *pinzhuyin_str;
+	*one_pinzhuyin = 0;
+	return(1);
+	}
+    else  {
+	*one_pinzhuyin = 0;
+	return(0);
+	}
+}
+
+static int
+get_one_zhuyin(pinzhuyin_str,one_pinzhuyin)
+register unsigned char *pinzhuyin_str;
+register char *one_pinzhuyin;
+{
+register w_char  chrtmp;
+for (; !isZY_EOF(chrtmp = (((*pinzhuyin_str<<8)&0xff00)|(*(pinzhuyin_str+1)
+	&0x00ff))) && *pinzhuyin_str != 0; pinzhuyin_str++)
+    *one_pinzhuyin++ = *pinzhuyin_str;
+    if ( isZY_EOF(chrtmp) ) 
+	{
+	*one_pinzhuyin++ = *pinzhuyin_str;
+	pinzhuyin_str++;
+	*one_pinzhuyin++ = *pinzhuyin_str;
+	*one_pinzhuyin = 0;
+	return(1);
+	}
+    else  {
+	*one_pinzhuyin = 0;
+	return(0);
+	}
+}
+
+/* cwnn_is_yincod(c)	To check is "c"is a yincod. 
+	if so, return(1) otherwise return 0*/ 
+int cwnn_is_yincod(c)
+register w_char	 c;
+{
+register int sheng_raw;
+register int yun_raw;
+
+  	if (! _cwnn_isyincod_d(c) ) return (0);
+
+    	sheng_raw = Shengraw(c);
+    	yun_raw = Yunraw(c);
+    	if ( is_pinyin(sheng_raw, yun_raw) ) return(1);
+    	if  ( sheng_raw == X_SHENG_RAW && is_pinyin(EMPTY_SHENG_RAW, yun_raw) == 0)
+      	    return( 1 );
+	else return(0);
+}
+
+/* For a given 'yincod', creat the corresponding Pinyin or Zhuyin
+   to pzy_buf as a w_char string. If the given 'yincod' is not a yincod,
+   'yincod', followed by a NULL is created to pzy_fub.
+   Return: the lenth of pzy_buf is returned.
+   Lenth means the lenth in console but not num of character.
+*/ 
+int  cwnn_yincod_pzy(pzy_buf, c, which )
+register w_char  *pzy_buf;	/* out:    a Pinyin or Zhuyin */
+register w_char  c;		/* input:  a yincod 	*/
+int which;			/* option Pinyin or Zhuyin */
+{
+register int sheng_raw;
+register int yun_raw;
+register int ss;	/* for Sisheng	*/
+register int zytmp;
+
+  if ( ! cwnn_is_yincod(c) ) { 
+	*pzy_buf = c;
+	*(pzy_buf + 1) = 0;
+	return(1);
+
+/*	if ( ((c&0x00ff)>0xa0) && ((c&0x00ff)< 0xff) &&
+	     ((c>>8) > 0xa0) && ((c>>8) < 0xff) )
+		return(2);	
+	else	return(1);
+*/
+  }
+	    
+  sheng_raw = Shengraw(c);
+  yun_raw = Yunraw(c);
+  ss = _cwnn_sisheng(c);
+
+    if  (which == CWNN_PINYIN){		/* For Pinyin case */
+	if (sheng_raw == X_SHENG_RAW && is_pinyin(sheng_raw, yun_raw) == -1 ) 
+	     if ( is_pinyin(EMPTY_SHENG_RAW, yun_raw) == 0 )
+		sheng_raw = EMPTY_SHENG_RAW;
+	cwnn_Sstrcpy(pzy_buf, py_shengmu_tbl[sheng_raw]);
+	if ( _cwnn_has_sisheng(c) ) 
+	    cwnn_Sstrcat(pzy_buf, py_yunmu_tbl[yun_raw*5+ss]);
+	else 
+	    cwnn_Sstrcat(pzy_buf, py_yunmu_tbl[yun_raw*5]);
+    }
+    else {		/* For Zhuyin case */
+
+	zytmp = zhuyin_tbl[sheng_raw * ZY_NUM_YUNMU + yun_raw];
+	if ( is_zhuyin(sheng_raw, yun_raw) == -1 ) {
+	     if ((zytmp & 0x0080)== 0x0080 ){
+	       sheng_raw = (zytmp >>8) & 0x7f;	
+	       yun_raw = zytmp & 0x7f;
+	     }
+	     else {
+	     if ((sheng_raw == X_SHENG_RAW) &&(is_zhuyin(EMPTY_SHENG_RAW,yun_raw)==0))
+		sheng_raw = EMPTY_SHENG_RAW;
+	     }
+ 	}
+	cwnn_Sstrcpy(pzy_buf, zy_shengmu_tbl[sheng_raw]);
+	if ( yun_raw == EMPTY_YUN_RAW ) {
+	    w_char tmp_w;
+	    if ( _cwnn_has_sisheng(c) ) {
+	      switch  (ss) {
+		case 1:
+		    tmp_w = ZY_EOF_1;
+		    break;
+		case 2:
+		    tmp_w = ZY_EOF_2;
+		    break;
+		case 3:
+		    tmp_w = ZY_EOF_3;
+		    break;
+		case 4:
+		    tmp_w = ZY_EOF_4;
+		    break;
+	      }
+	     } else {
+		tmp_w = ZY_EOF_0;
+	     }
+	     wnn_Strncat(pzy_buf, &tmp_w, 1);
+	}
+	else {
+	    if ( _cwnn_has_sisheng(c))
+		  cwnn_Sstrcat(pzy_buf, zy_yunmu_tbl[yun_raw*5+ss]);
+	    else 
+		cwnn_Sstrcat(pzy_buf, zy_yunmu_tbl[yun_raw*5]);
+	}
+  }
+return(wnn_Strlen(pzy_buf));
+}
+
+/* Copy s2 which having yincod to s1 in which yincod are replaced by
+the corresponding Pinyin or Zhuyin. Lenth of s2 is returned
+*/
+int cwnn_yincod_pzy_str(s1, s2, n, which)
+register w_char *s1;	/* result string having Pinyin or Zhuyin */
+register w_char *s2;	/* input string having Yincod */
+int  n;
+int  which;
+{
+    w_char s2tmp[LINE_SIZE];
+    register int i, j;
+    w_char pzy_buf[10];
+    int	len, sum_len;
+
+	len = 0;
+	sum_len = 0;
+    	for (i = 0; i < n;  i++)  s2tmp[i] = s2[i];
+    	for (i = 0; i < n;  i++) {
+
+/*	len = cwnn_yincod_pzy(pzy_buf, s2tmp[i], which);
+	for (j = 0; j < len; j++) 
+		*s1++ = pzy_buf[j];
+	sum_len += len;
+*/
+/* Strlen(pzy_buf) is the num of w_char , but "len" means the width */
+
+	len = cwnn_yincod_pzy(pzy_buf, s2tmp[i], which);
+	for (j = 0; j < wnn_Strlen(pzy_buf); j++) 
+	*s1++ = pzy_buf[j];
+	sum_len += wnn_Strlen(pzy_buf); 
+	}
+	*s1 =0;
+	return(sum_len);
+}
+
+/* cwnn_pzy_yincod(s1, s2, which): 
+After the matching in automaton, the string may be a Pinyin or a Zhuyin
+If so, it will be replace by the coreesponding Yincod */
+
+int cwnn_pzy_yincod(s1, s2, which)
+letter *s1, *s2;
+int which;
+{
+  /*
+  register w_char codetmp2[PY_LEN];
+  register char *codetmp1 = {"          "};
+  */
+  w_char codetmp2_buf[PY_LEN*10+1];
+  char codetmp1_buf[PY_LEN*20+2];
+  register w_char *codetmp2 = codetmp2_buf;
+  register char *codetmp1 = codetmp1_buf;
+  register letter *lettertmp = s2, *s1tmp = s1;
+  register w_char yincod;
+  int len;
+  int conv = 0;
+  w_char save_w[2];
+  char save, tmp[6];
+
+  save_w[0] = save_w[1] = 0;
+	ltoScpy(codetmp2, lettertmp);
+	if (cwnn_sStrcpy(codetmp1, codetmp2) <= 0) return(0);
+
+/*	if ((yincod = pzy_yincod(codetmp1)) != 0) 
+		getstr_pzy(s1, yincod, which);
+
+Jun 13 Zhong */
+	for (;*lettertmp && *lettertmp != EOLTTR;) {
+	    if ( ( yincod = pzy_yincod(codetmp1, &len)) != 0) {
+		conv++;
+		*s1tmp++ = (letter)yincod;
+		save = codetmp1[len];
+		codetmp1[len] = '\0';
+		lettertmp += cwnn_Sstrcpy(codetmp2, codetmp1);
+		codetmp1[len] = save;
+		codetmp1 += len;
+	    } else {
+		save_w[0] = (w_char)(*lettertmp & 0xffff);
+		*s1tmp++ = *lettertmp++;
+		codetmp1 += cwnn_sStrcpy(tmp, save_w);
+	    }
+	}
+	if (*lettertmp == EOLTTR) *s1tmp++ = *lettertmp++;
+	if (conv) {
+	    return(s1tmp - s1);
+	} else {
+	    return(0);
+	}
+}
+
+/* cwnn_py_yincod_str(), cwnn_zy_yincod_str():HUANG: for atod
+	we get yomi as PinYin or ZhuYin strings from ascii-dictionary and
+	translate it to YINcode
+*/
+void
+cwnn_py_yincod_str(yuyin_str, css, un_sisheng_yincod_str, yincod_str)
+register char    *yuyin_str;        /* yomi: PinYin or ZhuYin strings */
+register char    *css;        /* get sisheng strings from PinYin strings */
+register w_char  *un_sisheng_yincod_str; /* no-sisheng Yincod strings */
+register w_char  *yincod_str;            /* Yincod strings with sisheng */
+{
+/*
+  register  char    one_yuyin[LINE_SIZE];
+  register  w_char not_yuyin[LINE_SIZE];
+*/
+  char    one_yuyin_buf[LINE_SIZE];
+  w_char    not_yuyin_buf[LINE_SIZE];
+  register  char    *one_yuyin = one_yuyin_buf;
+  register  w_char    *not_yuyin = not_yuyin_buf;
+  register  int     yin_eof;
+  register  w_char  yincod;
+  register  int     i, pst;
+  int len;
+
+    for ( ; *yuyin_str; ) {
+	yin_eof = get_one_pinyin(yuyin_str, one_yuyin);
+	yuyin_str += strlen(one_yuyin);
+	cwnn_Sstrcpy(not_yuyin,  one_yuyin);
+	pst = find_pinyin(one_yuyin);
+	if ( yin_eof == 1  && pst != -1 ) {
+		for ( i = 0; i < pst; i++ ) {
+			*yincod_str++ = not_yuyin[i];
+			*un_sisheng_yincod_str++ = not_yuyin[i];
+			*css++ = '5';
+			}
+		yincod = pzy_yincod(one_yuyin, &len);
+		*yincod_str ++ = yincod;
+		*un_sisheng_yincod_str++ = _cwnn_yincod_0(yincod);
+		*css++ = (char)(_cwnn_sisheng(yincod) + 0x30);
+	}
+	else {
+		for ( i = 0;  not_yuyin[i]; i++ ) {
+			*yincod_str++ = not_yuyin[i];
+			*un_sisheng_yincod_str++ = not_yuyin[i];
+			*css++ = '5';
+		}
+	}
+    }
+	*yincod_str = 0;
+	*un_sisheng_yincod_str = 0;
+	*css = 0;
+}
+
+void
+cwnn_zy_yincod_str(yuyin_str, css, un_sisheng_yincod_str, yincod_str)
+register char    *yuyin_str;        /* yomi: PinYin or ZhuYin strings */
+register char    *css;        /* get sisheng strings from PinYin strings */
+register w_char  *un_sisheng_yincod_str; /* no-sisheng Yincod strings */
+register w_char  *yincod_str;            /* Yincod strings with sisheng */
+{
+/*
+  register  char    one_yuyin[LINE_SIZE];
+  register  w_char not_yuyin[LINE_SIZE];
+*/
+  char    one_yuyin_buf[LINE_SIZE];
+  w_char    not_yuyin_buf[LINE_SIZE];
+  register  char    *one_yuyin = one_yuyin_buf;
+  register  w_char    *not_yuyin = not_yuyin_buf;
+  register  int     yin_eof;
+  register  w_char  yincod;
+  register  int     i, pst;
+  int len;
+
+    for ( ; *yuyin_str; ) {
+	yin_eof = get_one_zhuyin(yuyin_str, one_yuyin);
+	yuyin_str += strlen(one_yuyin);
+	cwnn_Sstrcpy(not_yuyin,  one_yuyin);
+	pst = find_zhuyin(one_yuyin);
+	if ( yin_eof == 1  && pst != -1 ) {
+		for ( i = 0; i < pst; i++ ) {
+			*yincod_str++ = not_yuyin[i];
+			*un_sisheng_yincod_str++ = not_yuyin[i];
+			*css++ = '5';
+			}
+		yincod = pzy_yincod(one_yuyin, &len);
+		*yincod_str ++ = yincod;
+		*un_sisheng_yincod_str++ = _cwnn_yincod_0(yincod);
+		*css++ = (char)(_cwnn_sisheng(yincod) + 0x30);
+	}
+	else {
+		for ( i = 0;  not_yuyin[i]; i++ ) {
+			*yincod_str++ = not_yuyin[i];
+			*un_sisheng_yincod_str++ = not_yuyin[i];
+			*css++ = '5';
+		}
+	}
+    }
+	*yincod_str = 0;
+	*un_sisheng_yincod_str = 0;
+	*css = 0;
+}
+
+/* cwnn_py_str_analysis(), cp_zy_str_analysis():   HUANG: for atod
+	we get yomi as PinYin or ZhuYin strings from ascii-dictionary 
+	and translate it to YINcode
+*/
+void
+cwnn_py_str_analysis(yuyin_str, css, un_sisheng_yincod_str, yincod_str)
+register char    *yuyin_str;        /* yomi: PinYin or ZhuYin strings */
+register char    *css;    /* get sisheng strings from PinYin strings */
+register w_char  *un_sisheng_yincod_str; /* no-sisheng Yincod strings */
+register w_char  *yincod_str;       /* Yincod strings with sisheng */
+{
+/*
+  register  char    one_yuyin[LINE_SIZE];
+  register  w_char not_yuyin[LINE_SIZE];
+*/
+  char    one_yuyin_buf[LINE_SIZE];
+  w_char    not_yuyin_buf[LINE_SIZE];
+  register  char    *one_yuyin = one_yuyin_buf;
+  register  w_char    *not_yuyin = not_yuyin_buf;
+  register  int     yin_eof;
+  register  w_char  yincod;
+  register  int     i, pst;
+  int len;
+    for ( ; *yuyin_str; ) {
+	yin_eof = get_one_pinyin(yuyin_str, one_yuyin);
+	yuyin_str += strlen(one_yuyin);
+	cwnn_Sstrcpy(not_yuyin,  one_yuyin);
+	pst = find_pinyin(one_yuyin);
+	if ( yin_eof == 1  && pst != -1 ) {
+		for ( i = 0; i < pst; i++ ) {
+			*yincod_str++ = not_yuyin[i];
+			*un_sisheng_yincod_str++ = not_yuyin[i];
+			*css++ = '5';
+			}
+		yincod = pzy_yincod(one_yuyin, &len);
+		*yincod_str ++ = yincod;
+		*un_sisheng_yincod_str++ = _cwnn_yincod_0(yincod);
+		*css++ = (char)(_cwnn_sisheng(yincod) + 0x30);
+	}
+	else {  for ( i = 0;  not_yuyin[i]; i++ ) {
+			*yincod_str++ = not_yuyin[i];
+			*un_sisheng_yincod_str++ = not_yuyin[i];
+			*css++ = '5';
+		}
+	}
+    }
+	*yincod_str = 0;
+	*un_sisheng_yincod_str = 0;
+	*css = 0;
+}
+
+void
+cwnn_zy_str_analysis(yuyin_str, css, un_sisheng_yincod_str, yincod_str)
+register char    *yuyin_str;        /* yomi: PinYin or ZhuYin strings */
+register char    *css;     /* get sisheng strings from PinYin strings */
+register w_char  *un_sisheng_yincod_str; /* no-sisheng Yincod strings */
+register w_char  *yincod_str;      /* Yincod strings with sisheng */
+{
+/*
+  register  char    one_yuyin[LINE_SIZE];
+  register  w_char not_yuyin[LINE_SIZE];
+*/
+  char    one_yuyin_buf[LINE_SIZE];
+  w_char    not_yuyin_buf[LINE_SIZE];
+  register  char    *one_yuyin = one_yuyin_buf;
+  register  w_char    *not_yuyin = not_yuyin_buf;
+  register  int     yin_eof;
+  register  w_char  yincod;
+  register  int     i, pst;
+  int len;
+    for ( ; *yuyin_str; ) {
+	yin_eof = get_one_zhuyin(yuyin_str, one_yuyin);
+	yuyin_str += strlen(one_yuyin);
+	cwnn_Sstrcpy(not_yuyin,  one_yuyin);
+	pst = find_zhuyin(one_yuyin);
+	if ( yin_eof == 1  && pst != -1 ) {
+		for ( i = 0; i < pst; i++ ) {
+			*yincod_str++ = not_yuyin[i];
+			*un_sisheng_yincod_str++ = not_yuyin[i];
+			*css++ = '5';
+			}
+		yincod = pzy_yincod(one_yuyin, &len);
+		*yincod_str ++ = yincod;
+		*un_sisheng_yincod_str++ = _cwnn_yincod_0(yincod);
+		*css++ = (char)(_cwnn_sisheng(yincod) + 0x30);
+	}
+	else {  for ( i = 0;  not_yuyin[i]; i++ ) {
+			*yincod_str++ = not_yuyin[i];
+			*un_sisheng_yincod_str++ = not_yuyin[i];
+			*css++ = '5';
+		}
+	}
+    }
+	*yincod_str = 0;
+	*un_sisheng_yincod_str = 0;
+	*css = 0;
+}
+#endif /* CHINESE */
diff --git a/wnn/zy_table.c b/wnn/zy_table.c
new file mode 100644
index 0000000000000000000000000000000000000000..337bda5b7a870ef228937fc803a9c78bba530ee1
--- /dev/null
+++ b/wnn/zy_table.c
@@ -0,0 +1,298 @@
+/*
+ * $Id: zy_table.c,v 1.1 1996/03/13 09:57:31 colin Exp $
+ */
+/** 		Copyright OMRON Corporation. 1989, 1990, 1991, 1992, 1992
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its 
+ * documentation for any purpose is hereby granted without fee, provided 
+ * that all of the following conditions are satisfied:
+ *
+ * <1>	The above copyright notices appear in all copies
+ * <2>	Both the copyright notices and this permission notice appear in 
+ *	supporting documentation
+ * <3>	The name of "cWnn" isn't changed unless substantial modifications 
+ * 	are made
+ * <4>	Following words followed by the above copyright notices appear
+ *    	in all supporting documentation of software based on "cWnn":
+ *
+ * 	This software is based on the original version of cWnn developed 
+ *	by OMRON Corporation and Wnn developed by Kyoto University Research 
+ *	Institute for Mathematical Sciences (KURIMS), OMRON Corporation and 
+ * 	ASTEC Inc."
+ *
+ * <5>	The names of OMRON may not be used in advertising or publicity 
+ *	pertaining to distribution of the software without specific, written 
+ *	prior permission
+ *
+ *  OMRON Corporation makes no representations about the suitability of this 
+ *  software for any purpose.  It is provided "as is" without express or 
+ *  implied warranty.
+ *
+ *  Wnn consortium is one of distributors of the official Wnn source code
+ *  release.  Wnn consortium also makes no representations about the
+ *  suitability of this software for any purpose.  It is provided "as is"
+ *  without express or implied warranty.
+ *
+ *  OMRON AND WNN CONSORTIUM DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ *  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ *  IN NO EVENT SHALL OMRON OR WNN CONSORTIUM BE LIABLE FOR ANY SPECIAL,
+ *  INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ *  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ *  PERFORMANCE OF THIS SOFTWARE.
+ *
+ *  This sofeware is developed by OMRON Corporation, based on the original 
+ *  version of Wnn which was developed by Kyoto University Research Institute 
+ *  for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc. 
+ *
+ *  	Copyright Kyoto University Research Institute for Mathematical 
+ *		Sciences 1987,1988,1989,1990,1991, 1992
+ * 	Copyright OMRON Corporation 1987,1988,1989,1990,1991, 1992
+ *	Copyright ASTEC Inc. 1987, 1988,1989,1990,1991, 1992
+ *
+ *  Contact:	Tel:   	+81-75-951-5111
+ *		Fax:   	+81-75-955-2442
+ *		E-mail: zhong@ari.ncl.omron.co.jp
+**/
+/**  cWnn  Version 1.1	 **/
+
+#include  <ctype.h>
+#include "commonhd.h"
+#ifdef CHINESE
+#include "cplib.h"
+
+/* zy_shengmu_tbl: ShengMu table of Chinese ZhuYin  */
+char 	*zy_shengmu_tbl[ZY_NUM_SHENGMU] = {
+	
+	"", "��", "��",  "��", "��",    /*	"", "B", "C",  "Ch", "D",   */
+	"��", "��", "��", "��", "��",    /*	"F", "G", "H",  "J",  "K", */
+	"��", "��", "��", "��", "��",    /*	"L", "M", "N",  "P",  "Q",  */
+	"��", "��", "��", "��", "��",    /*	"R", "S", "Sh", "T",  "W",  */
+	"��", "��", "��", "��"          /*	"X", "Y", "Z",  "Zh"   */
+	};
+	
+
+/* zy_yunmu_tbl: YunMu table of Chinese ZhuYin  */
+char 	*zy_yunmu_tbl[ZY_NUM_YUNMU*5] = {
+/* 3.20
+	"",     "",     "",      "",      "", 
+*/
+	"��",   "��",   "��",    "��",    "��",		/* a 	*/
+	"�ڎ�",   "�ڎ�",   "�ڎ�",    "�ڎ�",    "�ڎ�",		/* a 	*/
+	"�ގ�",   "�ގ�",   "�ގ�",    "�ގ�",    "�ގ�",		/* ai 	*/
+	"���",   "���",   "���",    "���",    "���",		/* an 	*/
+	"���",   "���",   "���",    "���",    "���",		/* ang 	*/
+	"����",   "����",   "����",    "����",    "����",		/* ao 	*/
+	"�܎�",   "�܎�",   "�܎�",    "�܎�",    "�܎�",		/* e 	*/
+	"�ߎ�",   "�ߎ�",   "�ߎ�",    "�ߎ�",    "�ߎ�",		/* ei 	*/
+	"���",   "���",   "���",    "���",    "���",		/* en 	*/
+	"���",   "���",   "���",    "���",    "���",		/* eng 	*/
+	"���",   "���",   "���",    "���",    "���",		/* er 	*/
+	"���",   "���",   "���",    "���",    "���",		/* i	*/
+	"��ڎ�",  "��ڎ�",  "��ڎ�",   "��ڎ�",   "��ڎ�",	/* ia	*/
+	"����",  "����",  "����",   "����",   "����",	/* ian	*/
+	"����",  "����",  "����",   "����",   "����",	/* iang	*/
+	"�����",  "�����",  "�����",   "�����",   "�����",	/* iao	*/
+	"��ݎ�",  "��ݎ�",  "��ݎ�",   "��ݎ�",   "��ݎ�",	/* ie	*/
+	"����",  "����",  "����",   "����",   "����",	/* in	*/
+	"����",  "����",  "����",   "����",   "����",	/* ing	*/
+	"����",  "����",  "����",   "����",   "����",	/* iong	*/
+	"����",  "����",  "����",   "����",   "����",	/* iu	*/
+	"�ǎ�",   "�ǎ�",   "�ǎ�",    "�ǎ�",    "�ǎ�",		/* m	*/
+	"�ˎ�",   "�ˎ�",   "�ˎ�",    "�ˎ�",    "�ˎ�",		/* n 	*/
+	"@��",    "@��",   "@��",    "@��",    "@��",	/* ng	*/
+	"�ێ�",   "�ێ�",   "�ێ�",    "�ێ�",    "�ێ�",		/* o 	*/
+	"����",  "����",  "����",   "����",   "����",	/* ong	*/
+	"���",   "���",   "���",    "���",    "���",		/* ou	*/
+	"���",   "���",   "���",    "���",    "���",		/* u	*/
+	"��ڎ�",  "��ڎ�",  "��ڎ�",   "��ڎ�",   "��ڎ�",	/* ua	*/
+	"��ގ�",  "��ގ�",  "��ގ�",   "��ގ�",   "��ގ�",	/* uai	*/
+	"����",  "����",  "����",   "����",   "����",	/* uan	*/
+	"����",  "����",  "����",   "����",   "����",	/* uang	*/
+	"��ݎ�",  "��ݎ�",  "��ݎ�",   "��ݎ�",   "��ݎ�",	/* ue	*/
+	"��ߎ�",  "��ߎ�",  "��ߎ�",   "��ߎ�",   "��ߎ�",	/* ui	*/
+	"����",  "����",  "����",   "����",   "����",	/* un 	*/
+	"��ێ�",  "��ێ�",  "��ێ�",   "��ێ�",   "��ێ�",	/* uo	*/
+	"���",   "���",   "���",    "���",    "���",		/* ��	*/
+	"��ݎ�",  "��ݎ�",  "��ݎ�",   "��ݎ�",   "��ݎ�",	/* ��e	*/
+	"0��",    "1��",    "2��",     "3��",     "4��",	/* undefinited YunMu */
+	"����",  "����",  "����",   "����",   "����",	/* ��an,	only ZhuYin */
+	"����",  "����",  "����",   "����",   "����",	/* ��n,	only ZhuYin */
+	};
+
+
+/* zhuyin_tbl:  size is ZY_NUM_SHENGMU*ZY_NUM_YUNMU, including empty ShengMu */
+/*      	empty YunMu and undefinited ShengMu '-' */
+
+int  zhuyin_tbl[ZY_NUM_SHENGMU*ZY_NUM_YUNMU] = {
+					    	
+/* empty ShengMu */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X0000,0X0000,0X0000,0X0000,0X0000,0X9586,0X0000,0X9592,0X9599,
+0X0000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X959B,0X95A0,0X0000,0X959E,
+0X95A2,
+
+/* SHengMu B */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,0X8000,0X8000,
+0X0000,0X8000,0X0000,0X8000,0X0000,0X8000,0X8000,0X8000,0X8000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,0X0000,0X8000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu C */
+0X828B,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,0X8000,
+0X0000,0X0280,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,
+0X8000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu Ch */
+0X838B,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,0X8000,
+0X0000,0X0380,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X8000,
+0X8000,0X8000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu D */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X8000,0X8000,0X8000,0X0000,0X8000,0X8000,0X0000,0X8000,0X0000,
+0X8000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,
+0X8000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu F */
+0X0000,0X8000,0X0000,0X8000,0X8000,0X0000,0X0000,0X8000,0X8000,0X8000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,0X8000,0X8000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu G */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X8000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu H */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X8000,0X0000,0X8000,0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X8000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu J */
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X08A4,0X0000,0X0000,
+0X08A7,0X0000,0X08A5,0X0000,0X08A8,0X0000,0X889B,0X88A0,0X8000,0X889E,
+0X88A2,
+
+/* ShengMu K */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X8000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu L */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,
+0X8000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,0X0000,0X0000,
+0X8000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu M */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X8000,0X0000,0X8000,0X0000,0X8000,0X8000,0X8000,0X8000,0X0000,
+0X8000,0X0000,0X0000,0X0000,0X8000,0X0000,0X8000,0X8000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu N */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X8000,0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,
+0X8000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,
+0X8000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu P */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,0X8000,0X8000,
+0X0000,0X8000,0X0000,0X8000,0X0000,0X8000,0X8000,0X8000,0X8000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,0X8000,0X8000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu Q */
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0EA4,0X0000,0X0000,
+0X0EA7,0X0000,0X0EA5,0X0000,0X0EA8,0X0000,0X8E9B,0X8EA0,0X8000,0X8E9E,
+0X8EA2,
+
+/* ShengMu R */
+0X8F8B,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,0X8000,
+0X0000,0X0F80,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,0X0000,
+0X8000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu S */
+0X908B,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,0X8000,
+0X0000,0X1080,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,
+0X8000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu Sh */
+0X918B,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X1180,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X8000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu T */
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X0000,0X8000,
+0X0000,0X8000,0X0000,0X8000,0X0000,0X8000,0X8000,0X0000,0X8000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,
+0X8000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu W */
+0X939B,0X8000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X8000,0X8000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,0X0000,0X1380,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu X */
+0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X14A4,0X0000,0X0000,
+0X14A7,0X0000,0X14A5,0X0000,0X14A8,0X0000,0X949B,0X94A0,0X8000,0X949E,
+0X94A2,
+
+/* ShengMu Y */ 
+0X958B,0X8000,0X0000,0X8000,0X8000,0X8000,0X0090,0X0000,0X9591,0X9592,
+0X0000,0X1580,0X0000,0X0000,0X0000,0X0000,0X0000,0X1588,0X1589,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X8000,0X0093,0X8000,0X00A4,0X0000,0X0000,
+0X00A7,0X0000,0X00A5,0X0000,0X00A8,0X0000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu Z */
+0X968B,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X1680,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,
+0X8000,0X0000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+/* ShengMu Zh  */
+0X978B,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X0000,0X1780,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,0X0000,
+0X0000,0X0000,0X0000,0X0000,0X0000,0X8000,0X8000,0X8000,0X8000,0X8000,
+0X8000,0X8000,0X0000,0X8000,0X8000,0X8000,0X0000,0X0000,0X8000,0X0000,
+0X0000,
+
+	};
+#endif /* CHINESE */