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>
25 #include "AFS_component_version_number.c"
28 main(int argc
, char **argv
)
31 struct ubik_client
*cstruct
= 0;
32 afs_uint32 serverList
[MAXSERVERS
];
33 struct rx_connection
*serverconns
[MAXSERVERS
];
34 struct rx_securityClass
*sc
;
40 ("uclient: usage is 'uclient -servers ... [-try] [-get] [-inc] [-minc] [-trunc]\n");
44 /* initialize winsock */
45 if (afs_winsockInit() < 0)
48 /* first parse '-servers <server-1> <server-2> ... <server-n>' from command line */
49 code
= ubik_ParseClientList(argc
, argv
, serverList
);
51 printf("could not parse server list, code %d\n", code
);
55 sc
= rxnull_NewClientSecurityObject();
56 for (i
= 0; i
< MAXSERVERS
; i
++) {
59 rx_NewConnection(serverList
[i
], htons(3000), USER_SERVICE_ID
,
62 serverconns
[i
] = (struct rx_connection
*)0;
67 /* next, pass list of server rx_connections (in serverconns), and
68 * a place to put the returned client structure that we'll use in
69 * all of our rpc calls (via ubik_Calll) */
70 code
= ubik_ClientInit(serverconns
, &cstruct
);
72 /* check code from init */
74 printf("ubik client init failed with code %d\n", code
);
78 /* parse command line for our own operations */
79 for (i
= 1; i
< argc
; i
++) {
80 if (!strcmp(argv
[i
], "-inc")) {
81 /* use ubik_Call to do the work, finding an up server and handling
82 * the job of finding a sync site, if need be */
83 code
= ubik_SAMPLE_Inc(cstruct
, 0);
84 printf("return code is %d\n", code
);
85 } else if (!strcmp(argv
[i
], "-try")) {
86 code
= ubik_SAMPLE_Test(cstruct
, 0);
87 printf("return code is %d\n", code
);
88 } else if (!strcmp(argv
[i
], "-qget")) {
89 code
= ubik_SAMPLE_QGet(cstruct
, 0, &temp
);
90 printf("got quick value %d (code %d)\n", temp
, code
);
91 } else if (!strcmp(argv
[i
], "-get")) {
92 code
= ubik_SAMPLE_Get(cstruct
, 0, &temp
);
93 printf("got value %d (code %d)\n", temp
, code
);
94 } else if (!strcmp(argv
[i
], "-trunc")) {
95 code
= ubik_SAMPLE_Trun(cstruct
, 0);
96 printf("return code is %d\n", code
);
97 } else if (!strcmp(argv
[i
], "-minc")) {
102 printf("ubik_client: Running minc...\n");
106 code
= ubik_SAMPLE_Get(cstruct
, 0, &temp
);
108 printf("SAMPLE_Get #1 failed with code %ld\n",
109 afs_printable_int32_ld(code
));
111 printf("SAMPLE_Get #1 succeeded, got value %ld\n",
112 afs_printable_int32_ld(temp
));
116 code
= ubik_SAMPLE_Inc(cstruct
, 0);
118 printf("SAMPLE_Inc #1 failed with code %ld\n",
119 afs_printable_int32_ld(code
));
121 printf("SAMPLE_Inc #1 succeeded, incremented integer\n");
124 code
= ubik_SAMPLE_Get(cstruct
, 0, &temp
);
126 printf("SAMPLE_Get #2 failed with code %ld\n",
127 afs_printable_int32_ld(code
));
129 printf("SAMPLE_Get #2 succeeded, got value %ld\n",
130 afs_printable_int32_ld(temp
));
134 code
= ubik_SAMPLE_Inc(cstruct
, 0);
136 printf("SAMPLE_Inc #2 failed with code %ld\n",
137 afs_printable_int32_ld(code
));
139 printf("SAMPLE_Inc #2 succeeded, incremented integer\n");
143 #ifdef AFS_PTHREAD_ENV
144 select(0, 0, 0, 0, &tv
);
146 IOMGR_Select(0, 0, 0, 0, &tv
);
148 printf("Repeating the SAMPLE operations again...\n");
150 } else if (!strcmp(argv
[i
], "-mget")) {
156 code
= ubik_SAMPLE_Get(cstruct
, 0, &temp
);
157 printf("got value %d (code %d)\n", temp
, code
);
159 code
= ubik_SAMPLE_Inc(cstruct
, 0);
160 printf("update return code is %d\n", code
);
162 code
= ubik_SAMPLE_Get(cstruct
, 0, &temp
);
163 printf("got value %d (code %d)\n", temp
, code
);
165 code
= ubik_SAMPLE_Get(cstruct
, 0, &temp
);
166 printf("got value %d (code %d)\n", temp
, code
);
170 #ifdef AFS_PTHREAD_ENV
171 select(0, 0, 0, 0, &tv
);
173 IOMGR_Select(0, 0, 0, 0, &tv
);