discover/grub2: Add initial script infrastructure
authorJeremy Kerr <jk@ozlabs.org>
Thu, 12 Sep 2013 08:08:18 +0000 (16:08 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Tue, 24 Sep 2013 05:14:59 +0000 (13:14 +0800)
Now that we can parse scripts, we want some infrastructure for
execution.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/grub2/grub2.h
discover/grub2/parser.y
discover/grub2/script.c [new file with mode: 0644]

index 0643a7293d8aba9025e742d5c822f7ff8901d6fc..f3ad2e5b48491e30eb5d15c025d8c617e3b13284 100644 (file)
@@ -55,9 +55,13 @@ struct grub2_statement_block {
        struct grub2_statements *statements;
 };
 
        struct grub2_statements *statements;
 };
 
+struct grub2_script {
+       struct grub2_statements *statements;
+};
+
 struct grub2_parser {
        void                    *scanner;
 struct grub2_parser {
        void                    *scanner;
-       struct grub2_statements *statements;
+       struct grub2_script     *script;
 };
 
 struct grub2_statements *create_statements(struct grub2_parser *parser);
 };
 
 struct grub2_statements *create_statements(struct grub2_parser *parser);
@@ -88,5 +92,9 @@ void argv_append(struct grub2_argv *argv, struct grub2_word *word);
 
 void word_append(struct grub2_word *w1, struct grub2_word *w2);
 
 
 void word_append(struct grub2_word *w1, struct grub2_word *w2);
 
+/* script interface */
+
+struct grub2_script *create_script(void *ctx);
+
 #endif /* GRUB2_H */
 
 #endif /* GRUB2_H */
 
index d57c732a8382152c690fbabad381b5b266c0f509..6461801b3287c5d044919b08e521eebf19dc3f18 100644 (file)
@@ -56,7 +56,7 @@ static void yyerror(struct grub2_parser *, char const *s);
 %%
 
 script: statements {
 %%
 
 script: statements {
-               parser->statements = $1;
+               parser->script->statements = $1;
        }
 
 statements: statement {
        }
 
 statements: statement {
diff --git a/discover/grub2/script.c b/discover/grub2/script.c
new file mode 100644 (file)
index 0000000..71d6cba
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <talloc/talloc.h>
+
+#include "grub2.h"
+
+struct grub2_script *create_script(void *ctx)
+{
+       struct grub2_script *script;
+       script = talloc(ctx, struct grub2_script);
+       return script;
+}
+