summaryrefslogtreecommitdiff
path: root/source3/client/clitar.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2007-12-19 21:59:28 +0100
committerVolker Lendecke <vl@samba.org>2007-12-21 09:58:20 +0100
commitbea16599112eade0a23b810abcb8cdc4b2480fd9 (patch)
treec56ba1b433dca435a93f2f71e0e4709e7f749de8 /source3/client/clitar.c
parent44d086a15f4908a01d0c719498fde953bd4809e7 (diff)
downloadsamba-bea16599112eade0a23b810abcb8cdc4b2480fd9.tar.gz
samba-bea16599112eade0a23b810abcb8cdc4b2480fd9.tar.bz2
samba-bea16599112eade0a23b810abcb8cdc4b2480fd9.zip
Remove next_token_nr_talloc and its associated global
Only client.c and clitar.c used this, I think they should carry the static themselves. Also move the a bit funny routine toktocliplist to clitar.c, the only place where it is used. (This used to be commit 86d9412611fd99c21e15c71d30a3f95e35d8535b)
Diffstat (limited to 'source3/client/clitar.c')
-rw-r--r--source3/client/clitar.c60
1 files changed, 55 insertions, 5 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 0b4a8b2943..135815c3cd 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -100,6 +100,7 @@ char tar_type='\0';
static char **cliplist=NULL;
static int clipn=0;
static bool must_free_cliplist = False;
+static const char *cmd_ptr = NULL;
extern bool lowercase;
extern uint16 cnum;
@@ -1273,7 +1274,7 @@ int cmd_block(void)
char *buf;
int block;
- if (!next_token_nr_talloc(ctx,NULL,&buf,NULL)) {
+ if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
DEBUG(0, ("blocksize <n>\n"));
return 1;
}
@@ -1298,7 +1299,7 @@ int cmd_tarmode(void)
TALLOC_CTX *ctx = talloc_tos();
char *buf;
- while (next_token_nr_talloc(ctx,NULL,&buf,NULL)) {
+ while (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
if (strequal(buf, "full"))
tar_inc=False;
else if (strequal(buf, "inc"))
@@ -1348,7 +1349,7 @@ int cmd_setmode(void)
attra[0] = attra[1] = 0;
- if (!next_token_nr_talloc(ctx,NULL,&buf,NULL)) {
+ if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
DEBUG(0, ("setmode <filename> <[+|-]rsha>\n"));
return 1;
}
@@ -1361,7 +1362,7 @@ int cmd_setmode(void)
return 1;
}
- while (next_token_nr_talloc(ctx,NULL,&buf,NULL)) {
+ while (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
q=buf;
while(*q) {
@@ -1402,6 +1403,55 @@ int cmd_setmode(void)
return 0;
}
+/**
+ Convert list of tokens to array; dependent on above routine.
+ Uses the global cmd_ptr from above - bit of a hack.
+**/
+
+static char **toktocliplist(int *ctok, const char *sep)
+{
+ char *s=(char *)cmd_ptr;
+ int ictok=0;
+ char **ret, **iret;
+
+ if (!sep)
+ sep = " \t\n\r";
+
+ while(*s && strchr_m(sep,*s))
+ s++;
+
+ /* nothing left? */
+ if (!*s)
+ return(NULL);
+
+ do {
+ ictok++;
+ while(*s && (!strchr_m(sep,*s)))
+ s++;
+ while(*s && strchr_m(sep,*s))
+ *s++=0;
+ } while(*s);
+
+ *ctok=ictok;
+ s=(char *)cmd_ptr;
+
+ if (!(ret=iret=SMB_MALLOC_ARRAY(char *,ictok+1)))
+ return NULL;
+
+ while(ictok--) {
+ *iret++=s;
+ if (ictok > 0) {
+ while(*s++)
+ ;
+ while(!*s)
+ s++;
+ }
+ }
+
+ ret[*ctok] = NULL;
+ return ret;
+}
+
/****************************************************************************
Principal command for creating / extracting
***************************************************************************/
@@ -1414,7 +1464,7 @@ int cmd_tar(void)
int argcl = 0;
int ret;
- if (!next_token_nr_talloc(ctx,NULL,&buf,NULL)) {
+ if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
DEBUG(0,("tar <c|x>[IXbgan] <filename>\n"));
return 1;
}