* support multiple interfaces in one IDL file in pidl
authorAndrew Tridgell <tridge@samba.org>
Fri, 28 Nov 2003 03:47:45 +0000 (03:47 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 28 Nov 2003 03:47:45 +0000 (03:47 +0000)
 * make far more generated functions static

 * get rid of gen_rpc, and include the client calls in ndr_*.c

 * added placeholder IDL for a number of intefaces (dcom, wzcsvc, browser etc)

source/Makefile.in
source/build/pidl/client.pm
source/build/pidl/idl.gram
source/build/pidl/parser.pm
source/build/pidl/pidl.pl
source/librpc/idl/atsvc.idl
source/librpc/idl/dcerpc.idl
source/script/build_idl.sh
source/torture/rpc/scanner.c

index d9124e80c34bb6c182235787068ea41becb8b254..a1f9fb158ffb78e4cf71be8b834b8ec51387cd80 100644 (file)
@@ -197,17 +197,13 @@ LIBRAW_NDR_OBJ = librpc/ndr/ndr.o librpc/ndr/ndr_basic.o librpc/ndr/ndr_sec.o \
                librpc/gen_ndr/ndr_wkssvc.o librpc/gen_ndr/ndr_srvsvc.o \
                librpc/gen_ndr/ndr_atsvc.o librpc/gen_ndr/ndr_eventlog.o \
                librpc/gen_ndr/ndr_epmapper.o librpc/gen_ndr/ndr_winreg.o \
-               librpc/gen_ndr/ndr_mgmt.o
+               librpc/gen_ndr/ndr_mgmt.o librpc/gen_ndr/ndr_protected_storage.o \
+               librpc/gen_ndr/ndr_dcom.o librpc/gen_ndr/ndr_wzcsvc.o \
+               librpc/gen_ndr/ndr_browser.o
 
 LIBRAW_RPC_OBJ = librpc/rpc/dcerpc.o librpc/rpc/dcerpc_auth.o \
                librpc/rpc/dcerpc_util.o \
-               librpc/rpc/dcerpc_smb.o librpc/rpc/dcerpc_tcp.o \
-               librpc/gen_rpc/rpc_echo.o librpc/gen_rpc/rpc_lsa.o \
-               librpc/gen_rpc/rpc_dfs.o librpc/gen_rpc/rpc_spoolss.o \
-               librpc/gen_rpc/rpc_samr.o librpc/gen_rpc/rpc_wkssvc.o \
-               librpc/gen_rpc/rpc_srvsvc.o librpc/gen_rpc/rpc_atsvc.o \
-               librpc/gen_rpc/rpc_eventlog.o librpc/gen_rpc/rpc_epmapper.o \
-               librpc/gen_rpc/rpc_winreg.o librpc/gen_rpc/rpc_mgmt.o
+               librpc/rpc/dcerpc_smb.o librpc/rpc/dcerpc_tcp.o
 
 LIBRAW_OBJ = libcli/raw/rawfile.o libcli/raw/smb_signing.o  \
             libcli/raw/clisocket.o libcli/raw/clitransport.o \
index b0c78d7b3aef371b06a0e75823465e756248cf8b..495fe3dd7c94ba18142646138f9e5248bfa1d394 100644 (file)
@@ -67,7 +67,6 @@ sub Parse($)
 {
        my($idl) = shift;
        $res = "/* dcerpc client calls generated by pidl */\n\n";
-       $res .= "#include \"includes.h\"\n\n";
        foreach my $x (@{$idl}) {
                ($x->{TYPE} eq "INTERFACE") && 
                    ParseInterface($x);
index 897a5ad769cb86cf505980a2c945b9d8bdde3512..b354b9772a84089188876d3dbbcf51aa1c0f3904 100644 (file)
@@ -2,7 +2,11 @@
        use util;
 }
 
-idl: cpp_prefix(s?) module_header interface 
+idl: idl_interface(s?)
+     {{ util::FlattenArray($item[1]) }}
+  | <error>
+
+idl_interface: module_header interface
    { [$item{module_header}, $item{interface}] }
    | <error>
 
@@ -25,8 +29,7 @@ interface: 'interface' <commit> identifier '{' definition(s?) '}'
           }}
           | <error?>
 
