int lookup_gtab_key(char *ch, void *out) { int outN=0; INMD *tinmd = &inmd[default_input_method]; int i; for(i=0; i < tinmd->DefChars; i++) { char *chi = (char *)tblch2(tinmd, i); if (!(chi[0] & 0x80)) continue; if (!utf8_eq(chi, ch)) continue; u_int64_t key = CONVT2(tinmd, i); if (ph_key_sz==4) { u_int32_t key32 = (u_int32_t)key; memcpy(get_ph_key_ptr(out, outN), &key32, ph_key_sz); } else memcpy(get_ph_key_ptr(out, outN), &key, ph_key_sz); outN++; } return outN; }
int ch_to_gtab_keys(INMD *tinmd, char *ch, u_int64_t keys[]) { int n = utf8_str_N(ch); gboolean phrase = n > 1 || !(ch[0] & 0x80); int i, keysN=0; for(i=0; i < tinmd->DefChars; i++) { char *chi = (char *)tblch2(tinmd, i); if (phrase) { if ((chi[0] & 0x80)) continue; char tstr[512]; load_phr_ch(tinmd, (u_char *)chi, tstr); if (strcmp(tstr, ch)) continue; } else { if (!(chi[0] & 0x80)) continue; if (!utf8_eq(chi, ch)) continue; } u_int64_t key = CONVT2(tinmd, i); keys[keysN++] = key; } return keysN; }