r26238: Add a loadparm context parameter to torture_context, remove more uses of...
[gd/samba-autobuild/.git] / source4 / torture / smb2 / util.c
index da74e47c0ad15453ea4b5aca761d816ee854c28d..ab3d299c5abd1c4d9381c236a64d40feceb598b3 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,
@@ -16,8 +16,7 @@
    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 "lib/events/events.h"
 #include "system/time.h"
 #include "librpc/gen_ndr/ndr_security.h"
+#include "param/param.h"
+
+#include "torture/torture.h"
+#include "torture/smb2/proto.h"
 
 
 /*
@@ -91,7 +94,7 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree,
   create a complex file/dir using the SMB2 protocol
 */
 static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, 
-                                        struct smb2_handle *handle, BOOL dir)
+                                        struct smb2_handle *handle, bool dir)
 {
        TALLOC_CTX *tmp_ctx = talloc_new(tree);
        char buf[7] = "abc";
@@ -175,9 +178,9 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
                printf("(%s) " #field " not setup correctly: %s(%llu) => %s(%llu)\n", \
                        __location__, \
                        nt_time_string(tree, setfile.basic_info.in.field), \
-                       setfile.basic_info.in.field, \
+                       (unsigned long long)setfile.basic_info.in.field, \
                        nt_time_string(tree, fileinfo.basic_info.out.field), \
-                       fileinfo.basic_info.out.field); \
+                       (unsigned long long)fileinfo.basic_info.out.field); \
                status = NT_STATUS_INVALID_PARAMETER; \
        } \
 } while (0)
@@ -196,7 +199,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname,
 NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, 
                                         struct smb2_handle *handle)
 {
-       return smb2_create_complex(tree, fname, handle, False);
+       return smb2_create_complex(tree, fname, handle, false);
 }
 
 /*
@@ -205,7 +208,7 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname,
 NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname, 
                                 struct smb2_handle *handle)
 {
-       return smb2_create_complex(tree, fname, handle, True);
+       return smb2_create_complex(tree, fname, handle, true);
 }
 
 /*
@@ -299,21 +302,21 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle)
 /*
   open a smb2 connection
 */
-BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree)
+bool torture_smb2_connection(struct torture_context *tctx, struct smb2_tree **tree)
 {
        NTSTATUS status;
-       const char *host = lp_parm_string(-1, "torture", "host");
-       const char *share = lp_parm_string(-1, "torture", "share");
+       const char *host = torture_setting_string(tctx, "host", NULL);
+       const char *share = torture_setting_string(tctx, "share", NULL);
        struct cli_credentials *credentials = cmdline_credentials;
 
-       status = smb2_connect(mem_ctx, host, share, credentials, tree, 
-                             event_context_find(mem_ctx));
+       status = smb2_connect(tctx, host, share, credentials, tree, 
+                             event_context_find(tctx));
        if (!NT_STATUS_IS_OK(status)) {
                printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n",
                       host, share, nt_errstr(status));
-               return False;
+               return false;
        }
-       return True;
+       return true;
 }