Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright (C) 2008-2012  OMRON SOFTWARE Co., Ltd.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef _NJ_EXTERN_H_
     18 #define _NJ_EXTERN_H_
     19 
     20 
     21 #define NJ_MAX_CHAR_LEN  2
     22 
     23 #define NJ_CHAR_IS_EQUAL(a, b) \
     24     ( (((NJ_UINT8*)(a))[0] == ((NJ_UINT8*)(b))[0]) && (((NJ_UINT8*)(a))[1] == ((NJ_UINT8*)(b))[1]) )
     25 
     26 #define NJ_CHAR_IS_LESSEQ(a, b)                                         \
     27     ( (((NJ_UINT8*)(a))[0] < ((NJ_UINT8*)(b))[0]) ||                    \
     28       ((((NJ_UINT8*)(a))[0] == ((NJ_UINT8*)(b))[0]) && (((NJ_UINT8*)(a))[1] <= ((NJ_UINT8*)(b))[1])) )
     29 
     30 #define NJ_CHAR_IS_MOREEQ(a, b)                                         \
     31     (  (((NJ_UINT8*)(a))[0] >  ((NJ_UINT8*)(b))[0]) ||                  \
     32       ((((NJ_UINT8*)(a))[0] == ((NJ_UINT8*)(b))[0]) && (((NJ_UINT8*)(a))[1] >= ((NJ_UINT8*)(b))[1])) )
     33 
     34 #define NJ_CHAR_DIFF(a, b)                                              \
     35     ((NJ_INT16)                                                         \
     36      ( (((NJ_UINT8*)(a))[0] == ((NJ_UINT8*)(b))[0])                     \
     37        ? (((NJ_UINT8*)(a))[1] - ((NJ_UINT8*)(b))[1])                    \
     38        : (((NJ_UINT8*)(a))[0] - ((NJ_UINT8*)(b))[0]) )                  \
     39      )
     40 
     41 #define NJ_CHAR_COPY(dst, src)                                          \
     42     {                                                                   \
     43         ((NJ_UINT8*)(dst))[0] = ((NJ_UINT8*)(src))[0];                  \
     44         ((NJ_UINT8*)(dst))[1] = ((NJ_UINT8*)(src))[1];                  \
     45     }
     46 
     47 #define NJ_CHAR_STRLEN_IS_0(c)   (*(c) == NJ_CHAR_NUL)
     48 
     49 #define NJ_CHAR_ILLEGAL_DIC_YINDEX(size)   ((size) != 2)
     50 
     51 
     52 #define NJ_CHAR_LEN(s)                                                  \
     53     ( (NJ_CHAR_IS_MOREEQ((s), "\xD8\x00") && NJ_CHAR_IS_LESSEQ((s), "\xDB\xFF")) \
     54       ? ( (*((s)+1) == NJ_CHAR_NUL) ? 1 : 2)                            \
     55       : 1)
     56 
     57 #define UTL_CHAR(s)  1
     58 
     59 
     60 #define NJ_GET_DIC_INFO(dicinfo) ((NJ_UINT8)((dicinfo)->type))
     61 
     62 #define NJ_GET_DIC_TYPE_EX(type, handle) \
     63                  NJ_GET_DIC_TYPE((handle))
     64 
     65 
     66 #define GET_BITFIELD_16(data, pos, width)                        \
     67     ((NJ_UINT16)(((NJ_UINT16)(data) >> (16 - (pos) - (width))) & \
     68                  ((NJ_UINT16)0xffff >> (16 - (width)       ))))
     69 
     70 #define GET_BITFIELD_32(data, pos, width)       \
     71     ((NJ_UINT32)(((NJ_UINT32)(data) >> (32 - (pos) - (width))) & ((NJ_UINT32)0xffffffff >> (32 - (width)))))
     72 
     73 #define GET_BIT_TO_BYTE(bit) ((NJ_UINT8)(((bit) + 7) >> 3))
     74 
     75 
     76 #define INIT_KEYWORD_IN_NJ_DIC_SET(x) \
     77     { (x)->keyword[0] = NJ_CHAR_NUL; (x)->keyword[1] = NJ_CHAR_NUL; }
     78 
     79 #define GET_ERR_FUNCVAL(errval) \
     80     ((NJ_UINT16)(((NJ_UINT16)(errval) & 0x007F) << 8))
     81 
     82 
     83 extern NJ_INT16 njd_get_word_data(NJ_CLASS *iwnn, NJ_DIC_SET *dicset, NJ_SEARCH_LOCATION_SET *loctset, NJ_UINT16 dic_idx, NJ_WORD *word);
     84 extern NJ_INT16 njd_get_stroke(NJ_CLASS *iwnn, NJ_RESULT *result,
     85                                NJ_CHAR *stroke, NJ_UINT16 size);
     86 extern NJ_INT16 njd_get_candidate(NJ_CLASS *iwnn, NJ_RESULT *result,
     87                                NJ_CHAR *candidate, NJ_UINT16 size);
     88 extern NJ_INT16 njd_init_search_location_set(NJ_SEARCH_LOCATION_SET* loctset);
     89 extern NJ_INT16 njd_init_word(NJ_WORD* word);
     90 
     91 extern NJ_INT16 njd_b_search_word(NJ_SEARCH_CONDITION *con,
     92                                   NJ_SEARCH_LOCATION_SET *loctset);
     93 extern NJ_INT16 njd_b_get_word(NJ_SEARCH_LOCATION_SET *loctset, NJ_WORD *word);
     94 extern NJ_INT16 njd_b_get_candidate(NJ_WORD *word, NJ_CHAR *candidate,
     95                                     NJ_UINT16 size);
     96 extern NJ_INT16 njd_b_get_stroke(NJ_WORD *word, NJ_CHAR *stroke, NJ_UINT16 size);
     97 
     98 extern NJ_INT16 njd_f_search_word(NJ_SEARCH_CONDITION *con,
     99                                   NJ_SEARCH_LOCATION_SET *loctset);
    100 extern NJ_INT16 njd_f_get_word(NJ_SEARCH_LOCATION_SET *loctset, NJ_WORD *word);
    101 extern NJ_INT16 njd_f_get_stroke(NJ_WORD *word, NJ_CHAR *stroke,
    102                                  NJ_UINT16 size);
    103 extern NJ_INT16 njd_f_get_candidate(NJ_WORD *word, NJ_CHAR *candidate,
    104                                     NJ_UINT16 size);
    105 
    106 extern NJ_INT16 njd_l_search_word(NJ_CLASS *iwnn, NJ_SEARCH_CONDITION *con,
    107                                   NJ_SEARCH_LOCATION_SET *loctset, NJ_UINT8 comp_flg);
    108 extern NJ_INT16 njd_l_add_word(NJ_CLASS *iwnn, NJ_LEARN_WORD_INFO *word,
    109                                 NJ_UINT8 connect, NJ_UINT8 type,
    110                                 NJ_UINT8 undo, NJ_UINT8 dictype);
    111 
    112 extern NJ_INT16 njd_l_delete_word(NJ_CLASS *iwnn, NJ_SEARCH_LOCATION *loc);
    113 extern NJ_INT16 njd_l_get_word(NJ_CLASS *iwnn, NJ_SEARCH_LOCATION_SET *loctset, NJ_WORD *word);
    114 extern NJ_INT16 njd_l_get_stroke(NJ_CLASS *iwnn, NJ_WORD *word,
    115                                  NJ_CHAR *stroke, NJ_UINT16 size);
    116 extern NJ_INT16 njd_l_get_candidate(NJ_CLASS *iwnn, NJ_WORD *word,
    117                                  NJ_CHAR *candidate, NJ_UINT16 size);
    118 extern NJ_INT16 njd_l_undo_learn(NJ_CLASS *iwnn, NJ_UINT16 undo_count);
    119 extern NJ_INT16 njd_l_check_dic(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle);
    120 extern NJ_INT16 njd_l_init_area(NJ_DIC_HANDLE handle);
    121 extern NJ_INT16 njd_l_make_space(NJ_CLASS *iwnn, NJ_UINT16 count, NJ_UINT8 mode);
    122 extern NJ_INT16 njd_l_get_relational_word(NJ_CLASS *iwnn, NJ_SEARCH_LOCATION *loc,
    123                                  NJ_WORD *word, NJ_DIC_FREQ *mdic_freq);
    124 extern NJ_INT16 njd_l_check_word_connect(NJ_CLASS *iwnn, NJ_WORD *word);
    125 extern NJ_INT16 njd_l_get_ext_word_data(NJ_CLASS *iwnn, NJ_WORD *word, NJ_UINT16 *hinsi, NJ_UINT8 *len);
    126 extern NJ_INT16 njd_l_mld_op_commit(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle);
    127 extern NJ_INT16 njd_l_mld_op_commit_to_top(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle);
    128 extern NJ_INT16 njd_l_mld_op_commit_cancel(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle);
    129 extern NJ_INT16 njd_l_mld_op_get_space(NJ_CLASS *iwnn, NJ_DIC_HANDLE handle);
    130 
    131 extern NJ_INT16 njd_r_get_hinsi(NJ_DIC_HANDLE rule, NJ_UINT8 type);
    132 extern NJ_INT16 njd_r_get_connect(NJ_DIC_HANDLE rule,
    133                                   NJ_UINT16 hinsi, NJ_UINT8 type,
    134                                   NJ_UINT8 **connect);
    135 extern NJ_INT16 njd_r_get_count(NJ_DIC_HANDLE rule,
    136                                 NJ_UINT16 *fcount, NJ_UINT16 *rcount);
    137 
    138 extern NJ_UINT16 nje_check_string(NJ_CHAR *s, NJ_UINT16 max_len);
    139 extern NJ_UINT8 nje_get_top_char_type(NJ_CHAR *s);
    140 extern NJ_INT16 nje_convert_kata_to_hira(NJ_CHAR *kata, NJ_CHAR *hira, NJ_UINT16 len, NJ_UINT16 max_len, NJ_UINT8 type);
    141 extern NJ_INT16 nje_convert_hira_to_kata(NJ_CHAR *hira, NJ_CHAR *kata, NJ_UINT16 len);
    142 
    143 extern NJ_INT16 njd_connect_test(NJ_SEARCH_CONDITION *con, NJ_UINT16 hinsiF, NJ_UINT16 hinsiR);
    144 
    145 extern NJ_CHAR  *nj_strcpy(NJ_CHAR *dst, NJ_CHAR *src);
    146 extern NJ_CHAR  *nj_strncpy(NJ_CHAR *dst, NJ_CHAR *src, NJ_UINT16 n);
    147 extern NJ_UINT16 nj_strlen(NJ_CHAR *c);
    148 extern NJ_INT16  nj_strcmp(NJ_CHAR *s1, NJ_CHAR *s2);
    149 extern NJ_INT16  nj_strncmp(NJ_CHAR *s1, NJ_CHAR *s2, NJ_UINT16 n);
    150 extern NJ_UINT16 nj_charlen(NJ_CHAR *c);
    151 extern NJ_INT16  nj_charncmp(NJ_CHAR *s1, NJ_CHAR *s2, NJ_UINT16 n);
    152 extern NJ_CHAR  *nj_charncpy(NJ_CHAR *dst, NJ_CHAR *src, NJ_UINT16 n);
    153 extern NJ_UINT8 *nj_memcpy(NJ_UINT8 *dst, NJ_UINT8 *src, NJ_UINT16 n);
    154 
    155 
    156 #endif
    157