diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-05-25 13:50:27 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:17:01 -0500 |
commit | e427f58622e3d88c59953d6c1fb583acfb046213 (patch) | |
tree | 4fe708ec07cdcb85dd3af028e158505e065ca59e /source4/librpc/ndr/ndr.c | |
parent | e7b3f91678a27d85791f7a62fc418988edc92214 (diff) | |
download | samba-e427f58622e3d88c59953d6c1fb583acfb046213.tar.gz samba-e427f58622e3d88c59953d6c1fb583acfb046213.tar.bz2 samba-e427f58622e3d88c59953d6c1fb583acfb046213.zip |
r6973: Merge new version of pidl into the main SAMBA_4_0 branch.
The main difference in this new version is the extra data structure generated
between the IDL data structure and the NDR parser:
IDL -> NDR -> { ndr_parser, ndr_header, eparser, etc }
This makes the ndr_parser.pm internals much more sane.
Other changes include:
- Remove unnecessary calls with NDR_BUFFERS (for example, GUID doesn't have any buffers, just scalars) as well as some (unnecessary) nested setting of flags.
- Parse array loops in the C code rather then calling ndr_pull_array(). This allows us to have, for example, arrays of pointers or arrays of pointers to arrays, etc..
- Use if() {} rather then if () goto foo; everywhere
- NDR_IN no longer implies LIBNDR_FLAG_REF_ALLOC
- By default, top level pointers are now "ref" (as is the default in
most other IDL compilers). This can be overridden using the
default_pointer_top() property.
- initial work on new ethereal parser generators by Alan DeKok and me
- pidl now writes errors in the standard format used by compilers, which
is parsable by most editors
- ability to warn about the fact that pidl extension(s) have been used,
useful for making sure IDL files work with other IDL compilers.
oh, and there's probably some other things I can't think of right now..
(This used to be commit 13cf227615f6b9e0e5fa62e59197024410254f01)
Diffstat (limited to 'source4/librpc/ndr/ndr.c')
-rw-r--r-- | source4/librpc/ndr/ndr.c | 120 |
1 files changed, 3 insertions, 117 deletions
diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 8296726866..dfd21018d2 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -182,120 +182,6 @@ NTSTATUS ndr_push_expand(struct ndr_push *ndr, uint32_t size) return NT_STATUS_OK; } -/* This function does not appear to be used */ - -#if 0 - -/* - set the push offset to 'ofs' -*/ -static NTSTATUS ndr_push_set_offset(struct ndr_push *ndr, uint32_t ofs) -{ - NDR_CHECK(ndr_push_expand(ndr, ofs)); - ndr->offset = ofs; - return NT_STATUS_OK; -} - -#endif - -/* - push a generic array -*/ -NTSTATUS ndr_push_array(struct ndr_push *ndr, int ndr_flags, void *base, - size_t elsize, uint32_t count, - NTSTATUS (*push_fn)(struct ndr_push *, int, void *)) -{ - int i; - char *p = base; - if (!(ndr_flags & NDR_SCALARS)) goto buffers; - for (i=0;i<count;i++) { - NDR_CHECK(push_fn(ndr, NDR_SCALARS, p)); - p += elsize; - } - if (!(ndr_flags & NDR_BUFFERS)) goto done; -buffers: - p = base; - for (i=0;i<count;i++) { - NDR_CHECK(push_fn(ndr, NDR_BUFFERS, p)); - p += elsize; - } -done: - return NT_STATUS_OK; -} - -/* - pull a constant sized array -*/ -NTSTATUS ndr_pull_array(struct ndr_pull *ndr, int ndr_flags, void *base, - size_t elsize, uint32_t count, - NTSTATUS (*pull_fn)(struct ndr_pull *, int, void *)) -{ - int i; - char *p; - p = base; - if (!(ndr_flags & NDR_SCALARS)) goto buffers; - for (i=0;i<count;i++) { - NDR_CHECK(pull_fn(ndr, NDR_SCALARS, p)); - p += elsize; - } - if (!(ndr_flags & NDR_BUFFERS)) goto done; -buffers: - p = base; - for (i=0;i<count;i++) { - NDR_CHECK(pull_fn(ndr, NDR_BUFFERS, p)); - p += elsize; - } -done: - return NT_STATUS_OK; -} - -/* - pull a constant size array of structures -*/ -NTSTATUS ndr_pull_struct_array(struct ndr_pull *ndr, uint32_t count, - size_t elsize, void **info, - NTSTATUS (*pull_fn)(struct ndr_pull *, int, void *)) -{ - int i; - char *base; - - NDR_ALLOC_N_SIZE(ndr, *info, count, elsize); - base = (char *)*info; - - for (i = 0; i < count; i++) { - ndr->data += ndr->offset; - ndr->offset = 0; - NDR_CHECK(pull_fn(ndr, NDR_SCALARS|NDR_BUFFERS, &base[count * elsize])); - } - - return NT_STATUS_OK; -} - -/* - print a generic array -*/ -void ndr_print_array(struct ndr_print *ndr, const char *name, void *base, - size_t elsize, uint32_t count, - void (*print_fn)(struct ndr_print *, const char *, void *)) -{ - int i; - char *p = base; - ndr->print(ndr, "%s: ARRAY(%d)", name, count); - ndr->depth++; - for (i=0;i<count;i++) { - char *idx=NULL; - asprintf(&idx, "[%d]", i); - if (idx) { - print_fn(ndr, idx, p); - free(idx); - } - p += elsize; - } - ndr->depth--; -} - - - void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3) { va_list ap; @@ -390,7 +276,7 @@ static NTSTATUS ndr_map_error(enum ndr_err_code err) break; } - /* we should all error codes to different status codes */ + /* we should map all error codes to different status codes */ return NT_STATUS_INVALID_PARAMETER; } @@ -623,7 +509,7 @@ uint32_t ndr_get_array_size(struct ndr_pull *ndr, const void *p) NTSTATUS ndr_check_array_size(struct ndr_pull *ndr, void *p, uint32_t size) { uint32_t stored; - NDR_CHECK(ndr_token_retrieve(&ndr->array_size_list, p, &stored)); + stored = ndr_token_peek(&ndr->array_size_list, p); if (stored != size) { return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size - got %u expected %u\n", @@ -661,7 +547,7 @@ uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p) NTSTATUS ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length) { uint32_t stored; - NDR_CHECK(ndr_token_retrieve(&ndr->array_length_list, p, &stored)); + stored = ndr_token_peek(&ndr->array_length_list, p); if (stored != length) { return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array length - got %u expected %u\n", |