From 77c571986414afd070ba629f41317e011e52349b Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 20 Jun 2004 11:34:26 +0000 Subject: r1208: Return some dummy printer information for the EnumPrinters RPC. rpcclient enumprinters prints this information OK. Some minor cut&paste cleanups. (This used to be commit 1c749a3a348a2df477808d4fcc5377832bffa5e9) --- source4/rpc_server/spoolss/dcesrv_spoolss.c | 57 ++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 6 deletions(-) (limited to 'source4/rpc_server') diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c index cb001c168a..dbf3d4cb89 100644 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.c +++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c @@ -31,19 +31,64 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_EnumPrinters *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + struct ndr_push *buf; + struct spoolss_PrinterInfo1 info; + WERROR result; + + info.flags = 0; + info.name = "p"; + info.description = "a printer"; + info.comment = "a comment"; + + buf = ndr_push_init(); + + ndr_push_spoolss_PrinterInfo1(buf, NDR_SCALARS|NDR_BUFFERS, &info); + + if (*r->in.buf_size < buf->offset) { + *r->out.buf_size = buf->offset; + result = WERR_INSUFFICIENT_BUFFER; + goto done; + } + + r->out.buffer = (DATA_BLOB *)talloc(mem_ctx, sizeof(DATA_BLOB)); + + if (!r->out.buffer) { + result = WERR_NOMEM; + goto done; + } + + *r->out.buffer = data_blob_talloc(mem_ctx, buf->data, buf->offset); + + r->out.count = 1; + *r->out.buf_size = buf->offset; + + result = WERR_OK; + + done: + ndr_push_free(buf); + + return result; } +/* + destroy connection state +*/ +static void spoolss_OpenPrinter_close(struct spoolss_openprinter_state *c_state) +{ + c_state->reference_count--; + if (c_state->reference_count == 0) { + talloc_destroy(c_state->mem_ctx); + } +} + /* destroy an open connection. This closes the database connection */ static void spoolss_OpenPrinter_destroy(struct dcesrv_connection *conn, struct dcesrv_handle *h) { -#if 0 - struct samr_connect_state *c_state = h->data; - samr_Connect_close(c_state); -#endif + struct spoolss_openprinter_state *c_state = h->data; + spoolss_OpenPrinter_close(c_state); } /* @@ -338,7 +383,7 @@ static WERROR spoolss_ClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CT DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); - /* this causes the callback spoolss_XXX_destroy() to be called by + /* this causes the callback s_XXX_destroy() to be called by the handle destroy code which destroys the state associated with the handle */ dcesrv_handle_destroy(dce_call->conn, h); -- cgit