/****************************************************************************** * * \par Function Name: adm_add_datadef_collect * * \par Registers a collection function to a data definition. * * \param[in] mid_str serialized MID value * \param[in] collect The data collection function. * * \par Notes: * 1. When working with parameterized OIDs, the given MID should * be all information excluding the parameterized portion of the OID. * 2. ADM names will be truncated after ADM_MAX_NAME bytes. * * Modification History: * MM/DD/YY AUTHOR DESCRIPTION * -------- ------------ --------------------------------------------- * 11/25/12 E. Birrane Initial implementation. * 07/27/13 E. BIrrane Updated ADM to use Lysts. *****************************************************************************/ void adm_add_datadef_collect(uint8_t *mid_str, adm_data_collect_fn collect) { uint32_t used = 0; mid_t *mid = NULL; adm_datadef_t *entry = NULL; DTNMP_DEBUG_ENTRY("adm_add_datadef_collect","(%lld, %lld)", mid_str, collect); if((mid_str == NULL) || (collect == NULL)) { DTNMP_DEBUG_ERR("adm_add_datadef_collect","Bad Args.", NULL); DTNMP_DEBUG_EXIT("adm_add_datadef_collect","->.", NULL); return; } if((mid = mid_deserialize(mid_str, ADM_MID_ALLOC, &used)) == NULL) { char *tmp = utils_hex_to_string(mid_str, ADM_MID_ALLOC); DTNMP_DEBUG_ERR("adm_add_datadef_collect","Can't deserialize MID str %s.",tmp); MRELEASE(tmp); DTNMP_DEBUG_EXIT("adm_add_datadef_collect","->.", NULL); return; } if((entry = adm_find_datadef(mid)) == NULL) { char *tmp = mid_to_string(mid); DTNMP_DEBUG_ERR("adm_add_datadef_collect","Can't find data for MID %s.", tmp); MRELEASE(tmp); } else { entry->collect = collect; } mid_release(mid); DTNMP_DEBUG_EXIT("adm_add_datadef_collect","->.", NULL); }
/* * We need to find out a description for the entry so we can print it out. * So, if entry is <RPT MID> <int d1><int d2><int d3> we need to match the items * to elements of the report definition. * */ void ui_print_entry(rpt_entry_t *entry, uvast *mid_sizes, uvast *data_sizes) { LystElt elt = NULL; def_gen_t *cur_def = NULL; uint8_t del_def = 0; if((entry == NULL) || (mid_sizes == NULL) || (data_sizes == NULL)) { AMP_DEBUG_ERR("ui_print_entry","Bad Args.", NULL); return; } /* Step 1: Calculate sizes...*/ *mid_sizes = *mid_sizes + entry->id->raw_size; for(elt = lyst_first(entry->contents->datacol); elt; elt = lyst_next(elt)) { blob_t *cur = lyst_data(elt); *data_sizes = *data_sizes + cur->length; } *data_sizes = *data_sizes + entry->contents->hdr.length; /* Step 1: Print the MID associated with the Entry. */ printf(" ("); ui_print_mid(entry->id); printf(") has %d values.", entry->contents->hdr.length); /* * Step 2: Try and find the metadata associated with each * value in the TDC. Since the TDC is already typed, the * needed meta-data information is simply the * "name" of the data. * * i Only computed data definitions, reports, and macros * need names. Literals, controls, and atomic data do * not (currently) define extra meta-data for their * definitions. * * \todo: Consider printing names for each return * value from a control. */ cur_def = NULL; if(MID_GET_FLAG_ID(entry->id->flags) == MID_ATOMIC) { adm_datadef_t *ad_entry = adm_find_datadef(entry->id); /* Fake a def_gen_t for now. */ if(ad_entry != NULL) { Lyst tmp = lyst_create(); lyst_insert(tmp,mid_copy(ad_entry->mid)); cur_def = def_create_gen(mid_copy(ad_entry->mid), ad_entry->type, tmp); del_def = 1; } } else if(MID_GET_FLAG_ID(entry->id->flags) == MID_COMPUTED) { var_t *cd = NULL; if(MID_GET_FLAG_ISS(entry->id->flags) == 0) { cd = var_find_by_id(gAdmComputed, NULL, entry->id); } else { cd = var_find_by_id(gMgrVDB.compdata, &(gMgrVDB.compdata_mutex), entry->id); } // Fake a def_gen just for this CD item. if(cd != NULL) { Lyst tmp = lyst_create(); lyst_insert(tmp,mid_copy(cd->id)); cur_def = def_create_gen(mid_copy(cd->id), cd->value.type, tmp); del_def = 1; } } else if(MID_GET_FLAG_ID(entry->id->flags) == MID_REPORT) { if(MID_GET_FLAG_ISS(entry->id->flags) == 0) { cur_def = def_find_by_id(gAdmRpts, NULL, entry->id); } else { cur_def = def_find_by_id(gMgrVDB.reports, &(gMgrVDB.reports_mutex), entry->id); } } else if(MID_GET_FLAG_ID(entry->id->flags) == MID_MACRO) { if(MID_GET_FLAG_ISS(entry->id->flags) == 0) { cur_def = def_find_by_id(gAdmMacros, NULL, entry->id); } else { cur_def = def_find_by_id(gMgrVDB.macros, &(gMgrVDB.macros_mutex), entry->id); } } /* Step 3: Print the TDC holding data for the entry. */ ui_print_tdc(entry->contents, cur_def); if(del_def) { def_release_gen(cur_def); } return; }