r10909: Give better shutdown messages
[Samba/bb.git] / source3 / registry / reg_util.c
blob9f19db2646a12a61f2926b5e861accb5c15b180a
1 /*
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 2 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, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 /* Implementation of registry frontend view functions. */
23 #include "includes.h"
25 #undef DBGC_CLASS
26 #define DBGC_CLASS DBGC_RPC_SRV
28 /***********************************************************************
29 Utility function for splitting the base path of a registry path off
30 by setting base and new_path to the apprapriate offsets withing the
31 path.
33 WARNING!! Does modify the original string!
34 ***********************************************************************/
36 BOOL reg_split_path( char *path, char **base, char **new_path )
38 char *p;
40 *new_path = *base = NULL;
42 if ( !path)
43 return False;
45 *base = path;
47 p = strchr( path, '\\' );
49 if ( p ) {
50 *p = '\0';
51 *new_path = p+1;
54 return True;
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
61 path.
63 WARNING!! Does modify the original string!
64 ***********************************************************************/
66 BOOL reg_split_key( char *path, char **base, char **key )
68 char *p;
70 *key = *base = NULL;
72 if ( !path)
73 return False;
75 *base = path;
77 p = strrchr( path, '\\' );
79 if ( p ) {
80 *p = '\0';
81 *key = p+1;
84 return True;
88 /**********************************************************************
89 The full path to the registry key is used as database after the
90 \'s are converted to /'s. Key string is also normalized to UPPER
91 case.
92 **********************************************************************/
94 void normalize_reg_path( pstring keyname )
96 pstring_sub( keyname, "\\", "/" );
97 strupper_m( keyname );
100 /**********************************************************************
101 move to next non-delimter character
102 *********************************************************************/
104 char* reg_remaining_path( const char *key )
106 static pstring new_path;
107 char *p;
109 if ( !key || !*key )
110 return NULL;
112 pstrcpy( new_path, key );
113 /* normalize_reg_path( new_path ); */
115 if ( !(p = strchr( new_path, '\\' )) )
117 if ( !(p = strchr( new_path, '/' )) )
118 p = new_path;
119 else
120 p++;
122 else
123 p++;
125 return p;