public int makedict(ref DDlDevDescription.DICT_REF_TBL dict_ref_tbl) { ushort i; //DEBUGLOG(CLOG_LOG, "DICTIONARY::: makedict from table at %p\n", this); if ((object)dict_ref_tbl.name == null && (object)dict_ref_tbl.text == null) { // timj 14jan08 // name and text are not present. therefore dictionary just came in // from an fm6 binary. also, dictionary has already been installed // from .dct file with name and text. // Each entry with a ref in dict_ref_tbl will be marked as used, // others are marked as unused // first mark all entries as being unused for (i = 0; i < num_dict_table_entries; i++) { dict_table[i].used = false; } // then mark ref's in dict_ref_tbl as being used for (i = 0; i < dict_ref_tbl.count; i++) { DICT_TABLE_ENTRY found_ptr = new DICT_TABLE_ENTRY(); foreach (DICT_TABLE_ENTRY de in dict_table) { if (de.ulref == dict_ref_tbl.list[i]) { found_ptr = de; found_ptr.used = true; break; } } } } else { // timj 14jan08 // dictionary just came in from binary (fm8) or from .dct file (fm6) // build the dictionary, marking all entries as used for (i = 0; i < dict_ref_tbl.count; i++) { dict_table_install(dict_ref_tbl.list[i], dict_ref_tbl.name[i].str, dict_ref_tbl.text[i].str);//?????? // stevev - 28sep11 - mark as deletable to try and stop mem leak dict_ref_tbl.name[i].flags = Common.FREE_STRING; dict_ref_tbl.text[i].flags = Common.FREE_STRING; } // sort the dictionary entries Endian.QSort <DICT_TABLE_ENTRY>(dict_table, num_dict_table_entries, DictableSortBy); //(void)qsort(dict_table, num_dict_table_entries, sizeof(DICT_TABLE_ENTRY), dict_compare); } return(0); // dicterrs }
static int DictableSortBy(DICT_TABLE_ENTRY a, DICT_TABLE_ENTRY b) { if (a.ulref > b.ulref) { return(1); } if (a.ulref < b.ulref) { return(-1); } return(0); }
public int get_dictionary_string(uint index, ref ddpSTRING str) { //ADDED By Deepak , initializing all vars DICT_TABLE_ENTRY found_ptr = new DICT_TABLE_ENTRY(); bool bf = false; //DICT_TABLE_ENTRY key; //key.ulref = index; /* * Perform a binary search on the standard dictionary table to find the * entry we're looking for. * * * found_ptr = (DICT_TABLE_ENTRY*)B_SEARCH((char*)&key, * (char*)dict_table, (unsigned)num_dict_table_entries, * sizeof(DICT_TABLE_ENTRY), dict_compare);*/ foreach (DICT_TABLE_ENTRY de in dict_table) { if (de.ulref == index) { found_ptr = de; bf = true; break; } } if (!bf) { return(Common.DDL_DICT_STRING_NOT_FOUND); } else { /* * Retrieve the information */ str.flags = Common.DONT_FREE_STRING; str.len = found_ptr.len; str.str = found_ptr.str; return(Common.DDL_SUCCESS); } }