s3-spoolss: use pidl for _spoolss_EnumForms.
authorGünther Deschner <gd@samba.org>
Fri, 6 Mar 2009 11:01:14 +0000 (12:01 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 6 Mar 2009 13:32:15 +0000 (14:32 +0100)
Guenther

source3/include/proto.h
source3/rpc_server/srv_spoolss.c
source3/rpc_server/srv_spoolss_nt.c

index 4ce5ed695f9eb8ee1eb1c4203a04a624c9dafdf5..8395e2ad4dfcd9a55526cbcf3ffe89e69676e315 100644 (file)
@@ -6123,7 +6123,6 @@ WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname
 bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer);
 WERROR _spoolss_enumjobs( pipes_struct *p, SPOOL_Q_ENUMJOBS *q_u, SPOOL_R_ENUMJOBS *r_u);
 WERROR _spoolss_enumprinterdrivers( pipes_struct *p, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, SPOOL_R_ENUMPRINTERDRIVERS *r_u);
-WERROR _spoolss_enumforms(pipes_struct *p, SPOOL_Q_ENUMFORMS *q_u, SPOOL_R_ENUMFORMS *r_u);
 WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines );
 WERROR _spoolss_enumports( pipes_struct *p, SPOOL_Q_ENUMPORTS *q_u, SPOOL_R_ENUMPORTS *r_u);
 WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u);
index ee36f04c6d6c34133b8b24e1bb90c4015216f950..d665ebe24419ec00d02e3739f3deb3be337a0662 100644 (file)
@@ -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);
 }
 
 /****************************************************************************
index 814f406e8702948eb6302bb48aeae24806278a33..ec19279e0c09f7b043eb9a04d701e30e0fe54cce 100644 (file)
@@ -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;
 
@@ -10312,17 +10288,6 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p,
        return WERR_NOT_SUPPORTED;
 }
 
-/****************************************************************
- _spoolss_EnumForms
-****************************************************************/
-
-WERROR _spoolss_EnumForms(pipes_struct *p,
-                         struct spoolss_EnumForms *r)
-{
-       p->rng_fault_state = true;
-       return WERR_NOT_SUPPORTED;
-}
-
 /****************************************************************
  _spoolss_EnumPorts
 ****************************************************************/