pidl Add support for uid_t and gid_t types
authorAndrew Bartlett <abartlet@samba.org>
Fri, 11 Feb 2011 07:45:32 +0000 (18:45 +1100)
committerStefan Metzmacher <metze@samba.org>
Tue, 22 Feb 2011 18:32:53 +0000 (19:32 +0100)
These are mapped to int64_t, which should be big enough.  This is
proposed to be used for internal Samba representations, where it would
be more painful to convert all the callers to an int64_t calling
convention.

Andrew Bartlett

librpc/ndr/ndr_basic.c
pidl/lib/Parse/Pidl/NDR.pm
pidl/lib/Parse/Pidl/Samba4/Python.pm
pidl/lib/Parse/Pidl/Typelist.pm

index 1d67e11e9d2dc43c70e58af4bd8d073a8f031901..60d9bc5626dfbb0140714ebe7ab85f706c889375 100644 (file)
@@ -809,6 +809,46 @@ _PUBLIC_ enum ndr_err_code ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags,
 }
 
 
+/*
+  push a uid_t
+*/
+_PUBLIC_ enum ndr_err_code ndr_push_uid_t(struct ndr_push *ndr, int ndr_flags, uid_t t)
+{
+       return ndr_push_int64(ndr, ndr_flags, t);
+}
+
+/*
+  pull a uid_t
+*/
+_PUBLIC_ enum ndr_err_code ndr_pull_uid_t(struct ndr_pull *ndr, int ndr_flags, uid_t *t)
+{
+       int64_t tt;
+       NDR_CHECK(ndr_pull_int64(ndr, ndr_flags, &tt));
+       *t = tt;
+       return NDR_ERR_SUCCESS;
+}
+
+
+/*
+  push a gid_t
+*/
+_PUBLIC_ enum ndr_err_code ndr_push_gid_t(struct ndr_push *ndr, int ndr_flags, gid_t t)
+{
+       return ndr_push_int64(ndr, ndr_flags, t);
+}
+
+/*
+  pull a gid_t
+*/
+_PUBLIC_ enum ndr_err_code ndr_pull_gid_t(struct ndr_pull *ndr, int ndr_flags, gid_t *t)
+{
+       int64_t tt;
+       NDR_CHECK(ndr_pull_int64(ndr, ndr_flags, &tt));
+       *t = tt;
+       return NDR_ERR_SUCCESS;
+}
+
+
 /*
   pull a ipv4address
 */
index 3edb9b732f26454f922aeed3cde915051153b330..5ade5c175a1c83e35e8cb68f24b156a55db15165 100644 (file)
@@ -66,6 +66,8 @@ my $scalar_alignment = {
        'string' => 4,
        'string_array' => 4, #???
        'time_t' => 4,
+       'uid_t' => 8,
+       'gid_t' => 8,
        'NTTIME' => 4,
        'NTTIME_1sec' => 4,
        'NTTIME_hyper' => 8,
index 7f6f94e748148c70211687a82aead52faf72862b..dfacfb335256db7f5eed87977856eef24b008555 100644 (file)
@@ -895,7 +895,7 @@ sub ConvertObjectFromPythonData($$$$$$;$)
                        $self->pidl("}");
                        return;
                }
-               if (expandAlias($actual_ctype->{NAME}) =~ /^(char|u?int[0-9]*|time_t)$/) {
+               if (expandAlias($actual_ctype->{NAME}) =~ /^(char|u?int[0-9]*|time_t|uid_t|gid_t)$/) {
                        $self->pidl("PY_CHECK_TYPE(&PyInt_Type, $cvar, $fail);");
                        $self->pidl("$target = PyInt_AsLong($cvar);");
                        return;
@@ -1103,7 +1103,7 @@ sub ConvertScalarToPython($$$)
                return "PyLong_FromLongLong($cvar)";
        }
 
-       if ($ctypename =~ /^(char|u?int[0-9]*|time_t)$/) {
+       if ($ctypename =~ /^(char|u?int[0-9]*|time_t|uid_t|gid_t)$/) {
                return "PyInt_FromLong($cvar)";
        }
 
index a89b1a74eb495c66bb26daa517ed2d2544cd471c..307187b4f4ca77c2ab626241869d637ac171a7e5 100644 (file)
@@ -48,6 +48,8 @@ my %scalars = (
        "string"        => "const char *",
        "string_array"  => "const char **",
        "time_t"        => "time_t",
+       "uid_t"         => "uid_t",
+       "gid_t"         => "gid_t",
        "NTTIME"        => "NTTIME",
        "NTTIME_1sec"   => "NTTIME",
        "NTTIME_hyper"  => "NTTIME",