From ba6d3075bc7806878ed22f0bde7abf83142a714b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 17 Aug 2005 01:29:35 +0000 Subject: r9339: treat arrays of uint8 values as a special DATA_BLOB type in the ejs interfaces to RPC. This makes large blobs of data much saner. Tim, you will probably want to do the same for the smb_interfaces.h generated code. Next we will need ways of extracting different data types from these blobs, for example asking for the blob to be interpreted as a utf16 string, or as a little-endian integer. That will allow for registry scripting to be quite sane. (This used to be commit a8bca2e8e27c953c0413693326ec3b5ecf17ba41) --- source4/scripting/ejs/ejsrpc.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'source4/scripting/ejs/ejsrpc.c') diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c index f107c84b73..de25d3a0f0 100644 --- a/source4/scripting/ejs/ejsrpc.c +++ b/source4/scripting/ejs/ejsrpc.c @@ -349,3 +349,40 @@ NTSTATUS ejs_push_BOOL(struct ejs_rpc *ejs, { return mprSetVar(v, name, mprCreateBoolVar(*r)); } + + +/* + pull a uint8 array from a mpr variable to a C element - treating as a data blob +*/ +NTSTATUS ejs_pull_array_uint8(struct ejs_rpc *ejs, + struct MprVar *v, const char *name, + uint8_t *r, uint32_t length) +{ + NTSTATUS status; + DATA_BLOB *blob; + + status = mprGetVar(&v, name); + NT_STATUS_NOT_OK_RETURN(status); + + blob = mprToDataBlob(v); + if (blob == NULL) { + return NT_STATUS_OBJECT_NAME_INVALID; + } + if (blob->length != length) { + return NT_STATUS_INFO_LENGTH_MISMATCH; + } + memcpy(r, blob->data, length); + return NT_STATUS_OK; + +} + +NTSTATUS ejs_push_array_uint8(struct ejs_rpc *ejs, + struct MprVar *v, const char *name, + const uint8_t *r, uint32_t length) +{ + DATA_BLOB blob; + blob.data = discard_const(r); + blob.length = length; + mprSetVar(v, name, mprDataBlob(blob)); + return NT_STATUS_OK; +} -- cgit