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>
17 #include <sys/types.h>
24 #include <netinet/in.h>
37 #include "AFS_component_version_number.c"
40 main(int argc, char **argv)
42 register afs_int32 code;
43 struct ubik_client *cstruct = 0;
44 afs_int32 serverList[MAXSERVERS];
45 struct rx_connection *serverconns[MAXSERVERS];
46 struct rx_securityClass *sc;
52 ("uclient: usage is 'uclient -servers ... [-try] [-get] [-inc] [-minc] [-trunc]\n");
56 /* initialize winsock */
57 if (afs_winsockInit() < 0)
60 /* first parse '-servers <server-1> <server-2> ... <server-n>' from command line */
61 code = ubik_ParseClientList(argc, argv, serverList);
63 printf("could not parse server list, code %d\n", code);
67 sc = rxnull_NewClientSecurityObject();
68 for (i = 0; i < MAXSERVERS; i++) {
71 rx_NewConnection(serverList[i], htons(3000), USER_SERVICE_ID,
74 serverconns[i] = (struct rx_connection *)0;
79 /* next, pass list of server rx_connections (in serverconns), and
80 * a place to put the returned client structure that we'll use in
81 * all of our rpc calls (via ubik_Calll) */
82 code = ubik_ClientInit(serverconns, &cstruct);
84 /* check code from init */
86 printf("ubik client init failed with code %d\n", code);
90 /* parse command line for our own operations */
91 for (i = 1; i < argc; i++) {
92 if (!strcmp(argv[i], "-inc")) {
93 /* use ubik_Call to do the work, finding an up server and handling
94 * the job of finding a sync site, if need be */
95 code = ubik_SAMPLE_Inc(cstruct, 0);
96 printf("return code is %d\n", code);
97 } else if (!strcmp(argv[i], "-try")) {
98 code = ubik_SAMPLE_Test(cstruct, 0);
99 printf("return code is %d\n", code);
100 } else if (!strcmp(argv[i], "-qget")) {
101 code = ubik_SAMPLE_QGet(cstruct, 0, &temp);
102 printf("got quick value %d (code %d)\n", temp, code);
103 } else if (!strcmp(argv[i], "-get")) {
104 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
105 printf("got value %d (code %d)\n", temp, code);
106 } else if (!strcmp(argv[i], "-trunc")) {
107 code = ubik_SAMPLE_Trun(cstruct, 0);
108 printf("return code is %d\n", code);
109 } else if (!strcmp(argv[i], "-minc")) {
114 printf("ubik_client: Running minc...\n");
118 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
120 printf("SAMPLE_Get #1 failed with code %ld\n", code);
122 printf("SAMPLE_Get #1 succeeded, got value %d\n", temp);
126 code = ubik_SAMPLE_Inc(cstruct, 0);
128 printf("SAMPLE_Inc #1 failed with code %ld\n",
129 afs_cast_int32(code));
131 printf("SAMPLE_Inc #1 succeeded, incremented integer\n");
134 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
136 printf("SAMPLE_Get #2 failed with code %ld\n", code);
138 printf("SAMPLE_Get #2 succeeded, got value %d\n", temp);
142 code = ubik_SAMPLE_Inc(cstruct, 0);
144 printf("SAMPLE_Inc #2 failed with code %ld\n",
145 afs_cast_int32(code));
147 printf("SAMPLE_Inc #2 succeeded, incremented integer\n");
151 #ifdef AFS_PTHREAD_ENV
152 select(0, 0, 0, 0, &tv);
154 IOMGR_Select(0, 0, 0, 0, &tv);
156 printf("Repeating the SAMPLE operations again...\n");
158 } else if (!strcmp(argv[i], "-mget")) {
164 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
165 printf("got value %d (code %d)\n", temp, code);
167 code = ubik_SAMPLE_Inc(cstruct, 0);
168 printf("update return code is %d\n", code);
170 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
171 printf("got value %d (code %d)\n", temp, code);
173 code = ubik_SAMPLE_Get(cstruct, 0, &temp);
174 printf("got value %d (code %d)\n", temp, code);
178 #ifdef AFS_PTHREAD_ENV
179 select(0, 0, 0, 0, &tv);
181 IOMGR_Select(0, 0, 0, 0, &tv);