diff options
author | Luke Leighton <lkcl@samba.org> | 1999-11-06 20:36:07 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1999-11-06 20:36:07 +0000 |
commit | 4dbd1c135ca286f59a5f692abd51a0c78f4cb6a0 (patch) | |
tree | 1827e581147bf7cbde9ded3ba1dc01861d49de43 /source3/rpcclient | |
parent | 0f18ca772da544a93799ca130a8f23529aad98f6 (diff) | |
download | samba-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)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 14 | ||||
-rw-r--r-- | source3/rpcclient/display.c | 194 |
2 files changed, 203 insertions, 5 deletions
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 /**************************************************************************** |