NJ_INT16 njd_get_stroke(NJ_CLASS *iwnn, NJ_RESULT *result, NJ_CHAR *stroke, NJ_UINT16 size) { NJ_INT16 ret = 0; NJ_UINT16 len; NJ_UINT32 dictype; if (result->word.stem.loc.handle == NULL) { return NJ_SET_ERR_VAL(NJ_FUNC_NJD_GET_STROKE, NJ_ERR_INVALID_RESULT); } dictype = NJ_GET_DIC_TYPE_EX(result->word.stem.loc.type, result->word.stem.loc.handle); switch (dictype) { case NJ_DIC_TYPE_JIRITSU: case NJ_DIC_TYPE_FZK: case NJ_DIC_TYPE_TANKANJI: case NJ_DIC_TYPE_STDFORE: case NJ_DIC_TYPE_CUSTOM_COMPRESS: case NJ_DIC_TYPE_FORECONV: if (GET_LOCATION_OPERATION(result->word.stem.loc.status) != NJ_CUR_OP_COMP) { ret = njd_b_get_stroke(&result->word, stroke, size); } else { len = NJ_GET_YLEN_FROM_STEM(&result->word); if (size < ((len + NJ_TERM_LEN) * sizeof(NJ_CHAR))) { return NJ_SET_ERR_VAL(NJ_FUNC_NJD_GET_STROKE, NJ_ERR_BUFFER_NOT_ENOUGH); } if (len == 0) { return NJ_SET_ERR_VAL(NJ_FUNC_NJD_GET_STROKE, NJ_ERR_INVALID_RESULT); } nj_strncpy(stroke, result->word.yomi, len); *(stroke + len) = NJ_CHAR_NUL; return len; } break; case NJ_DIC_TYPE_USER: case NJ_DIC_TYPE_CUSTOM_INCOMPRESS: ret = njd_l_get_stroke(iwnn, &result->word, stroke, size); break; case NJ_DIC_TYPE_YOMINASHI: ret = njd_f_get_stroke(&result->word, stroke, size); break; default: return NJ_SET_ERR_VAL(NJ_FUNC_NJD_GET_STROKE, NJ_ERR_DIC_TYPE_INVALID); } if (ret == 0) { return NJ_SET_ERR_VAL(NJ_FUNC_NJD_GET_STROKE, NJ_ERR_INVALID_RESULT); } return ret; }
NJ_INT16 njd_f_get_stroke(NJ_WORD *word, NJ_CHAR *stroke, NJ_UINT16 size) { NJ_SEARCH_LOCATION *loc; NJ_UINT8 *area, *data; NJ_UINT16 len; NJ_UINT32 j; if (NJ_GET_YLEN_FROM_STEM(word) == 0) { return NJ_SET_ERR_VAL(NJ_FUNC_NJD_F_GET_STROKE, NJ_ERR_INVALID_RESULT); } loc = &word->stem.loc; data = STEM_AREA_TOP_ADDR(loc->handle) + loc->current; area = YOMI_AREA_TOP_ADDR(loc->handle) + DATA_YOMI(data); if (YOMI_INDX_CNT(loc->handle) == 0) { len = DATA_YOMI_SIZE(data)/sizeof(NJ_CHAR); if (size < ((len + NJ_TERM_LEN) * sizeof(NJ_CHAR))) { return NJ_SET_ERR_VAL(NJ_FUNC_NJD_F_GET_STROKE, NJ_ERR_BUFFER_NOT_ENOUGH); } for (j = 0; j < len; j++) { NJ_CHAR_COPY(stroke, area); stroke++; area += sizeof(NJ_CHAR); } *stroke = NJ_CHAR_NUL; } else { len = convert_to_yomi(loc->handle, area, DATA_YOMI_SIZE(data), stroke, size); if (size < ((len + NJ_TERM_LEN) * sizeof(NJ_CHAR))) { return NJ_SET_ERR_VAL(NJ_FUNC_NJD_F_GET_STROKE, NJ_ERR_BUFFER_NOT_ENOUGH); } } return len; }