summaryrefslogtreecommitdiff
path: root/other/burneye/src/conf/tmp/compiler-test.c
diff options
context:
space:
mode:
authorRoot THC2026-02-24 12:42:47 +0000
committerRoot THC2026-02-24 12:42:47 +0000
commitc9cbeced5b3f2bdd7407e29c0811e65954132540 (patch)
treeaefc355416b561111819de159ccbd86c3004cf88 /other/burneye/src/conf/tmp/compiler-test.c
parent073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff)
initial
Diffstat (limited to 'other/burneye/src/conf/tmp/compiler-test.c')
-rw-r--r--other/burneye/src/conf/tmp/compiler-test.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/other/burneye/src/conf/tmp/compiler-test.c b/other/burneye/src/conf/tmp/compiler-test.c
new file mode 100644
index 0000000..969ae4d
--- /dev/null
+++ b/other/burneye/src/conf/tmp/compiler-test.c
@@ -0,0 +1,74 @@
1/* fornax - distributed network
2 *
3 * by team teso
4 *
5 * compiler test program
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include "../../shared/common.h"
12#include "element.h"
13#include "compiler.h"
14#include "script.h"
15
16
17extern void scr_elem_exec (element **el);
18char * file_read (char *filename);
19
20
21char *
22file_read (char *filename)
23{
24 FILE *fp;
25 char *array = NULL;
26 unsigned long int readbytes = 0;
27 size_t rb;
28
29 fp = fopen (filename, "r");
30 if (fp == NULL)
31 return (NULL);
32
33 do {
34 array = xrealloc (array, readbytes + 1024);
35 rb = fread (array + readbytes, 1, 1024, fp);
36 readbytes += rb;
37 } while (rb > 0);
38
39 fclose (fp);
40
41 return (array);
42}
43
44
45int
46main (int argc, char **argv)
47{
48 element ** script_c;
49 char * script;
50
51 if (argc != 2) {
52 printf ("usage: %s <inputfile>\n\n", argv[0]);
53 exit (EXIT_FAILURE);
54 }
55
56 script = file_read (argv[1]);
57 if (script == NULL) {
58 fprintf (stderr, "couldn't open %s, aborting\n", argv[1]);
59 exit (EXIT_FAILURE);
60 }
61
62 script_c = cp_compile (script, strlen (script));
63 printf ("-------------------------------------------------------------------------------\n");
64 printf ("compilation of script %s %s.\n\n", argv[1], (script_c == NULL) ? "failed" : "successful");
65
66 printf ("\ntrying to run it...\n");
67 scr_elem_exec (script_c);
68
69 elem_list_free (script_c);
70
71 exit (EXIT_SUCCESS);
72}
73
74