forked from jlucid/capi
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathguid.c
54 lines (46 loc) · 1.08 KB
/
guid.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* File name: guid.c */
#include "common.h"
int main() {
J i, j;
I handle;
I portnumber= 12345;
S hostname= "localhost";
S usernamePassword= "kdb:pass";
K singleGuid, multiGuid;
handle= khpu(hostname, portnumber, usernamePassword);
if(!handleOk(handle)) {
m9();
return EXIT_FAILURE;
}
singleGuid= k(handle, "rand 0Ng", (K) 0);
if(isRemoteErr(singleGuid)) {
kclose(handle);
m9();
return EXIT_FAILURE;
}
printf("Single guid: type %d\n", singleGuid->t);
printf("Single guid: length %lld\n", singleGuid->n);
for(i= 0; i < 16; i++) {
printf("%02x", kU(singleGuid)->g[i]);
}
r0(singleGuid);
printf("\n");
multiGuid= k(handle, "2?0Ng", (K) 0);
if(isRemoteErr(multiGuid)) {
kclose(handle);
m9();
return EXIT_FAILURE;
}
printf("Multi guid: type %d\n", multiGuid->t);
printf("Multi guid: length %lld\n", multiGuid->n);
for(i= 0; i < multiGuid->n; i++) {
for(j= 0; j < 16; j++) {
printf("%02x", kU(multiGuid)[i].g[j]);
}
printf("\n");
}
r0(multiGuid);
kclose(handle);
m9();
return EXIT_SUCCESS;
}