2002-04-02 05:10:41 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2001-01-12 01:49:30 +03:00
RPC pipe client
2005-07-20 19:35:29 +04:00
Copyright ( C ) Gerald Carter 2001 - 2005
2001-01-12 01:49:30 +03:00
Copyright ( C ) Tim Potter 2000
Copyright ( C ) Andrew Tridgell 1992 - 1999
Copyright ( C ) Luke Kenneth Casson Leighton 1996 - 1999
2009-02-09 14:40:12 +03:00
2000-07-07 10:18:00 +04:00
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
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2000-07-07 10:18:00 +04:00
( at your option ) any later version .
2009-02-09 14:40:12 +03:00
2000-07-07 10:18:00 +04:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2009-02-09 14:40:12 +03:00
2000-07-07 10:18:00 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2000-07-07 10:18:00 +04:00
*/
# include "includes.h"
2001-10-12 09:56:23 +04:00
# include "rpcclient.h"
2000-07-07 10:18:00 +04:00
2009-02-10 17:11:29 +03:00
# define RPCCLIENT_PRINTERNAME(_printername, _cli, _arg) \
{ \
_printername = talloc_asprintf_strupper_m ( mem_ctx , " %s \\ %s " , \
_cli - > srv_name_slash , _arg ) ; \
W_ERROR_HAVE_NO_MEMORY ( _printername ) ; \
}
2001-03-16 01:06:53 +03:00
struct table_node {
2003-01-03 11:28:12 +03:00
const char * long_archi ;
const char * short_archi ;
2001-03-16 01:06:53 +03:00
int version ;
2001-03-15 10:13:27 +03:00
} ;
2009-02-09 14:40:12 +03:00
2005-01-24 21:42:33 +03:00
/* The version int is used by getdrivers. Note that
all architecture strings that support mutliple
versions must be grouped together since enumdrivers
2009-02-09 14:40:12 +03:00
uses this property to prevent issuing multiple
2005-01-24 21:42:33 +03:00
enumdriver calls for the same arch */
2003-01-03 11:28:12 +03:00
static const struct table_node archi_table [ ] = {
2001-03-16 01:06:53 +03:00
{ " Windows 4.0 " , " WIN40 " , 0 } ,
{ " Windows NT x86 " , " W32X86 " , 2 } ,
2003-08-19 20:56:53 +04:00
{ " Windows NT x86 " , " W32X86 " , 3 } ,
2001-03-16 01:06:53 +03:00
{ " Windows NT R4000 " , " W32MIPS " , 2 } ,
{ " Windows NT Alpha_AXP " , " W32ALPHA " , 2 } ,
{ " Windows NT PowerPC " , " W32PPC " , 2 } ,
2004-08-10 18:27:17 +04:00
{ " Windows IA64 " , " IA64 " , 3 } ,
2004-10-05 02:13:57 +04:00
{ " Windows x64 " , " x64 " , 3 } ,
2001-03-16 01:06:53 +03:00
{ NULL , " " , - 1 }
2001-03-15 10:13:27 +03:00
} ;
2003-02-26 02:51:56 +03:00
/**
* @ file
*
* rpcclient module for SPOOLSS rpc pipe .
*
* This generally just parses and checks command lines , and then calls
* a cli_spoolss function .
* */
2001-03-16 01:06:53 +03:00
/****************************************************************************
2005-07-20 19:35:29 +04:00
function to do the mapping between the long architecture name and
the short one .
2001-03-16 01:06:53 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2003-04-23 17:27:35 +04:00
static const char * cmd_spoolss_get_short_archi ( const char * long_archi )
2001-03-16 01:06:53 +03:00
{
int i = - 1 ;
DEBUG ( 107 , ( " Getting architecture dependant directory \n " ) ) ;
do {
i + + ;
} while ( ( archi_table [ i ] . long_archi ! = NULL ) & &
StrCaseCmp ( long_archi , archi_table [ i ] . long_archi ) ) ;
if ( archi_table [ i ] . long_archi = = NULL ) {
DEBUGADD ( 10 , ( " Unknown architecture [%s] ! \n " , long_archi ) ) ;
2003-04-23 17:27:35 +04:00
return NULL ;
2001-03-16 01:06:53 +03:00
}
2003-01-14 11:53:59 +03:00
/* this might be client code - but shouldn't this be an fstrcpy etc? */
2001-03-16 01:06:53 +03:00
DEBUGADD ( 108 , ( " index: [%d] \n " , i ) ) ;
2003-04-23 17:27:35 +04:00
DEBUGADD ( 108 , ( " long architecture: [%s] \n " , archi_table [ i ] . long_archi ) ) ;
DEBUGADD ( 108 , ( " short architecture: [%s] \n " , archi_table [ i ] . short_archi ) ) ;
2001-03-16 01:06:53 +03:00
2003-04-23 17:27:35 +04:00
return archi_table [ i ] . short_archi ;
2001-03-16 01:06:53 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-03-15 05:15:05 +03:00
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_open_printer_ex ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-03-15 05:15:05 +03:00
{
2002-01-06 06:54:40 +03:00
WERROR werror ;
2001-03-15 05:15:05 +03:00
POLICY_HND hnd ;
2009-02-09 14:40:12 +03:00
2001-03-15 05:15:05 +03:00
if ( argc ! = 2 ) {
2001-04-28 04:32:56 +04:00
printf ( " Usage: %s <printername> \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-03-15 05:15:05 +03:00
}
2009-02-09 14:40:12 +03:00
2001-03-15 05:15:05 +03:00
if ( ! cli )
2003-03-18 09:30:30 +03:00
return WERR_GENERAL_FAILURE ;
2001-04-28 04:32:56 +04:00
2001-03-15 10:13:27 +03:00
/* Open the printer handle */
2001-03-15 05:15:05 +03:00
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
argv [ 1 ] ,
PRINTER_ALL_ACCESS ,
& hnd ) ;
2002-01-06 06:54:40 +03:00
if ( W_ERROR_IS_OK ( werror ) ) {
2009-02-09 20:49:34 +03:00
printf ( " Printer %s opened successfully \n " , argv [ 1 ] ) ;
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & hnd , & werror ) ;
2002-01-06 06:54:40 +03:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
2009-02-09 14:40:12 +03:00
printf ( " Error closing printer handle! (%s) \n " ,
2002-01-06 06:54:40 +03:00
get_dos_error_msg ( werror ) ) ;
2001-03-15 05:15:05 +03:00
}
}
2003-03-18 09:30:30 +03:00
return werror ;
2001-03-15 05:15:05 +03:00
}
2000-07-14 20:29:22 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2002-01-03 06:51:13 +03:00
static void display_print_info_0 ( PRINTER_INFO_0 * i0 )
2000-07-14 20:29:22 +04:00
{
2002-03-07 07:22:16 +03:00
fstring name = " " ;
fstring servername = " " ;
if ( ! i0 )
return ;
2000-07-14 20:29:22 +04:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( name , i0 - > printername . buffer , sizeof ( name ) , - 1 , STR_TERMINATE ) ;
2002-01-03 06:51:13 +03:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( servername , i0 - > servername . buffer , sizeof ( servername ) , - 1 , STR_TERMINATE ) ;
2009-02-09 14:40:12 +03:00
2001-01-12 01:49:30 +03:00
printf ( " \t printername:[%s] \n " , name ) ;
2001-05-04 11:34:16 +04:00
printf ( " \t servername:[%s] \n " , servername ) ;
2002-01-03 06:51:13 +03:00
printf ( " \t cjobs:[0x%x] \n " , i0 - > cjobs ) ;
printf ( " \t total_jobs:[0x%x] \n " , i0 - > total_jobs ) ;
2009-02-09 14:40:12 +03:00
printf ( " \t :date: [%d]-[%d]-[%d] (%d) \n " , i0 - > year , i0 - > month ,
2002-01-03 06:51:13 +03:00
i0 - > day , i0 - > dayofweek ) ;
2009-02-09 14:40:12 +03:00
printf ( " \t :time: [%d]-[%d]-[%d]-[%d] \n " , i0 - > hour , i0 - > minute ,
2002-01-03 06:51:13 +03:00
i0 - > second , i0 - > milliseconds ) ;
2009-02-09 14:40:12 +03:00
2002-01-03 06:51:13 +03:00
printf ( " \t global_counter:[0x%x] \n " , i0 - > global_counter ) ;
printf ( " \t total_pages:[0x%x] \n " , i0 - > total_pages ) ;
2009-02-09 14:40:12 +03:00
2002-01-03 06:51:13 +03:00
printf ( " \t majorversion:[0x%x] \n " , i0 - > major_version ) ;
printf ( " \t buildversion:[0x%x] \n " , i0 - > build_version ) ;
2009-02-09 14:40:12 +03:00
2002-01-03 06:51:13 +03:00
printf ( " \t unknown7:[0x%x] \n " , i0 - > unknown7 ) ;
printf ( " \t unknown8:[0x%x] \n " , i0 - > unknown8 ) ;
printf ( " \t unknown9:[0x%x] \n " , i0 - > unknown9 ) ;
printf ( " \t session_counter:[0x%x] \n " , i0 - > session_counter ) ;
printf ( " \t unknown11:[0x%x] \n " , i0 - > unknown11 ) ;
printf ( " \t printer_errors:[0x%x] \n " , i0 - > printer_errors ) ;
printf ( " \t unknown13:[0x%x] \n " , i0 - > unknown13 ) ;
printf ( " \t unknown14:[0x%x] \n " , i0 - > unknown14 ) ;
printf ( " \t unknown15:[0x%x] \n " , i0 - > unknown15 ) ;
printf ( " \t unknown16:[0x%x] \n " , i0 - > unknown16 ) ;
printf ( " \t change_id:[0x%x] \n " , i0 - > change_id ) ;
printf ( " \t unknown18:[0x%x] \n " , i0 - > unknown18 ) ;
printf ( " \t status:[0x%x] \n " , i0 - > status ) ;
printf ( " \t unknown20:[0x%x] \n " , i0 - > unknown20 ) ;
printf ( " \t c_setprinter:[0x%x] \n " , i0 - > c_setprinter ) ;
printf ( " \t unknown22:[0x%x] \n " , i0 - > unknown22 ) ;
printf ( " \t unknown23:[0x%x] \n " , i0 - > unknown23 ) ;
printf ( " \t unknown24:[0x%x] \n " , i0 - > unknown24 ) ;
printf ( " \t unknown25:[0x%x] \n " , i0 - > unknown25 ) ;
printf ( " \t unknown26:[0x%x] \n " , i0 - > unknown26 ) ;
printf ( " \t unknown27:[0x%x] \n " , i0 - > unknown27 ) ;
printf ( " \t unknown28:[0x%x] \n " , i0 - > unknown28 ) ;
printf ( " \t unknown29:[0x%x] \n " , i0 - > unknown29 ) ;
2002-03-07 07:22:16 +03:00
printf ( " \n " ) ;
2000-07-14 20:29:22 +04:00
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2001-01-12 01:49:30 +03:00
static void display_print_info_1 ( PRINTER_INFO_1 * i1 )
2000-07-14 20:29:22 +04:00
{
2002-01-03 06:51:13 +03:00
fstring desc = " " ;
fstring name = " " ;
fstring comm = " " ;
2002-01-03 05:48:23 +03:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( desc , i1 - > description . buffer , sizeof ( desc ) , - 1 ,
STR_TERMINATE ) ;
2002-01-03 05:48:23 +03:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( name , i1 - > name . buffer , sizeof ( name ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( comm , i1 - > comment . buffer , sizeof ( comm ) , - 1 , STR_TERMINATE ) ;
2001-01-12 01:49:30 +03:00
printf ( " \t flags:[0x%x] \n " , i1 - > flags ) ;
printf ( " \t name:[%s] \n " , name ) ;
printf ( " \t description:[%s] \n " , desc ) ;
2002-03-07 07:22:16 +03:00
printf ( " \t comment:[%s] \n " , comm ) ;
printf ( " \n " ) ;
2000-07-14 20:29:22 +04:00
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2001-01-12 01:49:30 +03:00
static void display_print_info_2 ( PRINTER_INFO_2 * i2 )
2000-07-14 20:29:22 +04:00
{
2002-01-03 06:51:13 +03:00
fstring servername = " " ;
fstring printername = " " ;
fstring sharename = " " ;
fstring portname = " " ;
fstring drivername = " " ;
fstring comment = " " ;
fstring location = " " ;
fstring sepfile = " " ;
fstring printprocessor = " " ;
fstring datatype = " " ;
fstring parameters = " " ;
2009-02-09 14:40:12 +03:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( servername , i2 - > servername . buffer , sizeof ( servername ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( printername , i2 - > printername . buffer , sizeof ( printername ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( sharename , i2 - > sharename . buffer , sizeof ( sharename ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( portname , i2 - > portname . buffer , sizeof ( portname ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( drivername , i2 - > drivername . buffer , sizeof ( drivername ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( comment , i2 - > comment . buffer , sizeof ( comment ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( location , i2 - > location . buffer , sizeof ( location ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( sepfile , i2 - > sepfile . buffer , sizeof ( sepfile ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( printprocessor , i2 - > printprocessor . buffer , sizeof ( printprocessor ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( datatype , i2 - > datatype . buffer , sizeof ( datatype ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( parameters , i2 - > parameters . buffer , sizeof ( parameters ) , - 1 , STR_TERMINATE ) ;
2001-01-12 01:49:30 +03:00
printf ( " \t servername:[%s] \n " , servername ) ;
printf ( " \t printername:[%s] \n " , printername ) ;
printf ( " \t sharename:[%s] \n " , sharename ) ;
printf ( " \t portname:[%s] \n " , portname ) ;
printf ( " \t drivername:[%s] \n " , drivername ) ;
printf ( " \t comment:[%s] \n " , comment ) ;
printf ( " \t location:[%s] \n " , location ) ;
printf ( " \t sepfile:[%s] \n " , sepfile ) ;
printf ( " \t printprocessor:[%s] \n " , printprocessor ) ;
printf ( " \t datatype:[%s] \n " , datatype ) ;
printf ( " \t parameters:[%s] \n " , parameters ) ;
printf ( " \t attributes:[0x%x] \n " , i2 - > attributes ) ;
printf ( " \t priority:[0x%x] \n " , i2 - > priority ) ;
printf ( " \t defaultpriority:[0x%x] \n " , i2 - > defaultpriority ) ;
printf ( " \t starttime:[0x%x] \n " , i2 - > starttime ) ;
printf ( " \t untiltime:[0x%x] \n " , i2 - > untiltime ) ;
printf ( " \t status:[0x%x] \n " , i2 - > status ) ;
printf ( " \t cjobs:[0x%x] \n " , i2 - > cjobs ) ;
printf ( " \t averageppm:[0x%x] \n " , i2 - > averageppm ) ;
2009-02-09 14:40:12 +03:00
if ( i2 - > secdesc )
2002-03-07 07:22:16 +03:00
display_sec_desc ( i2 - > secdesc ) ;
printf ( " \n " ) ;
2000-07-14 20:29:22 +04:00
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2001-01-12 01:49:30 +03:00
static void display_print_info_3 ( PRINTER_INFO_3 * i3 )
2000-07-14 20:29:22 +04:00
{
2001-01-12 01:49:30 +03:00
display_sec_desc ( i3 - > secdesc ) ;
2002-03-07 07:22:16 +03:00
printf ( " \n " ) ;
2000-07-14 20:29:22 +04:00
}
2004-08-26 01:26:37 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2009-02-14 05:08:06 +03:00
static void display_print_info7 ( struct spoolss_PrinterInfo7 * r )
2004-08-26 01:26:37 +04:00
{
2009-02-14 05:08:06 +03:00
printf ( " \t guid:[%s] \n " , r - > guid ) ;
printf ( " \t action:[0x%x] \n " , r - > action ) ;
2004-08-26 01:26:37 +04:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-01-12 01:49:30 +03:00
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_enum_printers ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2000-07-14 20:29:22 +04:00
{
2002-01-06 12:03:48 +03:00
WERROR result ;
2001-09-04 14:57:29 +04:00
uint32 info_level = 1 ;
2001-03-15 10:13:27 +03:00
PRINTER_INFO_CTR ctr ;
2005-07-20 19:35:29 +04:00
uint32 i = 0 , num_printers ;
2002-09-25 19:19:00 +04:00
fstring name ;
2001-04-28 04:32:56 +04:00
2009-02-09 14:40:12 +03:00
if ( argc > 3 )
2001-03-15 10:13:27 +03:00
{
2002-09-25 19:19:00 +04:00
printf ( " Usage: %s [level] [name] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-01-12 01:49:30 +03:00
}
2004-06-24 13:15:39 +04:00
if ( argc > = 2 )
2001-01-12 01:49:30 +03:00
info_level = atoi ( argv [ 1 ] ) ;
2002-09-25 19:19:00 +04:00
if ( argc = = 3 )
fstrcpy ( name , argv [ 2 ] ) ;
else {
2008-04-19 23:56:43 +04:00
slprintf ( name , sizeof ( name ) - 1 , " \\ \\ %s " , cli - > desthost ) ;
2003-07-03 23:11:31 +04:00
strupper_m ( name ) ;
2001-01-12 01:49:30 +03:00
}
ZERO_STRUCT ( ctr ) ;
2000-07-14 20:29:22 +04:00
2009-02-09 14:40:12 +03:00
result = rpccli_spoolss_enum_printers ( cli , mem_ctx , name , PRINTER_ENUM_LOCAL ,
2002-01-06 12:03:48 +03:00
info_level , & num_printers , & ctr ) ;
if ( W_ERROR_IS_OK ( result ) ) {
2002-03-07 07:29:13 +03:00
if ( ! num_printers ) {
printf ( " No printers returned. \n " ) ;
goto done ;
}
2009-02-09 14:40:12 +03:00
2002-03-07 07:22:16 +03:00
for ( i = 0 ; i < num_printers ; i + + ) {
switch ( info_level ) {
case 0 :
2002-01-06 12:03:48 +03:00
display_print_info_0 ( & ctr . printers_0 [ i ] ) ;
2002-03-07 07:22:16 +03:00
break ;
case 1 :
2002-01-06 12:03:48 +03:00
display_print_info_1 ( & ctr . printers_1 [ i ] ) ;
2002-03-07 07:22:16 +03:00
break ;
case 2 :
2002-01-06 12:03:48 +03:00
display_print_info_2 ( & ctr . printers_2 [ i ] ) ;
2002-03-07 07:22:16 +03:00
break ;
case 3 :
2002-01-06 12:03:48 +03:00
display_print_info_3 ( & ctr . printers_3 [ i ] ) ;
2002-03-07 07:22:16 +03:00
break ;
default :
printf ( " unknown info level %d \n " , info_level ) ;
goto done ;
}
2001-01-12 01:49:30 +03:00
}
}
2002-03-08 06:36:03 +03:00
done :
2001-01-12 01:49:30 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2000-07-14 20:29:22 +04:00
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2001-01-12 01:49:30 +03:00
static void display_port_info_1 ( PORT_INFO_1 * i1 )
2000-07-14 20:29:22 +04:00
{
2001-01-12 01:49:30 +03:00
fstring buffer ;
2009-02-09 14:40:12 +03:00
2002-05-07 10:36:22 +04:00
rpcstr_pull ( buffer , i1 - > port_name . buffer , sizeof ( buffer ) , - 1 , STR_TERMINATE ) ;
2001-01-12 01:49:30 +03:00
printf ( " \t Port Name: \t [%s] \n " , buffer ) ;
}
2000-07-14 20:29:22 +04:00
2001-01-12 01:49:30 +03:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2001-01-12 01:49:30 +03:00
static void display_port_info_2 ( PORT_INFO_2 * i2 )
{
fstring buffer ;
2009-02-09 14:40:12 +03:00
2002-05-07 10:36:22 +04:00
rpcstr_pull ( buffer , i2 - > port_name . buffer , sizeof ( buffer ) , - 1 , STR_TERMINATE ) ;
2001-01-12 01:49:30 +03:00
printf ( " \t Port Name: \t [%s] \n " , buffer ) ;
2002-05-07 10:36:22 +04:00
rpcstr_pull ( buffer , i2 - > monitor_name . buffer , sizeof ( buffer ) , - 1 , STR_TERMINATE ) ;
2001-07-04 11:15:53 +04:00
2001-01-12 01:49:30 +03:00
printf ( " \t Monitor Name: \t [%s] \n " , buffer ) ;
2002-05-07 10:36:22 +04:00
rpcstr_pull ( buffer , i2 - > description . buffer , sizeof ( buffer ) , - 1 , STR_TERMINATE ) ;
2001-07-04 11:15:53 +04:00
2001-01-12 01:49:30 +03:00
printf ( " \t Description: \t [%s] \n " , buffer ) ;
2003-08-07 04:55:35 +04:00
printf ( " \t Port Type: \t " ) ;
if ( i2 - > port_type ) {
int comma = 0 ; /* hack */
printf ( " [ " ) ;
if ( i2 - > port_type & PORT_TYPE_READ ) {
printf ( " Read " ) ;
comma = 1 ;
}
if ( i2 - > port_type & PORT_TYPE_WRITE ) {
printf ( " %sWrite " , comma ? " , " : " " ) ;
comma = 1 ;
}
/* These two have slightly different interpretations
on 95 / 98 / ME but I ' m disregarding that for now */
if ( i2 - > port_type & PORT_TYPE_REDIRECTED ) {
printf ( " %sRedirected " , comma ? " , " : " " ) ;
comma = 1 ;
}
if ( i2 - > port_type & PORT_TYPE_NET_ATTACHED ) {
printf ( " %sNet-Attached " , comma ? " , " : " " ) ;
}
printf ( " ] \n " ) ;
} else {
printf ( " [Unset] \n " ) ;
}
2001-01-12 01:49:30 +03:00
printf ( " \t Reserved: \t [%d] \n " , i2 - > reserved ) ;
printf ( " \n " ) ;
}
2000-07-14 20:29:22 +04:00
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2000-07-14 20:29:22 +04:00
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_enum_ports ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2001-01-12 01:49:30 +03:00
{
2002-01-06 12:03:48 +03:00
WERROR result ;
2005-07-20 19:35:29 +04:00
uint32 info_level = 1 ;
2001-03-15 10:13:27 +03:00
PORT_INFO_CTR ctr ;
2004-08-24 15:56:51 +04:00
uint32 returned ;
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
if ( argc > 2 ) {
2001-04-28 04:32:56 +04:00
printf ( " Usage: %s [level] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-01-12 01:49:30 +03:00
}
2009-02-09 14:40:12 +03:00
2002-01-06 12:03:48 +03:00
if ( argc = = 2 )
2001-01-12 01:49:30 +03:00
info_level = atoi ( argv [ 1 ] ) ;
2000-07-14 20:29:22 +04:00
2001-03-14 23:22:57 +03:00
/* Enumerate ports */
2002-01-06 12:03:48 +03:00
2001-01-12 01:49:30 +03:00
ZERO_STRUCT ( ctr ) ;
2005-09-30 21:13:37 +04:00
result = rpccli_spoolss_enum_ports ( cli , mem_ctx , info_level , & returned , & ctr ) ;
2001-01-12 01:49:30 +03:00
2002-01-06 12:03:48 +03:00
if ( W_ERROR_IS_OK ( result ) ) {
2001-01-12 01:49:30 +03:00
int i ;
for ( i = 0 ; i < returned ; i + + ) {
switch ( info_level ) {
case 1 :
display_port_info_1 ( & ctr . port . info_1 [ i ] ) ;
2002-01-06 12:03:48 +03:00
break ;
2001-01-12 01:49:30 +03:00
case 2 :
display_port_info_2 ( & ctr . port . info_2 [ i ] ) ;
break ;
default :
2001-01-12 20:53:47 +03:00
printf ( " unknown info level %d \n " , info_level ) ;
2001-01-12 01:49:30 +03:00
break ;
}
2000-07-26 01:07:46 +04:00
}
}
2009-02-09 14:40:12 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2000-07-26 01:07:46 +04:00
}
2000-08-08 10:57:48 +04:00
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_setprinter ( struct rpc_pipe_client * cli ,
2002-04-02 05:10:41 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2002-04-02 05:10:41 +04:00
{
POLICY_HND pol ;
WERROR result ;
2009-02-14 05:08:06 +03:00
NTSTATUS status ;
2002-04-02 05:10:41 +04:00
uint32 info_level = 2 ;
2009-02-14 05:08:06 +03:00
union spoolss_PrinterInfo info ;
struct spoolss_SetPrinterInfoCtr info_ctr ;
2009-02-10 17:11:29 +03:00
const char * printername , * comment = NULL ;
2009-02-14 05:08:06 +03:00
struct spoolss_DevmodeContainer devmode_ctr ;
struct sec_desc_buf secdesc_ctr ;
2002-04-02 05:10:41 +04:00
if ( argc = = 1 | | argc > 3 ) {
printf ( " Usage: %s printername comment \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-04-02 05:10:41 +04:00
}
/* Open a printer handle */
if ( argc = = 3 ) {
2009-02-10 17:11:29 +03:00
comment = argv [ 2 ] ;
2002-04-02 05:10:41 +04:00
}
2009-02-14 05:08:06 +03:00
ZERO_STRUCT ( devmode_ctr ) ;
ZERO_STRUCT ( secdesc_ctr ) ;
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-04-02 05:10:41 +04:00
/* get a printer handle */
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
PRINTER_ALL_ACCESS ,
& pol ) ;
2002-04-02 05:10:41 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
/* Get printer info */
2009-02-14 05:08:06 +03:00
result = rpccli_spoolss_getprinter ( cli , mem_ctx ,
& pol ,
info_level ,
0 ,
& info ) ;
2002-04-02 05:10:41 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
/* Modify the comment. */
2009-02-14 05:08:06 +03:00
info . info2 . comment = comment ;
2009-03-02 13:21:26 +03:00
info . info2 . secdesc = NULL ;
info . info2 . devmode = NULL ;
2002-04-02 05:10:41 +04:00
2009-02-14 05:08:06 +03:00
info_ctr . level = 2 ;
info_ctr . info . info2 = ( struct spoolss_SetPrinterInfo2 * ) & info . info2 ;
status = rpccli_spoolss_SetPrinter ( cli , mem_ctx ,
& pol ,
& info_ctr ,
& devmode_ctr ,
& secdesc_ctr ,
0 , /* command */
& result ) ;
2002-04-02 05:10:41 +04:00
if ( W_ERROR_IS_OK ( result ) )
printf ( " Success in setting comment. \n " ) ;
done :
2009-02-25 14:09:15 +03:00
if ( is_valid_policy_hnd ( & pol ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & pol , NULL ) ;
2002-04-02 05:10:41 +04:00
2003-03-18 09:30:30 +03:00
return result ;
2002-04-02 05:10:41 +04:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_setprintername ( struct rpc_pipe_client * cli ,
2004-06-10 17:07:44 +04:00
TALLOC_CTX * mem_ctx ,
int argc , const char * * argv )
{
POLICY_HND pol ;
WERROR result ;
2009-02-14 05:08:06 +03:00
NTSTATUS status ;
2004-06-10 17:07:44 +04:00
uint32 info_level = 2 ;
2009-02-14 05:08:06 +03:00
union spoolss_PrinterInfo info ;
2009-02-10 17:11:29 +03:00
const char * printername ,
* new_printername = NULL ;
2009-02-14 05:08:06 +03:00
struct spoolss_SetPrinterInfoCtr info_ctr ;
struct spoolss_DevmodeContainer devmode_ctr ;
struct sec_desc_buf secdesc_ctr ;
ZERO_STRUCT ( devmode_ctr ) ;
ZERO_STRUCT ( secdesc_ctr ) ;
2004-06-10 17:07:44 +04:00
if ( argc = = 1 | | argc > 3 ) {
printf ( " Usage: %s printername new_printername \n " , argv [ 0 ] ) ;
return WERR_OK ;
}
/* Open a printer handle */
if ( argc = = 3 ) {
2009-02-10 17:11:29 +03:00
new_printername = argv [ 2 ] ;
2004-06-10 17:07:44 +04:00
}
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2004-06-10 17:07:44 +04:00
/* get a printer handle */
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
PRINTER_ALL_ACCESS ,
& pol ) ;
2004-06-10 17:07:44 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
/* Get printer info */
2009-02-14 05:08:06 +03:00
result = rpccli_spoolss_getprinter ( cli , mem_ctx ,
& pol ,
info_level ,
0 ,
& info ) ;
2004-06-10 17:07:44 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
/* Modify the printername. */
2009-02-14 05:08:06 +03:00
info . info2 . printername = new_printername ;
info . info2 . devmode = NULL ;
info . info2 . secdesc = NULL ;
info_ctr . level = info_level ;
info_ctr . info . info2 = ( struct spoolss_SetPrinterInfo2 * ) & info . info2 ;
status = rpccli_spoolss_SetPrinter ( cli , mem_ctx ,
& pol ,
& info_ctr ,
& devmode_ctr ,
& secdesc_ctr ,
0 , /* command */
& result ) ;
2004-06-10 17:07:44 +04:00
if ( W_ERROR_IS_OK ( result ) )
printf ( " Success in setting printername. \n " ) ;
done :
2009-02-25 14:09:15 +03:00
if ( is_valid_policy_hnd ( & pol ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & pol , NULL ) ;
2004-06-10 17:07:44 +04:00
return result ;
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_getprinter ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2000-08-08 10:57:48 +04:00
{
2001-03-15 10:13:27 +03:00
POLICY_HND pol ;
2002-02-19 05:12:01 +03:00
WERROR result ;
2001-09-04 14:57:29 +04:00
uint32 info_level = 1 ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2009-02-14 05:08:06 +03:00
union spoolss_PrinterInfo info ;
2001-01-12 01:49:30 +03:00
if ( argc = = 1 | | argc > 3 ) {
2001-04-28 04:32:56 +04:00
printf ( " Usage: %s <printername> [level] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2000-08-08 10:57:48 +04:00
}
2001-01-12 01:49:30 +03:00
/* Open a printer handle */
if ( argc = = 3 ) {
info_level = atoi ( argv [ 2 ] ) ;
}
2000-08-10 00:14:29 +04:00
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
/* get a printer handle */
2002-01-06 06:54:40 +03:00
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& pol ) ;
2002-02-19 05:12:01 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
2001-01-12 01:49:30 +03:00
goto done ;
2009-02-09 14:40:12 +03:00
2001-01-12 01:49:30 +03:00
/* Get printer info */
2002-01-06 06:54:40 +03:00
2009-02-14 05:08:06 +03:00
result = rpccli_spoolss_getprinter ( cli , mem_ctx ,
& pol ,
info_level ,
0 ,
& info ) ;
2002-02-19 05:12:01 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
2001-01-12 01:49:30 +03:00
goto done ;
/* Display printer info */
switch ( info_level ) {
2009-02-14 05:08:06 +03:00
#if 0 /* FIXME GD */
2009-02-09 14:40:12 +03:00
case 0 :
2001-01-12 01:49:30 +03:00
display_print_info_0 ( ctr . printers_0 ) ;
break ;
case 1 :
display_print_info_1 ( ctr . printers_1 ) ;
break ;
case 2 :
display_print_info_2 ( ctr . printers_2 ) ;
break ;
case 3 :
display_print_info_3 ( ctr . printers_3 ) ;
break ;
2009-02-14 05:08:06 +03:00
# endif
2004-08-26 01:26:37 +04:00
case 7 :
2009-02-14 05:08:06 +03:00
display_print_info7 ( & info . info7 ) ;
2004-08-26 01:26:37 +04:00
break ;
2001-01-12 01:49:30 +03:00
default :
printf ( " unknown info level %d \n " , info_level ) ;
break ;
2000-08-08 10:57:48 +04:00
}
2009-02-09 14:40:12 +03:00
done :
2009-02-25 14:09:15 +03:00
if ( is_valid_policy_hnd ( & pol ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & pol , NULL ) ;
2001-01-12 20:53:47 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2000-08-08 10:57:48 +04:00
}
2000-08-10 00:14:29 +04:00
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-11-11 18:43:09 +03:00
static void display_reg_value ( REGISTRY_VALUE value )
{
2007-11-21 02:31:37 +03:00
char * text = NULL ;
2002-11-11 18:43:09 +03:00
switch ( value . type ) {
case REG_DWORD :
2007-11-21 02:31:37 +03:00
printf ( " %s: REG_DWORD: 0x%08x \n " , value . valuename ,
2002-11-11 18:43:09 +03:00
* ( ( uint32 * ) value . data_p ) ) ;
break ;
case REG_SZ :
2007-11-21 02:31:37 +03:00
rpcstr_pull_talloc ( talloc_tos ( ) ,
& text ,
value . data_p ,
value . size ,
STR_TERMINATE ) ;
printf ( " %s: REG_SZ: %s \n " , value . valuename , text ? text : " " ) ;
2002-11-11 18:43:09 +03:00
break ;
2005-08-08 01:23:38 +04:00
case REG_BINARY : {
2008-10-18 18:16:57 +04:00
char * hex = hex_encode_talloc ( NULL , value . data_p , value . size ) ;
2005-08-08 01:23:38 +04:00
size_t i , len ;
printf ( " %s: REG_BINARY: " , value . valuename ) ;
len = strlen ( hex ) ;
for ( i = 0 ; i < len ; i + + ) {
if ( hex [ i ] = = ' \0 ' ) {
break ;
}
if ( i % 40 = = 0 ) {
putchar ( ' \n ' ) ;
}
putchar ( hex [ i ] ) ;
}
2006-02-20 20:59:58 +03:00
TALLOC_FREE ( hex ) ;
2005-08-08 01:23:38 +04:00
putchar ( ' \n ' ) ;
2002-11-11 18:43:09 +03:00
break ;
2005-08-08 01:23:38 +04:00
}
2002-11-11 18:43:09 +03:00
case REG_MULTI_SZ : {
2006-11-21 05:21:45 +03:00
uint32 i , num_values ;
2006-07-11 22:01:26 +04:00
char * * values ;
2006-12-01 23:01:09 +03:00
if ( ! W_ERROR_IS_OK ( reg_pull_multi_sz ( NULL , value . data_p ,
value . size , & num_values ,
& values ) ) ) {
2006-07-11 22:01:26 +04:00
d_printf ( " reg_pull_multi_sz failed \n " ) ;
break ;
}
for ( i = 0 ; i < num_values ; i + + ) {
d_printf ( " %s \n " , values [ i ] ) ;
2002-11-11 18:43:09 +03:00
}
2006-07-11 22:01:26 +04:00
TALLOC_FREE ( values ) ;
break ;
2002-11-11 18:43:09 +03:00
}
default :
printf ( " %s: unknown type %d \n " , value . valuename , value . type ) ;
}
2009-02-09 14:40:12 +03:00
2002-11-11 18:43:09 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_getprinterdata ( struct rpc_pipe_client * cli ,
2002-11-11 18:43:09 +03:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2002-11-11 18:43:09 +03:00
{
POLICY_HND pol ;
WERROR result ;
2009-02-09 21:02:56 +03:00
fstring printername ;
2003-02-26 02:51:56 +03:00
const char * valuename ;
2002-11-11 18:43:09 +03:00
REGISTRY_VALUE value ;
if ( argc ! = 3 ) {
printf ( " Usage: %s <printername> <valuename> \n " , argv [ 0 ] ) ;
printf ( " <printername> of . queries print server \n " ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-11-11 18:43:09 +03:00
}
valuename = argv [ 2 ] ;
/* Open a printer handle */
if ( strncmp ( argv [ 1 ] , " . " , sizeof ( " . " ) ) = = 0 )
2009-02-09 20:10:18 +03:00
fstrcpy ( printername , cli - > srv_name_slash ) ;
2002-11-11 18:43:09 +03:00
else
2009-02-09 20:10:18 +03:00
slprintf ( printername , sizeof ( printername ) - 1 , " %s \\ %s " ,
cli - > srv_name_slash , argv [ 1 ] ) ;
2009-02-09 14:40:12 +03:00
2002-11-11 18:43:09 +03:00
/* get a printer handle */
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& pol ) ;
2002-11-11 18:43:09 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2009-02-09 14:40:12 +03:00
2002-11-11 18:43:09 +03:00
/* Get printer info */
2005-09-30 21:13:37 +04:00
result = rpccli_spoolss_getprinterdata ( cli , mem_ctx , & pol , valuename , & value ) ;
2002-11-11 18:43:09 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
/* Display printer data */
fstrcpy ( value . valuename , valuename ) ;
display_reg_value ( value ) ;
2009-02-09 14:40:12 +03:00
done :
2009-02-25 14:09:15 +03:00
if ( is_valid_policy_hnd ( & pol ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & pol , NULL ) ;
2002-11-11 18:43:09 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2002-11-11 18:43:09 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_getprinterdataex ( struct rpc_pipe_client * cli ,
2002-11-11 18:43:09 +03:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2002-11-11 18:43:09 +03:00
{
POLICY_HND pol ;
WERROR result ;
2009-02-13 00:06:54 +03:00
NTSTATUS status ;
2009-02-09 21:02:56 +03:00
fstring printername ;
2003-02-26 02:51:56 +03:00
const char * valuename , * keyname ;
2002-11-11 18:43:09 +03:00
REGISTRY_VALUE value ;
2009-02-13 00:06:54 +03:00
uint32_t type ;
uint8_t * buffer = NULL ;
uint32_t offered = 0 ;
uint32_t needed ;
2002-11-11 18:43:09 +03:00
if ( argc ! = 4 ) {
2009-02-09 14:40:12 +03:00
printf ( " Usage: %s <printername> <keyname> <valuename> \n " ,
2002-11-11 18:43:09 +03:00
argv [ 0 ] ) ;
printf ( " <printername> of . queries print server \n " ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-11-11 18:43:09 +03:00
}
valuename = argv [ 3 ] ;
keyname = argv [ 2 ] ;
/* Open a printer handle */
if ( strncmp ( argv [ 1 ] , " . " , sizeof ( " . " ) ) = = 0 )
2009-02-09 20:10:18 +03:00
fstrcpy ( printername , cli - > srv_name_slash ) ;
2002-11-11 18:43:09 +03:00
else
2009-02-09 14:40:12 +03:00
slprintf ( printername , sizeof ( printername ) - 1 , " %s \\ %s " ,
2009-02-09 20:10:18 +03:00
cli - > srv_name_slash , argv [ 1 ] ) ;
2009-02-09 14:40:12 +03:00
2002-11-11 18:43:09 +03:00
/* get a printer handle */
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& pol ) ;
2002-11-11 18:43:09 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2009-02-09 14:40:12 +03:00
2002-11-11 18:43:09 +03:00
/* Get printer info */
2009-02-13 00:06:54 +03:00
status = rpccli_spoolss_GetPrinterDataEx ( cli , mem_ctx ,
& pol ,
keyname ,
valuename ,
& type ,
buffer ,
offered ,
& needed ,
& result ) ;
if ( W_ERROR_EQUAL ( result , WERR_MORE_DATA ) ) {
offered = needed ;
buffer = talloc_array ( mem_ctx , uint8_t , needed ) ;
status = rpccli_spoolss_GetPrinterDataEx ( cli , mem_ctx ,
& pol ,
keyname ,
valuename ,
& type ,
buffer ,
offered ,
& needed ,
& result ) ;
}
if ( ! NT_STATUS_IS_OK ( status ) ) {
goto done ;
}
if ( ! W_ERROR_IS_OK ( result ) ) {
goto done ;
}
2002-11-11 18:43:09 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
/* Display printer data */
fstrcpy ( value . valuename , valuename ) ;
2009-02-13 00:06:54 +03:00
value . type = type ;
value . size = needed ;
value . data_p = buffer ;
2002-11-11 18:43:09 +03:00
2009-02-13 00:06:54 +03:00
display_reg_value ( value ) ;
2009-02-09 14:40:12 +03:00
done :
2009-02-25 14:09:15 +03:00
if ( is_valid_policy_hnd ( & pol ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & pol , NULL ) ;
2002-11-11 18:43:09 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2002-11-11 18:43:09 +03:00
}
2001-03-15 10:13:27 +03:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2001-03-15 10:13:27 +03:00
static void display_print_driver_1 ( DRIVER_INFO_1 * i1 )
{
fstring name ;
if ( i1 = = NULL )
return ;
2002-05-07 10:36:22 +04:00
rpcstr_pull ( name , i1 - > name . buffer , sizeof ( name ) , - 1 , STR_TERMINATE ) ;
2001-03-15 10:13:27 +03:00
printf ( " Printer Driver Info 1: \n " ) ;
printf ( " \t Driver Name: [%s] \n \n " , name ) ;
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
return ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2001-03-15 10:13:27 +03:00
static void display_print_driver_2 ( DRIVER_INFO_2 * i1 )
{
fstring name ;
fstring architecture ;
fstring driverpath ;
fstring datafile ;
fstring configfile ;
if ( i1 = = NULL )
return ;
2002-05-07 10:36:22 +04:00
rpcstr_pull ( name , i1 - > name . buffer , sizeof ( name ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( architecture , i1 - > architecture . buffer , sizeof ( architecture ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( driverpath , i1 - > driverpath . buffer , sizeof ( driverpath ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( datafile , i1 - > datafile . buffer , sizeof ( datafile ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( configfile , i1 - > configfile . buffer , sizeof ( configfile ) , - 1 , STR_TERMINATE ) ;
2001-03-15 10:13:27 +03:00
printf ( " Printer Driver Info 2: \n " ) ;
printf ( " \t Version: [%x] \n " , i1 - > version ) ;
printf ( " \t Driver Name: [%s] \n " , name ) ;
printf ( " \t Architecture: [%s] \n " , architecture ) ;
printf ( " \t Driver Path: [%s] \n " , driverpath ) ;
printf ( " \t Datafile: [%s] \n " , datafile ) ;
printf ( " \t Configfile: [%s] \n \n " , configfile ) ;
return ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2001-03-15 10:13:27 +03:00
static void display_print_driver_3 ( DRIVER_INFO_3 * i1 )
{
2003-01-29 09:53:07 +03:00
fstring name = " " ;
fstring architecture = " " ;
fstring driverpath = " " ;
fstring datafile = " " ;
fstring configfile = " " ;
fstring helpfile = " " ;
fstring dependentfiles = " " ;
fstring monitorname = " " ;
fstring defaultdatatype = " " ;
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
int length = 0 ;
2007-10-19 04:40:25 +04:00
bool valid = True ;
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
if ( i1 = = NULL )
return ;
2002-05-07 10:36:22 +04:00
rpcstr_pull ( name , i1 - > name . buffer , sizeof ( name ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( architecture , i1 - > architecture . buffer , sizeof ( architecture ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( driverpath , i1 - > driverpath . buffer , sizeof ( driverpath ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( datafile , i1 - > datafile . buffer , sizeof ( datafile ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( configfile , i1 - > configfile . buffer , sizeof ( configfile ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( helpfile , i1 - > helpfile . buffer , sizeof ( helpfile ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( monitorname , i1 - > monitorname . buffer , sizeof ( monitorname ) , - 1 , STR_TERMINATE ) ;
rpcstr_pull ( defaultdatatype , i1 - > defaultdatatype . buffer , sizeof ( defaultdatatype ) , - 1 , STR_TERMINATE ) ;
2001-03-15 10:13:27 +03:00
printf ( " Printer Driver Info 3: \n " ) ;
printf ( " \t Version: [%x] \n " , i1 - > version ) ;
2001-07-04 11:15:53 +04:00
printf ( " \t Driver Name: [%s] \n " , name ) ;
2001-03-15 10:13:27 +03:00
printf ( " \t Architecture: [%s] \n " , architecture ) ;
printf ( " \t Driver Path: [%s] \n " , driverpath ) ;
printf ( " \t Datafile: [%s] \n " , datafile ) ;
printf ( " \t Configfile: [%s] \n " , configfile ) ;
printf ( " \t Helpfile: [%s] \n \n " , helpfile ) ;
while ( valid )
{
2002-05-07 10:36:22 +04:00
rpcstr_pull ( dependentfiles , i1 - > dependentfiles + length , sizeof ( dependentfiles ) , - 1 , STR_TERMINATE ) ;
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
length + = strlen ( dependentfiles ) + 1 ;
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
if ( strlen ( dependentfiles ) > 0 )
{
printf ( " \t Dependentfiles: [%s] \n " , dependentfiles ) ;
}
else
{
valid = False ;
}
}
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
printf ( " \n " ) ;
printf ( " \t Monitorname: [%s] \n " , monitorname ) ;
printf ( " \t Defaultdatatype: [%s] \n \n " , defaultdatatype ) ;
2009-02-09 14:40:12 +03:00
return ;
2001-03-15 10:13:27 +03:00
}
2009-02-25 00:20:30 +03:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void display_print_driver1 ( struct spoolss_DriverInfo1 * r )
{
if ( ! r ) {
return ;
}
printf ( " Printer Driver Info 1: \n " ) ;
printf ( " \t Driver Name: [%s] \n \n " , r - > driver_name ) ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void display_print_driver2 ( struct spoolss_DriverInfo2 * r )
{
if ( ! r ) {
return ;
}
printf ( " Printer Driver Info 2: \n " ) ;
printf ( " \t Version: [%x] \n " , r - > version ) ;
printf ( " \t Driver Name: [%s] \n " , r - > driver_name ) ;
printf ( " \t Architecture: [%s] \n " , r - > architecture ) ;
printf ( " \t Driver Path: [%s] \n " , r - > driver_path ) ;
printf ( " \t Datafile: [%s] \n " , r - > data_file ) ;
printf ( " \t Configfile: [%s] \n \n " , r - > config_file ) ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void display_print_driver3 ( struct spoolss_DriverInfo3 * r )
{
int i ;
if ( ! r ) {
return ;
}
printf ( " Printer Driver Info 3: \n " ) ;
printf ( " \t Version: [%x] \n " , r - > version ) ;
printf ( " \t Driver Name: [%s] \n " , r - > driver_name ) ;
printf ( " \t Architecture: [%s] \n " , r - > architecture ) ;
printf ( " \t Driver Path: [%s] \n " , r - > driver_path ) ;
printf ( " \t Datafile: [%s] \n " , r - > data_file ) ;
printf ( " \t Configfile: [%s] \n \n " , r - > config_file ) ;
printf ( " \t Helpfile: [%s] \n \n " , r - > help_file ) ;
for ( i = 0 ; r - > dependent_files [ i ] ! = NULL ; i + + ) {
printf ( " \t Dependentfiles: [%s] \n " , r - > dependent_files [ i ] ) ;
}
printf ( " \n " ) ;
printf ( " \t Monitorname: [%s] \n " , r - > monitor_name ) ;
printf ( " \t Defaultdatatype: [%s] \n \n " , r - > default_datatype ) ;
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_getdriver ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-03-15 10:13:27 +03:00
{
POLICY_HND pol ;
2002-01-06 06:54:40 +03:00
WERROR werror ;
2001-09-04 14:57:29 +04:00
uint32 info_level = 3 ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2001-03-15 10:13:27 +03:00
uint32 i ;
2007-10-19 04:40:25 +04:00
bool success = False ;
2009-02-25 00:20:30 +03:00
union spoolss_DriverInfo info ;
uint32_t server_major_version ;
uint32_t server_minor_version ;
2001-03-15 10:13:27 +03:00
2009-02-09 14:40:12 +03:00
if ( ( argc = = 1 ) | | ( argc > 3 ) )
2001-03-15 10:13:27 +03:00
{
printf ( " Usage: %s <printername> [level] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-03-15 10:13:27 +03:00
}
/* get the arguments need to open the printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2001-03-15 10:13:27 +03:00
if ( argc = = 3 )
info_level = atoi ( argv [ 2 ] ) ;
/* Open a printer handle */
2002-01-06 06:54:40 +03:00
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
PRINTER_ACCESS_USE ,
& pol ) ;
2003-03-18 09:30:30 +03:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
2002-01-06 06:54:40 +03:00
printf ( " Error opening printer handle for %s! \n " , printername ) ;
2003-03-18 09:30:30 +03:00
return werror ;
2001-03-15 10:13:27 +03:00
}
/* loop through and print driver info level for each architecture */
2002-01-07 06:33:46 +03:00
for ( i = 0 ; archi_table [ i ] . long_archi ! = NULL ; i + + ) {
2009-02-25 00:20:30 +03:00
werror = rpccli_spoolss_getprinterdriver2 ( cli , mem_ctx ,
& pol ,
archi_table [ i ] . long_archi ,
info_level ,
0 , /* offered */
archi_table [ i ] . version ,
2 ,
& info ,
& server_major_version ,
& server_minor_version ) ;
2002-01-07 06:33:46 +03:00
if ( ! W_ERROR_IS_OK ( werror ) )
continue ;
2009-02-09 14:40:12 +03:00
2003-08-19 20:56:53 +04:00
/* need at least one success */
2009-02-09 14:40:12 +03:00
2003-08-19 20:56:53 +04:00
success = True ;
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
printf ( " \n [%s] \n " , archi_table [ i ] . long_archi ) ;
2002-01-07 06:33:46 +03:00
switch ( info_level ) {
2001-03-15 10:13:27 +03:00
case 1 :
2009-02-25 00:20:30 +03:00
display_print_driver1 ( & info . info1 ) ;
2001-03-15 10:13:27 +03:00
break ;
case 2 :
2009-02-25 00:20:30 +03:00
display_print_driver2 ( & info . info2 ) ;
2001-03-15 10:13:27 +03:00
break ;
case 3 :
2009-02-25 00:20:30 +03:00
display_print_driver3 ( & info . info3 ) ;
2001-03-15 10:13:27 +03:00
break ;
default :
printf ( " unknown info level %d \n " , info_level ) ;
break ;
}
}
2009-02-09 14:40:12 +03:00
2002-01-06 06:54:40 +03:00
/* Cleanup */
2009-02-25 14:09:15 +03:00
if ( is_valid_policy_hnd ( & pol ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & pol , NULL ) ;
2009-02-09 14:40:12 +03:00
2003-08-19 20:56:53 +04:00
if ( success )
werror = WERR_OK ;
2009-02-09 14:40:12 +03:00
2003-03-18 09:30:30 +03:00
return werror ;
2001-03-15 10:13:27 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_enum_drivers ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-03-15 10:13:27 +03:00
{
2005-11-02 03:37:35 +03:00
WERROR werror = WERR_OK ;
2001-09-04 14:57:29 +04:00
uint32 info_level = 1 ;
2001-03-15 10:13:27 +03:00
PRINTER_DRIVER_CTR ctr ;
uint32 i , j ,
returned ;
2005-11-02 03:37:35 +03:00
if ( argc > 2 ) {
2001-03-15 10:13:27 +03:00
printf ( " Usage: enumdrivers [level] \n " ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-03-15 10:13:27 +03:00
}
if ( argc = = 2 )
info_level = atoi ( argv [ 1 ] ) ;
/* loop through and print driver info level for each architecture */
2005-11-02 03:37:35 +03:00
for ( i = 0 ; archi_table [ i ] . long_archi ! = NULL ; i + + ) {
2005-01-24 21:42:33 +03:00
/* check to see if we already asked for this architecture string */
if ( i > 0 & & strequal ( archi_table [ i ] . long_archi , archi_table [ i - 1 ] . long_archi ) )
continue ;
2005-09-30 21:13:37 +04:00
werror = rpccli_spoolss_enumprinterdrivers (
2009-02-09 14:40:12 +03:00
cli , mem_ctx , info_level ,
2002-02-19 04:06:55 +03:00
archi_table [ i ] . long_archi , & returned , & ctr ) ;
2004-08-10 18:27:17 +04:00
if ( W_ERROR_V ( werror ) = = W_ERROR_V ( WERR_INVALID_ENVIRONMENT ) ) {
2009-02-09 14:40:12 +03:00
printf ( " Server does not support environment [%s] \n " ,
2004-08-10 18:27:17 +04:00
archi_table [ i ] . long_archi ) ;
werror = WERR_OK ;
continue ;
}
2001-03-15 10:13:27 +03:00
if ( returned = = 0 )
continue ;
2009-02-09 14:40:12 +03:00
2002-02-19 04:06:55 +03:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
printf ( " Error getting driver for environment [%s] - %d \n " ,
archi_table [ i ] . long_archi , W_ERROR_V ( werror ) ) ;
2001-03-15 10:13:27 +03:00
continue ;
}
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
printf ( " \n [%s] \n " , archi_table [ i ] . long_archi ) ;
2009-02-09 14:40:12 +03:00
switch ( info_level )
2001-03-15 10:13:27 +03:00
{
2009-02-09 14:40:12 +03:00
2001-03-15 10:13:27 +03:00
case 1 :
for ( j = 0 ; j < returned ; j + + ) {
2005-11-02 03:37:35 +03:00
display_print_driver_1 ( & ctr . info1 [ j ] ) ;
2001-03-15 10:13:27 +03:00
}
break ;
case 2 :
for ( j = 0 ; j < returned ; j + + ) {
2005-11-02 03:37:35 +03:00
display_print_driver_2 ( & ctr . info2 [ j ] ) ;
2001-03-15 10:13:27 +03:00
}
break ;
case 3 :
for ( j = 0 ; j < returned ; j + + ) {
2005-11-02 03:37:35 +03:00
display_print_driver_3 ( & ctr . info3 [ j ] ) ;
2001-03-15 10:13:27 +03:00
}
break ;
default :
printf ( " unknown info level %d \n " , info_level ) ;
2005-11-02 03:37:35 +03:00
return WERR_UNKNOWN_LEVEL ;
2001-03-15 10:13:27 +03:00
}
}
2009-02-09 14:40:12 +03:00
2003-03-18 09:30:30 +03:00
return werror ;
2001-03-15 10:13:27 +03:00
}
2001-03-15 19:43:19 +03:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-07-20 19:35:29 +04:00
2009-02-19 03:55:39 +03:00
static void display_printdriverdir_1 ( struct spoolss_DriverDirectoryInfo1 * r )
2001-03-15 19:43:19 +03:00
{
2009-02-19 03:55:39 +03:00
printf ( " \t Directory Name:[%s] \n " , r - > directory_name ) ;
2001-03-15 19:43:19 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_getdriverdir ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-03-15 19:43:19 +03:00
{
2002-02-20 21:41:07 +03:00
WERROR result ;
2009-02-19 03:55:39 +03:00
NTSTATUS status ;
2009-02-19 19:41:10 +03:00
const char * env = SPOOLSS_ARCHITECTURE_NT_X86 ;
2009-02-19 03:55:39 +03:00
DATA_BLOB buffer ;
uint32_t offered ;
union spoolss_DriverDirectoryInfo info ;
uint32_t needed ;
2001-03-15 19:43:19 +03:00
2002-02-20 21:41:07 +03:00
if ( argc > 2 ) {
2001-03-15 19:43:19 +03:00
printf ( " Usage: %s [environment] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-03-15 19:43:19 +03:00
}
2002-02-20 21:41:07 +03:00
/* Get the arguments need to open the printer handle */
2009-02-19 03:55:39 +03:00
if ( argc = = 2 ) {
env = argv [ 1 ] ;
}
2001-03-15 19:43:19 +03:00
/* Get the directory. Only use Info level 1 */
2009-02-19 03:55:39 +03:00
status = rpccli_spoolss_GetPrinterDriverDirectory ( cli , mem_ctx ,
cli - > srv_name_slash ,
env ,
1 ,
NULL , /* buffer */
0 , /* offered */
NULL , /* info */
& needed ,
& result ) ;
if ( W_ERROR_EQUAL ( result , WERR_INSUFFICIENT_BUFFER ) ) {
offered = needed ;
buffer = data_blob_talloc_zero ( mem_ctx , needed ) ;
status = rpccli_spoolss_GetPrinterDriverDirectory ( cli , mem_ctx ,
cli - > srv_name_slash ,
env ,
1 ,
& buffer ,
offered ,
& info ,
& needed ,
& result ) ;
}
2001-03-15 19:43:19 +03:00
2009-02-19 03:55:39 +03:00
if ( W_ERROR_IS_OK ( result ) ) {
display_printdriverdir_1 ( & info . info1 ) ;
}
2002-02-20 21:41:07 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2001-03-15 19:43:19 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-19 02:43:23 +03:00
static void set_drv_info_3_env ( TALLOC_CTX * mem_ctx ,
struct spoolss_AddDriverInfo3 * info ,
const char * arch )
2001-03-16 01:06:53 +03:00
{
int i ;
2009-02-09 14:40:12 +03:00
for ( i = 0 ; archi_table [ i ] . long_archi ! = NULL ; i + + )
2001-03-16 01:06:53 +03:00
{
if ( strcmp ( arch , archi_table [ i ] . short_archi ) = = 0 )
{
info - > version = archi_table [ i ] . version ;
2009-02-19 02:43:23 +03:00
info - > architecture = talloc_strdup ( mem_ctx , archi_table [ i ] . long_archi ) ;
2001-03-16 01:06:53 +03:00
break ;
}
}
2009-02-09 14:40:12 +03:00
2001-03-16 01:06:53 +03:00
if ( archi_table [ i ] . long_archi = = NULL )
{
DEBUG ( 0 , ( " set_drv_info_3_env: Unknown arch [%s] \n " , arch ) ) ;
}
2009-02-09 14:40:12 +03:00
2001-03-16 01:06:53 +03:00
return ;
}
/**************************************************************************
wrapper for strtok to get the next parameter from a delimited list .
Needed to handle the empty parameter string denoted by " NULL "
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
2009-02-19 02:43:23 +03:00
static char * get_driver_3_param ( TALLOC_CTX * mem_ctx , char * str ,
const char * delim , const char * * dest ,
char * * saveptr )
2001-03-16 01:06:53 +03:00
{
char * ptr ;
/* get the next token */
2008-06-26 17:32:27 +04:00
ptr = strtok_r ( str , delim , saveptr ) ;
2001-03-16 01:06:53 +03:00
/* a string of 'NULL' is used to represent an empty
parameter because two consecutive delimiters
will not return an empty string . See man strtok ( 3 )
for details */
2009-02-19 02:43:23 +03:00
if ( ptr & & ( StrCaseCmp ( ptr , " NULL " ) = = 0 ) ) {
2001-03-16 01:06:53 +03:00
ptr = NULL ;
2009-02-19 02:43:23 +03:00
}
2001-03-16 01:06:53 +03:00
2009-02-19 02:43:23 +03:00
if ( dest ! = NULL ) {
* dest = talloc_strdup ( mem_ctx , ptr ) ;
}
2001-03-16 01:06:53 +03:00
return ptr ;
}
/********************************************************************************
2009-02-19 02:43:23 +03:00
fill in the members of a spoolss_AddDriverInfo3 struct using a character
2001-03-16 01:06:53 +03:00
string in the form of
< Long Printer Name > : < Driver File Name > : < Data File Name > : \
< Config File Name > : < Help File Name > : < Language Monitor Name > : \
2009-02-09 14:40:12 +03:00
< Default Data Type > : < Comma Separated list of Files >
2001-03-16 01:06:53 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-19 02:43:23 +03:00
static bool init_drv_info_3_members ( TALLOC_CTX * mem_ctx , struct spoolss_AddDriverInfo3 * r ,
char * args )
2001-03-16 01:06:53 +03:00
{
char * str , * str2 ;
2009-02-19 02:43:23 +03:00
int count = 0 ;
2008-01-25 23:20:39 +03:00
char * saveptr = NULL ;
2009-02-19 02:43:23 +03:00
struct spoolss_StringArray * deps ;
const char * * file_array = NULL ;
int i ;
2008-01-23 13:04:10 +03:00
2001-03-16 01:06:53 +03:00
/* fill in the UNISTR fields */
2009-02-19 02:43:23 +03:00
str = get_driver_3_param ( mem_ctx , args , " : " , & r - > driver_name , & saveptr ) ;
str = get_driver_3_param ( mem_ctx , NULL , " : " , & r - > driver_path , & saveptr ) ;
str = get_driver_3_param ( mem_ctx , NULL , " : " , & r - > data_file , & saveptr ) ;
str = get_driver_3_param ( mem_ctx , NULL , " : " , & r - > config_file , & saveptr ) ;
str = get_driver_3_param ( mem_ctx , NULL , " : " , & r - > help_file , & saveptr ) ;
str = get_driver_3_param ( mem_ctx , NULL , " : " , & r - > monitor_name , & saveptr ) ;
str = get_driver_3_param ( mem_ctx , NULL , " : " , & r - > default_datatype , & saveptr ) ;
2001-03-16 01:06:53 +03:00
/* <Comma Separated List of Dependent Files> */
2008-06-26 17:32:27 +04:00
/* save the beginning of the string */
2009-02-19 02:43:23 +03:00
str2 = get_driver_3_param ( mem_ctx , NULL , " : " , NULL , & saveptr ) ;
2008-06-26 17:32:27 +04:00
str = str2 ;
2001-03-16 01:06:53 +03:00
/* begin to strip out each filename */
2008-01-23 13:04:10 +03:00
str = strtok_r ( str , " , " , & saveptr ) ;
2009-02-19 02:43:23 +03:00
/* no dependent files, we are done */
if ( ! str ) {
return true ;
}
deps = talloc_zero ( mem_ctx , struct spoolss_StringArray ) ;
if ( ! deps ) {
return false ;
}
while ( str ! = NULL ) {
add_string_to_array ( deps , str , & file_array , & count ) ;
2008-01-23 13:04:10 +03:00
str = strtok_r ( NULL , " , " , & saveptr ) ;
2001-03-16 01:06:53 +03:00
}
2009-02-19 02:43:23 +03:00
deps - > string = talloc_zero_array ( deps , const char * , count + 1 ) ;
if ( ! deps - > string ) {
return false ;
2001-03-16 01:06:53 +03:00
}
2009-02-19 02:43:23 +03:00
for ( i = 0 ; i < count ; i + + ) {
deps - > string [ i ] = file_array [ i ] ;
2001-03-16 01:06:53 +03:00
}
2009-02-19 02:43:23 +03:00
r - > dependent_files = deps ;
2001-03-16 01:06:53 +03:00
2009-02-19 02:43:23 +03:00
return true ;
}
2001-03-16 01:06:53 +03:00
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_addprinterdriver ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-03-16 01:06:53 +03:00
{
2002-02-20 21:41:07 +03:00
WERROR result ;
2009-02-19 02:43:23 +03:00
NTSTATUS status ;
2001-09-04 14:57:29 +04:00
uint32 level = 3 ;
2009-02-19 02:43:23 +03:00
struct spoolss_AddDriverInfoCtr info_ctr ;
struct spoolss_AddDriverInfo3 info3 ;
2003-04-23 17:27:35 +04:00
const char * arch ;
2005-03-22 17:33:30 +03:00
char * driver_args ;
2001-03-16 01:06:53 +03:00
2008-06-17 11:44:21 +04:00
/* parse the command arguments */
2003-11-05 19:40:13 +03:00
if ( argc ! = 3 & & argc ! = 4 )
2001-03-16 01:06:53 +03:00
{
2003-11-05 19:40:13 +03:00
printf ( " Usage: %s <Environment> \\ \n " , argv [ 0 ] ) ;
2001-03-16 01:06:53 +03:00
printf ( " \t <Long Printer Name>:<Driver File Name>:<Data File Name>: \\ \n " ) ;
printf ( " \t <Config File Name>:<Help File Name>:<Language Monitor Name>: \\ \n " ) ;
2003-11-05 19:40:13 +03:00
printf ( " \t <Default Data Type>:<Comma Separated list of Files> \\ \n " ) ;
printf ( " \t [version] \n " ) ;
2001-03-16 01:06:53 +03:00
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-03-16 01:06:53 +03:00
}
2009-02-09 14:40:12 +03:00
2009-02-19 02:43:23 +03:00
/* Fill in the spoolss_AddDriverInfo3 struct */
2001-03-16 01:06:53 +03:00
ZERO_STRUCT ( info3 ) ;
2009-02-19 02:43:23 +03:00
arch = cmd_spoolss_get_short_archi ( argv [ 1 ] ) ;
if ( ! arch ) {
2001-03-16 01:06:53 +03:00
printf ( " Error Unknown architechture [%s] \n " , argv [ 1 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_INVALID_PARAM ;
2001-03-16 01:06:53 +03:00
}
2009-02-19 02:43:23 +03:00
set_drv_info_3_env ( mem_ctx , & info3 , arch ) ;
2001-03-16 01:06:53 +03:00
2005-03-22 17:33:30 +03:00
driver_args = talloc_strdup ( mem_ctx , argv [ 2 ] ) ;
if ( ! init_drv_info_3_members ( mem_ctx , & info3 , driver_args ) )
2001-03-16 01:06:53 +03:00
{
printf ( " Error Invalid parameter list - %s. \n " , argv [ 2 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_INVALID_PARAM ;
2001-03-16 01:06:53 +03:00
}
2003-11-05 19:40:13 +03:00
/* if printer driver version specified, override the default version
* used by the architecture . This allows installation of Windows
* 2000 ( version 3 ) printer drivers . */
if ( argc = = 4 )
{
info3 . version = atoi ( argv [ 3 ] ) ;
}
2001-03-16 01:06:53 +03:00
2009-02-19 02:43:23 +03:00
info_ctr . level = level ;
info_ctr . info . info3 = & info3 ;
2001-03-16 01:06:53 +03:00
2009-02-19 02:43:23 +03:00
status = rpccli_spoolss_AddPrinterDriver ( cli , mem_ctx ,
cli - > srv_name_slash ,
& info_ctr ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return ntstatus_to_werror ( status ) ;
}
2002-02-20 21:41:07 +03:00
if ( W_ERROR_IS_OK ( result ) ) {
2002-04-02 05:10:41 +04:00
printf ( " Printer Driver %s successfully installed. \n " ,
2009-02-19 02:43:23 +03:00
info3 . driver_name ) ;
2002-02-20 21:41:07 +03:00
}
2001-03-16 01:06:53 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2001-03-16 01:06:53 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_addprinterex ( struct rpc_pipe_client * cli ,
2002-04-02 05:10:41 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-03-16 01:06:53 +03:00
{
2002-02-20 21:41:07 +03:00
WERROR result ;
2009-02-13 20:06:45 +03:00
struct spoolss_SetPrinterInfoCtr info_ctr ;
struct spoolss_SetPrinterInfo2 info2 ;
2009-02-09 14:40:12 +03:00
2008-06-17 11:44:21 +04:00
/* parse the command arguments */
2001-03-16 01:06:53 +03:00
if ( argc ! = 5 )
{
printf ( " Usage: %s <name> <shared name> <driver> <port> \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-03-16 01:06:53 +03:00
}
2009-02-09 14:40:12 +03:00
2003-12-07 13:48:31 +03:00
/* Fill in the DRIVER_INFO_2 struct */
2001-03-16 01:06:53 +03:00
ZERO_STRUCT ( info2 ) ;
2009-02-13 20:06:45 +03:00
info2 . printername = argv [ 1 ] ;
info2 . drivername = argv [ 3 ] ;
info2 . sharename = argv [ 2 ] ;
info2 . portname = argv [ 4 ] ;
info2 . comment = " Created by rpcclient " ;
info2 . printprocessor = " winprint " ;
info2 . datatype = " RAW " ;
info2 . devmode = NULL ;
info2 . secdesc = NULL ;
2001-03-16 01:06:53 +03:00
info2 . attributes = PRINTER_ATTRIBUTE_SHARED ;
info2 . priority = 0 ;
info2 . defaultpriority = 0 ;
info2 . starttime = 0 ;
info2 . untiltime = 0 ;
2009-02-09 14:40:12 +03:00
/* These three fields must not be used by AddPrinter()
as defined in the MS Platform SDK documentation . .
2001-03-16 01:06:53 +03:00
- - jerry
info2 . status = 0 ;
info2 . cjobs = 0 ;
info2 . averageppm = 0 ;
*/
2009-02-13 20:06:45 +03:00
info_ctr . level = 2 ;
info_ctr . info . info2 = & info2 ;
2009-02-25 03:11:01 +03:00
result = rpccli_spoolss_addprinterex ( cli , mem_ctx ,
& info_ctr ) ;
2002-02-20 21:41:07 +03:00
if ( W_ERROR_IS_OK ( result ) )
printf ( " Printer %s successfully installed. \n " , argv [ 1 ] ) ;
2001-03-16 01:06:53 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2001-03-16 01:06:53 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_setdriver ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-04-28 04:32:56 +04:00
{
POLICY_HND pol ;
2002-01-06 06:54:40 +03:00
WERROR result ;
2009-02-14 05:08:06 +03:00
NTSTATUS status ;
2001-09-04 14:57:29 +04:00
uint32 level = 2 ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2009-02-14 05:08:06 +03:00
union spoolss_PrinterInfo info ;
struct spoolss_SetPrinterInfoCtr info_ctr ;
struct spoolss_DevmodeContainer devmode_ctr ;
struct sec_desc_buf secdesc_ctr ;
ZERO_STRUCT ( devmode_ctr ) ;
ZERO_STRUCT ( secdesc_ctr ) ;
2009-02-09 14:40:12 +03:00
2008-06-17 11:44:21 +04:00
/* parse the command arguments */
2001-04-28 04:32:56 +04:00
if ( argc ! = 3 )
{
printf ( " Usage: %s <printer> <driver> \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-04-28 04:32:56 +04:00
}
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2001-04-28 04:32:56 +04:00
2002-01-06 06:54:40 +03:00
/* Get a printer handle */
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
PRINTER_ALL_ACCESS ,
& pol ) ;
2002-02-20 21:41:07 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
2001-04-28 04:32:56 +04:00
goto done ;
2002-02-20 21:41:07 +03:00
2001-04-28 04:32:56 +04:00
/* Get printer info */
2002-01-06 06:54:40 +03:00
2009-02-14 05:08:06 +03:00
result = rpccli_spoolss_getprinter ( cli , mem_ctx ,
& pol ,
level ,
0 ,
& info ) ;
2002-02-19 05:12:01 +03:00
if ( ! W_ERROR_IS_OK ( result ) ) {
2001-05-31 21:28:40 +04:00
printf ( " Unable to retrieve printer information! \n " ) ;
2001-04-28 04:32:56 +04:00
goto done ;
}
2002-01-06 06:54:40 +03:00
/* Set the printer driver */
2009-02-14 05:08:06 +03:00
info . info2 . drivername = argv [ 2 ] ;
2009-03-02 13:21:26 +03:00
info . info2 . devmode = NULL ;
info . info2 . secdesc = NULL ;
2009-02-14 05:08:06 +03:00
info_ctr . level = 2 ;
info_ctr . info . info2 = ( struct spoolss_SetPrinterInfo2 * ) & info . info2 ;
status = rpccli_spoolss_SetPrinter ( cli , mem_ctx ,
& pol ,
& info_ctr ,
& devmode_ctr ,
& secdesc_ctr ,
0 , /* command */
& result ) ;
2002-02-20 21:41:07 +03:00
if ( ! W_ERROR_IS_OK ( result ) ) {
2002-01-06 06:54:40 +03:00
printf ( " SetPrinter call failed! \n " ) ;
2001-04-28 04:32:56 +04:00
goto done ; ;
}
2008-02-05 12:34:00 +03:00
printf ( " Successfully set %s to driver %s. \n " , argv [ 1 ] , argv [ 2 ] ) ;
2001-04-28 04:32:56 +04:00
done :
2002-01-06 06:54:40 +03:00
/* Cleanup */
2009-02-25 14:09:15 +03:00
if ( is_valid_policy_hnd ( & pol ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & pol , NULL ) ;
2002-04-02 05:10:41 +04:00
2003-03-18 09:30:30 +03:00
return result ;
2001-04-28 04:32:56 +04:00
}
2001-03-15 10:13:27 +03:00
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_deletedriverex ( struct rpc_pipe_client * cli ,
2004-11-10 00:15:14 +03:00
TALLOC_CTX * mem_ctx ,
int argc , const char * * argv )
{
WERROR result , ret = WERR_UNKNOWN_PRINTER_DRIVER ;
2009-02-09 13:14:00 +03:00
NTSTATUS status ;
2004-11-10 00:15:14 +03:00
int i ;
int vers = - 1 ;
2009-02-09 14:40:12 +03:00
2004-11-10 00:15:14 +03:00
const char * arch = NULL ;
2009-02-09 13:14:00 +03:00
uint32_t delete_flags = 0 ;
2008-06-17 11:44:21 +04:00
/* parse the command arguments */
2004-11-10 00:15:14 +03:00
if ( argc < 2 | | argc > 4 ) {
printf ( " Usage: %s <driver> [arch] [version] \n " , argv [ 0 ] ) ;
return WERR_OK ;
}
if ( argc > = 3 )
arch = argv [ 2 ] ;
if ( argc = = 4 )
vers = atoi ( argv [ 3 ] ) ;
2009-02-09 13:14:00 +03:00
if ( vers > = 0 ) {
delete_flags | = DPD_DELETE_SPECIFIC_VERSION ;
}
2004-11-10 00:15:14 +03:00
/* delete the driver for all architectures */
for ( i = 0 ; archi_table [ i ] . long_archi ; i + + ) {
2009-02-09 14:40:12 +03:00
if ( arch & & ! strequal ( archi_table [ i ] . long_archi , arch ) )
2004-11-10 00:15:14 +03:00
continue ;
if ( vers > = 0 & & archi_table [ i ] . version ! = vers )
continue ;
/* make the call to remove the driver */
2009-02-09 13:14:00 +03:00
status = rpccli_spoolss_DeletePrinterDriverEx ( cli , mem_ctx ,
cli - > srv_name_slash ,
archi_table [ i ] . long_archi ,
argv [ 1 ] ,
delete_flags ,
archi_table [ i ] . version ,
& result ) ;
2004-11-10 00:15:14 +03:00
2009-02-09 14:40:12 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
2004-11-10 00:15:14 +03:00
{
if ( ! W_ERROR_EQUAL ( result , WERR_UNKNOWN_PRINTER_DRIVER ) ) {
2009-02-09 14:40:12 +03:00
printf ( " Failed to remove driver %s for arch [%s] (version: %d): %s \n " ,
2008-11-01 19:19:26 +03:00
argv [ 1 ] , archi_table [ i ] . long_archi , archi_table [ i ] . version , win_errstr ( result ) ) ;
2004-11-10 00:15:14 +03:00
}
2009-02-09 14:40:12 +03:00
}
else
2004-11-10 00:15:14 +03:00
{
2009-02-09 14:40:12 +03:00
printf ( " Driver %s and files removed for arch [%s] (version: %d). \n " , argv [ 1 ] ,
2004-11-10 03:53:35 +03:00
archi_table [ i ] . long_archi , archi_table [ i ] . version ) ;
2004-11-10 00:15:14 +03:00
ret = WERR_OK ;
}
}
2009-02-09 14:40:12 +03:00
2004-11-10 00:15:14 +03:00
return ret ;
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_deletedriver ( struct rpc_pipe_client * cli ,
2001-10-12 09:56:23 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-05-17 22:57:25 +04:00
{
2005-11-02 03:37:35 +03:00
WERROR result = WERR_OK ;
2009-02-09 03:49:40 +03:00
NTSTATUS status ;
2001-05-18 08:11:17 +04:00
int i ;
2009-02-09 14:40:12 +03:00
2008-06-17 11:44:21 +04:00
/* parse the command arguments */
2005-11-02 03:37:35 +03:00
if ( argc ! = 2 ) {
2001-05-18 08:11:17 +04:00
printf ( " Usage: %s <driver> \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-05-17 22:57:25 +04:00
}
2001-05-18 08:11:17 +04:00
/* delete the driver for all architectures */
2005-11-02 03:37:35 +03:00
for ( i = 0 ; archi_table [ i ] . long_archi ; i + + ) {
2001-05-18 08:11:17 +04:00
/* make the call to remove the driver */
2009-02-09 03:49:40 +03:00
status = rpccli_spoolss_DeletePrinterDriver ( cli , mem_ctx ,
2009-02-09 20:10:18 +03:00
cli - > srv_name_slash ,
2009-02-09 03:49:40 +03:00
archi_table [ i ] . long_archi ,
argv [ 1 ] ,
& result ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return result ;
}
2002-11-09 17:49:26 +03:00
if ( ! W_ERROR_IS_OK ( result ) ) {
if ( ! W_ERROR_EQUAL ( result , WERR_UNKNOWN_PRINTER_DRIVER ) ) {
2009-02-09 14:40:12 +03:00
printf ( " Failed to remove driver %s for arch [%s] - error 0x%x! \n " ,
argv [ 1 ] , archi_table [ i ] . long_archi ,
2002-11-09 17:49:26 +03:00
W_ERROR_V ( result ) ) ;
}
2005-11-02 03:37:35 +03:00
} else {
2009-02-09 14:40:12 +03:00
printf ( " Driver %s removed for arch [%s]. \n " , argv [ 1 ] ,
2002-02-20 21:41:07 +03:00
archi_table [ i ] . long_archi ) ;
2002-11-09 17:49:26 +03:00
}
2001-05-17 22:57:25 +04:00
}
2009-02-09 14:40:12 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2001-05-17 22:57:25 +04:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_getprintprocdir ( struct rpc_pipe_client * cli ,
2001-12-10 08:03:17 +03:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2001-12-10 08:03:17 +03:00
{
2002-02-20 21:41:07 +03:00
WERROR result ;
2009-02-19 12:26:00 +03:00
NTSTATUS status ;
const char * environment = SPOOLSS_ARCHITECTURE_NT_X86 ;
DATA_BLOB buffer ;
uint32_t offered ;
union spoolss_PrintProcessorDirectoryInfo info ;
uint32_t needed ;
2009-02-09 14:40:12 +03:00
2008-06-17 11:44:21 +04:00
/* parse the command arguments */
2002-02-20 21:41:07 +03:00
if ( argc > 2 ) {
printf ( " Usage: %s [environment] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2001-12-10 08:03:17 +03:00
}
2009-02-19 12:26:00 +03:00
if ( argc = = 2 ) {
environment = argv [ 1 ] ;
2002-01-19 20:29:32 +03:00
}
2001-12-10 08:03:17 +03:00
2009-02-19 12:26:00 +03:00
status = rpccli_spoolss_GetPrintProcessorDirectory ( cli , mem_ctx ,
cli - > srv_name_slash ,
environment ,
1 ,
NULL , /* buffer */
0 , /* offered */
NULL , /* info */
& needed ,
& result ) ;
if ( W_ERROR_EQUAL ( result , WERR_INSUFFICIENT_BUFFER ) ) {
offered = needed ;
buffer = data_blob_talloc_zero ( mem_ctx , needed ) ;
2001-12-10 08:03:17 +03:00
2009-02-19 12:26:00 +03:00
status = rpccli_spoolss_GetPrintProcessorDirectory ( cli , mem_ctx ,
cli - > srv_name_slash ,
environment ,
1 ,
& buffer ,
offered ,
& info ,
& needed ,
& result ) ;
}
2001-12-10 08:03:17 +03:00
2009-02-19 12:26:00 +03:00
if ( W_ERROR_IS_OK ( result ) ) {
printf ( " %s \n " , info . info1 . directory_name ) ;
}
2001-12-10 08:03:17 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2001-12-10 08:03:17 +03:00
}
2001-05-17 22:57:25 +04:00
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-01-31 14:36:30 +03:00
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_addform ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2002-01-31 14:36:30 +03:00
{
POLICY_HND handle ;
WERROR werror ;
2009-02-08 02:03:00 +03:00
NTSTATUS status ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2009-02-08 02:03:00 +03:00
union spoolss_AddFormInfo info ;
struct spoolss_AddFormInfo1 info1 ;
2009-02-25 22:50:34 +03:00
struct spoolss_AddFormInfo2 info2 ;
uint32_t level = 1 ;
2009-02-08 02:03:00 +03:00
2008-06-17 11:44:21 +04:00
/* Parse the command arguments */
2002-01-31 14:36:30 +03:00
2009-02-25 22:50:34 +03:00
if ( argc < 3 | | argc > 5 ) {
printf ( " Usage: %s <printer> <formname> [level] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-01-31 14:36:30 +03:00
}
2009-02-09 14:40:12 +03:00
2002-01-31 14:36:30 +03:00
/* Get a printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-01-31 14:36:30 +03:00
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
PRINTER_ALL_ACCESS ,
& handle ) ;
2002-01-31 14:36:30 +03:00
if ( ! W_ERROR_IS_OK ( werror ) )
goto done ;
/* Dummy up some values for the form data */
2009-02-25 22:50:34 +03:00
if ( argc = = 4 ) {
level = atoi ( argv [ 3 ] ) ;
}
switch ( level ) {
case 1 :
2009-03-06 14:01:54 +03:00
info1 . flags = SPOOLSS_FORM_USER ;
2009-02-25 22:50:34 +03:00
info1 . form_name = argv [ 2 ] ;
info1 . size . width = 100 ;
info1 . size . height = 100 ;
info1 . area . left = 0 ;
info1 . area . top = 10 ;
info1 . area . right = 20 ;
info1 . area . bottom = 30 ;
info . info1 = & info1 ;
2002-01-31 14:36:30 +03:00
2009-02-25 22:50:34 +03:00
break ;
case 2 :
2009-03-06 14:01:54 +03:00
info2 . flags = SPOOLSS_FORM_USER ;
2009-02-25 22:50:34 +03:00
info2 . form_name = argv [ 2 ] ;
info2 . size . width = 100 ;
info2 . size . height = 100 ;
info2 . area . left = 0 ;
info2 . area . top = 10 ;
info2 . area . right = 20 ;
info2 . area . bottom = 30 ;
info2 . keyword = argv [ 2 ] ;
info2 . string_type = SPOOLSS_FORM_STRING_TYPE_NONE ;
info2 . mui_dll = NULL ;
info2 . ressource_id = 0 ;
info2 . display_name = argv [ 2 ] ;
info2 . lang_id = 0 ;
info . info2 = & info2 ;
break ;
}
2002-01-31 14:36:30 +03:00
/* Add the form */
2002-02-25 09:43:31 +03:00
2009-02-08 02:03:00 +03:00
status = rpccli_spoolss_AddForm ( cli , mem_ctx ,
& handle ,
2009-02-25 22:50:34 +03:00
level ,
2009-02-08 02:03:00 +03:00
info ,
& werror ) ;
2002-01-31 14:36:30 +03:00
done :
2009-02-25 15:19:12 +03:00
if ( is_valid_policy_hnd ( & handle ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & handle , NULL ) ;
2002-01-31 14:36:30 +03:00
2003-03-18 09:30:30 +03:00
return werror ;
2002-01-31 14:36:30 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-01-31 14:36:30 +03:00
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_setform ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2002-01-31 14:36:30 +03:00
{
POLICY_HND handle ;
WERROR werror ;
2009-02-08 21:19:20 +03:00
NTSTATUS status ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2009-02-08 21:19:20 +03:00
union spoolss_AddFormInfo info ;
struct spoolss_AddFormInfo1 info1 ;
2008-06-17 11:44:21 +04:00
/* Parse the command arguments */
2002-01-31 14:36:30 +03:00
if ( argc ! = 3 ) {
printf ( " Usage: %s <printer> <formname> \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-01-31 14:36:30 +03:00
}
2009-02-09 14:40:12 +03:00
2002-01-31 14:36:30 +03:00
/* Get a printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-01-31 14:36:30 +03:00
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
2002-01-31 14:36:30 +03:00
if ( ! W_ERROR_IS_OK ( werror ) )
goto done ;
/* Dummy up some values for the form data */
2009-03-06 14:01:54 +03:00
info1 . flags = SPOOLSS_FORM_PRINTER ;
2009-02-08 21:19:20 +03:00
info1 . size . width = 100 ;
info1 . size . height = 100 ;
info1 . area . left = 0 ;
info1 . area . top = 1000 ;
info1 . area . right = 2000 ;
info1 . area . bottom = 3000 ;
info1 . form_name = argv [ 2 ] ;
2002-01-31 14:36:30 +03:00
2009-02-08 21:19:20 +03:00
info . info1 = & info1 ;
2002-01-31 14:36:30 +03:00
/* Set the form */
2009-02-08 21:19:20 +03:00
status = rpccli_spoolss_SetForm ( cli , mem_ctx ,
& handle ,
argv [ 2 ] ,
1 ,
info ,
& werror ) ;
2002-01-31 14:36:30 +03:00
done :
2009-02-25 15:19:12 +03:00
if ( is_valid_policy_hnd ( & handle ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & handle , NULL ) ;
2002-01-31 14:36:30 +03:00
2003-03-18 09:30:30 +03:00
return werror ;
2002-01-31 14:36:30 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-03-19 02:48:46 +03:00
static const char * get_form_flag ( int form_flag )
{
switch ( form_flag ) {
2009-03-06 14:01:54 +03:00
case SPOOLSS_FORM_USER :
2005-03-19 02:48:46 +03:00
return " FORM_USER " ;
2009-03-06 14:01:54 +03:00
case SPOOLSS_FORM_BUILTIN :
2005-03-19 02:48:46 +03:00
return " FORM_BUILTIN " ;
2009-03-06 14:01:54 +03:00
case SPOOLSS_FORM_PRINTER :
2005-03-19 02:48:46 +03:00
return " FORM_PRINTER " ;
default :
return " unknown " ;
}
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-08 21:51:20 +03:00
static void display_form_info1 ( struct spoolss_FormInfo1 * r )
{
printf ( " %s \n " \
" \t flag: %s (%d) \n " \
" \t width: %d, length: %d \n " \
" \t left: %d, right: %d, top: %d, bottom: %d \n \n " ,
r - > form_name , get_form_flag ( r - > flags ) , r - > flags ,
r - > size . width , r - > size . height ,
r - > area . left , r - > area . right ,
r - > area . top , r - > area . bottom ) ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-25 15:46:08 +03:00
static void display_form_info2 ( struct spoolss_FormInfo2 * r )
{
printf ( " %s \n " \
" \t flag: %s (%d) \n " \
" \t width: %d, length: %d \n " \
" \t left: %d, right: %d, top: %d, bottom: %d \n " ,
r - > form_name , get_form_flag ( r - > flags ) , r - > flags ,
r - > size . width , r - > size . height ,
r - > area . left , r - > area . right ,
r - > area . top , r - > area . bottom ) ;
printf ( " \t keyword: %s \n " , r - > keyword ) ;
printf ( " \t string_type: 0x%08x \n " , r - > string_type ) ;
printf ( " \t mui_dll: %s \n " , r - > mui_dll ) ;
printf ( " \t ressource_id: 0x%08x \n " , r - > ressource_id ) ;
printf ( " \t display_name: %s \n " , r - > display_name ) ;
printf ( " \t lang_id: %d \n " , r - > lang_id ) ;
printf ( " \n " ) ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_getform ( struct rpc_pipe_client * cli , TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2002-01-31 14:36:30 +03:00
{
POLICY_HND handle ;
WERROR werror ;
2009-02-08 21:51:20 +03:00
NTSTATUS status ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2009-02-08 21:51:20 +03:00
DATA_BLOB buffer ;
uint32_t offered = 0 ;
union spoolss_FormInfo info ;
uint32_t needed ;
2009-02-25 15:46:08 +03:00
uint32_t level = 1 ;
2009-02-08 21:51:20 +03:00
2008-06-17 11:44:21 +04:00
/* Parse the command arguments */
2002-01-31 14:36:30 +03:00
2009-02-25 15:46:08 +03:00
if ( argc < 3 | | argc > 5 ) {
printf ( " Usage: %s <printer> <formname> [level] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-01-31 14:36:30 +03:00
}
2009-02-09 14:40:12 +03:00
2002-01-31 14:36:30 +03:00
/* Get a printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-01-31 14:36:30 +03:00
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
2002-02-25 09:43:31 +03:00
if ( ! W_ERROR_IS_OK ( werror ) )
goto done ;
2009-02-25 15:46:08 +03:00
if ( argc = = 4 ) {
level = atoi ( argv [ 3 ] ) ;
}
2005-03-19 02:48:46 +03:00
/* Get the form */
2002-02-25 09:43:31 +03:00
2009-02-08 21:51:20 +03:00
status = rpccli_spoolss_GetForm ( cli , mem_ctx ,
& handle ,
argv [ 2 ] ,
2009-02-25 15:46:08 +03:00
level ,
2009-02-08 21:51:20 +03:00
NULL ,
offered ,
& info ,
& needed ,
& werror ) ;
if ( W_ERROR_EQUAL ( werror , WERR_INSUFFICIENT_BUFFER ) ) {
2009-02-25 15:46:08 +03:00
buffer = data_blob_talloc_zero ( mem_ctx , needed ) ;
2009-02-08 21:51:20 +03:00
offered = needed ;
status = rpccli_spoolss_GetForm ( cli , mem_ctx ,
& handle ,
argv [ 2 ] ,
2009-02-25 15:46:08 +03:00
level ,
2009-02-08 21:51:20 +03:00
& buffer ,
offered ,
& info ,
& needed ,
& werror ) ;
}
2002-02-25 09:43:31 +03:00
2009-02-08 21:51:20 +03:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
return werror ;
}
2002-02-25 09:43:31 +03:00
2009-02-25 15:46:08 +03:00
switch ( level ) {
case 1 :
display_form_info1 ( & info . info1 ) ;
break ;
case 2 :
display_form_info2 ( & info . info2 ) ;
break ;
}
2002-02-25 09:43:31 +03:00
done :
2009-02-25 15:19:12 +03:00
if ( is_valid_policy_hnd ( & handle ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & handle , NULL ) ;
2002-02-25 09:43:31 +03:00
2003-03-18 09:30:30 +03:00
return werror ;
2002-02-25 09:43:31 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-02-25 09:43:31 +03:00
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_deleteform ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2002-02-25 09:43:31 +03:00
{
POLICY_HND handle ;
WERROR werror ;
2008-11-16 00:16:51 +03:00
NTSTATUS status ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2009-02-09 14:40:12 +03:00
2008-06-17 11:44:21 +04:00
/* Parse the command arguments */
2002-02-25 09:43:31 +03:00
if ( argc ! = 3 ) {
printf ( " Usage: %s <printer> <formname> \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-02-25 09:43:31 +03:00
}
2009-02-09 14:40:12 +03:00
2002-02-25 09:43:31 +03:00
/* Get a printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-02-25 09:43:31 +03:00
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
2002-01-31 14:36:30 +03:00
if ( ! W_ERROR_IS_OK ( werror ) )
goto done ;
/* Delete the form */
2008-11-16 00:16:51 +03:00
status = rpccli_spoolss_DeleteForm ( cli , mem_ctx ,
& handle ,
argv [ 2 ] ,
& werror ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return ntstatus_to_werror ( status ) ;
}
2002-01-31 14:36:30 +03:00
done :
2009-02-25 15:19:12 +03:00
if ( is_valid_policy_hnd ( & handle ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & handle , NULL ) ;
2002-01-31 14:36:30 +03:00
2003-03-18 09:30:30 +03:00
return werror ;
2002-01-31 14:36:30 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-02-25 09:43:31 +03:00
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_enum_forms ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2002-02-25 09:43:31 +03:00
{
POLICY_HND handle ;
WERROR werror ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2006-06-29 01:52:56 +04:00
uint32 num_forms , level = 1 , i ;
2009-03-06 12:55:41 +03:00
union spoolss_FormInfo * forms ;
2009-02-09 14:40:12 +03:00
2008-06-17 11:44:21 +04:00
/* Parse the command arguments */
2002-02-25 09:43:31 +03:00
2009-03-06 12:55:41 +03:00
if ( argc < 2 | | argc > 4 ) {
printf ( " Usage: %s <printer> [level] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-02-25 09:43:31 +03:00
}
2009-02-09 14:40:12 +03:00
2002-02-25 09:43:31 +03:00
/* Get a printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-02-25 09:43:31 +03:00
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& handle ) ;
2002-02-25 09:43:31 +03:00
if ( ! W_ERROR_IS_OK ( werror ) )
goto done ;
2009-03-06 12:55:41 +03:00
if ( argc = = 3 ) {
level = atoi ( argv [ 2 ] ) ;
}
2002-02-25 09:43:31 +03:00
/* Enumerate forms */
2009-03-06 12:55:41 +03:00
werror = rpccli_spoolss_enumforms ( cli , mem_ctx ,
& handle ,
level ,
0 ,
& num_forms ,
& forms ) ;
2002-02-25 09:43:31 +03:00
if ( ! W_ERROR_IS_OK ( werror ) )
goto done ;
/* Display output */
for ( i = 0 ; i < num_forms ; i + + ) {
2009-03-06 12:55:41 +03:00
switch ( level ) {
case 1 :
display_form_info1 ( & forms [ i ] . info1 ) ;
break ;
case 2 :
display_form_info2 ( & forms [ i ] . info2 ) ;
break ;
}
2002-02-25 09:43:31 +03:00
}
done :
2009-02-25 15:19:12 +03:00
if ( is_valid_policy_hnd ( & handle ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & handle , NULL ) ;
2002-02-25 09:43:31 +03:00
2003-03-18 09:30:30 +03:00
return werror ;
2002-02-25 09:43:31 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2005-09-30 21:13:37 +04:00
static WERROR cmd_spoolss_setprinterdata ( struct rpc_pipe_client * cli ,
2002-04-02 05:10:41 +04:00
TALLOC_CTX * mem_ctx ,
2003-02-26 02:51:56 +03:00
int argc , const char * * argv )
2002-04-02 05:10:41 +04:00
{
WERROR result ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2002-04-02 05:10:41 +04:00
POLICY_HND pol ;
2009-02-14 05:08:06 +03:00
union spoolss_PrinterInfo info ;
2002-09-25 19:19:00 +04:00
REGISTRY_VALUE value ;
2008-03-28 17:49:13 +03:00
TALLOC_CTX * tmp_ctx = talloc_stackframe ( ) ;
2002-04-02 05:10:41 +04:00
2008-06-17 11:44:21 +04:00
/* parse the command arguments */
2005-08-07 23:09:14 +04:00
if ( argc < 5 ) {
2005-08-08 01:23:38 +04:00
printf ( " Usage: %s <printer> <string|binary|dword|multistring> "
2005-08-07 23:09:14 +04:00
" <value> <data> \n " ,
argv [ 0 ] ) ;
2008-03-28 17:49:13 +03:00
result = WERR_INVALID_PARAM ;
goto done ;
2005-07-20 19:35:29 +04:00
}
2002-04-02 05:10:41 +04:00
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-04-02 05:10:41 +04:00
2005-08-07 23:09:14 +04:00
value . type = REG_NONE ;
if ( strequal ( argv [ 2 ] , " string " ) ) {
value . type = REG_SZ ;
}
if ( strequal ( argv [ 2 ] , " binary " ) ) {
value . type = REG_BINARY ;
}
if ( strequal ( argv [ 2 ] , " dword " ) ) {
value . type = REG_DWORD ;
}
if ( strequal ( argv [ 2 ] , " multistring " ) ) {
value . type = REG_MULTI_SZ ;
}
if ( value . type = = REG_NONE ) {
printf ( " Unknown data type: %s \n " , argv [ 2 ] ) ;
2008-03-28 17:49:13 +03:00
result = WERR_INVALID_PARAM ;
goto done ;
2005-08-07 23:09:14 +04:00
}
2002-04-02 05:10:41 +04:00
/* get a printer handle */
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& pol ) ;
2002-04-02 05:10:41 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2009-02-14 05:08:06 +03:00
result = rpccli_spoolss_getprinter ( cli , mem_ctx ,
& pol ,
0 ,
0 ,
& info ) ;
2002-04-02 05:10:41 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2009-02-09 14:40:12 +03:00
2008-03-28 17:49:13 +03:00
printf ( " %s \n " , current_timestring ( tmp_ctx , True ) ) ;
2009-02-14 05:08:06 +03:00
printf ( " \t change_id (before set) \t :[0x%x] \n " , info . info0 . change_id ) ;
2002-04-02 05:10:41 +04:00
/* Set the printer data */
2009-02-09 14:40:12 +03:00
2005-08-07 23:09:14 +04:00
fstrcpy ( value . valuename , argv [ 3 ] ) ;
switch ( value . type ) {
case REG_SZ : {
UNISTR2 data ;
init_unistr2 ( & data , argv [ 4 ] , UNI_STR_TERMINATE ) ;
value . size = data . uni_str_len * 2 ;
2007-04-30 05:34:28 +04:00
if ( value . size ) {
value . data_p = ( uint8 * ) TALLOC_MEMDUP ( mem_ctx , data . buffer ,
2006-07-30 20:36:56 +04:00
value . size ) ;
2007-04-30 05:34:28 +04:00
} else {
value . data_p = NULL ;
}
2005-08-07 23:09:14 +04:00
break ;
}
case REG_DWORD : {
uint32 data = strtoul ( argv [ 4 ] , NULL , 10 ) ;
value . size = sizeof ( data ) ;
2007-04-30 05:34:28 +04:00
if ( sizeof ( data ) ) {
value . data_p = ( uint8 * ) TALLOC_MEMDUP ( mem_ctx , & data ,
2006-07-30 20:36:56 +04:00
sizeof ( data ) ) ;
2007-04-30 05:34:28 +04:00
} else {
value . data_p = NULL ;
}
2005-08-07 23:09:14 +04:00
break ;
}
2005-08-08 01:23:38 +04:00
case REG_BINARY : {
DATA_BLOB data = strhex_to_data_blob ( mem_ctx , argv [ 4 ] ) ;
value . data_p = data . data ;
value . size = data . length ;
break ;
}
2005-08-07 23:09:14 +04:00
case REG_MULTI_SZ : {
int i ;
size_t len = 0 ;
char * p ;
for ( i = 4 ; i < argc ; i + + ) {
if ( strcmp ( argv [ i ] , " NULL " ) = = 0 ) {
argv [ i ] = " " ;
}
len + = strlen ( argv [ i ] ) + 1 ;
}
value . size = len * 2 ;
2005-10-18 07:24:00 +04:00
value . data_p = TALLOC_ARRAY ( mem_ctx , unsigned char , value . size ) ;
2005-08-07 23:09:14 +04:00
if ( value . data_p = = NULL ) {
result = WERR_NOMEM ;
goto done ;
}
2005-10-18 07:24:00 +04:00
p = ( char * ) value . data_p ;
2005-08-07 23:09:14 +04:00
len = value . size ;
for ( i = 4 ; i < argc ; i + + ) {
size_t l = ( strlen ( argv [ i ] ) + 1 ) * 2 ;
rpcstr_push ( p , argv [ i ] , len , STR_TERMINATE ) ;
p + = l ;
len - = l ;
}
SMB_ASSERT ( len = = 0 ) ;
break ;
}
default :
printf ( " Unknown data type: %s \n " , argv [ 2 ] ) ;
result = WERR_INVALID_PARAM ;
goto done ;
}
2002-09-25 19:19:00 +04:00
2005-09-30 21:13:37 +04:00
result = rpccli_spoolss_setprinterdata ( cli , mem_ctx , & pol , & value ) ;
2009-02-09 14:40:12 +03:00
2002-04-02 05:10:41 +04:00
if ( ! W_ERROR_IS_OK ( result ) ) {
2005-08-07 23:09:14 +04:00
printf ( " Unable to set [%s=%s]! \n " , argv [ 3 ] , argv [ 4 ] ) ;
2002-04-02 05:10:41 +04:00
goto done ;
}
2005-08-07 23:09:14 +04:00
printf ( " \t SetPrinterData succeeded [%s: %s] \n " , argv [ 3 ] , argv [ 4 ] ) ;
2009-02-09 14:40:12 +03:00
2009-02-14 05:08:06 +03:00
result = rpccli_spoolss_getprinter ( cli , mem_ctx ,
& pol ,
0 ,
0 ,
& info ) ;
2002-04-02 05:10:41 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2009-02-09 14:40:12 +03:00
2008-03-28 17:49:13 +03:00
printf ( " %s \n " , current_timestring ( tmp_ctx , True ) ) ;
2009-02-14 05:08:06 +03:00
printf ( " \t change_id (after set) \t :[0x%x] \n " , info . info0 . change_id ) ;
2002-04-02 05:10:41 +04:00
done :
/* cleanup */
2008-03-28 17:49:13 +03:00
TALLOC_FREE ( tmp_ctx ) ;
2009-02-25 14:09:15 +03:00
if ( is_valid_policy_hnd ( & pol ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & pol , NULL ) ;
2002-04-02 05:10:41 +04:00
2003-03-18 09:30:30 +03:00
return result ;
2002-04-02 05:10:41 +04:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-05-07 10:36:22 +04:00
static void display_job_info_1 ( JOB_INFO_1 * job )
{
fstring username = " " , document = " " , text_status = " " ;
2003-01-29 09:53:07 +03:00
rpcstr_pull ( username , job - > username . buffer ,
sizeof ( username ) , - 1 , STR_TERMINATE ) ;
2002-05-07 10:36:22 +04:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( document , job - > document . buffer ,
sizeof ( document ) , - 1 , STR_TERMINATE ) ;
2002-05-07 10:36:22 +04:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( text_status , job - > text_status . buffer ,
sizeof ( text_status ) , - 1 , STR_TERMINATE ) ;
2002-05-07 10:36:22 +04:00
printf ( " %d: jobid[%d]: %s %s %s %d/%d pages \n " , job - > position , job - > jobid ,
username , document , text_status , job - > pagesprinted ,
job - > totalpages ) ;
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-05-07 10:36:22 +04:00
static void display_job_info_2 ( JOB_INFO_2 * job )
{
fstring username = " " , document = " " , text_status = " " ;
2003-01-29 09:53:07 +03:00
rpcstr_pull ( username , job - > username . buffer ,
sizeof ( username ) , - 1 , STR_TERMINATE ) ;
2002-05-07 10:36:22 +04:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( document , job - > document . buffer ,
sizeof ( document ) , - 1 , STR_TERMINATE ) ;
2002-05-07 10:36:22 +04:00
2003-01-29 09:53:07 +03:00
rpcstr_pull ( text_status , job - > text_status . buffer ,
sizeof ( text_status ) , - 1 , STR_TERMINATE ) ;
2002-05-07 10:36:22 +04:00
printf ( " %d: jobid[%d]: %s %s %s %d/%d pages, %d bytes \n " , job - > position , job - > jobid ,
username , document , text_status , job - > pagesprinted ,
job - > totalpages , job - > size ) ;
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-05-07 10:36:22 +04:00
2009-02-26 17:35:12 +03:00
static void display_job_info1 ( struct spoolss_JobInfo1 * r )
{
printf ( " %d: jobid[%d]: %s %s %s %d/%d pages \n " , r - > position , r - > job_id ,
r - > user_name , r - > document_name , r - > text_status , r - > pages_printed ,
r - > total_pages ) ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void display_job_info2 ( struct spoolss_JobInfo2 * r )
{
printf ( " %d: jobid[%d]: %s %s %s %d/%d pages, %d bytes \n " ,
r - > position , r - > job_id ,
r - > user_name , r - > document_name , r - > text_status , r - > pages_printed ,
r - > total_pages , r - > size ) ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void display_job_info3 ( struct spoolss_JobInfo3 * r )
{
printf ( " jobid[%d], next_jobid[%d] \n " ,
r - > job_id , r - > next_job_id ) ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void display_job_info4 ( struct spoolss_JobInfo4 * r )
{
printf ( " %d: jobid[%d]: %s %s %s %d/%d pages, %d/%d bytes \n " ,
r - > position , r - > job_id ,
r - > user_name , r - > document_name , r - > text_status , r - > pages_printed ,
r - > total_pages , r - > size , r - > size_high ) ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_enum_jobs ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2002-05-07 10:36:22 +04:00
{
WERROR result ;
2006-06-29 01:52:56 +04:00
uint32 level = 1 , num_jobs , i ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2002-05-07 10:36:22 +04:00
POLICY_HND hnd ;
JOB_INFO_CTR ctr ;
2007-11-21 02:31:37 +03:00
2002-05-07 10:36:22 +04:00
if ( argc < 2 | | argc > 3 ) {
printf ( " Usage: %s printername [level] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-05-07 10:36:22 +04:00
}
2007-11-21 02:31:37 +03:00
2002-05-07 10:36:22 +04:00
if ( argc = = 3 )
level = atoi ( argv [ 2 ] ) ;
/* Open printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-05-07 10:36:22 +04:00
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& hnd ) ;
2002-05-07 10:36:22 +04:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2007-11-21 02:31:37 +03:00
2002-05-07 10:36:22 +04:00
/* Enumerate ports */
2005-09-30 21:13:37 +04:00
result = rpccli_spoolss_enumjobs ( cli , mem_ctx , & hnd , level , 0 , 1000 ,
2002-05-07 10:36:22 +04:00
& num_jobs , & ctr ) ;
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
for ( i = 0 ; i < num_jobs ; i + + ) {
switch ( level ) {
case 1 :
2002-09-25 19:19:00 +04:00
display_job_info_1 ( & ctr . job . job_info_1 [ i ] ) ;
2002-05-07 10:36:22 +04:00
break ;
case 2 :
2002-09-25 19:19:00 +04:00
display_job_info_2 ( & ctr . job . job_info_2 [ i ] ) ;
2002-05-07 10:36:22 +04:00
break ;
default :
d_printf ( " unknown info level %d \n " , level ) ;
break ;
}
}
2009-02-09 14:40:12 +03:00
2002-05-07 10:36:22 +04:00
done :
2009-02-26 17:33:16 +03:00
if ( is_valid_policy_hnd ( & hnd ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & hnd , NULL ) ;
2002-05-07 10:36:22 +04:00
2003-03-18 09:30:30 +03:00
return result ;
2002-05-07 10:36:22 +04:00
}
2002-04-02 05:10:41 +04:00
2009-02-26 17:35:12 +03:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static WERROR cmd_spoolss_get_job ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
WERROR result ;
const char * printername ;
struct policy_handle hnd ;
uint32_t job_id ;
uint32_t level = 1 ;
union spoolss_JobInfo info ;
if ( argc < 3 | | argc > 4 ) {
printf ( " Usage: %s printername job_id [level] \n " , argv [ 0 ] ) ;
return WERR_OK ;
}
job_id = atoi ( argv [ 2 ] ) ;
if ( argc = = 4 ) {
level = atoi ( argv [ 3 ] ) ;
}
/* Open printer handle */
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& hnd ) ;
if ( ! W_ERROR_IS_OK ( result ) ) {
goto done ;
}
/* Enumerate ports */
result = rpccli_spoolss_getjob ( cli , mem_ctx ,
& hnd ,
job_id ,
level ,
0 ,
& info ) ;
if ( ! W_ERROR_IS_OK ( result ) ) {
goto done ;
}
switch ( level ) {
case 1 :
display_job_info1 ( & info . info1 ) ;
break ;
case 2 :
display_job_info2 ( & info . info2 ) ;
break ;
case 3 :
display_job_info3 ( & info . info3 ) ;
break ;
case 4 :
display_job_info4 ( & info . info4 ) ;
break ;
default :
d_printf ( " unknown info level %d \n " , level ) ;
break ;
}
done :
if ( is_valid_policy_hnd ( & hnd ) ) {
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & hnd , NULL ) ;
}
return result ;
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-11-08 23:50:06 +03:00
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_enum_data ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2002-11-08 23:50:06 +03:00
{
WERROR result ;
uint32 i = 0 , val_needed , data_needed ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2002-11-08 23:50:06 +03:00
POLICY_HND hnd ;
if ( argc ! = 2 ) {
printf ( " Usage: %s printername \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-11-08 23:50:06 +03:00
}
2007-11-21 02:31:37 +03:00
2002-11-08 23:50:06 +03:00
/* Open printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-11-08 23:50:06 +03:00
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& hnd ) ;
2002-11-08 23:50:06 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2009-02-09 14:40:12 +03:00
2002-11-08 23:50:06 +03:00
/* Enumerate data */
2005-09-30 21:13:37 +04:00
result = rpccli_spoolss_enumprinterdata ( cli , mem_ctx , & hnd , i , 0 , 0 ,
2002-11-08 23:50:06 +03:00
& val_needed , & data_needed ,
NULL ) ;
while ( W_ERROR_IS_OK ( result ) ) {
REGISTRY_VALUE value ;
2005-09-30 21:13:37 +04:00
result = rpccli_spoolss_enumprinterdata (
2002-11-08 23:50:06 +03:00
cli , mem_ctx , & hnd , i + + , val_needed ,
data_needed , 0 , 0 , & value ) ;
if ( W_ERROR_IS_OK ( result ) )
display_reg_value ( value ) ;
}
if ( W_ERROR_V ( result ) = = ERRnomoreitems )
result = W_ERROR ( ERRsuccess ) ;
done :
2009-02-26 17:33:16 +03:00
if ( is_valid_policy_hnd ( & hnd ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & hnd , NULL ) ;
2002-11-08 23:50:06 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2002-11-08 23:50:06 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-11-09 00:40:31 +03:00
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_enum_data_ex ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2002-11-09 00:40:31 +03:00
{
WERROR result ;
2005-07-20 19:35:29 +04:00
uint32 i ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2003-02-26 02:51:56 +03:00
const char * keyname = NULL ;
2002-11-09 00:40:31 +03:00
POLICY_HND hnd ;
2005-08-29 18:55:40 +04:00
REGVAL_CTR * ctr = NULL ;
2002-11-09 00:40:31 +03:00
if ( argc ! = 3 ) {
printf ( " Usage: %s printername <keyname> \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-11-09 00:40:31 +03:00
}
2007-11-21 02:31:37 +03:00
2002-11-09 00:40:31 +03:00
keyname = argv [ 2 ] ;
/* Open printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-11-09 00:40:31 +03:00
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& hnd ) ;
2002-11-09 00:40:31 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2009-02-09 14:40:12 +03:00
2002-11-09 00:40:31 +03:00
/* Enumerate subkeys */
2009-02-09 14:40:12 +03:00
if ( ! ( ctr = TALLOC_ZERO_P ( mem_ctx , REGVAL_CTR ) ) )
2005-08-29 18:55:40 +04:00
return WERR_NOMEM ;
2005-09-30 21:13:37 +04:00
result = rpccli_spoolss_enumprinterdataex ( cli , mem_ctx , & hnd , keyname , ctr ) ;
2002-11-09 00:40:31 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2005-08-29 18:55:40 +04:00
for ( i = 0 ; i < ctr - > num_values ; i + + ) {
display_reg_value ( * ( ctr - > values [ i ] ) ) ;
2002-11-09 00:40:31 +03:00
}
2005-08-29 18:55:40 +04:00
TALLOC_FREE ( ctr ) ;
2002-11-09 00:40:31 +03:00
done :
2009-02-26 17:33:16 +03:00
if ( is_valid_policy_hnd ( & hnd ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & hnd , NULL ) ;
2002-11-09 00:40:31 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2002-11-09 00:40:31 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-11-08 22:07:36 +03:00
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_enum_printerkey ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2002-11-08 22:07:36 +03:00
{
WERROR result ;
2009-02-10 17:11:29 +03:00
const char * printername ;
2003-01-03 11:28:12 +03:00
const char * keyname = NULL ;
2002-11-08 22:07:36 +03:00
POLICY_HND hnd ;
uint16 * keylist = NULL , * curkey ;
if ( argc < 2 | | argc > 3 ) {
printf ( " Usage: %s printername [keyname] \n " , argv [ 0 ] ) ;
2003-03-18 09:30:30 +03:00
return WERR_OK ;
2002-11-08 22:07:36 +03:00
}
2007-11-21 02:31:37 +03:00
2002-11-08 22:07:36 +03:00
if ( argc = = 3 )
keyname = argv [ 2 ] ;
else
keyname = " " ;
/* Open printer handle */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2007-11-21 02:31:37 +03:00
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& hnd ) ;
2002-11-08 22:07:36 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
2009-02-09 14:40:12 +03:00
2002-11-08 23:50:06 +03:00
/* Enumerate subkeys */
2002-11-08 22:07:36 +03:00
2005-09-30 21:13:37 +04:00
result = rpccli_spoolss_enumprinterkey ( cli , mem_ctx , & hnd , keyname , & keylist , NULL ) ;
2002-11-08 22:07:36 +03:00
if ( ! W_ERROR_IS_OK ( result ) )
goto done ;
curkey = keylist ;
while ( * curkey ! = 0 ) {
2007-11-21 02:31:37 +03:00
char * subkey = NULL ;
rpcstr_pull_talloc ( mem_ctx , & subkey , curkey , - 1 ,
2002-11-08 22:07:36 +03:00
STR_TERMINATE ) ;
2007-11-21 02:31:37 +03:00
if ( ! subkey ) {
break ;
}
2002-11-08 22:07:36 +03:00
printf ( " %s \n " , subkey ) ;
curkey + = strlen ( subkey ) + 1 ;
}
done :
2006-03-31 04:50:09 +04:00
SAFE_FREE ( keylist ) ;
2009-02-26 17:33:16 +03:00
if ( is_valid_policy_hnd ( & hnd ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & hnd , NULL ) ;
2002-11-08 22:07:36 +03:00
2003-03-18 09:30:30 +03:00
return result ;
2002-11-08 22:07:36 +03:00
}
2005-07-20 19:35:29 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_rffpcnex ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2003-02-26 02:51:56 +03:00
const char * * argv )
2002-08-17 19:33:49 +04:00
{
2009-02-10 17:11:29 +03:00
const char * printername ;
2009-02-23 12:29:46 +03:00
const char * clientname ;
2002-08-17 19:33:49 +04:00
POLICY_HND hnd ;
WERROR result ;
2009-02-17 01:32:31 +03:00
NTSTATUS status ;
struct spoolss_NotifyOption option ;
2002-08-17 19:33:49 +04:00
if ( argc ! = 2 ) {
printf ( " Usage: %s printername \n " , argv [ 0 ] ) ;
result = WERR_OK ;
goto done ;
}
/* Open printer */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername , cli , argv [ 1 ] ) ;
2002-08-17 19:33:49 +04:00
2009-02-09 20:49:34 +03:00
result = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername ,
SEC_FLAG_MAXIMUM_ALLOWED ,
& hnd ) ;
2002-08-17 19:33:49 +04:00
if ( ! W_ERROR_IS_OK ( result ) ) {
printf ( " Error opening %s \n " , argv [ 1 ] ) ;
goto done ;
}
/* Create spool options */
option . version = 2 ;
2009-02-17 01:32:31 +03:00
option . count = 2 ;
2002-08-17 19:33:49 +04:00
2009-02-17 01:32:31 +03:00
option . types = talloc_array ( mem_ctx , struct spoolss_NotifyOptionType , 2 ) ;
if ( option . types = = NULL ) {
2006-06-18 13:45:18 +04:00
result = WERR_NOMEM ;
goto done ;
}
2002-08-17 19:33:49 +04:00
2009-02-17 01:32:31 +03:00
option . types [ 0 ] . type = PRINTER_NOTIFY_TYPE ;
option . types [ 0 ] . count = 1 ;
option . types [ 0 ] . fields = talloc_array ( mem_ctx , enum spoolss_Field , 1 ) ;
if ( option . types [ 0 ] . fields = = NULL ) {
result = WERR_NOMEM ;
goto done ;
}
option . types [ 0 ] . fields [ 0 ] = PRINTER_NOTIFY_SERVER_NAME ;
2002-08-17 19:33:49 +04:00
2009-02-17 01:32:31 +03:00
option . types [ 1 ] . type = JOB_NOTIFY_TYPE ;
option . types [ 1 ] . count = 1 ;
option . types [ 1 ] . fields = talloc_array ( mem_ctx , enum spoolss_Field , 1 ) ;
if ( option . types [ 1 ] . fields = = NULL ) {
result = WERR_NOMEM ;
goto done ;
}
option . types [ 1 ] . fields [ 0 ] = JOB_NOTIFY_PRINTER_NAME ;
2002-08-17 19:33:49 +04:00
2009-02-23 12:29:46 +03:00
clientname = talloc_asprintf ( mem_ctx , " \\ \\ %s " , global_myname ( ) ) ;
if ( ! clientname ) {
result = WERR_NOMEM ;
goto done ;
}
2002-08-17 19:33:49 +04:00
/* Send rffpcnex */
2009-02-17 01:32:31 +03:00
status = rpccli_spoolss_RemoteFindFirstPrinterChangeNotifyEx ( cli , mem_ctx ,
& hnd ,
0 ,
0 ,
2009-02-23 12:29:46 +03:00
clientname ,
2009-02-17 01:32:31 +03:00
123 ,
& option ,
& result ) ;
2002-08-17 19:33:49 +04:00
if ( ! W_ERROR_IS_OK ( result ) ) {
printf ( " Error rffpcnex %s \n " , argv [ 1 ] ) ;
goto done ;
}
2009-02-09 14:40:12 +03:00
done :
2009-02-26 17:33:16 +03:00
if ( is_valid_policy_hnd ( & hnd ) )
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & hnd , NULL ) ;
2002-08-17 19:33:49 +04:00
2003-03-18 09:30:30 +03:00
return result ;
2002-08-17 19:33:49 +04:00
}
2005-09-30 21:13:37 +04:00
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
static bool compare_printer ( struct rpc_pipe_client * cli1 , POLICY_HND * hnd1 ,
2005-09-30 21:13:37 +04:00
struct rpc_pipe_client * cli2 , POLICY_HND * hnd2 )
{
2009-02-14 05:08:06 +03:00
union spoolss_PrinterInfo info1 , info2 ;
2005-09-30 21:13:37 +04:00
WERROR werror ;
TALLOC_CTX * mem_ctx = talloc_init ( " compare_printer " ) ;
2008-04-19 23:56:43 +04:00
printf ( " Retrieving printer propertiesfor %s... " , cli1 - > desthost ) ;
2009-02-14 05:08:06 +03:00
werror = rpccli_spoolss_getprinter ( cli1 , mem_ctx ,
hnd1 ,
2 ,
0 ,
& info1 ) ;
2005-09-30 21:13:37 +04:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
2008-11-01 19:19:26 +03:00
printf ( " failed (%s) \n " , win_errstr ( werror ) ) ;
2005-09-30 21:13:37 +04:00
talloc_destroy ( mem_ctx ) ;
return False ;
}
printf ( " ok \n " ) ;
2008-04-19 23:56:43 +04:00
printf ( " Retrieving printer properties for %s... " , cli2 - > desthost ) ;
2009-02-14 05:08:06 +03:00
werror = rpccli_spoolss_getprinter ( cli2 , mem_ctx ,
hnd2 ,
2 ,
0 ,
& info2 ) ;
2005-09-30 21:13:37 +04:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
2008-11-01 19:19:26 +03:00
printf ( " failed (%s) \n " , win_errstr ( werror ) ) ;
2005-09-30 21:13:37 +04:00
talloc_destroy ( mem_ctx ) ;
return False ;
}
printf ( " ok \n " ) ;
talloc_destroy ( mem_ctx ) ;
return True ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
static bool compare_printer_secdesc ( struct rpc_pipe_client * cli1 , POLICY_HND * hnd1 ,
2005-09-30 21:13:37 +04:00
struct rpc_pipe_client * cli2 , POLICY_HND * hnd2 )
{
2009-02-14 05:08:06 +03:00
union spoolss_PrinterInfo info1 , info2 ;
2005-09-30 21:13:37 +04:00
WERROR werror ;
TALLOC_CTX * mem_ctx = talloc_init ( " compare_printer_secdesc " ) ;
SEC_DESC * sd1 , * sd2 ;
2007-10-19 04:40:25 +04:00
bool result = True ;
2005-09-30 21:13:37 +04:00
2008-04-19 23:56:43 +04:00
printf ( " Retrieving printer security for %s... " , cli1 - > desthost ) ;
2009-02-14 05:08:06 +03:00
werror = rpccli_spoolss_getprinter ( cli1 , mem_ctx ,
hnd1 ,
3 ,
0 ,
& info1 ) ;
2005-09-30 21:13:37 +04:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
2008-11-01 19:19:26 +03:00
printf ( " failed (%s) \n " , win_errstr ( werror ) ) ;
2005-09-30 21:13:37 +04:00
result = False ;
goto done ;
}
printf ( " ok \n " ) ;
2008-04-19 23:56:43 +04:00
printf ( " Retrieving printer security for %s... " , cli2 - > desthost ) ;
2009-02-14 05:08:06 +03:00
werror = rpccli_spoolss_getprinter ( cli2 , mem_ctx ,
hnd2 ,
3 ,
0 ,
& info2 ) ;
2005-09-30 21:13:37 +04:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
2008-11-01 19:19:26 +03:00
printf ( " failed (%s) \n " , win_errstr ( werror ) ) ;
2005-09-30 21:13:37 +04:00
result = False ;
goto done ;
}
printf ( " ok \n " ) ;
2009-02-09 14:40:12 +03:00
2005-09-30 21:13:37 +04:00
printf ( " ++ " ) ;
2009-02-14 05:08:06 +03:00
sd1 = info1 . info3 . secdesc ;
sd2 = info2 . info3 . secdesc ;
2009-02-09 14:40:12 +03:00
2005-09-30 21:13:37 +04:00
if ( ( sd1 ! = sd2 ) & & ( ! sd1 | | ! sd2 ) ) {
printf ( " NULL secdesc! \n " ) ;
result = False ;
goto done ;
}
2009-02-09 14:40:12 +03:00
2007-04-03 23:47:19 +04:00
if ( ! sec_desc_equal ( sd1 , sd2 ) ) {
2005-09-30 21:13:37 +04:00
printf ( " Security Descriptors *not* equal! \n " ) ;
result = False ;
goto done ;
}
2009-02-09 14:40:12 +03:00
2005-09-30 21:13:37 +04:00
printf ( " Security descriptors match \n " ) ;
2009-02-09 14:40:12 +03:00
2005-09-30 21:13:37 +04:00
done :
talloc_destroy ( mem_ctx ) ;
return result ;
}
/****************************************************************************
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-12-14 15:06:19 +03:00
extern struct user_auth_info * rpcclient_auth_info ;
2009-02-09 14:40:12 +03:00
static WERROR cmd_spoolss_printercmp ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
2005-09-30 21:13:37 +04:00
const char * * argv )
{
2009-02-11 11:35:05 +03:00
const char * printername ;
2007-11-21 02:31:37 +03:00
char * printername_path = NULL ;
2005-09-30 21:13:37 +04:00
struct cli_state * cli_server2 = NULL ;
struct rpc_pipe_client * cli2 = NULL ;
POLICY_HND hPrinter1 , hPrinter2 ;
NTSTATUS nt_status ;
WERROR werror ;
2007-11-21 02:31:37 +03:00
2005-09-30 21:13:37 +04:00
if ( argc ! = 3 ) {
printf ( " Usage: %s <printer> <server> \n " , argv [ 0 ] ) ;
return WERR_OK ;
}
2009-02-11 11:35:05 +03:00
printername = argv [ 1 ] ;
2007-11-21 02:31:37 +03:00
2005-09-30 21:13:37 +04:00
/* first get the connection to the remote server */
2007-11-21 02:31:37 +03:00
2009-02-10 17:11:29 +03:00
nt_status = cli_full_connection ( & cli_server2 , global_myname ( ) , argv [ 2 ] ,
2005-09-30 21:13:37 +04:00
NULL , 0 ,
2007-11-21 02:31:37 +03:00
" IPC$ " , " IPC " ,
2008-12-14 15:06:19 +03:00
get_cmdline_auth_info_username ( rpcclient_auth_info ) ,
2005-09-30 21:13:37 +04:00
lp_workgroup ( ) ,
2008-12-14 15:06:19 +03:00
get_cmdline_auth_info_password ( rpcclient_auth_info ) ,
get_cmdline_auth_info_use_kerberos ( rpcclient_auth_info ) ? CLI_FULL_CONNECTION_USE_KERBEROS : 0 ,
get_cmdline_auth_info_signing_state ( rpcclient_auth_info ) , NULL ) ;
2007-11-21 02:31:37 +03:00
2005-09-30 21:13:37 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) )
return WERR_GENERAL_FAILURE ;
2008-07-20 13:04:31 +04:00
nt_status = cli_rpc_pipe_open_noauth ( cli_server2 , & syntax_spoolss ,
& cli2 ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2005-09-30 21:13:37 +04:00
printf ( " failed to open spoolss pipe on server %s (%s) \n " ,
2009-02-10 17:11:29 +03:00
argv [ 2 ] , nt_errstr ( nt_status ) ) ;
2005-09-30 21:13:37 +04:00
return WERR_GENERAL_FAILURE ;
}
2007-11-21 02:31:37 +03:00
2005-09-30 21:13:37 +04:00
/* now open up both printers */
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername_path , cli , printername ) ;
2005-09-30 21:13:37 +04:00
printf ( " Opening %s... " , printername_path ) ;
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli , mem_ctx ,
printername_path ,
PRINTER_ALL_ACCESS ,
& hPrinter1 ) ;
2005-09-30 21:13:37 +04:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
2008-11-01 19:19:26 +03:00
printf ( " failed (%s) \n " , win_errstr ( werror ) ) ;
2005-09-30 21:13:37 +04:00
goto done ;
}
printf ( " ok \n " ) ;
2007-11-21 02:31:37 +03:00
2009-02-10 17:11:29 +03:00
RPCCLIENT_PRINTERNAME ( printername_path , cli2 , printername ) ;
2005-09-30 21:13:37 +04:00
printf ( " Opening %s... " , printername_path ) ;
2009-02-09 20:49:34 +03:00
werror = rpccli_spoolss_openprinter_ex ( cli2 , mem_ctx ,
printername_path ,
PRINTER_ALL_ACCESS ,
& hPrinter2 ) ;
2005-09-30 21:13:37 +04:00
if ( ! W_ERROR_IS_OK ( werror ) ) {
2008-11-01 19:19:26 +03:00
printf ( " failed (%s) \n " , win_errstr ( werror ) ) ;
2005-09-30 21:13:37 +04:00
goto done ;
}
printf ( " ok \n " ) ;
2007-11-21 02:31:37 +03:00
2005-09-30 21:13:37 +04:00
compare_printer ( cli , & hPrinter1 , cli2 , & hPrinter2 ) ;
compare_printer_secdesc ( cli , & hPrinter1 , cli2 , & hPrinter2 ) ;
#if 0
compare_printerdata ( cli_server1 , & hPrinter1 , cli_server2 , & hPrinter2 ) ;
# endif
done :
/* cleanup */
2007-11-21 02:31:37 +03:00
printf ( " Closing printers... " ) ;
2008-11-15 01:58:26 +03:00
rpccli_spoolss_ClosePrinter ( cli , mem_ctx , & hPrinter1 , NULL ) ;
rpccli_spoolss_ClosePrinter ( cli2 , mem_ctx , & hPrinter2 , NULL ) ;
2005-09-30 21:13:37 +04:00
printf ( " ok \n " ) ;
2007-11-21 02:31:37 +03:00
2005-09-30 21:13:37 +04:00
/* close the second remote connection */
2007-11-21 02:31:37 +03:00
2005-09-30 21:13:37 +04:00
cli_shutdown ( cli_server2 ) ;
return WERR_OK ;
}
2009-03-07 00:11:09 +03:00
static void display_proc_info1 ( struct spoolss_PrintProcessorInfo1 * r )
{
printf ( " print_processor_name: %s \n " , r - > print_processor_name ) ;
}
static WERROR cmd_spoolss_enum_procs ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
WERROR werror ;
const char * environment = SPOOLSS_ARCHITECTURE_NT_X86 ;
uint32_t num_procs , level = 1 , i ;
union spoolss_PrintProcessorInfo * procs ;
/* Parse the command arguments */
if ( argc < 1 | | argc > 4 ) {
printf ( " Usage: %s [environment] [level] \n " , argv [ 0 ] ) ;
return WERR_OK ;
}
if ( argc > = 2 ) {
environment = argv [ 1 ] ;
}
if ( argc = = 3 ) {
level = atoi ( argv [ 2 ] ) ;
}
/* Enumerate Print Processors */
werror = rpccli_spoolss_enumprintprocessors ( cli , mem_ctx ,
cli - > srv_name_slash ,
environment ,
level ,
0 ,
& num_procs ,
& procs ) ;
if ( ! W_ERROR_IS_OK ( werror ) )
goto done ;
/* Display output */
for ( i = 0 ; i < num_procs ; i + + ) {
switch ( level ) {
case 1 :
display_proc_info1 ( & procs [ i ] . info1 ) ;
break ;
}
}
done :
return werror ;
}
2009-03-07 02:55:15 +03:00
static void display_proc_data_types_info1 ( struct spoolss_PrintProcDataTypesInfo1 * r )
{
printf ( " name_array: %s \n " , r - > name_array ) ;
}
static WERROR cmd_spoolss_enum_proc_data_types ( struct rpc_pipe_client * cli ,
TALLOC_CTX * mem_ctx , int argc ,
const char * * argv )
{
WERROR werror ;
const char * print_processor_name = " winprint " ;
uint32_t num_procs , level = 1 , i ;
union spoolss_PrintProcDataTypesInfo * procs ;
/* Parse the command arguments */
if ( argc < 1 | | argc > 4 ) {
printf ( " Usage: %s [environment] [level] \n " , argv [ 0 ] ) ;
return WERR_OK ;
}
if ( argc > = 2 ) {
print_processor_name = argv [ 1 ] ;
}
if ( argc = = 3 ) {
level = atoi ( argv [ 2 ] ) ;
}
/* Enumerate Print Processor Data Types */
werror = rpccli_spoolss_enumprintprocessordatatypes ( cli , mem_ctx ,
cli - > srv_name_slash ,
print_processor_name ,
level ,
0 ,
& num_procs ,
& procs ) ;
if ( ! W_ERROR_IS_OK ( werror ) )
goto done ;
/* Display output */
for ( i = 0 ; i < num_procs ; i + + ) {
switch ( level ) {
case 1 :
display_proc_data_types_info1 ( & procs [ i ] . info1 ) ;
break ;
}
}
done :
return werror ;
}
2001-01-12 01:49:30 +03:00
/* List of commands exported by this module */
struct cmd_set spoolss_commands [ ] = {
2000-08-10 00:14:29 +04:00
2001-07-20 08:38:58 +04:00
{ " SPOOLSS " } ,
2008-07-20 20:17:52 +04:00
{ " adddriver " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_addprinterdriver , & syntax_spoolss , NULL , " Add a print driver " , " " } ,
{ " addprinter " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_addprinterex , & syntax_spoolss , NULL , " Add a printer " , " " } ,
{ " deldriver " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_deletedriver , & syntax_spoolss , NULL , " Delete a printer driver " , " " } ,
{ " deldriverex " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_deletedriverex , & syntax_spoolss , NULL , " Delete a printer driver with files " , " " } ,
{ " enumdata " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_data , & syntax_spoolss , NULL , " Enumerate printer data " , " " } ,
{ " enumdataex " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_data_ex , & syntax_spoolss , NULL , " Enumerate printer data for a key " , " " } ,
{ " enumkey " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_printerkey , & syntax_spoolss , NULL , " Enumerate printer keys " , " " } ,
{ " enumjobs " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_jobs , & syntax_spoolss , NULL , " Enumerate print jobs " , " " } ,
2009-02-26 17:35:12 +03:00
{ " getjob " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_get_job , & syntax_spoolss , NULL , " Get print job " , " " } ,
2008-07-20 20:17:52 +04:00
{ " enumports " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_ports , & syntax_spoolss , NULL , " Enumerate printer ports " , " " } ,
{ " enumdrivers " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_drivers , & syntax_spoolss , NULL , " Enumerate installed printer drivers " , " " } ,
{ " enumprinters " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_printers , & syntax_spoolss , NULL , " Enumerate printers " , " " } ,
{ " getdata " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_getprinterdata , & syntax_spoolss , NULL , " Get print driver data " , " " } ,
{ " getdataex " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_getprinterdataex , & syntax_spoolss , NULL , " Get printer driver data with keyname " , " " } ,
{ " getdriver " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_getdriver , & syntax_spoolss , NULL , " Get print driver information " , " " } ,
{ " getdriverdir " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_getdriverdir , & syntax_spoolss , NULL , " Get print driver upload directory " , " " } ,
{ " getprinter " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_getprinter , & syntax_spoolss , NULL , " Get printer info " , " " } ,
{ " openprinter " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_open_printer_ex , & syntax_spoolss , NULL , " Open printer handle " , " " } ,
{ " setdriver " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_setdriver , & syntax_spoolss , NULL , " Set printer driver " , " " } ,
{ " getprintprocdir " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_getprintprocdir , & syntax_spoolss , NULL , " Get print processor directory " , " " } ,
{ " addform " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_addform , & syntax_spoolss , NULL , " Add form " , " " } ,
{ " setform " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_setform , & syntax_spoolss , NULL , " Set form " , " " } ,
{ " getform " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_getform , & syntax_spoolss , NULL , " Get form " , " " } ,
{ " deleteform " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_deleteform , & syntax_spoolss , NULL , " Delete form " , " " } ,
{ " enumforms " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_forms , & syntax_spoolss , NULL , " Enumerate forms " , " " } ,
{ " setprinter " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_setprinter , & syntax_spoolss , NULL , " Set printer comment " , " " } ,
{ " setprintername " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_setprintername , & syntax_spoolss , NULL , " Set printername " , " " } ,
{ " setprinterdata " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_setprinterdata , & syntax_spoolss , NULL , " Set REG_SZ printer data " , " " } ,
{ " rffpcnex " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_rffpcnex , & syntax_spoolss , NULL , " Rffpcnex test " , " " } ,
{ " printercmp " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_printercmp , & syntax_spoolss , NULL , " Printer comparison test " , " " } ,
2009-03-07 00:11:09 +03:00
{ " enumprocs " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_procs , & syntax_spoolss , NULL , " Enumerate Print Processors " , " " } ,
2009-03-07 02:55:15 +03:00
{ " enumprocdatatypes " , RPC_RTYPE_WERROR , NULL , cmd_spoolss_enum_proc_data_types , & syntax_spoolss , NULL , " Enumerate Print Processor Data Types " , " " } ,
2001-07-20 08:38:58 +04:00
{ NULL }
2001-01-12 01:49:30 +03:00
} ;