summaryrefslogtreecommitdiff
path: root/source3/aparser/templates
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-05-16 11:55:06 +0000
committerAndrew Tridgell <tridge@samba.org>2000-05-16 11:55:06 +0000
commitf3a3a05ade784ff6906e5c8b132c9440a8db44e5 (patch)
tree35f1cfbb0a880a592487450c5a9b8d37cfe302b9 /source3/aparser/templates
parent466338b165a19149e7a938bf4302c95dcab82beb (diff)
downloadsamba-f3a3a05ade784ff6906e5c8b132c9440a8db44e5.tar.gz
samba-f3a3a05ade784ff6906e5c8b132c9440a8db44e5.tar.bz2
samba-f3a3a05ade784ff6906e5c8b132c9440a8db44e5.zip
another awk parser update
we can now handle arrays of structures, pointers to structures, pointers in unions etc (This used to be commit 1df80cd1e8475b6b2fe7b80b6c9089692ab7691b)
Diffstat (limited to 'source3/aparser/templates')
-rw-r--r--source3/aparser/templates/fn_end.tpl27
-rw-r--r--source3/aparser/templates/fn_mid.tpl6
-rw-r--r--source3/aparser/templates/fn_start.tpl10
-rw-r--r--source3/aparser/templates/harness_start.tpl2
-rw-r--r--source3/aparser/templates/ifptr_start.tpl1
-rw-r--r--source3/aparser/templates/prs_array.tpl13
-rw-r--r--source3/aparser/templates/prs_break.tpl1
-rw-r--r--source3/aparser/templates/prs_case.tpl2
-rw-r--r--source3/aparser/templates/prs_element.tpl1
-rw-r--r--source3/aparser/templates/prs_pointer.tpl4
-rw-r--r--source3/aparser/templates/prs_wstring.tpl2
-rw-r--r--source3/aparser/templates/union_start.tpl2
12 files changed, 32 insertions, 39 deletions
diff --git a/source3/aparser/templates/fn_end.tpl b/source3/aparser/templates/fn_end.tpl
index a21decdd13..38cf10d1b2 100644
--- a/source3/aparser/templates/fn_end.tpl
+++ b/source3/aparser/templates/fn_end.tpl
@@ -1,3 +1,6 @@
+
+end:
+ /* the parse is OK, just align and end */
if (!prs_align(ps)) goto fail;
return True;
@@ -7,28 +10,4 @@ fail:
return False;
} /* @FUNCNAME@ */
-/*******************************************************************
-parse a @STRUCTNAME@ structure
-********************************************************************/
-BOOL @FUNCNAME@_alloc(char *desc, @STRUCTNAME@ **q_u,
- prs_struct *ps, int depth)
-{
- @STRUCTNAME@ *il;
- BOOL ret;
-
- if (!UNMARSHALLING(ps)) return False;
-
- il=(@STRUCTNAME@ *)malloc(sizeof(@STRUCTNAME@));
- if (il == NULL) return False;
- ZERO_STRUCTP(il);
-
- ret = @FUNCNAME@(desc, il, ps, depth);
- if (!ret) {
- free(il);
- return False;
- }
- *q_u = il;
- return True;
-}
-
diff --git a/source3/aparser/templates/fn_mid.tpl b/source3/aparser/templates/fn_mid.tpl
new file mode 100644
index 0000000000..b81de92a5b
--- /dev/null
+++ b/source3/aparser/templates/fn_mid.tpl
@@ -0,0 +1,6 @@
+
+buffers:
+ if (!(flags & PARSE_BUFFERS)) goto end;
+
+ /* now parse the buffers */
+
diff --git a/source3/aparser/templates/fn_start.tpl b/source3/aparser/templates/fn_start.tpl
index deecc670e3..017f894f78 100644
--- a/source3/aparser/templates/fn_start.tpl
+++ b/source3/aparser/templates/fn_start.tpl
@@ -1,9 +1,13 @@
/*******************************************************************
parse a @STRUCTNAME@ structure
********************************************************************/
-BOOL @FUNCNAME@(char *desc, @STRUCTNAME@ *il,
- prs_struct *ps, int depth)
+BOOL @FUNCNAME@(char *desc, prs_struct *ps, int depth,
+ @STRUCTNAME@ *il, unsigned flags)
{
prs_debug(ps, depth, desc, "@FUNCNAME@");
depth++;
-
+
+ if (!(flags & PARSE_SCALARS)) goto buffers;
+
+ ZERO_STRUCTP(il);
+ /* parse the scalars */
diff --git a/source3/aparser/templates/harness_start.tpl b/source3/aparser/templates/harness_start.tpl
index 375b110536..7e6ab9dc3a 100644
--- a/source3/aparser/templates/harness_start.tpl
+++ b/source3/aparser/templates/harness_start.tpl
@@ -1,6 +1,6 @@
#define TEST_STRUCT @STRUCTNAME@
#define TEST_NAME "@TEST@"
-#define TEST_FUNC @FUNCNAME@_alloc
+#define TEST_FUNC @FUNCNAME@
#include "prs_@MODULE@.h"
diff --git a/source3/aparser/templates/ifptr_start.tpl b/source3/aparser/templates/ifptr_start.tpl
index ffffe49e91..228b84bac9 100644
--- a/source3/aparser/templates/ifptr_start.tpl
+++ b/source3/aparser/templates/ifptr_start.tpl
@@ -1 +1,2 @@
if (il->@ELEM@) {
+ if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@)))) goto fail;
diff --git a/source3/aparser/templates/prs_array.tpl b/source3/aparser/templates/prs_array.tpl
index ca707148db..1bf3fa4b04 100644
--- a/source3/aparser/templates/prs_array.tpl
+++ b/source3/aparser/templates/prs_array.tpl
@@ -1,7 +1,8 @@
- if (il->@ARRAYLEN@ > 0) {
- il->@ELEM@ = (@TYPE@ *)malloc(sizeof(@TYPE@)*il->@ARRAYLEN@);
- if (!il->@ELEM@) goto fail;
- if (!prs_@TYPE@s(True, "@ELEM@", ps, depth+1, il->@ELEM@, il->@ARRAYLEN@)) goto fail;
- } else {
- il->@ELEM@ = NULL;
+ if ((@FLAGS@ & PARSE_SCALARS) &&
+ !io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*il->@ARRAY_LEN@)) goto fail;
+ {
+ int i;
+ for (i=0;i<il->@ARRAY_LEN@;i++) {
+ if (!io_@TYPE@("@ELEM@...", ps, depth+1, &il->@ELEM@[i], @FLAGS@)) goto fail;
+ }
}
diff --git a/source3/aparser/templates/prs_break.tpl b/source3/aparser/templates/prs_break.tpl
new file mode 100644
index 0000000000..eb540f7be8
--- /dev/null
+++ b/source3/aparser/templates/prs_break.tpl
@@ -0,0 +1 @@
+ break;
diff --git a/source3/aparser/templates/prs_case.tpl b/source3/aparser/templates/prs_case.tpl
index 2f81c35828..06c1bd3ae6 100644
--- a/source3/aparser/templates/prs_case.tpl
+++ b/source3/aparser/templates/prs_case.tpl
@@ -1 +1 @@
- case @VALUE@:
+ case @CASE@:
diff --git a/source3/aparser/templates/prs_element.tpl b/source3/aparser/templates/prs_element.tpl
new file mode 100644
index 0000000000..e8bf5180ce
--- /dev/null
+++ b/source3/aparser/templates/prs_element.tpl
@@ -0,0 +1 @@
+ if (!io_@TYPE@("@ELEM@", ps, depth+1, @PTR@il->@ELEM@, @FLAGS@)) goto fail;
diff --git a/source3/aparser/templates/prs_pointer.tpl b/source3/aparser/templates/prs_pointer.tpl
index 6ad1b99a01..4ebcf19d83 100644
--- a/source3/aparser/templates/prs_pointer.tpl
+++ b/source3/aparser/templates/prs_pointer.tpl
@@ -1,2 +1,2 @@
- if (!prs_pointer("@ELEM@_ptr", ps, depth+1,
- (void **)&il->@ELEM@, True)) goto fail;
+ if (!io_pointer("@ELEM@_ptr", ps, depth+1,
+ (void **)&il->@ELEM@, @FLAGS@)) goto fail;
diff --git a/source3/aparser/templates/prs_wstring.tpl b/source3/aparser/templates/prs_wstring.tpl
new file mode 100644
index 0000000000..022381c2d2
--- /dev/null
+++ b/source3/aparser/templates/prs_wstring.tpl
@@ -0,0 +1,2 @@
+ if (!io_alloc("@ELEM@", ps, (void **)&il->@ELEM@, sizeof(*(il->@ELEM@))*il->@ARRAY_LEN@)) goto fail;
+ if (!io_wstring("@ELEM@", ps, depth+1, il->@ELEM@, il->@ARRAY_LEN@, @FLAGS@)) goto fail;
diff --git a/source3/aparser/templates/union_start.tpl b/source3/aparser/templates/union_start.tpl
index a46c99c1e1..aa052be697 100644
--- a/source3/aparser/templates/union_start.tpl
+++ b/source3/aparser/templates/union_start.tpl
@@ -1,3 +1 @@
- il->@ELEM@ = (void *)malloc(sizeof(*(il->@ELEM@)));
- if (!il->@ELEM@) goto fail;
switch (il->@SWITCH@) {