1 /*tests cac_RegOpenKey()*/
6 CacServerHandle
*hnd
= NULL
;
7 TALLOC_CTX
*mem_ctx
= NULL
;
14 mem_ctx
= talloc_init("regopenkey");
16 hnd
= cac_NewServerHandle(True
);
18 printf("Enter server to connect to: ");
19 fscanf(stdin
, "%s", hnd
->server
);
21 printf("How many keys do you want to open?: ");
22 fscanf(stdin
, "%d", &num_keys
);
24 key_names
= TALLOC_ARRAY(mem_ctx
, fstring
, num_keys
);
26 fprintf(stderr
, "No memory\n");
30 for(i
= 0; i
< num_keys
; i
++) {
31 printf("Enter key to open: ");
32 fscanf(stdin
, "%s", key_names
[i
]);
35 if(!cac_Connect(hnd
, NULL
)) {
36 fprintf(stderr
, "Could not connect to server.\n Error: %s.\n errno: %s\n", nt_errstr(hnd
->status
), strerror(errno
));
41 for(i
= 0; i
< num_keys
; i
++) {
42 printf("trying to open key %s...\n", key_names
[i
]);
44 struct RegOpenKey rok
;
47 rok
.in
.parent_key
= NULL
;
48 rok
.in
.name
= key_names
[i
];
49 rok
.in
.access
= REG_KEY_ALL
;
51 if(!cac_RegOpenKey(hnd
, mem_ctx
, &rok
)) {
52 fprintf(stderr
, "Could not open key %s\n Error: %s\n", rok
.in
.name
, nt_errstr(hnd
->status
));
56 printf("closing key %s...\n", key_names
[i
]);
58 if(!cac_RegClose(hnd
, mem_ctx
, rok
.out
.key
)) {
59 fprintf(stderr
, "Could not close handle %s\n", nt_errstr(hnd
->status
));
65 talloc_destroy(mem_ctx
);