4d1bcbb8389c38047fa17c1f7a89a103ba2c19a7
[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
14     ("$Header$");
15
16 #include "cmd.h"
17 #include <stdio.h>
18
19 static int
20 cproc1(struct cmd_syndesc *as, void *arock)
21 {
22     printf("in the apple command\n");
23     return 0;
24 }
25
26 static int
27 cproc2(struct cmd_syndesc *as, void *arock)
28 {
29     register struct cmd_item *ti;
30     printf("in the pear command\n");
31     printf("number is %s\n", as->parms[0].items->data);
32     if (as->parms[1].items)
33         printf("running unauthenticated\n");
34     for (ti = as->parms[2].items; ti; ti = ti->next) {
35         printf("spotspos %s\n", ti->data);
36     }
37     if (as->parms[8].items)
38         printf("cell name %s\n", as->parms[8].items->data);
39     return 0;
40 }
41
42 int
43 main(int argc, char **argv)
44 {
45     register struct cmd_syndesc *ts;
46
47     ts = cmd_CreateSyntax("apple", cproc1, NULL, "describe apple");
48     cmd_CreateAlias(ts, "appl");
49
50     ts = cmd_CreateSyntax("pear", cproc2, NULL, "describe pear");
51     cmd_AddParm(ts, "-num", CMD_LIST, 0, "number of pears");
52     cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "don't authenticate");
53     cmd_AddParm(ts, "-spotpos", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS, 0);
54     cmd_Seek(ts, 8);
55     cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
56     cmd_CreateAlias(ts, "alias");
57
58     return cmd_Dispatch(argc, argv);
59 }