2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
16 #include <sys/types.h>
24 /* declaration of private token type */
26 struct cmd_token *next;
30 static int dummy; /* non-null ptr used for flag existence */
31 static struct cmd_syndesc *allSyntax = 0;
32 static int noOpcodes = 0;
33 static int (*beforeProc) (struct cmd_syndesc * ts, void *beforeRock) = NULL;
34 static int (*afterProc) (struct cmd_syndesc * ts, void *afterRock) = NULL;
35 static void *beforeRock, *afterRock;
36 static char initcmd_opcode[] = "initcmd"; /*Name of initcmd opcode */
38 /* take name and string, and return null string if name is empty, otherwise return
39 the concatenation of the two strings */
41 NName(char *a1, char *a2)
43 static char tbuffer[300];
44 if (strlen(a1) == 0) {
47 strncpy(tbuffer, a1, sizeof(tbuffer));
48 strncat(tbuffer, a2, sizeof(tbuffer));
49 tbuffer[sizeof(tbuffer)-1]='\0';
54 /* return true if asub is a substring of amain */
56 SubString(register char *amain, register char *asub)
60 mlen = (int) strlen(amain);
61 slen = (int) strlen(asub);
64 return 0; /* not a substring */
65 for (i = 0; i <= j; i++) {
66 if (strncmp(amain, asub, slen) == 0)
70 return 0; /* didn't find it */
74 FindType(register struct cmd_syndesc *as, register char *aname)
81 cmdlen = strlen(aname);
84 for (i = 0; i < CMD_MAXPARMS; i++) {
85 if (as->parms[i].type == 0)
86 continue; /* this slot not set (seeked over) */
87 if (strcmp(as->parms[i].name, aname) == 0)
89 if (strlen(as->parms[i].name) < cmdlen)
91 /* A hidden option must be a full match (no best matches) */
92 if (as->parms[i].flags & CMD_HIDE)
95 if (strncmp(as->parms[i].name, aname, cmdlen) == 0) {
102 return (ambig ? -1 : best);
105 static struct cmd_syndesc *
106 FindSyntax(char *aname, int *aambig)
108 register struct cmd_syndesc *ts;
109 struct cmd_syndesc *best;
113 cmdLen = strlen(aname);
114 best = (struct cmd_syndesc *)0;
117 *aambig = 0; /* initialize to unambiguous */
118 for (ts = allSyntax; ts; ts = ts->next) {
119 if (strcmp(aname, ts->name) == 0)
121 if (strlen(ts->name) < cmdLen)
122 continue; /* we typed more than item has */
123 /* A hidden command must be a full match (no best matches) */
124 if (ts->flags & CMD_HIDDEN)
127 /* This is just an alias for *best, or *best is just an alias for us.
128 * If we don't make this check explicitly, then an alias which is just a
129 * short prefix of the real command's name might make things ambiguous
130 * for no apparent reason.
132 if (best && ts->aliasOf == best->aliasOf)
134 if (strncmp(ts->name, aname, cmdLen) == 0) {
136 ambig = 1; /* ambiguous name */
143 *aambig = ambig; /* if ambiguous and they care, tell them */
144 return (struct cmd_syndesc *)0; /* fails */
146 return best; /* otherwise its not ambiguous, and they know */
149 /* print the help for a single parameter */
151 PrintParmHelp(register struct cmd_parmdesc *aparm)
153 if (aparm->type == CMD_FLAG) {
155 /* doc people don't like seeing this information */
157 printf(" (%s)", aparm->help);
159 } else if (aparm->help) {
160 printf(" <%s>", aparm->help);
161 if (aparm->type == CMD_LIST)
163 } else if (aparm->type == CMD_SINGLE)
165 else if (aparm->type == CMD_LIST)
169 extern char *AFSVersion;
172 VersionProc(register struct cmd_syndesc *as, void *arock)
174 printf("%s\n", AFSVersion);
179 PrintSyntax(register struct cmd_syndesc *as)
182 register struct cmd_parmdesc *tp;
184 /* now print usage, from syntax table */
186 printf("Usage: %s", as->a0name);
188 if (!strcmp(as->name, initcmd_opcode))
189 printf("Usage: %s[%s]", NName(as->a0name, " "), as->name);
191 printf("Usage: %s%s", NName(as->a0name, " "), as->name);
194 for (i = 0; i < CMD_MAXPARMS; i++) {
197 continue; /* seeked over slot */
198 if (tp->flags & CMD_HIDE)
199 continue; /* skip hidden options */
201 if (tp->flags & CMD_OPTIONAL)
203 printf("%s", tp->name);
205 if (tp->flags & CMD_OPTIONAL)
211 /* must print newline in any case, to terminate preceding line */
213 PrintAliases(register struct cmd_syndesc *as)
215 register struct cmd_syndesc *ts;
217 if (as->flags & CMD_ALIAS) {
219 printf("(alias for %s)\n", ts->name);
223 return; /* none, print nothing */
225 for (as = as->nextAlias; as; as = as->nextAlias) {
226 printf("%s ", as->name);
233 PrintFlagHelp(register struct cmd_syndesc *as)
236 register struct cmd_parmdesc *tp;
240 /* find flag name length */
242 for (i = 0; i < CMD_MAXPARMS; i++) {
243 if (i == CMD_HELPPARM)
246 if (tp->type != CMD_FLAG)
248 if (tp->flags & CMD_HIDE)
249 continue; /* skip hidden options */
253 if (strlen(tp->name) > flag_width)
254 flag_width = strlen(tp->name);
257 /* print flag help */
258 flag_prefix = "Where:";
259 for (i = 0; i < CMD_MAXPARMS; i++) {
260 if (i == CMD_HELPPARM)
263 if (tp->type != CMD_FLAG)
265 if (tp->flags & CMD_HIDE)
266 continue; /* skip hidden options */
270 printf("%-7s%-*s %s\n", flag_prefix, flag_width, tp->name, tp->help);
276 AproposProc(register struct cmd_syndesc *as, void *arock)
278 register struct cmd_syndesc *ts;
283 tsub = as->parms[0].items->data;
284 for (ts = allSyntax; ts; ts = ts->next) {
285 if ((ts->flags & CMD_ALIAS) || (ts->flags & CMD_HIDDEN))
287 if (SubString(ts->help, tsub)) {
288 printf("%s: %s\n", ts->name, ts->help);
290 } else if (SubString(ts->name, tsub)) {
291 printf("%s: %s\n", ts->name, ts->help);
296 printf("Sorry, no commands found\n");
301 HelpProc(register struct cmd_syndesc *as, void *arock)
303 register struct cmd_syndesc *ts;
304 register struct cmd_item *ti;
308 if (as->parms[0].items == 0) {
309 printf("%sCommands are:\n", NName(as->a0name, ": "));
310 for (ts = allSyntax; ts; ts = ts->next) {
311 if ((ts->flags & CMD_ALIAS) || (ts->flags & CMD_HIDDEN))
313 printf("%-15s %s\n", ts->name, (ts->help ? ts->help : ""));
316 /* print out individual help topics */
317 for (ti = as->parms[0].items; ti; ti = ti->next) {
319 ts = FindSyntax(ti->data, &ambig);
320 if (ts && (ts->flags & CMD_HIDDEN))
321 ts = 0; /* no hidden commands */
323 /* print out command name and help */
324 printf("%s%s: %s ", NName(as->a0name, " "), ts->name,
325 (ts->help ? ts->help : ""));
326 ts->a0name = as->a0name;
332 fprintf(stderr, "%sUnknown topic '%s'\n",
333 NName(as->a0name, ": "), ti->data);
335 /* ambiguous, list 'em all */
337 "%sAmbiguous topic '%s'; use 'apropos' to list\n",
338 NName(as->a0name, ": "), ti->data);
340 code = CMD_UNKNOWNCMD;
348 cmd_SetBeforeProc(int (*aproc) (struct cmd_syndesc * ts, void *beforeRock),
357 cmd_SetAfterProc(int (*aproc) (struct cmd_syndesc * ts, void *afterRock),
365 /* thread on list in alphabetical order */
367 SortSyntax(struct cmd_syndesc *as)
369 register struct cmd_syndesc **ld, *ud;
371 for (ld = &allSyntax, ud = *ld; ud; ld = &ud->next, ud = *ld) {
372 if (strcmp(ud->name, as->name) > 0) { /* next guy is bigger than us */
376 /* thread us on the list now */
383 cmd_CreateSyntax(char *aname,
384 int (*aproc) (struct cmd_syndesc * ts, void *arock),
385 void *arock, char *ahelp)
387 register struct cmd_syndesc *td;
389 /* can't have two cmds in no opcode mode */
391 return (struct cmd_syndesc *)0;
393 td = (struct cmd_syndesc *)calloc(1, sizeof(struct cmd_syndesc));
395 td->aliasOf = td; /* treat aliasOf as pointer to real command, no matter what */
397 /* copy in name, etc */
399 td->name = (char *)malloc(strlen(aname) + 1);
401 strcpy(td->name, aname);
407 /* Piggy-back the hidden option onto the help string */
408 if (ahelp == (char *)CMD_HIDDEN) {
409 td->flags |= CMD_HIDDEN;
411 td->help = (char *)malloc(strlen(ahelp) + 1);
413 strcpy(td->help, ahelp);
422 cmd_Seek(td, CMD_HELPPARM);
423 cmd_AddParm(td, "-help", CMD_FLAG, CMD_OPTIONAL, "get detailed help");
430 cmd_CreateAlias(register struct cmd_syndesc *as, char *aname)
432 register struct cmd_syndesc *td;
434 td = (struct cmd_syndesc *)malloc(sizeof(struct cmd_syndesc));
436 memcpy(td, as, sizeof(struct cmd_syndesc));
437 td->name = (char *)malloc(strlen(aname) + 1);
439 strcpy(td->name, aname);
440 td->flags |= CMD_ALIAS;
441 /* if ever free things, make copy of help string, too */
446 /* thread on alias lists */
447 td->nextAlias = as->nextAlias;
451 return 0; /* all done */
455 cmd_IsAdministratorCommand(register struct cmd_syndesc *as)
457 as->flags |= CMD_ADMIN;
462 cmd_Seek(register struct cmd_syndesc *as, int apos)
464 if (apos >= CMD_MAXPARMS)
465 return CMD_EXCESSPARMS;
471 cmd_AddParm(register struct cmd_syndesc *as, char *aname, int atype,
472 afs_int32 aflags, char *ahelp)
474 register struct cmd_parmdesc *tp;
476 if (as->nParms >= CMD_MAXPARMS)
477 return CMD_EXCESSPARMS;
478 tp = &as->parms[as->nParms++];
480 tp->name = (char *)malloc(strlen(aname) + 1);
482 strcpy(tp->name, aname);
487 tp->help = (char *)malloc(strlen(ahelp) + 1);
489 strcpy(tp->help, ahelp);
495 /* add a text item to the end of the parameter list */
497 AddItem(register struct cmd_parmdesc *aparm, register char *aval)
499 register struct cmd_item *ti, *ni;
500 ti = (struct cmd_item *)calloc(1, sizeof(struct cmd_item));
502 ti->data = (char *)malloc(strlen(aval) + 1);
504 strcpy(ti->data, aval);
505 /* now put ti at the *end* of the list */
506 if ((ni = aparm->items)) {
507 for (; ni; ni = ni->next)
509 break; /* skip to last one */
512 aparm->items = ti; /* we're first */
516 /* skip to next non-flag item, if any */
518 AdvanceType(register struct cmd_syndesc *as, register afs_int32 aval)
520 register afs_int32 next;
521 register struct cmd_parmdesc *tp;
523 /* first see if we should try to grab rest of line for this dude */
524 if (as->parms[aval].flags & CMD_EXPANDS)
527 /* if not, find next non-flag used slot */
528 for (next = aval + 1; next < CMD_MAXPARMS; next++) {
529 tp = &as->parms[next];
530 if (tp->type != 0 && tp->type != CMD_FLAG)
536 /* discard parameters filled in by dispatch */
538 ResetSyntax(register struct cmd_syndesc *as)
541 register struct cmd_parmdesc *tp;
542 register struct cmd_item *ti, *ni;
545 for (i = 0; i < CMD_MAXPARMS; i++, tp++) {
549 /* free whole list in both cases, just for fun */
550 for (ti = tp->items; ti; ti = ni) {
564 /* move the expands flag to the last one in the list */
566 SetupExpandsFlag(register struct cmd_syndesc *as)
568 register struct cmd_parmdesc *tp;
569 register int last, i;
572 /* find last CMD_LIST type parameter, optional or not, and make it expandable
573 * if no other dude is expandable */
574 for (i = 0; i < CMD_MAXPARMS; i++) {
576 if (tp->type == CMD_LIST) {
577 if (tp->flags & CMD_EXPANDS)
578 return 0; /* done if already specified */
583 as->parms[last].flags |= CMD_EXPANDS;
587 /*Take the current argv & argc and alter them so that the initialization opcode is made to appear. This is used in cases where the initialization opcode is implicitly invoked.*/
589 InsertInitOpcode(int *aargc, char **aargv)
591 char **newargv; /*Ptr to new, expanded argv space */
592 char *pinitopcode; /*Ptr to space for name of init opcode */
593 int i; /*Loop counter */
595 /*Allocate the new argv array, plus one for the new opcode, plus one more for the trailing null pointer */
596 newargv = (char **)malloc(((*aargc) + 2) * sizeof(char *));
598 fprintf(stderr, "%s: Can't create new argv array with %d+2 slots\n",
603 /*Create space for the initial opcode & fill it in */
604 pinitopcode = (char *)malloc(sizeof(initcmd_opcode));
606 fprintf(stderr, "%s: Can't malloc initial opcode space\n", aargv[0]);
610 strcpy(pinitopcode, initcmd_opcode);
612 /*Move all the items in the old argv into the new argv, in their proper places */
613 for (i = *aargc; i > 1; i--)
614 newargv[i] = aargv[i - 1];
616 /*Slip in the opcode and the trailing null pointer, and bump the argument count up by one for the new opcode */
617 newargv[0] = aargv[0];
618 newargv[1] = pinitopcode;
620 newargv[*aargc] = NULL;
622 /*Return the happy news */
625 } /*InsertInitOpcode */
628 NoParmsOK(register struct cmd_syndesc *as)
631 register struct cmd_parmdesc *td;
633 for (i = 0; i < CMD_MAXPARMS; i++) {
635 if (td->type != 0 && !(td->flags & CMD_OPTIONAL)) {
636 /* found a non-optional (e.g. required) parm, so NoParmsOK
637 * is false (some parms are required) */
644 /* Call the appropriate function, or return syntax error code. Note: if no opcode is specified, an initialization routine exists, and it has NOT been called before, we invoke the special initialization opcode*/
646 cmd_Dispatch(int argc, char **argv)
649 struct cmd_syndesc *ts;
650 struct cmd_parmdesc *tparm;
655 static int initd = 0; /*Is this the first time this routine has been called? */
656 static int initcmdpossible = 1; /*Should be consider parsing the initial command? */
660 /* Add help, apropos commands once */
662 ts = cmd_CreateSyntax("help", HelpProc, (char *)0,
663 "get help on commands");
664 cmd_AddParm(ts, "-topic", CMD_LIST, CMD_OPTIONAL, "help string");
665 cmd_AddParm(ts, "-admin", CMD_FLAG, CMD_OPTIONAL, NULL);
667 ts = cmd_CreateSyntax("apropos", AproposProc, (char *)0,
668 "search by help text");
669 cmd_AddParm(ts, "-topic", CMD_SINGLE, CMD_REQUIRED,
671 ts = cmd_CreateSyntax("version", VersionProc, (char *)0,
673 ts = cmd_CreateSyntax("-version", VersionProc, (char *)0,
675 ts = cmd_CreateSyntax("-help", HelpProc, (char *)0,
677 ts = cmd_CreateSyntax("--version", VersionProc, (char *)0,
679 ts = cmd_CreateSyntax("--help", HelpProc, (char *)0,
684 /*Remember the program name */
689 if (!NoParmsOK(allSyntax)) {
690 printf("%s: Type '%s -help' for help\n", pname, pname);
696 /* if there is an initcmd, don't print an error message, just
697 * setup to use the initcmd below. */
698 if (!(initcmdpossible && FindSyntax(initcmd_opcode, (int *)0))) {
699 printf("%s: Type '%s help' or '%s help <topic>' for help\n",
700 pname, pname, pname);
706 /* Find the syntax descriptor for this command, doing prefix matching properly */
710 ts = (argc < 2 ? 0 : FindSyntax(argv[1], &ambig));
712 /*First token doesn't match a syntax descriptor */
713 if (initcmdpossible) {
714 /*If initial command line handling hasn't been done yet,
715 * see if there is a descriptor for the initialization opcode.
716 * Only try this once. */
718 ts = FindSyntax(initcmd_opcode, (int *)0);
720 /*There is no initialization opcode available, so we declare
723 fprintf(stderr, "%s", NName(pname, ": "));
725 "Ambiguous operation '%s'; type '%shelp' for list\n",
726 argv[1], NName(pname, " "));
728 fprintf(stderr, "%s", NName(pname, ": "));
730 "Unrecognized operation '%s'; type '%shelp' for list\n",
731 argv[1], NName(pname, " "));
733 return (CMD_UNKNOWNCMD);
735 /*Found syntax structure for an initialization opcode. Fix
736 * up argv and argc to relect what the user
737 * ``should have'' typed */
738 if (!(argv = InsertInitOpcode(&argc, argv))) {
740 "%sCan't insert implicit init opcode into command line\n",
742 return (CMD_INTERNALERROR);
745 } /*Initial opcode not yet attempted */
747 /* init cmd already run and no syntax entry found */
749 fprintf(stderr, "%s", NName(pname, ": "));
751 "Ambiguous operation '%s'; type '%shelp' for list\n",
752 argv[1], NName(pname, " "));
754 fprintf(stderr, "%s", NName(pname, ": "));
756 "Unrecognized operation '%s'; type '%shelp' for list\n",
757 argv[1], NName(pname, " "));
759 return CMD_UNKNOWNCMD;
761 } /*Argv[1] is not a valid opcode */
762 } /*Opcodes are defined */
764 /* Found the descriptor; start parsing. curType is the type we're trying to parse */
767 /* We start off parsing in "positional" mode, where tokens are put in
768 * slots positionally. If we find a name that takes args, we go
769 * out of positional mode, and from that point on, expect a switch
770 * before any particular token. */
771 positional = 1; /* Are we still in the positional region of the cmd line? */
772 i = noOpcodes ? 1 : 2;
773 SetupExpandsFlag(ts);
774 for (; i < argc; i++) {
775 /* Only tokens that start with a hyphen and are not followed by a digit
776 * are considered switches. This allow negative numbers. */
777 if ((argv[i][0] == '-') && !isdigit(argv[i][1])) {
779 j = FindType(ts, argv[i]);
782 "%sUnrecognized or ambiguous switch '%s'; type ",
783 NName(pname, ": "), argv[i]);
785 fprintf(stderr, "'%s -help' for detailed help\n",
788 fprintf(stderr, "'%shelp %s' for detailed help\n",
789 NName(argv[0], " "), ts->name);
791 return (CMD_UNKNOWNSWITCH);
793 if (j >= CMD_MAXPARMS) {
794 fprintf(stderr, "%sInternal parsing error\n",
797 return (CMD_INTERNALERROR);
799 if (ts->parms[j].type == CMD_FLAG) {
800 ts->parms[j].items = (struct cmd_item *)&dummy;
804 ts->parms[j].flags |= CMD_PROCESSED;
807 /* Try to fit in this descr */
808 if (curType >= CMD_MAXPARMS) {
809 fprintf(stderr, "%sToo many arguments\n", NName(pname, ": "));
811 return (CMD_TOOMANY);
813 tparm = &ts->parms[curType];
815 if ((tparm->type == 0) || /* No option in this slot */
816 (tparm->type == CMD_FLAG)) { /* A flag (not an argument */
817 /* skipped parm slot */
818 curType++; /* Skip this slot and reprocess this parm */
823 if (!(tparm->flags & CMD_PROCESSED) && (tparm->flags & CMD_HIDE)) {
824 curType++; /* Skip this slot and reprocess this parm */
829 if (tparm->type == CMD_SINGLE) {
831 fprintf(stderr, "%sToo many values after switch %s\n",
832 NName(pname, ": "), tparm->name);
834 return (CMD_NOTLIST);
836 AddItem(tparm, argv[i]); /* Add to end of list */
837 } else if (tparm->type == CMD_LIST) {
838 AddItem(tparm, argv[i]); /* Add to end of list */
840 /* Now, if we're in positional mode, advance to the next item */
842 curType = AdvanceType(ts, curType);
846 /* keep track of this for messages */
847 ts->a0name = argv[0];
849 /* If we make it here, all the parameters are filled in. Check to see if this
850 * is a -help version. Must do this before checking for all required parms,
851 * otherwise it is a real nuisance */
852 if (ts->parms[CMD_HELPPARM].items) {
854 /* Display full help syntax if we don't have subcommands */
861 /* Parsing done, see if we have all of our required parameters */
862 for (i = 0; i < CMD_MAXPARMS; i++) {
863 tparm = &ts->parms[i];
864 if (tparm->type == 0)
865 continue; /* Skipped parm slot */
866 if ((tparm->flags & CMD_PROCESSED) && tparm->items == 0) {
867 fprintf(stderr, "%s The field '%s' isn't completed properly\n",
868 NName(pname, ": "), tparm->name);
870 tparm->flags &= ~CMD_PROCESSED;
873 if (!(tparm->flags & CMD_OPTIONAL) && tparm->items == 0) {
874 fprintf(stderr, "%sMissing required parameter '%s'\n",
875 NName(pname, ": "), tparm->name);
877 tparm->flags &= ~CMD_PROCESSED;
880 tparm->flags &= ~CMD_PROCESSED;
884 * Before calling the beforeProc and afterProc and all the implications
885 * from those calls, check if the help procedure was called and call it now.
887 if ((ts->proc == HelpProc) || (ts->proc == AproposProc)) {
888 i = (*ts->proc) (ts, ts->rock);
893 /* Now, we just call the procedure and return */
895 i = (*beforeProc) (ts, beforeRock);
902 i = (*ts->proc) (ts, ts->rock);
904 (*afterProc) (ts, afterRock);
905 ResetSyntax(ts); /* Reset and free things */
909 /* free token list returned by parseLine */
911 FreeTokens(register struct cmd_token *alist)
913 register struct cmd_token *nlist;
914 for (; alist; alist = nlist) {
922 /* free an argv list returned by parseline */
924 cmd_FreeArgv(register char **argv)
927 for (tp = *argv; tp; argv++, tp = *argv)
932 /* copy back the arg list to the argv array, freeing the cmd_tokens as you go; the actual
933 data is still malloc'd, and will be freed when the caller calls cmd_FreeArgv
937 CopyBackArgs(register struct cmd_token *alist, register char **argv,
938 afs_int32 * an, afs_int32 amaxn)
940 register struct cmd_token *next;
946 *argv = (char *)malloc(strlen(INITSTR) + 1);
948 strcpy(*argv, INITSTR);
954 return CMD_TOOMANY; /* argv is too small for his many parms. */
963 *(argv++) = 0; /* use last slot for terminating null */
964 /* don't count terminating null */
970 quote(register int x)
972 if (x == '"' || x == 39 /* single quote */ )
979 space(register int x)
981 if (x == 0 || x == ' ' || x == '\t' || x == '\n')
988 cmd_ParseLine(char *aline, char **argv, afs_int32 * an, afs_int32 amaxn)
991 register char *tptr = 0;
992 int inToken, inQuote;
993 struct cmd_token *first, *last;
994 register struct cmd_token *ttok;
997 inToken = 0; /* not copying token chars at start */
998 first = (struct cmd_token *)0;
999 last = (struct cmd_token *)0;
1000 inQuote = 0; /* not in a quoted string */
1003 if (tc == 0 || (!inQuote && space(tc))) { /* terminating null gets us in here, too */
1005 inToken = 0; /* end of this token */
1007 return -1; /* should never get here */
1010 ttok = (struct cmd_token *)malloc(sizeof(struct cmd_token));
1012 ttok->next = (struct cmd_token *)0;
1013 ttok->key = (char *)malloc(strlen(tbuffer) + 1);
1015 strcpy(ttok->key, tbuffer);
1025 /* an alpha character */
1030 if (tptr - tbuffer >= sizeof(tbuffer)) {
1032 return CMD_TOOBIG; /* token too long */
1035 /* hit a quote, toggle inQuote flag but don't insert character */
1038 /* insert character */
1043 /* last token flushed 'cause space(0) --> true */
1045 last->next = (struct cmd_token *)0;
1046 return CopyBackArgs(first, argv, an, amaxn);