summaryrefslogtreecommitdiff
path: root/source4/rpc_server/spoolss
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2004-06-26 13:28:30 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:56:46 -0500
commit27f245a2199f2ce8d007810992d13b3a2c7560fa (patch)
tree76e0d8a76430d19e54af2b56dfa41936a75607c2 /source4/rpc_server/spoolss
parentcbf6caa7167c4ed1f28c1026a6fe419d3d0ecb51 (diff)
downloadsamba-27f245a2199f2ce8d007810992d13b3a2c7560fa.tar.gz
samba-27f245a2199f2ce8d007810992d13b3a2c7560fa.tar.bz2
samba-27f245a2199f2ce8d007810992d13b3a2c7560fa.zip
r1266: Start to split out EnumPrinters into a separate fn for each info level.
(This used to be commit 6b24ee38646f3476eaf8eda946488b46180038e2)
Diffstat (limited to 'source4/rpc_server/spoolss')
-rw-r--r--source4/rpc_server/spoolss/dcesrv_spoolss.c64
1 files changed, 44 insertions, 20 deletions
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c
index 7efe9b2129..0916ddf081 100644
--- a/source4/rpc_server/spoolss/dcesrv_spoolss.c
+++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c
@@ -25,15 +25,10 @@
#include "rpc_server/spoolss/dcesrv_spoolss.h"
-/*
- spoolss_EnumPrinters
-*/
-static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
- struct spoolss_EnumPrinters *r)
+static WERROR spoolss_EnumPrinters1(TALLOC_CTX *mem_ctx, void *spoolss_ctx,
+ struct ndr_push *ndr, uint32_t *count)
{
- struct ndr_push *buf;
struct spoolss_PrinterInfo1 info[2];
- WERROR result;
info[0].flags = 0x80;
info[0].name = "p";
@@ -45,14 +40,46 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
info[1].description = "spottyfoot";
info[1].comment = "the doggy";
- buf = ndr_push_init();
-
- ndr_push_array(buf, NDR_SCALARS|NDR_BUFFERS, info,
+ ndr_push_array(ndr, NDR_SCALARS|NDR_BUFFERS, info,
sizeof(struct spoolss_PrinterInfo1), 2,
- (ndr_push_const_fn_t)ndr_push_spoolss_PrinterInfo1);
+ (ndr_push_flags_fn_t)ndr_push_spoolss_PrinterInfo1);
+
+ *count = 2;
- if (*r->in.buf_size < buf->offset) {
- *r->out.buf_size = buf->offset;
+ return WERR_OK;
+}
+
+/*
+ spoolss_EnumPrinters
+*/
+static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
+ struct spoolss_EnumPrinters *r)
+{
+ struct ndr_push *ndr;
+ void *spoolss_ctx;
+ WERROR result;
+
+ spoolss_ctx = spoolssdb_connect();
+ if (spoolss_ctx == NULL)
+ return WERR_NOMEM;
+
+ ndr = ndr_push_init();
+
+ switch(r->in.level) {
+ case 1:
+ result = spoolss_EnumPrinters1(
+ mem_ctx, spoolss_ctx, ndr, &r->out.count);
+ break;
+ default:
+ r->out.buffer = NULL;
+ *r->out.buf_size = 0;
+ r->out.count = 0;
+ result = WERR_INVALID_PARAM;
+ goto done;
+ }
+
+ if (*r->in.buf_size < ndr->offset) {
+ *r->out.buf_size = ndr->offset;
result = WERR_INSUFFICIENT_BUFFER;
goto done;
}
@@ -64,15 +91,12 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT
goto done;
}
- *r->out.buffer = data_blob_talloc(mem_ctx, buf->data, buf->offset);
-
- r->out.count = 2;
- *r->out.buf_size = buf->offset;
-
- result = WERR_OK;
+ *r->out.buffer = data_blob_talloc(mem_ctx, ndr->data, ndr->offset);
+ *r->out.buf_size = ndr->offset;
done:
- ndr_push_free(buf);
+ ndr_push_free(ndr);
+ spoolssdb_close(spoolss_ctx);
return result;
}