UilSemCSet.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these librararies and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * @OSF_COPYRIGHT@
  25. * COPYRIGHT NOTICE
  26. * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
  27. * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
  28. * the full copyright text.
  29. */
  30. /*
  31. * HISTORY
  32. */
  33. #ifdef REV_INFO
  34. #ifndef lint
  35. static char rcsid[] = "$TOG: UilSemCSet.c /main/10 1997/03/12 15:21:53 dbl $"
  36. #endif
  37. #endif
  38. /*
  39. * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
  40. /*
  41. **++
  42. ** FACILITY:
  43. **
  44. ** User Interface Language Compiler (UIL)
  45. **
  46. ** ABSTRACT:
  47. **
  48. ** This file contains and routines related to the semantics of
  49. ** character sets.
  50. ** semantic validation.
  51. **
  52. **--
  53. **/
  54. /*
  55. **
  56. ** INCLUDE FILES
  57. **
  58. **/
  59. #include <Xm/Xm.h>
  60. #include "UilDefI.h"
  61. /*
  62. **
  63. ** DEFINE and MACRO DEFINITIONS
  64. **
  65. **/
  66. /*
  67. **
  68. ** EXTERNAL VARIABLE DECLARATIONS
  69. **
  70. **/
  71. /*
  72. **
  73. ** GLOBAL VARIABLE DECLARATIONS
  74. **
  75. **/
  76. /*
  77. **
  78. ** OWN VARIABLE DECLARATIONS
  79. **
  80. **/
  81. /*
  82. **++
  83. ** FUNCTIONAL DESCRIPTION:
  84. **
  85. ** This function returns a pointer to a character set name given
  86. ** its sym_k_..._charset code and possibly a userdefined charset
  87. ** value entry.
  88. **
  89. ** FORMAL PARAMETERS:
  90. **
  91. ** l_charset charset of the string (token value)
  92. ** az_charset_entry charset of the string (symbol table value entry)
  93. **
  94. ** IMPLICIT INPUTS:
  95. **
  96. ** charset data tables
  97. **
  98. ** IMPLICIT OUTPUTS:
  99. **
  100. ** none
  101. **
  102. ** FUNCTION VALUE:
  103. **
  104. ** pointer to name (must NOT be freed)
  105. **
  106. ** SIDE EFFECTS:
  107. **
  108. ** error messages may be issued for objects that are still undefined
  109. ** or of the wrong type
  110. **
  111. **--
  112. **/
  113. char *sem_charset_name (l_charset, az_charset_entry)
  114. int l_charset;
  115. sym_value_entry_type *az_charset_entry;
  116. {
  117. int charset; /* mapped character set */
  118. charset = sem_map_subclass_to_charset (l_charset);
  119. switch ( charset )
  120. {
  121. case sym_k_fontlist_default_tag:
  122. return XmFONTLIST_DEFAULT_TAG;
  123. case sym_k_userdefined_charset:
  124. /*
  125. ** If the charset is user-defined, then fetch info from the symbol
  126. ** table entry for it.
  127. */
  128. _assert (az_charset_entry!=NULL, "null userdefined charset entry");
  129. return az_charset_entry->value.c_value;
  130. default:
  131. return charset_xmstring_names_table[charset];
  132. }
  133. }
  134. /*
  135. **++
  136. ** FUNCTIONAL DESCRIPTION:
  137. **
  138. ** This function returns information about the character set specified
  139. ** (writing direction and sixteen_bit properties).
  140. **
  141. ** FORMAL PARAMETERS:
  142. **
  143. ** l_charset charset of the string (token value)
  144. ** az_charset_entry charset of the string (symbol table value entry)
  145. ** direction string writing direction
  146. ** sixteen_bit Boolean return value
  147. **
  148. ** IMPLICIT INPUTS:
  149. **
  150. ** none
  151. **
  152. ** IMPLICIT OUTPUTS:
  153. **
  154. ** none
  155. **
  156. ** FUNCTION VALUE:
  157. **
  158. ** none
  159. **
  160. ** SIDE EFFECTS:
  161. **
  162. ** none
  163. **
  164. **--
  165. **/
  166. void sem_charset_info
  167. (l_charset, az_charset_entry, write_direction, parse_direction, sixteen_bit)
  168. int l_charset;
  169. sym_value_entry_type *az_charset_entry;
  170. int *write_direction;
  171. int *parse_direction;
  172. int *sixteen_bit;
  173. {
  174. int charset; /* mapped character set */
  175. charset = sem_map_subclass_to_charset (l_charset);
  176. switch (charset)
  177. {
  178. /*
  179. ** If the charset is user-defined, then fetch info from the symbol
  180. ** table entry for it.
  181. */
  182. case sym_k_userdefined_charset:
  183. {
  184. *write_direction = az_charset_entry->b_direction;
  185. *parse_direction = az_charset_entry->b_direction;
  186. *sixteen_bit = (az_charset_entry->b_aux_flags &
  187. sym_m_sixteen_bit) != 0;
  188. break;
  189. }
  190. default:
  191. {
  192. *write_direction = charset_writing_direction_table[charset];
  193. *parse_direction = charset_parsing_direction_table[charset];
  194. if ( charset_character_size_table[charset] != sym_k_onebyte_charsize )
  195. *sixteen_bit = TRUE;
  196. else
  197. *sixteen_bit = FALSE;
  198. break;
  199. }
  200. }
  201. }
  202. /*
  203. **++
  204. ** FUNCTIONAL DESCRIPTION:
  205. **
  206. ** This function returns the charset id corresponding to the
  207. ** charset specified in a $LANG variable. User-defined character
  208. ** sets are not recognized - it must be one available in the
  209. ** the compiler tables.
  210. **
  211. ** The name match is case-insensitive.
  212. **
  213. ** FORMAL PARAMETERS:
  214. **
  215. ** lang_charset string naming a character set
  216. **
  217. ** IMPLICIT INPUTS:
  218. **
  219. ** none
  220. **
  221. ** IMPLICIT OUTPUTS:
  222. **
  223. ** none
  224. **
  225. ** FUNCTION VALUE:
  226. **
  227. ** 0 no match - character set not found
  228. ** >0 character set code from sym_k_..._charset.
  229. ** sym_k_userdefined_charset is never returned.
  230. **
  231. **
  232. ** SIDE EFFECTS:
  233. **
  234. ** none
  235. **
  236. **--
  237. **/
  238. int sem_charset_lang_name (lang_charset)
  239. char *lang_charset;
  240. {
  241. char uname[200]; /* upper-case character set name */
  242. int ndx; /* loop index */
  243. /*
  244. * Convert name to upper case, then search table (which is already in
  245. * upper case).
  246. */
  247. strcpy (uname, lang_charset);
  248. for ( ndx=0 ; ndx<(int)strlen(uname) ; ndx++ )
  249. uname[ndx] = _upper (uname[ndx]);
  250. for ( ndx=0 ; ndx<(int)charset_lang_table_max ; ndx++ )
  251. if ( strcmp(uname,charset_lang_names_table[ndx]) == 0 )
  252. return (int)charset_lang_codes_table[ndx];
  253. return 0;
  254. }