summaryrefslogtreecommitdiff
path: root/other/burneye/src/conf/tmp/element.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/element.c
parent073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff)
initial
Diffstat (limited to 'other/burneye/src/conf/tmp/element.c')
-rw-r--r--other/burneye/src/conf/tmp/element.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/other/burneye/src/conf/tmp/element.c b/other/burneye/src/conf/tmp/element.c
new file mode 100644
index 0000000..ee7633e
--- /dev/null
+++ b/other/burneye/src/conf/tmp/element.c
@@ -0,0 +1,115 @@
1/* fornax - distributed network
2 *
3 * by team teso
4 *
5 * scripting element routines
6 */
7
8#include <string.h>
9#include <stdlib.h>
10#include "../../shared/common.h"
11#include "call.h"
12#include "branch.h"
13#include "element.h"
14#include "symbol.h"
15
16
17/* static function declarations
18 */
19static int elem_count (element **el);
20
21
22void
23elem_list_free (element **el)
24{
25 if (el == NULL)
26 return;
27
28 while (elem_count (el) > 0) {
29 elem_free (el[0]);
30 memmove (&el[0], &el[1], (elem_count (&el[1]) + 1) * sizeof (element *));
31 }
32
33 if (el != NULL)
34 free (el);
35}
36
37
38static int
39elem_count (element **el)
40{
41 int count;
42
43 if (el == NULL)
44 return (0);
45
46 for (count = 0 ; el[count] != NULL ; ++count)
47 ;
48
49 return (count);
50}
51
52
53element **
54elem_add (element **el, element *e)
55{
56 int ec = elem_count (el);
57
58 el = xrealloc (el, (ec + 2) * sizeof (element *));
59 el[ec] = e;
60 el[ec + 1] = NULL;
61
62 return (el);
63}
64
65
66element *
67elem_create (void)
68{
69 element * new = xcalloc (1, sizeof (element));
70
71 return (new);
72}
73
74
75void
76elem_free (element *e)
77{
78 switch (e->type) {
79 case (ELEM_TYPE_CALL):
80 call_free ((call *) e->data);
81 break;
82 case (ELEM_TYPE_BRANCH):
83 br_free ((branch *) e->data);
84 break;
85 case (ELEM_TYPE_SET):
86 sym_elem_free ((sym_elem *) e->data);
87 break;
88 default:
89 break;
90 }
91
92 free (e);
93
94 return;
95}
96
97
98element *
99elem_set_type (element *e, int type)
100{
101 e->type = type;
102
103 return (e);
104}
105
106
107element *
108elem_set_data (element *e, void *data)
109{
110 e->data = data;
111
112 return (e);
113}
114
115