From 6336366abb53436c6800263cc0da26faa13c038c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 10:55:41 +0100 Subject: s3-rpcclient: use new rpccli_spoolss_enumforms wrapper. Guenther --- source3/rpcclient/cmd_spoolss.c | 49 ++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 28 deletions(-) (limited to 'source3/rpcclient/cmd_spoolss.c') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 5b55ac3e2a..c88cf89367 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1977,27 +1977,6 @@ static const char *get_form_flag(int form_flag) /**************************************************************************** ****************************************************************************/ -static void display_form(FORM_1 *form) -{ - fstring form_name = ""; - - if (form->name.buffer) - rpcstr_pull(form_name, form->name.buffer, - sizeof(form_name), -1, STR_TERMINATE); - - printf("%s\n" \ - "\tflag: %s (%d)\n" \ - "\twidth: %d, length: %d\n" \ - "\tleft: %d, right: %d, top: %d, bottom: %d\n\n", - form_name, get_form_flag(form->flag), form->flag, - form->width, form->length, - form->left, form->right, - form->top, form->bottom); -} - -/**************************************************************************** -****************************************************************************/ - static void display_form_info1(struct spoolss_FormInfo1 *r) { printf("%s\n" \ @@ -2173,12 +2152,12 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli, WERROR werror; const char *printername; uint32 num_forms, level = 1, i; - FORM_1 *forms; + union spoolss_FormInfo *forms; /* Parse the command arguments */ - if (argc != 2) { - printf ("Usage: %s \n", argv[0]); + if (argc < 2 || argc > 4) { + printf ("Usage: %s [level]\n", argv[0]); return WERR_OK; } @@ -2193,9 +2172,18 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli, if (!W_ERROR_IS_OK(werror)) goto done; + if (argc == 3) { + level = atoi(argv[2]); + } + /* Enumerate forms */ - werror = rpccli_spoolss_enumforms(cli, mem_ctx, &handle, level, &num_forms, &forms); + werror = rpccli_spoolss_enumforms(cli, mem_ctx, + &handle, + level, + 0, + &num_forms, + &forms); if (!W_ERROR_IS_OK(werror)) goto done; @@ -2203,9 +2191,14 @@ static WERROR cmd_spoolss_enum_forms(struct rpc_pipe_client *cli, /* Display output */ for (i = 0; i < num_forms; i++) { - - display_form(&forms[i]); - + switch (level) { + case 1: + display_form_info1(&forms[i].info1); + break; + case 2: + display_form_info2(&forms[i].info2); + break; + } } done: -- cgit From 4541aa5f846bc7b38e2873d65b5b6a5614a037b4 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 12:01:54 +0100 Subject: s3-spoolss: use form flags from idl in rpcclient and net. Guenther --- source3/rpcclient/cmd_spoolss.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source3/rpcclient/cmd_spoolss.c') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index c88cf89367..fae5c552c2 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1848,7 +1848,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c switch (level) { case 1: - info1.flags = FORM_USER; + info1.flags = SPOOLSS_FORM_USER; info1.form_name = argv[2]; info1.size.width = 100; info1.size.height = 100; @@ -1861,7 +1861,7 @@ static WERROR cmd_spoolss_addform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c break; case 2: - info2.flags = FORM_USER; + info2.flags = SPOOLSS_FORM_USER; info2.form_name = argv[2]; info2.size.width = 100; info2.size.height = 100; @@ -1930,7 +1930,7 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c /* Dummy up some values for the form data */ - info1.flags = FORM_PRINTER; + info1.flags = SPOOLSS_FORM_PRINTER; info1.size.width = 100; info1.size.height = 100; info1.area.left = 0; @@ -1963,11 +1963,11 @@ static WERROR cmd_spoolss_setform(struct rpc_pipe_client *cli, TALLOC_CTX *mem_c static const char *get_form_flag(int form_flag) { switch (form_flag) { - case FORM_USER: + case SPOOLSS_FORM_USER: return "FORM_USER"; - case FORM_BUILTIN: + case SPOOLSS_FORM_BUILTIN: return "FORM_BUILTIN"; - case FORM_PRINTER: + case SPOOLSS_FORM_PRINTER: return "FORM_PRINTER"; default: return "unknown"; -- cgit From a58e59fc6ed0ee91c8761cbda62c34e35e6dd153 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 22:11:09 +0100 Subject: s3-rpcclient: add enumprocs command to enumerate print processors. Guenther --- source3/rpcclient/cmd_spoolss.c | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'source3/rpcclient/cmd_spoolss.c') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index fae5c552c2..03d506e083 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3057,6 +3057,61 @@ done: return WERR_OK; } +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; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { @@ -3092,6 +3147,7 @@ struct cmd_set spoolss_commands[] = { { "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", "" }, + { "enumprocs", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_procs, &syntax_spoolss, NULL, "Enumerate Print Processors", "" }, { NULL } }; -- cgit From 62d73b8854b5a0a900c9abb3a60a2b089579886e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Mar 2009 00:55:15 +0100 Subject: s3-rpcclient: add enumprocdatatypes command to enumerate print processor data types. Guenther --- source3/rpcclient/cmd_spoolss.c | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'source3/rpcclient/cmd_spoolss.c') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 03d506e083..01e61b9a8c 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3112,6 +3112,61 @@ static WERROR cmd_spoolss_enum_procs(struct rpc_pipe_client *cli, return werror; } +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; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { @@ -3148,6 +3203,7 @@ struct cmd_set spoolss_commands[] = { { "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", "" }, { "enumprocs", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_procs, &syntax_spoolss, NULL, "Enumerate Print Processors", "" }, + { "enumprocdatatypes", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_proc_data_types, &syntax_spoolss, NULL, "Enumerate Print Processor Data Types", "" }, { NULL } }; -- cgit From e9179a6850a99d9d6ec25eba86ec02c9c1279850 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 6 Mar 2009 23:36:31 +0100 Subject: s3-rpcclient: use rpccli_spoolss_enumports wrapper. Guenther --- source3/rpcclient/cmd_spoolss.c | 50 +++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 29 deletions(-) (limited to 'source3/rpcclient/cmd_spoolss.c') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 01e61b9a8c..03d88f743c 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -359,55 +359,45 @@ static WERROR cmd_spoolss_enum_printers(struct rpc_pipe_client *cli, /**************************************************************************** ****************************************************************************/ -static void display_port_info_1(PORT_INFO_1 *i1) +static void display_port_info_1(struct spoolss_PortInfo1 *r) { - fstring buffer; - - rpcstr_pull(buffer, i1->port_name.buffer, sizeof(buffer), -1, STR_TERMINATE); - printf("\tPort Name:\t[%s]\n", buffer); + printf("\tPort Name:\t[%s]\n", r->port_name); } /**************************************************************************** ****************************************************************************/ -static void display_port_info_2(PORT_INFO_2 *i2) +static void display_port_info_2(struct spoolss_PortInfo2 *r) { - fstring buffer; - - rpcstr_pull(buffer, i2->port_name.buffer, sizeof(buffer), -1, STR_TERMINATE); - printf("\tPort Name:\t[%s]\n", buffer); - rpcstr_pull(buffer, i2->monitor_name.buffer, sizeof(buffer), -1, STR_TERMINATE); - - printf("\tMonitor Name:\t[%s]\n", buffer); - rpcstr_pull(buffer, i2->description.buffer, sizeof(buffer), -1, STR_TERMINATE); - - printf("\tDescription:\t[%s]\n", buffer); + printf("\tPort Name:\t[%s]\n", r->port_name); + printf("\tMonitor Name:\t[%s]\n", r->monitor_name); + printf("\tDescription:\t[%s]\n", r->description); printf("\tPort Type:\t" ); - if ( i2->port_type ) { + if (r->port_type) { int comma = 0; /* hack */ printf( "[" ); - if ( i2->port_type & PORT_TYPE_READ ) { + if (r->port_type & SPOOLSS_PORT_TYPE_READ) { printf( "Read" ); comma = 1; } - if ( i2->port_type & PORT_TYPE_WRITE ) { + if (r->port_type & SPOOLSS_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 ) { + if (r->port_type & SPOOLSS_PORT_TYPE_REDIRECTED) { printf( "%sRedirected", comma ? ", " : "" ); comma = 1; } - if ( i2->port_type & PORT_TYPE_NET_ATTACHED ) { + if (r->port_type & SPOOLSS_PORT_TYPE_NET_ATTACHED) { printf( "%sNet-Attached", comma ? ", " : "" ); } printf( "]\n" ); } else { printf( "[Unset]\n" ); } - printf("\tReserved:\t[%d]\n", i2->reserved); + printf("\tReserved:\t[%d]\n", r->reserved); printf("\n"); } @@ -420,8 +410,8 @@ static WERROR cmd_spoolss_enum_ports(struct rpc_pipe_client *cli, { WERROR result; uint32 info_level = 1; - PORT_INFO_CTR ctr; uint32 returned; + union spoolss_PortInfo *info; if (argc > 2) { printf("Usage: %s [level]\n", argv[0]); @@ -433,20 +423,22 @@ static WERROR cmd_spoolss_enum_ports(struct rpc_pipe_client *cli, /* Enumerate ports */ - ZERO_STRUCT(ctr); - - result = rpccli_spoolss_enum_ports(cli, mem_ctx, info_level, &returned, &ctr); - + result = rpccli_spoolss_enumports(cli, mem_ctx, + cli->srv_name_slash, + info_level, + 0, + &returned, + &info); if (W_ERROR_IS_OK(result)) { int i; for (i = 0; i < returned; i++) { switch (info_level) { case 1: - display_port_info_1(&ctr.port.info_1[i]); + display_port_info_1(&info[i].info1); break; case 2: - display_port_info_2(&ctr.port.info_2[i]); + display_port_info_2(&info[i].info2); break; default: printf("unknown info level %d\n", info_level); -- cgit From d75d3502875f35cfabb9a41528f43f2fd129527c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Sat, 7 Mar 2009 00:16:10 +0100 Subject: s3-rpcclient: add enummonitors command to enumerate print monitors. Guenther --- source3/rpcclient/cmd_spoolss.c | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'source3/rpcclient/cmd_spoolss.c') diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 03d88f743c..6cbdf89583 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3159,6 +3159,66 @@ static WERROR cmd_spoolss_enum_proc_data_types(struct rpc_pipe_client *cli, return werror; } +static void display_monitor1(const struct spoolss_MonitorInfo1 *r) +{ + printf("monitor_name: %s\n", r->monitor_name); +} + +static void display_monitor2(const struct spoolss_MonitorInfo2 *r) +{ + printf("monitor_name: %s\n", r->monitor_name); + printf("environment: %s\n", r->environment); + printf("dll_name: %s\n", r->dll_name); +} + +static WERROR cmd_spoolss_enum_monitors(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + WERROR werror; + uint32_t count, level = 1, i; + union spoolss_MonitorInfo *info; + + /* Parse the command arguments */ + + if (argc > 2) { + printf("Usage: %s [level]\n", argv[0]); + return WERR_OK; + } + + if (argc == 2) { + level = atoi(argv[1]); + } + + /* Enumerate Print Monitors */ + + werror = rpccli_spoolss_enummonitors(cli, mem_ctx, + cli->srv_name_slash, + level, + 0, + &count, + &info); + if (!W_ERROR_IS_OK(werror)) { + goto done; + } + + /* Display output */ + + for (i = 0; i < count; i++) { + switch (level) { + case 1: + display_monitor1(&info[i].info1); + break; + case 2: + display_monitor2(&info[i].info2); + break; + } + } + + done: + return werror; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { @@ -3196,6 +3256,7 @@ struct cmd_set spoolss_commands[] = { { "printercmp", RPC_RTYPE_WERROR, NULL, cmd_spoolss_printercmp, &syntax_spoolss, NULL, "Printer comparison test", "" }, { "enumprocs", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_procs, &syntax_spoolss, NULL, "Enumerate Print Processors", "" }, { "enumprocdatatypes", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_proc_data_types, &syntax_spoolss, NULL, "Enumerate Print Processor Data Types", "" }, + { "enummonitors", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_monitors, &syntax_spoolss, NULL, "Enumerate Print Monitors", "" }, { NULL } }; -- cgit