summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-06 20:36:07 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-06 20:36:07 +0000
commit4dbd1c135ca286f59a5f692abd51a0c78f4cb6a0 (patch)
tree1827e581147bf7cbde9ded3ba1dc01861d49de43
parent0f18ca772da544a93799ca130a8f23529aad98f6 (diff)
downloadsamba-4dbd1c135ca286f59a5f692abd51a0c78f4cb6a0.tar.gz
samba-4dbd1c135ca286f59a5f692abd51a0c78f4cb6a0.tar.bz2
samba-4dbd1c135ca286f59a5f692abd51a0c78f4cb6a0.zip
fixed string function for reading in printer_info_N.
(This used to be commit 0249ae50ad8135cf3fd11a3b85f771f2347fcb29)
-rw-r--r--source3/include/proto.h10
-rw-r--r--source3/rpc_parse/parse_spoolss.c37
-rw-r--r--source3/rpcclient/cmd_spoolss.c14
-rw-r--r--source3/rpcclient/display.c194
4 files changed, 240 insertions, 15 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 1bd5d131b5..d56fbf6fa6 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3587,6 +3587,16 @@ void display_sam_unk_info_2(FILE *out_hnd, enum action_type action,
SAM_UNK_INFO_2 *info2);
void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
uint32 switch_value, SAM_UNK_CTR *ctr);
+void display_print_info_0(FILE *out_hnd, enum action_type action,
+ PRINTER_INFO_0 *i0);
+void display_print_info_1(FILE *out_hnd, enum action_type action,
+ PRINTER_INFO_1 *i1);
+void display_printer_info_0_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, PRINTER_INFO_0 **ctr);
+void display_printer_info_1_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, PRINTER_INFO_1 **ctr);
+void display_printer_info_ctr(FILE *out_hnd, enum action_type action,
+ uint32 level, uint32 count, void **ctr);
/*The following definitions come from rpcclient/rpcclient.c */
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 59fbd6ac23..c7d3d894d1 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -956,19 +956,36 @@ static BOOL spoolss_smb_io_unistr(char *desc, UNISTR *uni, prs_struct *ps, int
static BOOL smb_io_relstr(char *desc, prs_struct *ps, int depth, UNISTR *buffer,
uint32 *start_offset, uint32 *end_offset)
{
- uint32 struct_offset;
- uint32 relative_offset;
-
- struct_offset=ps->offset;
- *end_offset-= 2*(str_len_uni(buffer)+1);
- ps->offset=*end_offset;
- spoolss_smb_io_unistr(desc, buffer, ps, depth);
+ if (!ps->io)
+ {
+ uint32 struct_offset = ps->offset;
+ uint32 relative_offset;
+
+ /* writing */
+ *end_offset -= 2*(str_len_uni(buffer)+1);
+ ps->offset=*end_offset;
+ spoolss_smb_io_unistr(desc, buffer, ps, depth);
- ps->offset=struct_offset;
- relative_offset=*end_offset-*start_offset;
+ ps->offset=struct_offset;
+ relative_offset=*end_offset-*start_offset;
- prs_uint32("offset", ps, depth, &(relative_offset));
+ prs_uint32("offset", ps, depth, &(relative_offset));
+ }
+ else
+ {
+ uint32 old_offset;
+ uint32 relative_offset;
+
+ prs_uint32("offset", ps, depth, &(relative_offset));
+
+ old_offset = ps->offset;
+ ps->offset = (*start_offset) + relative_offset;
+ spoolss_smb_io_unistr(desc, buffer, ps, depth);
+
+ *end_offset = ps->offset;
+ ps->offset = old_offset;
+ }
return True;
}
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 8966eb45c2..257f32aa8b 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -44,8 +44,9 @@ void cmd_spoolss_enum_printers(struct client_info *info)
{
uint16 nt_pipe_fnum;
fstring srv_name;
- void **printers = NULL;
- uint32 count = 0;
+ void **ctr = NULL;
+ uint32 num = 0;
+ uint32 level = 1;
BOOL res = True;
@@ -59,7 +60,7 @@ void cmd_spoolss_enum_printers(struct client_info *info)
res = res ? cli_nt_session_open(smb_cli, PIPE_SPOOLSS, &nt_pipe_fnum) : False;
res = res ? spoolss_enum_printers(smb_cli, nt_pipe_fnum,
- 0x40, srv_name, 1, &count, &printers) : False;
+ 0x40, srv_name, level, &num, &ctr) : False;
/* close the session */
cli_nt_session_close(smb_cli, nt_pipe_fnum);
@@ -67,14 +68,17 @@ void cmd_spoolss_enum_printers(struct client_info *info)
if (res)
{
DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n"));
- report(out_hnd, "OK\n");
+ display_printer_info_ctr(out_hnd, ACTION_HEADER , level, num, ctr);
+ display_printer_info_ctr(out_hnd, ACTION_ENUMERATE, level, num, ctr);
+ display_printer_info_ctr(out_hnd, ACTION_FOOTER , level, num, ctr);
}
else
{
DEBUG(5,("cmd_spoolss_enum_printer: query failed\n"));
+ report(out_hnd, "FAILED\n");
}
- free_void_array(count, printers, free);
+ free_void_array(num, ctr, free);
}
/****************************************************************************
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
index 74d75776b4..3f3f9488a4 100644
--- a/source3/rpcclient/display.c
+++ b/source3/rpcclient/display.c
@@ -2525,6 +2525,200 @@ void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
}
}
+/****************************************************************************
+printer info level 0 display function
+****************************************************************************/
+void display_print_info_0(FILE *out_hnd, enum action_type action,
+ PRINTER_INFO_0 *i0)
+{
+ if (i0 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ fprintf(out_hnd, "Printer Info Level 0:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring name;
+ fstring serv;
+
+ unistr_to_ascii(name, i0->printername.buffer, sizeof(name)-1);
+ unistr_to_ascii(serv, i0->servername .buffer, sizeof(serv)-1);
+
+ fprintf(out_hnd, "\tprinter name:\t%s\n", name);
+ fprintf(out_hnd, "\tserver name:\t%s\n", serv);
+ fprintf(out_hnd, "\t[Other info not displayed]\n");
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ fprintf(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+printer info level 1 display function
+****************************************************************************/
+void display_print_info_1(FILE *out_hnd, enum action_type action,
+ PRINTER_INFO_1 *i1)
+{
+ if (i1 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ fprintf(out_hnd, "Printer Info Level 1:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring desc;
+ fstring name;
+ fstring comm;
+
+ unistr_to_ascii(desc, i1->description.buffer, sizeof(desc)-1);
+ unistr_to_ascii(name, i1->name .buffer, sizeof(name)-1);
+ unistr_to_ascii(comm, i1->comment .buffer, sizeof(comm)-1);
+
+ fprintf(out_hnd, "\tflags:\t%d\n", i1->flags);
+ fprintf(out_hnd, "\tname:\t%s\n", name);
+ fprintf(out_hnd, "\tdescription:\t%s\n", desc);
+ fprintf(out_hnd, "\tcomment:\t%s\n", comm);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ fprintf(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+connection info level 0 container display function
+****************************************************************************/
+void display_printer_info_0_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, PRINTER_INFO_0 **ctr)
+{
+ if (ctr == NULL)
+ {
+ fprintf(out_hnd, "display_printer_info_0_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ display_print_info_0(out_hnd, ACTION_HEADER , ctr[i]);
+ display_print_info_0(out_hnd, ACTION_ENUMERATE, ctr[i]);
+ display_print_info_0(out_hnd, ACTION_FOOTER , ctr[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info level 1 container display function
+****************************************************************************/
+void display_printer_info_1_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, PRINTER_INFO_1 **ctr)
+{
+ if (ctr == NULL)
+ {
+ fprintf(out_hnd, "display_printer_info_1_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ display_print_info_1(out_hnd, ACTION_HEADER , ctr[i]);
+ display_print_info_1(out_hnd, ACTION_ENUMERATE, ctr[i]);
+ display_print_info_1(out_hnd, ACTION_FOOTER , ctr[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info container display function
+****************************************************************************/
+void display_printer_info_ctr(FILE *out_hnd, enum action_type action,
+ uint32 level, uint32 count, void **ctr)
+{
+ if (ctr == NULL)
+ {
+ fprintf(out_hnd, "display_printer_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (level)
+ {
+ case 0:
+ {
+ display_printer_info_0_ctr(out_hnd, action,
+ count, (PRINTER_INFO_0**)ctr);
+ break;
+ }
+ case 1:
+ {
+ display_printer_info_1_ctr(out_hnd, action,
+ count, (PRINTER_INFO_1**)ctr);
+ break;
+ }
+ default:
+ {
+ fprintf(out_hnd, "display_printer_info_ctr: Unknown Info Level\n");
+ break;
+ }
+ }
+}
#if COPY_THIS_TEMPLATE
/****************************************************************************