diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-11-17 02:18:11 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-11-17 02:18:11 +0000 |
commit | 657b4d2abdad5691fc37bafe819f75cc440354b9 (patch) | |
tree | a66c51ef8e39efa62e5b7a5f9e2e227bd3138935 /source4/torture | |
parent | cc5f231e95b2a322a1f1f118b8a3a363a0e4d0cc (diff) | |
download | samba-657b4d2abdad5691fc37bafe819f75cc440354b9.tar.gz samba-657b4d2abdad5691fc37bafe819f75cc440354b9.tar.bz2 samba-657b4d2abdad5691fc37bafe819f75cc440354b9.zip |
nicer method of handling spoolss EnumPrinters
this also handles the return of several printers (an array of relative
subcontexts)
(This used to be commit 060421c7dc9aa611fe4160843a4f76498ab16bf4)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/rpc/spoolss.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index e7e35659d7..d203be2d47 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -30,14 +30,16 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { - uint32 needed = 0; - + uint32 buf_size = 0; + union spoolss_PrinterEnum *info; + int j; + r.in.flags = 0x02; r.in.server = ""; r.in.level = levels[i]; - r.in.buf = NULL; - r.in.offered = needed; - r.out.needed = &needed; + r.in.buffer = NULL; + r.in.buf_size = &buf_size; + r.out.buf_size = &buf_size; printf("\nTesting EnumPrinters level %u\n", r.in.level); @@ -48,14 +50,10 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) continue; } - if (NT_STATUS_V(status) == 0x0000007a) { - r.in.buf = talloc(mem_ctx, needed); - if (!r.in.buf) { - ret = False; - continue; - } - memset(r.in.buf, 0xfe, needed); - r.in.offered = needed; + if (NT_STATUS_V(status) == ERRinsufficientbuffer) { + DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, buf_size); + data_blob_clear(&blob); + r.in.buffer = &blob; status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r); } @@ -63,8 +61,14 @@ static BOOL test_EnumPrinters(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) printf("EnumPrinters failed - %s\n", nt_errstr(status)); } - if (r.out.info) { - NDR_PRINT_UNION_DEBUG(spoolss_PrinterEnum, r.in.level, r.out.info); + status = pull_spoolss_PrinterEnumArray(r.out.buffer, mem_ctx, r.in.level, r.out.count, &info); + if (!NT_STATUS_IS_OK(status)) { + printf("EnumPrintersArray parse failed - %s\n", nt_errstr(status)); + } + + for (j=0;j<r.out.count;j++) { + printf("Printer %d\n", j); + NDR_PRINT_UNION_DEBUG(spoolss_PrinterEnum, r.in.level, &info[j]); } } |