2 * Unix SMB/CIFS implementation.
3 * Virtual Windows Registry Layer (utility functions)
4 * Copyright (C) Gerald Carter 2002-2005
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 /* Implementation of registry frontend view functions. */
24 #include "reg_util_internal.h"
27 #define DBGC_CLASS DBGC_REGISTRY
29 /***********************************************************************
30 Utility function for splitting the base path of a registry path off
31 by setting base and new_path to the apprapriate offsets withing the
34 WARNING!! Does modify the original string!
35 ***********************************************************************/
37 bool reg_split_path(char *path
, char **base
, char **new_path
)
41 *new_path
= *base
= NULL
;
48 p
= strchr(path
, '\\');
58 /***********************************************************************
59 Utility function for splitting the base path of a registry path off
60 by setting base and new_path to the appropriate offsets withing the
63 WARNING!! Does modify the original string!
64 ***********************************************************************/
66 bool reg_split_key(char *path
, char **base
, char **key
)
78 p
= strrchr(path
, '\\');
89 * The full path to the registry key is used as database key.
90 * Leading and trailing '\' characters are stripped.
91 * Key string is also normalized to UPPER case.
94 char *normalize_reg_path(TALLOC_CTX
*ctx
, const char *keyname
)
99 /* skip leading '\' chars */
105 nkeyname
= talloc_strdup(ctx
, p
);
106 if (nkeyname
== NULL
) {
110 /* strip trailing '\' chars */
111 p
= strrchr(nkeyname
, '\\');
112 while ((p
!= NULL
) && (p
[1] == '\0')) {
114 p
= strrchr(nkeyname
, '\\');
117 strupper_m(nkeyname
);
122 /**********************************************************************
123 move to next non-delimter character
124 *********************************************************************/
126 char *reg_remaining_path(TALLOC_CTX
*ctx
, const char *key
)
128 char *new_path
= NULL
;
135 new_path
= talloc_strdup(ctx
, key
);
139 /* normalize_reg_path( new_path ); */
140 if (!(p
= strchr(new_path
, '\\')) ) {