-definition : cpp_prefix
-             | typedef { $item[1] }
+definition : typedef { $item[1] }
              | function { $item[1] }
              | const { $item[1] }
 
@@ -148,11 +151,12 @@ identifier: /[\w?]+/
 
 expression: /[\w.?\/+*-_]+/
 
-function : type identifier '(' <commit> element_list2 ');' 
+function : property_list(s?) type identifier '(' <commit> element_list2 ');' 
         {{
                "TYPE" => "FUNCTION",
                "NAME" => $item{identifier},
                "RETURN_TYPE" => $item{type},
+               "PROPERTIES" => util::FlattenArray($item[1]),
                "DATA" => $item{element_list2}
         }}
          | <error?>
@@ -177,4 +181,3 @@ anytext: text2 '(' <commit> anytext ')' anytext
 constant: /-?[\dx]+/
          | '*'
 
-cpp_prefix: '#' /.*/
index 5c80812ec10749e16b3035c665dab9347f7301b6..a10058a160523cdc162e49b96345a98b2318c2e3 100644 (file)
@@ -8,6 +8,7 @@ package IdlParser;
 
 use strict;
 use Data::Dumper;
+use client;
 
 # the list of needed functions
 my %needed;
@@ -15,7 +16,7 @@ my %structs;
 
 sub pidl($)
 {
-       print IDL shift;
+       print OUT shift;
 }
 
 #####################################################################
@@ -111,11 +112,19 @@ sub find_size_var($$$)
 # work out is a parse function should be declared static or not
 sub fn_prefix($)
 {
-       my $e = shift;
-       if (util::has_property($e, "public")) {
-               return "static ";
+       my $fn = shift;
+       if ($fn->{TYPE} eq "TYPEDEF") {
+               if (util::has_property($fn->{DATA}, "public")) {
+                       return "";
+               }
        }
-       return "";
+
+       if ($fn->{TYPE} eq "FUNCTION") {
+               if (util::has_property($fn, "public")) {
+                       return "";
+               }
+       }
+       return "static ";
 }
 
 
@@ -997,7 +1006,7 @@ sub ParseTypedefPush($)
        }
 
        if ($e->{DATA}->{TYPE} eq "STRUCT") {
-               pidl "$static" . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, struct $e->{NAME} *r)";
+               pidl $static . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, struct $e->{NAME} *r)";
                pidl "\n{\n";
                ParseTypePush($e->{DATA});
                pidl "\treturn NT_STATUS_OK;\n";
@@ -1005,7 +1014,7 @@ sub ParseTypedefPush($)
        }
 
        if ($e->{DATA}->{TYPE} eq "UNION") {
-               pidl "$static" . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, uint16 level, union $e->{NAME} *r)";
+               pidl $static . "NTSTATUS ndr_push_$e->{NAME}(struct ndr_push *ndr, int ndr_flags, uint16 level, union $e->{NAME} *r)";
                pidl "\n{\n";
                ParseTypePush($e->{DATA});
                pidl "\treturn NT_STATUS_OK;\n";
@@ -1027,7 +1036,7 @@ sub ParseTypedefPull($)
        }
 
        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 . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, struct $e->{NAME} *r)";
                pidl "\n{\n";
                ParseTypePull($e->{DATA});
                pidl "\treturn NT_STATUS_OK;\n";
@@ -1035,7 +1044,7 @@ sub ParseTypedefPull($)
        }
 
        if ($e->{DATA}->{TYPE} eq "UNION") {
-               pidl "$static" . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, uint16 level, union $e->{NAME} *r)";
+               pidl $static . "NTSTATUS ndr_pull_$e->{NAME}(struct ndr_pull *ndr, int ndr_flags, uint16 level, union $e->{NAME} *r)";
                pidl "\n{\n";
                ParseTypePull($e->{DATA});
                pidl "\treturn NT_STATUS_OK;\n";
