📄 i18nic.c
字号:
extern XimFrameRec attr_head_fr[]; while (total_length < value_length) { fm = FrameMgrInit (attr_head_fr, (char *) p1, need_swap); /* get data */ FrameMgrGetToken (fm, attribute_ID); FrameMgrGetToken (fm, attribute_length); FrameMgrFree (fm); p1 += sizeof (CARD16)*2; ReadICValue (i18n_core, attribute_ID, attribute_length, p1, (value_ret + ic_len), &number, need_swap); ic_len++; *number_ret += number; p1 += attribute_length; p1 += IMPAD (attribute_length); total_length += (CARD16) sizeof(CARD16)*2 + (INT16) attribute_length + IMPAD (attribute_length); } /*endwhile*/ return ic_len; } case XimType_CARD8: case XimType_CARD16: case XimType_CARD32: case XimType_Window: SetCardAttribute (value_ret, p, ic_attr, value_length, need_swap); *number_ret = (CARD16) 1; return *number_ret; case XimType_XFontSet: SetFontAttribute (value_ret, p, ic_attr, value_length, need_swap); *number_ret = (CARD16) 1; return *number_ret; case XimType_XRectangle: SetRectAttribute (value_ret, p, ic_attr, value_length, need_swap); *number_ret = (CARD16) 1; return *number_ret; case XimType_XPoint: SetPointAttribute(value_ret, p, ic_attr, value_length, need_swap); *number_ret = (CARD16) 1; return *number_ret;#if 0 case XimType_XIMHotKeyTriggers: SetHotKeyAttribute (value_ret, p, ic_attr, value_length, need_swap); *number_ret = (CARD16) 1; return *number_ret;#endif } /*endswitch*/ return 0;}static XICAttribute *CreateNestedList (CARD16 attr_id, XICAttribute *list, int number, int need_swap){ XICAttribute *nest_list = NULL; register int i; char *values = NULL; char *valuesp; int value_length = 0; if (number == 0) return NULL; /*endif*/ for (i = 0; i < number; i++) { value_length += sizeof (CARD16)*2; value_length += list[i].value_length; value_length += IMPAD (list[i].value_length); } /*endfor*/ if ((values = (char *) malloc (value_length)) == NULL) return NULL; /*endif*/ memset (values, 0, value_length); valuesp = values; for (i = 0; i < number; i++) { switch (list[i].type) { case XimType_CARD8: case XimType_CARD16: case XimType_CARD32: case XimType_Window: GetCardAttribute (valuesp, &list[i], need_swap); break; case XimType_XFontSet: GetFontAttribute (valuesp, &list[i], need_swap); break; case XimType_XRectangle: GetRectAttribute (valuesp, &list[i], need_swap); break; case XimType_XPoint: GetPointAttribute (valuesp, &list[i], need_swap); break;#if 0 case XimType_XIMHotKeyTriggers: GetHotKeyAttribute (valuesp, &list[i], need_swap); break;#endif } /*endswitch*/ valuesp += sizeof (CARD16)*2; valuesp += list[i].value_length; valuesp += IMPAD(list[i].value_length); } /*endfor*/ nest_list = (XICAttribute *) malloc (sizeof (XICAttribute)); if (nest_list == NULL) return NULL; /*endif*/ memset (nest_list, 0, sizeof (XICAttribute)); nest_list->value = (void *) malloc (value_length); if (nest_list->value == NULL) return NULL; /*endif*/ memset (nest_list->value, 0, sizeof (value_length)); nest_list->attribute_id = attr_id; nest_list->value_length = value_length; memmove (nest_list->value, values, value_length); XFree (values); return nest_list;}static Bool IsNestedList (Xi18n i18n_core, CARD16 icvalue_id){ XICAttr *ic_attr = i18n_core->address.xic_attr; int i; for (i = 0; i < i18n_core->address.ic_attr_num; i++, ic_attr++) { if (ic_attr->attribute_id == icvalue_id) { if (ic_attr->type == XimType_NEST) return True; /*endif*/ return False; } /*endif*/ } /*endfor*/ return False;}static Bool IsSeparator (Xi18n i18n_core, CARD16 icvalue_id){ return (i18n_core->address.separatorAttr_id == icvalue_id);}static int GetICValue (Xi18n i18n_core, XICAttribute *attr_ret, CARD16 *id_list, int list_num){ XICAttr *xic_attr = i18n_core->address.xic_attr; register int i; register int j; register int n; i = n = 0; if (IsNestedList (i18n_core, id_list[i])) { i++; while (i < list_num && !IsSeparator (i18n_core, id_list[i])) { for (j = 0; j < i18n_core->address.ic_attr_num; j++) { if (xic_attr[j].attribute_id == id_list[i]) { attr_ret[n].attribute_id = xic_attr[j].attribute_id; attr_ret[n].name_length = xic_attr[j].length; attr_ret[n].name = malloc (xic_attr[j].length + 1); memcpy (attr_ret[n].name, xic_attr[j].name, xic_attr[j].length); attr_ret[n].name[xic_attr[j].length] = '\0'; attr_ret[n].type = xic_attr[j].type; n++; i++; break; } /*endif*/ } /*endfor*/ } /*endwhile*/ } else { for (j = 0; j < i18n_core->address.ic_attr_num; j++) { if (xic_attr[j].attribute_id == id_list[i]) { attr_ret[n].attribute_id = xic_attr[j].attribute_id; attr_ret[n].name_length = xic_attr[j].length; attr_ret[n].name = malloc (xic_attr[j].length + 1); memcpy (attr_ret[n].name, xic_attr[j].name, xic_attr[j].length); attr_ret[n].name[xic_attr[j].length] = '\0'; attr_ret[n].type = xic_attr[j].type; n++; break; } /*endif*/ } /*endfor*/ } /*endif*/ return n;}/* called from CreateICMessageProc and SetICValueMessageProc */void _Xi18nChangeIC (XIMS ims, IMProtocol *call_data, unsigned char *p, int create_flag){ Xi18n i18n_core = ims->protocol; FrameMgr fm; FmStatus status; CARD16 byte_length; register int total_size; unsigned char *reply = NULL; register int i; register int attrib_num; XICAttribute *attrib_list; XICAttribute pre_attr[IC_SIZE]; XICAttribute sts_attr[IC_SIZE]; XICAttribute ic_attr[IC_SIZE]; CARD16 preedit_ic_num = 0; CARD16 status_ic_num = 0; CARD16 ic_num = 0; CARD16 connect_id = call_data->any.connect_id; IMChangeICStruct *changeic = (IMChangeICStruct *) &call_data->changeic; extern XimFrameRec create_ic_fr[]; extern XimFrameRec create_ic_reply_fr[]; extern XimFrameRec set_ic_values_fr[]; extern XimFrameRec set_ic_values_reply_fr[]; CARD16 input_method_ID; memset (pre_attr, 0, sizeof (XICAttribute)*IC_SIZE); memset (sts_attr, 0, sizeof (XICAttribute)*IC_SIZE); memset (ic_attr, 0, sizeof (XICAttribute)*IC_SIZE); if (create_flag == True) { fm = FrameMgrInit (create_ic_fr, (char *) p, _Xi18nNeedSwap (i18n_core, connect_id)); /* get data */ FrameMgrGetToken (fm, input_method_ID); FrameMgrGetToken (fm, byte_length); } else { fm = FrameMgrInit (set_ic_values_fr, (char *) p, _Xi18nNeedSwap (i18n_core, connect_id)); /* get data */ FrameMgrGetToken (fm, input_method_ID); FrameMgrGetToken (fm, changeic->icid); FrameMgrGetToken (fm, byte_length); } /*endif*/ attrib_list = (XICAttribute *) malloc (sizeof (XICAttribute)*IC_SIZE); if (!attrib_list) { _Xi18nSendMessage (ims, connect_id, XIM_ERROR, 0, 0, 0); return; } /*endif*/ memset (attrib_list, 0, sizeof(XICAttribute)*IC_SIZE); attrib_num = 0; while (FrameMgrIsIterLoopEnd (fm, &status) == False) { void *value; int value_length; FrameMgrGetToken (fm, attrib_list[attrib_num].attribute_id); FrameMgrGetToken (fm, value_length); FrameMgrSetSize (fm, value_length); attrib_list[attrib_num].value_length = value_length; FrameMgrGetToken (fm, value); attrib_list[attrib_num].value = (void *) malloc (value_length + 1); memmove (attrib_list[attrib_num].value, value, value_length); attrib_num++; } /*endwhile*/ for (i = 0; i < attrib_num; i++) { CARD16 number; if (IsNestedList (i18n_core, attrib_list[i].attribute_id)) { if (attrib_list[i].attribute_id == i18n_core->address.preeditAttr_id) { ReadICValue (i18n_core, attrib_list[i].attribute_id, attrib_list[i].value_length, attrib_list[i].value, &pre_attr[preedit_ic_num], &number, _Xi18nNeedSwap(i18n_core, connect_id)); preedit_ic_num += number; } else if (attrib_list[i].attribute_id == i18n_core->address.statusAttr_id) { ReadICValue (i18n_core, attrib_list[i].attribute_id, attrib_list[i].value_length, attrib_list[i].value, &sts_attr[status_ic_num], &number, _Xi18nNeedSwap (i18n_core, connect_id)); status_ic_num += number; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -