diff options
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 166 |
1 files changed, 97 insertions, 69 deletions
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index d4234b0be6..124913edb2 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -1277,24 +1277,113 @@ static WERROR cmd_spoolss_getdriver(struct rpc_pipe_client *cli, /**************************************************************************** ****************************************************************************/ +static WERROR enum_driver_by_architecture(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *architecture, + uint32_t level) +{ + WERROR werror; + uint32_t count = 0; + union spoolss_DriverInfo *info = NULL; + uint32_t j; + + werror = rpccli_spoolss_enumprinterdrivers(cli, mem_ctx, + cli->srv_name_slash, + architecture, + level, + 0, + &count, + &info); + + if (W_ERROR_EQUAL(werror, WERR_INVALID_ENVIRONMENT)) { + printf("Server does not support environment [%s]\n", + architecture); + return WERR_OK; + } + + if (count == 0) { + return WERR_OK; + } + + if (!W_ERROR_IS_OK(werror)) { + printf("Error getting driver for environment [%s] - %s\n", + architecture, win_errstr(werror)); + return werror; + } + + printf("\n[%s]\n", architecture); + + switch (level) { + case 1: + for (j=0; j < count; j++) { + display_print_driver1(&info[j].info1); + } + break; + case 2: + for (j=0; j < count; j++) { + display_print_driver2(&info[j].info2); + } + break; + case 3: + for (j=0; j < count; j++) { + display_print_driver3(&info[j].info3); + } + break; + case 4: + for (j=0; j < count; j++) { + display_print_driver4(&info[j].info4); + } + break; + case 5: + for (j=0; j < count; j++) { + display_print_driver5(&info[j].info5); + } + break; + case 6: + for (j=0; j < count; j++) { + display_print_driver6(&info[j].info6); + } + break; + case 8: + for (j=0; j < count; j++) { + display_print_driver8(&info[j].info8); + } + break; + default: + printf("unknown info level %d\n", level); + return WERR_UNKNOWN_LEVEL; + } + + return werror; +} + static WERROR cmd_spoolss_enum_drivers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv) { WERROR werror = WERR_OK; uint32_t level = 1; - union spoolss_DriverInfo *info; - uint32_t i, j, count; + uint32_t i; + const char *architecture = NULL; - if (argc > 2) { - printf("Usage: enumdrivers [level]\n"); + if (argc > 3) { + printf("Usage: enumdrivers [level] [architecture]\n"); return WERR_OK; } - if (argc == 2) { + if (argc >= 2) { level = atoi(argv[1]); } + if (argc == 3) { + architecture = argv[2]; + } + + if (architecture) { + return enum_driver_by_architecture(cli, mem_ctx, + architecture, + level); + } /* loop through and print driver info level for each architecture */ for (i=0; archi_table[i].long_archi!=NULL; i++) { @@ -1304,72 +1393,11 @@ static WERROR cmd_spoolss_enum_drivers(struct rpc_pipe_client *cli, continue; } - werror = rpccli_spoolss_enumprinterdrivers(cli, mem_ctx, - cli->srv_name_slash, - archi_table[i].long_archi, - level, - 0, - &count, - &info); - - if (W_ERROR_V(werror) == W_ERROR_V(WERR_INVALID_ENVIRONMENT)) { - printf("Server does not support environment [%s]\n", - archi_table[i].long_archi); - werror = WERR_OK; - continue; - } - - if (count == 0) { - continue; - } - + werror = enum_driver_by_architecture(cli, mem_ctx, + archi_table[i].long_archi, + level); if (!W_ERROR_IS_OK(werror)) { - printf("Error getting driver for environment [%s] - %d\n", - archi_table[i].long_archi, W_ERROR_V(werror)); - continue; - } - - printf("\n[%s]\n", archi_table[i].long_archi); - - switch (level) { - case 1: - for (j=0; j < count; j++) { - display_print_driver1(&info[j].info1); - } - break; - case 2: - for (j=0; j < count; j++) { - display_print_driver2(&info[j].info2); - } break; - case 3: - for (j=0; j < count; j++) { - display_print_driver3(&info[j].info3); - } - break; - case 4: - for (j=0; j < count; j++) { - display_print_driver4(&info[j].info4); - } - break; - case 5: - for (j=0; j < count; j++) { - display_print_driver5(&info[j].info5); - } - break; - case 6: - for (j=0; j < count; j++) { - display_print_driver6(&info[j].info6); - } - break; - case 8: - for (j=0; j < count; j++) { - display_print_driver8(&info[j].info8); - } - break; - default: - printf("unknown info level %d\n", level); - return WERR_UNKNOWN_LEVEL; } } |