#include "includes.h"
#include "client/client_proto.h"
-#include "include/rpc_client.h"
+#include "../librpc/gen_ndr/cli_srvsvc.h"
+
#ifndef REGISTER
#define REGISTER 0
#endif
return client_get_cur_dir();
}
+/****************************************************************************
+ Put up a yes/no prompt.
+****************************************************************************/
+
+static bool yesno(const char *p)
+{
+ char ans[20];
+ printf("%s",p);
+
+ if (!fgets(ans,sizeof(ans)-1,stdin))
+ return(False);
+
+ if (*ans == 'y' || *ans == 'Y')
+ return(True);
+
+ return(False);
+}
+
/****************************************************************************
Write to a local file with CR/LF->LF translation if appropriate. Return the
number taken from the buffer. This may not equal the number written.
static void send_message(const char *username)
{
- int total_len = 0;
- int grp_id;
-
- if (!cli_message_start(cli, desthost, username, &grp_id)) {
- d_printf("message start: %s\n", cli_errstr(cli));
- return;
- }
-
-
- d_printf("Connected. Type your message, ending it with a Control-D\n");
-
- while (!feof(stdin) && total_len < 1600) {
- int maxlen = MIN(1600 - total_len,127);
- char msg[1024];
- int l=0;
- int c;
-
- ZERO_ARRAY(msg);
+ char buf[1600];
+ NTSTATUS status;
+ int i;
- for (l=0;l<maxlen && (c=fgetc(stdin))!=EOF;l++) {
- if (c == '\n')
- msg[l++] = '\r';
- msg[l] = c;
- }
+ d_printf("Type your message, ending it with a Control-D\n");
- if ((total_len > 0) && (strlen(msg) == 0)) {
+ i = 0;
+ while (i<sizeof(buf)-2) {
+ int c = fgetc(stdin);
+ if (c == EOF) {
break;
}
-
- if (!cli_message_text(cli, msg, l, grp_id)) {
- d_printf("SMBsendtxt failed (%s)\n",cli_errstr(cli));
- return;
+ if (c == '\n') {
+ buf[i++] = '\r';
}
-
- total_len += l;
+ buf[i++] = c;
}
+ buf[i] = '\0';
- if (total_len >= 1600)
- d_printf("the message was truncated to 1600 bytes\n");
- else
- d_printf("sent %d bytes\n",total_len);
-
- if (!cli_message_end(cli, grp_id)) {
- d_printf("SMBsendend failed (%s)\n",cli_errstr(cli));
- return;
+ status = cli_message(cli, desthost, username, buf);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr, "cli_message returned %s\n",
+ nt_errstr(status));
}
}
Except Win9x doesn't support the qpathinfo_basic() call..... */
if (targetcli->protocol > PROTOCOL_LANMAN2 && !targetcli->win95) {
- if (!cli_qpathinfo_basic( targetcli, targetpath, &sbuf, &attributes ) ) {
- d_printf("cd %s: %s\n", new_cd, cli_errstr(targetcli));
+ NTSTATUS status;
+
+ status = cli_qpathinfo_basic(targetcli, targetpath, &sbuf,
+ &attributes);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("cd %s: %s\n", new_cd, nt_errstr(status));
client_set_cur_dir(saved_dir);
goto out;
}
if (f && reput) {
if (x_tseek(f, start, SEEK_SET) == -1) {
d_printf("Error seeking local file\n");
+ x_fclose(f);
return 1;
}
}
if (!NT_STATUS_IS_OK(cli_close(targetcli, fnum))) {
d_printf("%s closing remote file %s\n",cli_errstr(cli),rname);
- x_fclose(f);
+ if (f != x_stdin) {
+ x_fclose(f);
+ }
return 1;
}
SMB_STRUCT_STAT st;
/* allow '-' to represent stdin
jdblair, 24.jun.98 */
- if (!file_exist_stat(lname,&st) &&
+ if (!file_exist_stat(lname, &st, false) &&
(strcmp(lname,"-"))) {
d_printf("%s does not exist\n",lname);
return 1;
uint16 major, minor;
uint32 caplow, caphigh;
char *caps;
+ NTSTATUS status;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
d_printf("Server doesn't support UNIX CIFS extensions.\n");
return 1;
}
- if (!cli_unix_extensions_version(cli, &major, &minor, &caplow, &caphigh)) {
- d_printf("Can't get UNIX CIFS extensions version from server.\n");
+ status = cli_unix_extensions_version(cli, &major, &minor, &caplow,
+ &caphigh);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Can't get UNIX CIFS extensions version from "
+ "server: %s\n", nt_errstr(status));
return 1;
}
d_printf("Server supports CIFS capabilities %s\n", caps);
- if (!cli_set_unix_extensions_capabilities(cli, major, minor, caplow, caphigh)) {
- d_printf("Can't set UNIX CIFS extensions capabilities. %s.\n", cli_errstr(cli));
+ status = cli_set_unix_extensions_capabilities(cli, major, minor,
+ caplow, caphigh);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Can't set UNIX CIFS extensions capabilities. %s.\n",
+ nt_errstr(status));
return 1;
}
len = (uint64_t)strtol(buf, (char **)NULL, 16);
- if (!cli_posix_lock(cli, fnum, start, len, true, lock_type)) {
+ if (!NT_STATUS_IS_OK(cli_posix_lock(cli, fnum, start, len, true, lock_type))) {
d_printf("lock failed %d: %s\n", fnum, cli_errstr(cli));
}
len = (uint64_t)strtol(buf, (char **)NULL, 16);
- if (!cli_posix_unlock(cli, fnum, start, len)) {
+ if (!NT_STATUS_IS_OK(cli_posix_unlock(cli, fnum, start, len))) {
d_printf("unlock failed %d: %s\n", fnum, cli_errstr(cli));
}
uint16 num_file_acls = 0;
uint16 num_dir_acls = 0;
uint16 i;
+ NTSTATUS status;
if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) {
d_printf("getfacl filename\n");
return 1;
}
- if (!cli_unix_extensions_version(targetcli, &major, &minor,
- &caplow, &caphigh)) {
- d_printf("Can't get UNIX CIFS version from server.\n");
+ status = cli_unix_extensions_version(targetcli, &major, &minor,
+ &caplow, &caphigh);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Can't get UNIX CIFS version from server: %s.\n",
+ nt_errstr(status));
return 1;
}
fstring volname;
uint32 serial_num;
time_t create_date;
+ NTSTATUS status;
- if (!cli_get_fs_volume_info(cli, volname, &serial_num, &create_date)) {
- d_printf("Errr %s getting volume info\n",cli_errstr(cli));
+ status = cli_get_fs_volume_info(cli, volname, &serial_num,
+ &create_date);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("Error %s getting volume info\n", nt_errstr(status));
return 1;
}
SMB_STRUCT_STAT sbuf;
ok = next_token_talloc(ctx, &cmd_ptr,&buf,NULL);
- if (ok && (sys_stat(buf,&sbuf) == 0)) {
+ if (ok && (sys_stat(buf, &sbuf, false) == 0)) {
newer_than = convert_timespec_to_time_t(sbuf.st_ex_mtime);
DEBUG(1,("Getting files newer than %s",
time_to_asc(newer_than)));
return 1;
}
- if (!file_exist_stat(local_name, &st)) {
+ if (!file_exist_stat(local_name, &st, false)) {
d_printf("%s does not exist\n", local_name);
return 1;
}
static bool browse_host_rpc(bool sort)
{
NTSTATUS status;
- struct rpc_pipe_client *pipe_hnd;
+ struct rpc_pipe_client *pipe_hnd = NULL;
TALLOC_CTX *frame = talloc_stackframe();
WERROR werr;
struct srvsvc_NetShareInfoCtr info_ctr;
#define MAX_COMPLETIONS 100
-typedef struct {
+struct completion_remote {
char *dirmask;
char **matches;
int count, samelen;
const char *text;
int len;
-} completion_remote_t;
+};
static void completion_remote_filter(const char *mnt,
file_info *f,
const char *mask,
void *state)
{
- completion_remote_t *info = (completion_remote_t *)state;
+ struct completion_remote *info = (struct completion_remote *)state;
if ((info->count < MAX_COMPLETIONS - 1) &&
(strncmp(info->text, f->name, info->len) == 0) &&
char *targetpath = NULL;
struct cli_state *targetcli = NULL;
int i;
- completion_remote_t info = { NULL, NULL, 1, 0, NULL, 0 };
+ struct completion_remote info = { NULL, NULL, 1, 0, NULL, 0 };
- /* can't have non-static intialisation on Sun CC, so do it
+ /* can't have non-static initialisation on Sun CC, so do it
at run time here */
info.samelen = len;
info.text = text;
int opt;
char *query_host = NULL;
bool message = false;
- char *term_code = NULL;
static const char *new_name_resolve_order = NULL;
poptContext pc;
char *p;
{ "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" },
{ "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr instead of stdout" },
{ "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available on a host", "HOST" },
- { "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code {sjis|euc|jis7|jis8|junet|hex}", "CODE" },
{ "max-protocol", 'm', POPT_ARG_STRING, NULL, 'm', "Set the max protocol level", "LEVEL" },
{ "tar", 'T', POPT_ARG_STRING, NULL, 'T', "Command line tar", "<c|x>IXFqgbNan" },
{ "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" },
exit(ENOMEM);
}
-#ifdef KANJI
- term_code = talloc_strdup(frame,KANJI);
-#else /* KANJI */
- term_code = talloc_strdup(frame,"");
-#endif /* KANJI */
- if (!term_code) {
- exit(ENOMEM);
- }
-
/* initialize the workgroup name so we can determine whether or
not it was set by a command line option */
exit(ENOMEM);
}
break;
- case 't':
- term_code = talloc_strdup(frame,poptGetOptArg(pc));
- if (!term_code) {
- exit(ENOMEM);
- }
- break;
case 'm':
max_protocol = interpret_protocol(poptGetOptArg(pc), max_protocol);
break;