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>
15 #include <afs/com_err.h>
19 cproc1(struct cmd_syndesc
*as
, void *arock
)
21 printf("in the apple command\n");
26 cproc2(struct cmd_syndesc
*as
, void *arock
)
29 printf("in the pear command\n");
30 printf("number is %s\n", as
->parms
[0].items
->data
);
31 if (as
->parms
[1].items
)
32 printf("running unauthenticated\n");
33 for (ti
= as
->parms
[2].items
; ti
; ti
= ti
->next
) {
34 printf("spotspos %s\n", ti
->data
);
36 if (as
->parms
[8].items
)
37 printf("cell name %s\n", as
->parms
[8].items
->data
);
42 cproc3(struct cmd_syndesc
*as
, void *arock
)
48 main(int argc
, char **argv
)
50 struct cmd_syndesc
*ts
;
57 initialize_CMD_error_table();
59 ts
= cmd_CreateSyntax("apple", cproc1
, NULL
, 0, "describe apple");
61 ts
= cmd_CreateSyntax("pear", cproc2
, NULL
, 0, "describe pear");
62 cmd_AddParm(ts
, "-num", CMD_LIST
, 0, "number of pears");
63 cmd_AddParm(ts
, "-noauth", CMD_FLAG
, CMD_OPTIONAL
, "don't authenticate");
64 cmd_AddParm(ts
, "-spotpos", CMD_LIST
, CMD_OPTIONAL
| CMD_EXPANDS
, 0);
66 cmd_AddParm(ts
, "-cell", CMD_SINGLE
, CMD_OPTIONAL
, "cell name");
67 cmd_CreateAlias(ts
, "alias");
69 ts
= cmd_CreateSyntax("quit", cproc3
, 0, 0, "quit");
76 code
= cmd_ParseLine(tline
, tv
, &tc
, 100);
78 printf("itest: parsing failure: %s\n", afs_error_message(code
));
81 code
= cmd_Dispatch(tc
, tv
);
84 printf("itest: execution failed: %s\n", afs_error_message(code
));