Ejemplo n.º 1
0
T_KRDB* kr_db_create(char *psDBName, T_DbsEnv *ptDbsEnv, T_KRModule *ptModule)
{
    T_KRDB *ptDB = (T_KRDB *)kr_calloc(sizeof(T_KRDB));
    if (ptDB == NULL) {
        fprintf(stderr, "kr_calloc ptDB failed!\n");
        return NULL;
    }
    strncpy(ptDB->caDBName, psDBName, sizeof(ptDB->caDBName));
    ptDB->dbsenv = ptDbsEnv;

    ptDB->pTableList = kr_list_new();
    kr_list_set_match(ptDB->pTableList, (KRCompareFunc )kr_tableid_match);
    kr_list_set_free(ptDB->pTableList, (KRFreeFunc )kr_table_drop);

    ptDB->pIndexList = kr_list_new();
    kr_list_set_match(ptDB->pIndexList, (KRCompareFunc )kr_indexid_match);
    kr_list_set_free(ptDB->pIndexList, (KRFreeFunc )kr_index_drop);

    ptDB->pIndexTableList = kr_list_new();
    kr_list_set_match(ptDB->pIndexTableList, (KRCompareFunc )kr_index_table_match);
    kr_list_set_free(ptDB->pIndexTableList, (KRFreeFunc )kr_index_table_drop);


    return ptDB;
}
Ejemplo n.º 2
0
T_KROutput* kr_output_construct(T_KRParam *ptParam, char *psOutputModule, 
        KRGetTypeFunc pfGetType, KRGetValueFunc pfGetValue)
{
    T_KROutput *ptOutput = kr_calloc(sizeof(*ptOutput));
    if (ptOutput == NULL) {
        KR_LOG(KR_LOGERROR, "kr_calloc ptOutput failed!");
        return NULL;
    }
    
    /* load output module */
    ptOutput->ptOutputModule = kr_module_open(psOutputModule, RTLD_LAZY);
    if (ptOutput->ptOutputModule == NULL) {
        KR_LOG(KR_LOGERROR, "kr_module_open %s failed!", psOutputModule);
        kr_output_destruct(ptOutput);
        return NULL;
    }
    ptOutput->pfGetType = pfGetType;
    ptOutput->pfGetValue = pfGetValue;
    
    /*alloc output define list*/
    ptOutput->ptOutputDefineList = kr_list_new();
    kr_list_set_match(ptOutput->ptOutputDefineList, (KRListMatchFunc )kr_output_define_match);
    kr_list_set_free(ptOutput->ptOutputDefineList, (KRListFreeFunc )kr_output_define_free);
    
    /*create output list*/
    if (kr_param_object_foreach(ptParam, KR_PARAM_OUTPUT, 
            _kr_output_define_new, ptOutput) != 0) {
        KR_LOG(KR_LOGERROR, "_kr_db_build_table Error!");
        return NULL;
    }
    
    ptOutput->tConstructTime = kr_param_load_time(ptParam);
    
    return ptOutput;
}