Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

regsetval.c

Go to the documentation of this file.
00001 /*tests cac_RegSetVal()*/
00002 
00003 #include "libmsrpc.h"
00004 #include "test_util.h"
00005 
00006 int main(int argc, char **argv) {
00007    CacServerHandle *hnd = NULL;
00008    TALLOC_CTX *mem_ctx  = NULL;
00009 
00010    fstring tmp;
00011    
00012    mem_ctx = talloc_init("regsetval");
00013 
00014    hnd = cac_NewServerHandle(True);
00015 
00016    cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);
00017 
00018    cac_parse_cmd_line(argc, argv, hnd);
00019 
00020    if(!cac_Connect(hnd, NULL)) {
00021       fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
00022       exit(-1);
00023    }
00024 
00025    printf("enter key to open: \n");
00026    scanf("%s", tmp);
00027 
00028    struct RegOpenKey rok;
00029    ZERO_STRUCT(rok);
00030 
00031    rok.in.name = talloc_strdup(mem_ctx, tmp);
00032    rok.in.access = REG_KEY_ALL;
00033 
00034    if(!cac_RegOpenKey(hnd, mem_ctx, &rok)) {
00035       fprintf(stderr, "Could not open key %s. Error %s\n", rok.in.name, nt_errstr(hnd->status));
00036       exit(-1);
00037    }
00038 
00039    struct RegSetValue rsv;
00040    ZERO_STRUCT(rsv);
00041 
00042    rsv.in.key = rok.out.key;
00043 
00044    cactest_reg_input_val(mem_ctx, &rsv.in.type, &rsv.in.val_name, &rsv.in.value);
00045 
00046    if(!cac_RegSetValue(hnd, mem_ctx, &rsv)) {
00047       fprintf(stderr, "Could not set value. Error: %s\n", nt_errstr(hnd->status));
00048    }
00049 
00050    cac_RegClose(hnd, mem_ctx, rok.out.key);
00051 
00052    cac_FreeHandle(hnd);
00053 
00054    talloc_destroy(mem_ctx);
00055 
00056    return 0;
00057 }
00058 
00059 

© sourcejam.com 2005-2008