From 48a3e00224cf3dbfc903c99d6110a09a5efabca4 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 25 Jul 2000 21:07:46 +0000 Subject: some initial code for AddPrinterEx() project. Most is ifdef'd out 'cause it's not all written. -jerry (This used to be commit 2c0f6bcc8f926ee9c17de12671075e8a9239bb94) --- source3/rpcclient/cmd_spoolss.c | 116 ++++++++++++++++++++++++++++++++++++++- source3/rpcclient/spoolss_cmds.c | 4 ++ 2 files changed, 119 insertions(+), 1 deletion(-) (limited to 'source3/rpcclient') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 3a80e5d0e7..7ed6dd80ce 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -5,6 +5,7 @@ Copyright (C) Andrew Tridgell 1994-2000 Copyright (C) Luke Kenneth Casson Leighton 1996-2000 Copyright (C) Jean-Francois Micouleau 1999-2000 + Copyright (C) Gerald Carter 2000 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -457,7 +458,7 @@ uint32 cmd_spoolss_getprinterdriverdir(struct client_info *info, int argc, char uint32 level = 1; fstring srv_name; - fstring env; + fstring env; fstrcpy(srv_name, "\\\\"); fstrcat(srv_name, info->dest_host); @@ -483,3 +484,116 @@ uint32 cmd_spoolss_getprinterdriverdir(struct client_info *info, int argc, char return NT_STATUS_NOPROBLEMO; } +/******************************************************************************** + send an AddPrinterEx() request +********************************************************************************/ +uint32 cmd_spoolss_addprinterex(struct client_info *info, int argc, char *argv[]) +{ +#if 0 + PRINTER_INFO_CTR ctr; + uint32 level = 2; + fstring srv_name, + printer_name, + driver_name, + port_name; + POLICY_HND hnd; + PRINTER_INFO_2 print_info_2; + PORT_INFO_1 *port_info_1 = NULL; + NEW_BUFFER buffer; + uint32 status, + needed, + returned; + uint32 i; + fstring srv_port_name; + BOOL valid_port = False; + + fstrcpy(srv_name, "\\\\"); + fstrcat(srv_name, info->dest_host); + strupper(srv_name); + + /* check (and copy) the command line arguments */ + if (argc < 2) { + report(out_hnd, "spooladdprinterex \n"); + return NT_STATUS_NOPROBLEMO; + } + + fstrcpy(printer_name, argv[1]); + fstrcpy(driver_name, argv[2]); + fstrcpy(port_name, argv[3]); + + + /* Verify that the specified port is ok; spoolss_enum_ports() should + be a level 1 since all we need is the name */ + init_buffer (&buffer, 0); + + /* send a NULL buffer first */ + status=spoolss_enum_ports(srv_name, 1, &buffer, 0, + &needed, &returned); + + /* send the right amount of space this time */ + if (status==ERROR_INSUFFICIENT_BUFFER) { + init_buffer(&buffer, needed); + status=spoolss_enum_ports(srv_name, 1, &buffer, + needed, &needed, &returned); + + /* if the call succeeded, then decode the buffer into + an PRINTER_INFO_1 structre */ + if (status == NT_STATUS_NO_PROBLEMO) + { + decode_port_info_1 (&buffer, returned, &port_info_1); + } + else + { + report (out_hnd, "cmd_spoolss_addprinterex: FAILED to enumerate ports\n")); + return NT_STATUS_NOPROBLEMO; + } + + } + + /* + * now we have an array of port names and we can interate + * through it to verify port_name before actually attempting + * to add the printer on the server. + */ + for (i=0; i Spool AddPrinterEx()", + {NULL, NULL}}, /* * oop! */ -- cgit