Ejemplo n.º 1
0
        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
        }
Ejemplo n.º 2
0
        }/*End eval_dir_image_tbl*/

        public unsafe static int eval_dir_dict_ref_tbl8(ref DDlDevDescription.DICT_REF_TBL dict_ref_tbl, ref DDlDevDescription.BININFO bin)
        {

            //uint* element = null;             /* temp pointer for the list */
            //uint* end_element = null;         /* end pointer for the list */
            uint size = 0;         /* temp size */
            byte* root_ptr = null;     /* temp pointer */
            UInt64 temp_int;              /* integer value */
            //int rc;                     /* return code */
            fixed (byte* chu = &bin.chunk[bin.uoffset])
            {
                fixed (uint* puiSize = &bin.size)
                {

                    //ASSERT_DBG(bin && bin.chunk && bin.size);

                    /* parse count */
                    Common.DDL_PARSE_INTEGER(&chu, puiSize, &temp_int);

                    /*
                     * if count is zero
                     */

                    if (temp_int == 0)
                    {

                        dict_ref_tbl.count = 0;
                        dict_ref_tbl.list = null;
                        dict_ref_tbl.name = null;
                        dict_ref_tbl.text = null;
                        return Common.DDL_SUCCESS;
                    }

                    dict_ref_tbl.count = (ushort)temp_int;

                    /* malloc the lists */
                    dict_ref_tbl.list = new uint[temp_int];// (uint*)new uint[((size_t)(temp_int))];

                    dict_ref_tbl.name = new ddpSTRING[temp_int];
                    dict_ref_tbl.text = new ddpSTRING[temp_int];

                    for (ushort i = 0; i < temp_int; i++)
                    {
                        dict_ref_tbl.name[i] = new ddpSTRING();
                        dict_ref_tbl.text[i] = new ddpSTRING();
                    }

                    if (dict_ref_tbl.list == null || dict_ref_tbl.name == null || dict_ref_tbl.text == null)
                    {

                        dict_ref_tbl.count = 0;
                        return Common.DDL_MEMORY_ERROR;
                    }


                    /* load list with zeros */
                    //(void)memset((char*)dict_ref_tbl.list, 0, (size_t)temp_int * sizeof(uint));

                    /*
                     * load the list
                     */

                    size = bin.size;
                    root_ptr = chu;
                    for (ushort i = 0; i < dict_ref_tbl.count; i++)
                    {
                        //char* s;

                        // value

                        Common.DDL_PARSE_INTEGER(&root_ptr, &size, &temp_int);
                        dict_ref_tbl.list[i] = (uint)temp_int;

                        // name
                        // stevev 06jan10 - allow string to be freed.  The makedict call immediatly after this
                        //		makes a duplicate of both the strings.

                        Common.DDL_PARSE_INTEGER(&root_ptr, &size, &temp_int);
                        //assert(temp_int < MAXIMUM_USHRT);
                        dict_ref_tbl.name[i].len = (ushort)temp_int;

                        //dict_ref_tbl.name[i].str = new char[(uint)temp_int + 1];
                        //strcpy(dict_ref_tbl.name[i].str, (char*)root_ptr);
                        byte[] cc = new byte[temp_int];
                        for (int j = 0; j < dict_ref_tbl.name[i].len; j++)
                        {
                            cc[j] = root_ptr[j];
                        }
                        dict_ref_tbl.name[i].str = Encoding.Default.GetString(cc);//??????
                        dict_ref_tbl.name[i].str = dict_ref_tbl.name[i].str.TrimEnd('\0');//??????
                        size -= (ushort)temp_int;
                        root_ptr += temp_int;
                        dict_ref_tbl.name[i].flags = Common.FREE_STRING;// DONT_FREE_STRING;
                        //s = dict_ref_tbl.name[i].str;

                        // text

                        Common.DDL_PARSE_INTEGER(&root_ptr, &size, &temp_int);
                        //assert(temp_int < MAXIMUM_USHRT);
                        dict_ref_tbl.text[i].len = (ushort)temp_int;
                        //dict_ref_tbl.text[i].str = new char[(ushort)temp_int + 1];
                        //strcpy(dict_ref_tbl.text[i].str, (char*)root_ptr);
                        cc = new byte[temp_int];
                        for (int j = 0; j < dict_ref_tbl.text[i].len; j++)
                        {
                            cc[j] = root_ptr[j];
                        }
                        dict_ref_tbl.text[i].str = Encoding.Default.GetString(cc);//??????
                        dict_ref_tbl.text[i].str = dict_ref_tbl.text[i].str.TrimEnd('\0');//??????
                        size -= (ushort)temp_int;
                        root_ptr += temp_int;
                        dict_ref_tbl.text[i].flags = Common.FREE_STRING;//DONT_FREE_STRING;
                        //s = dict_ref_tbl.text[i].str;
                    }
                }
            }

            return Common.DDL_SUCCESS;
        }
Ejemplo n.º 3
0
        public static unsafe int eval_dir_dict_ref_tbl(ref DDlDevDescription.DICT_REF_TBL dict_ref_tbl, ref DDlDevDescription.BININFO bin)
        {

            uint* element = null;             /* temp pointer for the list */
            uint* end_element = null;         /* end pointer for the list */
            UInt64 temp_int;              /* integer value */
            //int rc;                     /* return code */

            fixed (byte* chunk = &bin.chunk[bin.uoffset])
            {
                fixed (uint* pz = &bin.size)
                {
                    Common.DDL_PARSE_INTEGER(&chunk, pz, &temp_int);
                    /* parse count */
                    /*
                     * if count is zero
                     */

                    if (temp_int == 0)
                    {

                        dict_ref_tbl.count = 0;
                        dict_ref_tbl.list = null;
                        return Common.DDL_SUCCESS;
                    }

                    dict_ref_tbl.count = (ushort)temp_int;

                    /* malloc the list */
                    dict_ref_tbl.list = new uint[((uint)(temp_int))];

                    if (dict_ref_tbl.list == null)
                    {

                        dict_ref_tbl.count = 0;
                        return Common.DDL_MEMORY_ERROR;
                    }

                    /* load list with zeros */
                    //(void)memset((char*)dict_ref_tbl->list, 0, (size_t)temp_int * sizeof(uint));

                    /*
                     * load the list
                     */
                    /*
                                for (element = dict_ref_tbl.list, end_element = element + temp_int;
                                     element < end_element; element++)
                                {

                                    DDlDevDescription.DDL_PARSE_INTEGER(&bin.chunk[0], &bin.size, &temp_int);
                                    *element = (uint)temp_int;
                                }
                                */
                    for (uint i = 0; i < dict_ref_tbl.count; i++)
                    {
                        Common.DDL_PARSE_INTEGER(&chunk, pz, &temp_int);
                        dict_ref_tbl.list[i] = (uint)temp_int;
                    }

                }
                /* parse count */
            }
            return Common.DDL_SUCCESS;
        }