]> git.ozlabs.org Git - petitboot/blobdiff - discover/grub2/grub2.h
discover/grub2: Remove debug printfs
[petitboot] / discover / grub2 / grub2.h
index 0643a7293d8aba9025e742d5c822f7ff8901d6fc..07a1e6c7fe3517deb46e4786472cab0312a82f64 100644 (file)
@@ -1,10 +1,11 @@
 #ifndef GRUB2_H
 #define GRUB2_H
 
+#include <regex.h>
 #include <stdbool.h>
 #include <list/list.h>
 
-struct grub2_parser;
+struct grub2_script;
 
 struct grub2_word {
        const char              *text;
@@ -30,6 +31,8 @@ struct grub2_statement {
                STMT_TYPE_IF,
                STMT_TYPE_BLOCK,
        } type;
+       int                     (*exec)(struct grub2_script *,
+                                       struct grub2_statement *);
 };
 
 struct grub2_statement_simple {
@@ -55,9 +58,15 @@ struct grub2_statement_block {
        struct grub2_statements *statements;
 };
 
+struct grub2_script {
+       struct grub2_statements *statements;
+       struct list             environment;
+       regex_t                 var_re;
+};
+
 struct grub2_parser {
        void                    *scanner;
-       struct grub2_statements *statements;
+       struct grub2_script     *script;
 };
 
 struct grub2_statements *create_statements(struct grub2_parser *parser);
@@ -88,5 +97,15 @@ void argv_append(struct grub2_argv *argv, struct grub2_word *word);
 
 void word_append(struct grub2_word *w1, struct grub2_word *w2);
 
+/* script interface */
+void script_execute(struct grub2_script *script);
+
+int statement_simple_execute(struct grub2_script *script,
+               struct grub2_statement *statement);
+int statement_if_execute(struct grub2_script *script,
+               struct grub2_statement *statement);
+
+struct grub2_script *create_script(void *ctx);
+
 #endif /* GRUB2_H */