Example #1
0
        public CommandTableEntry *FindCommand(CString8 *name)
        {
            Diagnostics.Assert(name != null, "CommandTableHeader::FindCommand(CString8*): Parameter 'name' is null");
            Diagnostics.Assert(firstEntry != null, "CommandTableHeader::FindCommand(CString8*): Cannot search through commands; command list is empty");
            CommandTableEntry *currentEntry;

            for (currentEntry = firstEntry;
                 currentEntry != null;
                 currentEntry = currentEntry->nextEntry)
            {
                //FIXME: This needs to be case insensitive!
                if (ByteString.Compare(name->Pointer, currentEntry->name->Pointer) == 0)
                {
                    return(currentEntry);
                }
                //else
                //{
                //    ADC.TextMode.Write("CommandTableHeader::FindCommand(CString8*): Entered '");
                //    ADC.TextMode.Write(name);
                //    ADC.TextMode.Write("' != '");
                //    ADC.TextMode.Write(currentEntry->name);
                //    ADC.TextMode.WriteLine("'");
                //}
            }

            return(null);
        }
Example #2
0
        static void *GetBuiltinKeyMap(byte *name, int nameLen)
        {
#if VERBOSE_KeyMap_INIT
            TextMode.Write("Key Map Name: ");
            TextMode.Write(name);
            TextMode.WriteLine();

            TextMode.Write("Key Map Name Length: ");
            TextMode.Write(nameLen);
            TextMode.WriteLine();
#endif

            byte *table = (byte *)keymapArchive + 4;
            byte *ret_table;
            byte *buf = getBuiltinKeyMapBuffer;

            Diagnostics.Assert(nameLen > 0,
                               "KeyMap.GetBuiltinKeyMap(): key map name is too small");
            Diagnostics.Assert(nameLen <= EntryModule.MaxKeyMapNameLength,
                               "KeyMap.GetBuiltinKeyMap(): key map name is too large");

            for (int x = 0; x < keymapEntries; ++x)
            {
                int nSize   = 0;
                int tSize   = 0;
                int error   = 0;
                int strSize = 0;

                strSize = BinaryTool.ReadPrefixedString(table, buf,
                                                        EntryModule.MaxKeyMapNameLength, &error);

                table += strSize;
                nSize  = ByteString.Length(buf);

#if VERBOSE_KeyMap_INIT
                TextMode.Write("nsize: ");
                TextMode.Write(nSize);
                TextMode.WriteLine();

                TextMode.Write("found keymap: ");
                TextMode.WriteLine(buf);
#endif

                ret_table = table;

                table += 2;                 // keymask/statebit

                // default table

                tSize = *(int *)table;
#if VERBOSE_KeyMap_INIT
                TextMode.Write("Default-table size:");
                TextMode.Write(tSize);
                TextMode.WriteLine("");
#endif
                table += 4;
                table += tSize;

                // shifted table

                tSize = *(int *)table;
#if VERBOSE_KeyMap_INIT
                TextMode.Write("Shifted-table size:");
                TextMode.Write(tSize);
                TextMode.WriteLine("");
#endif
                table += 4;
                table += tSize;

                if (nSize == nameLen && ByteString.Compare(name, buf, nameLen) == 0)
                {
                    return(ret_table);
                }
            }

            return(null);
        }