@@ -1139,8 +1148,9 @@ sub ParseFunctionElementPush($$)
 sub ParseFunctionPush($)
 { 
        my($fn) = shift;
+       my $static = fn_prefix($fn);
 
-       pidl "NTSTATUS ndr_push_$fn->{NAME}(struct ndr_push *ndr, int flags, struct $fn->{NAME} *r)\n{\n";
+       pidl $static . "NTSTATUS ndr_push_$fn->{NAME}(struct ndr_push *ndr, int flags, struct $fn->{NAME} *r)\n{\n";
 
        pidl "\n\tif (!(flags & NDR_IN)) goto ndr_out;\n\n";
        foreach my $e (@{$fn->{DATA}}) {
@@ -1205,9 +1215,10 @@ sub ParseFunctionElementPull($$)
 sub ParseFunctionPull($)
 { 
        my($fn) = shift;
+       my $static = fn_prefix($fn);
 
        # pull function args
-       pidl "NTSTATUS ndr_pull_$fn->{NAME}(struct ndr_pull *ndr, int flags, struct $fn->{NAME} *r)\n{\n";
+       pidl $static . "NTSTATUS ndr_pull_$fn->{NAME}(struct ndr_pull *ndr, int flags, struct $fn->{NAME} *r)\n{\n";
 
        # declare any internal pointers we need
        foreach my $e (@{$fn->{DATA}}) {
@@ -1384,7 +1395,7 @@ sub Parse($$)
        my($idl) = shift;
        my($filename) = shift;
 
-       open(IDL, ">$filename") || die "can't open $filename";    
+       open(OUT, ">$filename") || die "can't open $filename";    
 
        pidl "/* parser auto-generated by pidl */\n\n";
        pidl "#include \"includes.h\"\n\n";
@@ -1394,7 +1405,10 @@ sub Parse($$)
                        ParseInterface($x);
                }
        }
-       close(IDL);
+
+       pidl IdlClient::Parse($idl);
+
+       close(OUT);
 }
 
 1;
index edeab1564ed3363bd62a2c60919d46f68332849d..77b80d8bfd541f298d494f49627422053b813a2b 100755 (executable)
@@ -18,7 +18,6 @@ use dump;
 use header;
 use parser;
 use eparser;
-use client;
 use validator;
 use util;
 
@@ -29,7 +28,6 @@ my($opt_diff) = 0;
 my($opt_header) = 0;
 my($opt_parser) = 0;
 my($opt_eparser) = 0;
-my($opt_client);
 my($opt_keep) = 0;
 my($opt_output);
 
@@ -73,7 +71,6 @@ sub ShowHelp()
              --header              create a C header file
              --parser              create a C parser
              --eparser             create an ethereal parser
-             --client FILENAME     create client calls in FILENAME
              --diff                run diff on the idl and dumped output
              --keep                keep the .pidl file
            \n";
@@ -89,7 +86,6 @@ GetOptions (
            'header' => \$opt_header,
            'parser' => \$opt_parser,
            'eparser' => \$opt_eparser,
-           'client=s' => \$opt_client,
            'diff' => \$opt_diff,
            'keep' => \$opt_keep
            );
@@ -149,14 +145,6 @@ sub process_file($)
                util::FileSave($parser, IdlEParser::Parse($idl));
        }
        
