2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
4 * Copyright (C) Gerald Carter 2002.
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 virtual views for printing information */
26 #define DBGC_CLASS DBGC_RPC_SRV
28 #define MAX_TOP_LEVEL_KEYS 3
30 /* some symbolic indexes into the top_level_keys */
32 #define KEY_INDEX_ENVIR 0
33 #define KEY_INDEX_FORMS 1
34 #define KEY_INDEX_PRINTER 2
36 static char *top_level_keys
[MAX_TOP_LEVEL_KEYS
] = {
42 /**********************************************************************
43 It is safe to assume that every registry path passed into on of
44 the exported functions here begins with KEY_PRINTING else
45 these functions would have never been called. This is a small utility
46 function to strip the beginning of the path and make a copy that the
47 caller can modify. Note that the caller is responsible for releasing
48 the memory allocated here.
49 **********************************************************************/
51 static char* trim_reg_path( char *path
)
55 p
= path
+ strlen(KEY_PRINTING
);
63 /**********************************************************************
64 handle enumeration of subkeys below KEY_PRINTING.
65 *********************************************************************/
67 static int handle_printing_subpath( char *key
, char **subkeys
, uint32 index
)
75 * break off the first part of the path
76 * topmost base **must** be one of the strings
81 p
= strchr( key
, '\\' );
85 for ( i
=0; i
<MAX_TOP_LEVEL_KEYS
; i
++ ) {
86 if ( StrCaseCmp( top_level_keys
[i
], base
) == 0 )
90 if ( !(i
< MAX_TOP_LEVEL_KEYS
) )
93 /* Call routine to handle each top level key */
102 case KEY_INDEX_PRINTER
:
105 /* default case for top level key that has no handler */
116 /**********************************************************************
117 Enumerate registry subkey names given a registry path.
118 Caller is responsible for freeing memory to **subkeys
119 *********************************************************************/
121 int printing_subkey_info( char *key
, char **subkeys
)
124 BOOL top_level
= False
;
127 DEBUG(10,("printing_subkey_info: key=>[%s]\n", key
));
129 path
= trim_reg_path( key
);
131 /* check to see if we are dealing with the top level key */
137 if ( ! (*subkeys
= malloc( sizeof(top_level_keys
) )) )
140 num_subkeys
= MAX_TOP_LEVEL_KEYS
;
141 memcpy( *subkeys
, top_level_keys
, sizeof(top_level_keys
) );
144 num_subkeys
= handle_printing_subpath( path
, subkeys
, -1 );
151 /**********************************************************************
152 Count the registry subkey names given a registry path.
153 Caller is responsible for freeing memory to **subkey
154 *********************************************************************/
156 BOOL
printing_subkey_specific( char *key
, char** subkey
, uint32 index
)
159 BOOL top_level
= False
;
162 DEBUG(10,("printing_subkey_specific: key=>[%s], index=>[%d]\n", key
, index
));
164 path
= trim_reg_path( key
);
166 /* check to see if we are dealing with the top level key */
175 /* make sure the index is in range */
177 if ( !(index
< MAX_TOP_LEVEL_KEYS
) )
180 if ( !(*subkey
= malloc( strlen(top_level_keys
[index
])+1 )) )
183 strncpy( *subkey
, top_level_keys
[index
], strlen(top_level_keys
[index
])+1 );
188 if ( handle_printing_subpath( path
, subkey
, index
) != -1 )
198 /**********************************************************************
199 Enumerate registry values given a registry path.
200 Caller is responsible for freeing memory
201 *********************************************************************/
203 int printing_value_info( char *key
, REGISTRY_VALUE
**val
)
205 DEBUG(10,("printing_value_info: key=>[%s]\n", key
));
210 /**********************************************************************
211 Stub function which always returns failure since we don't want
212 people storing printing information directly via regostry calls
214 *********************************************************************/
216 BOOL
printing_store_subkey( char *key
, char **subkeys
, uint32 num_subkeys
)
221 /**********************************************************************
222 Stub function which always returns failure since we don't want
223 people storing printing information directly via regostry calls
225 *********************************************************************/
227 BOOL
printing_store_value( char *key
, REGISTRY_VALUE
**val
, uint32 num_values
)
233 * Table of function pointers for accessing printing data
236 REGISTRY_OPS printing_ops
= {
237 printing_subkey_info
,
238 printing_subkey_specific
,
240 printing_store_subkey
,