1 /******************************************************************
3 Copyright 1992, 1993, 1994 by FUJITSU LIMITED
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
8 that both that copyright notice and this permission notice appear
9 in supporting documentation, and that the name of FUJITSU LIMITED
10 not be used in advertising or publicity pertaining to distribution
11 of the software without specific, written prior permission.
12 FUJITSU LIMITED makes no representations about the suitability of
13 this software for any purpose.
14 It is provided "as is" without express or implied warranty.
16 FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
20 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 PERFORMANCE OF THIS SOFTWARE.
24 Author: Takashi Fujiwara FUJITSU LIMITED
25 fujiwara@a80.tech.yk.fujitsu.co.jp
27 ******************************************************************/
37 Private XIMResourceList
38 _XimGetNestedListSeparator(
39 XIMResourceList res_list, /* LISTofIMATTR or IMATTR */
42 return _XimGetResourceListRec(res_list, res_num, XNSeparatorofNestedList);
46 _XimCheckInnerIMAttributes(
54 if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
55 im->private.proto.im_num_inner_resources, arg->name)))
58 check = _XimCheckIMMode(res, mode);
59 if(check == XIM_CHECK_INVALID)
61 else if(check == XIM_CHECK_ERROR)
70 XIMResourceList res_list,
85 for (p = arg; p->name; p++) {
86 if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
87 if (_XimCheckInnerIMAttributes(im, p, mode))
92 check = _XimCheckIMMode(res, mode);
93 if (check == XIM_CHECK_INVALID)
95 else if (check == XIM_CHECK_ERROR)
99 *len += sizeof(CARD16);
106 _XimCheckInnerICAttributes(
114 if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
115 ic->private.proto.ic_num_inner_resources, arg->name)))
118 check = _XimCheckICMode(res, mode);
119 if(check == XIM_CHECK_INVALID)
121 else if(check == XIM_CHECK_ERROR)
128 _XimMakeICAttrIDList(
130 XIMResourceList res_list,
131 unsigned int res_num,
149 pre_quark = XrmStringToQuark(XNPreeditAttributes);
150 sts_quark = XrmStringToQuark(XNStatusAttributes);
152 for (p = arg; p && p->name; p++) {
153 if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
154 if (_XimCheckInnerICAttributes(ic, p, mode))
160 check = _XimCheckICMode(res, mode);
161 if(check == XIM_CHECK_INVALID)
163 else if(check == XIM_CHECK_ERROR) {
169 *len += sizeof(CARD16);
171 if (res->resource_size == XimType_NEST) {
172 if (res->xrm_name == pre_quark) {
173 if ((name = _XimMakeICAttrIDList(ic, res_list, res_num,
174 (XIMArg *)p->value, buf, &new_len,
175 (mode | XIM_PREEDIT_ATTR)))) {
176 if (new_len < 0) *len = -1;
177 else *len += new_len;
181 buf = (CARD16 *)((char *)buf + new_len);
182 } else if (res->xrm_name == sts_quark) {
183 if ((name = _XimMakeICAttrIDList(ic, res_list, res_num,
184 (XIMArg *)p->value, buf, &new_len,
185 (mode | XIM_STATUS_ATTR)))) {
186 if (new_len < 0) *len = -1;
187 else *len += new_len;
191 buf = (CARD16 *)((char *)buf + new_len);
194 if (!(res = _XimGetNestedListSeparator(res_list, res_num))) {
205 *len += sizeof(CARD16);
213 _XimAttributeToValue(
221 switch (res->resource_size) {
222 case XimType_SeparatorOfNestedList:
230 case XimType_XIMHotKeyState:
231 _XCopyToArg((XPointer)data, (XPointer *)&value, data_len);
234 case XimType_STRING8:
241 if (!(str = (char *)Xmalloc(data_len + 1)))
244 (void)memcpy(str, (char *)data, data_len);
245 str[data_len] = '\0';
247 *((char **)value) = str;
251 case XimType_XIMStyles:
254 register CARD32 *style_list = (CARD32 *)&data[2];
264 alloc_len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
265 if (!(p = (char *)Xmalloc(alloc_len)))
268 rep = (XIMStyles *)p;
269 style = (XIMStyle *)(p + sizeof(XIMStyles));
271 for (i = 0; i < num; i++)
272 style[i] = (XIMStyle)style_list[i];
274 rep->count_styles = (unsigned short)num;
275 rep->supported_styles = style;
276 *((XIMStyles **)value) = rep;
280 case XimType_XRectangle:
287 if (!(rep = (XRectangle *)Xmalloc(sizeof(XRectangle))))
292 rep->width = data[2];
293 rep->height = data[3];
294 *((XRectangle **)value) = rep;
305 if (!(rep = (XPoint *)Xmalloc(sizeof(XPoint))))
310 *((XPoint **)value) = rep;
314 case XimType_XFontSet:
318 XFontSet rep = (XFontSet)NULL;
319 char **missing_list = NULL;
328 if (!(base_name = (char *)Xmalloc(len + 1)))
331 (void)strncpy(base_name, (char *)&data[1], (int)len);
332 base_name[len] = '\0';
334 if (mode & XIM_PREEDIT_ATTR) {
335 if (!strcmp(base_name, ic->private.proto.preedit_font)) {
336 rep = ic->core.preedit_attr.fontset;
337 } else if (!ic->private.proto.preedit_font_length) {
338 rep = XCreateFontSet(ic->core.im->core.display,
339 base_name, &missing_list,
340 &missing_count, &def_string);
342 } else if (mode & XIM_STATUS_ATTR) {
343 if (!strcmp(base_name, ic->private.proto.status_font)) {
344 rep = ic->core.status_attr.fontset;
345 } else if (!ic->private.proto.status_font_length) {
346 rep = XCreateFontSet(ic->core.im->core.display,
347 base_name, &missing_list,
348 &missing_count, &def_string);
354 *((XFontSet *)value) = rep;
358 case XimType_XIMHotKeyTriggers:
360 INT32 num = *((CARD32 *)data);
361 register CARD32 *key_list = (CARD32 *)&data[2];
362 XIMHotKeyTrigger *key;
363 XIMHotKeyTriggers *rep;
371 alloc_len = sizeof(XIMHotKeyTriggers)
372 + sizeof(XIMHotKeyTrigger) * num;
373 if (!(p = (char *)Xmalloc(alloc_len)))
376 rep = (XIMHotKeyTriggers *)p;
377 key = (XIMHotKeyTrigger *)(p + sizeof(XIMHotKeyTriggers));
379 for (i = 0; i < num; i++, key_list += 3) {
380 key[i].keysym = (KeySym)key_list[0]; /* keysym */
381 key[i].modifier = (int)key_list[1]; /* modifier */
382 key[i].modifier_mask = (int)key_list[2]; /* modifier_mask */
385 rep->num_hot_key = (int)num;
387 *((XIMHotKeyTriggers **)value) = rep;
391 case XimType_XIMStringConversion:
403 _XimDecodeInnerIMATTRIBUTE(
408 XimDefIMValues im_values;
410 if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
411 im->private.proto.im_num_inner_resources, arg->name)))
414 _XimGetCurrentIMValues(im, &im_values);
415 return _XimDecodeLocalIMAttr(res, (XPointer)&im_values, arg->value);
419 _XimDecodeIMATTRIBUTE(
421 XIMResourceList res_list,
422 unsigned int res_num,
434 INT16 min_len = sizeof(CARD16) /* sizeof attributeID */
435 + sizeof(INT16); /* sizeof length */
437 for (p = arg; p->name; p++) {
438 if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
439 if (_XimDecodeInnerIMATTRIBUTE(im, p))
444 check = _XimCheckIMMode(res, mode);
445 if(check == XIM_CHECK_INVALID)
447 else if(check == XIM_CHECK_ERROR)
452 while (total >= min_len) {
453 if (res->id == buf[0])
457 len += XIM_PAD(len) + min_len;
458 buf = (CARD16 *)((char *)buf + len);
464 if (!(_XimAttributeToValue((Xic) im->private.local.current_ic,
465 res, &buf[2], buf[1], p->value, mode)))
472 _XimDecodeInnerICATTRIBUTE(
478 XimDefICValues ic_values;
480 if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
481 ic->private.proto.ic_num_inner_resources, arg->name)))
484 _XimGetCurrentICValues(ic, &ic_values);
485 if (!_XimDecodeLocalICAttr(res, (XPointer)&ic_values, arg->value, mode))
487 _XimSetCurrentICValues(ic, &ic_values);
492 _XimDecodeICATTRIBUTE(
494 XIMResourceList res_list,
495 unsigned int res_num,
508 INT16 min_len = sizeof(CARD16) /* sizeof attributeID */
509 + sizeof(INT16); /* sizeof length */
516 pre_quark = XrmStringToQuark(XNPreeditAttributes);
517 sts_quark = XrmStringToQuark(XNStatusAttributes);
519 for (p = arg; p->name; p++) {
520 if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
521 if (_XimDecodeInnerICATTRIBUTE(ic, p, mode))
526 check = _XimCheckICMode(res, mode);
527 if (check == XIM_CHECK_INVALID)
529 else if (check == XIM_CHECK_ERROR)
534 while (total >= min_len) {
535 if (res->id == buf[0])
539 len += XIM_PAD(len) + min_len;
540 buf = (CARD16 *)((char *)buf + len);
546 if (res->resource_size == XimType_NEST) {
547 if (res->xrm_name == pre_quark) {
548 if ((name = _XimDecodeICATTRIBUTE(ic, res_list, res_num,
549 &buf[2], buf[1], (XIMArg *)p->value,
550 (mode | XIM_PREEDIT_ATTR))))
552 } else if (res->xrm_name == sts_quark) {
553 if ((name = _XimDecodeICATTRIBUTE(ic, res_list, res_num,
554 &buf[2], buf[1], (XIMArg *)p->value,
555 (mode | XIM_STATUS_ATTR))))
559 if (!(_XimAttributeToValue(ic, res, &buf[2], buf[1],
568 _XimValueToAttribute(
579 switch (res->resource_size) {
580 case XimType_SeparatorOfNestedList:
586 ret_len = sizeof(CARD8);
587 if (buf_size < ret_len + XIM_PAD(ret_len)) {
592 *((CARD8 *)buf) = (CARD8)(long)value;
597 ret_len = sizeof(CARD16);
598 if (buf_size < ret_len + XIM_PAD(ret_len)) {
603 *((CARD16 *)buf) = (CARD16)(long)value;
609 case XimType_XIMHotKeyState:
610 ret_len = sizeof(CARD32);
611 if (buf_size < ret_len + XIM_PAD(ret_len)) {
616 *((CARD32 *)buf) = (CARD32)(long)value;
620 case XimType_STRING8:
626 ret_len = strlen((char *)value);
627 if (buf_size < ret_len + XIM_PAD(ret_len)) {
632 (void)memcpy((char *)buf, (char *)value, ret_len);
636 case XimType_XRectangle:
638 XRectangle *rect = (XRectangle *)value;
639 CARD16 *buf_s = (CARD16 *)buf;
646 ret_len = sizeof(INT16) /* sizeof X */
647 + sizeof(INT16) /* sizeof Y */
648 + sizeof(CARD16) /* sizeof width */
649 + sizeof(CARD16); /* sizeof height */
650 if (buf_size < ret_len + XIM_PAD(ret_len)) {
655 buf_s[0] = (CARD16)rect->x; /* X */
656 buf_s[1] = (CARD16)rect->y; /* Y */
657 buf_s[2] = (CARD16)rect->width; /* width */
658 buf_s[3] = (CARD16)rect->height; /* heght */
665 XPoint *point = (XPoint *)value;
666 CARD16 *buf_s = (CARD16 *)buf;
673 ret_len = sizeof(INT16) /* sizeof X */
674 + sizeof(INT16); /* sizeof Y */
675 if (buf_size < ret_len + XIM_PAD(ret_len)) {
680 buf_s[0] = (CARD16)point->x; /* X */
681 buf_s[1] = (CARD16)point->y; /* Y */
686 case XimType_XFontSet:
688 XFontSet font = (XFontSet)value;
690 char *base_name = NULL;
692 CARD16 *buf_s = (CARD16 *)buf;
699 if (mode & XIM_PREEDIT_ATTR) {
700 base_name = ic->private.proto.preedit_font;
701 length = ic->private.proto.preedit_font_length;
702 } else if (mode & XIM_STATUS_ATTR) {
703 base_name = ic->private.proto.status_font;
704 length = ic->private.proto.status_font_length;
712 ret_len = sizeof(CARD16) /* sizeof length of Base name */
713 + length; /* sizeof Base font name list */
714 if (buf_size < ret_len + XIM_PAD(ret_len)) {
719 buf_s[0] = (INT16)length; /* length of Base font name */
720 (void)memcpy((char *)&buf_s[1], base_name, length);
721 /* Base font name list */
726 case XimType_XIMHotKeyTriggers:
728 XIMHotKeyTriggers *hotkey = (XIMHotKeyTriggers *)value;
730 CARD32 *buf_l = (CARD32 *)buf;
731 register CARD32 *key = (CARD32 *)&buf_l[1];
738 num = (INT32)hotkey->num_hot_key;
740 ret_len = sizeof(INT32) /* sizeof number of key list */
741 + (sizeof(CARD32) /* sizeof keysyn */
742 + sizeof(CARD32) /* sizeof modifier */
743 + sizeof(CARD32)) /* sizeof modifier_mask */
744 * num; /* number of key list */
745 if (buf_size < ret_len + XIM_PAD(ret_len)) {
750 buf_l[0] = num; /* number of key list */
751 for (i = 0; i < num; i++, key += 3) {
752 key[0] = (CARD32)(hotkey->key[i].keysym);
754 key[1] = (CARD32)(hotkey->key[i].modifier);
756 key[2] = (CARD32)(hotkey->key[i].modifier_mask);
763 case XimType_XIMStringConversion:
776 _XimSetInnerIMAttributes(
785 if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
786 im->private.proto.im_num_inner_resources, arg->name)))
789 check = _XimCheckIMMode(res, mode);
790 if(check == XIM_CHECK_INVALID)
792 else if(check == XIM_CHECK_ERROR)
795 return _XimEncodeLocalIMAttr(res, top, arg->value);
799 _XimEncodeIMATTRIBUTE(
801 XIMResourceList res_list,
802 unsigned int res_num,
816 int min_len = sizeof(CARD16) /* sizeof attribute ID */
817 + sizeof(INT16); /* sizeof value length */
820 for (p = arg; p->name; p++) {
821 if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
822 if (_XimSetInnerIMAttributes(im, top, p, mode))
827 check = _XimCheckIMMode(res, mode);
828 if (check == XIM_CHECK_INVALID)
830 else if (check == XIM_CHECK_ERROR)
833 if (!(_XimEncodeLocalIMAttr(res, top, p->value)))
836 buf_s = (CARD16 *)buf;
837 if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2], (size - min_len),
838 p->value, &len, mode, (XPointer)NULL)))
843 } else if (len < 0) {
848 buf_s[0] = res->id; /* attribute ID */
849 buf_s[1] = len; /* value length */
850 XIM_SET_PAD(&buf_s[2], len); /* pad */
857 *arg_ret = (XIMArg *)NULL;
861 #ifdef XIM_CONNECTABLE
863 _XimEncodeSavedIMATTRIBUTE(
865 XIMResourceList res_list,
866 unsigned int res_num,
875 int num = im->private.proto.num_saved_imvalues;
876 XrmQuark *quark_list = im->private.proto.saved_imvalues;
881 int min_len = sizeof(CARD16) /* sizeof attribute ID */
882 + sizeof(INT16); /* sizeof value length */
884 if (!im->private.proto.saved_imvalues) {
891 for (i = *idx; i < num; i++) {
892 if (!(res = _XimGetResourceListRecByQuark(res_list,
893 res_num, quark_list[i])))
896 if (!_XimDecodeLocalIMAttr(res, top, value))
899 buf_s = (CARD16 *)buf;
900 if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
901 (size - min_len), value, &len, mode, (XPointer)NULL)))
906 } else if (len < 0) {
911 buf_s[0] = res->id; /* attribute ID */
912 buf_s[1] = len; /* value length */
913 XIM_SET_PAD(&buf_s[2], len); /* pad */
923 #endif /* XIM_CONNECTABLE */
931 if (res->xrm_name == XrmStringToQuark(XNClientWindow)) {
932 ic->core.client_window = (Window)p->value;
933 if (ic->core.focus_window == (Window)0)
934 ic->core.focus_window = ic->core.client_window;
935 _XimRegisterFilter(ic);
937 } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) {
938 if (ic->core.client_window) {
939 _XimUnregisterFilter(ic);
940 ic->core.focus_window = (Window)p->value;
941 _XimRegisterFilter(ic);
942 } else /* client_window not yet */
943 ic->core.focus_window = (Window)p->value;
949 _XimEncodePreeditValue(
954 if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
955 XStandardColormap *colormap_ret;
958 if (!(XGetRGBColormaps(ic->core.im->core.display,
959 ic->core.focus_window, &colormap_ret,
960 &count, (Atom)p->value)))
964 } else if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
966 XFontStruct **struct_list;
975 if (ic->private.proto.preedit_font)
976 Xfree(ic->private.proto.preedit_font);
978 list_ret = XFontsOfFontSet((XFontSet)p->value,
979 &struct_list, &name_list);
980 for (i = 0, len = 0; i < list_ret; i++) {
981 len += (strlen(name_list[i]) + sizeof(char));
983 if (!(tmp = Xmalloc(len + 1))) {
984 ic->private.proto.preedit_font = NULL;
989 for (i = 0; i < list_ret; i++) {
990 strcat(tmp, name_list[i]);
994 ic->private.proto.preedit_font = tmp;
995 ic->private.proto.preedit_font_length = len - 1;
1001 _XimEncodeStatusValue(
1003 XIMResourceList res,
1006 if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
1007 XStandardColormap *colormap_ret = NULL;
1010 if (!(XGetRGBColormaps(ic->core.im->core.display,
1011 ic->core.focus_window, &colormap_ret,
1012 &count, (Atom)p->value)))
1015 XFree(colormap_ret);
1016 } else if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
1018 XFontStruct **struct_list;
1027 if (ic->private.proto.status_font)
1028 Xfree(ic->private.proto.status_font);
1030 list_ret = XFontsOfFontSet((XFontSet)p->value,
1031 &struct_list, &name_list);
1032 for (i = 0, len = 0; i < list_ret; i++) {
1033 len += (strlen(name_list[i]) + sizeof(char));
1035 if (!(tmp = Xmalloc(len+1))) {
1036 ic->private.proto.status_font = NULL;
1041 for(i = 0; i < list_ret; i++) {
1042 strcat(tmp, name_list[i]);
1046 ic->private.proto.status_font = tmp;
1047 ic->private.proto.status_font_length = len - 1;
1053 _XimSetInnerICAttributes(
1059 XIMResourceList res;
1062 if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
1063 ic->private.proto.ic_num_inner_resources, arg->name)))
1066 check = _XimCheckICMode(res, mode);
1067 if(check == XIM_CHECK_INVALID)
1069 else if(check == XIM_CHECK_ERROR)
1072 return _XimEncodeLocalICAttr(ic, res, top, arg, mode);
1076 _XimEncodeICATTRIBUTE(
1078 XIMResourceList res_list,
1079 unsigned int res_num,
1090 XIMResourceList res;
1094 int min_len = sizeof(CARD16) /* sizeof attribute ID */
1095 + sizeof(INT16); /* sizeof value length */
1100 pre_quark = XrmStringToQuark(XNPreeditAttributes);
1101 sts_quark = XrmStringToQuark(XNStatusAttributes);
1104 for (p = arg; p && p->name; p++) {
1105 buf_s = (CARD16 *)buf;
1106 if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
1107 if (_XimSetInnerICAttributes(ic, top, p, mode))
1112 check = _XimCheckICMode(res, mode);
1113 if (check == XIM_CHECK_INVALID)
1115 else if (check == XIM_CHECK_ERROR)
1118 if (mode & XIM_PREEDIT_ATTR) {
1119 if (!(_XimEncodePreeditValue(ic, res, p)))
1121 } else if (mode & XIM_STATUS_ATTR) {
1122 if (!(_XimEncodeStatusValue(ic, res, p)))
1125 if (!(_XimEncodeTopValue(ic, res, p)))
1129 if (res->resource_size == XimType_NEST) {
1130 XimDefICValues *ic_attr = (XimDefICValues *)top;
1132 if (res->xrm_name == pre_quark) {
1134 if ((name = _XimEncodeICATTRIBUTE(ic, res_list, res_num,
1135 (XIMArg *)p->value, &arg_rt,
1136 (char *)&buf_s[2], (size - min_len),
1137 &len, (XPointer)&ic_attr->preedit_attr, flag,
1138 (mode | XIM_PREEDIT_ATTR)))) {
1142 } else if (res->xrm_name == sts_quark) {
1144 if ((name = _XimEncodeICATTRIBUTE(ic, res_list, res_num,
1145 (XIMArg *)p->value, &arg_rt,
1146 (char *)&buf_s[2], (size - min_len),
1147 &len, (XPointer)&ic_attr->status_attr, flag,
1148 (mode | XIM_STATUS_ATTR)))) {
1155 *flag |= _XimExtenArgCheck(p);
1157 if (!(_XimEncodeLocalICAttr(ic, res, top, p, mode)))
1160 if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
1161 (size - min_len), p->value,
1162 &len, mode, (XPointer)ic)))
1168 } else if (len < 0) {
1170 return (char *)NULL;
1173 buf_s[0] = res->id; /* attribute ID */
1174 buf_s[1] = len; /* value length */
1175 XIM_SET_PAD(&buf_s[2], len); /* pad */
1182 *arg_ret = (XIMArg *)NULL;
1183 return (char *)NULL;
1186 #ifdef XIM_CONNECTABLE
1188 _XimEncodeSavedPreeditValue(
1190 XIMResourceList res,
1194 XFontStruct **struct_list;
1200 if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
1204 if (ic->private.proto.preedit_font)
1205 Xfree(ic->private.proto.preedit_font);
1207 list_ret = XFontsOfFontSet((XFontSet)value,
1208 &struct_list, &name_list);
1209 for(i = 0, len = 0; i < list_ret; i++) {
1210 len += (strlen(name_list[i]) + sizeof(char));
1212 if(!(tmp = Xmalloc(len + 1))) {
1213 ic->private.proto.preedit_font = NULL;
1218 for(i = 0; i < list_ret; i++) {
1219 strcat(tmp, name_list[i]);
1223 ic->private.proto.preedit_font = tmp;
1224 ic->private.proto.preedit_font_length = len - 1;
1230 _XimEncodeSavedStatusValue(
1232 XIMResourceList res,
1236 XFontStruct **struct_list;
1242 if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
1246 if (ic->private.proto.status_font)
1247 Xfree(ic->private.proto.status_font);
1249 list_ret = XFontsOfFontSet((XFontSet)value,
1250 &struct_list, &name_list);
1251 for(i = 0, len = 0; i < list_ret; i++) {
1252 len += (strlen(name_list[i]) + sizeof(char));
1254 if(!(tmp = Xmalloc(len + 1))) {
1255 ic->private.proto.status_font = NULL;
1260 for(i = 0; i < list_ret; i++) {
1261 strcat(tmp, name_list[i]);
1265 ic->private.proto.status_font = tmp;
1266 ic->private.proto.status_font_length = len - 1;
1272 _XimEncodeSavedICATTRIBUTE(
1274 XIMResourceList res_list,
1275 unsigned int res_num,
1284 int num = ic->private.proto.num_saved_icvalues;
1285 XrmQuark *quark_list = ic->private.proto.saved_icvalues;
1286 XIMResourceList res;
1290 int min_len = sizeof(CARD16) /* sizeof attribute ID */
1291 + sizeof(INT16); /* sizeof value length */
1296 if (!ic->private.proto.saved_icvalues) {
1302 pre_quark = XrmStringToQuark(XNPreeditAttributes);
1303 sts_quark = XrmStringToQuark(XNStatusAttributes);
1304 separator = XrmStringToQuark(XNSeparatorofNestedList);
1307 for (i = *idx; i < num; i++) {
1308 if (quark_list[i] == separator) {
1313 if (!(res = _XimGetResourceListRecByQuark(res_list,
1314 res_num, quark_list[i])))
1317 if (!_XimDecodeLocalICAttr(res, top,(XPointer)&value, mode))
1320 if (mode & XIM_PREEDIT_ATTR) {
1321 if (!(_XimEncodeSavedPreeditValue(ic, res, value))) {
1324 } else if (mode & XIM_STATUS_ATTR) {
1325 if (!(_XimEncodeSavedStatusValue(ic, res, value))) {
1330 buf_s = (CARD16 *)buf;
1331 if (res->resource_size == XimType_NEST) {
1332 XimDefICValues *ic_attr = (XimDefICValues *)top;
1335 if (res->xrm_name == pre_quark) {
1336 if (!_XimEncodeSavedICATTRIBUTE(ic, res_list, res_num,
1337 &i, (char *)&buf_s[2], (size - min_len),
1338 &len, (XPointer)&ic_attr->preedit_attr,
1339 (mode | XIM_PREEDIT_ATTR))) {
1343 } else if (res->xrm_name == sts_quark) {
1344 if (!_XimEncodeSavedICATTRIBUTE(ic, res_list, res_num,
1345 &i, (char *)&buf_s[2], (size - min_len),
1346 &len, (XPointer)&ic_attr->status_attr,
1347 (mode | XIM_STATUS_ATTR))) {
1352 if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
1353 (size - min_len), value,
1354 &len, mode, (XPointer)ic))) {
1361 } else if (len < 0) {
1362 if (quark_list[i] == separator)
1368 buf_s[0] = res->id; /* attribute ID */
1369 buf_s[1] = len; /* value length */
1370 XIM_SET_PAD(&buf_s[2], len); /* pad */
1380 #endif /* XIM_CONNECTABLE */
1382 Private unsigned int
1383 _XimCountNumberOfAttr(
1390 INT16 min_len = sizeof(CARD16) /* sizeof attribute ID */
1391 + sizeof(CARD16) /* sizeof type of value */
1392 + sizeof(INT16); /* sizeof length of attribute */
1396 while (total > min_len) {
1398 *names_len += (len + 1);
1399 len += (min_len + XIM_PAD(len + 2));
1401 attr = (CARD16 *)((char *)attr + len);
1413 XIMResourceList res;
1417 XIMValuesList *values_list;
1422 INT16 min_len = sizeof(CARD16) /* sizeof attribute ID */
1423 + sizeof(CARD16) /* sizeof type of value */
1424 + sizeof(INT16); /* sizeof length of attr */
1429 if (!(n = _XimCountNumberOfAttr(buf[0], &buf[1], &names_len)))
1432 if (!(res = Xcalloc(n, sizeof(XIMResource))))
1435 values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len;
1436 if (!(tmp = Xcalloc(1, values_len))) {
1441 values_list = (XIMValuesList *)tmp;
1442 values = (char **)((char *)tmp + sizeof(XIMValuesList));
1443 names = (char *)((char *)values + (sizeof(char **) * n));
1445 values_list->count_values = n;
1446 values_list->supported_values = values;
1449 for (i = 0; i < n; i++) {
1451 (void)memcpy(names, (char *)&buf[3], len);
1454 res[i].resource_name = names;
1455 res[i].resource_size = buf[1];
1458 len += (min_len + XIM_PAD(len + 2));
1459 buf = (CARD16 *)((char *)buf + len);
1461 _XIMCompileResourceList(res, n);
1463 if (im->core.im_resources)
1464 Xfree(im->core.im_resources);
1465 if (im->core.im_values_list)
1466 Xfree(im->core.im_values_list);
1467 im->core.im_resources = res;
1468 im->core.im_num_resources = n;
1469 im->core.im_values_list = values_list;
1475 if (!(n = _XimCountNumberOfAttr(buf[0], &buf[2], &names_len)))
1478 if (!(res = Xcalloc(n, sizeof(XIMResource))))
1481 values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len;
1482 if (!(tmp = Xcalloc(1, values_len))) {
1487 values_list = (XIMValuesList *)tmp;
1488 values = (char **)((char *)tmp + sizeof(XIMValuesList));
1489 names = (char *)((char *)values + (sizeof(char **) * n));
1491 values_list->count_values = n;
1492 values_list->supported_values = values;
1495 for (i = 0; i < n; i++) {
1497 (void)memcpy(names, (char *)&buf[3], len);
1500 res[i].resource_name = names;
1501 res[i].resource_size = buf[1];
1504 len += (min_len + XIM_PAD(len + 2));
1505 buf = (CARD16 *)((char *)buf + len);
1507 _XIMCompileResourceList(res, n);
1509 if (im->core.ic_resources)
1510 Xfree(im->core.ic_resources);
1511 if (im->core.ic_values_list)
1512 Xfree(im->core.ic_values_list);
1513 im->core.ic_resources = res;
1514 im->core.ic_num_resources = n;
1515 im->core.ic_values_list = values_list;