summaryrefslogtreecommitdiff
path: root/source4/scripting/ejs
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-08 03:33:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:20 -0500
commit7fded3c856735050e7d72972da8bc2cd19f01cd8 (patch)
treed04267c6eb16b1006b54384158712b38bde62178 /source4/scripting/ejs
parent1e1a96eea6c340eb0fd867f942f176c13d856c5f (diff)
downloadsamba-7fded3c856735050e7d72972da8bc2cd19f01cd8.tar.gz
samba-7fded3c856735050e7d72972da8bc2cd19f01cd8.tar.bz2
samba-7fded3c856735050e7d72972da8bc2cd19f01cd8.zip
r8215: switched the pull side of the ejs generator over to the recursive LEVELS based approach.
This allows for much more complex structure mappings to be generated. (This used to be commit 49fc14d13291b02f7b16ab0eefe7bfb26f51b1c8)
Diffstat (limited to 'source4/scripting/ejs')
-rw-r--r--source4/scripting/ejs/ejsrpc.c27
-rw-r--r--source4/scripting/ejs/ejsrpc.h17
2 files changed, 14 insertions, 30 deletions
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
index 965fd8d447..574c75b7de 100644
--- a/source4/scripting/ejs/ejsrpc.c
+++ b/source4/scripting/ejs/ejsrpc.c
@@ -254,33 +254,6 @@ NTSTATUS ejs_push_enum(struct ejs_rpc *ejs,
/*
- pull an array of elements
-*/
-NTSTATUS ejs_pull_array(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint32_t length,
- size_t elsize, void **r, ejs_pull_t ejs_pull)
-{
- int i;
- char *data;
-
- NDR_CHECK(ejs_pull_struct_start(ejs, &v, name));
-
- (*r) = talloc_array_size(ejs, elsize, length);
- NT_STATUS_HAVE_NO_MEMORY(*r);
-
- data = *r;
-
- for (i=0;i<length;i++) {
- char *id = talloc_asprintf(ejs, "%u", i);
- NT_STATUS_HAVE_NO_MEMORY(id);
- NDR_CHECK(ejs_pull(ejs, v, id, (i*elsize)+data));
- talloc_free(id);
- }
- return NT_STATUS_OK;
-}
-
-
-/*
pull a string
*/
NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index 67b81b3411..fdf15c027c 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -64,10 +64,21 @@ NTSTATUS ejs_pull_enum(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, unsigned *r);
NTSTATUS ejs_push_enum(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const unsigned *r);
-NTSTATUS ejs_pull_array(struct ejs_rpc *ejs,
- struct MprVar *v, const char *name, uint32_t length,
- size_t elsize, void **r, ejs_pull_t ejs_pull);
NTSTATUS ejs_pull_string(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, char **s);
NTSTATUS ejs_push_string(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const char *s);
+
+#define EJS_ALLOC_SIZE(ejs, s, size) do { \
+ (s) = talloc_size(ejs, size); \
+ if (!(s)) return ejs_panic(ejs, "out of memory"); \
+} while (0)
+
+#define EJS_ALLOC(ejs, s) EJS_ALLOC_SIZE(ejs, s, sizeof(*(s)))
+
+#define EJS_ALLOC_N_SIZE(ejs, s, n, elsize) do { \
+ (s) = talloc_array_size(ejs, elsize, n); \
+ if (!(s)) return ejs_panic(ejs, "out of memory"); \
+} while (0)
+
+#define EJS_ALLOC_N(ejs, s, n) EJS_ALLOC_N_SIZE(ejs, s, n, sizeof(*(s)))