1 /*
2  * $Id: chkim.c,v 1.2 2001/06/14 18:16:11 ura Exp $
3  */
4 
5 /*
6  * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
7  * This file is part of FreeWnn.
8  *
9  * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
10  *
11  * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with GNU Emacs; see the file COPYING.  If not, write to the
25  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26  *
27  * Commentary:
28  *
29  * Change log:
30  *
31  * Last modified date: 8,Feb.1999
32  *
33  * Code:
34  *
35  */
36 
37 /*
38  * X11R5 Input Method Test Program
39  * chkim.c v 1.0   Tue Mar  5 16:18:15 JST 1991
40  */
41 
42 /*
43  *      Author: Takashi Inoue    OMRON Corporation
44  *                               takashi@ari.ncl.omron.co.jp
45  *
46  *              Shoji kamada     OMRON Corporation
47  *                               kamada@ari.ncl.omron.co.jp
48  */
49 
50 #include "exvalue.h"
51 #include "func.h"
52 
53 #include <stdio.h>
54 #include <X11/IntrinsicP.h>
55 #include <X11/Xresource.h>
56 
57 /* *INDENT-OFF* */
58 XIM
openim(lfdir,flag)59 openim (lfdir, flag)            /* check of XOpenIM */
60      char *lfdir;
61      FLAG *flag;
62 /* *INDENT-ON* */
63 {
64   XIM im;
65   char *home;
66   char logfile[MAX_BUF];
67   char dbsrc[MAX_BUF];
68   XrmDatabase rdb;
69   XIMStyles *ximstyle;
70   XIMStyle *style;
71 #ifdef XML
72   char *languages;
73 #endif /* XML */
74   int cnt;
75 
76   char *getenv ();
77 
78   prmode ("X11R5 Input Method Test Program : <<IM Mode>>");
79   prstatus ("Creating log file for im...");     /* open log file for IM test */
80   sprintf (logfile, "%s/tim.log", lfdir);
81   imfp = fopen (logfile, "w");
82   prstatus ("done.");
83   if (imfp == NULL)
84     {
85       cls (prdisp);
86       prerrld (logfile);
87     }
88 
89   prstatus ("Creating resource database...");   /* create resource database */
90   home = getenv ("HOME");
91   sprintf (dbsrc, "%s/.Xdefaults", home);
92   rdb = XrmGetFileDatabase (dbsrc);
93   prstatus ("done.");
94 
95   prstatus ("Creating input method...");        /* open IM */
96   im = XOpenIM (dpy, rdb, "xim", "XIM");
97   prstatus ("done.");
98   cls (prdisp);
99   if (im == NULL)
100     {                           /* for XOpenIM error */
101       prprint ("Test of XOpenIM() is failed.\n\n");
102       prprint ("Check environmental valuable \"XNLSPATH\"\n\n");
103       prprint ("and make sure to run \"xwnmo\".\n\n");
104       prprint ("This program will shutdown soon.\n\n");
105       fprintf (imfp, "Test of XOpenIM() is failed.\n");
106       fprintf (imfp, "\"NULL\" returned.\n\n");
107       *flag = OPIMERR;
108       return (im);
109     }
110   prprint ("Test of XOpenIM() is succeeded.\n");        /* for XOpenIM success */
111   prprint ("Move next test.\n\n");
112   fprintf (imfp, "Test of XOpenIM() is succeeded.\n");
113   fprintf (imfp, "im : 0x%X\n\n", im);
114 
115 #ifdef XML
116   languages = 0;                /* initialization of valuables */
117 #endif /* XML */
118   prstatus ("Test of XGetIMValues()...");       /* test of XGetIMValues */
119   XGetIMValues (im, XNQueryInputStyle, &ximstyle,
120 #ifdef XML
121                 XNQueryLanguage, &languages,
122 #endif /* XML */
123                 NULL);
124   prstatus ("done.");
125   if (ximstyle->count_styles == 0)
126     {                           /* for XGetIMValues error */
127       prprint ("Test of XGetIMValues() is failed.\n");
128       prprint ("This program will shutdown soon.\n\n");
129       fprintf (imfp, "Test of XGetIMValues() is failed. ");
130       fprintf (imfp, "ximstyle returned \"NULL\".\n\n");
131       *flag = GIMERR;
132       XFree (ximstyle);
133       return (NULL);
134     }
135   prprint ("Test of XGetIMValues() is succeeded.\n");
136   prprint ("Move next test.\n\n");
137   /* for XGetIMValues success */
138   fprintf (imfp, "Test of XGetIMValues() is succeeded.\n");
139   for (cnt = 0, style = ximstyle->supported_styles; cnt < ximstyle->count_styles; cnt++, style++)
140     fprintf (imfp, "input style : 0x%X\n", *style);     /* write values to log file */
141 #ifdef XML
142   fprintf (imfp, "You can use languages in this IM : %s\n\n", languages);
143 #endif /* XML */
144   XFree (ximstyle);
145   return (im);
146 }
147 
148 void
closeim(im)149 closeim (im)                    /* CLOSE IM */
150      XIM im;
151 {
152   XCloseIM (im);
153 }
154 
155 void
fclim()156 fclim ()                        /* log File CLose for IM */
157 {
158   fclose (imfp);
159 }
160