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>
16 #include <sys/types.h>
23 #include <netinet/in.h>
34 extern int SAMPLE_Inc(), SAMPLE_Test(), SAMPLE_Get(), SAMPLE_Trun(),
39 #include "AFS_component_version_number.c"
45 register afs_int32 code;
46 struct ubik_client *cstruct = 0;
47 afs_int32 serverList[MAXSERVERS];
48 struct rx_connection *serverconns[MAXSERVERS];
49 struct rx_securityClass *sc;
55 ("uclient: usage is 'uclient -servers ... [-try] [-get] [-inc] [-minc] [-trunc]\n");
59 /* initialize winsock */
60 if (afs_winsockInit() < 0)
63 /* first parse '-servers <server-1> <server-2> ... <server-n>' from command line */
64 code = ubik_ParseClientList(argc, argv, serverList);
66 printf("could not parse server list, code %d\n", code);
70 sc = rxnull_NewClientSecurityObject();
71 for (i = 0; i < MAXSERVERS; i++) {
74 rx_NewConnection(serverList[i], htons(3000), USER_SERVICE_ID,
77 serverconns[i] = (struct rx_connection *)0;
82 /* next, pass list of server rx_connections (in serverconns), and
83 * a place to put the returned client structure that we'll use in
84 * all of our rpc calls (via ubik_Calll) */
85 code = ubik_ClientInit(serverconns, &cstruct);
87 /* check code from init */
89 printf("ubik client init failed with code %d\n", code);
93 /* parse command line for our own operations */
94 for (i = 1; i < argc; i++) {
95 if (!strcmp(argv[i], "-inc")) {
96 /* use ubik_Call to do the work, finding an up server and handling
97 * the job of finding a sync site, if need be */
98 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
99 printf("return code is %d\n", code);
100 } else if (!strcmp(argv[i], "-try")) {
101 code = ubik_Call(SAMPLE_Test, cstruct, 0);
102 printf("return code is %d\n", code);
103 } else if (!strcmp(argv[i], "-qget")) {
104 code = ubik_Call(SAMPLE_QGet, cstruct, 0, &temp);
105 printf("got quick value %d (code %d)\n", temp, code);
106 } else if (!strcmp(argv[i], "-get")) {
107 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
108 printf("got value %d (code %d)\n", temp, code);
109 } else if (!strcmp(argv[i], "-trunc")) {
110 code = ubik_Call(SAMPLE_Trun, cstruct, 0);
111 printf("return code is %d\n", code);
112 } else if (!strcmp(argv[i], "-minc")) {
117 printf("ubik_client: Running minc...\n");
121 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
123 printf("SAMPLE_Inc #1 failed with code %ld\n", code);
125 printf("SAMPLE_Get #1 succeeded, got value %d\n", temp);
129 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
131 printf("SAMPLE_Inc #1 failed with code %ld\n", code);
133 printf("SAMPLE_Inc #1 succeeded, incremented integer\n");
136 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
138 printf("SAMPLE_Get #2 failed with code %ld\n", code);
140 printf("SAMPLE_Get #2 succeeded, got value %d\n", temp);
144 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
146 printf("SAMPLE_Inc #2 failed with code %ld\n", code);
148 printf("SAMPLE_Inc #2 succeeded, incremented integer\n");
152 IOMGR_Select(0, 0, 0, 0, &tv);
153 printf("Repeating the SAMPLE operations again...\n");
155 } else if (!strcmp(argv[i], "-mget")) {
161 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
162 printf("got value %d (code %d)\n", temp, code);
164 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
165 printf("update return code is %d\n", code);
167 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
168 printf("got value %d (code %d)\n", temp, code);
170 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
171 printf("got value %d (code %d)\n", temp, code);
175 IOMGR_Select(0, 0, 0, 0, &tv);