summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2001-03-15 16:43:19 +0000
committerGerald Carter <jerry@samba.org>2001-03-15 16:43:19 +0000
commit729b7cf214a8eeb36cef9ff86cfbc1a03fcf0d51 (patch)
tree49c7fd4001069754e20ec715b610efc6834b347c /source3
parentf758474f32bd0c3f840d85eedb6a5024da4f1507 (diff)
downloadsamba-729b7cf214a8eeb36cef9ff86cfbc1a03fcf0d51.tar.gz
samba-729b7cf214a8eeb36cef9ff86cfbc1a03fcf0d51.tar.bz2
samba-729b7cf214a8eeb36cef9ff86cfbc1a03fcf0d51.zip
added getdriverdir and cleaned up the PRINTER_DRIVER_CTR struct
(This used to be commit 5d321673850e1e28e1bee4093705d7e319421687)
Diffstat (limited to 'source3')
-rwxr-xr-xsource3/include/rpc_spoolss.h6
-rw-r--r--source3/libsmb/cli_spoolss.c96
-rw-r--r--source3/rpcclient/cmd_spoolss.c62
3 files changed, 156 insertions, 8 deletions
diff --git a/source3/include/rpc_spoolss.h b/source3/include/rpc_spoolss.h
index 798b32bb7e..1e0a43987c 100755
--- a/source3/include/rpc_spoolss.h
+++ b/source3/include/rpc_spoolss.h
@@ -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;
diff --git a/source3/libsmb/cli_spoolss.c b/source3/libsmb/cli_spoolss.c
index c0ec4d0d9c..55eb4dc4b2 100644
--- a/source3/libsmb/cli_spoolss.c
+++ b/source3/libsmb/cli_spoolss.c
@@ -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;
+}
+
+
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 0c101056f5..b1160f1822 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -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 }