summaryrefslogtreecommitdiff
path: root/source3/registry/reg_dynamic.c
blob: 97cb46261569d1461889c623792eb391c3e385d3 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/* 
 *  Unix SMB/CIFS implementation.
 *  Virtual Windows Registry Layer
 *  Copyright (C) Gerald Carter                     2002-2005
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

/* Implementation of registry frontend view functions. */

#include "includes.h"

#undef DBGC_CLASS
#define DBGC_CLASS DBGC_REGISTRY

struct reg_dyn_values {
	const char *path;
	int (*fetch_values) ( REGVAL_CTR *val );
};

/***********************************************************************
 Structure holding the registry paths and pointers to the value 
 enumeration functions
***********************************************************************/

static struct reg_dyn_values dynamic_values[] = {
	{ NULL, NULL }
};

/***********************************************************************
***********************************************************************/

int fetch_dynamic_reg_values( REGISTRY_KEY *key, REGVAL_CTR *val )
{
	int i;
	char *path = NULL;
	TALLOC_CTX *ctx = talloc_tos();

	path = talloc_strdup(ctx, key->name);
	if (!path) {
		return -1;
	}
	path = normalize_reg_path(ctx, path);
	if (!path) {
		return -1;
	}

	for ( i=0; dynamic_values[i].path; i++ ) {
		if ( strcmp( path, dynamic_values[i].path ) == 0 )
			return dynamic_values[i].fetch_values( val );
	}

	return -1;
}

/***********************************************************************
***********************************************************************/

bool check_dynamic_reg_values( REGISTRY_KEY *key )
{
	int i;
	char *path = NULL;
	TALLOC_CTX *ctx = talloc_tos();

	path = talloc_strdup(ctx, key->name);
	if (!path) {
		return false;
	}
	path = normalize_reg_path(ctx, path);
	if (!path) {
		return false;
	}

	for ( i=0; dynamic_values[i].path; i++ ) {
		/* can't write to dynamic keys */
		if ( strcmp( path, dynamic_values[i].path ) == 0 )
			return true;
	}

	return false;
}