summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-05-11 11:07:36 +0200
committerSimo Sorce <idra@samba.org>2010-07-27 10:27:13 -0400
commit7c629bda2f86271b709292dbc5a9e811e438a902 (patch)
tree7292c950686e8b289161506ea8e02cc98eeeda0b /source3/printing
parentae405eed4fa1857e90f240671c539088be51d562 (diff)
downloadsamba-7c629bda2f86271b709292dbc5a9e811e438a902.tar.gz
samba-7c629bda2f86271b709292dbc5a9e811e438a902.tar.bz2
samba-7c629bda2f86271b709292dbc5a9e811e438a902.zip
s3-printing: Remove unused printer registry key functions.
Signed-off-by: Jim McDonough <jmcd@samba.org>
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c494
1 files changed, 0 insertions, 494 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 63cdefc077..e42d0dfac1 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1793,327 +1793,7 @@ WERROR spoolss_create_default_secdesc(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-/****************************************************************************
- Allocate and initialize a new slot.
-***************************************************************************/
-
-int add_new_printer_key( NT_PRINTER_DATA *data, const char *name )
-{
- NT_PRINTER_KEY *d;
- int key_index;
- WERROR werr;
-
- if ( !name || !data )
- return -1;
-
- /* allocate another slot in the NT_PRINTER_KEY array */
-
- if ( !(d = TALLOC_REALLOC_ARRAY( data, data->keys, NT_PRINTER_KEY, data->num_keys+1)) ) {
- DEBUG(0,("add_new_printer_key: Realloc() failed!\n"));
- return -1;
- }
-
- data->keys = d;
-
- key_index = data->num_keys;
-
- /* initialze new key */
-
- data->keys[key_index].name = talloc_strdup( data, name );
-
- werr = regval_ctr_init(data, &(data->keys[key_index].values));
- if (!W_ERROR_IS_OK(werr)) {
- return -1;
- }
-
- data->num_keys++;
-
- DEBUG(10,("add_new_printer_key: Inserted new data key [%s]\n", name ));
-
- return key_index;
-}
-
-/****************************************************************************
- search for a registry key name in the existing printer data
- ***************************************************************************/
-
-int delete_printer_key( NT_PRINTER_DATA *data, const char *name )
-{
- int i;
-
- for ( i=0; i<data->num_keys; i++ ) {
- if ( strequal( data->keys[i].name, name ) ) {
-
- /* cleanup memory */
-
- TALLOC_FREE( data->keys[i].name );
- TALLOC_FREE( data->keys[i].values );
-
- /* if not the end of the array, move remaining elements down one slot */
-
- data->num_keys--;
- if ( data->num_keys && (i < data->num_keys) )
- memmove( &data->keys[i], &data->keys[i+1], sizeof(NT_PRINTER_KEY)*(data->num_keys-i) );
-
- break;
- }
- }
-
-
- return data->num_keys;
-}
-
-/****************************************************************************
- search for a registry key name in the existing printer data
- ***************************************************************************/
-
-int lookup_printerkey( NT_PRINTER_DATA *data, const char *name )
-{
- int key_index = -1;
- int i;
-
- if ( !data || !name )
- return -1;
-
- DEBUG(12,("lookup_printerkey: Looking for [%s]\n", name));
-
- /* loop over all existing keys */
-
- for ( i=0; i<data->num_keys; i++ ) {
- if ( strequal(data->keys[i].name, name) ) {
- DEBUG(12,("lookup_printerkey: Found [%s]!\n", name));
- key_index = i;
- break;
-
- }
- }
-
- return key_index;
-}
-
-/****************************************************************************
- ***************************************************************************/
-
-int get_printer_subkeys( NT_PRINTER_DATA *data, const char* key, fstring **subkeys )
-{
- int i, j;
- int key_len;
- int num_subkeys = 0;
- char *p;
- fstring *subkeys_ptr = NULL;
- fstring subkeyname;
-
- *subkeys = NULL;
-
- if ( !data )
- return 0;
-
- if ( !key )
- return -1;
-
- /* special case of asking for the top level printer data registry key names */
-
- if ( strlen(key) == 0 ) {
- for ( i=0; i<data->num_keys; i++ ) {
-
- /* found a match, so allocate space and copy the name */
-
- if ( !(subkeys_ptr = SMB_REALLOC_ARRAY( subkeys_ptr, fstring, num_subkeys+2)) ) {
- DEBUG(0,("get_printer_subkeys: Realloc failed for [%d] entries!\n",
- num_subkeys+1));
- return -1;
- }
-
- fstrcpy( subkeys_ptr[num_subkeys], data->keys[i].name );
- num_subkeys++;
- }
-
- goto done;
- }
-
- /* asking for the subkeys of some key */
- /* subkey paths are stored in the key name using '\' as the delimiter */
-
- for ( i=0; i<data->num_keys; i++ ) {
- if ( StrnCaseCmp(data->keys[i].name, key, strlen(key)) == 0 ) {
-
- /* if we found the exact key, then break */
- key_len = strlen( key );
- if ( strlen(data->keys[i].name) == key_len )
- break;
-
- /* get subkey path */
-
- p = data->keys[i].name + key_len;
- if ( *p == '\\' )
- p++;
- fstrcpy( subkeyname, p );
- if ( (p = strchr( subkeyname, '\\' )) )
- *p = '\0';
-
- /* don't add a key more than once */
-
- for ( j=0; j<num_subkeys; j++ ) {
- if ( strequal( subkeys_ptr[j], subkeyname ) )
- break;
- }
-
- if ( j != num_subkeys )
- continue;
-
- /* found a match, so allocate space and copy the name */
-
- if ( !(subkeys_ptr = SMB_REALLOC_ARRAY( subkeys_ptr, fstring, num_subkeys+2)) ) {
- DEBUG(0,("get_printer_subkeys: Realloc failed for [%d] entries!\n",
- num_subkeys+1));
- return 0;
- }
-
- fstrcpy( subkeys_ptr[num_subkeys], subkeyname );
- num_subkeys++;
- }
-
- }
-
- /* return error if the key was not found */
-
- if ( i == data->num_keys ) {
- SAFE_FREE(subkeys_ptr);
- return -1;
- }
-
-done:
- /* tag off the end */
-
- if (num_subkeys)
- fstrcpy(subkeys_ptr[num_subkeys], "" );
-
- *subkeys = subkeys_ptr;
-
- return num_subkeys;
-}
-
#ifdef HAVE_ADS
-static void map_sz_into_ctr(struct regval_ctr *ctr, const char *val_name,
- const char *sz)
-{
- regval_ctr_delvalue(ctr, val_name);
- regval_ctr_addvalue_sz(ctr, val_name, sz);
-}
-
-static void map_dword_into_ctr(struct regval_ctr *ctr, const char *val_name,
- uint32 dword)
-{
- regval_ctr_delvalue(ctr, val_name);
- regval_ctr_addvalue(ctr, val_name, REG_DWORD,
- (uint8 *) &dword, sizeof(dword));
-}
-
-static void map_bool_into_ctr(struct regval_ctr *ctr, const char *val_name,
- bool b)
-{
- uint8 bin_bool = (b ? 1 : 0);
- regval_ctr_delvalue(ctr, val_name);
- regval_ctr_addvalue(ctr, val_name, REG_BINARY,
- (uint8 *) &bin_bool, sizeof(bin_bool));
-}
-
-static void map_single_multi_sz_into_ctr(struct regval_ctr *ctr, const char *val_name,
- const char *multi_sz)
-{
- const char *a[2];
-
- a[0] = multi_sz;
- a[1] = NULL;
-
- regval_ctr_delvalue(ctr, val_name);
- regval_ctr_addvalue_multi_sz(ctr, val_name, a);
-}
-
-/****************************************************************************
- * Map spoolss_PrinterInfo2 data into DsSpooler keys for publishing.
- *
- * @param mem_ctx allocation context
- * @param info2 spoolss_PrinterInfo2 describing printer
- * @param pdata the talloced printer data
- * @return bool indicating success or failure
- ***************************************************************************/
-
-static bool map_nt_printer_info2_to_dsspooler(TALLOC_CTX *mem_ctx,
- struct spoolss_PrinterInfo2 *info2,
- NT_PRINTER_DATA **pdata)
-{
- NT_PRINTER_DATA *data;
- struct regval_ctr *ctr = NULL;
- fstring longname;
- const char *dnssuffix;
- char *allocated_string = NULL;
- const char *ascii_str;
- int i;
-
- data = talloc_zero(mem_ctx, NT_PRINTER_DATA);
- if (!data) return false;
-
- /* init data */
- i = add_new_printer_key(data, SPOOL_DSSPOOLER_KEY);
- ctr = data->keys[i].values;
-
- map_sz_into_ctr(ctr, SPOOL_REG_PRINTERNAME, info2->sharename);
- map_sz_into_ctr(ctr, SPOOL_REG_SHORTSERVERNAME, global_myname());
-
- /* we make the assumption that the netbios name is the same
- as the DNS name sinc ethe former will be what we used to
- join the domain */
-
- dnssuffix = get_mydnsdomname(talloc_tos());
- if (dnssuffix && *dnssuffix) {
- fstr_sprintf( longname, "%s.%s", global_myname(), dnssuffix );
- } else {
- fstrcpy( longname, global_myname() );
- }
-
- map_sz_into_ctr(ctr, SPOOL_REG_SERVERNAME, longname);
-
- if (asprintf(&allocated_string, "\\\\%s\\%s", longname, info2->sharename) == -1) {
- talloc_free(data);
- return false;
- }
- map_sz_into_ctr(ctr, SPOOL_REG_UNCNAME, allocated_string);
- SAFE_FREE(allocated_string);
-
- map_dword_into_ctr(ctr, SPOOL_REG_VERSIONNUMBER, 4);
- map_sz_into_ctr(ctr, SPOOL_REG_DRIVERNAME, info2->drivername);
- map_sz_into_ctr(ctr, SPOOL_REG_LOCATION, info2->location);
- map_sz_into_ctr(ctr, SPOOL_REG_DESCRIPTION, info2->comment);
- map_single_multi_sz_into_ctr(ctr, SPOOL_REG_PORTNAME, info2->portname);
- map_sz_into_ctr(ctr, SPOOL_REG_PRINTSEPARATORFILE, info2->sepfile);
- map_dword_into_ctr(ctr, SPOOL_REG_PRINTSTARTTIME, info2->starttime);
- map_dword_into_ctr(ctr, SPOOL_REG_PRINTENDTIME, info2->untiltime);
- map_dword_into_ctr(ctr, SPOOL_REG_PRIORITY, info2->priority);
-
- map_bool_into_ctr(ctr, SPOOL_REG_PRINTKEEPPRINTEDJOBS,
- (info2->attributes &
- PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS));
-
- switch (info2->attributes & 0x3) {
- case 0:
- ascii_str = SPOOL_REGVAL_PRINTWHILESPOOLING;
- break;
- case 1:
- ascii_str = SPOOL_REGVAL_PRINTAFTERSPOOLED;
- break;
- case 2:
- ascii_str = SPOOL_REGVAL_PRINTDIRECT;
- break;
- default:
- ascii_str = "unknown";
- }
- map_sz_into_ctr(ctr, SPOOL_REG_PRINTSPOOLING, ascii_str);
-
- *pdata = data;
- return true;
-}
-
/*****************************************************************
****************************************************************/
@@ -2180,7 +1860,6 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
struct GUID guid;
WERROR win_rc = WERR_OK;
size_t converted_size;
- NT_PRINTER_DATA *pdata;
const char *printer = pinfo2->sharename;
/* build the ads mods */
@@ -2191,11 +1870,6 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
DEBUG(5, ("publishing printer %s\n", printer));
- if (!map_nt_printer_info2_to_dsspooler(ctx, pinfo2, &pdata)) {
- TALLOC_FREE(ctx);
- return WERR_SERVER_UNAVAILABLE;
- }
-
/* figure out where to publish */
ads_find_machine_acct(ads, &res, global_myname());
@@ -2257,7 +1931,6 @@ static WERROR nt_printer_publish_ads(ADS_STRUCT *ads,
return WERR_NOMEM;
}
- get_local_printer_publishing_data(ctx, &mods, pdata);
ads_mod_str(ctx, &mods, SPOOL_REG_PRINTERNAME, printer);
/* publish it */
@@ -2563,173 +2236,6 @@ bool is_printer_published(TALLOC_CTX *mem_ctx,
/****************************************************************************
***************************************************************************/
-WERROR delete_all_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key )
-{
- NT_PRINTER_DATA *data;
- int i;
- int removed_keys = 0;
- int empty_slot;
-
- data = p2->data;
- empty_slot = data->num_keys;
-
- if ( !key )
- return WERR_INVALID_PARAM;
-
- /* remove all keys */
-
- if ( !strlen(key) ) {
-
- TALLOC_FREE( data );
-
- p2->data = NULL;
-
- DEBUG(8,("delete_all_printer_data: Removed all Printer Data from printer [%s]\n",
- p2->printername ));
-
- return WERR_OK;
- }
-
- /* remove a specific key (and all subkeys) */
-
- for ( i=0; i<data->num_keys; i++ ) {
- if ( StrnCaseCmp( data->keys[i].name, key, strlen(key)) == 0 ) {
- DEBUG(8,("delete_all_printer_data: Removed all Printer Data from key [%s]\n",
- data->keys[i].name));
-
- TALLOC_FREE( data->keys[i].name );
- TALLOC_FREE( data->keys[i].values );
-
- /* mark the slot as empty */
-
- ZERO_STRUCTP( &data->keys[i] );
- }
- }
-
- /* find the first empty slot */
-
- for ( i=0; i<data->num_keys; i++ ) {
- if ( !data->keys[i].name ) {
- empty_slot = i;
- removed_keys++;
- break;
- }
- }
-
- if ( i == data->num_keys )
- /* nothing was removed */
- return WERR_INVALID_PARAM;
-
- /* move everything down */
-
- for ( i=empty_slot+1; i<data->num_keys; i++ ) {
- if ( data->keys[i].name ) {
- memcpy( &data->keys[empty_slot], &data->keys[i], sizeof(NT_PRINTER_KEY) );
- ZERO_STRUCTP( &data->keys[i] );
- empty_slot++;
- removed_keys++;
- }
- }
-
- /* update count */
-
- data->num_keys -= removed_keys;
-
- /* sanity check to see if anything is left */
-
- if ( !data->num_keys ) {
- DEBUG(8,("delete_all_printer_data: No keys left for printer [%s]\n", p2->printername ));
-
- SAFE_FREE( data->keys );
- ZERO_STRUCTP( data );
- }
-
- return WERR_OK;
-}
-
-/****************************************************************************
- ***************************************************************************/
-
-WERROR delete_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value )
-{
- WERROR result = WERR_OK;
- int key_index;
-
- /* we must have names on non-zero length */
-
- if ( !key || !*key|| !value || !*value )
- return WERR_INVALID_NAME;
-
- /* find the printer key first */
-
- key_index = lookup_printerkey( p2->data, key );
- if ( key_index == -1 )
- return WERR_OK;
-
- /* make sure the value exists so we can return the correct error code */
-
- if ( !regval_ctr_getvalue( p2->data->keys[key_index].values, value ) )
- return WERR_BADFILE;
-
- regval_ctr_delvalue( p2->data->keys[key_index].values, value );
-
- DEBUG(8,("delete_printer_data: Removed key => [%s], value => [%s]\n",
- key, value ));
-
- return result;
-}
-
-/****************************************************************************
- ***************************************************************************/
-
-WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value,
- uint32 type, uint8 *data, int real_len )
-{
- WERROR result = WERR_OK;
- int key_index;
-
- /* we must have names on non-zero length */
-
- if ( !key || !*key|| !value || !*value )
- return WERR_INVALID_NAME;
-
- /* find the printer key first */
-
- key_index = lookup_printerkey( p2->data, key );
- if ( key_index == -1 )
- key_index = add_new_printer_key( p2->data, key );
-
- if ( key_index == -1 )
- return WERR_NOMEM;
-
- regval_ctr_addvalue( p2->data->keys[key_index].values, value,
- type, data, real_len );
-
- DEBUG(8,("add_printer_data: Added key => [%s], value => [%s], type=> [%d], size => [%d]\n",
- key, value, type, real_len ));
-
- return result;
-}
-
-/****************************************************************************
- ***************************************************************************/
-
-struct regval_blob* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value )
-{
- int key_index;
-
- if ( (key_index = lookup_printerkey( p2->data, key )) == -1 )
- return NULL;
-
- DEBUG(8,("get_printer_data: Attempting to lookup key => [%s], value => [%s]\n",
- key, value ));
-
- return regval_ctr_getvalue( p2->data->keys[key_index].values, value );
-}
-
-/****************************************************************************
- ***************************************************************************/
-
static char *win_driver;
static char *os2_driver;