summaryrefslogtreecommitdiff
path: root/source4/pidl
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-10-04 18:24:21 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:39:24 -0500
commiteea74cde05c1532d59b9f8ecc4f88c191a4b200f (patch)
treeaf6b5c488c5cc3c3b4b806d67a8b7a3ea3728736 /source4/pidl
parent81c306472a9c6bf6238e916e49076525d4920ed8 (diff)
downloadsamba-eea74cde05c1532d59b9f8ecc4f88c191a4b200f.tar.gz
samba-eea74cde05c1532d59b9f8ecc4f88c191a4b200f.tar.bz2
samba-eea74cde05c1532d59b9f8ecc4f88c191a4b200f.zip
r10716: Use correct Samba3 data types for strings. Also use Samba3 types
for a couple of other types (policy handles, SIDs, times) (This used to be commit c2527217b4b4c120d82044e65b979dd3b7d2609e)
Diffstat (limited to 'source4/pidl')
-rw-r--r--source4/pidl/lib/Parse/Pidl/Samba3/Types.pm87
1 files changed, 65 insertions, 22 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm b/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
index b9d969216c..f93e90fe1f 100644
--- a/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
+++ b/source4/pidl/lib/Parse/Pidl/Samba3/Types.pm
@@ -10,7 +10,7 @@ require Exporter;
@EXPORT_OK = qw(DeclShort DeclLong InitType DissectType AddType);
use strict;
-use Parse::Pidl::Util qw(has_property ParseExpr);
+use Parse::Pidl::Util qw(has_property ParseExpr property_matches);
use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred);
use vars qw($VERSION);
@@ -40,37 +40,44 @@ sub decl_string($)
{
my $e = shift;
- # FIXME: More intelligent code here - select between UNISTR2 and other
- # variants
- return "UNISTR2";
-}
+ my $is_conformant = property_matches($e, "flag", ".*STR_SIZE4.*");
+ my $is_varying = property_matches($e, "flag", ".*STR_LEN4.*");
+ my $is_ascii = property_matches($e, "flag", ".*STR_ASCII.*");
-sub init_string($$$$)
-{
- my ($e,$l,$n,$v) = @_;
-
- return "init_unistr2(&$n, $v, UNI_FLAGS_NONE);";
-}
+ return "STRING2" if ($is_conformant and $is_varying and $is_ascii);
-sub dissect_string($$$)
-{
- my ($e,$l,$n) = @_;
+ return "UNISTR2" if ($is_conformant and $is_varying);
+ return "UNISTR3" if ($is_varying);
+ # We don't do UNISTR4, as we have lsa_String for that in Samba4's IDL
- return "prs_unistr2(True, \"$e->{NAME}\", ps, depth, &n)";
+ die("Don't know what string type to use");
}
-sub init_uuid($$$$)
+sub init_string($$$$)
{
my ($e,$l,$n,$v) = @_;
- return "";
+ my $t = lc(decl_string($e));
+
+ my $flags;
+ if (property_matches($e, "flag", ".*STR_NULLTERM.*")) {
+ $flags = "UNI_STR_TERMINATE";
+ } elsif (property_matches($e, "flag", ".*STR_NOTERM.*")) {
+ $flags = "UNI_STR_NOTERM";
+ } else {
+ $flags = "UNI_FLAGS_NONE";
+ }
+
+ return "init_$t(&$n, $v, $flags);";
}
-sub dissect_uuid($$$)
+sub dissect_string($$$)
{
my ($e,$l,$n) = @_;
- return "smb_io_uuid(\"$e->{NAME}\", &$n, ps, depth)";
+ my $t = lc(decl_string($e));
+
+ return "prs_$t(True, \"$e->{NAME}\", ps, depth, &n)";
}
my $known_types =
@@ -93,6 +100,12 @@ my $known_types =
INIT => \&init_scalar,
DISSECT => \&dissect_scalar,
},
+ uint64 =>
+ {
+ DECL => "uint64",
+ INIT => \&init_scalar,
+ DISSECT => \&dissect_scalar,
+ },
string =>
{
DECL => \&decl_string,
@@ -114,9 +127,39 @@ my $known_types =
GUID =>
{
DECL => "struct uuid",
- INIT => \&init_uuid,
- DISSECT => \&dissect_uuid,
- }
+ INIT => "",
+ DISSECT => sub {
+ my ($e,$l,$n) = @_;
+ return "smb_io_uuid(\"$e->{NAME}\", &$n, ps, depth)";
+ }
+ },
+ NTTIME =>
+ {
+ DECL => "NTTIME",
+ INIT => "",
+ DISSECT => sub {
+ my ($e,$l,$n) = @_;
+ return "smb_io_nttime(\"$e->{NAME}\", &n, ps, depth)";
+ }
+ },
+ dom_sid =>
+ {
+ DECL => "DOM_SID",
+ INIT => "",
+ DISSECT => sub {
+ my ($e,$l,$n) = @_;
+ return "smb_io_dom_sid(\"$e->{NAME}\", &n, ps, depth)";
+ }
+ },
+ policy_handle =>
+ {
+ DECL => "POLICY_HND",
+ INIT => "",
+ DISSECT => sub {
+ my ($e,$l,$n) = @_;
+ return "smb_io_pol_hnd(\"$e->{NAME}\", &n, ps, depth)";
+ }
+ },
};
sub AddType($$)