mirror of
https://github.com/samba-team/samba.git
synced 2025-03-08 04:58:40 +03:00
added getdriverdir and cleaned up the PRINTER_DRIVER_CTR struct
This commit is contained in:
parent
7a84bc93ed
commit
5d32167385
@ -1534,11 +1534,7 @@ DRIVER_DIRECTORY_1;
|
||||
|
||||
typedef struct driver_info_ctr_info
|
||||
{
|
||||
union
|
||||
{
|
||||
DRIVER_DIRECTORY_1 info_1;
|
||||
}
|
||||
driver;
|
||||
DRIVER_DIRECTORY_1 *info1;
|
||||
}
|
||||
DRIVER_DIRECTORY_CTR;
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
Unix SMB/Netbios implementation.
|
||||
Version 2.2
|
||||
RPC pipe client
|
||||
|
||||
Copyright (C) Gerald Carter 2001,
|
||||
Copyright (C) Tim Potter 2000,
|
||||
Copyright (C) Andrew Tridgell 1994-2000
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-2000
|
||||
@ -342,8 +344,11 @@ static void decode_printer_driver_2(NEW_BUFFER *buffer, uint32 returned,
|
||||
*info=inf;
|
||||
}
|
||||
|
||||
static void decode_printer_driver_3(NEW_BUFFER *buffer, uint32 returned,
|
||||
DRIVER_INFO_3 **info)
|
||||
static void decode_printer_driver_3(
|
||||
NEW_BUFFER *buffer,
|
||||
uint32 returned,
|
||||
DRIVER_INFO_3 **info
|
||||
)
|
||||
{
|
||||
uint32 i;
|
||||
DRIVER_INFO_3 *inf;
|
||||
@ -359,6 +364,22 @@ static void decode_printer_driver_3(NEW_BUFFER *buffer, uint32 returned,
|
||||
*info=inf;
|
||||
}
|
||||
|
||||
static void decode_printerdriverdir_1 (
|
||||
NEW_BUFFER *buffer,
|
||||
uint32 returned,
|
||||
DRIVER_DIRECTORY_1 **info
|
||||
)
|
||||
{
|
||||
DRIVER_DIRECTORY_1 *inf;
|
||||
|
||||
inf=(DRIVER_DIRECTORY_1 *)malloc(sizeof(DRIVER_DIRECTORY_1));
|
||||
|
||||
prs_set_offset(&buffer->prs, 0);
|
||||
|
||||
new_smb_io_driverdir_1("", buffer, inf, 0);
|
||||
|
||||
*info=inf;
|
||||
}
|
||||
|
||||
|
||||
/* Enumerate printers */
|
||||
@ -737,3 +758,74 @@ uint32 cli_spoolss_enumprinterdrivers (
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Get installed printer drivers for a given printer
|
||||
*/
|
||||
uint32 cli_spoolss_getprinterdriverdir (
|
||||
struct cli_state *cli,
|
||||
uint32 level,
|
||||
char* env,
|
||||
DRIVER_DIRECTORY_CTR *ctr
|
||||
)
|
||||
{
|
||||
prs_struct qbuf, rbuf;
|
||||
SPOOL_Q_GETPRINTERDRIVERDIR q;
|
||||
SPOOL_R_GETPRINTERDRIVERDIR r;
|
||||
NEW_BUFFER buffer;
|
||||
uint32 needed = 100;
|
||||
uint32 result;
|
||||
fstring server;
|
||||
|
||||
ZERO_STRUCT(q);
|
||||
ZERO_STRUCT(r);
|
||||
|
||||
slprintf (server, sizeof(fstring), "\\\\%s", cli->desthost);
|
||||
strupper (server);
|
||||
|
||||
do
|
||||
{
|
||||
/* Initialise input parameters */
|
||||
init_buffer(&buffer, needed, cli->mem_ctx);
|
||||
|
||||
prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
|
||||
prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
|
||||
|
||||
|
||||
/* write the request */
|
||||
make_spoolss_q_getprinterdriverdir(&q, server, env, level, &buffer, needed);
|
||||
|
||||
/* Marshall data and send request */
|
||||
if (!spoolss_io_q_getprinterdriverdir ("", &q, &qbuf, 0) ||
|
||||
!rpc_api_pipe_req (cli, SPOOLSS_GETPRINTERDRIVERDIRECTORY, &qbuf, &rbuf))
|
||||
{
|
||||
result = NT_STATUS_UNSUCCESSFUL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Unmarshall response */
|
||||
if (spoolss_io_r_getprinterdriverdir ("", &r, &rbuf, 0))
|
||||
{
|
||||
needed = r.needed;
|
||||
}
|
||||
|
||||
/* Return output parameters */
|
||||
if ((result=r.status) == NT_STATUS_NOPROBLEMO)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case 1:
|
||||
decode_printerdriverdir_1(r.buffer, 1, &ctr->info1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
prs_mem_free(&qbuf);
|
||||
prs_mem_free(&rbuf);
|
||||
|
||||
} while (result == ERROR_INSUFFICIENT_BUFFER);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
Version 2.2
|
||||
RPC pipe client
|
||||
|
||||
Copyright (C) Gerald Carter 2001
|
||||
Copyright (C) Tim Potter 2000
|
||||
Copyright (C) Andrew Tridgell 1992-1999
|
||||
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
|
||||
@ -817,6 +818,65 @@ static uint32 cmd_spoolss_enum_drivers(struct cli_state *cli, int argc, char **a
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
printer info level 1 display function
|
||||
****************************************************************************/
|
||||
static void display_printdriverdir_1(DRIVER_DIRECTORY_1 *i1)
|
||||
{
|
||||
fstring name;
|
||||
if (i1 == NULL)
|
||||
return;
|
||||
|
||||
unistr_to_ascii(name, i1->name.buffer, sizeof(name)-1);
|
||||
|
||||
printf ("\tDirectory Name:[%s]\n", name);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* Get printer information
|
||||
*/
|
||||
static uint32 cmd_spoolss_getdriverdir(struct cli_state *cli, int argc, char **argv)
|
||||
{
|
||||
uint32 result;
|
||||
fstring env;
|
||||
DRIVER_DIRECTORY_CTR ctr;
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
printf("Usage: %s [environment]\n", argv[0]);
|
||||
return NT_STATUS_NOPROBLEMO;
|
||||
}
|
||||
|
||||
/* Initialise RPC connection */
|
||||
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
|
||||
{
|
||||
fprintf (stderr, "Could not initialize spoolss pipe!\n");
|
||||
return NT_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
/* get the arguments need to open the printer handle */
|
||||
if (argc == 2)
|
||||
fstrcpy (env, argv[1]);
|
||||
else
|
||||
fstrcpy (env, "Windows NT x86");
|
||||
|
||||
/* Get the directory. Only use Info level 1 */
|
||||
if ((result = cli_spoolss_getprinterdriverdir (cli, 1, env, &ctr))
|
||||
!= NT_STATUS_NO_PROBLEMO)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
display_printdriverdir_1 (ctr.info1);
|
||||
|
||||
/* cleanup */
|
||||
cli_nt_session_close (cli);
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* List of commands exported by this module */
|
||||
struct cmd_set spoolss_commands[] = {
|
||||
@ -831,7 +891,7 @@ struct cmd_set spoolss_commands[] = {
|
||||
{ "enumdrivers", cmd_spoolss_enum_drivers, "Enumerate installed printer drivers" },
|
||||
{ "getdata", cmd_spoolss_not_implemented, "Get print driver data (*)" },
|
||||
{ "getdriver", cmd_spoolss_getdriver, "Get print driver information" },
|
||||
{ "getdriverdir", cmd_spoolss_not_implemented, "Get print driver upload directory (*)" },
|
||||
{ "getdriverdir", cmd_spoolss_getdriverdir, "Get print driver upload directory" },
|
||||
{ "getprinter", cmd_spoolss_getprinter, "Get printer info" },
|
||||
{ "openprinter", cmd_spoolss_open_printer_ex, "Open printer handle" },
|
||||
{ NULL, NULL, NULL }
|
||||
|
Loading…
x
Reference in New Issue
Block a user