-       if ($opt_client) {
-               my($idl) = util::LoadStructure($pidl_file);
-               my($client) = $opt_client . $basename;
-               $client = util::ChangeExtension($client, "c");
-               print "Generating $client client calls\n";
-               util::FileSave($client, IdlClient::Parse($idl));
-       }
-       
        if ($opt_diff) {
                my($idl) = util::LoadStructure($pidl_file);
                my($tempfile) = util::ChangeExtension($output, "tmp");
index 39add81b09a6568de87ee56a216239c6eab7bccb..e221875f9fb6f6d0f56bd5a8a7786981bf026731 100644 (file)
@@ -59,7 +59,7 @@
 
        /******************/
        /* Function: 0x03 */
-       NTSTATUS atsvc_JobGetInfo(
+       [public] NTSTATUS atsvc_JobGetInfo(
                [in]    unistr *servername,
                [in]    uint32 job_id,
                [out]   atsvc_JobInfo *job_info
index b00396e787663958dcc09e7ba49d91187e4f4161..32850b90cf84e6435815d90d5f1f963ced0ecebd 100644 (file)
@@ -11,7 +11,7 @@
 [] 
 interface dcerpc
 {
-       typedef struct {
+       typedef [public] struct {
                GUID uuid;
                uint16 major_version;
                uint16 minor_version;
index b31d26c23d15834ffdffefd337f6c6b22881d864..8c04db6f3705f5e8898f059ce726e2bdf38e4306 100755 (executable)
@@ -3,11 +3,10 @@
 FULLBUILD=$1
 
 [ -d librpc/gen_ndr ] || mkdir -p librpc/gen_ndr || exit 1
-[ -d librpc/gen_rpc ] || mkdir -p librpc/gen_rpc || exit 1
 
 ( cd build/pidl && make ) || exit 1
 
-PIDL="build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser --client librpc/gen_rpc/rpc_"
+PIDL="build/pidl/pidl.pl --output librpc/gen_ndr/ndr_ --parse --header --parser"
 TABLES="build/pidl/tables.pl --output librpc/gen_ndr/tables"
 
 if [ x$FULLBUILD = xFULL ]; then
@@ -15,7 +14,7 @@ if [ x$FULLBUILD = xFULL ]; then
       $PIDL librpc/idl/*.idl || exit 1
 
       echo Rebuilding IDL tables
-      $TABLES librpc/gen_ndr/ndr_*.h
+      $TABLES librpc/gen_ndr/ndr_*.h || exit 1
       exit 0
 fi
 
@@ -30,6 +29,7 @@ done
 
 if [ "x$list" != x ]; then
     $PIDL $list || exit 1
+    $TABLES librpc/gen_ndr/ndr_*.h || exit 1
 fi
 
 exit 0
index 9c94515ea3193180a3ff4a09e7098553cee18ef0..3469294552efea9e354d33bea24e39d20a7e436e 100644 (file)
@@ -47,27 +47,32 @@ static BOOL test_num_calls(const struct dcerpc_interface_table *iface,
        }
 
        /* make null calls */
-       stub_in = data_blob(NULL, 0);
-
-       status = dcerpc_request(p, 10000, mem_ctx, &stub_in, &stub_out);
-       if (NT_STATUS_IS_OK(status) ||
-           p->last_fault_code != DCERPC_FAULT_OP_RNG_ERROR) {
-               printf("\tunable to determine call count - %s %08x\n",
-                      nt_errstr(status), p->last_fault_code);
-               goto done;
-       }
+       stub_in = data_blob(NULL, 1000);
+       memset(stub_in.data, 0xFF, stub_in.length);
 
-       for (i=128;i>=0;i--) {
+       for (i=0;i<200;i++) {
                status = dcerpc_request(p, i, mem_ctx, &stub_in, &stub_out);
-               if (NT_STATUS_IS_OK(status) ||
-                   p->last_fault_code != DCERPC_FAULT_OP_RNG_ERROR) break;
+               if (!NT_STATUS_IS_OK(status) &&
+                   p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) {
+                       break;
+               }
+
+               if (!NT_STATUS_IS_OK(status) && p->last_fault_code == 5) {
+                       printf("\tpipe disconnected at %d\n", i);
+                       goto done;
+               }
+
+               if (!NT_STATUS_IS_OK(status) && p->last_fault_code == 0x80010111) {
+                       printf("\terr 0x80010111 at %d\n", i);
+                       goto done;
+               }
        }
 
-       printf("\t%d calls available\n", i+1);
+       printf("\t%d calls available\n", i);
        idl_calls = idl_num_calls(uuid, id->major_version);
        if (idl_calls == -1) {
                printf("\tinterface not known in local IDL\n");
-       } else if (i+1 != idl_calls) {
+       } else if (i != idl_calls) {
                printf("\tWARNING: local IDL defines %u calls\n", idl_calls);
        } else {
                printf("\tOK: matches num_calls in local IDL\n");