Remove include/local.h and move defines to more appropriate places.
[kai/samba.git] / source4 / client / client.c
index 01197e8a9ee8cc2abffaf9ade19a01c00ed5eb18..56b923974b9f0fc09e091ce2f3ebdd5ef2405a71 100644 (file)
@@ -41,7 +41,7 @@
 #include "libcli/util/clilsa.h"
 #include "system/dir.h"
 #include "system/filesys.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
 #include "system/readline.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
 #include "param/param.h"
 #include "librpc/rpc/dcerpc.h"
 
+/* the default pager to use for the client "more" command. Users can
+ *    override this with the PAGER environment variable */
+#ifndef DEFAULT_PAGER
+#define DEFAULT_PAGER "more"
+#endif
+
 struct smbclient_context {
        char *remote_cur_dir;
        struct smbcli_state *cli;
@@ -934,7 +940,7 @@ static int cmd_more(struct smbclient_context *ctx, const char **args)
 
        pager=getenv("PAGER");
 
-       pager_cmd = talloc_asprintf(ctx, "%s %s",(pager? pager:PAGER), lname);
+       pager_cmd = talloc_asprintf(ctx, "%s %s",(pager? pager:DEFAULT_PAGER), lname);
        system(pager_cmd);
        unlink(lname);
        
@@ -2754,7 +2760,7 @@ process a -c command string
 ****************************************************************************/
 static int process_command_string(struct smbclient_context *ctx, const char *cmd)
 {
-       const char **lines;
+       char **lines;
        int i, rc = 0;
 
        lines = str_list_make(NULL, cmd, ";");
@@ -3032,7 +3038,9 @@ static bool do_connect(struct smbclient_context *ctx,
                       const char *specified_server, const char **ports, 
                       const char *specified_share, 
                       struct cli_credentials *cred, 
-                      struct smbcli_options *options)
+                      struct smbcli_options *options,
+                      struct smbcli_session_options *session_options,
+                          struct smb_iconv_convenience *iconv_convenience)
 {
        NTSTATUS status;
        char *server, *share;
@@ -3051,7 +3059,8 @@ static bool do_connect(struct smbclient_context *ctx,
        
        status = smbcli_full_connection(ctx, &ctx->cli, server, ports,
                                        share, NULL, cred, resolve_ctx, 
-                                       ev_ctx, options);
+                                       ev_ctx, options, session_options,
+                                       iconv_convenience);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Connection to \\\\%s\\%s failed - %s\n", 
                         server, share, nt_errstr(status));
@@ -3084,7 +3093,8 @@ static int do_message_op(const char *netbios_name, const char *desthost,
                         int name_type,
                         struct event_context *ev_ctx,
                         struct resolve_context *resolve_ctx,
-                        struct smbcli_options *options)
+                        struct smbcli_options *options,
+                        struct smb_iconv_convenience *iconv_convenience)
 {
        struct nbt_name called, calling;
        const char *server_name;
@@ -3098,7 +3108,8 @@ static int do_message_op(const char *netbios_name, const char *desthost,
 
        if (!(cli = smbcli_state_init(NULL)) ||
            !smbcli_socket_connect(cli, server_name, destports,
-                                  ev_ctx, resolve_ctx, options)) {
+                                  ev_ctx, resolve_ctx, options,
+                                  iconv_convenience)) {
                d_printf("Connection to %s failed\n", server_name);
                return 1;
        }
@@ -3138,6 +3149,7 @@ static int do_message_op(const char *netbios_name, const char *desthost,
        struct smbclient_context *ctx;
        const char *cmdstr = NULL;
        struct smbcli_options smb_options;
+       struct smbcli_session_options smb_session_options;
 
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -3227,8 +3239,9 @@ static int do_message_op(const char *netbios_name, const char *desthost,
        poptFreeContext(pc);
 
        lp_smbcli_options(cmdline_lp_ctx, &smb_options);
+       lp_smbcli_session_options(cmdline_lp_ctx, &smb_session_options);
 
-       ev_ctx = event_context_init(talloc_autofree_context());
+       ev_ctx = s4_event_context_init(talloc_autofree_context());
 
        DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
 
@@ -3249,13 +3262,14 @@ static int do_message_op(const char *netbios_name, const char *desthost,
                                   lp_smb_ports(cmdline_lp_ctx), dest_ip,
                                   name_type, ev_ctx,
                                   lp_resolve_context(cmdline_lp_ctx),
-                                  &smb_options);
+                                  &smb_options, lp_iconv_convenience(cmdline_lp_ctx));
                return rc;
        }
        
        if (!do_connect(ctx, ev_ctx, lp_resolve_context(cmdline_lp_ctx),
                        desthost, lp_smb_ports(cmdline_lp_ctx), service,
-                       cmdline_credentials, &smb_options))
+                       cmdline_credentials, &smb_options, &smb_session_options,
+                       lp_iconv_convenience(cmdline_lp_ctx)))
                return 1;
 
        if (base_directory)