diff options
-rw-r--r-- | source3/include/proto.h | 26 | ||||
-rw-r--r-- | source3/include/rpc_spoolss.h | 144 | ||||
-rw-r--r-- | source3/rpc_parse/parse_spoolss.c | 713 |
3 files changed, 0 insertions, 883 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 95651e5a9e..9badb95a1c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5838,24 +5838,6 @@ bool make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, const char *valuename, uint32 size); bool spoolss_io_q_getprinterdata(const char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth); bool spoolss_io_r_getprinterdata(const char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth); -bool smb_io_printer_info_0(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_0 *info, int depth); -bool smb_io_printer_info_1(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_1 *info, int depth); -bool smb_io_printer_info_2(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_2 *info, int depth); -bool smb_io_printer_info_3(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_3 *info, int depth); -bool smb_io_printer_info_4(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_4 *info, int depth); -bool smb_io_printer_info_5(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_5 *info, int depth); -bool smb_io_printer_info_6(const char *desc, RPC_BUFFER *buffer, - PRINTER_INFO_6 *info, int depth); -bool smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth); -uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info); -uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info); -uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info); -uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info); -uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info); -uint32 spoolss_size_printer_info_6(PRINTER_INFO_6 *info); -uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info); -uint32 spoolss_size_printer_info_7(PRINTER_INFO_7 *info); -uint32 spoolss_size_string_array(uint16 *string); uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p); bool make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src); bool spoolss_io_r_enumprinterdata(const char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth); @@ -5870,14 +5852,6 @@ bool make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND char* value, uint32 data_type, char* data, uint32 data_size); bool spoolss_io_q_setprinterdata(const char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth); bool spoolss_io_r_setprinterdata(const char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth); -void free_devmode(DEVICEMODE *devmode); -void free_printer_info_1(PRINTER_INFO_1 *printer); -void free_printer_info_2(PRINTER_INFO_2 *printer); -void free_printer_info_3(PRINTER_INFO_3 *printer); -void free_printer_info_4(PRINTER_INFO_4 *printer); -void free_printer_info_5(PRINTER_INFO_5 *printer); -void free_printer_info_6(PRINTER_INFO_6 *printer); -void free_printer_info_7(PRINTER_INFO_7 *printer); bool make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u, POLICY_HND *hnd, const char *key, uint32 size); diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h index e6a279497d..eb2fdd5309 100644 --- a/source3/include/rpc_spoolss.h +++ b/source3/include/rpc_spoolss.h @@ -311,150 +311,6 @@ typedef struct spool_r_getprinterdata } SPOOL_R_GETPRINTERDATA; -typedef struct printer_info_0 -{ - UNISTR printername; - UNISTR servername; - uint32 cjobs; - uint32 total_jobs; - uint32 total_bytes; - - uint16 year; - uint16 month; - uint16 dayofweek; - uint16 day; - uint16 hour; - uint16 minute; - uint16 second; - uint16 milliseconds; - - uint32 global_counter; - uint32 total_pages; - - uint16 major_version; - uint16 build_version; - - uint32 unknown7; - uint32 unknown8; - uint32 unknown9; - uint32 session_counter; - uint32 unknown11; - uint32 printer_errors; - uint32 unknown13; - uint32 unknown14; - uint32 unknown15; - uint32 unknown16; - uint32 change_id; - uint32 unknown18; - uint32 status; - uint32 unknown20; - uint32 c_setprinter; - - uint16 unknown22; - uint16 unknown23; - uint16 unknown24; - uint16 unknown25; - uint16 unknown26; - uint16 unknown27; - uint16 unknown28; - uint16 unknown29; -} PRINTER_INFO_0; - -typedef struct printer_info_1 -{ - uint32 flags; - UNISTR description; - UNISTR name; - UNISTR comment; -} -PRINTER_INFO_1; - -typedef struct printer_info_2 -{ - UNISTR servername; - UNISTR printername; - UNISTR sharename; - UNISTR portname; - UNISTR drivername; - UNISTR comment; - UNISTR location; - DEVICEMODE *devmode; - UNISTR sepfile; - UNISTR printprocessor; - UNISTR datatype; - UNISTR parameters; - SEC_DESC *secdesc; - uint32 attributes; - uint32 priority; - uint32 defaultpriority; - uint32 starttime; - uint32 untiltime; - uint32 status; - uint32 cjobs; - uint32 averageppm; -} -PRINTER_INFO_2; - -typedef struct printer_info_3 -{ - SEC_DESC *secdesc; -} -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 printer_info_6 -{ - uint32 status; -} -PRINTER_INFO_6; - -typedef struct printer_info_7 -{ - UNISTR guid; /* text form of printer guid */ - uint32 action; -} -PRINTER_INFO_7; - -typedef struct printer_info_ctr_info -{ - PRINTER_INFO_0 *printers_0; - 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_7 *printers_7; -} -PRINTER_INFO_CTR; - -typedef struct printer_info_info -{ - union - { - PRINTER_INFO_0 *info0; - PRINTER_INFO_1 *info1; - PRINTER_INFO_2 *info2; - void *info; - } printer; -} PRINTER_INFO; - typedef struct add_jobinfo_1 { UNISTR path; diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index a854352a81..e499607a4d 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -347,15 +347,6 @@ bool spoolss_io_r_getprinterdata(const char *desc, SPOOL_R_GETPRINTERDATA *r_u, } /******************************************************************* - * return the length of a uint16 (obvious, but the code is clean) - ********************************************************************/ - -static uint32 size_of_uint16(uint16 *value) -{ - return (sizeof(*value)); -} - -/******************************************************************* * return the length of a uint32 (obvious, but the code is clean) ********************************************************************/ @@ -365,663 +356,6 @@ static uint32 size_of_uint32(uint32 *value) } /******************************************************************* - * return the length of a NTTIME (obvious, but the code is clean) - ********************************************************************/ - -static uint32 size_of_nttime(NTTIME *value) -{ - return (sizeof(*value)); -} - -/******************************************************************* - * return the length of a uint32 (obvious, but the code is clean) - ********************************************************************/ - -static uint32 size_of_device_mode(DEVICEMODE *devmode) -{ - if (devmode==NULL) - return (4); - else - return (4+devmode->size+devmode->driverextra); -} - -/******************************************************************* - Parse a DEVMODE structure and its relative pointer. -********************************************************************/ - -static bool smb_io_reldevmode(const char *desc, RPC_BUFFER *buffer, int depth, DEVICEMODE **devmode) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_reldevmode"); - depth++; - - if (MARSHALLING(ps)) { - uint32 struct_offset = prs_offset(ps); - uint32 relative_offset; - - if (*devmode == NULL) { - relative_offset=0; - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - DEBUG(8, ("boing, the devmode was NULL\n")); - - return True; - } - - buffer->string_at_end -= ((*devmode)->size + (*devmode)->driverextra); - - /* mz: we have to align the device mode for VISTA */ - if (buffer->string_at_end % 4) { - buffer->string_at_end += 4 - (buffer->string_at_end % 4); - } - - if(!prs_set_offset(ps, buffer->string_at_end)) - return False; - - /* write the DEVMODE */ - if (!spoolss_io_devmode(desc, ps, depth, *devmode)) - return False; - - if(!prs_set_offset(ps, struct_offset)) - return False; - - relative_offset=buffer->string_at_end - buffer->struct_start; - /* write its offset */ - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - } - else { - uint32 old_offset; - - /* read the offset */ - if (!prs_uint32("offset", ps, depth, &buffer->string_at_end)) - return False; - if (buffer->string_at_end == 0) { - *devmode = NULL; - return True; - } - - old_offset = prs_offset(ps); - if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start)) - return False; - - /* read the string */ - if((*devmode=PRS_ALLOC_MEM(ps,DEVICEMODE,1)) == NULL) - return False; - if (!spoolss_io_devmode(desc, ps, depth, *devmode)) - return False; - - if(!prs_set_offset(ps, old_offset)) - return False; - } - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_0 structure. -********************************************************************/ - -bool smb_io_printer_info_0(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_0 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_0"); - 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("cjobs", ps, depth, &info->cjobs)) - return False; - if(!prs_uint32("total_jobs", ps, depth, &info->total_jobs)) - return False; - if(!prs_uint32("total_bytes", ps, depth, &info->total_bytes)) - return False; - - if(!prs_uint16("year", ps, depth, &info->year)) - return False; - if(!prs_uint16("month", ps, depth, &info->month)) - return False; - if(!prs_uint16("dayofweek", ps, depth, &info->dayofweek)) - return False; - if(!prs_uint16("day", ps, depth, &info->day)) - return False; - if(!prs_uint16("hour", ps, depth, &info->hour)) - return False; - if(!prs_uint16("minute", ps, depth, &info->minute)) - return False; - if(!prs_uint16("second", ps, depth, &info->second)) - return False; - if(!prs_uint16("milliseconds", ps, depth, &info->milliseconds)) - return False; - - if(!prs_uint32("global_counter", ps, depth, &info->global_counter)) - return False; - if(!prs_uint32("total_pages", ps, depth, &info->total_pages)) - return False; - - if(!prs_uint16("major_version", ps, depth, &info->major_version)) - return False; - if(!prs_uint16("build_version", ps, depth, &info->build_version)) - return False; - if(!prs_uint32("unknown7", ps, depth, &info->unknown7)) - return False; - if(!prs_uint32("unknown8", ps, depth, &info->unknown8)) - return False; - if(!prs_uint32("unknown9", ps, depth, &info->unknown9)) - return False; - if(!prs_uint32("session_counter", ps, depth, &info->session_counter)) - return False; - if(!prs_uint32("unknown11", ps, depth, &info->unknown11)) - return False; - if(!prs_uint32("printer_errors", ps, depth, &info->printer_errors)) - return False; - if(!prs_uint32("unknown13", ps, depth, &info->unknown13)) - return False; - if(!prs_uint32("unknown14", ps, depth, &info->unknown14)) - return False; - if(!prs_uint32("unknown15", ps, depth, &info->unknown15)) - return False; - if(!prs_uint32("unknown16", ps, depth, &info->unknown16)) - return False; - if(!prs_uint32("change_id", ps, depth, &info->change_id)) - return False; - if(!prs_uint32("unknown18", ps, depth, &info->unknown18)) - return False; - if(!prs_uint32("status" , ps, depth, &info->status)) - return False; - if(!prs_uint32("unknown20", ps, depth, &info->unknown20)) - return False; - if(!prs_uint32("c_setprinter", ps, depth, &info->c_setprinter)) - return False; - if(!prs_uint16("unknown22", ps, depth, &info->unknown22)) - return False; - if(!prs_uint16("unknown23", ps, depth, &info->unknown23)) - return False; - if(!prs_uint16("unknown24", ps, depth, &info->unknown24)) - return False; - if(!prs_uint16("unknown25", ps, depth, &info->unknown25)) - return False; - if(!prs_uint16("unknown26", ps, depth, &info->unknown26)) - return False; - if(!prs_uint16("unknown27", ps, depth, &info->unknown27)) - return False; - if(!prs_uint16("unknown28", ps, depth, &info->unknown28)) - return False; - if(!prs_uint16("unknown29", ps, depth, &info->unknown29)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_1 structure. -********************************************************************/ - -bool smb_io_printer_info_1(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("flags", ps, depth, &info->flags)) - return False; - if (!smb_io_relstr("description", buffer, depth, &info->description)) - return False; - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - if (!smb_io_relstr("comment", buffer, depth, &info->comment)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_2 structure. -********************************************************************/ - -bool smb_io_printer_info_2(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - uint32 dm_offset, sd_offset, current_offset; - uint32 dummy_value = 0, has_secdesc = 0; - - prs_debug(ps, depth, desc, "smb_io_printer_info_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("servername", buffer, depth, &info->servername)) - return False; - if (!smb_io_relstr("printername", buffer, depth, &info->printername)) - return False; - if (!smb_io_relstr("sharename", buffer, depth, &info->sharename)) - return False; - if (!smb_io_relstr("portname", buffer, depth, &info->portname)) - return False; - if (!smb_io_relstr("drivername", buffer, depth, &info->drivername)) - return False; - if (!smb_io_relstr("comment", buffer, depth, &info->comment)) - return False; - if (!smb_io_relstr("location", buffer, depth, &info->location)) - return False; - - /* save current offset and wind forwared by a uint32 */ - dm_offset = prs_offset(ps); - if (!prs_uint32("devmode", ps, depth, &dummy_value)) - return False; - - if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile)) - return False; - if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor)) - return False; - if (!smb_io_relstr("datatype", buffer, depth, &info->datatype)) - return False; - if (!smb_io_relstr("parameters", buffer, depth, &info->parameters)) - return False; - - /* save current offset for the sec_desc */ - sd_offset = prs_offset(ps); - if (!prs_uint32("sec_desc", ps, depth, &has_secdesc)) - return False; - - - /* save current location so we can pick back up here */ - current_offset = prs_offset(ps); - - /* parse the devmode */ - if (!prs_set_offset(ps, dm_offset)) - return False; - if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode)) - return False; - - /* parse the sec_desc */ - if (info->secdesc) { - if (!prs_set_offset(ps, sd_offset)) - return False; - if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc)) - return False; - } - - /* pick up where we left off */ - if (!prs_set_offset(ps, current_offset)) - return False; - - if (!prs_uint32("attributes", ps, depth, &info->attributes)) - return False; - if (!prs_uint32("priority", ps, depth, &info->priority)) - return False; - if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority)) - return False; - if (!prs_uint32("starttime", ps, depth, &info->starttime)) - return False; - if (!prs_uint32("untiltime", ps, depth, &info->untiltime)) - return False; - if (!prs_uint32("status", ps, depth, &info->status)) - return False; - if (!prs_uint32("jobs", ps, depth, &info->cjobs)) - return False; - if (!prs_uint32("averageppm", ps, depth, &info->averageppm)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_3 structure. -********************************************************************/ - -bool smb_io_printer_info_3(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_3 *info, int depth) -{ - uint32 offset = 0; - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_3"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (MARSHALLING(ps)) { - /* Ensure the SD is 8 byte aligned in the buffer. */ - uint32 start = prs_offset(ps); /* Remember the start position. */ - uint32 off_val = 0; - - /* Write a dummy value. */ - if (!prs_uint32("offset", ps, depth, &off_val)) - return False; - - /* 8 byte align. */ - if (!prs_align_uint64(ps)) - return False; - - /* Remember where we must seek back to write the SD. */ - offset = prs_offset(ps); - - /* Calculate the real offset for the SD. */ - - off_val = offset - start; - - /* Seek back to where we store the SD offset & store. */ - prs_set_offset(ps, start); - if (!prs_uint32("offset", ps, depth, &off_val)) - return False; - - /* Return to after the 8 byte align. */ - prs_set_offset(ps, offset); - - } else { - if (!prs_uint32("offset", ps, depth, &offset)) - return False; - /* Seek within the buffer. */ - if (!prs_set_offset(ps, offset)) - return False; - } - if (!sec_io_desc("sec_desc", &info->secdesc, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_4 structure. -********************************************************************/ - -bool smb_io_printer_info_4(const char *desc, RPC_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(const char *desc, RPC_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 PRINTER_INFO_6 structure. -********************************************************************/ - -bool smb_io_printer_info_6(const char *desc, RPC_BUFFER *buffer, - PRINTER_INFO_6 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_6"); - depth++; - - if (!prs_uint32("status", ps, depth, &info->status)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_7 structure. -********************************************************************/ - -bool smb_io_printer_info_7(const char *desc, RPC_BUFFER *buffer, PRINTER_INFO_7 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_7"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("guid", buffer, depth, &info->guid)) - return False; - if (!prs_uint32("action", ps, depth, &info->action)) - return False; - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info) -{ - int size=0; - - size+=size_of_relative_string( &info->printername ); - size+=size_of_relative_string( &info->servername ); - - size+=size_of_uint32( &info->cjobs); - size+=size_of_uint32( &info->total_jobs); - size+=size_of_uint32( &info->total_bytes); - - size+=size_of_uint16( &info->year); - size+=size_of_uint16( &info->month); - size+=size_of_uint16( &info->dayofweek); - size+=size_of_uint16( &info->day); - size+=size_of_uint16( &info->hour); - size+=size_of_uint16( &info->minute); - size+=size_of_uint16( &info->second); - size+=size_of_uint16( &info->milliseconds); - - size+=size_of_uint32( &info->global_counter); - size+=size_of_uint32( &info->total_pages); - - size+=size_of_uint16( &info->major_version); - size+=size_of_uint16( &info->build_version); - - size+=size_of_uint32( &info->unknown7); - size+=size_of_uint32( &info->unknown8); - size+=size_of_uint32( &info->unknown9); - size+=size_of_uint32( &info->session_counter); - size+=size_of_uint32( &info->unknown11); - size+=size_of_uint32( &info->printer_errors); - size+=size_of_uint32( &info->unknown13); - size+=size_of_uint32( &info->unknown14); - size+=size_of_uint32( &info->unknown15); - size+=size_of_uint32( &info->unknown16); - size+=size_of_uint32( &info->change_id); - size+=size_of_uint32( &info->unknown18); - size+=size_of_uint32( &info->status); - size+=size_of_uint32( &info->unknown20); - size+=size_of_uint32( &info->c_setprinter); - - size+=size_of_uint16( &info->unknown22); - size+=size_of_uint16( &info->unknown23); - size+=size_of_uint16( &info->unknown24); - size+=size_of_uint16( &info->unknown25); - size+=size_of_uint16( &info->unknown26); - size+=size_of_uint16( &info->unknown27); - size+=size_of_uint16( &info->unknown28); - size+=size_of_uint16( &info->unknown29); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info) -{ - int size=0; - - size+=size_of_uint32( &info->flags ); - size+=size_of_relative_string( &info->description ); - size+=size_of_relative_string( &info->name ); - size+=size_of_relative_string( &info->comment ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info) -{ - uint32 size=0; - - size += 4; - - size += ndr_size_security_descriptor( info->secdesc, NULL, 0 ); - - size+=size_of_device_mode( info->devmode ); - - size+=size_of_relative_string( &info->servername ); - size+=size_of_relative_string( &info->printername ); - size+=size_of_relative_string( &info->sharename ); - size+=size_of_relative_string( &info->portname ); - size+=size_of_relative_string( &info->drivername ); - size+=size_of_relative_string( &info->comment ); - size+=size_of_relative_string( &info->location ); - - size+=size_of_relative_string( &info->sepfile ); - size+=size_of_relative_string( &info->printprocessor ); - size+=size_of_relative_string( &info->datatype ); - size+=size_of_relative_string( &info->parameters ); - - size+=size_of_uint32( &info->attributes ); - size+=size_of_uint32( &info->priority ); - size+=size_of_uint32( &info->defaultpriority ); - size+=size_of_uint32( &info->starttime ); - size+=size_of_uint32( &info->untiltime ); - size+=size_of_uint32( &info->status ); - size+=size_of_uint32( &info->cjobs ); - size+=size_of_uint32( &info->averageppm ); - - /* - * add any adjustments for alignment. This is - * not optimal since we could be calling this - * function from a loop (e.g. enumprinters), but - * it is easier to maintain the calculation here and - * not place the burden on the caller to remember. --jerry - */ - if ((size % 4) != 0) - size += 4 - (size % 4); - - 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 -********************************************************************/ - -uint32 spoolss_size_printer_info_6(PRINTER_INFO_6 *info) -{ - return sizeof(uint32); -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info) -{ - /* The 8 is for the self relative pointer - 8 byte aligned.. */ - return 8 + (uint32)ndr_size_security_descriptor( info->secdesc, NULL, 0 ); -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_7(PRINTER_INFO_7 *info) -{ - uint32 size=0; - - size+=size_of_relative_string( &info->guid ); - size+=size_of_uint32( &info->action ); - return size; -} - -/******************************************************************* -return the size required by a string array. -********************************************************************/ - -uint32 spoolss_size_string_array(uint16 *string) -{ - uint32 i = 0; - - if (string) { - for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++); - } - i=i+2; /* to count all chars including the leading zero */ - i=2*i; /* because we need the value in bytes */ - i=i+4; /* the offset pointer size */ - - return i; -} - -/******************************************************************* return the size required by a struct in the stream ********************************************************************/ uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p) @@ -1252,53 +586,6 @@ bool spoolss_io_r_setprinterdata(const char *desc, SPOOL_R_SETPRINTERDATA *r_u, return True; } -void free_devmode(DEVICEMODE *devmode) -{ - if (devmode!=NULL) { - SAFE_FREE(devmode->dev_private); - SAFE_FREE(devmode); - } -} - -void free_printer_info_1(PRINTER_INFO_1 *printer) -{ - SAFE_FREE(printer); -} - -void free_printer_info_2(PRINTER_INFO_2 *printer) -{ - if (printer!=NULL) { - free_devmode(printer->devmode); - printer->devmode = NULL; - SAFE_FREE(printer); - } -} - -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_printer_info_6(PRINTER_INFO_6 *printer) -{ - SAFE_FREE(printer); -} - -void free_printer_info_7(PRINTER_INFO_7 *printer) -{ - SAFE_FREE(printer); -} - /******************************************************************* * read a structure. ********************************************************************/ |