Home | History | Annotate | Download | only in engine
      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 
     18 #include "nj_lib.h"
     19 #include "nj_err.h"
     20 #include "nj_ext.h"
     21 #include "nj_dic.h"
     22 #include "njd.h"
     23 
     24 
     25 #define F_HINSI_TOP_ADDR(h) ((NJ_UINT8*)((h)+NJ_INT32_READ((h)+0x20)))
     26 #define B_HINSI_TOP_ADDR(h) ((NJ_UINT8*)((h)+NJ_INT32_READ((h)+0x24)))
     27 #define V2_F_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x28)))
     28 #define BUN_B_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x2A)))
     29 #define TAN_F_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x30)))
     30 #define TAN_B_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x32)))
     31 #define SUUJI_B_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x34)))
     32 #define MEISI_F_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x36)))
     33 #define MEISI_B_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x38)))
     34 #define JINMEI_F_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x3A)))
     35 #define JINMEI_B_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x3C)))
     36 #define CHIMEI_F_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x3E)))
     37 #define CHIMEI_B_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x40)))
     38 #define KIGOU_F_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x42)))
     39 #define KIGOU_B_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x44)))
     40 #define V1_F_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x52)))
     41 #define V3_F_HINSI(h) ((NJ_UINT16)(NJ_INT16_READ((h)+0x54)))
     42 
     43 NJ_INT16 njd_r_get_hinsi(NJ_DIC_HANDLE rule, NJ_UINT8 type) {
     44 
     45 
     46     if (rule == NULL) {
     47         return 0;
     48     }
     49 
     50     switch (type) {
     51     case NJ_HINSI_V2_F :
     52         return V2_F_HINSI(rule);
     53     case NJ_HINSI_BUNTOU_B :
     54         return BUN_B_HINSI(rule);
     55     case NJ_HINSI_TANKANJI_F :
     56         return TAN_F_HINSI(rule);
     57     case NJ_HINSI_TANKANJI_B :
     58         return TAN_B_HINSI(rule);
     59     case NJ_HINSI_SUUJI_B:
     60         return SUUJI_B_HINSI(rule);
     61     case NJ_HINSI_MEISI_F :
     62         return MEISI_F_HINSI(rule);
     63     case NJ_HINSI_MEISI_B :
     64         return MEISI_B_HINSI(rule);
     65     case NJ_HINSI_JINMEI_F :
     66         return JINMEI_F_HINSI(rule);
     67     case NJ_HINSI_JINMEI_B :
     68         return JINMEI_B_HINSI(rule);
     69     case NJ_HINSI_CHIMEI_F :
     70         return CHIMEI_F_HINSI(rule);
     71     case NJ_HINSI_CHIMEI_B :
     72         return CHIMEI_B_HINSI(rule);
     73     case NJ_HINSI_KIGOU_F :
     74         return KIGOU_F_HINSI(rule);
     75     case NJ_HINSI_KIGOU_B :
     76         return KIGOU_B_HINSI(rule);
     77     case NJ_HINSI_V1_F :
     78         return V1_F_HINSI(rule);
     79     case NJ_HINSI_V3_F :
     80         return V3_F_HINSI(rule);    default:
     81 
     82         return 0;
     83     }
     84 }
     85 
     86 NJ_INT16 njd_r_get_connect(NJ_DIC_HANDLE rule, NJ_UINT16 hinsi, NJ_UINT8 type, NJ_UINT8 **connect) {
     87     NJ_UINT16 i, rec_len;
     88 
     89 
     90     if (rule == NULL) {
     91         return 0;
     92     }
     93     if (hinsi < 1) {
     94         return 0;
     95     }
     96 
     97     if (type == NJ_RULE_TYPE_BTOF) {
     98         i = F_HINSI_SET_CNT(rule);
     99         rec_len = (NJ_UINT16)((i + 7) / 8);
    100 
    101         *connect = (NJ_UINT8*)(F_HINSI_TOP_ADDR(rule) + ((hinsi - 1) * rec_len));
    102     } else {
    103         i = B_HINSI_SET_CNT(rule);
    104         rec_len = (NJ_UINT16)((i + 7) / 8);
    105 
    106         *connect = (NJ_UINT8*)(B_HINSI_TOP_ADDR(rule) + ((hinsi - 1) * rec_len));
    107     }
    108     return 0;
    109 }
    110 
    111 NJ_INT16 njd_r_get_count(NJ_DIC_HANDLE rule, NJ_UINT16 *fcount, NJ_UINT16 *rcount) {
    112 
    113 
    114     if (rule == NULL) {
    115         return 0;
    116     }
    117 
    118     *fcount = F_HINSI_SET_CNT(rule);
    119     *rcount = B_HINSI_SET_CNT(rule);
    120 
    121     return 0;
    122 }
    123