void load_ts_phrase() { FILE *fp = tsin_hand.fph; int i; dbg("fname %s\n", current_tsin_fname); int ofs = is_gtab ? sizeof(TSIN_GTAB_HEAD):0; fseek(fp, ofs, SEEK_SET); tsN=0; free(ts_idx); ts_idx=NULL; while (!feof(fp)) { ts_idx = trealloc(ts_idx, int, tsN); ts_idx[tsN] = ftell(fp); u_int64_t phbuf[MAX_PHRASE_LEN]; char chbuf[MAX_PHRASE_LEN * CH_SZ + 1]; u_char clen; usecount_t usecount; clen = 0; fread(&clen,1,1,fp); if (clen > MAX_PHRASE_LEN) { box_warn("bad tsin db clen %d > MAX_PHRASE_LEN %d\n", clen, MAX_PHRASE_LEN); break; } fread(&usecount,sizeof(usecount_t), 1, fp); fread(phbuf, ph_key_sz, clen, fp); int tlen = 0; for(i=0; i < clen; i++) { int n = fread(&chbuf[tlen], 1, 1, fp); if (n<=0) goto stop; int len=utf8_sz(&chbuf[tlen]); fread(&chbuf[tlen+1], 1, len-1, fp); tlen+=len; } if (clen < 2) continue; chbuf[tlen]=0; tsN++; } page_ofs = tsN - PAGE_LEN; if (page_ofs < 0) page_ofs = 0; stop: dbg("load_ts_phrase\n"); // fclose(fp); }
GCIN_module_callback_functions *init_GCIN_module_callback_functions(char *sofile) { #if UNIX void *handle; char *error; dbg("dlopen %s\n", sofile); if (!(handle = dlopen(sofile, RTLD_LAZY))) { if ((error = dlerror()) != NULL) box_warn(error); return NULL; } #else HMODULE handle = LoadLibraryA(sofile); if (!handle) { box_warn("LoadLibraryA %s error %s", sofile, sys_err_strA()); return NULL; } #define dlsym GetProcAddress #endif GCIN_module_callback_functions st; *(void **) (&st.module_init_win) = dlsym(handle, "module_init_win"); if (!st.module_init_win) p_err("module_init_win() not found in %s", sofile); *(void **) (&st.module_get_win_geom) = dlsym(handle, "module_get_win_geom"); *(void **) (&st.module_reset) = dlsym(handle, "module_reset"); *(void **) (&st.module_get_preedit) = dlsym(handle, "module_get_preedit"); *(void **) (&st.module_feedkey) = dlsym(handle, "module_feedkey"); *(void **) (&st.module_feedkey_release) = dlsym(handle, "module_feedkey_release"); *(void **) (&st.module_move_win) = dlsym(handle, "module_move_win"); *(void **) (&st.module_change_font_size) = dlsym(handle, "module_change_font_size"); *(void **) (&st.module_show_win) = dlsym(handle, "module_show_win"); *(void **) (&st.module_hide_win) = dlsym(handle, "module_hide_win"); *(void **) (&st.module_win_visible) = dlsym(handle, "module_win_visible"); *(void **) (&st.module_flush_input) = dlsym(handle, "module_flush_input"); *(void **) (&st.module_setup_window_create) = dlsym(handle, "module_setup_window_create"); return tmemdup(&st, GCIN_module_callback_functions, 1); }