static int name_type = 0x20;
static int process_tok(fstring tok);
-static int cmd_help(void);
+static int cmd_help(const char **cmd_ptr);
/* 30 second timeout on most commands */
#define CLIENT_TIMEOUT (30*1000)
/****************************************************************************
show cd/pwd
****************************************************************************/
-static int cmd_pwd(void)
+static int cmd_pwd(const char **cmd_ptr)
{
d_printf("Current directory is %s",service);
d_printf("%s\n",cur_dir);
/****************************************************************************
change directory
****************************************************************************/
-static int cmd_cd(void)
+static int cmd_cd(const char **cmd_ptr)
{
fstring buf;
int rc = 0;
- if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
+ if (next_token(cmd_ptr,buf,NULL,sizeof(buf)))
rc = do_cd(buf);
else
d_printf("Current directory is %s\n",cur_dir);
/****************************************************************************
get a directory listing
****************************************************************************/
-static int cmd_dir(void)
+static int cmd_dir(const char **cmd_ptr)
{
uint16_t attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
pstring mask;
if(mask[strlen(mask)-1]!='\\')
pstrcat(mask,"\\");
- if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
dos_format(p);
if (*p == '\\')
pstrcpy(mask,p);
/****************************************************************************
get a directory listing
****************************************************************************/
-static int cmd_du(void)
+static int cmd_du(const char **cmd_ptr)
{
uint16_t attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
pstring mask;
if(mask[strlen(mask)-1]!='\\')
pstrcat(mask,"\\");
- if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
dos_format(p);
if (*p == '\\')
pstrcpy(mask,p);
/****************************************************************************
get a file
****************************************************************************/
-static int cmd_get(void)
+static int cmd_get(const char **cmd_ptr)
{
pstring lname;
pstring rname;
p = rname + strlen(rname);
- if (!next_token_nr(NULL,p,NULL,sizeof(rname)-strlen(rname))) {
+ if (!next_token(cmd_ptr,p,NULL,sizeof(rname)-strlen(rname))) {
d_printf("get <filename>\n");
return 1;
}
pstrcpy(lname,p);
dos_clean_name(rname);
- next_token_nr(NULL,lname,NULL,sizeof(lname));
+ next_token(cmd_ptr,lname,NULL,sizeof(lname));
return do_get(rname, lname, False);
}
/****************************************************************************
view the file using the pager
****************************************************************************/
-static int cmd_more(void)
+static int cmd_more(const char **cmd_ptr)
{
fstring rname,lname,pager_cmd;
char *pager;
}
close(fd);
- if (!next_token_nr(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
+ if (!next_token(cmd_ptr,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
d_printf("more <filename>\n");
unlink(lname);
return 1;
/****************************************************************************
do a mget command
****************************************************************************/
-static int cmd_mget(void)
+static int cmd_mget(const char **cmd_ptr)
{
uint16_t attribute = FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN;
pstring mget_mask;
abort_mget = False;
- while (next_token_nr(NULL,p,NULL,sizeof(buf))) {
+ while (next_token(cmd_ptr,p,NULL,sizeof(buf))) {
pstrcpy(mget_mask,cur_dir);
if(mget_mask[strlen(mget_mask)-1]!='\\')
pstrcat(mget_mask,"\\");
/****************************************************************************
Exit client.
****************************************************************************/
-static int cmd_quit(void)
+static int cmd_quit(const char **cmd_ptr)
{
smbcli_shutdown(cli);
exit(0);
/****************************************************************************
make a directory
****************************************************************************/
-static int cmd_mkdir(void)
+static int cmd_mkdir(const char **cmd_ptr)
{
pstring mask;
fstring buf;
pstrcpy(mask,cur_dir);
- if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,p,NULL,sizeof(buf))) {
if (!recurse)
d_printf("mkdir <dirname>\n");
return 1;
/****************************************************************************
show alt name
****************************************************************************/
-static int cmd_altname(void)
+static int cmd_altname(const char **cmd_ptr)
{
pstring name;
fstring buf;
pstrcpy(name,cur_dir);
- if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,p,NULL,sizeof(buf))) {
d_printf("altname <file>\n");
return 1;
}
/****************************************************************************
put a file
****************************************************************************/
-static int cmd_put(void)
+static int cmd_put(const char **cmd_ptr)
{
pstring lname;
pstring rname;
pstrcpy(rname,cur_dir);
pstrcat(rname,"\\");
- if (!next_token_nr(NULL,p,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,p,NULL,sizeof(buf))) {
d_printf("put <filename>\n");
return 1;
}
pstrcpy(lname,p);
- if (next_token_nr(NULL,p,NULL,sizeof(buf)))
+ if (next_token(cmd_ptr,p,NULL,sizeof(buf)))
pstrcat(rname,p);
else
pstrcat(rname,lname);
/****************************************************************************
set the file selection mask
****************************************************************************/
-static int cmd_select(void)
+static int cmd_select(const char **cmd_ptr)
{
pstrcpy(fileselection,"");
- next_token_nr(NULL,fileselection,NULL,sizeof(fileselection));
+ next_token(cmd_ptr,fileselection,NULL,sizeof(fileselection));
return 0;
}
/****************************************************************************
mput some files
****************************************************************************/
-static int cmd_mput(void)
+static int cmd_mput(const char **cmd_ptr)
{
fstring buf;
char *p=buf;
- while (next_token_nr(NULL,p,NULL,sizeof(buf))) {
+ while (next_token(cmd_ptr,p,NULL,sizeof(buf))) {
int ret;
struct file_list *temp_list;
char *quest, *lname, *rname;
/****************************************************************************
cancel a print job
****************************************************************************/
-static int cmd_cancel(void)
+static int cmd_cancel(const char **cmd_ptr)
{
fstring buf;
int job;
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
d_printf("cancel <jobid> ...\n");
return 1;
}
do {
job = atoi(buf);
do_cancel(job);
- } while (next_token_nr(NULL,buf,NULL,sizeof(buf)));
+ } while (next_token(cmd_ptr,buf,NULL,sizeof(buf)));
return 0;
}
/****************************************************************************
print a file
****************************************************************************/
-static int cmd_print(void)
+static int cmd_print(const char **cmd_ptr)
{
pstring lname;
pstring rname;
char *p;
- if (!next_token_nr(NULL,lname,NULL, sizeof(lname))) {
+ if (!next_token(cmd_ptr,lname,NULL, sizeof(lname))) {
d_printf("print <filename>\n");
return 1;
}
/****************************************************************************
show a print queue
****************************************************************************/
-static int cmd_queue(void)
+static int cmd_queue(const char **cmd_ptr)
{
d_printf("REWRITE: print job queue not implemented\n");
/****************************************************************************
delete some files
****************************************************************************/
-static int cmd_del(void)
+static int cmd_del(const char **cmd_ptr)
{
pstring mask;
fstring buf;
pstrcpy(mask,cur_dir);
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
d_printf("del <filename>\n");
return 1;
}
/****************************************************************************
delete a whole directory tree
****************************************************************************/
-static int cmd_deltree(void)
+static int cmd_deltree(const char **cmd_ptr)
{
pstring dname;
fstring buf;
pstrcpy(dname,cur_dir);
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
d_printf("deltree <dirname>\n");
return 1;
}
/****************************************************************************
show as much information as possible about a file
****************************************************************************/
-static int cmd_allinfo(void)
+static int cmd_allinfo(const char **cmd_ptr)
{
pstring fname;
fstring buf;
pstrcpy(fname,cur_dir);
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
d_printf("allinfo <filename>\n");
return 1;
}
/****************************************************************************
show any ACL on a file
****************************************************************************/
-static int cmd_acl(void)
+static int cmd_acl(const char **cmd_ptr)
{
pstring fname;
fstring buf;
pstrcpy(fname,cur_dir);
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
d_printf("acl <filename>\n");
return 1;
}
/****************************************************************************
****************************************************************************/
-static int cmd_open(void)
+static int cmd_open(const char **cmd_ptr)
{
pstring mask;
fstring buf;
pstrcpy(mask,cur_dir);
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
d_printf("open <filename>\n");
return 1;
}
/****************************************************************************
remove a directory
****************************************************************************/
-static int cmd_rmdir(void)
+static int cmd_rmdir(const char **cmd_ptr)
{
pstring mask;
fstring buf;
pstrcpy(mask,cur_dir);
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
d_printf("rmdir <dirname>\n");
return 1;
}
/****************************************************************************
UNIX hardlink.
****************************************************************************/
-static int cmd_link(void)
+static int cmd_link(const char **cmd_ptr)
{
pstring src,dest;
fstring buf,buf2;
pstrcpy(src,cur_dir);
pstrcpy(dest,cur_dir);
- if (!next_token(NULL,buf,NULL,sizeof(buf)) ||
- !next_token(NULL,buf2,NULL, sizeof(buf2))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf)) ||
+ !next_token(cmd_ptr,buf2,NULL, sizeof(buf2))) {
d_printf("link <src> <dest>\n");
return 1;
}
UNIX symlink.
****************************************************************************/
-static int cmd_symlink(void)
+static int cmd_symlink(const char **cmd_ptr)
{
pstring src,dest;
fstring buf,buf2;
pstrcpy(src,cur_dir);
pstrcpy(dest,cur_dir);
- if (!next_token(NULL,buf,NULL,sizeof(buf)) ||
- !next_token(NULL,buf2,NULL, sizeof(buf2))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf)) ||
+ !next_token(cmd_ptr,buf2,NULL, sizeof(buf2))) {
d_printf("symlink <src> <dest>\n");
return 1;
}
UNIX chmod.
****************************************************************************/
-static int cmd_chmod(void)
+static int cmd_chmod(const char **cmd_ptr)
{
pstring src;
mode_t mode;
pstrcpy(src,cur_dir);
- if (!next_token(NULL,buf,NULL,sizeof(buf)) ||
- !next_token(NULL,buf2,NULL, sizeof(buf2))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf)) ||
+ !next_token(cmd_ptr,buf2,NULL, sizeof(buf2))) {
d_printf("chmod mode file\n");
return 1;
}
UNIX chown.
****************************************************************************/
-static int cmd_chown(void)
+static int cmd_chown(const char **cmd_ptr)
{
pstring src;
uid_t uid;
pstrcpy(src,cur_dir);
- if (!next_token(NULL,buf,NULL,sizeof(buf)) ||
- !next_token(NULL,buf2,NULL, sizeof(buf2)) ||
- !next_token(NULL,buf3,NULL, sizeof(buf3))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf)) ||
+ !next_token(cmd_ptr,buf2,NULL, sizeof(buf2)) ||
+ !next_token(cmd_ptr,buf3,NULL, sizeof(buf3))) {
d_printf("chown uid gid file\n");
return 1;
}
/****************************************************************************
rename some files
****************************************************************************/
-static int cmd_rename(void)
+static int cmd_rename(const char **cmd_ptr)
{
pstring src,dest;
fstring buf,buf2;
pstrcpy(src,cur_dir);
pstrcpy(dest,cur_dir);
- if (!next_token_nr(NULL,buf,NULL,sizeof(buf)) ||
- !next_token_nr(NULL,buf2,NULL, sizeof(buf2))) {
+ if (!next_token(cmd_ptr,buf,NULL,sizeof(buf)) ||
+ !next_token(cmd_ptr,buf2,NULL, sizeof(buf2))) {
d_printf("rename <src> <dest>\n");
return 1;
}
/****************************************************************************
toggle the prompt flag
****************************************************************************/
-static int cmd_prompt(void)
+static int cmd_prompt(const char **cmd_ptr)
{
prompt = !prompt;
DEBUG(2,("prompting is now %s\n",prompt?"on":"off"));
/****************************************************************************
set the newer than time
****************************************************************************/
-static int cmd_newer(void)
+static int cmd_newer(const char **cmd_ptr)
{
fstring buf;
BOOL ok;
SMB_STRUCT_STAT sbuf;
- ok = next_token_nr(NULL,buf,NULL,sizeof(buf));
+ ok = next_token(cmd_ptr,buf,NULL,sizeof(buf));
if (ok && (sys_stat(buf,&sbuf) == 0)) {
newer_than = sbuf.st_mtime;
DEBUG(1,("Getting files newer than %s",
/****************************************************************************
set the archive level
****************************************************************************/
-static int cmd_archive(void)
+static int cmd_archive(const char **cmd_ptr)
{
fstring buf;
- if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
archive_level = atoi(buf);
} else
d_printf("Archive level is %d\n",archive_level);
/****************************************************************************
toggle the lowercaseflag
****************************************************************************/
-static int cmd_lowercase(void)
+static int cmd_lowercase(const char **cmd_ptr)
{
lowercase = !lowercase;
DEBUG(2,("filename lowercasing is now %s\n",lowercase?"on":"off"));
/****************************************************************************
toggle the recurse flag
****************************************************************************/
-static int cmd_recurse(void)
+static int cmd_recurse(const char **cmd_ptr)
{
recurse = !recurse;
DEBUG(2,("directory recursion is now %s\n",recurse?"on":"off"));
/****************************************************************************
toggle the translate flag
****************************************************************************/
-static int cmd_translate(void)
+static int cmd_translate(const char **cmd_ptr)
{
translation = !translation;
DEBUG(2,("CR/LF<->LF and print text translation now %s\n",
/****************************************************************************
do a printmode command
****************************************************************************/
-static int cmd_printmode(void)
+static int cmd_printmode(const char **cmd_ptr)
{
fstring buf;
fstring mode;
- if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
if (strequal(buf,"text")) {
printmode = 0;
} else {
/****************************************************************************
do the lcd command
****************************************************************************/
-static int cmd_lcd(void)
+static int cmd_lcd(const char **cmd_ptr)
{
fstring buf;
pstring d;
- if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
+ if (next_token(cmd_ptr,buf,NULL,sizeof(buf)))
chdir(buf);
DEBUG(2,("the local directory is now %s\n",sys_getwd(d)));
/****************************************************************************
get a file restarting at end of local file
****************************************************************************/
-static int cmd_reget(void)
+static int cmd_reget(const char **cmd_ptr)
{
pstring local_name;
pstring remote_name;
p = remote_name + strlen(remote_name);
- if (!next_token_nr(NULL, p, NULL, sizeof(remote_name) - strlen(remote_name))) {
+ if (!next_token(cmd_ptr, p, NULL, sizeof(remote_name) - strlen(remote_name))) {
d_printf("reget <filename>\n");
return 1;
}
pstrcpy(local_name, p);
dos_clean_name(remote_name);
- next_token_nr(NULL, local_name, NULL, sizeof(local_name));
+ next_token(cmd_ptr, local_name, NULL, sizeof(local_name));
return do_get(remote_name, local_name, True);
}
/****************************************************************************
put a file restarting at end of local file
****************************************************************************/
-static int cmd_reput(void)
+static int cmd_reput(const char **cmd_ptr)
{
pstring local_name;
pstring remote_name;
pstrcpy(remote_name, cur_dir);
pstrcat(remote_name, "\\");
- if (!next_token_nr(NULL, p, NULL, sizeof(buf))) {
+ if (!next_token(cmd_ptr, p, NULL, sizeof(buf))) {
d_printf("reput <filename>\n");
return 1;
}
return 1;
}
- if (next_token_nr(NULL, p, NULL, sizeof(buf)))
+ if (next_token(cmd_ptr, p, NULL, sizeof(buf)))
pstrcat(remote_name, p);
else
pstrcat(remote_name, local_name);
static struct
{
const char *name;
- int (*fn)(void);
+ int (*fn)(const char **cmd_ptr);
const char *description;
char compl_args[2]; /* Completion argument info */
} commands[] =
/****************************************************************************
help
****************************************************************************/
-static int cmd_help(void)
+static int cmd_help(const char **cmd_ptr)
{
int i=0,j;
fstring buf;
- if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
+ if (next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
if ((i = process_tok(buf)) >= 0)
d_printf("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description);
} else {
/* and get the first part of the command */
ptr = line;
- if (!next_token_nr(&ptr,tok,NULL,sizeof(tok))) continue;
+ if (!next_token(&ptr,tok,NULL,sizeof(tok))) continue;
if ((i = process_tok(tok)) >= 0) {
- rc = commands[i].fn();
+ rc = commands[i].fn(&ptr);
} else if (i == -2) {
d_printf("%s: command abbreviation ambiguous\n",tok);
} else {
/****************************************************************************
make sure we swallow keepalives during idle time
****************************************************************************/
-static void readline_callback(void)
+static void readline_callback(const char **cmd_ptr)
{
static time_t last_t;
time_t t;
****************************************************************************/
static void process_stdin(void)
{
- const char *ptr;
-
while (1) {
fstring tok;
fstring the_prompt;
char *cline;
pstring line;
+ const char *ptr;
int i;
/* display a prompt */
/* and get the first part of the command */
ptr = line;
- if (!next_token_nr(&ptr,tok,NULL,sizeof(tok))) continue;
+ if (!next_token(&ptr,tok,NULL,sizeof(tok))) continue;
if ((i = process_tok(tok)) >= 0) {
- commands[i].fn();
+ commands[i].fn(&ptr);
} else if (i == -2) {
d_printf("%s: command abbreviation ambiguous\n",tok);
} else {