From d59b0eb1236cf5bb9371030a94eb60d4131c15fb Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Sat, 17 Aug 2002 13:17:41 +0000 Subject: [PATCH] * the printing code should now be back to the working state it was before the swap from NT_PRINTER_PARAM to REGISTRY_VALUE. * XxxPrinterDataEx() functions have not been expanded to support keys other than SPOOL_PRINTERDATA_KEY yet * fixed apparent long standing bug regarding the dependentfiles list in the DRIVER_INFO struct --- source/printing/nt_printing.c | 57 +++++++++++++------------------------- source/rpc_parse/parse_spoolss.c | 2 +- source/rpc_server/srv_spoolss_nt.c | 56 +++++++++++++++++++++++++------------ 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/source/printing/nt_printing.c b/source/printing/nt_printing.c index c497c65bfea..3b85fce0200 100644 --- a/source/printing/nt_printing.c +++ b/source/printing/nt_printing.c @@ -1759,7 +1759,8 @@ static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, driver.defaultdatatype); i=0; - while (len < dbuf.dsize) { + while (len < dbuf.dsize) + { fstring *tddfs; tddfs = (fstring *)Realloc(driver.dependentfiles, @@ -1774,13 +1775,15 @@ static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, &driver.dependentfiles[i]); i++; } + if (driver.dependentfiles != NULL) fstrcpy(driver.dependentfiles[i], ""); SAFE_FREE(dbuf.dptr); - if (len != dbuf.dsize) { - SAFE_FREE(driver.dependentfiles); + if (len != dbuf.dsize) + { + SAFE_FREE(driver.dependentfiles); return get_a_printer_driver_3_default(info_ptr, drivername, arch); } @@ -3034,15 +3037,17 @@ static BOOL set_driver_init_2( NT_PRINTER_INFO_LEVEL_2 *info_ptr ) TDB_DATA kbuf, dbuf; NT_PRINTER_INFO_LEVEL_2 info; + + ZERO_STRUCT(info); + /* * Delete any printer data 'values' already set. When called for driver * replace, there will generally be some, but during an add printer, there * should not be any (if there are delete them). */ + delete_all_printer_data( info_ptr ); - - ZERO_STRUCT(info); - + slprintf(key, sizeof(key)-1, "%s%s", DRIVER_INIT_PREFIX, info_ptr->drivername); kbuf.dptr = key; @@ -3057,16 +3062,18 @@ static BOOL set_driver_init_2( NT_PRINTER_INFO_LEVEL_2 *info_ptr ) free_nt_devicemode(&info_ptr->devmode); return False; } - + /* * Get the saved DEVMODE.. */ + len += unpack_devicemode(&info.devmode,dbuf.dptr+len, dbuf.dsize-len); /* * The saved DEVMODE contains the devicename from the printer used during * the initialization save. Change it to reflect the new printer. */ + ZERO_STRUCT(info.devmode->devicename); fstrcpy(info.devmode->devicename, info_ptr->printername); @@ -3082,44 +3089,18 @@ static BOOL set_driver_init_2( NT_PRINTER_INFO_LEVEL_2 *info_ptr ) * --jerry */ -#if 1 /* JERRY */ - /* - * Bind the saved DEVMODE to the new the printer. - */ + /* Bind the saved DEVMODE to the new the printer */ + free_nt_devicemode(&info_ptr->devmode); info_ptr->devmode = info.devmode; -#else - /* copy the entire devmode if we currently don't have one */ - - if (!info_ptr->devmode) { - DEBUG(10,("set_driver_init_2: Current Devmode is NULL. Copying entire Device Mode\n")); - info_ptr->devmode = info.devmode; - } - else { - /* only set the necessary fields */ - - DEBUG(10,("set_driver_init_2: Setting driverversion [0x%x] and private data [0x%x]\n", - info.devmode->driverversion, info.devmode->driverextra)); - - info_ptr->devmode->driverversion = info.devmode->driverversion; - SAFE_FREE(info_ptr->devmode->private); - info_ptr->devmode->private = NULL; - - if (info.devmode->driverversion) - info_ptr->devmode->private = memdup(info.devmode->private, info.devmode->driverversion); - - free_nt_devicemode(&info.devmode); - } -#endif DEBUG(10,("set_driver_init_2: Set printer [%s] init DEVMODE for driver [%s]\n", info_ptr->printername, info_ptr->drivername)); - /* - * Add the printer data 'values' to the new printer - */ + /* Add the printer data 'values' to the new printer */ + len += unpack_values( &info_ptr->data, dbuf.dptr+len, dbuf.dsize-len ); @@ -3142,7 +3123,7 @@ BOOL set_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level) switch (level) { case 2: - result=set_driver_init_2(printer->info_2); + result = set_driver_init_2(printer->info_2); break; default: diff --git a/source/rpc_parse/parse_spoolss.c b/source/rpc_parse/parse_spoolss.c index ac41a81a5a1..3a7f4b57ae6 100644 --- a/source/rpc_parse/parse_spoolss.c +++ b/source/rpc_parse/parse_spoolss.c @@ -5200,7 +5200,7 @@ static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar) *ar = NULL; while (src < ((char *)buf5->buffer) + buf5->buf_len*2) { - rpcstr_pull(f, src, sizeof(f)-1, 0, 0); + rpcstr_pull(f, src, sizeof(f)-1, -1, STR_TERMINATE); src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer)); tar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2)); if (!tar) diff --git a/source/rpc_server/srv_spoolss_nt.c b/source/rpc_server/srv_spoolss_nt.c index 2c1dbefd8b3..7aceaa548f2 100644 --- a/source/rpc_server/srv_spoolss_nt.c +++ b/source/rpc_server/srv_spoolss_nt.c @@ -4395,22 +4395,29 @@ static void init_unistr_array(uint16 **uni_array, fstring *char_array, char *ser DEBUG(6,("init_unistr_array\n")); *uni_array=NULL; - while (1) { + while (True) + { if (char_array == NULL) v = ""; else { v = char_array[i]; if (!v) v = ""; /* hack to handle null lists */ } - if (strlen(v) == 0) break; + + if ( !strlen(v) ) + break; + slprintf(line, sizeof(line)-1, "\\\\%s%s", servername, v); + DEBUGADD(6,("%d:%s:%d\n", i, line, strlen(line))); + if((tuary=Realloc(*uni_array, (j+strlen(line)+2)*sizeof(uint16))) == NULL) { DEBUG(2,("init_unistr_array: Realloc error\n" )); return; } else *uni_array = tuary; - j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, 0)/ sizeof(uint16)); + + j += (rpcstr_push((*uni_array+j), line, sizeof(uint16)*strlen(line)+2, STR_TERMINATE) / sizeof(uint16)); i++; } @@ -4572,8 +4579,8 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN init_unistr( &info->monitorname, driver.info_3->monitorname ); init_unistr( &info->defaultdatatype, driver.info_3->defaultdatatype ); - info->dependentfiles=NULL; - init_unistr_array(&info->dependentfiles, driver.info_3->dependentfiles, servername); + info->dependentfiles = NULL; + init_unistr_array( &info->dependentfiles, driver.info_3->dependentfiles, servername ); info->previousdrivernames=NULL; init_unistr_array(&info->previousdrivernames, &nullstr, servername); @@ -4596,21 +4603,28 @@ static void fill_printer_driver_info_6(DRIVER_INFO_6 *info, NT_PRINTER_DRIVER_IN * fill a printer_info_6 struct ********************************************************************/ -static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, fstring servername, fstring architecture, uint32 version) +static WERROR construct_printer_driver_info_6(DRIVER_INFO_6 *info, int snum, + fstring servername, fstring architecture, uint32 version) { - NT_PRINTER_INFO_LEVEL *printer = NULL; - NT_PRINTER_DRIVER_INFO_LEVEL driver; - WERROR status; + NT_PRINTER_INFO_LEVEL *printer = NULL; + NT_PRINTER_DRIVER_INFO_LEVEL driver; + WERROR status; + ZERO_STRUCT(driver); status=get_a_printer(&printer, 2, lp_servicename(snum) ); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); + if (!W_ERROR_IS_OK(status)) return WERR_INVALID_PRINTER_NAME; - status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + status = get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version); + DEBUG(8,("construct_printer_driver_info_6: status: %s\n", dos_errstr(status))); - if (!W_ERROR_IS_OK(status)) { + + if (!W_ERROR_IS_OK(status)) + { /* * Is this a W2k client ? */ @@ -4821,9 +4835,9 @@ WERROR _spoolss_getprinterdriver2(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVER2 *q_ DEBUG(4,("_spoolss_getprinterdriver2\n")); - *needed=0; - *servermajorversion=0; - *serverminorversion=0; + *needed = 0; + *servermajorversion = 0; + *serverminorversion = 0; pstrcpy(servername, get_called_name()); unistr2_to_ascii(architecture, uni_arch, sizeof(architecture)-1); @@ -5340,7 +5354,8 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, * requires Win32 client code (see other notes elsewhere in the code). */ if (printer->info_2->devmode && - printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) { + printer->info_2->devmode->displayfrequency == MAGIC_DISPLAY_FREQUENCY) + { DEBUG(10,("update_printer: Save printer driver init data\n")); printer->info_2->devmode->displayfrequency = 0; @@ -5356,20 +5371,25 @@ static WERROR update_printer(pipes_struct *p, POLICY_HND *handle, uint32 level, srv_spoolss_reset_printerdata( printer->info_2->drivername ); - } else { + } + else + { /* * When a *new* driver is bound to a printer, the drivername is used to * lookup previously saved driver initialization info, which is then * bound to the printer, simulating what happens in the Windows arch. */ - if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)){ - if (!set_driver_init(printer, 2)) { + if (!strequal(printer->info_2->drivername, old_printer->info_2->drivername)) + { + if (!set_driver_init(printer, 2)) + { DEBUG(5,("update_printer: Error restoring driver initialization data for driver [%s]!\n", printer->info_2->drivername)); } DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n", printer->info_2->drivername)); + notify_printer_driver(snum, printer->info_2->drivername); } } -- 2.11.4.GIT