2 test-mala.c - MaLa test driver
4 Copyright (C) 2004, Christian Thaeter <chth@gmx.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, contact me.
28 mala_actioninit my_actions
[] =
30 MALA_PARSER_SUBSTITUTE("--SUBST-TEST","SUBST_SUCCEEDED"),
31 MALA_PARSER_EXPAND("--FOOBAR",("foo","bar")),
36 main(int argc
, char * argv
[])
40 engine
= mala_engine_new ();
44 ACOGC_STACK_ENTER (&engine
->gcroot
);
45 ACOGC_STACK_PTR (MalaStringList
, args
);
46 ACOGC_STACK_PTR (MalaStringList
, result
);
48 mala_module_std_init (engine
);
50 // TODO mala_engine_new_main
51 mala_engine_actions_register (engine
, my_actions
);
53 args
.ptr
= mala_stringlist_new (engine
);
54 mala_stringlist_append_cstrs (args
.ptr
, argc
- 1, argv
+ 1, engine
);
56 mala_engine_action_new_cstr (engine
, "--ARGV0",
57 mala_substitute_parser
,
58 argv
[0], ACOGC_STATIC
,
59 mala_engine_action_get_cstr (engine
, "--WORLD"));
61 mala_engine_action_new_cstr (engine
, "--COMMANDLINE",
64 mala_engine_action_get_cstr (engine
, "--WORLD"));
67 mala_engine_run_cstr (engine
, "--COMMANDLINE", &result
.ptr
);
69 mala_stringlist_dump (result
.ptr
, stdout
, ".\n", "literal: ","%s.\n", "", "");
72 printf ("variable: %s\n", getenv ("variable"));
73 printf ("state: %s\n", mala_engine_state_str (engine
));
75 mala_engine_free (engine
);
84 // c-file-style: "gnu"
86 // arch-tag: 610917e5-3918-4cba-be05-bf83efb45223