2 #include <talloc/talloc.h>
6 struct grub2_statements *create_statements(struct grub2_parser *parser)
8 struct grub2_statements *stmts = talloc(parser,
9 struct grub2_statements);
10 list_init(&stmts->list);
14 struct grub2_statement *create_statement_simple(struct grub2_parser *parser,
15 struct grub2_argv *argv)
17 struct grub2_statement *stmt = talloc(parser, struct grub2_statement);
18 stmt->type = STMT_TYPE_SIMPLE;
19 stmt->simple.argv = argv;
23 struct grub2_statement *create_statement_menuentry(struct grub2_parser *parser,
24 struct grub2_argv *argv, struct grub2_statements *stmts)
26 struct grub2_statement *stmt = talloc(parser, struct grub2_statement);
27 stmt->type = STMT_TYPE_MENUENTRY;
28 stmt->menuentry.argv = argv;
29 stmt->menuentry.statements = stmts;
33 struct grub2_statement *create_statement_if(struct grub2_parser *parser,
34 struct grub2_statement *condition,
35 struct grub2_statements *true_case,
36 struct grub2_statements *false_case)
38 struct grub2_statement *stmt = talloc(parser, struct grub2_statement);
39 stmt->type = STMT_TYPE_IF;
40 stmt->ifstmt.condition = condition;
41 stmt->ifstmt.true_case = true_case;
42 stmt->ifstmt.false_case = false_case;
46 struct grub2_statement *create_statement_block(struct grub2_parser *parser,
47 struct grub2_statements *stmts)
49 struct grub2_statement *stmt = talloc(parser, struct grub2_statement);
50 stmt->type = STMT_TYPE_BLOCK;
51 stmt->block.statements = stmts;
55 void statement_append(struct grub2_statements *stmts,
56 struct grub2_statement *stmt)
60 list_add_tail(&stmts->list, &stmt->list);
63 struct grub2_word *create_word(struct grub2_parser *parser, const char *text,
64 bool expand, bool split)
66 struct grub2_word *word = talloc(parser, struct grub2_word);
67 word->text = talloc_strdup(word, text);
68 word->expand = expand;
74 struct grub2_argv *create_argv(struct grub2_parser *parser)
76 struct grub2_argv *argv = talloc(parser, struct grub2_argv);
77 list_init(&argv->words);
81 void argv_append(struct grub2_argv *argv, struct grub2_word *word)
83 list_add_tail(&argv->words, &word->argv_list);
86 void word_append(struct grub2_word *w1, struct grub2_word *w2)