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>
40 extern int SAMPLE_Inc(), SAMPLE_Test(), SAMPLE_Get(), SAMPLE_Trun(),
45 #include "AFS_component_version_number.c"
51 register afs_int32 code;
52 struct ubik_client *cstruct = 0;
53 afs_int32 serverList[MAXSERVERS];
54 struct rx_connection *serverconns[MAXSERVERS];
55 struct rx_securityClass *sc;
61 ("uclient: usage is 'uclient -servers ... [-try] [-get] [-inc] [-minc] [-trunc]\n");
65 /* initialize winsock */
66 if (afs_winsockInit() < 0)
69 /* first parse '-servers <server-1> <server-2> ... <server-n>' from command line */
70 code = ubik_ParseClientList(argc, argv, serverList);
72 printf("could not parse server list, code %d\n", code);
76 sc = rxnull_NewClientSecurityObject();
77 for (i = 0; i < MAXSERVERS; i++) {
80 rx_NewConnection(serverList[i], htons(3000), USER_SERVICE_ID,
83 serverconns[i] = (struct rx_connection *)0;
88 /* next, pass list of server rx_connections (in serverconns), and
89 * a place to put the returned client structure that we'll use in
90 * all of our rpc calls (via ubik_Calll) */
91 code = ubik_ClientInit(serverconns, &cstruct);
93 /* check code from init */
95 printf("ubik client init failed with code %d\n", code);
99 /* parse command line for our own operations */
100 for (i = 1; i < argc; i++) {
101 if (!strcmp(argv[i], "-inc")) {
102 /* use ubik_Call to do the work, finding an up server and handling
103 * the job of finding a sync site, if need be */
104 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
105 printf("return code is %d\n", code);
106 } else if (!strcmp(argv[i], "-try")) {
107 code = ubik_Call(SAMPLE_Test, cstruct, 0);
108 printf("return code is %d\n", code);
109 } else if (!strcmp(argv[i], "-qget")) {
110 code = ubik_Call(SAMPLE_QGet, cstruct, 0, &temp);
111 printf("got quick value %d (code %d)\n", temp, code);
112 } else if (!strcmp(argv[i], "-get")) {
113 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
114 printf("got value %d (code %d)\n", temp, code);
115 } else if (!strcmp(argv[i], "-trunc")) {
116 code = ubik_Call(SAMPLE_Trun, cstruct, 0);
117 printf("return code is %d\n", code);
118 } else if (!strcmp(argv[i], "-minc")) {
123 printf("ubik_client: Running minc...\n");
127 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
129 printf("SAMPLE_Inc #1 failed with code %ld\n", code);
131 printf("SAMPLE_Get #1 succeeded, got value %d\n", temp);
135 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
137 printf("SAMPLE_Inc #1 failed with code %ld\n", code);
139 printf("SAMPLE_Inc #1 succeeded, incremented integer\n");
142 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
144 printf("SAMPLE_Get #2 failed with code %ld\n", code);
146 printf("SAMPLE_Get #2 succeeded, got value %d\n", temp);
150 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
152 printf("SAMPLE_Inc #2 failed with code %ld\n", code);
154 printf("SAMPLE_Inc #2 succeeded, incremented integer\n");
158 IOMGR_Select(0, 0, 0, 0, &tv);
159 printf("Repeating the SAMPLE operations again...\n");
161 } else if (!strcmp(argv[i], "-mget")) {
167 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
168 printf("got value %d (code %d)\n", temp, code);
170 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
171 printf("update return code is %d\n", code);
173 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
174 printf("got value %d (code %d)\n", temp, code);
176 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
177 printf("got value %d (code %d)\n", temp, code);
181 IOMGR_Select(0, 0, 0, 0, &tv);