s3-spoolss: use pidl for _spoolss_EnumPrinterKey.
authorGünther Deschner <gd@samba.org>
Mon, 16 Mar 2009 22:09:15 +0000 (23:09 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 17 Mar 2009 11:18:57 +0000 (12:18 +0100)
Guenther

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

index 57d9a992692b70a319643c170b72690c8a7aa374..d1e20db4b6f9d7284bdca2a81ad7a27fe117f31d 100644 (file)
@@ -6050,7 +6050,6 @@ struct spoolss_DeviceMode *construct_dev_mode_new(TALLOC_CTX *mem_ctx,
 WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname, const char *uri );
 bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer);
 WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines );
 WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname, const char *uri );
 bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer);
 WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines );
-WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u);
 WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_u, SPOOL_R_ENUMPRINTERDATAEX *r_u);
 
 /* The following definitions come from rpc_server/srv_srvsvc_nt.c  */
 WERROR _spoolss_enumprinterdataex(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATAEX *q_u, SPOOL_R_ENUMPRINTERDATAEX *r_u);
 
 /* The following definitions come from rpc_server/srv_srvsvc_nt.c  */
index ced4ed53f413dcd3b08a73252d7bf31fbc30e81a..1b9cdb343845ed9d7c8bc6b53059ff3936d4062c 100644 (file)
@@ -456,27 +456,7 @@ static bool api_spoolss_setprinterdataex(pipes_struct *p)
 
 static bool api_spoolss_enumprinterkey(pipes_struct *p)
 {
 
 static bool api_spoolss_enumprinterkey(pipes_struct *p)
 {
-       SPOOL_Q_ENUMPRINTERKEY q_u;
-       SPOOL_R_ENUMPRINTERKEY 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_enumprinterkey("", &q_u, data, 0)) {
-               DEBUG(0,("spoolss_io_q_setprinterkey: unable to unmarshall SPOOL_Q_ENUMPRINTERKEY.\n"));
-               return False;
-       }
-       
-       r_u.status = _spoolss_enumprinterkey(p, &q_u, &r_u);
-                               
-       if(!spoolss_io_r_enumprinterkey("", &r_u, rdata, 0)) {
-               DEBUG(0,("spoolss_io_r_enumprinterkey: unable to marshall SPOOL_R_ENUMPRINTERKEY.\n"));
-               return False;
-       }
-
-       return True;
+       return proxy_spoolss_call(p, NDR_SPOOLSS_ENUMPRINTERKEY);
 }
 
 /****************************************************************************
 }
 
 /****************************************************************************
index 9cde7d2e010d7c8abe486e63d0a6e87cf7f0cde8..84064a308f4c607c0d028b4bd4ad61a973cccbb9 100644 (file)
@@ -9206,76 +9206,88 @@ WERROR _spoolss_DeletePrinterDataEx(pipes_struct *p,
        return status;
 }
 
        return status;
 }
 
-/********************************************************************
- * spoolss_enumprinterkey
- ********************************************************************/
-
+/****************************************************************
+ _spoolss_EnumPrinterKey
+****************************************************************/
 
 
-WERROR _spoolss_enumprinterkey(pipes_struct *p, SPOOL_Q_ENUMPRINTERKEY *q_u, SPOOL_R_ENUMPRINTERKEY *r_u)
+WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
+                              struct spoolss_EnumPrinterKey *r)
 {
 {
-       fstring         key;
        fstring         *keynames = NULL;
        fstring         *keynames = NULL;
-       uint16          *enumkeys = NULL;
        int             num_keys;
        int             num_keys;
-       int             printerkey_len;
-       POLICY_HND      *handle = &q_u->handle;
-       Printer_entry   *Printer = find_printer_index_by_hnd(p, handle);
+       Printer_entry   *Printer = find_printer_index_by_hnd(p, r->in.handle);
        NT_PRINTER_DATA *data;
        NT_PRINTER_INFO_LEVEL   *printer = NULL;
        int             snum = 0;
        NT_PRINTER_DATA *data;
        NT_PRINTER_INFO_LEVEL   *printer = NULL;
        int             snum = 0;
-       WERROR          status = WERR_BADFILE;
+       WERROR          result = WERR_BADFILE;
+       int i;
+       const char **array = NULL;
 
 
 
 
-       DEBUG(4,("_spoolss_enumprinterkey\n"));
+       DEBUG(4,("_spoolss_EnumPrinterKey\n"));
 
        if (!Printer) {
 
        if (!Printer) {
-               DEBUG(2,("_spoolss_enumprinterkey: Invalid handle (%s:%u:%u).\n", OUR_HANDLE(handle)));
+               DEBUG(2,("_spoolss_EnumPrinterKey: Invalid handle (%s:%u:%u).\n",
+                       OUR_HANDLE(r->in.handle)));
                return WERR_BADFID;
        }
 
                return WERR_BADFID;
        }
 
-       if ( !get_printer_snum(p,handle, &snum, NULL) )
+       if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
                return WERR_BADFID;
                return WERR_BADFID;
+       }
 
 
-       status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
-       if (!W_ERROR_IS_OK(status))
-               return status;
+       result = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
 
        /* get the list of subkey names */
 
 
        /* get the list of subkey names */
 
-       unistr2_to_ascii(key, &q_u->key, sizeof(key));
        data = printer->info_2->data;
 
        data = printer->info_2->data;
 
-       num_keys = get_printer_subkeys( data, key, &keynames );
-
-       if ( num_keys == -1 ) {
-               status = WERR_BADFILE;
+       num_keys = get_printer_subkeys(data, r->in.key_name, &keynames);
+       if (num_keys == -1) {
+               result = WERR_BADFILE;
                goto done;
        }
 
                goto done;
        }
 
-       printerkey_len = init_unistr_array( &enumkeys,  keynames, NULL );
-
-       r_u->needed = printerkey_len*2;
+       *r->out.needed = 4;
 
 
-       if ( q_u->size < r_u->needed ) {
-               status = WERR_MORE_DATA;
+       array = talloc_zero_array(r->out.key_buffer, const char *, num_keys + 1);
+       if (!array) {
+               result = WERR_NOMEM;
                goto done;
        }
 
                goto done;
        }
 
-       if (!make_spoolss_buffer5(p->mem_ctx, &r_u->keys, printerkey_len, enumkeys)) {
-               status = WERR_NOMEM;
+       for (i=0; i < num_keys; i++) {
+               array[i] = talloc_strdup(array, keynames[i]);
+               if (!array[i]) {
+                       result = WERR_NOMEM;
+                       goto done;
+               }
+
+               *r->out.needed += strlen_m_term(keynames[i]) * 2;
+       }
+
+       if (r->in.offered < *r->out.needed) {
+               result = WERR_MORE_DATA;
                goto done;
        }
 
                goto done;
        }
 
-       status = WERR_OK;
+       result = WERR_OK;
 
 
-       if ( q_u->size < r_u->needed )
-               status = WERR_MORE_DATA;
+       *r->out.key_buffer = array;
 
 
-done:
-       free_a_printer( &printer, 2 );
-       SAFE_FREE( keynames );
+ done:
+       if (!W_ERROR_IS_OK(result)) {
+               TALLOC_FREE(array);
+               ZERO_STRUCTP(r->out.key_buffer);
+       }
 
 
-        return status;
+       free_a_printer(&printer, 2);
+       SAFE_FREE(keynames);
+
+       return result;
 }
 
 /****************************************************************
 }
 
 /****************************************************************
@@ -10269,17 +10281,6 @@ WERROR _spoolss_EnumPrinterDataEx(pipes_struct *p,
        return WERR_NOT_SUPPORTED;
 }
 
        return WERR_NOT_SUPPORTED;
 }
 
-/****************************************************************
- _spoolss_EnumPrinterKey
-****************************************************************/
-
-WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
-                              struct spoolss_EnumPrinterKey *r)
-{
-       p->rng_fault_state = true;
-       return WERR_NOT_SUPPORTED;
-}
-
 /****************************************************************
  _spoolss_53
 ****************************************************************/
 /****************************************************************
  _spoolss_53
 ****************************************************************/