1 | /*tests cac_RegSetVal()*/
|
---|
2 |
|
---|
3 | #include "libmsrpc.h"
|
---|
4 | #include "test_util.h"
|
---|
5 |
|
---|
6 | int main(int argc, char **argv) {
|
---|
7 | CacServerHandle *hnd = NULL;
|
---|
8 | TALLOC_CTX *mem_ctx = NULL;
|
---|
9 |
|
---|
10 | fstring tmp;
|
---|
11 |
|
---|
12 | mem_ctx = talloc_init("regsetval");
|
---|
13 |
|
---|
14 | hnd = cac_NewServerHandle(True);
|
---|
15 |
|
---|
16 | cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
|
---|
17 |
|
---|
18 | cac_parse_cmd_line(argc, argv, hnd);
|
---|
19 |
|
---|
20 | if(!cac_Connect(hnd, NULL)) {
|
---|
21 | fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
|
---|
22 | exit(-1);
|
---|
23 | }
|
---|
24 |
|
---|
25 | printf("enter key to open: \n");
|
---|
26 | scanf("%s", tmp);
|
---|
27 |
|
---|
28 | struct RegOpenKey rok;
|
---|
29 | ZERO_STRUCT(rok);
|
---|
30 |
|
---|
31 | rok.in.name = talloc_strdup(mem_ctx, tmp);
|
---|
32 | rok.in.access = REG_KEY_ALL;
|
---|
33 |
|
---|
34 | if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
|
---|
35 | fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status));
|
---|
36 | exit(-1);
|
---|
37 | }
|
---|
38 |
|
---|
39 | struct RegSetValue rsv;
|
---|
40 | ZERO_STRUCT(rsv);
|
---|
41 |
|
---|
42 | rsv.in.key = rok.out.key;
|
---|
43 |
|
---|
44 | cactest_reg_input_val(mem_ctx, &rsv.in.type, &rsv.in.val_name, &rsv.in.value);
|
---|
45 |
|
---|
46 | if(!cac_RegSetValue(hnd, mem_ctx, &rsv)) {
|
---|
47 | fprintf(stderr, "Could not set value. Error: %s\n", nt_errstr(hnd->status));
|
---|
48 | }
|
---|
49 |
|
---|
50 | cac_RegClose(hnd, mem_ctx, rok.out.key);
|
---|
51 |
|
---|
52 | cac_FreeHandle(hnd);
|
---|
53 |
|
---|
54 | talloc_destroy(mem_ctx);
|
---|
55 |
|
---|
56 | return 0;
|
---|
57 | }
|
---|
58 |
|
---|
59 |
|
---|