summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss.c22
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c111
2 files changed, 39 insertions, 94 deletions
diff --git a/source3/rpc_server/srv_spoolss.c b/source3/rpc_server/srv_spoolss.c
index ee36f04c6d..d665ebe244 100644
--- a/source3/rpc_server/srv_spoolss.c
+++ b/source3/rpc_server/srv_spoolss.c
@@ -431,27 +431,7 @@ static bool api_spoolss_getform(pipes_struct *p)
static bool api_spoolss_enumforms(pipes_struct *p)
{
- SPOOL_Q_ENUMFORMS q_u;
- SPOOL_R_ENUMFORMS r_u;
- prs_struct *data = &p->in_data.data;
- prs_struct *rdata = &p->out_data.rdata;
-
- ZERO_STRUCT(q_u);
- ZERO_STRUCT(r_u);
-
- if (!spoolss_io_q_enumforms("", &q_u, data, 0)) {
- DEBUG(0,("spoolss_io_q_enumforms: unable to unmarshall SPOOL_Q_ENUMFORMS.\n"));
- return False;
- }
-
- r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
-
- if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
- DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
- return False;
- }
-
- return True;
+ return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMFORMS);
}
/****************************************************************************
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 814f406e87..ec19279e0c 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -7277,73 +7277,65 @@ static WERROR fill_form_info_1(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_EnumForms
+****************************************************************/
-WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u)
+WERROR _spoolss_EnumForms(pipes_struct *p,
+ struct spoolss_EnumForms *r)
{
- uint32 level = q_u->level;
- RPC_BUFFER *buffer = NULL;
- uint32 offered = q_u->offered;
- uint32 *needed = &r_u->needed;
- uint32 *numofforms = &r_u->numofforms;
- uint32 numbuiltinforms;
-
nt_forms_struct *list=NULL;
nt_forms_struct *builtinlist=NULL;
- FORM_1 *forms_1;
- int buffer_size=0;
+ union spoolss_FormInfo *info;
+ uint32_t count;
+ uint32_t numbuiltinforms;
+ size_t buffer_size = 0;
int i;
- /* that's an [in out] buffer */
+ *r->out.count = 0;
- if (!q_u->buffer && (offered!=0) ) {
- return WERR_INVALID_PARAM;
- }
+ /* that's an [in out] buffer */
- if (offered > MAX_RPC_DATA_SIZE) {
+ if (!r->in.buffer && (r->in.offered != 0) ) {
return WERR_INVALID_PARAM;
}
- rpcbuf_move(q_u->buffer, &r_u->buffer);
- buffer = r_u->buffer;
-
- DEBUG(4,("_spoolss_enumforms\n"));
- DEBUGADD(5,("Offered buffer size [%d]\n", offered));
- DEBUGADD(5,("Info level [%d]\n", level));
+ DEBUG(4,("_spoolss_EnumForms\n"));
+ DEBUGADD(5,("Offered buffer size [%d]\n", r->in.offered));
+ DEBUGADD(5,("Info level [%d]\n", r->in.level));
numbuiltinforms = get_builtin_ntforms(&builtinlist);
DEBUGADD(5,("Number of builtin forms [%d]\n", numbuiltinforms));
- *numofforms = get_ntforms(&list);
- DEBUGADD(5,("Number of user forms [%d]\n", *numofforms));
- *numofforms += numbuiltinforms;
+ count = get_ntforms(&list);
+ DEBUGADD(5,("Number of user forms [%d]\n", count));
+ count += numbuiltinforms;
- if (*numofforms == 0) {
+ if (count == 0) {
SAFE_FREE(builtinlist);
SAFE_FREE(list);
return WERR_NO_MORE_ITEMS;
}
- switch (level) {
- case 1:
- if ((forms_1=SMB_MALLOC_ARRAY(FORM_1, *numofforms)) == NULL) {
- SAFE_FREE(builtinlist);
- SAFE_FREE(list);
- *numofforms=0;
- return WERR_NOMEM;
- }
+ info = TALLOC_ARRAY(p->mem_ctx, union spoolss_FormInfo, count);
+ if (!info) {
+ SAFE_FREE(builtinlist);
+ SAFE_FREE(list);
+ return WERR_NOMEM;
+ }
+ switch (r->in.level) {
+ case 1:
/* construct the list of form structures */
for (i=0; i<numbuiltinforms; i++) {
DEBUGADD(6,("Filling form number [%d]\n",i));
- fill_form_1(&forms_1[i], &builtinlist[i]);
+ fill_form_info_1(info, &info[i].info1, &builtinlist[i]);
}
SAFE_FREE(builtinlist);
- for (; i<*numofforms; i++) {
+ for (; i<count; i++) {
DEBUGADD(6,("Filling form number [%d]\n",i));
- fill_form_1(&forms_1[i], &list[i-numbuiltinforms]);
+ fill_form_info_1(info, &info[i].info1, &list[i-numbuiltinforms]);
}
SAFE_FREE(list);
@@ -7351,38 +7343,22 @@ WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMF
/* check the required size. */
for (i=0; i<numbuiltinforms; i++) {
DEBUGADD(6,("adding form [%d]'s size\n",i));
- buffer_size += spoolss_size_form_1(&forms_1[i]);
+ buffer_size += ndr_size_spoolss_FormInfo1(&info[i].info1, NULL, 0);
}
- for (; i<*numofforms; i++) {
+ for (; i<count; i++) {
DEBUGADD(6,("adding form [%d]'s size\n",i));
- buffer_size += spoolss_size_form_1(&forms_1[i]);
+ buffer_size += ndr_size_spoolss_FormInfo1(&info[i].info1, NULL, 0);
}
- *needed=buffer_size;
+ *r->out.needed = buffer_size;
- if (*needed > offered) {
- SAFE_FREE(forms_1);
- *numofforms=0;
+ if (*r->out.needed > r->in.offered) {
+ TALLOC_FREE(info);
return WERR_INSUFFICIENT_BUFFER;
}
- if (!rpcbuf_alloc_size(buffer, buffer_size)){
- SAFE_FREE(forms_1);
- *numofforms=0;
- return WERR_NOMEM;
- }
-
- /* fill the buffer with the form structures */
- for (i=0; i<numbuiltinforms; i++) {
- DEBUGADD(6,("adding form [%d] to buffer\n",i));
- smb_io_form_1("", buffer, &forms_1[i], 0);
- }
- for (; i<*numofforms; i++) {
- DEBUGADD(6,("adding form [%d] to buffer\n",i));
- smb_io_form_1("", buffer, &forms_1[i], 0);
- }
-
- SAFE_FREE(forms_1);
+ *r->out.count = count;
+ *r->out.info = info;
return WERR_OK;
@@ -10313,17 +10289,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p,
}
/****************************************************************
- _spoolss_EnumForms
-****************************************************************/
-
-WERROR _spoolss_EnumForms(pipes_struct *p,
- struct spoolss_EnumForms *r)
-{
- p->rng_fault_state = true;
- return WERR_NOT_SUPPORTED;
-}
-
-/****************************************************************
_spoolss_EnumPorts
****************************************************************/