diff options
author | Tim Potter <tpot@samba.org> | 2004-06-03 07:33:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:56:25 -0500 |
commit | e071ecd9917e6d5e57a949d9aa64b35b445283f5 (patch) | |
tree | 566e4585dcd8bdb9ab919e600d333d73384e6e53 | |
parent | faaa211d6632872004a2b1eb6025fe032cf0f790 (diff) | |
download | samba-e071ecd9917e6d5e57a949d9aa64b35b445283f5.tar.gz samba-e071ecd9917e6d5e57a949d9aa64b35b445283f5.tar.bz2 samba-e071ecd9917e6d5e57a949d9aa64b35b445283f5.zip |
r987: Start replacing ndr_* functions with e_ndr_* and removing stuff related
to storing data in structure members.
(This used to be commit 60942eaa3a8a56b5823bfcb736d25c00b17fec50)
-rw-r--r-- | source4/build/pidl/eparser.pm | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/source4/build/pidl/eparser.pm b/source4/build/pidl/eparser.pm index 366293f30d..54962daf9c 100644 --- a/source4/build/pidl/eparser.pm +++ b/source4/build/pidl/eparser.pm @@ -238,7 +238,7 @@ sub ParseArrayPull($$$) $alloc_size = $e->{CONFORMANT_SIZE}; pidl "\tif ($size > $alloc_size) {\n"; - pidl "\t\treturn ndr_pull_error(ndr, NDR_ERR_CONFORMANT_SIZE, \"Bad conformant size %u should be %u\", $alloc_size, $size);\n"; + pidl "\t\treturn e_ndr_pull_error(ndr, NDR_ERR_CONFORMANT_SIZE, \"Bad conformant size %u should be %u\", $alloc_size, $size);\n"; pidl "\t}\n"; } elsif (!util::is_inline_array($e)) { if ($var_prefix =~ /^r->out/ && $size =~ /^\*r->in/) { @@ -249,13 +249,13 @@ sub ParseArrayPull($$$) # non fixed arrays encode the size just before the array pidl "\t{\n"; pidl "\t\tguint32 _array_size;\n"; - pidl "\t\tndr_pull_uint32(ndr, &_array_size);\n"; + pidl "\t\te_ndr_pull_uint32(ndr, &_array_size);\n"; if ($size =~ /r->in/) { pidl "\t\tif (!(ndr->flags & LIBNDR_FLAG_REF_ALLOC) && _array_size != $size) {\n"; } else { pidl "\t\tif ($size != _array_size) {\n"; } - pidl "\t\t\treturn ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should be %u\", _array_size, $size);\n"; + pidl "\t\t\treturn e_ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, \"Bad array size %u should be %u\", _array_size, $size);\n"; pidl "\t\t}\n"; if ($size =~ /r->in/) { pidl "else { $size = _array_size; }\n"; @@ -283,17 +283,17 @@ sub ParseArrayPull($$$) if (my $length = util::has_property($e, "length_is")) { $length = find_size_var($e, $length, $var_prefix); pidl "\t\tguint32 _offset, _length;\n"; - pidl "\t\tndr_pull_uint32(ndr, &_offset);\n"; - pidl "\t\tndr_pull_uint32(ndr, &_length);\n"; - pidl "\t\tif (_offset != 0) return ndr_pull_error(ndr, NDR_ERR_OFFSET, \"Bad array offset 0x%08x\", _offset);\n"; - pidl "\t\tif (_length > $size || _length != $length) return ndr_pull_error(ndr, NDR_ERR_LENGTH, \"Bad array length 0x%08x > size 0x%08x\", _offset, $size);\n\n"; + pidl "\t\te_ndr_pull_uint32(ndr, &_offset);\n"; + pidl "\t\te_ndr_pull_uint32(ndr, &_length);\n"; + pidl "\t\tif (_offset != 0) return e_ndr_pull_error(ndr, NDR_ERR_OFFSET, \"Bad array offset 0x%08x\", _offset);\n"; + pidl "\t\tif (_length > $size || _length != $length) return e_ndr_pull_error(ndr, NDR_ERR_LENGTH, \"Bad array length 0x%08x > size 0x%08x\", _offset, $size);\n\n"; $size = "_length"; } if (util::is_scalar_type($e->{TYPE})) { - pidl "\t\tndr_pull_array_$e->{TYPE}(ndr, $ndr_flags, $var_prefix$e->{NAME}, $size);\n"; + pidl "\t\te_ndr_pull_array_$e->{TYPE}(ndr, $ndr_flags, $var_prefix$e->{NAME}, $size);\n"; } else { - pidl "\t\tndr_pull_array(ndr, $ndr_flags, (void **)$var_prefix$e->{NAME}, sizeof($var_prefix$e->{NAME}\[0]), $size, (ndr_pull_flags_fn_t)ndr_pull_$e->{TYPE});\n"; + pidl "\t\te_ndr_pull_array(ndr, $ndr_flags, (void **)$var_prefix$e->{NAME}, sizeof($var_prefix$e->{NAME}\[0]), $size, (ndr_pull_flags_fn_t)e_ndr_pull_$e->{TYPE});\n"; } pidl "\t}\n"; @@ -318,13 +318,13 @@ sub ParseElementPullSwitch($$$$) my $e2 = find_sibling($e, $switch); pidl "\tif (($ndr_flags) & NDR_SCALARS) {\n"; pidl "\t\t $e2->{TYPE} _level;\n"; - pidl "\t\tndr_pull_$e2->{TYPE}(ndr, &_level);\n"; + pidl "\t\te_ndr_pull_$e2->{TYPE}(ndr, &_level);\n"; if ($switch_var =~ /r->in/) { pidl "\t\tif (!(ndr->flags & LIBNDR_FLAG_REF_ALLOC) && _level != $switch_var) {\n"; } else { pidl "\t\tif (_level != $switch_var) {\n"; } - pidl "\t\t\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u in $e->{NAME}\");\t\t}\n"; + pidl "\t\t\treturn e_ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value %u in $e->{NAME}\");\t\t}\n"; if ($switch_var =~ /r->/) { pidl "else { $switch_var = _level; }\n"; } @@ -333,9 +333,9 @@ sub ParseElementPullSwitch($$$$) my $sub_size = util::has_property($e, "subcontext"); if (defined $sub_size) { - pidl "\tndr_pull_subcontext_union_fn(ndr, $sub_size, $switch_var, $cprefix$var_prefix$e->{NAME}, (ndr_pull_union_fn_t) ndr_pull_$e->{TYPE});\n"; + pidl "\te_ndr_pull_subcontext_union_fn(ndr, $sub_size, $switch_var, $cprefix$var_prefix$e->{NAME}, (e_ndr_pull_union_fn_t) ndr_pull_$e->{TYPE});\n"; } else { - pidl "\tndr_pull_$e->{TYPE}(ndr, $ndr_flags, $switch_var, $cprefix$var_prefix$e->{NAME});\n"; + pidl "\te_ndr_pull_$e->{TYPE}(ndr, $ndr_flags, $switch_var);\n"; } @@ -354,11 +354,11 @@ sub ParseElementPullScalar($$$) start_flags($e); if (util::has_property($e, "relative")) { - pidl "\tndr_pull_relative(ndr, (const void **)&$var_prefix$e->{NAME}, sizeof(*$var_prefix$e->{NAME}), (ndr_pull_flags_fn_t)ndr_pull_$e->{TYPE});\n"; + pidl "\te_ndr_pull_relative(ndr, (const void **)&$var_prefix$e->{NAME}, sizeof(*$var_prefix$e->{NAME}), (ndr_pull_flags_fn_t)e_ndr_pull_$e->{TYPE});\n"; } elsif (util::is_inline_array($e)) { ParseArrayPull($e, "r->", "NDR_SCALARS"); } elsif (util::need_wire_pointer($e)) { - pidl "\tndr_pull_uint32(ndr, &_ptr_$e->{NAME});\n"; + pidl "\te_ndr_pull_ptr(ndr, &_ptr_$e->{NAME});\n"; # pidl "\tif (_ptr_$e->{NAME}) {\n"; # pidl "\t\tNDR_ALLOC(ndr, $var_prefix$e->{NAME});\n"; # pidl "\t} else {\n"; @@ -370,14 +370,14 @@ sub ParseElementPullScalar($$$) ParseElementPullSwitch($e, $var_prefix, $ndr_flags, $switch); } elsif (defined $sub_size) { if (util::is_builtin_type($e->{TYPE})) { - pidl "\tndr_pull_subcontext_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_fn_t) ndr_pull_$e->{TYPE});\n"; + pidl "\te_ndr_pull_subcontext_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_fn_t) e_ndr_pull_$e->{TYPE});\n"; } else { - pidl "\tndr_pull_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_flags_fn_t) ndr_pull_$e->{TYPE});\n"; + pidl "\te_ndr_pull_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_flags_fn_t) e_ndr_pull_$e->{TYPE});\n"; } } elsif (util::is_builtin_type($e->{TYPE})) { - pidl "\tndr_pull_$e->{TYPE}(ndr, $cprefix$var_prefix$e->{NAME});\n"; + pidl "\te_ndr_pull_$e->{TYPE}(ndr, hf_$e->{NAME}_$e->{TYPE});\n"; } else { - pidl "\tndr_pull_$e->{TYPE}(ndr, $ndr_flags, $cprefix$var_prefix$e->{NAME});\n"; + pidl "\te_ndr_pull_$e->{TYPE}(ndr, $ndr_flags);\n"; } end_flags($e); @@ -420,17 +420,17 @@ sub ParseElementPullBuffer($$$) } elsif (defined $sub_size) { if ($e->{POINTERS}) { if (util::is_builtin_type($e->{TYPE})) { - pidl "\tndr_pull_subcontext_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_fn_t) ndr_pull_$e->{TYPE});\n"; + pidl "\te_ndr_pull_subcontext_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_fn_t) e_ndr_pull_$e->{TYPE});\n"; } else { - pidl "\tndr_pull_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_flags_fn_t) ndr_pull_$e->{TYPE});\n"; + pidl "\te_ndr_pull_subcontext_flags_fn(ndr, $sub_size, $cprefix$var_prefix$e->{NAME}, (ndr_pull_flags_fn_t) e_ndr_pull_$e->{TYPE});\n"; } } } elsif (util::is_builtin_type($e->{TYPE})) { - pidl "\t\tndr_pull_$e->{TYPE}(ndr, $cprefix$var_prefix$e->{NAME});\n"; + pidl "\t\te_ndr_pull_$e->{TYPE}(ndr, hf_$e->{NAME}_$e->{TYPE});\n"; } elsif ($e->{POINTERS}) { - pidl "\t\tndr_pull_$e->{TYPE}(ndr, NDR_SCALARS|NDR_BUFFERS, $cprefix$var_prefix$e->{NAME});\n"; + pidl "\t\te_ndr_pull_$e->{TYPE}(ndr, NDR_SCALARS|NDR_BUFFERS);\n"; } else { - pidl "\t\tndr_pull_$e->{TYPE}(ndr, $ndr_flags, $cprefix$var_prefix$e->{NAME});\n"; + pidl "\t\te_ndr_pull_$e->{TYPE}(ndr, $ndr_flags);\n"; } if (util::need_wire_pointer($e)) { @@ -475,14 +475,14 @@ sub ParseStructPull($) pidl "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n"; - pidl "\tndr_pull_struct_start(ndr);\n"; + pidl "\te_ndr_pull_struct_start(ndr);\n"; if (defined $conform_e) { - pidl "\tndr_pull_uint32(ndr, &$conform_e->{CONFORMANT_SIZE});\n"; + pidl "\te_ndr_pull_uint32(ndr, &$conform_e->{CONFORMANT_SIZE});\n"; } my $align = struct_alignment($struct); - pidl "\tndr_pull_align(ndr, $align);\n"; + pidl "\te_ndr_pull_align(ndr, $align);\n"; foreach my $e (@{$struct->{ELEMENTS}}) { ParseElementPullScalar($e, "r->", "NDR_SCALARS"); @@ -494,7 +494,7 @@ sub ParseStructPull($) ParseElementPullBuffer($e, "r->", "NDR_BUFFERS"); } - pidl "\tndr_pull_struct_end(ndr);\n"; + pidl "\te_ndr_pull_struct_end(ndr);\n"; pidl "done:\n"; @@ -512,10 +512,10 @@ sub ParseUnionPull($) pidl "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n"; - pidl "\tndr_pull_struct_start(ndr);\n"; + pidl "\te_ndr_pull_struct_start(ndr);\n"; # my $align = union_alignment($e); -# pidl "\tndr_pull_align(ndr, $align);\n"; +# pidl "\te_ndr_pull_align(ndr, $align);\n"; pidl "\tswitch (level) {\n"; foreach my $el (@{$e->{DATA}}) { @@ -536,7 +536,7 @@ sub ParseUnionPull($) } if (! $have_default) { pidl "\tdefault:\n"; - pidl "\t\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);\n"; + pidl "\t\treturn e_ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);\n"; } pidl "\t}\n"; pidl "buffers:\n"; @@ -555,10 +555,10 @@ sub ParseUnionPull($) } if (! $have_default) { pidl "\tdefault:\n"; - pidl "\t\treturn ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);\n"; + pidl "\t\treturn e_ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, \"Bad switch value \%u\", level);\n"; } pidl "\t}\n"; - pidl "\tndr_pull_struct_end(ndr);\n"; + pidl "\te_ndr_pull_struct_end(ndr);\n"; pidl "done:\n"; end_flags($e); } @@ -594,18 +594,16 @@ sub ParseTypedefPull($) pidl "*/\n\n"; if ($e->{DATA}->{TYPE} eq "STRUCT") { - pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, struct $e->{NAME} *r)"; + pidl $static . "void dissect_$e->{NAME}(struct e_ndr_pull *ndr, int ndr_flags)"; pidl "\n{\n"; ParseTypePull($e->{DATA}); - pidl "\treturn NT_STATUS_OK;\n"; pidl "}\n\n"; } if ($e->{DATA}->{TYPE} eq "UNION") { - pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, guint16 level, union $e->{NAME} *r)"; + pidl $static . "void dissect_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, guint16 level)"; pidl "\n{\n"; ParseTypePull($e->{DATA}); - pidl "\treturn NT_STATUS_OK;\n"; pidl "}\n\n"; } @@ -623,7 +621,7 @@ sub ParseFunctionElementPull($$) if (util::array_size($e)) { if (util::need_wire_pointer($e)) { - pidl "\tndr_pull_uint32(ndr, &_ptr_$e->{NAME});\n"; + pidl "\te_ndr_pull_ptr(ndr, &_ptr_$e->{NAME});\n"; pidl "\tif (_ptr_$e->{NAME}) {\n"; } elsif ($inout eq "out" && util::has_property($e, "ref")) { pidl "\tif (r->$inout.$e->{NAME}) {\n"; @@ -666,6 +664,7 @@ sub ParseFunctionPull($) pidl $static . "int $fn->{NAME}_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n"; pidl "{\n"; + pidl "\tstruct e_ndr_pull *ndr = e_ndr_pull_init(tvb, offset, pinfo, tree, drep);\n"; # declare any internal pointers we need foreach my $e (@{$fn->{DATA}}) { @@ -681,6 +680,8 @@ sub ParseFunctionPull($) } } + pidl "\toffset = ndr->offset;\n"; + pidl "\te_ndr_pull_free(ndr)\n"; pidl "\treturn offset;\n"; pidl "}\n\n"; @@ -688,6 +689,7 @@ sub ParseFunctionPull($) pidl $static . "int $fn->{NAME}_resp(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)\n"; pidl "{\n"; + pidl "\tstruct e_ndr_pull *ndr = e_ndr_pull_init(tvb, offset, pinfo, tree, drep);\n"; # declare any internal pointers we need foreach my $e (@{$fn->{DATA}}) { @@ -704,9 +706,11 @@ sub ParseFunctionPull($) } if ($fn->{RETURN_TYPE} && $fn->{RETURN_TYPE} ne "void") { - pidl "\tndr_pull_$fn->{RETURN_TYPE}(ndr, &r->out.result);\n"; + pidl "\te_ndr_pull_$fn->{RETURN_TYPE}(ndr, hf_rc);\n"; } + pidl "\toffset = ndr->offset;\n"; + pidl "\te_ndr_pull_free(ndr)\n"; pidl "\treturn offset;\n"; pidl "}\n\n"; } |