From 403562cb94bc06707f86ec87caf0cf2d32a02ed7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 28 Feb 2001 01:24:55 +0000 Subject: Partial conversion of SPOOLSS code to canonical format. More to follow. Once complete then the PRINTER_XX functions and structures will be converted to talloc control. Jeremy. (This used to be commit 8171cc56428920d8b765d077198893201f68766e) --- source3/include/proto.h | 31 ++++------- source3/rpc_server/srv_spoolss.c | 49 +++++++---------- source3/rpc_server/srv_spoolss_nt.c | 103 ++++++++++++++++++++++++++++-------- 3 files changed, 107 insertions(+), 76 deletions(-) (limited to 'source3') diff --git a/source3/include/proto.h b/source3/include/proto.h index 69b099fe6e..8f0858d4ef 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -3409,28 +3409,15 @@ BOOL api_spoolss_rpc(pipes_struct *p); #if OLD_NTDOMAIN void init_printer_hnd(void); void srv_spoolss_receive_message(int msg_type, pid_t src, void *buf, size_t len); -uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, - PRINTER_DEFAULT *printer_default, - uint32 user_switch, SPOOL_USER_CTR user_ctr, - POLICY_HND *handle); +uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u); BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, NT_DEVICEMODE **pp_nt_devmode); -uint32 _spoolss_closeprinter(POLICY_HND *handle); -uint32 _spoolss_deleteprinter(POLICY_HND *handle); -uint32 _spoolss_getprinterdata(pipes_struct *p, POLICY_HND *handle, UNISTR2 *valuename, - uint32 in_size, - uint32 *type, - uint32 *out_size, - uint8 **data, - uint32 *needed); -uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, - const UNISTR2 *localmachine, uint32 printerlocal, - SPOOL_NOTIFY_OPTION *option); -uint32 _spoolss_rfnpcnex( pipes_struct *p, POLICY_HND *handle, uint32 change, - SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info); -uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned); +uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R_CLOSEPRINTER *r_u); +uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL_R_DELETEPRINTER *r_u); +uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u); +uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNEX *r_u); +uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u); +uint32 _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u); uint32 _spoolss_getprinter(POLICY_HND *handle, uint32 level, NEW_BUFFER *buffer, uint32 offered, uint32 *needed); uint32 _spoolss_getprinterdriver2(POLICY_HND *handle, const UNISTR2 *uni_arch, uint32 level, @@ -3447,7 +3434,7 @@ uint32 _spoolss_writeprinter( POLICY_HND *handle, uint32 buffer_size, uint8 *buffer, uint32 *buffer_written); -uint32 _spoolss_abortprinter(POLICY_HND *handle, pipes_struct *p); +uint32 _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u); uint32 _spoolss_setprinter(POLICY_HND *handle, uint32 level, const SPOOL_PRINTER_INFO_LEVEL *info, DEVMODE_CTR devmode_ctr, @@ -3495,7 +3482,7 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, const uint8 *data, uint32 real_len, uint32 numeric_data); -uint32 _spoolss_deleteprinterdata( POLICY_HND *handle, const UNISTR2 *value); +uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u); uint32 _spoolss_addform( POLICY_HND *handle, uint32 level, const FORM *form); diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c index cd490d1944..91107e9dbe 100755 --- a/source3/rpc_server/srv_spoolss.c +++ b/source3/rpc_server/srv_spoolss.c @@ -29,11 +29,11 @@ extern int DEBUGLEVEL; /******************************************************************** * api_spoolss_open_printer_ex ********************************************************************/ + static BOOL api_spoolss_open_printer_ex(pipes_struct *p) { SPOOL_Q_OPEN_PRINTER_EX q_u; SPOOL_R_OPEN_PRINTER_EX r_u; - UNISTR2 *printername = NULL; prs_struct *data = &p->in_data.data; prs_struct *rdata = &p->out_data.rdata; @@ -45,13 +45,7 @@ static BOOL api_spoolss_open_printer_ex(pipes_struct *p) return False; } - if (q_u.printername_ptr != 0) - printername = &q_u.printername; - - r_u.status = _spoolss_open_printer_ex( printername, p, - &q_u.printer_default, - q_u.user_switch, q_u.user_ctr, - &r_u.handle); + r_u.status = _spoolss_open_printer_ex( p, &q_u, &r_u); if (!spoolss_io_r_open_printer_ex("",&r_u,rdata,0)){ DEBUG(0,("spoolss_io_r_open_printer_ex: unable to marshall SPOOL_R_OPEN_PRINTER_EX.\n")); @@ -66,6 +60,7 @@ static BOOL api_spoolss_open_printer_ex(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_getprinterdata(pipes_struct *p) { SPOOL_Q_GETPRINTERDATA q_u; @@ -82,9 +77,7 @@ static BOOL api_spoolss_getprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_getprinterdata( p, &q_u.handle, &q_u.valuename, - q_u.size, &r_u.type, &r_u.size, - &r_u.data, &r_u.needed); + r_u.status = _spoolss_getprinterdata( p, &q_u, &r_u); if (!spoolss_io_r_getprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_getprinterdata: unable to marshall SPOOL_R_GETPRINTERDATA.\n")); @@ -99,6 +92,7 @@ static BOOL api_spoolss_getprinterdata(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) { SPOOL_Q_DELETEPRINTERDATA q_u; @@ -115,7 +109,7 @@ static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) return False; } - r_u.status = _spoolss_deleteprinterdata( &q_u.handle, &q_u.valuename); + r_u.status = _spoolss_deleteprinterdata( p, &q_u, &r_u); if (!spoolss_io_r_deleteprinterdata("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_deleteprinterdata: unable to marshall SPOOL_R_DELETEPRINTERDATA.\n")); @@ -130,6 +124,7 @@ static BOOL api_spoolss_deleteprinterdata(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_closeprinter(pipes_struct *p) { SPOOL_Q_CLOSEPRINTER q_u; @@ -145,8 +140,7 @@ static BOOL api_spoolss_closeprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_closeprinter(&q_u.handle); - memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle)); + r_u.status = _spoolss_closeprinter(p, &q_u, &r_u); if (!spoolss_io_r_closeprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_closeprinter: unable to marshall SPOOL_R_CLOSEPRINTER.\n")); @@ -161,6 +155,7 @@ static BOOL api_spoolss_closeprinter(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_abortprinter(pipes_struct *p) { SPOOL_Q_ABORTPRINTER q_u; @@ -176,7 +171,7 @@ static BOOL api_spoolss_abortprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_abortprinter(&q_u.handle, p); + r_u.status = _spoolss_abortprinter(p, &q_u, &r_u); if (!spoolss_io_r_abortprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_abortprinter: unable to marshall SPOOL_R_ABORTPRINTER.\n")); @@ -191,6 +186,7 @@ static BOOL api_spoolss_abortprinter(pipes_struct *p) * * called from the spoolss dispatcher ********************************************************************/ + static BOOL api_spoolss_deleteprinter(pipes_struct *p) { SPOOL_Q_DELETEPRINTER q_u; @@ -206,8 +202,7 @@ static BOOL api_spoolss_deleteprinter(pipes_struct *p) return False; } - r_u.status = _spoolss_deleteprinter(&q_u.handle); - memcpy(&r_u.handle, &q_u.handle, sizeof(r_u.handle)); + r_u.status = _spoolss_deleteprinter(p, &q_u, &r_u); if (!spoolss_io_r_deleteprinter("",&r_u,rdata,0)) { DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n")); @@ -222,6 +217,7 @@ static BOOL api_spoolss_deleteprinter(pipes_struct *p) * api_spoolss_rffpcnex * ReplyFindFirstPrinterChangeNotifyEx ********************************************************************/ + static BOOL api_spoolss_rffpcnex(pipes_struct *p) { SPOOL_Q_RFFPCNEX q_u; @@ -237,9 +233,7 @@ static BOOL api_spoolss_rffpcnex(pipes_struct *p) return False; } - r_u.status = _spoolss_rffpcnex(&q_u.handle, q_u.flags, - q_u.options, &q_u.localmachine, - q_u.printerlocal, q_u.option); + r_u.status = _spoolss_rffpcnex(p, &q_u, &r_u); if (!spoolss_io_r_rffpcnex("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_rffpcnex: unable to marshall SPOOL_R_RFFPCNEX.\n")); @@ -256,6 +250,7 @@ static BOOL api_spoolss_rffpcnex(pipes_struct *p) * called from the spoolss dispatcher * ********************************************************************/ + static BOOL api_spoolss_rfnpcnex(pipes_struct *p) { SPOOL_Q_RFNPCNEX q_u; @@ -271,11 +266,7 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) return False; } - r_u.status = _spoolss_rfnpcnex(&q_u.handle, q_u.change, - q_u.option, p->mem_ctx, &r_u.info); - - /* we always have a NOTIFY_INFO struct */ - r_u.info_ptr=0x1; + r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u); if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) { DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n")); @@ -291,6 +282,7 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p) * called from the spoolss dispatcher * ********************************************************************/ + static BOOL api_spoolss_enumprinters(pipes_struct *p) { SPOOL_Q_ENUMPRINTERS q_u; @@ -306,12 +298,7 @@ static BOOL api_spoolss_enumprinters(pipes_struct *p) return False; } - /* that's an [in out] buffer */ - new_spoolss_move_buffer(q_u.buffer, &r_u.buffer); - - r_u.status = _spoolss_enumprinters( q_u.flags, &q_u.servername, q_u.level, - r_u.buffer, q_u.offered, - &r_u.needed, &r_u.returned); + r_u.status = _spoolss_enumprinters( p, &q_u, &r_u); if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) { DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n")); diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 4612384b0d..4170700705 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -697,18 +697,26 @@ static BOOL srv_spoolss_sendnotify(POLICY_HND *handle) * * called from the spoolss dispatcher ********************************************************************/ -uint32 _spoolss_open_printer_ex( const UNISTR2 *printername, pipes_struct *p, - PRINTER_DEFAULT *printer_default, - uint32 user_switch, SPOOL_USER_CTR user_ctr, - POLICY_HND *handle) + +uint32 _spoolss_open_printer_ex( pipes_struct *p, SPOOL_Q_OPEN_PRINTER_EX *q_u, SPOOL_R_OPEN_PRINTER_EX *r_u) { #if 0 uint32 result = NT_STATUS_NO_PROBLEMO; #endif + + UNISTR2 *printername = NULL; + PRINTER_DEFAULT *printer_default = &q_u->printer_default; +/* uint32 user_switch = q_u->user_switch; - notused */ +/* SPOOL_USER_CTR user_ctr = q_u->user_ctr; - notused */ + POLICY_HND *handle = &r_u->handle; + fstring name; int snum; struct current_user user; - + + if (q_u->printername_ptr != 0) + printername = &q_u->printername; + if (printername == NULL) return ERROR_INVALID_PRINTER_NAME; @@ -985,13 +993,18 @@ BOOL convert_devicemode(char *printername, const DEVICEMODE *devmode, /******************************************************************** * api_spoolss_closeprinter ********************************************************************/ -uint32 _spoolss_closeprinter(POLICY_HND *handle) + +uint32 _spoolss_closeprinter(pipes_struct *p, SPOOL_Q_CLOSEPRINTER *q_u, SPOOL_R_CLOSEPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer=find_printer_index_by_hnd(handle); if (Printer && Printer->document_started) _spoolss_enddocprinter(handle); /* print job was not closed */ + memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); + if (!close_printer_handle(handle)) return ERROR_INVALID_HANDLE; @@ -1000,15 +1013,21 @@ uint32 _spoolss_closeprinter(POLICY_HND *handle) /******************************************************************** * api_spoolss_deleteprinter + ********************************************************************/ -uint32 _spoolss_deleteprinter(POLICY_HND *handle) + +uint32 _spoolss_deleteprinter(pipes_struct *p, SPOOL_Q_DELETEPRINTER *q_u, SPOOL_R_DELETEPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + Printer_entry *Printer=find_printer_index_by_hnd(handle); uint32 result; if (Printer && Printer->document_started) _spoolss_enddocprinter(handle); /* print job was not closed */ + memcpy(&r_u->handle, &q_u->handle, sizeof(r_u->handle)); + result = delete_printer_handle(handle); if (result == ERROR_SUCCESS) { @@ -1155,13 +1174,17 @@ static BOOL getprinterdata_printer(POLICY_HND *handle, /******************************************************************** * spoolss_getprinterdata ********************************************************************/ -uint32 _spoolss_getprinterdata(pipes_struct *p, POLICY_HND *handle, UNISTR2 *valuename, - uint32 in_size, - uint32 *type, - uint32 *out_size, - uint8 **data, - uint32 *needed) + +uint32 _spoolss_getprinterdata(pipes_struct *p, SPOOL_Q_GETPRINTERDATA *q_u, SPOOL_R_GETPRINTERDATA *r_u) { + POLICY_HND *handle = &q_u->handle; + UNISTR2 *valuename = &q_u->valuename; + uint32 in_size = q_u->size; + uint32 *type = &r_u->type; + uint32 *out_size = &r_u->size; + uint8 **data = &r_u->data; + uint32 *needed = &r_u->needed; + fstring value; BOOL found=False; Printer_entry *Printer = find_printer_index_by_hnd(handle); @@ -1252,10 +1275,16 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin * in fact ReplyOpenPrinter is the changenotify equivalent on the spoolss pipe * called from api_spoolss_rffpcnex ********************************************************************/ -uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, - const UNISTR2 *localmachine, uint32 printerlocal, - SPOOL_NOTIFY_OPTION *option) + +uint32 _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNEX *r_u) { + POLICY_HND *handle = &q_u->handle; + uint32 flags = q_u->flags; + uint32 options = q_u->options; + UNISTR2 *localmachine = &q_u->localmachine; + uint32 printerlocal = q_u->printerlocal; + SPOOL_NOTIFY_OPTION *option = q_u->option; + /* store the notify value in the printer struct */ Printer_entry *Printer=find_printer_index_by_hnd(handle); @@ -1283,6 +1312,7 @@ uint32 _spoolss_rffpcnex(POLICY_HND *handle, uint32 flags, uint32 options, /******************************************************************* * fill a notify_info_data with the servername ********************************************************************/ + static void spoolss_notify_server_name(int snum, SPOOL_NOTIFY_INFO_DATA *data, print_queue_struct *queue, @@ -2330,12 +2360,20 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info, /******************************************************************** * spoolss_rfnpcnex ********************************************************************/ -uint32 _spoolss_rfnpcnex( pipes_struct *p, POLICY_HND *handle, uint32 change, - SPOOL_NOTIFY_OPTION *option, SPOOL_NOTIFY_INFO *info) + +uint32 _spoolss_rfnpcnex( pipes_struct *p, SPOOL_Q_RFNPCNEX *q_u, SPOOL_R_RFNPCNEX *r_u) { + POLICY_HND *handle = &q_u->handle; +/* uint32 change = q_u->change; - notused. */ +/* SPOOL_NOTIFY_OPTION *option = q_u->option; - notused. */ + SPOOL_NOTIFY_INFO *info = &r_u->info; + Printer_entry *Printer=find_printer_index_by_hnd(handle); uint32 result = ERROR_INVALID_HANDLE; + /* we always have a NOTIFY_INFO struct */ + r_u->info_ptr=0x1; + if (!OPEN_HANDLE(Printer)) { DEBUG(0,("_spoolss_rfnpcnex: Invalid handle (%s).\n", OUR_HANDLE(handle))); @@ -2874,6 +2912,7 @@ static BOOL enum_all_printers_info_1_remote(fstring name, NEW_BUFFER *buffer, ui /******************************************************************** enum_all_printers_info_1_network. *********************************************************************/ + static BOOL enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { DEBUG(4,("enum_all_printers_info_1_network\n")); @@ -2886,6 +2925,7 @@ static BOOL enum_all_printers_info_1_network(NEW_BUFFER *buffer, uint32 offered, * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ + static BOOL enum_all_printers_info_2(NEW_BUFFER *buffer, uint32 offered, uint32 *needed, uint32 *returned) { int snum; @@ -3010,12 +3050,23 @@ static uint32 enumprinters_level5( uint32 flags, fstring servername, * * called from api_spoolss_enumprinters (see this to understand) ********************************************************************/ -uint32 _spoolss_enumprinters( uint32 flags, const UNISTR2 *servername, uint32 level, - NEW_BUFFER *buffer, uint32 offered, - uint32 *needed, uint32 *returned) + +uint32 _spoolss_enumprinters( pipes_struct *p, SPOOL_Q_ENUMPRINTERS *q_u, SPOOL_R_ENUMPRINTERS *r_u) { + uint32 flags = q_u->flags; + UNISTR2 *servername = &q_u->servername; + uint32 level = q_u->level; + NEW_BUFFER *buffer = NULL; + uint32 offered = q_u->offered; + uint32 *needed = &r_u->needed; + uint32 *returned = &r_u->returned; + fstring name; + /* that's an [in out] buffer */ + new_spoolss_move_buffer(q_u->buffer, &r_u->buffer); + buffer = r_u->buffer; + DEBUG(4,("_spoolss_enumprinters\n")); *needed=0; @@ -3900,8 +3951,10 @@ static uint32 control_printer(POLICY_HND *handle, uint32 command, * api_spoolss_abortprinter ********************************************************************/ -uint32 _spoolss_abortprinter(POLICY_HND *handle, pipes_struct *p) +uint32 _spoolss_abortprinter(pipes_struct *p, SPOOL_Q_ABORTPRINTER *q_u, SPOOL_R_ABORTPRINTER *r_u) { + POLICY_HND *handle = &q_u->handle; + return control_printer(handle, PRINTER_CONTROL_PURGE, p); } @@ -5859,8 +5912,12 @@ uint32 _spoolss_setprinterdata( POLICY_HND *handle, /**************************************************************************** ****************************************************************************/ -uint32 _spoolss_deleteprinterdata( POLICY_HND *handle, const UNISTR2 *value) + +uint32 _spoolss_deleteprinterdata(pipes_struct *p, SPOOL_Q_DELETEPRINTERDATA *q_u, SPOOL_R_DELETEPRINTERDATA *r_u) { + POLICY_HND *handle = &q_u->handle; + UNISTR2 *value = &q_u->valuename; + NT_PRINTER_INFO_LEVEL *printer = NULL; NT_PRINTER_PARAM param; int snum=0; -- cgit