[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-1471-gb8ddb87

Günther Deschner gd at samba.org
Thu May 7 11:36:02 GMT 2009


The branch, master has been updated
       via  b8ddb8765c6421b595737dac8deaeb88546a847a (commit)
      from  8e490d2fa1c52be5da331df0b314508f77ec1f6e (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b8ddb8765c6421b595737dac8deaeb88546a847a
Author: Günther Deschner <gd at samba.org>
Date:   Thu May 7 13:35:00 2009 +0200

    s3-rpcclient: rework enumdrivers call a bit to allow queries like win7 does.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source3/rpcclient/cmd_spoolss.c |  166 +++++++++++++++++++++++----------------
 1 files changed, 97 insertions(+), 69 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index d4234b0..124913e 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;
 		}
 	}
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list