struct cli_state *cli;
extern BOOL in_client;
-static int port = SMB_PORT;
+static int port = 0;
pstring cur_dir = "\\";
pstring cd_path = "";
static pstring service;
read from a file with LF->CR/LF translation if appropriate. return the
number read. read approx n bytes.
****************************************************************************/
-static int readfile(char *b, int size, int n, FILE *f)
+static int readfile(char *b, int n, XFILE *f)
{
int i;
int c;
- if (!translation || (size != 1))
- return(fread(b,size,n,f));
+ if (!translation)
+ return x_fread(b,1,n,f);
i = 0;
while (i < (n - 1) && (i < BUFFER_SIZE)) {
- if ((c = getc(f)) == EOF) {
+ if ((c = x_getc(f)) == EOF) {
break;
}
int grp_id;
if (!cli_message_start(cli, desthost, username, &grp_id)) {
- DEBUG(0,("message start: %s\n", cli_errstr(cli)));
+ d_printf("message start: %s\n", cli_errstr(cli));
return;
}
- printf("Connected. Type your message, ending it with a Control-D\n");
+ 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);
}
if (!cli_message_text(cli, msg, l, grp_id)) {
- printf("SMBsendtxt failed (%s)\n",cli_errstr(cli));
+ d_printf("SMBsendtxt failed (%s)\n",cli_errstr(cli));
return;
}
}
if (total_len >= 1600)
- printf("the message was truncated to 1600 bytes\n");
+ d_printf("the message was truncated to 1600 bytes\n");
else
- printf("sent %d bytes\n",total_len);
+ d_printf("sent %d bytes\n",total_len);
if (!cli_message_end(cli, grp_id)) {
- printf("SMBsendend failed (%s)\n",cli_errstr(cli));
+ d_printf("SMBsendend failed (%s)\n",cli_errstr(cli));
return;
}
}
int total, bsize, avail;
if (!cli_dskattr(cli, &bsize, &total, &avail)) {
- DEBUG(0,("Error in dskattr: %s\n",cli_errstr(cli)));
+ d_printf("Error in dskattr: %s\n",cli_errstr(cli));
return;
}
- DEBUG(0,("\n\t\t%d blocks of size %d. %d blocks available\n",
- total, bsize, avail));
+ d_printf("\n\t\t%d blocks of size %d. %d blocks available\n",
+ total, bsize, avail);
}
/****************************************************************************
****************************************************************************/
static void cmd_pwd(void)
{
- DEBUG(0,("Current directory is %s",service));
- DEBUG(0,("%s\n",cur_dir));
+ d_printf("Current directory is %s",service);
+ d_printf("%s\n",cur_dir);
}
if (!strequal(cur_dir,"\\")) {
if (!cli_chkpath(cli, dname)) {
- DEBUG(0,("cd %s: %s\n", dname, cli_errstr(cli)));
+ d_printf("cd %s: %s\n", dname, cli_errstr(cli));
pstrcpy(cur_dir,saved_dir);
}
}
if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
do_cd(buf);
else
- DEBUG(0,("Current directory is %s\n",cur_dir));
+ d_printf("Current directory is %s\n",cur_dir);
}
{
if (do_this_one(finfo)) {
time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
- DEBUG(0,(" %-30s%7.7s %8.0f %s",
+ d_printf(" %-30s%7.7s %8.0f %s",
finfo->name,
attrib_string(finfo->mode),
(double)finfo->size,
- asctime(LocalTime(&t))));
+ asctime(LocalTime(&t)));
dir_total += finfo->size;
}
}
*/
static void reset_do_list_queue(void)
{
- if (do_list_queue)
- {
- free(do_list_queue);
- }
- do_list_queue = 0;
+ SAFE_FREE(do_list_queue);
do_list_queue_size = 0;
do_list_queue_start = 0;
do_list_queue_end = 0;
do_list_queue_size = 1024;
do_list_queue = malloc(do_list_queue_size);
if (do_list_queue == 0) {
- DEBUG(0,("malloc fail for size %d\n",
- (int)do_list_queue_size));
+ d_printf("malloc fail for size %d\n",
+ (int)do_list_queue_size);
reset_do_list_queue();
} else {
memset(do_list_queue, 0, do_list_queue_size);
static void add_to_do_list_queue(const char* entry)
{
+ char *dlq;
long new_end = do_list_queue_end + ((long)strlen(entry)) + 1;
while (new_end > do_list_queue_size)
{
do_list_queue_size *= 2;
DEBUG(4,("enlarging do_list_queue to %d\n",
(int)do_list_queue_size));
- do_list_queue = Realloc(do_list_queue, do_list_queue_size);
- if (! do_list_queue) {
- DEBUG(0,("failure enlarging do_list_queue to %d bytes\n",
- (int)do_list_queue_size));
+ dlq = Realloc(do_list_queue, do_list_queue_size);
+ if (! dlq) {
+ d_printf("failure enlarging do_list_queue to %d bytes\n",
+ (int)do_list_queue_size);
reset_do_list_queue();
}
else
{
+ do_list_queue = dlq;
memset(do_list_queue + do_list_queue_size / 2,
0, do_list_queue_size / 2);
}
strlen(next_file) - 2;
*save_ch = '\0';
}
- DEBUG(0,("\n%s\n",next_file));
+ d_printf("\n%s\n",next_file);
if (save_ch)
{
*save_ch = '\\';
{
if (cli_list(cli, mask, attribute, do_list_helper, NULL) == -1)
{
- DEBUG(0, ("%s listing %s\n", cli_errstr(cli), mask));
+ d_printf("%s listing %s\n", cli_errstr(cli), mask);
}
}
do_dskattr();
- DEBUG(0, ("Total number of bytes: %.0f\n", dir_total));
+ d_printf("Total number of bytes: %.0f\n", dir_total);
}
fnum = cli_open(cli, rname, O_RDONLY, DENY_NONE);
if (fnum == -1) {
- DEBUG(0,("%s opening remote file %s\n",cli_errstr(cli),rname));
+ d_printf("%s opening remote file %s\n",cli_errstr(cli),rname);
return;
}
newhandle = True;
}
if (handle < 0) {
- DEBUG(0,("Error opening local file %s\n",lname));
+ d_printf("Error opening local file %s\n",lname);
return;
}
&attr, &size, NULL, NULL, NULL, NULL, NULL) &&
!cli_getattrE(cli, fnum,
&attr, &size, NULL, NULL, NULL)) {
- DEBUG(0,("getattrib: %s\n",cli_errstr(cli)));
+ d_printf("getattrib: %s\n",cli_errstr(cli));
return;
}
lname, (double)size, lname));
if(!(data = (char *)malloc(read_size))) {
- DEBUG(0,("malloc fail for size %d\n", read_size));
+ d_printf("malloc fail for size %d\n", read_size);
cli_close(cli, fnum);
return;
}
if (n <= 0) break;
if (writefile(handle,data, n) != n) {
- DEBUG(0,("Error writing local file\n"));
+ d_printf("Error writing local file\n");
break;
}
rname, (long)nread));
}
- free(data);
+ SAFE_FREE(data);
if (!cli_close(cli, fnum)) {
- DEBUG(0,("Error %s closing remote file\n",cli_errstr(cli)));
+ d_printf("Error %s closing remote file\n",cli_errstr(cli));
}
if (newhandle) {
p = rname + strlen(rname);
if (!next_token_nr(NULL,p,NULL,sizeof(rname)-strlen(rname))) {
- DEBUG(0,("get <filename>\n"));
+ d_printf("get <filename>\n");
return;
}
pstrcpy(lname,p);
return;
if (abort_mget) {
- DEBUG(0,("mget aborted\n"));
+ d_printf("mget aborted\n");
return;
}
if (!directory_exist(finfo->name,NULL) &&
mkdir(finfo->name,0777) != 0) {
- DEBUG(0,("failed to create directory %s\n",finfo->name));
+ d_printf("failed to create directory %s\n",finfo->name);
pstrcpy(cur_dir,saved_curdir);
return;
}
if (chdir(finfo->name) != 0) {
- DEBUG(0,("failed to chdir to directory %s\n",finfo->name));
+ d_printf("failed to chdir to directory %s\n",finfo->name);
pstrcpy(cur_dir,saved_curdir);
return;
}
slprintf(lname,sizeof(lname)-1, "%s/smbmore.XXXXXX",tmpdir());
fd = smb_mkstemp(lname);
if (fd == -1) {
- DEBUG(0,("failed to create temporary file for more\n"));
+ d_printf("failed to create temporary file for more\n");
return;
}
close(fd);
if (!next_token_nr(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
- DEBUG(0,("more <filename>\n"));
+ d_printf("more <filename>\n");
unlink(lname);
return;
}
static BOOL do_mkdir(char *name)
{
if (!cli_mkdir(cli, name)) {
- DEBUG(0,("%s making remote directory %s\n",
- cli_errstr(cli),name));
+ d_printf("%s making remote directory %s\n",
+ cli_errstr(cli),name);
return(False);
}
if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
if (!recurse)
- DEBUG(0,("mkdir <dirname>\n"));
+ d_printf("mkdir <dirname>\n");
return;
}
pstrcat(mask,p);
static void do_put(char *rname,char *lname)
{
int fnum;
- FILE *f;
+ XFILE *f;
int nread=0;
char *buf=NULL;
int maxwrite=io_bufsize;
fnum = cli_open(cli, rname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);
if (fnum == -1) {
- DEBUG(0,("%s opening remote file %s\n",cli_errstr(cli),rname));
+ d_printf("%s opening remote file %s\n",cli_errstr(cli),rname);
return;
}
/* allow files to be piped into smbclient
jdblair 24.jun.98 */
if (!strcmp(lname, "-")) {
- f = stdin;
+ f = x_stdin;
/* size of file is not known */
} else {
- f = sys_fopen(lname,"r");
+ f = x_fopen(lname,O_RDONLY, 0);
}
if (!f) {
- DEBUG(0,("Error opening local file %s\n",lname));
+ d_printf("Error opening local file %s\n",lname);
return;
}
rname));
buf = (char *)malloc(maxwrite);
- while (!feof(f)) {
+ if (!buf) {
+ d_printf("ERROR: Not enough memory!\n");
+ return;
+ }
+ while (!x_feof(f)) {
int n = maxwrite;
int ret;
- if ((n = readfile(buf,1,n,f)) < 1) {
- if((n == 0) && feof(f))
+ if ((n = readfile(buf,n,f)) < 1) {
+ if((n == 0) && x_feof(f))
break; /* Empty local file. */
- DEBUG(0,("Error reading local file: %s\n", strerror(errno) ));
+ d_printf("Error reading local file: %s\n", strerror(errno));
break;
}
ret = cli_write(cli, fnum, 0, buf, nread, n);
if (n != ret) {
- DEBUG(0,("Error writing file: %s\n", cli_errstr(cli)));
+ d_printf("Error writing file: %s\n", cli_errstr(cli));
break;
}
}
if (!cli_close(cli, fnum)) {
- DEBUG(0,("%s closing remote file %s\n",cli_errstr(cli),rname));
- fclose(f);
- if (buf) free(buf);
+ d_printf("%s closing remote file %s\n",cli_errstr(cli),rname);
+ x_fclose(f);
+ SAFE_FREE(buf);
return;
}
- fclose(f);
- if (buf) free(buf);
+ x_fclose(f);
+ SAFE_FREE(buf);
{
struct timeval tp_end;
put_total_size / (1.024*put_total_time_ms)));
}
- if (f == stdin) {
+ if (f == x_stdin) {
cli_shutdown(cli);
exit(0);
}
pstrcat(rname,"\\");
if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
- DEBUG(0,("put <filename>\n"));
+ d_printf("put <filename>\n");
return;
}
pstrcpy(lname,p);
jdblair, 24.jun.98 */
if (!file_exist(lname,&st) &&
(strcmp(lname,"-"))) {
- DEBUG(0,("%s does not exist\n",lname));
+ d_printf("%s does not exist\n",lname);
return;
}
}
{
tmp = list;
DLIST_REMOVE(list, list);
- if (tmp->file_path) free(tmp->file_path);
- free(tmp);
+ SAFE_FREE(tmp->file_path);
+ SAFE_FREE(tmp);
}
}
}
isdir = False;
- if (!match || !ms_fnmatch(expression, dname)) {
+ if (!match || !gen_fnmatch(expression, dname)) {
if (recurse) {
ret = stat(path, &statbuf);
if (ret == 0) {
ret = file_find(list, path, expression, False);
}
} else {
- DEBUG(0,("file_find: cannot stat file %s\n", path));
+ d_printf("file_find: cannot stat file %s\n", path);
}
if (ret == -1) {
- free(path);
+ SAFE_FREE(path);
closedir(dir);
return -1;
}
}
entry = (struct file_list *) malloc(sizeof (struct file_list));
if (!entry) {
- DEBUG(0,("Out of memory in file_find\n"));
+ d_printf("Out of memory in file_find\n");
closedir(dir);
return -1;
}
entry->isdir = isdir;
DLIST_ADD(*list, entry);
} else {
- free(path);
+ SAFE_FREE(path);
}
}
for (temp_list = file_list; temp_list;
temp_list = temp_list->next) {
- if (lname) free(lname);
+ SAFE_FREE(lname);
if (asprintf(&lname, "%s/", temp_list->file_path) <= 0)
continue;
trim_string(lname, "./", "/");
if (temp_list->isdir) {
/* if (!recurse) continue; */
- if (quest) free(quest);
+ SAFE_FREE(quest);
asprintf(&quest, "Put directory %s? ", lname);
if (prompt && !yesno(quest)) { /* No */
/* Skip the directory */
if (!seek_list(temp_list, lname))
break;
} else { /* Yes */
- if (rname) free(rname);
+ SAFE_FREE(rname);
asprintf(&rname, "%s%s", cur_dir, lname);
dos_format(rname);
if (!cli_chkpath(cli, rname) &&
}
continue;
} else {
- if (quest) free(quest);
+ SAFE_FREE(quest);
asprintf(&quest,"Put file %s? ", lname);
if (prompt && !yesno(quest)) /* No */
continue;
/* Yes */
- if (rname) free(rname);
+ SAFE_FREE(rname);
asprintf(&rname, "%s%s", cur_dir, lname);
}
do_put(rname, lname);
}
free_file_list(file_list);
- if (quest) free(quest);
- if (lname) free(lname);
- if (rname) free(rname);
+ SAFE_FREE(quest);
+ SAFE_FREE(lname);
+ SAFE_FREE(rname);
}
}
static void do_cancel(int job)
{
if (cli_printjob_del(cli, job)) {
- printf("Job %d cancelled\n",job);
+ d_printf("Job %d cancelled\n",job);
} else {
- printf("Error cancelling job %d : %s\n",job,cli_errstr(cli));
+ d_printf("Error cancelling job %d : %s\n",job,cli_errstr(cli));
}
}
int job;
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- printf("cancel <jobid> ...\n");
+ d_printf("cancel <jobid> ...\n");
return;
}
do {
char *p;
if (!next_token_nr(NULL,lname,NULL, sizeof(lname))) {
- DEBUG(0,("print <filename>\n"));
+ d_printf("print <filename>\n");
return;
}
****************************************************************************/
static void queue_fn(struct print_job_info *p)
{
- DEBUG(0,("%-6d %-9d %s\n", (int)p->id, (int)p->size, p->name));
+ d_printf("%-6d %-9d %s\n", (int)p->id, (int)p->size, p->name);
}
/****************************************************************************
return;
if (!cli_unlink(cli, mask)) {
- DEBUG(0,("%s deleting remote file %s\n",cli_errstr(cli),mask));
+ d_printf("%s deleting remote file %s\n",cli_errstr(cli),mask);
}
}
pstrcpy(mask,cur_dir);
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- DEBUG(0,("del <filename>\n"));
+ d_printf("del <filename>\n");
return;
}
pstrcat(mask,buf);
pstrcpy(mask,cur_dir);
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- DEBUG(0,("del <filename>\n"));
+ d_printf("del <filename>\n");
return;
}
pstrcat(mask,buf);
pstrcpy(mask,cur_dir);
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
- DEBUG(0,("rmdir <dirname>\n"));
+ d_printf("rmdir <dirname>\n");
return;
}
pstrcat(mask,buf);
if (!cli_rmdir(cli, mask)) {
- DEBUG(0,("%s removing remote directory file %s\n",
- cli_errstr(cli),mask));
+ d_printf("%s removing remote directory file %s\n",
+ cli_errstr(cli),mask);
}
}
if (!next_token_nr(NULL,buf,NULL,sizeof(buf)) ||
!next_token_nr(NULL,buf2,NULL, sizeof(buf2))) {
- DEBUG(0,("rename <src> <dest>\n"));
+ d_printf("rename <src> <dest>\n");
return;
}
pstrcat(dest,buf2);
if (!cli_rename(cli, src, dest)) {
- DEBUG(0,("%s renaming files\n",cli_errstr(cli)));
+ d_printf("%s renaming files\n",cli_errstr(cli));
return;
}
}
}
if (ok && newer_than == 0)
- DEBUG(0,("Error setting newer-than time\n"));
+ d_printf("Error setting newer-than time\n");
}
/****************************************************************************
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
archive_level = atoi(buf);
} else
- DEBUG(0,("Archive level is %d\n",archive_level));
+ d_printf("Archive level is %d\n",archive_level);
}
/****************************************************************************
case STYPE_IPC:
fstrcpy(typestr,"IPC"); break;
}
- printf("\t%-15.15s%-10.10s%s\n",
+ d_printf("\t%-15.15s%-10.10s%s\n",
name,typestr,comment);
}
{
int ret;
- printf("\n\tSharename Type Comment\n");
- printf("\t--------- ---- -------\n");
+ d_printf("\n\tSharename Type Comment\n");
+ d_printf("\t--------- ---- -------\n");
if((ret = cli_RNetShareEnum(cli, browse_fn, NULL)) == -1)
- printf("Error returning browse list: %s\n", cli_errstr(cli));
+ d_printf("Error returning browse list: %s\n", cli_errstr(cli));
return (ret != -1);
}
static void server_fn(const char *name, uint32 m,
const char *comment, void *state)
{
- printf("\t%-16.16s %s\n", name, comment);
+ d_printf("\t%-16.16s %s\n", name, comment);
}
/****************************************************************************
{
if (!cli->server_domain) return False;
- printf("\n\tServer Comment\n");
- printf("\t--------- -------\n");
+ d_printf("\n\tServer Comment\n");
+ d_printf("\t--------- -------\n");
cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, server_fn, NULL);
- printf("\n\tWorkgroup Master\n");
- printf("\t--------- -------\n");
+ d_printf("\n\tWorkgroup Master\n");
+ d_printf("\t--------- -------\n");
cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM, server_fn, NULL);
return True;
#define COMPL_REMOTE 1 /* Complete remote filename */
#define COMPL_LOCAL 2 /* Complete local filename */
-/* This defines the commands supported by this client */
+/* This defines the commands supported by this client.
+ * NOTE: The "!" must be the last one in the list because it's fn pointer
+ * field is NULL, and NULL in that field is used in process_tok()
+ * (below) to indicate the end of the list. crh
+ */
struct
{
char *name;
char compl_args[2]; /* Completion argument info */
} commands[] =
{
- {"ls",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
+ {"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit",{COMPL_NONE,COMPL_NONE}},
+ {"blocksize",cmd_block,"blocksize <number> (default 20)",{COMPL_NONE,COMPL_NONE}},
+ {"cancel",cmd_cancel,"<jobid> cancel a print queue entry",{COMPL_NONE,COMPL_NONE}},
+ {"cd",cmd_cd,"[directory] change/report the remote directory",{COMPL_REMOTE,COMPL_NONE}},
+ {"del",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
{"dir",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
{"du",cmd_du,"<mask> computes the total size of the current directory",{COMPL_REMOTE,COMPL_NONE}},
- {"lcd",cmd_lcd,"[directory] change/report the local current working directory",{COMPL_LOCAL,COMPL_NONE}},
- {"cd",cmd_cd,"[directory] change/report the remote directory",{COMPL_REMOTE,COMPL_NONE}},
- {"pwd",cmd_pwd,"show current remote directory (same as 'cd' with no args)",{COMPL_NONE,COMPL_NONE}},
+ {"exit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
{"get",cmd_get,"<remote name> [local name] get a file",{COMPL_REMOTE,COMPL_LOCAL}},
+ {"help",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
+ {"history",cmd_history,"displays the command history",{COMPL_NONE,COMPL_NONE}},
+ {"lcd",cmd_lcd,"[directory] change/report the local current working directory",{COMPL_LOCAL,COMPL_NONE}},
+ {"lowercase",cmd_lowercase,"toggle lowercasing of filenames for get",{COMPL_NONE,COMPL_NONE}},
+ {"ls",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
+ {"mask",cmd_select,"<mask> mask all filenames against this",{COMPL_REMOTE,COMPL_NONE}},
+ {"md",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
{"mget",cmd_mget,"<mask> get all the matching files",{COMPL_REMOTE,COMPL_NONE}},
- {"put",cmd_put,"<local name> [remote name] put a file",{COMPL_LOCAL,COMPL_REMOTE}},
- {"mput",cmd_mput,"<mask> put all matching files",{COMPL_REMOTE,COMPL_NONE}},
- {"rename",cmd_rename,"<src> <dest> rename some files",{COMPL_REMOTE,COMPL_REMOTE}},
+ {"mkdir",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
{"more",cmd_more,"<remote name> view a remote file with your pager",{COMPL_REMOTE,COMPL_NONE}},
- {"mask",cmd_select,"<mask> mask all filenames against this",{COMPL_REMOTE,COMPL_NONE}},
- {"del",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
+ {"mput",cmd_mput,"<mask> put all matching files",{COMPL_REMOTE,COMPL_NONE}},
+ {"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
{"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}},
- {"rm",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
- {"mkdir",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
- {"md",cmd_mkdir,"<directory> make a directory",{COMPL_NONE,COMPL_NONE}},
- {"rmdir",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
- {"rd",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
- {"prompt",cmd_prompt,"toggle prompting for filenames for mget and mput",{COMPL_NONE,COMPL_NONE}},
- {"recurse",cmd_recurse,"toggle directory recursion for mget and mput",{COMPL_NONE,COMPL_NONE}},
- {"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}},
- {"lowercase",cmd_lowercase,"toggle lowercasing of filenames for get",{COMPL_NONE,COMPL_NONE}},
{"print",cmd_print,"<file name> print a file",{COMPL_NONE,COMPL_NONE}},
{"printmode",cmd_printmode,"<graphics or text> set the print mode",{COMPL_NONE,COMPL_NONE}},
+ {"prompt",cmd_prompt,"toggle prompting for filenames for mget and mput",{COMPL_NONE,COMPL_NONE}},
+ {"put",cmd_put,"<local name> [remote name] put a file",{COMPL_LOCAL,COMPL_REMOTE}},
+ {"pwd",cmd_pwd,"show current remote directory (same as 'cd' with no args)",{COMPL_NONE,COMPL_NONE}},
+ {"q",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
{"queue",cmd_queue,"show the print queue",{COMPL_NONE,COMPL_NONE}},
- {"cancel",cmd_cancel,"<jobid> cancel a print queue entry",{COMPL_NONE,COMPL_NONE}},
{"quit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
- {"q",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
- {"exit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
- {"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
- {"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit",{COMPL_NONE,COMPL_NONE}},
- {"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
- {"blocksize",cmd_block,"blocksize <number> (default 20)",{COMPL_NONE,COMPL_NONE}},
- {"tarmode",cmd_tarmode,
- "<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}},
+ {"rd",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
+ {"recurse",cmd_recurse,"toggle directory recursion for mget and mput",{COMPL_NONE,COMPL_NONE}},
+ {"rename",cmd_rename,"<src> <dest> rename some files",{COMPL_REMOTE,COMPL_REMOTE}},
+ {"rm",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
+ {"rmdir",cmd_rmdir,"<directory> remove a directory",{COMPL_NONE,COMPL_NONE}},
{"setmode",cmd_setmode,"filename <setmode string> change modes of file",{COMPL_REMOTE,COMPL_NONE}},
- {"help",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
+ {"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
+ {"tarmode",cmd_tarmode,"<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}},
+ {"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}},
{"?",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
- {"history",cmd_history,"displays the command history",{COMPL_NONE,COMPL_NONE}},
{"!",NULL,"run a shell command on the local system",{COMPL_NONE,COMPL_NONE}},
{"",NULL,NULL,{COMPL_NONE,COMPL_NONE}}
};
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
if ((i = process_tok(buf)) >= 0)
- DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description));
+ d_printf("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description);
} else {
while (commands[i].description) {
for (j=0; commands[i].description && (j<5); j++) {
- DEBUG(0,("%-15s",commands[i].name));
+ d_printf("%-15s",commands[i].name);
i++;
}
- DEBUG(0,("\n"));
+ d_printf("\n");
}
}
+ return;
}
/****************************************************************************
if ((i = process_tok(tok)) >= 0) {
commands[i].fn();
} else if (i == -2) {
- DEBUG(0,("%s: command abbreviation ambiguous\n",tok));
+ d_printf("%s: command abbreviation ambiguous\n",tok);
} else {
- DEBUG(0,("%s: command not found\n",tok));
+ d_printf("%s: command not found\n",tok);
}
}
}
}
if (count == 2) {
- free(matches[0]);
+ SAFE_FREE(matches[0]);
matches[0] = strdup(matches[1]);
}
matches[count] = NULL;
if ((i = process_tok(tok)) >= 0) {
commands[i].fn();
} else if (i == -2) {
- DEBUG(0,("%s: command abbreviation ambiguous\n",tok));
+ d_printf("%s: command abbreviation ambiguous\n",tok);
} else {
- DEBUG(0,("%s: command not found\n",tok));
+ d_printf("%s: command not found\n",tok);
}
}
}
if (have_ip) ip = dest_ip;
/* have to open a new connection */
- if (!(c=cli_initialise(NULL)) || (cli_set_port(c, port) == 0) ||
+ if (!(c=cli_initialise(NULL)) || (cli_set_port(c, port) != port) ||
!cli_connect(c, server_n, &ip)) {
- DEBUG(0,("Connection to %s failed\n", server_n));
+ d_printf("Connection to %s failed\n", server_n);
return NULL;
}
if (!cli_session_request(c, &calling, &called)) {
char *p;
- DEBUG(0,("session request to %s failed (%s)\n",
- called.name, cli_errstr(c)));
+ d_printf("session request to %s failed (%s)\n",
+ called.name, cli_errstr(c));
cli_shutdown(c);
- free(c);
+ SAFE_FREE(c);
if ((p=strchr_m(called.name, '.'))) {
*p = 0;
goto again;
DEBUG(4,(" session request ok\n"));
if (!cli_negprot(c)) {
- DEBUG(0,("protocol negotiation failed\n"));
+ d_printf("protocol negotiation failed\n");
cli_shutdown(c);
- free(c);
+ SAFE_FREE(c);
return NULL;
}
/* if a password was not supplied then try again with a null username */
if (password[0] || !username[0] ||
!cli_session_setup(c, "", "", 0, "", 0, workgroup)) {
- DEBUG(0,("session setup failed: %s\n", cli_errstr(c)));
+ d_printf("session setup failed: %s\n", cli_errstr(c));
cli_shutdown(c);
- free(c);
+ SAFE_FREE(c);
return NULL;
}
- DEBUG(0,("Anonymous login successful\n"));
+ d_printf("Anonymous login successful\n");
}
/*
if (!cli_send_tconX(c, sharename, "?????",
password, strlen(password)+1)) {
- DEBUG(0,("tree connect failed: %s\n", cli_errstr(c)));
+ d_printf("tree connect failed: %s\n", cli_errstr(c));
cli_shutdown(c);
- free(c);
+ SAFE_FREE(c);
return NULL;
}
****************************************************************************/
static void usage(char *pname)
{
- DEBUG(0,("Usage: %s service <password> [options]", pname));
-
- DEBUG(0,("\nVersion %s\n",VERSION));
- DEBUG(0,("\t-s smb.conf pathname to smb.conf file\n"));
- DEBUG(0,("\t-O socket_options socket options to use\n"));
- DEBUG(0,("\t-R name resolve order use these name resolution services only\n"));
- DEBUG(0,("\t-M host send a winpopup message to the host\n"));
- DEBUG(0,("\t-i scope use this NetBIOS scope\n"));
- DEBUG(0,("\t-N don't ask for a password\n"));
- DEBUG(0,("\t-n netbios name. Use this name as my netbios name\n"));
- DEBUG(0,("\t-d debuglevel set the debuglevel\n"));
- DEBUG(0,("\t-P connect to service as a printer\n"));
- DEBUG(0,("\t-p port connect to the specified port\n"));
- DEBUG(0,("\t-l log basename. Basename for log/debug files\n"));
- DEBUG(0,("\t-h Print this help message.\n"));
- DEBUG(0,("\t-I dest IP use this IP to connect to\n"));
- DEBUG(0,("\t-E write messages to stderr instead of stdout\n"));
- DEBUG(0,("\t-U username set the network username\n"));
- DEBUG(0,("\t-L host get a list of shares available on a host\n"));
- DEBUG(0,("\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n"));
- DEBUG(0,("\t-m max protocol set the max protocol level\n"));
- DEBUG(0,("\t-A filename get the credentials from a file\n"));
- DEBUG(0,("\t-W workgroup set the workgroup name\n"));
- DEBUG(0,("\t-T<c|x>IXFqgbNan command line tar\n"));
- DEBUG(0,("\t-D directory start from directory\n"));
- DEBUG(0,("\t-c command string execute semicolon separated commands\n"));
- DEBUG(0,("\t-b xmit/send buffer changes the transmit/send buffer (default: 65520)\n"));
- DEBUG(0,("\n"));
+ d_printf("Usage: %s service <password> [options]", pname);
+
+ d_printf("\nVersion %s\n",VERSION);
+ d_printf("\t-s smb.conf pathname to smb.conf file\n");
+ d_printf("\t-O socket_options socket options to use\n");
+ d_printf("\t-R name resolve order use these name resolution services only\n");
+ d_printf("\t-M host send a winpopup message to the host\n");
+ d_printf("\t-i scope use this NetBIOS scope\n");
+ d_printf("\t-N don't ask for a password\n");
+ d_printf("\t-n netbios name. Use this name as my netbios name\n");
+ d_printf("\t-d debuglevel set the debuglevel\n");
+ d_printf("\t-P connect to service as a printer\n");
+ d_printf("\t-p port connect to the specified port\n");
+ d_printf("\t-l log basename. Basename for log/debug files\n");
+ d_printf("\t-h Print this help message.\n");
+ d_printf("\t-I dest IP use this IP to connect to\n");
+ d_printf("\t-E write messages to stderr instead of stdout\n");
+ d_printf("\t-U username set the network username\n");
+ d_printf("\t-L host get a list of shares available on a host\n");
+ d_printf("\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n");
+ d_printf("\t-m max protocol set the max protocol level\n");
+ d_printf("\t-A filename get the credentials from a file\n");
+ d_printf("\t-W workgroup set the workgroup name\n");
+ d_printf("\t-T<c|x>IXFqgbNan command line tar\n");
+ d_printf("\t-D directory start from directory\n");
+ d_printf("\t-c command string execute semicolon separated commands\n");
+ d_printf("\t-b xmit/send buffer changes the transmit/send buffer (default: 65520)\n");
+ d_printf("\n");
}
ip = ipzero;
if (have_ip) ip = dest_ip;
- if (!(cli=cli_initialise(NULL)) || (cli_set_port(cli, port) == 0) || !cli_connect(cli, desthost, &ip)) {
- DEBUG(0,("Connection to %s failed\n", desthost));
+ if (!(cli=cli_initialise(NULL)) || (cli_set_port(cli, port) != port) || !cli_connect(cli, desthost, &ip)) {
+ d_printf("Connection to %s failed\n", desthost);
return 1;
}
if (!cli_session_request(cli, &calling, &called)) {
- DEBUG(0,("session request failed\n"));
+ d_printf("session request failed\n");
cli_shutdown(cli);
return 1;
}
fstring base_directory;
char *pname = argv[0];
int opt;
- extern FILE *dbf;
extern char *optarg;
extern int optind;
int old_debug;
for (opt = 1; opt < argc; opt++) {
if (strcmp(argv[opt], "-E") == 0)
- dbf = stderr;
+ dbf = x_stderr;
else if(strncmp(argv[opt], "-s", 2) == 0) {
if(argv[opt][2] != '\0')
pstrcpy(servicesf, &argv[opt][2]);
if (count_chars(service,'\\') < 3) {
usage(pname);
- printf("\n%s: Not enough '\\' characters in service\n",service);
+ d_printf("\n%s: Not enough '\\' characters in service\n",service);
exit(1);
}
}
break;
case 'E':
- dbf = stderr;
+ display_set_stderr();
+ dbf = x_stderr;
break;
case 'U':
{
case 'A':
{
- FILE *auth;
+ XFILE *auth;
fstring buf;
uint16 len = 0;
char *ptr, *val, *param;
- if ((auth=sys_fopen(optarg, "r")) == NULL)
+ if ((auth=x_fopen(optarg, O_RDONLY, 0)) == NULL)
{
/* fail if we can't open the credentials file */
- DEBUG(0,("ERROR: Unable to open credentials file!\n"));
+ d_printf("ERROR: Unable to open credentials file!\n");
exit (-1);
}
- while (!feof(auth))
+ while (!x_feof(auth))
{
/* get a line from the file */
- if (!fgets (buf, sizeof(buf), auth))
+ if (!x_fgets(buf, sizeof(buf), auth))
continue;
len = strlen(buf);
memset(buf, 0, sizeof(buf));
}
- fclose(auth);
+ x_fclose(auth);
}
break;