include-afsconfig-before-param-h-20010712
[openafs.git] / src / cmd / test / ctest.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #include <afsconfig.h>
11 #include <afs/param.h>
12
13 RCSID("$Header$");
14
15 #include "cmd.h"
16 #include <stdio.h>
17
18 static cproc1 (as, arock)
19 char *arock;
20 struct cmd_syndesc *as; {
21     printf("in the apple command\n");
22     return 0;
23 }
24
25 static cproc2 (as, arock)
26 char *arock;
27 struct cmd_syndesc *as; {
28     register struct cmd_item *ti;
29     printf("in the pear command\n");
30     printf("number is %s\n", as->parms[0].items->data);
31     if (as->parms[1].items) printf("running unauthenticated\n");
32     for(ti=as->parms[2].items; ti; ti=ti->next) {
33         printf("spotspos %s\n", ti->data);
34     }
35     if (as->parms[8].items)
36         printf("cell name %s\n", as->parms[8].items->data);
37     return 0;
38 }
39
40 main(argc, argv)
41 int argc;
42 char **argv; {
43     register struct cmd_syndesc *ts;
44     
45     ts = cmd_CreateSyntax("apple", cproc1, (char *) 0, "describe apple");
46     cmd_CreateAlias(ts, "appl");
47
48     ts = cmd_CreateSyntax("pear", cproc2, (char *) 0, "describe pear");
49     cmd_AddParm(ts, "-num", CMD_LIST, 0, "number of pears");
50     cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");
51     cmd_AddParm(ts, "-spotpos", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS, 0);
52     cmd_Seek(ts, 8);
53     cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
54     cmd_CreateAlias(ts, "alias");
55     
56     return cmd_Dispatch(argc, argv);
57 }