Commit | Line | Data |
---|---|---|
805e021f CE |
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 | #include <roken.h> | |
14 | ||
15 | #include <afs/cmd.h> | |
16 | ||
17 | static int | |
18 | cproc1(struct cmd_syndesc *as, void *arock) | |
19 | { | |
20 | printf("in the apple command\n"); | |
21 | return 0; | |
22 | } | |
23 | ||
24 | static int | |
25 | cproc2(struct cmd_syndesc *as, void *arock) | |
26 | { | |
27 | struct cmd_item *ti; | |
28 | printf("in the pear command\n"); | |
29 | printf("number is %s\n", as->parms[0].items->data); | |
30 | if (as->parms[1].items) | |
31 | 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 | int | |
41 | main(int argc, char **argv) | |
42 | { | |
43 | struct cmd_syndesc *ts; | |
44 | ||
45 | ts = cmd_CreateSyntax("apple", cproc1, NULL, 0, "describe apple"); | |
46 | cmd_CreateAlias(ts, "appl"); | |
47 | ||
48 | ts = cmd_CreateSyntax("pear", cproc2, NULL, 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 | } |