home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume20 / kdrill / part01 < prev    next >
Encoding:
Text File  |  1993-07-14  |  42.6 KB  |  1,623 lines

  1. Newsgroups: comp.sources.x
  2. From: philb@cats.UCSC.EDU (Philip Brown)
  3. Subject: v20i095:  kdrill - Kanji drill program, Part01/01
  4. Message-ID: <1993Jul15.204759.8834@sparky.sterling.com>
  5. X-Md4-Signature: c2de2a501c5dca4c92502a2552d2b01f
  6. Sender: chris@sparky.sterling.com (Chris Olson)
  7. Organization: Sterling Software
  8. Date: Thu, 15 Jul 1993 20:47:59 GMT
  9. Approved: chris@sterling.com
  10.  
  11. Submitted-by: philb@cats.UCSC.EDU (Philip Brown)
  12. Posting-number: Volume 20, Issue 95
  13. Archive-name: kdrill/part01
  14. Environment: X11R5, kanji-font
  15.  
  16. [ I was unable to test this (no kanji-dict or kanji font), but it compiles ]
  17. [ just fine.                                                               ]
  18. [        Chris                               ]
  19.  
  20. an R5 kanji<->english "flashcard" like program.
  21. uses "kanjidic". information on where to get this
  22. dictionary is in the readme.
  23.  
  24. #! /bin/sh
  25. #! /bin/sh
  26. # This is a shell archive.  Remove anything before this line, then feed it
  27. # into a shell via "sh file" or similar.  To overwrite existing files,
  28. # type "sh file -c".
  29. # Contents:  README Imakefile KDrill Makefile defs.h externs.h game.c
  30. #   init.c kdrill.man main.c patchlevel.h readfile.c usefile
  31. # Wrapped by chris@sparky on Thu Jul 15 15:40:47 1993
  32. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  33. echo If this archive is complete, you will see the following message:
  34. echo '          "shar: End of archive 1 (of 1)."'
  35. if test -f 'README' -a "${1}" != "-c" ; then 
  36.   echo shar: Will not clobber existing file \"'README'\"
  37. else
  38.   echo shar: Extracting \"'README'\" \(2157 characters\)
  39.   sed "s/^X//" >'README' <<'END_OF_FILE'
  40. X  README file for kanjidrill   oct 2, 1992
  41. X     (by Philip Brown)
  42. X
  43. X  Here is a program to quiz folks on either english-to-kanji, or
  44. Xkanji-to-english. It will quiz you on either the whole dictionary [around
  45. X6000 kanji?]  OR specific kanji, if you give the JIS-number in the
  46. X"usefile".
  47. X
  48. X  For the usefile, one number per entry, in hex, at the beginning of the
  49. Xline. NO TRAILING SPACE!! Anything after will be treated as a comment, so
  50. Xyou can notate the meaning of each kanji. A nifty useful usefile is
  51. Xincluded.
  52. X
  53. X  I use the PD kanjidic file from monu6.cc.monash.edu.au: I do not include
  54. Xit, as it is 400K. There is also a mirror at ftp.uwtc.washington.edu, but
  55. Xthey have not updated to the latest version as of this writing.
  56. X
  57. XUnfortunately.. they recently changed the format of the latest version.
  58. XI have simplified my parsing to account for all versions.
  59. X
  60. XThe format of any kanjidic file used (does not have to be the latest
  61. Xversion) should be:
  62. X
  63. Xkk 3333 .... {english} {english}
  64. X
  65. XWhere kk is the 16-bit kanji value seen as two 8-bit vals.(MSB,LSB)
  66. X'x' is any char, '....' is any char any number of times,
  67. X and the {english} segments may be any number, but there must be at least
  68. Xone, or the entry will be ignored. I hope. Note that the braces {} MUST
  69. Xbe included there.
  70. X
  71. X  Future releases MAY include quizzing on kana-to-kanji, etc, etc. but that
  72. Xwill be annoying to program, so may never happen. If someone ELSE wants
  73. Xto add it, feel free, and mail me so.
  74. XNote that you can make your own romaji quizzes, and add kana quizzes, by
  75. Xadding/fiddling with the lines of the dictionary. I should probably
  76. Xinclude a little sample of that.
  77. X
  78. X   The neat thing about programming this drill, is that it uses the Kanji in
  79. Xthe kanji24 Xwindows font, so we don't have to store extra graphics.
  80. XAdding new entries to the usefile is fairly simple. grep through the
  81. Xdictionary for potential numbers, then use "xfd -fn kanji24" to check out
  82. Xwhat the characters actually look like. Note that you have to click "Next
  83. XPage" MANY times before getting to the actual kanji section.
  84. X
  85. XPhilip Brown
  86. Xphilb@soda.berkeley.edu
  87. X [and hopefully for the next year or so, philb@cats.ucsc.edu]
  88. X
  89. END_OF_FILE
  90.   if test 2157 -ne `wc -c <'README'`; then
  91.     echo shar: \"'README'\" unpacked with wrong size!
  92.   fi
  93.   # end of 'README'
  94. fi
  95. if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  96.   echo shar: Will not clobber existing file \"'Imakefile'\"
  97. else
  98.   echo shar: Extracting \"'Imakefile'\" \(323 characters\)
  99.   sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
  100. XDEPLIBS = $(DEPXLIB)
  101. X/* Sun compilations require having the XMU lib here...
  102. X * I don't know about "normal" systems
  103. X */
  104. XLOCAL_LIBRARIES = $(XLIB) $(XTOOLLIB) $(XAWLIB) $(XMULIB)
  105. XINCLUDES = -I/usr/X11R5/include/X11
  106. X
  107. X
  108. XSRCS = main.c readfile.c game.c init.c
  109. XOBJS = main.o readfile.o game.o init.o
  110. X
  111. XComplexProgramTarget(kdrill)
  112. END_OF_FILE
  113.   if test 323 -ne `wc -c <'Imakefile'`; then
  114.     echo shar: \"'Imakefile'\" unpacked with wrong size!
  115.   fi
  116.   # end of 'Imakefile'
  117. fi
  118. if test -f 'KDrill' -a "${1}" != "-c" ; then 
  119.   echo shar: Will not clobber existing file \"'KDrill'\"
  120. else
  121.   echo shar: Extracting \"'KDrill'\" \(125 characters\)
  122.   sed "s/^X//" >'KDrill' <<'END_OF_FILE'
  123. X!This resource file is NOT CHECKED (I think),
  124. X!But try it anyways if it works for you.
  125. XKDrill*width:    400
  126. XKDrill*height:    300
  127. X
  128. END_OF_FILE
  129.   if test 125 -ne `wc -c <'KDrill'`; then
  130.     echo shar: \"'KDrill'\" unpacked with wrong size!
  131.   fi
  132.   # end of 'KDrill'
  133. fi
  134. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  135.   echo shar: Will not clobber existing file \"'Makefile'\"
  136. else
  137.   echo shar: Extracting \"'Makefile'\" \(10450 characters\)
  138.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  139. X# Makefile generated by imake - do not edit!
  140. X# $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $
  141. X#
  142. X# The cpp used on this machine replaces all newlines and multiple tabs and
  143. X# spaces in a macro expansion with a single space.  Imake tries to compensate
  144. X# for this, but is not always successful.
  145. X#
  146. X
  147. X# -------------------------------------------------------------------------
  148. X# Makefile generated from "Imake.tmpl" and <Imakefile>
  149. X# $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  150. X#
  151. X# Platform-specific parameters may be set in the appropriate <vendor>.cf
  152. X# configuration files.  Site-specific parameters should be set in the file
  153. X# site.def.  Full rebuilds are recommended if any parameters are changed.
  154. X#
  155. X# If your C preprocessor does not define any unique symbols, you will need
  156. X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
  157. X# "make World" the first time).
  158. X#
  159. X
  160. X# -------------------------------------------------------------------------
  161. X# site-specific configuration parameters that need to come before
  162. X# the platform-specific parameters - edit site.def to change
  163. X
  164. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  165. X
  166. X# -------------------------------------------------------------------------
  167. X# platform-specific configuration parameters - edit sun.cf to change
  168. X
  169. X# platform:  $XConsortium: sun.cf,v 1.72.1.1 92/03/18 13:13:37 rws Exp $
  170. X
  171. X# operating system:  SunOS 4.1.1
  172. X
  173. X# $XConsortium: sunLib.rules,v 1.7 91/12/20 11:19:47 rws Exp $
  174. X
  175. X# -------------------------------------------------------------------------
  176. X# site-specific configuration parameters that go after
  177. X# the platform-specific parameters - edit site.def to change
  178. X
  179. X# site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  180. X
  181. X            SHELL = /bin/sh
  182. X
  183. X              TOP = .
  184. X      CURRENT_DIR = .
  185. X
  186. X               AR = ar clq
  187. X  BOOTSTRAPCFLAGS =
  188. X               CC = cc
  189. X               AS = as
  190. X
  191. X         COMPRESS = compress
  192. X              CPP = /lib/cpp $(STD_CPP_DEFINES)
  193. X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
  194. X          INSTALL = install
  195. X               LD = ld
  196. X             LINT = lint
  197. X      LINTLIBFLAG = -C
  198. X         LINTOPTS = -axz
  199. X               LN = ln -s
  200. X             MAKE = make
  201. X               MV = mv
  202. X               CP = cp
  203. X
  204. X           RANLIB = ranlib
  205. X  RANLIBINSTFLAGS =
  206. X
  207. X               RM = rm -f
  208. X            TROFF = psroff
  209. X         MSMACROS = -ms
  210. X              TBL = tbl
  211. X              EQN = eqn
  212. X     STD_INCLUDES =
  213. X  STD_CPP_DEFINES =
  214. X      STD_DEFINES =
  215. X EXTRA_LOAD_FLAGS =
  216. X  EXTRA_LIBRARIES =
  217. X             TAGS = ctags
  218. X
  219. X    SHAREDCODEDEF = -DSHAREDCODE
  220. X         SHLIBDEF = -DSUNSHLIB
  221. X
  222. X    PROTO_DEFINES =
  223. X
  224. X     INSTPGMFLAGS =
  225. X
  226. X     INSTBINFLAGS = -m 0755
  227. X     INSTUIDFLAGS = -m 4755
  228. X     INSTLIBFLAGS = -m 0644
  229. X     INSTINCFLAGS = -m 0444
  230. X     INSTMANFLAGS = -m 0444
  231. X     INSTDATFLAGS = -m 0444
  232. X    INSTKMEMFLAGS = -g kmem -m 2755
  233. X
  234. X      PROJECTROOT = /usr/X11R5
  235. X
  236. X     TOP_INCLUDES = -I$(INCROOT)
  237. X
  238. X      CDEBUGFLAGS = -O
  239. X        CCOPTIONS = -pipe
  240. X
  241. X      ALLINCLUDES = $(INCLUDES) $(EXTRA_INCLUDES) $(TOP_INCLUDES) $(STD_INCLUDES)
  242. X       ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(EXTRA_DEFINES) $(PROTO_DEFINES) $(DEFINES)
  243. X           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES)
  244. X        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES)
  245. X
  246. X           LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  247. X
  248. X        LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  249. X
  250. X   LDCOMBINEFLAGS = -X -r
  251. X      DEPENDFLAGS =
  252. X
  253. X        MACROFILE = sun.cf
  254. X           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut
  255. X
  256. X    IMAKE_DEFINES =
  257. X
  258. X         IRULESRC = $(CONFIGDIR)
  259. X        IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES)
  260. X
  261. X     ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
  262. X            $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
  263. X            $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
  264. X
  265. X# -------------------------------------------------------------------------
  266. X# X Window System Build Parameters
  267. X# $XConsortium: Project.tmpl,v 1.138 91/09/10 09:02:12 rws Exp $
  268. X
  269. X# -------------------------------------------------------------------------
  270. X# X Window System make variables; this need to be coordinated with rules
  271. X
  272. X          PATHSEP = /
  273. X        USRLIBDIR = /usr/X11R5/lib
  274. X           BINDIR = /usr/X11R5/bin
  275. X          INCROOT = /usr/X11R5/include
  276. X     BUILDINCROOT = $(TOP)
  277. X      BUILDINCDIR = $(BUILDINCROOT)/X11
  278. X      BUILDINCTOP = ..
  279. X           INCDIR = $(INCROOT)/X11
  280. X           ADMDIR = /usr/adm
  281. X           LIBDIR = $(USRLIBDIR)/X11
  282. X        CONFIGDIR = $(LIBDIR)/config
  283. X       LINTLIBDIR = $(USRLIBDIR)/lint
  284. X
  285. X          FONTDIR = $(LIBDIR)/fonts
  286. X         XINITDIR = $(LIBDIR)/xinit
  287. X           XDMDIR = $(LIBDIR)/xdm
  288. X           TWMDIR = $(LIBDIR)/twm
  289. X          MANPATH = /usr/X11R5/man
  290. X    MANSOURCEPATH = $(MANPATH)/man
  291. X        MANSUFFIX = 1
  292. X     LIBMANSUFFIX = 3
  293. X           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)
  294. X        LIBMANDIR = $(MANSOURCEPATH)$(LIBMANSUFFIX)
  295. X           NLSDIR = $(LIBDIR)/nls
  296. X        PEXAPIDIR = $(LIBDIR)/PEX
  297. X      XAPPLOADDIR = $(LIBDIR)/app-defaults
  298. X       FONTCFLAGS = -t
  299. X
  300. X     INSTAPPFLAGS = $(INSTDATFLAGS)
  301. X
  302. X            IMAKE = imake
  303. X           DEPEND = makedepend
  304. X              RGB = rgb
  305. X
  306. X            FONTC = bdftopcf
  307. X
  308. X        MKFONTDIR = mkfontdir
  309. X        MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier
  310. X
  311. X        CONFIGSRC = $(TOP)/config
  312. X       DOCUTILSRC = $(TOP)/doc/util
  313. X        CLIENTSRC = $(TOP)/clients
  314. X          DEMOSRC = $(TOP)/demos
  315. X           LIBSRC = $(TOP)/lib
  316. X          FONTSRC = $(TOP)/fonts
  317. X       INCLUDESRC = $(TOP)/X11
  318. X        SERVERSRC = $(TOP)/server
  319. X          UTILSRC = $(TOP)/util
  320. X        SCRIPTSRC = $(UTILSRC)/scripts
  321. X       EXAMPLESRC = $(TOP)/examples
  322. X       CONTRIBSRC = $(TOP)/../contrib
  323. X           DOCSRC = $(TOP)/doc
  324. X           RGBSRC = $(TOP)/rgb
  325. X        DEPENDSRC = $(UTILSRC)/makedepend
  326. X         IMAKESRC = $(CONFIGSRC)
  327. X         XAUTHSRC = $(LIBSRC)/Xau
  328. X          XLIBSRC = $(LIBSRC)/X
  329. X           XMUSRC = $(LIBSRC)/Xmu
  330. X       TOOLKITSRC = $(LIBSRC)/Xt
  331. X       AWIDGETSRC = $(LIBSRC)/Xaw
  332. X       OLDXLIBSRC = $(LIBSRC)/oldX
  333. X      XDMCPLIBSRC = $(LIBSRC)/Xdmcp
  334. X      BDFTOSNFSRC = $(FONTSRC)/bdftosnf
  335. X      BDFTOSNFSRC = $(FONTSRC)/clients/bdftosnf
  336. X      BDFTOPCFSRC = $(FONTSRC)/clients/bdftopcf
  337. X     MKFONTDIRSRC = $(FONTSRC)/clients/mkfontdir
  338. X         FSLIBSRC = $(FONTSRC)/lib/fs
  339. X    FONTSERVERSRC = $(FONTSRC)/server
  340. X     EXTENSIONSRC = $(TOP)/extensions
  341. X         XILIBSRC = $(EXTENSIONSRC)/lib/xinput
  342. X      PHIGSLIBSRC = $(EXTENSIONSRC)/lib/PEX
  343. X
  344. X# $XConsortium: sunLib.tmpl,v 1.14.1.1 92/03/17 14:58:46 rws Exp $
  345. X
  346. XSHLIBLDFLAGS = -assert pure-text
  347. XPICFLAGS = -pic
  348. X
  349. X  DEPEXTENSIONLIB =
  350. X     EXTENSIONLIB = -lXext
  351. X
  352. X          DEPXLIB = $(DEPEXTENSIONLIB)
  353. X             XLIB = $(EXTENSIONLIB) -lX11
  354. X
  355. X        DEPXMULIB = $(USRLIBDIR)/libXmu.sa.$(SOXMUREV)
  356. X       XMULIBONLY = -lXmu
  357. X           XMULIB = -lXmu
  358. X
  359. X       DEPOLDXLIB =
  360. X          OLDXLIB = -loldX
  361. X
  362. X      DEPXTOOLLIB = $(USRLIBDIR)/libXt.sa.$(SOXTREV)
  363. X         XTOOLLIB = -lXt
  364. X
  365. X        DEPXAWLIB = $(USRLIBDIR)/libXaw.sa.$(SOXAWREV)
  366. X           XAWLIB = -lXaw
  367. X
  368. X        DEPXILIB =
  369. X           XILIB = -lXi
  370. X
  371. X        SOXLIBREV = 4.10
  372. X          SOXTREV = 4.10
  373. X         SOXAWREV = 5.0
  374. X        SOOLDXREV = 4.10
  375. X         SOXMUREV = 4.10
  376. X        SOXEXTREV = 4.10
  377. X      SOXINPUTREV = 4.10
  378. X
  379. X      DEPXAUTHLIB = $(USRLIBDIR)/libXau.a
  380. X         XAUTHLIB =  -lXau
  381. X      DEPXDMCPLIB = $(USRLIBDIR)/libXdmcp.a
  382. X         XDMCPLIB =  -lXdmcp
  383. X
  384. X        DEPPHIGSLIB = $(USRLIBDIR)/libphigs.a
  385. X           PHIGSLIB =  -lphigs
  386. X
  387. X       DEPXBSDLIB = $(USRLIBDIR)/libXbsd.a
  388. X          XBSDLIB =  -lXbsd
  389. X
  390. X LINTEXTENSIONLIB = $(LINTLIBDIR)/llib-lXext.ln
  391. X         LINTXLIB = $(LINTLIBDIR)/llib-lX11.ln
  392. X          LINTXMU = $(LINTLIBDIR)/llib-lXmu.ln
  393. X        LINTXTOOL = $(LINTLIBDIR)/llib-lXt.ln
  394. X          LINTXAW = $(LINTLIBDIR)/llib-lXaw.ln
  395. X           LINTXI = $(LINTLIBDIR)/llib-lXi.ln
  396. X        LINTPHIGS = $(LINTLIBDIR)/llib-lphigs.ln
  397. X
  398. X          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
  399. X
  400. X         DEPLIBS1 = $(DEPLIBS)
  401. X         DEPLIBS2 = $(DEPLIBS)
  402. X         DEPLIBS3 = $(DEPLIBS)
  403. X
  404. X# -------------------------------------------------------------------------
  405. X# Imake rules for building libraries, programs, scripts, and data files
  406. X# rules:  $XConsortium: Imake.rules,v 1.123 91/09/16 20:12:16 rws Exp $
  407. X
  408. X# -------------------------------------------------------------------------
  409. X# start of Imakefile
  410. X
  411. XDEPLIBS = $(DEPXLIB)
  412. X
  413. XLOCAL_LIBRARIES = $(XLIB) $(XTOOLLIB) $(XAWLIB) $(XMULIB)
  414. XINCLUDES = -I/usr/X11R5/include/X11
  415. X
  416. XSRCS = main.c readfile.c game.c init.c
  417. XOBJS = main.o readfile.o game.o init.o
  418. X
  419. X PROGRAM = kdrill
  420. X
  421. Xall:: kdrill
  422. X
  423. Xkdrill: $(OBJS) $(DEPLIBS)
  424. X    $(RM) $@
  425. X    $(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS)
  426. X
  427. Xsaber_kdrill:: $(SRCS)
  428. X    # load $(ALLDEFINES) $(SRCS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  429. X
  430. Xosaber_kdrill:: $(OBJS)
  431. X    # load $(ALLDEFINES) $(OBJS) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES)
  432. X
  433. Xinstall:: kdrill
  434. X    @if [ -d $(DESTDIR)$(BINDIR) ]; then set +x; \
  435. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(BINDIR)); fi
  436. X    $(INSTALL) -c $(INSTPGMFLAGS)  kdrill $(DESTDIR)$(BINDIR)
  437. X
  438. Xinstall.man:: kdrill.man
  439. X    @if [ -d $(DESTDIR)$(MANDIR) ]; then set +x; \
  440. X    else (set -x; $(MKDIRHIER) $(DESTDIR)$(MANDIR)); fi
  441. X    $(INSTALL) -c $(INSTMANFLAGS) kdrill.man $(DESTDIR)$(MANDIR)/kdrill.$(MANSUFFIX)
  442. X
  443. Xdepend::
  444. X    $(DEPEND) $(DEPENDFLAGS) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
  445. X
  446. Xlint:
  447. X    $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
  448. Xlint1:
  449. X    $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
  450. X
  451. Xclean::
  452. X    $(RM) $(PROGRAM)
  453. X
  454. X# -------------------------------------------------------------------------
  455. X# common rules for all Makefiles - do not edit
  456. X
  457. Xemptyrule::
  458. X
  459. Xclean::
  460. X    $(RM_CMD) "#"*
  461. X
  462. XMakefile::
  463. X    -@if [ -f Makefile ]; then set -x; \
  464. X    $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
  465. X    else exit 0; fi
  466. X    $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR)
  467. X
  468. Xtags::
  469. X    $(TAGS) -w *.[ch]
  470. X    $(TAGS) -xw *.[ch] > TAGS
  471. X
  472. Xsaber:
  473. X    # load $(ALLDEFINES) $(SRCS)
  474. X
  475. Xosaber:
  476. X    # load $(ALLDEFINES) $(OBJS)
  477. X
  478. X# -------------------------------------------------------------------------
  479. X# empty rules for directories that do not have SUBDIRS - do not edit
  480. X
  481. Xinstall::
  482. X    @echo "install in $(CURRENT_DIR) done"
  483. X
  484. Xinstall.man::
  485. X    @echo "install.man in $(CURRENT_DIR) done"
  486. X
  487. XMakefiles::
  488. X
  489. Xincludes::
  490. X
  491. X# -------------------------------------------------------------------------
  492. X# dependencies generated by makedepend
  493. X
  494. END_OF_FILE
  495.   if test 10450 -ne `wc -c <'Makefile'`; then
  496.     echo shar: \"'Makefile'\" unpacked with wrong size!
  497.   fi
  498.   # end of 'Makefile'
  499. fi
  500. if test -f 'defs.h' -a "${1}" != "-c" ; then 
  501.   echo shar: Will not clobber existing file \"'defs.h'\"
  502. else
  503.   echo shar: Extracting \"'defs.h'\" \(1008 characters\)
  504.   sed "s/^X//" >'defs.h' <<'END_OF_FILE'
  505. X#define KANJIFONT "kanji24"
  506. X#define KANJIFILE "kanjidic"
  507. X#define WINDOWHEIGHT 250
  508. X#define WINDOWWIDTH  400
  509. X#define USEFILE "usefile"
  510. X
  511. Xextern int errno;
  512. X
  513. Xstruct translationstruct {
  514. X
  515. X    char *pronunciation;/* not used, currently */
  516. X    char *english;    /* english translation string.
  517. X             * null-terminated.
  518. X             * Can theoretically be any length, but
  519. X             * since it will all be on a single-line
  520. X             * text widget, that would be silly
  521. X             */
  522. X};
  523. X
  524. X/********************************************************************
  525. X
  526. XSO here's the format for the translation/dictionary file I have decided
  527. Xon so far:
  528. X
  529. XI changed specs. it will have to be in "kanjidic" format...
  530. X
  531. XTwo char high-bit-set identifier, followed by JIS number in hex.
  532. XFollowed by stroke information? [HAS TO BE TERMINATED BY 'Gx', where
  533. X                  'x' is any number]
  534. XFollowed by pronunciation guide, in kana.
  535. XFollowed by various english translations, enclosed in {}
  536. X
  537. X"kanjidic" often has multiple {} phrases. which leads to another nasty
  538. Xhack  in readstructs()
  539. X
  540. X*/
  541. END_OF_FILE
  542.   if test 1008 -ne `wc -c <'defs.h'`; then
  543.     echo shar: \"'defs.h'\" unpacked with wrong size!
  544.   fi
  545.   # end of 'defs.h'
  546. fi
  547. if test -f 'externs.h' -a "${1}" != "-c" ; then 
  548.   echo shar: Will not clobber existing file \"'externs.h'\"
  549. else
  550.   echo shar: Extracting \"'externs.h'\" \(655 characters\)
  551.   sed "s/^X//" >'externs.h' <<'END_OF_FILE'
  552. Xextern struct translationstruct *translations[0x8000];
  553. Xextern int lowest,highest;    /* keep track of how many we have */
  554. Xextern char *dictname;
  555. X
  556. Xextern int game(),xtoi(),getline();
  557. Xvoid readstructs(),readstructs(),kprint(),eprint();
  558. Xextern void englishcallback();
  559. Xextern void kanjicallback();
  560. Xextern void changemode();
  561. X
  562. Xextern void quit();
  563. Xextern XtAppContext Context;
  564. X
  565. Xextern unsigned long black,white;
  566. Xextern Display *display;
  567. Xextern Window mainwindow,rootwindow;
  568. Xextern Widget toplevel,form,quitbutton,statusline;
  569. Xextern Widget kanjimode,englishmode;
  570. Xextern Widget englishWidget[4],kanjiWidget[4];
  571. Xextern Pixmap kanjiPixmap[4];
  572. Xextern GC gc,kgc,cleargc;
  573. END_OF_FILE
  574.   if test 655 -ne `wc -c <'externs.h'`; then
  575.     echo shar: \"'externs.h'\" unpacked with wrong size!
  576.   fi
  577.   # end of 'externs.h'
  578. fi
  579. if test -f 'game.c' -a "${1}" != "-c" ; then 
  580.   echo shar: Will not clobber existing file \"'game.c'\"
  581. else
  582.   echo shar: Extracting \"'game.c'\" \(6243 characters\)
  583.   sed "s/^X//" >'game.c' <<'END_OF_FILE'
  584. X#define GUESSKANJI 1
  585. X#define GUESSENGLISH 0
  586. X
  587. X#include <stdio.h>
  588. X#include <X11/Xlib.h>
  589. X#include <X11/Xatom.h>
  590. X#include <X11/Xutil.h>
  591. X#include <Intrinsic.h>
  592. X#include <StringDefs.h>
  593. X
  594. X#include "defs.h"
  595. X#include "externs.h"
  596. X
  597. Xint values[4];
  598. Xint truevalue;
  599. Xint Kanji2English=1;
  600. X
  601. Xextern Display *display;
  602. Xextern Window mainwindow;
  603. X
  604. Xint englishwidth=7;
  605. Xint englishheight=11;
  606. X
  607. X/* setstatus:
  608. X *  sets label for main status widget.
  609. X *    ( the long one at the bottom)
  610. X */
  611. Xvoid setstatus(s)
  612. Xchar *s;
  613. X{
  614. X    XtVaSetValues(statusline,
  615. X              XtNlabel,s,
  616. X              NULL);
  617. X}
  618. X
  619. X/* pickkanji:
  620. X *   picks an acceptably random kanji char
  621. X */
  622. X
  623. Xint pickkanji(){
  624. X    int i,span;
  625. X    span = highest - lowest;
  626. X
  627. X    i = (random()%span) + lowest;
  628. X    while((translations[i] == NULL) || (translations[i] == (void *) 1)){
  629. X        i= (i+1)% (highest+1);
  630. X        if(i==0) i = (random()%span) + lowest;
  631. X    }
  632. X    return i;
  633. X
  634. X}
  635. X
  636. X/* printkanji:
  637. X *    updates all the kanji buttons.
  638. X *    uses a nasty hack to get the buttons to update/grey out  properly,
  639. X *    since we use BITMAPS for the kanji
  640. X */
  641. X
  642. Xvoid printkanji(){
  643. X    int i,knum;
  644. X    XChar2b onecharstring;
  645. X
  646. X    if(Kanji2English == GUESSKANJI){
  647. X        XFillRectangle(display,kanjiPixmap[0],cleargc,0,0,50,50);
  648. X        XFillRectangle(display,kanjiPixmap[1],cleargc,0,0,50,50);
  649. X        XFillRectangle(display,kanjiPixmap[2],cleargc,0,0,50,50);
  650. X        XFillRectangle(display,kanjiPixmap[3],cleargc,0,0,50,50);
  651. X        knum = values[truevalue];
  652. X        onecharstring.byte1 = (knum & 0xff00)>>8;
  653. X        onecharstring.byte2 = (knum & 0x00ff);
  654. X        XDrawImageString16(display,kanjiPixmap[0],kgc,
  655. X                       0,24,&onecharstring,1);
  656. X
  657. X        /* this is the hack to get it to redraw */
  658. X        XtVaSetValues(kanjiWidget[0],XtNlabel,"",NULL);
  659. X        return;
  660. X    }
  661. X    for(i=0;i<4;i++) {
  662. X        knum = values[i];
  663. X
  664. X        onecharstring.byte1 = (knum & 0xff00)>>8;
  665. X        onecharstring.byte2 = (knum & 0x00ff);
  666. X
  667. X        XFillRectangle(display,kanjiPixmap[i],cleargc,0,0,50,50);
  668. X
  669. X        /* and now stupid hack to get it to redraw.. */
  670. X        XtVaSetValues(kanjiWidget[i], XtNlabel,"",NULL);
  671. X
  672. X        XDrawImageString16(display,kanjiPixmap[i],kgc,
  673. X                       0,24,&onecharstring,1);
  674. X    }
  675. X}
  676. X
  677. X/* printenglish()
  678. X *  similar to printkanji()
  679. X *  Forces all english widgets to update the way we WANT them to update
  680. X */
  681. Xvoid printenglish(){
  682. X    int i;
  683. X    char *string;
  684. X    if(Kanji2English == GUESSENGLISH){
  685. X        string = translations[values[truevalue]]->english;
  686. X        XtVaSetValues(englishWidget[0],
  687. X                  XtNlabel,string,
  688. X                  XtNresize,True,
  689. X                  NULL);
  690. X        XtVaSetValues(englishWidget[1],XtNlabel,"",NULL);
  691. X        XtVaSetValues(englishWidget[2],XtNlabel,"",NULL);
  692. X        XtVaSetValues(englishWidget[3],XtNlabel,"",NULL);
  693. X        return;
  694. X    }
  695. X    for(i=0;i<4;i++){
  696. X        Widget w;
  697. X        int width;
  698. X
  699. X        string =translations[values[i]]->english;
  700. X        w = englishWidget[i];
  701. X        width = strlen(string) * englishwidth;
  702. X
  703. X        XtVaSetValues(w,
  704. X                  XtNlabel,string,
  705. X                  XtNresize,True,
  706. X                  NULL);
  707. X    }
  708. X}
  709. X
  710. X
  711. X/* kanjitoenglish
  712. X *    sets up question...
  713. X *    { "what does this symbol? choose one of the four choices"}
  714. X *    
  715. X *    then returns, presumably falling back to XtAppMainLoop()
  716. X *
  717. X *    guesskanji == GUESSKANJI : give kanji, and user guesses the meaning
  718. X *                    int English
  719. X *    guesskanji == GUESSENGLISH : give english, and user guesses which
  720. X *                    kanji fits best. 
  721. X */
  722. Xint kanjitoenglish(guesskanji)
  723. X{
  724. X    int doloop;
  725. X    int i;
  726. X    int userguess=0;
  727. X    Kanji2English=guesskanji;
  728. X
  729. X    /* determine which value will be correct one.. */
  730. X    truevalue = random() %4;
  731. X
  732. X    /* hack for random numbers...
  733. X     * only picks values that are acceptable by our current
  734. X     *  "usefile"
  735. X     */
  736. X    values[0] = pickkanji();
  737. X    values[1] = pickkanji();
  738. X    values[2] = pickkanji();
  739. X    values[3] = pickkanji();
  740. X
  741. X    /* now weed out duplicates.. */
  742. X    doloop = 0;
  743. X    do{
  744. X        if((values[0] == values[1]) || (values[0] == values[2])
  745. X            || values[0] == values[3] ){
  746. X            values[0] = pickkanji();
  747. X            doloop=1;
  748. X        } else
  749. X        if(values[1] == values[2] || values[1] == values[3]){
  750. X            values[1] = pickkanji();
  751. X            doloop=1;
  752. X        } else 
  753. X        if(values[2] == values[3]){
  754. X            values[2] = pickkanji();
  755. X            doloop=1;
  756. X        } else
  757. X            doloop = 0;
  758. X    }while(doloop);
  759. X
  760. X    printkanji();    /* update labels */
  761. X    printenglish(); /* likewise      */
  762. X
  763. X    switch(Kanji2English){
  764. X       case GUESSENGLISH:
  765. X        /* the first english label is set sensitive,
  766. X         * because it looks silly otherwise
  767. X         */
  768. X        XtVaSetValues(englishWidget[0],XtNsensitive,True,NULL);
  769. X        XtVaSetValues(englishWidget[1],XtNsensitive,False,NULL);
  770. X        XtVaSetValues(englishWidget[2],XtNsensitive,False,NULL);
  771. X        XtVaSetValues(englishWidget[3],XtNsensitive,False,NULL);
  772. X
  773. X        XtVaSetValues(kanjiWidget[0],XtNsensitive,True,NULL);
  774. X        XtVaSetValues(kanjiWidget[1],XtNsensitive,True,NULL);
  775. X        XtVaSetValues(kanjiWidget[2],XtNsensitive,True,NULL);
  776. X        XtVaSetValues(kanjiWidget[3],XtNsensitive,True,NULL);
  777. X
  778. X        XtVaSetValues(kanjimode,XtNsensitive,True,NULL);
  779. X        XtVaSetValues(englishmode,XtNsensitive,False,NULL);
  780. X        break;
  781. X       case GUESSKANJI:
  782. X        XtVaSetValues(englishWidget[0],XtNsensitive,True,NULL);
  783. X        XtVaSetValues(englishWidget[1],XtNsensitive,True,NULL);
  784. X        XtVaSetValues(englishWidget[2],XtNsensitive,True,NULL);
  785. X        XtVaSetValues(englishWidget[3],XtNsensitive,True,NULL);
  786. X
  787. X        XtVaSetValues(kanjiWidget[0],XtNsensitive,False,NULL);
  788. X        XtVaSetValues(kanjiWidget[1],XtNsensitive,False,NULL);
  789. X        XtVaSetValues(kanjiWidget[2],XtNsensitive,False,NULL);
  790. X        XtVaSetValues(kanjiWidget[3],XtNsensitive,False,NULL);
  791. X
  792. X        XtVaSetValues(kanjimode,XtNsensitive,False,NULL);
  793. X        XtVaSetValues(englishmode,XtNsensitive,True,NULL);
  794. X        break;
  795. X    }
  796. X}
  797. X
  798. X
  799. X/* englishcallback:
  800. X *    handles english widgets.
  801. X *    only really neccessary if we are guessing the meaning of a
  802. X *    kanji character
  803. X */
  804. Xvoid englishcallback(w,data,calldata)
  805. XWidget w;
  806. XXtPointer data;XtPointer calldata;
  807. X{
  808. X    if(!Kanji2English)
  809. X        return;
  810. X    if(data == (XtPointer) truevalue){
  811. X        setstatus("Correct!");
  812. X        kanjitoenglish(GUESSKANJI);
  813. X    } else {
  814. X        XBell(display,100);
  815. X        setstatus("Incorrect.");
  816. X    }
  817. X
  818. X}
  819. X
  820. X
  821. Xvoid kanjicallback(w,data,calldata)
  822. XWidget w;XtPointer data;XtPointer calldata;
  823. X{
  824. X    if(data == (XtPointer) truevalue){
  825. X        setstatus("Correct!");
  826. X        kanjitoenglish(GUESSENGLISH);
  827. X    } else {
  828. X        XBell(display,100);
  829. X        setstatus("Incorrect.");
  830. X    }
  831. X}
  832. X
  833. X
  834. X/* changemode:
  835. X *   change from guessing kanji to guessing english, or vica verse,
  836. X *    by clicking on the appropriate button
  837. X */
  838. Xvoid changemode(w,data,calldata)
  839. XWidget w;XtPointer data;XtPointer calldata;
  840. X{
  841. X    kanjitoenglish((int ) data); 
  842. X
  843. X}
  844. X
  845. END_OF_FILE
  846.   if test 6243 -ne `wc -c <'game.c'`; then
  847.     echo shar: \"'game.c'\" unpacked with wrong size!
  848.   fi
  849.   # end of 'game.c'
  850. fi
  851. if test -f 'init.c' -a "${1}" != "-c" ; then 
  852.   echo shar: Will not clobber existing file \"'init.c'\"
  853. else
  854.   echo shar: Extracting \"'init.c'\" \(6707 characters\)
  855.   sed "s/^X//" >'init.c' <<'END_OF_FILE'
  856. X#include <stdio.h>
  857. X
  858. X#include <Xlib.h>
  859. X#include <Xatom.h>
  860. X#include <Xutil.h>
  861. X#include <Intrinsic.h>
  862. X#include <StringDefs.h>
  863. X#include <Xaw/Command.h>
  864. X#include <Xaw/Label.h>
  865. X#include <Xaw/Form.h>
  866. X#include <Composite.h>
  867. X#include "defs.h"
  868. X#include "externs.h"
  869. X
  870. Xint englishup,englishdown;/* not used.. */
  871. X
  872. XFont kfont;
  873. Xchar *usefile=USEFILE;
  874. X
  875. Xstatic XtActionsRec actionlist[] = {
  876. X    { "quit",quit },
  877. X};
  878. X
  879. Xstatic char *fallback[] = {
  880. X    "KDrill*width: 200",
  881. X    "KDrill*height: 200",
  882. X    NULL
  883. X};
  884. X
  885. Xstatic XrmOptionDescRec optionlist[] = {
  886. X/* WHAT dies this do?? */
  887. X/* I just copied it from the xterm source, mainly */
  888. X
  889. X{"-help",    "*help",XrmoptionNoArg,    (caddr_t) NULL},
  890. X};
  891. X
  892. X
  893. X/* initgc:
  894. X *    initialises global gc values, and the fonts
  895. X */
  896. Xvoid initgc(){
  897. X    XGCValues gcvalues;
  898. X
  899. X    gc =  XCreateGC(display,mainwindow,0,NULL);
  900. X    cleargc = XCreateGC(display,mainwindow,0,NULL);
  901. X    kgc = XCreateGC(display,mainwindow,0,NULL);
  902. X
  903. X    XSetForeground(display,gc,black);
  904. X    XSetBackground(display,gc,white);
  905. X    XSetForeground(display,kgc,black);
  906. X    XSetBackground(display,kgc,white);
  907. X    XSetForeground(display,cleargc,white);
  908. X    XSetBackground(display,cleargc,black);
  909. X
  910. X    kfont = XLoadFont(display,KANJIFONT);
  911. X    if(kfont == (Font) NULL){
  912. X        perror("cannot load desired kanji font\n");
  913. X        exit(0);
  914. X    }
  915. X    XSetFont(display,kgc,kfont);
  916. X    XSetFont(display,gc,XLoadFont(display,"fixed"));
  917. X
  918. X
  919. X
  920. X}
  921. X
  922. X/* getusefile:
  923. X *    Gets a "usefile", to abridge the full dictionary.
  924. X *    If possible, will get it from the user's home directory,
  925. X *    otherwise, tries current directory
  926. X */
  927. XFILE *getusefile(){
  928. X    FILE *f;
  929. X    char *homedir;
  930. X    char fullname[100];
  931. X
  932. X    if(usefile == NULL) return NULL;
  933. X    fullname[0] = '\0';
  934. X    if(usefile[0] == '~'){
  935. X        homedir = (char *) getenv("HOME");
  936. X        if(homedir == NULL){
  937. X            perror("Cannot expand '~' char. no HOME env. varriable");
  938. X            exit(0);
  939. X        }
  940. X        sprintf(fullname,"%s%s",homedir,usefile);
  941. X    } else {
  942. X        strcpy(fullname,usefile);
  943. X    }
  944. X
  945. X    if((f = fopen(fullname,"r")) == NULL){
  946. X        puts("no usefile. using entire dictionary...");
  947. X        usefile = NULL;
  948. X    } else {
  949. X        printf("using \"%s\" to abridge dictionary\n",fullname);
  950. X    }
  951. X    return f;
  952. X}
  953. X
  954. X/* inituse:
  955. X *    clear out global array of 'translations' (really abridgements),
  956. X *    and set what kanji chars are appropriate to check on.
  957. X *
  958. X *    we set "okay" chars to have a NULL pointer stored for them in the
  959. X *    translation table, since later, we will want to check if
  960. X *    malloc malloc'd them properly.
  961. X *
  962. X *     unacceptable chars have a pointer stored of (void *) 1
  963. X *
  964. X *    We should really redo this.. but either way, there would
  965. X *    seem to be a conflict as to whether we have actually
  966. X *    malloced memory that starts at 0x00000001, or whatever.
  967. X *    
  968. X */
  969. Xvoid inituse(){
  970. X    FILE *f;
  971. X    int i;
  972. X    char inbuf[100];
  973. X
  974. X    f = getusefile();
  975. X
  976. X    /* set all translations flags == NULL.
  977. X     *    NULL means it's okay to use this character
  978. X     *    
  979. X     */
  980. X    if(usefile == NULL){
  981. X        i = 0x2000;
  982. X        while(i<0x8000){
  983. X            translations[i++] = (void *)NULL;
  984. X        }
  985. X        return;
  986. X    } else {    /* set all to UNREADABLE, for now */
  987. X        i = 0x2000;
  988. X        while(i<0x8000){
  989. X            translations[i++] = (void *)1;
  990. X        }
  991. X    }
  992. X
  993. X    while(fgets(inbuf,99,f) != NULL){
  994. X        int usechar;
  995. X        usechar = xtoi(inbuf);
  996. X        if( usechar<0x8000)
  997. X            translations[usechar] = NULL;
  998. X    }
  999. X
  1000. X}
  1001. X
  1002. X/* initstuffs:
  1003. X *    calls the various init routines to setup
  1004. X *    GCs, fonts, dictionaries, and widgets
  1005. X */
  1006. Xvoid initstuffs(argc,argv)
  1007. Xint *argc;
  1008. Xchar *argv[];
  1009. X{
  1010. X    int i,junk;
  1011. X    Arg args[5];
  1012. X    
  1013. X    srandom (time(NULL));
  1014. X    dictname = KANJIFILE;
  1015. X
  1016. X    /* check for abridgements of the dictionary... */
  1017. X    inituse();
  1018. X    readstructs(&argc,argv);
  1019. X
  1020. X    toplevel = XtVaAppInitialize(&Context,"KDrill",
  1021. X                   NULL,0,
  1022. X                   (int *) &argc,(String *) argv,
  1023. X                   NULL,NULL);
  1024. X    form = XtVaCreateManagedWidget("kdrill",formWidgetClass,
  1025. X                       toplevel,NULL);
  1026. X    /* I suppose I shouldn't hard-code this.. but it makes
  1027. X        things easier for now.
  1028. X    */
  1029. X    XtVaSetValues(toplevel,
  1030. X              XtNwidth,WINDOWWIDTH,
  1031. X              XtNheight,WINDOWHEIGHT,
  1032. X              XtNx,200,
  1033. X              XtNy,100,
  1034. X              NULL);
  1035. X
  1036. X    
  1037. X    display = XtDisplay(toplevel);
  1038. X
  1039. X    /* make KANJI buttons */
  1040. X    for(i=0;i<4;i++){
  1041. X        char labl[20];
  1042. X        sprintf(labl,"kanji%d",i);
  1043. X        kanjiPixmap[i]=XCreatePixmap(display,
  1044. X                    RootWindow(display,0),
  1045. X                    30,30,1);
  1046. X
  1047. X        kanjiWidget[i]=XtVaCreateManagedWidget(
  1048. X            labl,commandWidgetClass,
  1049. X            form,NULL);
  1050. X        XtVaSetValues(kanjiWidget[i],
  1051. X                  XtNlabel,"",
  1052. X                  XtNwidth,50,
  1053. X                  XtNheight,50,
  1054. X                  XtNbitmap,kanjiPixmap[i],
  1055. X                  XtNshapeStyle,XawShapeOval,
  1056. X                  NULL);
  1057. X        XtAddCallback(kanjiWidget[i],XtNcallback,kanjicallback,(XtPointer)i);
  1058. X        if(i>0){
  1059. X            sprintf(labl,"english%d",i-1);
  1060. X            XtVaSetValues(kanjiWidget[i],
  1061. X                      XtNfromHoriz,kanjiWidget[i-1],
  1062. X                      NULL);
  1063. X        }
  1064. X
  1065. X    }
  1066. X    /********************************/
  1067. X    /* make ENGLISH buttons.. */
  1068. X    /********************************/
  1069. X    for(i=0;i<4;i++){
  1070. X        char labl[20];
  1071. X        sprintf(labl,"english%d",i);
  1072. X
  1073. X        englishWidget[i]=XtVaCreateManagedWidget(
  1074. X            labl,commandWidgetClass,
  1075. X            form,NULL);
  1076. X
  1077. X        /* the following is stupid, but I don't know of a better
  1078. X          way to make it resize properly. I've tried the
  1079. X          XtResize thing.
  1080. X        */
  1081. X        XtVaSetValues(englishWidget[i],
  1082. X                  XtNlabel,"                                ",
  1083. X                  NULL);
  1084. X        
  1085. X        XtAddCallback(englishWidget[i],XtNcallback,englishcallback,(XtPointer) i);
  1086. X
  1087. X        if(i==0){
  1088. X            XtVaSetValues(englishWidget[0],
  1089. X                      XtNfromVert,kanjiWidget[0],
  1090. X                      NULL);
  1091. X        } else {
  1092. X            XtVaSetValues(englishWidget[i],
  1093. X                      XtNfromVert,englishWidget[i-1],
  1094. X                      NULL);
  1095. X        }
  1096. X        
  1097. X
  1098. X    }
  1099. X
  1100. X    kanjimode = XtVaCreateManagedWidget("kanjimode",commandWidgetClass,
  1101. X                        form,NULL);
  1102. X    XtVaSetValues(kanjimode,
  1103. X            XtNlabel,"Guess kanji",
  1104. X            XtNfromVert,englishWidget[3],
  1105. X            XtNshapeStyle,XawShapeOval,
  1106. X            NULL);
  1107. X    XtAddCallback(kanjimode,XtNcallback,changemode,(XtPointer) 1);
  1108. X    englishmode = XtVaCreateManagedWidget("englishmode",commandWidgetClass,
  1109. X                          form,NULL);
  1110. X    XtVaSetValues(englishmode,
  1111. X            XtNlabel,"Guess english",
  1112. X            XtNfromVert,englishWidget[3],
  1113. X            XtNshapeStyle,XawShapeOval,
  1114. X            XtNfromHoriz,kanjimode,
  1115. X            NULL);
  1116. X    XtAddCallback(englishmode,XtNcallback,changemode,(XtPointer) 0);
  1117. X
  1118. X    quitbutton = XtVaCreateManagedWidget("quit",commandWidgetClass,
  1119. X                         form,NULL);
  1120. X    XtVaSetValues(quitbutton,
  1121. X              XtNlabel,"quit",
  1122. X              XtNfromVert,kanjimode,
  1123. X              XtNshapeStyle,XawShapeEllipse,
  1124. X              NULL);
  1125. X    XtAddCallback(quitbutton,XtNcallback,quit,NULL);
  1126. X
  1127. X    statusline = XtVaCreateManagedWidget("status",labelWidgetClass,
  1128. X                         form,NULL);
  1129. X    XtVaSetValues(statusline,
  1130. X              XtNlabel,"Welcome to kanjidrill",
  1131. X              XtNfromHoriz,quitbutton,
  1132. X              XtNfromVert,kanjimode,
  1133. X              NULL);
  1134. X
  1135. X
  1136. X    XtAppAddActions(Context,actionlist,XtNumber(actionlist));
  1137. X
  1138. X    XtRealizeWidget(toplevel);
  1139. X    mainwindow = XtWindow(form);
  1140. X
  1141. X    white = WhitePixel(display,0);
  1142. X    black = BlackPixel(display,0);
  1143. X    initgc();
  1144. X
  1145. X}
  1146. END_OF_FILE
  1147.   if test 6707 -ne `wc -c <'init.c'`; then
  1148.     echo shar: \"'init.c'\" unpacked with wrong size!
  1149.   fi
  1150.   # end of 'init.c'
  1151. fi
  1152. if test -f 'kdrill.man' -a "${1}" != "-c" ; then 
  1153.   echo shar: Will not clobber existing file \"'kdrill.man'\"
  1154. else
  1155.   echo shar: Extracting \"'kdrill.man'\" \(1637 characters\)
  1156.   sed "s/^X//" >'kdrill.man' <<'END_OF_FILE'
  1157. X.\" kdrill.1 1.13 93/02/15 
  1158. X.TH KDRILL 1.1 "9 November 1992"
  1159. X.SH NAME
  1160. Xkdrill \- drill program for kanji chars under Xwindows
  1161. X.SH DESCRIPTION
  1162. X.B kdrill
  1163. Xwill use the "kanjidic" file to interpret many of the various 16-bit kanji
  1164. Xchars in the
  1165. X.I kanji24
  1166. Xfont supplied with the X11R5 distribution. It checks for a file by the name of
  1167. X.B "usefile"
  1168. Xin the current directory (although this may be altered easily by your system 
  1169. Xadministrator at compile time).
  1170. X
  1171. XThe usefile simply consists of a list of hex numbers, one per line, no
  1172. Xinitial spaces allowed. The usefile makes the program only use particular
  1173. Xkanji, instead of the thousands possible in the dictionary. It is
  1174. Xpossible to add comment lines by having the very first character of a
  1175. Xline be "#". It is also possible to add english reminders after the number
  1176. Xon each line, so you remember what each number is.
  1177. XHex numbers can be checked or found by using the "xfd" util on the
  1178. X"kanji24" font. 
  1179. X
  1180. XThe dictionary, kanjidic, is currently available where it originated, via
  1181. Xftp from
  1182. X.I monu6.cc.monash.edu.au,
  1183. Xor from a mirror in the U.S. at ftp.uwtc.washington.edu
  1184. XIn one of these locations, the file may be found in a directory,
  1185. X.B JimBreen,
  1186. Xwhile in both locations, it is in a subdirectory akin to 
  1187. X.I /pub/japanese
  1188. Xor
  1189. X.I /pub/nihongo
  1190. Xor similar.
  1191. X
  1192. X.SH AUTHOR
  1193. XPhilip P Brown
  1194. X.SH BUGS
  1195. XThis was written with some of the R5 xterm source as a template. Thus, there 
  1196. Xare a few pieces of code in there that are apparently useless.
  1197. X
  1198. XThis manual page is NOT by Sun. 
  1199. X
  1200. Xkdrill does not like working on my truecolor display. This indicates it
  1201. Xprobably won't be happy on a regular color display, also.
  1202. END_OF_FILE
  1203.   if test 1637 -ne `wc -c <'kdrill.man'`; then
  1204.     echo shar: \"'kdrill.man'\" unpacked with wrong size!
  1205.   fi
  1206.   # end of 'kdrill.man'
  1207. fi
  1208. if test -f 'main.c' -a "${1}" != "-c" ; then 
  1209.   echo shar: Will not clobber existing file \"'main.c'\"
  1210. else
  1211.   echo shar: Extracting \"'main.c'\" \(1367 characters\)
  1212.   sed "s/^X//" >'main.c' <<'END_OF_FILE'
  1213. X#include <stdio.h>
  1214. X
  1215. X#include <Xlib.h>
  1216. X#include <Xatom.h>
  1217. X#include <Xutil.h>
  1218. X#include <Intrinsic.h>
  1219. X#include <StringDefs.h>
  1220. X#include <Xaw/Command.h>
  1221. X#include <Xaw/Label.h>
  1222. X#include <Xaw/Form.h>
  1223. X#include <Composite.h>
  1224. X#include "defs.h"
  1225. X#include "externs.h"
  1226. X#include "patchlevel.h"
  1227. X
  1228. Xstatic char *version = VERSION;
  1229. X
  1230. XDisplay *display;
  1231. Xint screen;
  1232. XWindow mainwindow,rootwindow;
  1233. XGC gc,kgc,cleargc;
  1234. XWidget toplevel,form,quitbutton,statusline;
  1235. XWidget kanjimode,englishmode,othermode;
  1236. XWidget englishWidget[4],kanjiWidget[4];
  1237. XPixmap kanjiPixmap[4];
  1238. XXtAppContext Context;
  1239. X
  1240. Xchar *dictname=NULL;
  1241. X
  1242. XXChar2b *kstring;
  1243. XXChar2b onecharstring;
  1244. X
  1245. Xunsigned long white,black;
  1246. X
  1247. X/* quitbutton, of course */
  1248. Xvoid quit(w,data,calldata)
  1249. XWidget w;
  1250. XXtPointer data,calldata;
  1251. X{
  1252. X    puts("quitting?");
  1253. X    XtCloseDisplay(display);
  1254. X    exit(0);
  1255. X}
  1256. X
  1257. X
  1258. X
  1259. X/* keypress:
  1260. X * return whether got strnage key (shift, etc), or normal key.
  1261. X * returns 0 on normal key, or exits program if 'q' hit
  1262. X */
  1263. Xint keypress(key)
  1264. Xint key;
  1265. X{
  1266. X    if(key == 61)
  1267. X        exit(0);
  1268. X    else
  1269. X
  1270. X        /* sun codes for shift, control, etc */
  1271. X    switch(key){
  1272. X        case 106:
  1273. X        case 83:
  1274. X        case 26:
  1275. X            return 1;
  1276. X            break;
  1277. X        default:
  1278. X            /* printf("Got keypress %d\n",key); */
  1279. X            return 0;
  1280. X    }
  1281. X}
  1282. X
  1283. X
  1284. Xmain(argc,argv)
  1285. Xint argc;
  1286. Xchar *argv[];
  1287. X{
  1288. X    int i;
  1289. X    XEvent event;
  1290. X
  1291. X    initstuffs();
  1292. X
  1293. X    kanjitoenglish(1);
  1294. X    /* if pass 0, means want to guess english */
  1295. X    XtAppMainLoop(Context);
  1296. X
  1297. X}
  1298. END_OF_FILE
  1299.   if test 1367 -ne `wc -c <'main.c'`; then
  1300.     echo shar: \"'main.c'\" unpacked with wrong size!
  1301.   fi
  1302.   # end of 'main.c'
  1303. fi
  1304. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  1305.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  1306. else
  1307.   echo shar: Extracting \"'patchlevel.h'\" \(76 characters\)
  1308.   sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  1309. X#ifndef _PATCHLEVEL_H
  1310. X#define _PATCHLEVEL_H
  1311. X
  1312. X#define VERSION    "v1.0"
  1313. X
  1314. X#endif
  1315. END_OF_FILE
  1316.   if test 76 -ne `wc -c <'patchlevel.h'`; then
  1317.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  1318.   fi
  1319.   # end of 'patchlevel.h'
  1320. fi
  1321. if test -f 'readfile.c' -a "${1}" != "-c" ; then 
  1322.   echo shar: Will not clobber existing file \"'readfile.c'\"
  1323. else
  1324.   echo shar: Extracting \"'readfile.c'\" \(3436 characters\)
  1325.   sed "s/^X//" >'readfile.c' <<'END_OF_FILE'
  1326. X/*
  1327. X * This file is for just setting up the structs, etc
  1328. X */
  1329. X
  1330. X
  1331. X#include <stdio.h>
  1332. X#include <ctype.h>
  1333. X#include <Xfuncs.h>
  1334. X#include <Xlib.h>
  1335. X#include <Xatom.h>
  1336. X#include <Xutil.h>
  1337. X#include <Intrinsic.h>
  1338. X#include <StringDefs.h>
  1339. X#include <Xos.h>
  1340. X
  1341. X#include "defs.h"
  1342. X#include "externs.h"
  1343. X
  1344. X/* translations[] keeps track of which kanji it is okay to test the
  1345. X *    user on. Likewise with numberofkanji, highest, and lowest.
  1346. X *    translations[x] == 
  1347. X */
  1348. Xstruct translationstruct *translations[0x8000];
  1349. Xint numberofkanji,highest,lowest;
  1350. X
  1351. X
  1352. X/* random debugging util? */
  1353. Xvoid printline(s)
  1354. Xunsigned char *s;
  1355. X{
  1356. X    while(*s){
  1357. X        putchar(*s++);
  1358. X    }
  1359. X    putchar('\n');
  1360. X}
  1361. X
  1362. X/* Since there is no standard util to convert hex ascii to int,...
  1363. X *  have to supply our own..
  1364. X *  It isn't incredibly efficient.. let's hope the compiler is smart.
  1365. X *  arrg..
  1366. X */
  1367. Xint xtoi(s)
  1368. Xchar * s;
  1369. X{
  1370. X    int out=0;
  1371. X    sscanf(s,"%x",&out);
  1372. X    return out;
  1373. X}
  1374. X
  1375. X/* getline:
  1376. X *    reads a line (from dictionary).
  1377. X *    returns true (1) if read aline, otherwise,
  1378. X *    returns false (0);
  1379. X *
  1380. X *    used in "readstructs", below.
  1381. X */
  1382. X
  1383. Xunsigned char instring[2][512];
  1384. Xunsigned char *inptr=NULL;
  1385. Xint whichstring;
  1386. X
  1387. Xint getline(fp,s)
  1388. XFILE *fp;
  1389. Xunsigned char *s;
  1390. X{
  1391. X    if(inptr==NULL){
  1392. X        inptr= &instring[0][100];
  1393. X        whichstring=0;
  1394. X    }
  1395. X    for(;;){
  1396. X        int i;
  1397. X        if(inptr == &instring[whichstring][100]){
  1398. X            whichstring = 1-whichstring;
  1399. X            inptr=instring[whichstring];
  1400. X            i=fread(instring[whichstring],1,100,fp);
  1401. X            if(i<100){
  1402. X                instring[whichstring][i]='\0';
  1403. X                /* okay, we put the termination signal in.
  1404. X                 * But if there is a complete line in there,
  1405. X                 * it should be read with our buffering
  1406. X                 */
  1407. X            }
  1408. X        }
  1409. X        switch(*inptr){
  1410. X            case 0:
  1411. X                *s = '\0';
  1412. X                return 0;
  1413. X            case 10:
  1414. X            case 13:
  1415. X                *inptr='\0';
  1416. X                *s++ = *inptr++;
  1417. X                return 1;
  1418. X            default:
  1419. X                *s++ = *inptr++;
  1420. X        }
  1421. X    }
  1422. X}
  1423. X
  1424. X/* nextchar:
  1425. X * returns pointer to next non-whitespace char
  1426. Xunsigned char *nextchar(c)
  1427. Xunsigned char *c;
  1428. X{
  1429. X    while(isspace(*c)){
  1430. X        if(*c == '\0') break;
  1431. X        c++;
  1432. X    }
  1433. X    return c;
  1434. X}
  1435. X
  1436. X
  1437. X/* readstructs:
  1438. X *    the main dictionary reading routine.
  1439. X *    Fills in the global translationstruct with 
  1440. X */
  1441. Xvoid readstructs(){
  1442. X    unsigned char instring[256];
  1443. X    int i;
  1444. X    FILE *fp;
  1445. X    lowest = highest = 0x3000;
  1446. X    fp = fopen(dictname,"r");
  1447. X    if(fp == NULL){
  1448. X        perror("cannot open kanji translation file");
  1449. X        fprintf(stderr,"Looking for %s\n",dictname);
  1450. X        exit(0);
  1451. X    }
  1452. X
  1453. X    puts("reading in dictionary: please wait a few moments...");
  1454. X    while (getline(fp,instring) != 0) {
  1455. X        unsigned char *parse;
  1456. X        int instrlen;    /* length of pronunciation */
  1457. X
  1458. X        /*i = instring[0] *256 + instring[1];*/
  1459. X        i = xtoi(&instring[2]);
  1460. X
  1461. X        if(i < 0x3000){
  1462. X            /* NASTY HACK */
  1463. X            continue;
  1464. X        }
  1465. X        if(translations[i] != NULL){
  1466. X            continue;
  1467. X            /* trick so that users can specify which numbers
  1468. X               they want to drill on */
  1469. X        }
  1470. X            /* NOther nasty hack */
  1471. X        parse = index(instring,'{');
  1472. X        if(parse == NULL){
  1473. X            continue;
  1474. X        }
  1475. X        
  1476. X
  1477. X        if(i<lowest) lowest = i;
  1478. X        if (i >highest) highest = i;
  1479. X        
  1480. X        translations[i] = (struct translationstruct *)
  1481. X            malloc(sizeof(struct translationstruct));
  1482. X        if (translations[i] == NULL){
  1483. X            perror("Cannot allocate memory for translation table\n");
  1484. X            exit(errno);
  1485. X        }
  1486. X
  1487. X        translations[i]->pronunciation = NULL;
  1488. X
  1489. X        instrlen = strlen(parse)+1;
  1490. X
  1491. X        translations[i]->english = (char *) malloc(instrlen);
  1492. X        if(translations[i]->english == NULL){
  1493. X            perror("Cannot allocate memory for translation table\n");
  1494. X            exit(errno);        
  1495. X        }
  1496. X
  1497. X        strncpy(translations[i]->english,parse,instrlen);
  1498. X    } 
  1499. X}
  1500. END_OF_FILE
  1501.   if test 3436 -ne `wc -c <'readfile.c'`; then
  1502.     echo shar: \"'readfile.c'\" unpacked with wrong size!
  1503.   fi
  1504.   # end of 'readfile.c'
  1505. fi
  1506. if test -f 'usefile' -a "${1}" != "-c" ; then 
  1507.   echo shar: Will not clobber existing file \"'usefile'\"
  1508. else
  1509.   echo shar: Extracting \"'usefile'\" \(1379 characters\)
  1510.   sed "s/^X//" >'usefile' <<'END_OF_FILE'
  1511. X# This is the "kdrill" 'usefile'
  1512. X#  it is used to abridge the "kanjidic" dictionary
  1513. X#
  1514. X# lines can be commented by the VERY FIRST CHARACTER being a '#'
  1515. X# Try not to leave blank lines
  1516. X# Only the initial hex number is important..
  1517. X#  You can add whatever english you  like afterwards,so that you remember
  1518. X#  what the numbers mean.
  1519. X3030 rising sun
  1520. X303f someone?
  1521. X306c "one"
  1522. X312b rain
  1523. X312c east
  1524. X315f yen, round
  1525. X323c below ,low 
  1526. X3433 dry
  1527. X3250 fire
  1528. X3456 interval (of time), a room
  1529. X355d bow
  1530. X3662 gold
  1531. X3665 nine
  1532. X376e  Moon
  1533. X384a self
  1534. X385e five
  1535. X3971 country
  1536. X3b30 three
  1537. X3b33 mountain
  1538. X3b4d four
  1539. X3b4e samurai,gentleman
  1540. X3b5s child
  1541. X3b54 city
  1542. X3b7b temple(buddhist)
  1543. X3b7e time, or hour
  1544. X3c37 seven
  1545. X3d3a utensil?ten??
  1546. X3d3d ten
  1547. X3d50 exit (verb)
  1548. X3d77 woman
  1549. X3e2e small
  1550. X3e65 above
  1551. X3f4d person
  1552. X3f65 water
  1553. X4038 life
  1554. X403e west
  1555. X405a cut, cut off
  1556. X4069 thousand
  1557. X406e river
  1558. X4134 all
  1559. X422b sheaf
  1560. X4267 large
  1561. X4331 one
  1562. X4366 middle/center
  1563. X4544 rice paddy
  1564. X455a earth
  1565. X4561 knife , sword
  1566. X466e south
  1567. X4673 two
  1568. X467c sun
  1569. X467e enter
  1570. X482a cultivated field, really.
  1571. X482b farm?
  1572. X482c eight
  1573. X4934 hundred
  1574. X4977 wind, style
  1575. X4a2c minute, portion
  1576. X4a60 garden
  1577. X4b2e country
  1578. X4b4c north
  1579. X4b5c book, origin
  1580. X4b7c ten thousand, many, etc
  1581. X4c40 bright, clear
  1582. X4c5a tree
  1583. X4c5c ordinal for numbers
  1584. X4c67 gates
  1585. X4d4b day of week
  1586. X4d5b sunshine
  1587. X4f3b six
  1588. X5042 thousand (sort of)
  1589. X5051 hundred (sort of)
  1590. X5345 one?
  1591. X5744 three (fur/hair radical)
  1592. X666d new moon
  1593. X
  1594. END_OF_FILE
  1595.   if test 1379 -ne `wc -c <'usefile'`; then
  1596.     echo shar: \"'usefile'\" unpacked with wrong size!
  1597.   fi
  1598.   # end of 'usefile'
  1599. fi
  1600. echo shar: End of archive 1 \(of 1\).
  1601. cp /dev/null ark1isdone
  1602. MISSING=""
  1603. for I in 1 ; do
  1604.     if test ! -f ark${I}isdone ; then
  1605.     MISSING="${MISSING} ${I}"
  1606.     fi
  1607. done
  1608. if test "${MISSING}" = "" ; then
  1609.     echo You have the archive.
  1610.     rm -f ark[1-9]isdone
  1611. else
  1612.     echo You still must unpack the following archives:
  1613.     echo "        " ${MISSING}
  1614. fi
  1615. exit 0
  1616. exit 0 # Just in case...
  1617. -- 
  1618.   // chris@Sterling.COM           | Send comp.sources.x submissions to:
  1619. \X/  Amiga - The only way to fly! |    sources-x@sterling.com
  1620.  "It's intuitively obvious to the |
  1621.   most casual observer..."        | GCS d+/-- p+ c++ l+ m+ s++/+ g+ w+ t+ r+ x+
  1622.