1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

Added PRINTER_INFO_4/PRINTER_INFO_5, we're seeing level 5 requested on the wire... so.

Jeremy.
(This used to be commit b63b762978)
This commit is contained in:
Jeremy Allison 2002-01-12 02:37:54 +00:00
parent 973c0b3257
commit c9d350a736
3 changed files with 224 additions and 0 deletions

View File

@ -852,6 +852,24 @@ typedef struct printer_info_3
}
PRINTER_INFO_3;
typedef struct printer_info_4
{
UNISTR printername;
UNISTR servername;
uint32 attributes;
}
PRINTER_INFO_4;
typedef struct printer_info_5
{
UNISTR printername;
UNISTR portname;
uint32 attributes;
uint32 device_not_selected_timeout;
uint32 transmission_retry_timeout;
}
PRINTER_INFO_5;
typedef struct spool_q_enumprinters
{
uint32 flags;
@ -869,6 +887,8 @@ typedef struct printer_info_ctr_info
PRINTER_INFO_1 *printers_1;
PRINTER_INFO_2 *printers_2;
PRINTER_INFO_3 *printers_3;
PRINTER_INFO_4 *printers_4;
PRINTER_INFO_5 *printers_5;
}
PRINTER_INFO_CTR;

View File

@ -2240,6 +2240,54 @@ BOOL smb_io_printer_info_3(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 *info,
return True;
}
/*******************************************************************
Parse a PRINTER_INFO_4 structure.
********************************************************************/
BOOL smb_io_printer_info_4(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_4 *info, int depth)
{
prs_struct *ps=&buffer->prs;
prs_debug(ps, depth, desc, "smb_io_printer_info_4");
depth++;
buffer->struct_start=prs_offset(ps);
if (!smb_io_relstr("printername", buffer, depth, &info->printername))
return False;
if (!smb_io_relstr("servername", buffer, depth, &info->servername))
return False;
if (!prs_uint32("attributes", ps, depth, &info->attributes))
return False;
return True;
}
/*******************************************************************
Parse a PRINTER_INFO_5 structure.
********************************************************************/
BOOL smb_io_printer_info_5(char *desc, NEW_BUFFER *buffer, PRINTER_INFO_5 *info, int depth)
{
prs_struct *ps=&buffer->prs;
prs_debug(ps, depth, desc, "smb_io_printer_info_5");
depth++;
buffer->struct_start=prs_offset(ps);
if (!smb_io_relstr("printername", buffer, depth, &info->printername))
return False;
if (!smb_io_relstr("portname", buffer, depth, &info->portname))
return False;
if (!prs_uint32("attributes", ps, depth, &info->attributes))
return False;
if (!prs_uint32("device_not_selected_timeout", ps, depth, &info->device_not_selected_timeout))
return False;
if (!prs_uint32("transmission_retry_timeout", ps, depth, &info->transmission_retry_timeout))
return False;
return True;
}
/*******************************************************************
Parse a PORT_INFO_1 structure.
********************************************************************/
@ -2947,6 +2995,39 @@ uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info)
return size;
}
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info)
{
uint32 size=0;
size+=size_of_relative_string( &info->printername );
size+=size_of_relative_string( &info->servername );
size+=size_of_uint32( &info->attributes );
return size;
}
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info)
{
uint32 size=0;
size+=size_of_relative_string( &info->printername );
size+=size_of_relative_string( &info->portname );
size+=size_of_uint32( &info->attributes );
size+=size_of_uint32( &info->device_not_selected_timeout );
size+=size_of_uint32( &info->transmission_retry_timeout );
return size;
}
/*******************************************************************
return the size required by a struct in the stream
********************************************************************/
@ -5921,6 +6002,16 @@ void free_printer_info_3(PRINTER_INFO_3 *printer)
SAFE_FREE(printer);
}
void free_printer_info_4(PRINTER_INFO_4 *printer)
{
SAFE_FREE(printer);
}
void free_printer_info_5(PRINTER_INFO_5 *printer)
{
SAFE_FREE(printer);
}
void free_job_info_2(JOB_INFO_2 *job)
{
if (job!=NULL)

View File

@ -2873,6 +2873,49 @@ static BOOL construct_printer_info_3(PRINTER_INFO_3 **pp_printer, int snum)
return True;
}
/********************************************************************
* construct_printer_info_4
* fill a printer_info_4 struct
********************************************************************/
static BOOL construct_printer_info_4(PRINTER_INFO_4 *printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum))))
return False;
init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/
init_unistr(&printer->servername, ntprinter->info_2->servername); /* servername*/
printer->attributes = ntprinter->info_2->attributes;
free_a_printer(&ntprinter, 2);
return True;
}
/********************************************************************
* construct_printer_info_5
* fill a printer_info_5 struct
********************************************************************/
static BOOL construct_printer_info_5(PRINTER_INFO_5 *printer, int snum)
{
NT_PRINTER_INFO_LEVEL *ntprinter = NULL;
if (!W_ERROR_IS_OK(get_a_printer(&ntprinter, 2, lp_servicename(snum))))
return False;
init_unistr(&printer->printername, ntprinter->info_2->printername); /* printername*/
init_unistr(&printer->portname, ntprinter->info_2->portname); /* portname */
printer->attributes = ntprinter->info_2->attributes;
printer->device_not_selected_timeout = 0x3a98;
printer->transmission_retry_timeout = 0xafc8;
free_a_printer(&ntprinter, 2);
return True;
}
/********************************************************************
Spoolss_enumprinters.
********************************************************************/
@ -3333,6 +3376,72 @@ static WERROR getprinter_level_3(int snum, NEW_BUFFER *buffer, uint32 offered, u
return WERR_OK;
}
/****************************************************************************
****************************************************************************/
static WERROR getprinter_level_4(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_4 *printer=NULL;
if((printer=(PRINTER_INFO_4*)malloc(sizeof(PRINTER_INFO_4)))==NULL)
return WERR_NOMEM;
if (!construct_printer_info_4(printer, snum))
return WERR_NOMEM;
/* check the required size. */
*needed += spoolss_size_printer_info_4(printer);
if (!alloc_buffer_size(buffer, *needed)) {
free_printer_info_4(printer);
return WERR_INSUFFICIENT_BUFFER;
}
/* fill the buffer with the structures */
smb_io_printer_info_4("", buffer, printer, 0);
/* clear memory */
free_printer_info_4(printer);
if (*needed > offered) {
return WERR_INSUFFICIENT_BUFFER;
}
return WERR_OK;
}
/****************************************************************************
****************************************************************************/
static WERROR getprinter_level_5(int snum, NEW_BUFFER *buffer, uint32 offered, uint32 *needed)
{
PRINTER_INFO_5 *printer=NULL;
if((printer=(PRINTER_INFO_5*)malloc(sizeof(PRINTER_INFO_5)))==NULL)
return WERR_NOMEM;
if (!construct_printer_info_5(printer, snum))
return WERR_NOMEM;
/* check the required size. */
*needed += spoolss_size_printer_info_5(printer);
if (!alloc_buffer_size(buffer, *needed)) {
free_printer_info_5(printer);
return WERR_INSUFFICIENT_BUFFER;
}
/* fill the buffer with the structures */
smb_io_printer_info_5("", buffer, printer, 0);
/* clear memory */
free_printer_info_5(printer);
if (*needed > offered) {
return WERR_INSUFFICIENT_BUFFER;
}
return WERR_OK;
}
/****************************************************************************
****************************************************************************/
@ -3364,6 +3473,10 @@ WERROR _spoolss_getprinter(pipes_struct *p, SPOOL_Q_GETPRINTER *q_u, SPOOL_R_GET
return getprinter_level_2(snum, buffer, offered, needed);
case 3:
return getprinter_level_3(snum, buffer, offered, needed);
case 4:
return getprinter_level_4(snum, buffer, offered, needed);
case 5:
return getprinter_level_5(snum, buffer, offered, needed);
}
return WERR_UNKNOWN_LEVEL;
}