PageRenderTime 48ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/nx-3.5.0/nx-X11/lib/X11/imThaiIm.c

#
C | 235 lines | 177 code | 23 blank | 35 comment | 33 complexity | 64bd50a22757067f4a9b72d43f11ba0e MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, LGPL-2.0
  1. /* $Xorg: imThaiIm.c,v 1.3 2000/08/17 19:45:15 cpqbld Exp $ */
  2. /******************************************************************
  3. Copyright 1992, 1993, 1994 by FUJITSU LIMITED
  4. Copyright 1993 by Digital Equipment Corporation
  5. Permission to use, copy, modify, distribute, and sell this software
  6. and its documentation for any purpose is hereby granted without fee,
  7. provided that the above copyright notice appear in all copies and that
  8. both that copyright notice and this permission notice appear in
  9. supporting documentation, and that the name of FUJITSU LIMITED and
  10. Digital Equipment Corporation not be used in advertising or publicity
  11. pertaining to distribution of the software without specific, written
  12. prior permission. FUJITSU LIMITED and Digital Equipment Corporation
  13. makes no representations about the suitability of this software for
  14. any purpose. It is provided "as is" without express or implied
  15. warranty.
  16. FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
  17. WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
  18. WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  19. FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR
  20. ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  21. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  22. IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  23. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  24. THIS SOFTWARE.
  25. Author: Takashi Fujiwara FUJITSU LIMITED
  26. fujiwara@a80.tech.yk.fujitsu.co.jp
  27. Modifier: Franky Ling Digital Equipment Corporation
  28. frankyling@hgrd01.enet.dec.com
  29. ******************************************************************/
  30. /* $XFree86: xc/lib/X11/imThaiIm.c,v 1.7 2001/01/17 19:41:52 dawes Exp $ */
  31. #ifdef HAVE_CONFIG_H
  32. #include <config.h>
  33. #endif
  34. #include <stdio.h>
  35. #include <X11/Xlib.h>
  36. #include <X11/Xmd.h>
  37. #include <X11/Xatom.h>
  38. #include <X11/Xos.h>
  39. #include "Xlibint.h"
  40. #include "Xlcint.h"
  41. #include "XlcPublic.h"
  42. #include "XlcPubI.h"
  43. #include "Ximint.h"
  44. Private XIMMethodsRec Xim_im_thai_methods = {
  45. _XimThaiCloseIM, /* close */
  46. _XimLocalSetIMValues, /* set_values */
  47. _XimLocalGetIMValues, /* get_values */
  48. _XimThaiCreateIC, /* create_ic */
  49. _XimLcctstombs, /* ctstombs */
  50. _XimLcctstowcs, /* ctstowcs */
  51. _XimLcctstoutf8 /* ctstoutf8 */
  52. };
  53. #define THAI_LANGUAGE_NAME "th"
  54. Bool
  55. _XimCheckIfThaiProcessing(im)
  56. Xim im;
  57. {
  58. char *language;
  59. _XGetLCValues(im->core.lcd, XlcNLanguage, &language, NULL);
  60. if(strcmp(language, THAI_LANGUAGE_NAME) == 0) {
  61. return(True);
  62. }
  63. return(False);
  64. }
  65. Public Bool
  66. _XimThaiOpenIM(im)
  67. Xim im;
  68. {
  69. XLCd lcd = im->core.lcd;
  70. XlcConv conv;
  71. XimDefIMValues im_values;
  72. XimLocalPrivateRec* private = &im->private.local;
  73. _XimInitialResourceInfo();
  74. if(_XimSetIMResourceList(&im->core.im_resources,
  75. &im->core.im_num_resources) == False) {
  76. goto Open_Error;
  77. }
  78. if(_XimSetICResourceList(&im->core.ic_resources,
  79. &im->core.ic_num_resources) == False) {
  80. goto Open_Error;
  81. }
  82. _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
  83. _XimGetCurrentIMValues(im, &im_values);
  84. if(_XimSetLocalIMDefaults(im, (XPointer)&im_values,
  85. im->core.im_resources, im->core.im_num_resources) == False) {
  86. goto Open_Error;
  87. }
  88. _XimSetCurrentIMValues(im, &im_values);
  89. if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte)))
  90. goto Open_Error;
  91. private->ctom_conv = conv;
  92. if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar)))
  93. goto Open_Error;
  94. private->ctow_conv = conv;
  95. if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNUtf8String)))
  96. goto Open_Error;
  97. private->ctoutf8_conv = conv;
  98. if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte)))
  99. goto Open_Error;
  100. private->cstomb_conv = conv;
  101. if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNWideChar)))
  102. goto Open_Error;
  103. private->cstowc_conv = conv;
  104. if (!(conv = _XlcOpenConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String)))
  105. goto Open_Error;
  106. private->cstoutf8_conv = conv;
  107. if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNChar)))
  108. goto Open_Error;
  109. private->ucstoc_conv = conv;
  110. if (!(conv = _XlcOpenConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String)))
  111. goto Open_Error;
  112. private->ucstoutf8_conv = conv;
  113. im->methods = &Xim_im_thai_methods;
  114. private->current_ic = (XIC)NULL;
  115. return(True);
  116. Open_Error :
  117. _XimThaiIMFree(im);
  118. return(False);
  119. }
  120. Public void
  121. _XimThaiIMFree(im)
  122. Xim im;
  123. {
  124. if(im->core.im_resources) {
  125. Xfree(im->core.im_resources);
  126. im->core.im_resources = NULL;
  127. }
  128. if(im->core.ic_resources) {
  129. Xfree(im->core.ic_resources);
  130. im->core.ic_resources = NULL;
  131. }
  132. if(im->core.im_values_list) {
  133. Xfree(im->core.im_values_list);
  134. im->core.im_values_list = NULL;
  135. }
  136. if(im->core.ic_values_list) {
  137. Xfree(im->core.ic_values_list);
  138. im->core.ic_values_list = NULL;
  139. }
  140. if(im->core.styles) {
  141. Xfree(im->core.styles);
  142. im->core.styles = NULL;
  143. }
  144. if(im->core.res_name) {
  145. Xfree(im->core.res_name);
  146. im->core.res_name = NULL;
  147. }
  148. if(im->core.res_class) {
  149. Xfree(im->core.res_class);
  150. im->core.res_class = NULL;
  151. }
  152. if(im->core.im_name) {
  153. Xfree(im->core.im_name);
  154. im->core.im_name = NULL;
  155. }
  156. if (im->private.local.ctom_conv) {
  157. _XlcCloseConverter(im->private.local.ctom_conv);
  158. im->private.local.ctom_conv = NULL;
  159. }
  160. if (im->private.local.ctow_conv) {
  161. _XlcCloseConverter(im->private.local.ctow_conv);
  162. im->private.local.ctow_conv = NULL;
  163. }
  164. if (im->private.local.ctoutf8_conv) {
  165. _XlcCloseConverter(im->private.local.ctoutf8_conv);
  166. im->private.local.ctoutf8_conv = NULL;
  167. }
  168. if (im->private.local.cstomb_conv) {
  169. _XlcCloseConverter(im->private.local.cstomb_conv);
  170. im->private.local.cstomb_conv = NULL;
  171. }
  172. if (im->private.local.cstowc_conv) {
  173. _XlcCloseConverter(im->private.local.cstowc_conv);
  174. im->private.local.cstowc_conv = NULL;
  175. }
  176. if (im->private.local.cstoutf8_conv) {
  177. _XlcCloseConverter(im->private.local.cstoutf8_conv);
  178. im->private.local.cstoutf8_conv = NULL;
  179. }
  180. if (im->private.local.ucstoc_conv) {
  181. _XlcCloseConverter(im->private.local.ucstoc_conv);
  182. im->private.local.ucstoc_conv = NULL;
  183. }
  184. if (im->private.local.ucstoutf8_conv) {
  185. _XlcCloseConverter(im->private.local.ucstoutf8_conv);
  186. im->private.local.ucstoutf8_conv = NULL;
  187. }
  188. return;
  189. }
  190. Public Status
  191. _XimThaiCloseIM(xim)
  192. XIM xim;
  193. {
  194. Xim im = (Xim)xim;
  195. XIC ic;
  196. XIC next;
  197. ic = im->core.ic_chain;
  198. im->core.ic_chain = NULL;
  199. while (ic) {
  200. (*ic->methods->destroy) (ic);
  201. next = ic->core.next;
  202. Xfree ((char *) ic);
  203. ic = next;
  204. }
  205. _XimThaiIMFree(im);
  206. return(True);
  207. }