summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-03-11 01:40:33 +0100
committerGünther Deschner <gd@samba.org>2009-03-13 09:25:19 +0100
commitc6e9dc11e5085baaf7365f72bc06684aeb8d89db (patch)
treebd380b9880dc89220d013304656f16c2bdaed43a
parentfacf66b40c6f8919bd78613990959a4f45a5738c (diff)
downloadsamba-c6e9dc11e5085baaf7365f72bc06684aeb8d89db.tar.gz
samba-c6e9dc11e5085baaf7365f72bc06684aeb8d89db.tar.bz2
samba-c6e9dc11e5085baaf7365f72bc06684aeb8d89db.zip
s3-spoolss: use macros for _spoolss_EnumPorts.
Guenther
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c53
1 files changed, 21 insertions, 32 deletions
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 8c6de1f264..67ee91e108 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -7557,8 +7557,6 @@ WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines )
static WERROR enumports_level_1(TALLOC_CTX *mem_ctx,
union spoolss_PortInfo **info_p,
- uint32_t offered,
- uint32_t *needed,
uint32_t *count)
{
union spoolss_PortInfo *info = NULL;
@@ -7590,17 +7588,6 @@ static WERROR enumports_level_1(TALLOC_CTX *mem_ctx,
}
TALLOC_FREE(qlines);
- /* check the required size. */
- for (i=0; i<numlines; i++) {
- DEBUGADD(6,("adding port [%d]'s size\n", i));
- *needed += ndr_size_spoolss_PortInfo1(&info[i].info1, NULL, 0);
- }
-
- if (*needed > offered) {
- result = WERR_INSUFFICIENT_BUFFER;
- goto out;
- }
-
out:
if (!W_ERROR_IS_OK(result)) {
TALLOC_FREE(info);
@@ -7622,8 +7609,6 @@ out:
static WERROR enumports_level_2(TALLOC_CTX *mem_ctx,
union spoolss_PortInfo **info_p,
- uint32_t offered,
- uint32_t *needed,
uint32_t *count)
{
union spoolss_PortInfo *info = NULL;
@@ -7655,17 +7640,6 @@ static WERROR enumports_level_2(TALLOC_CTX *mem_ctx,
}
TALLOC_FREE(qlines);
- /* check the required size. */
- for (i=0; i<numlines; i++) {
- DEBUGADD(6,("adding port [%d]'s size\n", i));
- *needed += ndr_size_spoolss_PortInfo2(&info[i].info2, NULL, 0);
- }
-
- if (*needed > offered) {
- result = WERR_INSUFFICIENT_BUFFER;
- goto out;
- }
-
out:
if (!W_ERROR_IS_OK(result)) {
TALLOC_FREE(info);
@@ -7688,6 +7662,8 @@ out:
WERROR _spoolss_EnumPorts(pipes_struct *p,
struct spoolss_EnumPorts *r)
{
+ WERROR result;
+
/* that's an [in out] buffer */
if (!r->in.buffer && (r->in.offered != 0)) {
@@ -7702,16 +7678,29 @@ WERROR _spoolss_EnumPorts(pipes_struct *p,
switch (r->in.level) {
case 1:
- return enumports_level_1(p->mem_ctx, r->out.info,
- r->in.offered, r->out.needed,
- r->out.count);
+ result = enumports_level_1(p->mem_ctx, r->out.info,
+ r->out.count);
+ break;
case 2:
- return enumports_level_2(p->mem_ctx, r->out.info,
- r->in.offered, r->out.needed,
- r->out.count);
+ result = enumports_level_2(p->mem_ctx, r->out.info,
+ r->out.count);
+ break;
default:
return WERR_UNKNOWN_LEVEL;
}
+
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ *r->out.needed = SPOOLSS_BUFFER_UNION_ARRAY(p->mem_ctx,
+ spoolss_EnumPorts, NULL,
+ *r->out.info, r->in.level,
+ *r->out.count);
+ *r->out.info = SPOOLSS_BUFFER_OK(*r->out.info, NULL);
+ *r->out.count = SPOOLSS_BUFFER_OK(*r->out.count, 0);
+
+ return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
}
/****************************************************************************