2 * (C) COPYRIGHT IBM CORPORATION 1987, 1988
3 * LICENSED MATERIALS - PROPERTY OF IBM
14 #include <netinet/in.h>
24 extern int SAMPLE_Inc(), SAMPLE_Test(), SAMPLE_Get(),
25 SAMPLE_Trun(), SAMPLE_QGet();
29 #include "AFS_component_version_number.c"
34 register afs_int32 code;
35 struct ubik_client *cstruct=0;
36 afs_int32 serverList[MAXSERVERS];
37 struct rx_connection *serverconns[MAXSERVERS];
38 struct rx_securityClass *sc;
43 printf("uclient: usage is 'uclient -servers ... [-try] [-get] [-inc] [-minc] [-trunc]\n");
47 /* initialize winsock */
48 if (afs_winsockInit()<0)
51 /* first parse '-servers <server-1> <server-2> ... <server-n>' from command line */
52 code = ubik_ParseClientList(argc, argv, serverList);
54 printf("could not parse server list, code %d\n", code);
58 sc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
59 for (i=0; i<MAXSERVERS; i++) {
61 serverconns[i] = rx_NewConnection(serverList[i], htons(3000),
62 USER_SERVICE_ID, sc, 0);
64 serverconns[i] = (struct rx_connection *)0;
69 /* next, pass list of server rx_connections (in serverconns), and
70 * a place to put the returned client structure that we'll use in
71 * all of our rpc calls (via ubik_Calll) */
72 code = ubik_ClientInit(serverconns, &cstruct);
74 /* check code from init */
76 printf("ubik client init failed with code %d\n", code);
80 /* parse command line for our own operations */
82 if (!strcmp(argv[i], "-inc")) {
83 /* use ubik_Call to do the work, finding an up server and handling
84 the job of finding a sync site, if need be */
85 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
86 printf("return code is %d\n", code);
88 else if (!strcmp(argv[i], "-try")) {
89 code = ubik_Call(SAMPLE_Test, cstruct, 0);
90 printf("return code is %d\n", code);
92 else if (!strcmp(argv[i], "-qget")) {
93 code = ubik_Call(SAMPLE_QGet, cstruct, 0, &temp);
94 printf("got quick value %d (code %d)\n", temp, code);
96 else if (!strcmp(argv[i], "-get")) {
97 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
98 printf("got value %d (code %d)\n", temp, code);
100 else if (!strcmp(argv[i], "-trunc")) {
101 code = ubik_Call(SAMPLE_Trun, cstruct, 0);
102 printf("return code is %d\n", code);
104 else if (!strcmp(argv[i], "-minc")) {
107 tv.tv_sec = 1; tv.tv_usec = 0;
108 printf("ubik_client: Running minc...\n");
112 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
114 printf("SAMPLE_Inc #1 failed with code %ld\n", code);
117 printf("SAMPLE_Get #1 succeeded, got value %d\n", temp);
121 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
123 printf("SAMPLE_Inc #1 failed with code %ld\n", code);
126 printf("SAMPLE_Inc #1 succeeded, incremented integer\n");
129 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
131 printf("SAMPLE_Get #2 failed with code %ld\n", code);
134 printf("SAMPLE_Get #2 succeeded, got value %d\n", temp);
138 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
140 printf("SAMPLE_Inc #2 failed with code %ld\n", code);
141 else printf("SAMPLE_Inc #2 succeeded, incremented integer\n");
143 tv.tv_sec = 1; tv.tv_usec = 0;
144 IOMGR_Select(0, 0, 0, 0, &tv);
145 printf("Repeating the SAMPLE operations again...\n");
148 else if (!strcmp(argv[i], "-mget")) {
154 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
155 printf("got value %d (code %d)\n", temp, code);
157 code = ubik_Call(SAMPLE_Inc, cstruct, 0);
158 printf("update return code is %d\n", code);
160 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
161 printf("got value %d (code %d)\n", temp, code);
163 code = ubik_Call(SAMPLE_Get, cstruct, 0, &temp);
164 printf("got value %d (code %d)\n", temp, code);
168 IOMGR_Select(0, 0, 0, 0, &tv);