[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha7-1019-g97ffd70
Günther Deschner
gd at samba.org
Mon Apr 13 14:13:48 GMT 2009
The branch, master has been updated
via 97ffd709f85ca0ecd101aac614fea19151394677 (commit)
via 9b3d3e8aebac25c55b2bcfb3daf3ba3d7df9d280 (commit)
via f325c342031d11d6133d417bdf57d918f4f10981 (commit)
via 0393c99302dc12f18f06db83201f096624682ea2 (commit)
from 81aca44d30783d1c162498a257fc47cc44a649fb (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 97ffd709f85ca0ecd101aac614fea19151394677
Author: Günther Deschner <gd at samba.org>
Date: Mon Apr 13 15:42:32 2009 +0200
s3-spoolss: use enumprinterdrivers_level() for level 3 enum.
Guenther
commit 9b3d3e8aebac25c55b2bcfb3daf3ba3d7df9d280
Author: Günther Deschner <gd at samba.org>
Date: Mon Apr 13 15:40:39 2009 +0200
s3-spoolss: use enumprinterdrivers_level() for level 2 enum.
Guenther
commit f325c342031d11d6133d417bdf57d918f4f10981
Author: Günther Deschner <gd at samba.org>
Date: Mon Apr 13 15:31:52 2009 +0200
s3-spoolss: use enumprinterdrivers_level() for level 1 enum.
Guenther
commit 0393c99302dc12f18f06db83201f096624682ea2
Author: Günther Deschner <gd at samba.org>
Date: Mon Apr 13 15:27:55 2009 +0200
s3-spoolss: add generic enumprinterdrivers_level function.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source3/rpc_server/srv_spoolss_nt.c | 197 +++++++++--------------------------
1 files changed, 51 insertions(+), 146 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 718f69f..faa155d 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -6609,14 +6609,15 @@ WERROR _spoolss_SetJob(pipes_struct *p,
}
/****************************************************************************
- Enumerates all printer drivers at level 1.
+ Enumerates all printer drivers by level.
****************************************************************************/
-static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
- const char *servername,
- const char *architecture,
- union spoolss_DriverInfo **info_p,
- uint32_t *count)
+static WERROR enumprinterdrivers_level(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *architecture,
+ uint32_t level,
+ union spoolss_DriverInfo **info_p,
+ uint32_t *count_p)
{
int i;
int ndrivers;
@@ -6624,9 +6625,11 @@ static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
fstring *list = NULL;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
union spoolss_DriverInfo *info = NULL;
+ uint32_t count = 0;
WERROR result = WERR_OK;
- *count = 0;
+ *count_p = 0;
+ *info_p = NULL;
for (version=0; version<DRIVER_MAX_VERSION; version++) {
list = NULL;
@@ -6642,7 +6645,7 @@ static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
if (ndrivers != 0) {
info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
union spoolss_DriverInfo,
- *count + ndrivers);
+ count + ndrivers);
if (!info) {
DEBUG(0,("enumprinterdrivers_level1: "
"failed to enlarge driver info buffer!\n"));
@@ -6659,9 +6662,26 @@ static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
if (!W_ERROR_IS_OK(result)) {
goto out;
}
- result = fill_printer_driver_info1(info, &info[*count+i].info1,
- &driver, servername,
- architecture);
+
+ switch (level) {
+ case 1:
+ result = fill_printer_driver_info1(info, &info[count+i].info1,
+ &driver, servername,
+ architecture);
+ break;
+ case 2:
+ result = fill_printer_driver_info2(info, &info[count+i].info2,
+ &driver, servername);
+ break;
+ case 3:
+ result = fill_printer_driver_info3(info, &info[count+i].info3,
+ &driver, servername);
+ break;
+ default:
+ result = WERR_UNKNOWN_LEVEL;
+ break;
+ }
+
if (!W_ERROR_IS_OK(result)) {
free_a_printer_driver(driver, 3);
goto out;
@@ -6669,7 +6689,7 @@ static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
free_a_printer_driver(driver, 3);
}
- *count += ndrivers;
+ count += ndrivers;
SAFE_FREE(list);
}
@@ -6678,91 +6698,41 @@ static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
if (!W_ERROR_IS_OK(result)) {
TALLOC_FREE(info);
- *count = 0;
return result;
}
*info_p = info;
+ *count_p = count;
return WERR_OK;
}
/****************************************************************************
- Enumerates all printer drivers at level 2.
+ Enumerates all printer drivers at level 1.
****************************************************************************/
-static WERROR enumprinterdrivers_level2(TALLOC_CTX *mem_ctx,
+static WERROR enumprinterdrivers_level1(TALLOC_CTX *mem_ctx,
const char *servername,
const char *architecture,
union spoolss_DriverInfo **info_p,
uint32_t *count)
{
- int i;
- int ndrivers;
- uint32_t version;
- fstring *list = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
- union spoolss_DriverInfo *info = NULL;
- WERROR result = WERR_OK;
-
- *count = 0;
-
- for (version=0; version<DRIVER_MAX_VERSION; version++) {
- list = NULL;
- ndrivers = get_ntdrivers(&list, architecture, version);
- DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n",
- ndrivers, architecture, version));
-
- if (ndrivers == -1) {
- result = WERR_NOMEM;
- goto out;
- }
-
- if (ndrivers != 0) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
- union spoolss_DriverInfo,
- *count + ndrivers);
- if (!info) {
- DEBUG(0,("enumprinterdrivers_level2: "
- "failed to enlarge driver info buffer!\n"));
- result = WERR_NOMEM;
- goto out;
- }
- }
-
- for (i=0; i<ndrivers; i++) {
- DEBUGADD(5,("\tdriver: [%s]\n", list[i]));
- ZERO_STRUCT(driver);
- result = get_a_printer_driver(&driver, 3, list[i],
- architecture, version);
- if (!W_ERROR_IS_OK(result)) {
- goto out;
- }
- result = fill_printer_driver_info2(info, &info[*count+i].info2,
- &driver, servername);
- if (!W_ERROR_IS_OK(result)) {
- free_a_printer_driver(driver, 3);
- goto out;
- }
- free_a_printer_driver(driver, 3);
- }
-
- *count += ndrivers;
- SAFE_FREE(list);
- }
-
- out:
- SAFE_FREE(list);
-
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
- }
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 1,
+ info_p, count);
+}
- *info_p = info;
+/****************************************************************************
+ Enumerates all printer drivers at level 2.
+****************************************************************************/
- return WERR_OK;
+static WERROR enumprinterdrivers_level2(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *architecture,
+ union spoolss_DriverInfo **info_p,
+ uint32_t *count)
+{
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 2,
+ info_p, count);
}
/****************************************************************************
@@ -6775,73 +6745,8 @@ static WERROR enumprinterdrivers_level3(TALLOC_CTX *mem_ctx,
union spoolss_DriverInfo **info_p,
uint32_t *count)
{
- int i;
- int ndrivers;
- uint32_t version;
- fstring *list = NULL;
- union spoolss_DriverInfo *info = NULL;
- NT_PRINTER_DRIVER_INFO_LEVEL driver;
- WERROR result = WERR_OK;
-
- *count = 0;
-
- for (version=0; version<DRIVER_MAX_VERSION; version++) {
- list = NULL;
- ndrivers = get_ntdrivers(&list, architecture, version);
- DEBUGADD(4,("we have:[%d] drivers in environment [%s] and version [%d]\n",
- ndrivers, architecture, version));
-
- if (ndrivers == -1) {
- result = WERR_NOMEM;
- goto out;
- }
-
- if (ndrivers != 0) {
- info = TALLOC_REALLOC_ARRAY(mem_ctx, info,
- union spoolss_DriverInfo,
- *count + ndrivers);
- if (!info) {
- DEBUG(0,("enumprinterdrivers_level3: "
- "failed to enlarge driver info buffer!\n"));
- result = WERR_NOMEM;
- goto out;
- }
- }
-
- for (i=0; i<ndrivers; i++) {
- DEBUGADD(5,("\tdriver: [%s]\n", list[i]));
- ZERO_STRUCT(driver);
- result = get_a_printer_driver(&driver, 3, list[i],
- architecture, version);
- if (!W_ERROR_IS_OK(result)) {
- goto out;
- }
- result = fill_printer_driver_info3(info, &info[*count+i].info3,
- &driver, servername);
- if (!W_ERROR_IS_OK(result)) {
- free_a_printer_driver(driver, 3);
- goto out;
- }
-
- free_a_printer_driver(driver, 3);
- }
-
- *count += ndrivers;
- SAFE_FREE(list);
- }
-
- out:
- SAFE_FREE(list);
-
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
- }
-
- *info_p = info;
-
- return WERR_OK;
+ return enumprinterdrivers_level(mem_ctx, servername, architecture, 3,
+ info_p, count);
}
/****************************************************************
--
Samba Shared Repository
More information about the samba-cvs
mailing list