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