e12f4ba20e564daec0113b818cb5d060bad32150
[kai/samba.git] / source4 / lib / registry / common / reg_display.c
1 /*
2    Unix SMB/CIFS implementation.
3
4    Copyright (C) Gerald Carter                     2001
5    Copyright (C) Tim Potter                        2000
6    Copyright (C) Jelmer Vernooij                                   2004
7  
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24
25 void display_reg_value(REG_VAL *value)
26 {
27         pstring text;
28
29         switch(reg_val_type(value)) {
30         case REG_DWORD:
31                 printf("%s: REG_DWORD: 0x%08x\n", reg_val_name(value), 
32                        *((uint32 *) reg_val_data_blk(value)));
33                 break;
34         case REG_SZ:
35                 rpcstr_pull(text, reg_val_data_blk(value), sizeof(text), reg_val_size(value),
36                             STR_TERMINATE);
37                 printf("%s: REG_SZ: %s\n", reg_val_name(value), text);
38                 break;
39         case REG_BINARY:
40                 printf("%s: REG_BINARY: unknown length value not displayed\n",
41                        reg_val_name(value));
42                 break;
43         case REG_MULTI_SZ: {
44                 uint16 *curstr = (uint16 *) reg_val_data_blk(value);
45                 uint8 *start = reg_val_data_blk(value);
46                 printf("%s: REG_MULTI_SZ:\n", reg_val_name(value));
47                 while ((*curstr != 0) && 
48                        ((uint8 *) curstr < start + reg_val_size(value))) {
49                         rpcstr_pull(text, curstr, sizeof(text), -1, 
50                                     STR_TERMINATE);
51                         printf("  %s\n", text);
52                         curstr += strlen(text) + 1;
53                 }
54         }
55         break;
56         default:
57                 printf("%s: unknown type %d\n", reg_val_name(value), reg_val_type(value));
58         }
59         
60 }