From 882ff84daad4052d87cbf3d83de6cb281b09251a Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Tue, 3 Sep 2002 00:26:19 +0000 Subject: Return data from enumprinterdataex by deep copying on passed in tdb context. (This used to be commit 1f629aa54ea3733c356c21f9f707b7f6075f6429) --- source3/rpc_client/cli_spoolss.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index cff1f1d0a9..d2492dc53b 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -2171,6 +2171,7 @@ WERROR cli_spoolss_enumprinterdataex(struct cli_state *cli, TALLOC_CTX *mem_ctx, SPOOL_Q_ENUMPRINTERDATAEX q; SPOOL_R_ENUMPRINTERDATAEX r; WERROR result = W_ERROR(ERRgeneral); + int i; ZERO_STRUCT(q); ZERO_STRUCT(r); @@ -2207,7 +2208,22 @@ WERROR cli_spoolss_enumprinterdataex(struct cli_state *cli, TALLOC_CTX *mem_ctx, *returned = r.returned; - /* TODO: figure out a nice way to return data */ + /* Again, we have to deep copy the results on the passed in + tdb context as they will disappear after the prs_free at + the end of this function. */ + + *values = talloc(mem_ctx, sizeof(PRINTER_ENUM_VALUES) * r.returned); + + for (i = 0; i < r.returned; i++) { + PRINTER_ENUM_VALUES *v = &r.ctr.values[i]; + + (*values)[i].valuename.buffer = talloc(mem_ctx, v->value_len * 2); + unistrcpy((*values)[i].valuename.buffer, v->valuename.buffer); + (*values)[i].type = v->type; + (*values)[i].data = talloc(mem_ctx, v->data_len); + memcpy((*values)[i].data, v->data, v->data_len); + (*values)[i].data_len = v->data_len; + } done: prs_mem_free(&qbuf); -- cgit