r4846: do not keep outdated files here.
[Samba.git] / source / aparser / dump.awk
blob11bfb107e467ee5a6dbbfc85ad339e45ec80796e
1 # dump the current parse tree
4 function element_string(elnum,
5 LOCAL, elem)
7 elem = elements[elnum, "elem"];
8 if (elements[elnum, "ptr"]=="1") elem="*"elem;
9 if (elements[elnum, "array_len"]!="")
10 elem=elem"["elements[elnum, "array_len"]"]";
11 if (elements[elnum, "switch"]!="")
12 elem=elem"["elements[elnum, "switch"]"]";
13 return elem;
16 function dump_element(f, elnum,
17 LOCAL, elem, type)
19 type = elements[elnum, "type"];
20 case = elements[elnum, "case"];
21 elem = element_string(elnum);
22 if (case != "") {
23 xprintf(f,"\t\tcase %d %s %s;\n", case, type, elem);
24 } else {
25 xprintf(f,"\t%s %s;\n", type, elem);
29 function dump_union(f, elnum,
30 LOCAL, i)
32 xprintf(f,"\tunion %s {\n", element_string(elnum));
33 for (i=0;i<unions[elnum, "num_elems"];i++) {
34 dump_element(f, unions[elnum, i]);
36 xprintf(f,"\t}\n");
39 function dump_elem(f, struct_num, elem_num,
40 LOCAL, enum)
42 elnum = structs[struct_num, elem_num];
44 if (elements[elnum, "type"] == "union") {
45 dump_union(f, elnum);
46 } else {
47 dump_element(f, elnum);
51 function dump_structs(f, NIL,
52 LOCAL, i, j)
54 xprintf(f,"/* dump of parsed structures */\n\n\n");
56 for (i=0;i < num_options;i++) {
57 xprintf(f,"option %s %s\n", options[i, "name"], options[i, "value"]);
59 xprintf(f,"\n\n");
61 for (i=0;i < num_structs;i++) {
62 xprintf(f,"/* structure %d */\n", i);
63 xprintf(f,"struct %s {\n", structs[i, "name"]);
64 for (j=0;j<structs[i, "num_elems"];j++) {
65 dump_elem(f, i, j);
67 xprintf(f,"};\n\n");
69 xprintf(f,"/* end dump */\n\n");