r26654: libcli/smb_composite: Rather than specifying each of the gazillion options...
[jelmer/samba4-debian.git] / source / scripting / ejs / smbcalls_cli.c
index e165222a984359b6701f2122044ed0dc012919c9..8295a0879fd462a60715a668e355a293fcb6f518 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"
@@ -27,6 +26,9 @@
 #include "libcli/composite/composite.h"
 #include "libcli/smb_composite/smb_composite.h"
 #include "libcli/libcli.h"
+#include "libcli/resolve/resolve.h"
+#include "auth/credentials/credentials.h"
+#include "param/param.h"
 
 #if 0
 
@@ -60,7 +62,7 @@ static int ejs_cli_connect(MprVarHandle eid, int argc, char **argv)
                return -1;
        }
 
-       transport = smbcli_transport_init(sock, sock, False);
+       transport = smbcli_transport_init(sock, sock, false);
 
        if (!transport) {
                ejsSetErrorMsg(eid, "transport init failed");
@@ -191,7 +193,7 @@ static int ejs_cli_ssetup(MprVarHandle eid, int argc, MprVar **argv)
 
        /* Do session setup */
 
-       session = smbcli_session_init(transport, transport, False);
+       session = smbcli_session_init(transport, transport, false);
 
        if (!session) {
                ejsSetErrorMsg(eid, "session init failed");
@@ -251,7 +253,7 @@ static int ejs_cli_tree_connect(MprVarHandle eid, int argc, MprVar **argv)
        }
 
        session = argv[0]->ptr;
-       tree = smbcli_tree_init(session, session, False);
+       tree = smbcli_tree_init(session, session, false);
 
        if (!tree) {
                ejsSetErrorMsg(eid, "tree init failed");
@@ -413,7 +415,7 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
        struct cli_credentials *creds;
        struct smb_composite_connect io;
        struct smbcli_tree *tree;
-       const char *hostname, *sharename;
+       char *hostname, *sharename;
        NTSTATUS result;
        TALLOC_CTX *mem_ctx;
 
@@ -430,21 +432,24 @@ static int ejs_tree_connect(MprVarHandle eid, int argc, char **argv)
        /* Set up credentials */
 
        creds = cli_credentials_init(NULL);
-       cli_credentials_set_conf(creds);
+       cli_credentials_set_conf(creds, global_loadparm);
        cli_credentials_parse_string(creds, argv[1], CRED_SPECIFIED);
 
        /* Do connect */
 
        io.in.dest_host              = hostname;
-       io.in.port                   = 0;
+       io.in.dest_ports             = lp_smb_ports(global_loadparm);
        io.in.called_name            = strupper_talloc(mem_ctx, hostname);
        io.in.service                = sharename;
        io.in.service_type           = "?????";
        io.in.credentials            = creds;
-       io.in.fallback_to_anonymous  = False;
-       io.in.workgroup              = lp_workgroup();
+       io.in.fallback_to_anonymous  = false;
+       io.in.workgroup              = lp_workgroup(global_loadparm);
+       lp_smbcli_options(global_loadparm, &io.in.options);
 
-       result = smb_composite_connect(&io, mem_ctx, NULL);
+       result = smb_composite_connect(&io, mem_ctx, 
+                                      lp_resolve_context(global_loadparm), 
+                                      NULL);
        tree = io.out.tree;
 
        talloc_free(mem_ctx);
@@ -483,7 +488,7 @@ static int ejs_tree_disconnect(MprVarHandle eid, int argc, MprVar **argv)
                return -1;
        }
 
-       tree = talloc_check_name(argv[0]->ptr, "struct smbcli_tree");
+       tree = talloc_get_type(argv[0]->ptr, struct smbcli_tree);
 
        result = smb_tree_disconnect(tree);
 
@@ -512,7 +517,7 @@ static int ejs_mkdir(MprVarHandle eid, int argc, MprVar **argv)
                return -1;
        }
 
-       tree = argv[0]->ptr;
+       tree = (struct smbcli_tree *)argv[0]->ptr;
 
        if (!mprVarIsString(argv[1]->type)) {
                ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -546,7 +551,7 @@ static int ejs_rmdir(MprVarHandle eid, int argc, MprVar **argv)
                return -1;
        }
 
-       tree = argv[0]->ptr;
+       tree = (struct smbcli_tree *)argv[0]->ptr;
 
        if (!mprVarIsString(argv[1]->type)) {
                ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -580,7 +585,7 @@ static int ejs_rename(MprVarHandle eid, int argc, MprVar **argv)
                return -1;
        }
 
-       tree = argv[0]->ptr;
+       tree = (struct smbcli_tree *)argv[0]->ptr;
 
        if (!mprVarIsString(argv[1]->type)) {
                ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -619,7 +624,7 @@ static int ejs_unlink(MprVarHandle eid, int argc, MprVar **argv)
                return -1;
        }
 
-       tree = argv[0]->ptr;
+       tree = (struct smbcli_tree *)argv[0]->ptr;
 
        if (!mprVarIsString(argv[1]->type)) {
                ejsSetErrorMsg(eid, "arg 2 must be a string");
@@ -666,7 +671,7 @@ static int ejs_list(MprVarHandle eid, int argc, MprVar **argv)
                return -1;
        }
 
-       tree = argv[0]->ptr;
+       tree = (struct smbcli_tree *)argv[0]->ptr;
 
        if (!mprVarIsString(argv[1]->type)) {
                ejsSetErrorMsg(eid, "arg 2 must be a string");