Ejemplo n.º 1
0
        public void Parse_imports()
        {
            List <string> importsList = new List <string>();
            Match         match;

            string       Imports_pattern = @"IMPORTS.*?FROM\s*(?<IMPORT>\w+-\w+).*?FROM\s*(?<IMPORT2>\w+-\w+)";
            RegexOptions options         = RegexOptions.Singleline;

            match = Regex.Match(text, Imports_pattern, options);
            importsList.Add(match.Groups[1].Value + ".txt");
            importsList.Add(match.Groups[2].Value + ".txt");
            foreach (string s in importsList)
            {
                string path = @"mibs\" + s;

                if (File.Exists(path))
                {
                    try
                    {
                        MIB_parser newParser = new MIB_parser(path);
                        newParser.Read_from_file();
                        newParser.Check_for_object_identifier();
                        newParser.Check_for_data_types();
                        newParser.Check_for_object_type();
                        tree             = newParser.tree;
                        data_types_found = newParser.data_types_found;
                    }
                    catch (IOException e)
                    {
                        Console.WriteLine("The file could not be read or doesn't exist:");
                        Console.WriteLine(e.Message);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            MIB_parser parser = new MIB_parser(@"mibs\RFC1213-MIB.txt");

            parser.Read_from_file();
            parser.Parse_imports();
            parser.Check_for_object_identifier();
            parser.Check_for_data_types();
            parser.Check_for_object_type();
            //Node szukany = parser.tree.Find_OID("1.3.6.1.2.1.1.1");
            Koder coder = new Koder("1.3.6.1.2.1.1.1", parser.tree);

            //List<Byte> data_vector = coder.Create_content_after_validation();
            while (true)
            {
                Console.WriteLine("W celu przerwania wprowadzania wciśnij ESC :");
                if (Console.ReadKey().Key == ConsoleKey.Escape)
                {
                    break;
                }
                Console.WriteLine("Rozpoczynam kodowanie następnego elementu. ");
            }
            Console.ReadLine();
        }