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>
15 #include <sys/types.h>
22 #include <netinet/in.h>
35 #include "AFS_component_version_number.c"
38 main(int argc, char **argv)
40 register afs_int32 code;
41 struct ubik_client *cstruct = 0;
42 afs_int32 serverList[MAXSERVERS];
43 struct rx_connection *serverconns[MAXSERVERS];
44 struct rx_securityClass *sc;
50 ("uclient: usage is 'uclient -servers ... [-try] [-get] [-inc] [-minc] [-trunc]\n");
54 /* initialize winsock */
55 if (afs_winsockInit() < 0)
58 /* first parse '-servers <server-1> <server-2> ... <server-n>' from command line */
59 code = ubik_ParseClientList(argc, argv, serverList);
61 printf("could not parse server list, code %d\n", code);
65 sc = rxnull_NewClientSecurityObject();
66 for (i = 0; i < MAXSERVERS; i++) {
69 rx_NewConnection(serverList[i], htons(3000), USER_SERVICE_ID,
72 serverconns[i] = (struct rx_connection *)0;
77 /* next, pass list of server rx_connections (in serverconns), and
78 * a place to put the returned client structure that we'll use in
79 * all of our rpc calls (via ubik_Calll) */
80 code = ubik_ClientInit(serverconns, &cstruct);
82 /* check code from init */
84 printf("ubik client init failed with code %d\n", code);
88 /* parse command line for our own operations */
89 for (i = 1; i < argc; i++) {
90 if (!strcmp(argv[i], "-inc")) {
91 /* use ubik_Call to do the work, finding an up server and handling
92 * the job of finding a sync site, if need be */
93 code = ubik_SAMPLE_Inc(cstruct, 0);
94 printf("return code is %d\n", code);
95 } else if (!strcmp(argv[i], "-try")) {
96 code = ubik_SAMPLE_Test(cstruct, 0);
97 printf("return code is %d\n", code);
98 } else if (!strcmp(argv[i], "-qget")) {
99 code = ubik_SAMPLE_QGet(cstruct, 0, &temp);
100 printf("got quick value %d (code %d)\n", temp, code);
101 } else if (!strcmp(argv[i], "-get")) {
102 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
103 printf("got value %d (code %d)\n", temp, code);
104 } else if (!strcmp(argv[i], "-trunc")) {
105 code = ubik_SAMPLE_Trun(cstruct, 0);
106 printf("return code is %d\n", code);
107 } else if (!strcmp(argv[i], "-minc")) {
112 printf("ubik_client: Running minc...\n");
116 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
118 printf("SAMPLE_Get #1 failed with code %ld\n", code);
120 printf("SAMPLE_Get #1 succeeded, got value %d\n", temp);
124 code = ubik_SAMPLE_Inc(cstruct, 0);
126 printf("SAMPLE_Inc #1 failed with code %ld\n",
127 afs_cast_int32(code));
129 printf("SAMPLE_Inc #1 succeeded, incremented integer\n");
132 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
134 printf("SAMPLE_Get #2 failed with code %ld\n", code);
136 printf("SAMPLE_Get #2 succeeded, got value %d\n", temp);
140 code = ubik_SAMPLE_Inc(cstruct, 0);
142 printf("SAMPLE_Inc #2 failed with code %ld\n",
143 afs_cast_int32(code));
145 printf("SAMPLE_Inc #2 succeeded, incremented integer\n");
149 #ifdef AFS_PTHREAD_ENV
150 select(0, 0, 0, 0, &tv);
152 IOMGR_Select(0, 0, 0, 0, &tv);
154 printf("Repeating the SAMPLE operations again...\n");
156 } else if (!strcmp(argv[i], "-mget")) {
162 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
163 printf("got value %d (code %d)\n", temp, code);
165 code = ubik_SAMPLE_Inc(cstruct, 0);
166 printf("update return code is %d\n", code);
168 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
169 printf("got value %d (code %d)\n", temp, code);
171 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
172 printf("got value %d (code %d)\n", temp, code);
176 #ifdef AFS_PTHREAD_ENV
177 select(0, 0, 0, 0, &tv);
179 IOMGR_Select(0, 0, 0, 0, &tv);