diff options
author | Tim Potter <tpot@samba.org> | 2004-06-20 07:36:26 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:56:44 -0500 |
commit | f1eef54ba8b16ed7b354ad457dbbadce26ebb807 (patch) | |
tree | b171e62bea9c17636bd15f530e4a7abf27a527a4 | |
parent | be081037e09bb78c0308cd6c7a5d7ae563678b7c (diff) | |
download | samba-f1eef54ba8b16ed7b354ad457dbbadce26ebb807.tar.gz samba-f1eef54ba8b16ed7b354ad457dbbadce26ebb807.tar.bz2 samba-f1eef54ba8b16ed7b354ad457dbbadce26ebb807.zip |
r1201: Skeleton versions of OpenPrinterEx() and ClosePrinter() to get the hang
of things.
(This used to be commit 3e79a6219eca3b96fe04d66b6cdfb11400c1771d)
-rw-r--r-- | source4/rpc_server/spoolss/dcesrv_spoolss.c | 67 | ||||
-rw-r--r-- | source4/rpc_server/spoolss/dcesrv_spoolss.h | 12 |
2 files changed, 76 insertions, 3 deletions
diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.c b/source4/rpc_server/spoolss/dcesrv_spoolss.c index 56cd04c18a..cb001c168a 100644 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.c +++ b/source4/rpc_server/spoolss/dcesrv_spoolss.c @@ -22,6 +22,8 @@ #include "includes.h" #include "rpc_server/common/common.h" +#include "rpc_server/spoolss/dcesrv_spoolss.h" + /* spoolss_EnumPrinters @@ -33,6 +35,17 @@ static WERROR spoolss_EnumPrinters(struct dcesrv_call_state *dce_call, TALLOC_CT } +/* + 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 +} + /* spoolss_OpenPrinter */ @@ -319,7 +332,20 @@ static WERROR spoolss_WaitForPrinterChange(struct dcesrv_call_state *dce_call, T static WERROR spoolss_ClosePrinter(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_ClosePrinter *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + struct dcesrv_handle *h; + + *r->out.handle = *r->in.handle; + + DCESRV_PULL_HANDLE_WERR(h, r->in.handle, DCESRV_HANDLE_ANY); + + /* this causes the callback spoolss_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); + + ZERO_STRUCTP(r->out.handle); + + return WERR_OK; } @@ -719,7 +745,44 @@ static WERROR spoolss_44(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx static WERROR spoolss_OpenPrinterEx(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct spoolss_OpenPrinterEx *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + struct spoolss_openprinter_state *state; + struct dcesrv_handle *handle; + TALLOC_CTX *op_mem_ctx; + + ZERO_STRUCTP(r->out.handle); + + /* Check printername is either \\\\SERVER, \\\\SERVERIP or + \\\\SERVER.FQ.DN */ + + if (!strequal(r->in.printername, lp_netbios_name())) { + return WERR_INVALID_PRINTER_NAME; + } + + op_mem_ctx = talloc_init("spoolss_OpenPrinter"); + if (!op_mem_ctx) { + return WERR_OK; + } + + state = talloc_p(op_mem_ctx, struct spoolss_openprinter_state); + if (!state) { + return WERR_OK; + } + state->mem_ctx = op_mem_ctx; + + handle = dcesrv_handle_new(dce_call->conn, SPOOLSS_HANDLE_SERVER); + if (!handle) { + talloc_destroy(state->mem_ctx); + return WERR_NOMEM; + } + + handle->data = state; + handle->destroy = spoolss_OpenPrinter_destroy; + + state->reference_count = 1; + state->access_mask = r->in.access_required; + *r->out.handle = handle->wire_handle; + + return WERR_OK; } diff --git a/source4/rpc_server/spoolss/dcesrv_spoolss.h b/source4/rpc_server/spoolss/dcesrv_spoolss.h index 6697e2afaf..950c765a72 100644 --- a/source4/rpc_server/spoolss/dcesrv_spoolss.h +++ b/source4/rpc_server/spoolss/dcesrv_spoolss.h @@ -23,7 +23,17 @@ /* this type allows us to distinguish handle types */ -enum samr_handle { +enum spoolss_handle { SPOOLSS_HANDLE_SERVER, SPOOLSS_HANDLE_PRINTER }; + +/* + state asscoiated with a spoolss_OpenPrinter{,Ex}() operation +*/ +struct spoolss_openprinter_state { + int reference_count; + void *openprinter_ctx; + TALLOC_CTX *mem_ctx; + uint32_t access_mask; +}; |