r25000: Fix some more C++ compatibility warnings.
[gd/samba-autobuild/.git] / source4 / torture / raw / streams.c
index 4a77dbfc769a121fdf084483db63266051edad4a..c51c6ea2dfb221d6b6791c04f2b43f3366b228db 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
+#include "torture/torture.h"
 #include "libcli/raw/libcliraw.h"
-#include "librpc/gen_ndr/ndr_security.h"
 #include "system/filesys.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
 
 #define BASEDIR "\\teststreams"
 
@@ -72,12 +73,12 @@ static BOOL check_stream(struct smbcli_state *cli, TALLOC_CTX *mem_ctx,
                return False;
        }
 
-       buf = talloc_size(mem_ctx, strlen(value)+11);
+       buf = talloc_array(mem_ctx, uint8_t, strlen(value)+11);
        
        ret = smbcli_read(cli->tree, fnum, buf, 0, strlen(value)+11);
        if (ret != strlen(value)) {
-               printf("Failed to read %d bytes from stream '%s' - got %d\n",
-                      strlen(value), full_name, (int)ret);
+               printf("Failed to read %lu bytes from stream '%s' - got %d\n",
+                      (long)strlen(value), full_name, (int)ret);
                return False;
        }
 
@@ -127,7 +128,7 @@ static BOOL test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.ntcreatex.in.fname = sname1;
        status = smb_raw_open(cli->tree, mem_ctx, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
-       fnum = io.ntcreatex.out.fnum;
+       fnum = io.ntcreatex.out.file.fnum;
 
        ret &= check_stream(cli, mem_ctx, fname, "Stream One", NULL);
 
@@ -136,7 +137,7 @@ static BOOL test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.ntcreatex.in.fname = fname;
        status = smb_raw_open(cli->tree, mem_ctx, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
-       smbcli_close(cli->tree, io.ntcreatex.out.fnum);
+       smbcli_close(cli->tree, io.ntcreatex.out.file.fnum);
 
        printf("writing to stream\n");
        retsize = smbcli_write(cli->tree, fnum, 0, "test data", 0, 9);
@@ -150,7 +151,7 @@ static BOOL test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.ntcreatex.in.fname = sname1;
        status = smb_raw_open(cli->tree, mem_ctx, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
-       fnum = io.ntcreatex.out.fnum;
+       fnum = io.ntcreatex.out.file.fnum;
 
        printf("modifying stream\n");
        retsize = smbcli_write(cli->tree, fnum, 0, "MORE DATA ", 5, 10);
@@ -165,7 +166,7 @@ static BOOL test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
        status = smb_raw_open(cli->tree, mem_ctx, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
-       fnum = io.ntcreatex.out.fnum;
+       fnum = io.ntcreatex.out.file.fnum;
 
        printf("modifying stream\n");
        retsize = smbcli_write(cli->tree, fnum, 0, "SECOND STREAM", 0, 13);
@@ -193,7 +194,7 @@ static BOOL test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
        io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
        status = smb_raw_open(cli->tree, mem_ctx, &io);
        CHECK_STATUS(status, NT_STATUS_OK);
-       fnum = io.ntcreatex.out.fnum;
+       fnum = io.ntcreatex.out.file.fnum;
        
        smbcli_close(cli->tree, fnum);
        status = smbcli_unlink(cli->tree, sname2);
@@ -212,28 +213,19 @@ done:
 /* 
    basic testing of streams calls
 */
-BOOL torture_raw_streams(void)
+bool torture_raw_streams(struct torture_context *torture, 
+                                                struct smbcli_state *cli)
 {
-       struct smbcli_state *cli;
        BOOL ret = True;
-       TALLOC_CTX *mem_ctx;
-
-       if (!torture_open_connection(&cli)) {
-               return False;
-       }
-
-       mem_ctx = talloc_init("torture_raw_streams");
 
        if (!torture_setup_dir(cli, BASEDIR)) {
                return False;
        }
 
-       ret &= test_stream_io(cli, mem_ctx);
+       ret &= test_stream_io(cli, torture);
 
        smb_raw_exit(cli->session);
        smbcli_deltree(cli->tree, BASEDIR);
 
-       torture_close_connection(cli);
-       talloc_free(mem_ctx);
        return ret;
 }