s3-spoolss: use pidl for _spoolss_GetPrinterDriverDirectory.
authorGünther Deschner <gd@samba.org>
Thu, 19 Feb 2009 00:46:17 +0000 (01:46 +0100)
committerGünther Deschner <gd@samba.org>
Thu, 19 Feb 2009 01:06:57 +0000 (02:06 +0100)
Guenther

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

index 3da5b987d17bb8d6c3d7676fbb37ed9e8e8bee9a..1972250843f9a5c56347ffe3d46f3b43baeac5bb 100644 (file)
@@ -6248,7 +6248,6 @@ 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_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u, SPOOL_R_ADDPRINTERDRIVER *r_u);
 WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, SPOOL_R_ADDPRINTERDRIVEREX *r_u);
-WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, SPOOL_R_GETPRINTERDRIVERDIR *r_u);
 WERROR _spoolss_enumprinterdata(pipes_struct *p, SPOOL_Q_ENUMPRINTERDATA *q_u, SPOOL_R_ENUMPRINTERDATA *r_u);
 WERROR _spoolss_setprinterdata( pipes_struct *p, SPOOL_Q_SETPRINTERDATA *q_u, SPOOL_R_SETPRINTERDATA *r_u);
 WERROR _spoolss_enumprintprocessors(pipes_struct *p, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, SPOOL_R_ENUMPRINTPROCESSORS *r_u);
index 10e983e72ab6082462ceb1357fa90698a5112d6a..4074f8601b8b67f46e09b804ca036c5d3cc0d77a 100644 (file)
@@ -575,27 +575,7 @@ static bool api_spoolss_addprinterdriver(pipes_struct *p)
 
 static bool api_spoolss_getprinterdriverdirectory(pipes_struct *p)
 {
-       SPOOL_Q_GETPRINTERDRIVERDIR q_u;
-       SPOOL_R_GETPRINTERDRIVERDIR 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_getprinterdriverdir("", &q_u, data, 0)) {
-               DEBUG(0,("spoolss_io_q_getprinterdriverdir: unable to unmarshall SPOOL_Q_GETPRINTERDRIVERDIR.\n"));
-               return False;
-       }
-
-       r_u.status = _spoolss_getprinterdriverdirectory(p, &q_u, &r_u);
-
-       if(!spoolss_io_r_getprinterdriverdir("", &r_u, rdata, 0)) {
-               DEBUG(0,("spoolss_io_r_getprinterdriverdir: unable to marshall SPOOL_R_GETPRINTERDRIVERDIR.\n"));
-               return False;
-       }
-
-       return True;
+       return proxy_spoolss_call(p, NDR_SPOOLSS_GETPRINTERDRIVERDIRECTORY);
 }
 
 /****************************************************************************
index d79d18f90fb00208cf34df6e5a3f3507d4b3be66..d72e2708a57b4a941a95d1a98ee77f1a26875bcb 100644 (file)
@@ -8053,33 +8053,16 @@ WERROR _spoolss_addprinterdriverex(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVEREX *
 /****************************************************************************
 ****************************************************************************/
 
-static void fill_driverdir_1(DRIVER_DIRECTORY_1 *info, char *name)
-{
-       init_unistr(&info->name, name);
-}
-
-/****************************************************************************
-****************************************************************************/
-
-static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environment, RPC_BUFFER *buffer, uint32 offered, uint32 *needed)
+static WERROR getprinterdriverdir_level_1(TALLOC_CTX *mem_ctx,
+                                         const char *servername,
+                                         const char *long_archi,
+                                         struct spoolss_DriverDirectoryInfo1 *info1,
+                                         uint32_t offered,
+                                         uint32_t *needed)
 {
        char *path = NULL;
-       char *long_archi = NULL;
-       char *servername = NULL;
        const char *pservername = NULL;
        const char *short_archi;
-       DRIVER_DIRECTORY_1 *info=NULL;
-       WERROR result = WERR_OK;
-       TALLOC_CTX *ctx = talloc_tos();
-
-       servername = unistr2_to_ascii_talloc(ctx, name);
-       if (!servername) {
-               return WERR_NOMEM;
-       }
-       long_archi = unistr2_to_ascii_talloc(ctx, uni_environment);
-       if (!long_archi) {
-               return WERR_NOMEM;
-       }
 
        pservername = canon_servername(servername);
 
@@ -8089,75 +8072,67 @@ static WERROR getprinterdriverdir_level_1(UNISTR2 *name, UNISTR2 *uni_environmen
        if (!(short_archi = get_short_archi(long_archi)))
                return WERR_INVALID_ENVIRONMENT;
 
-       if((info=SMB_MALLOC_P(DRIVER_DIRECTORY_1)) == NULL)
-               return WERR_NOMEM;
-
-       path = talloc_asprintf(ctx,
+       path = talloc_asprintf(mem_ctx,
                        "\\\\%s\\print$\\%s", pservername, short_archi);
        if (!path) {
-               result = WERR_NOMEM;
-               goto out;
+               return WERR_NOMEM;
        }
 
        DEBUG(4,("printer driver directory: [%s]\n", path));
 
-       fill_driverdir_1(info, path);
+       info1->directory_name = path;
 
-       *needed += spoolss_size_driverdir_info_1(info);
+       *needed += ndr_size_spoolss_DriverDirectoryInfo1(info1, NULL, 0);
 
        if (*needed > offered) {
-               result = WERR_INSUFFICIENT_BUFFER;
-               goto out;
-       }
-
-       if (!rpcbuf_alloc_size(buffer, *needed)) {
-               result = WERR_NOMEM;
-               goto out;
+               talloc_free(path);
+               ZERO_STRUCTP(info1);
+               return WERR_INSUFFICIENT_BUFFER;
        }
 
-       smb_io_driverdir_1("", buffer, info, 0);
-
-out:
-       SAFE_FREE(info);
-
-       return result;
+       return WERR_OK;
 }
 
-/****************************************************************************
-****************************************************************************/
+/****************************************************************
+ _spoolss_GetPrinterDriverDirectory
+****************************************************************/
 
-WERROR _spoolss_getprinterdriverdirectory(pipes_struct *p, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, SPOOL_R_GETPRINTERDRIVERDIR *r_u)
+WERROR _spoolss_GetPrinterDriverDirectory(pipes_struct *p,
+                                         struct spoolss_GetPrinterDriverDirectory *r)
 {
-       UNISTR2 *name = &q_u->name;
-       UNISTR2 *uni_environment = &q_u->environment;
-       uint32 level = q_u->level;
-       RPC_BUFFER *buffer = NULL;
-       uint32 offered = q_u->offered;
-       uint32 *needed = &r_u->needed;
+       WERROR werror;
 
        /* that's an [in out] buffer */
 
-       if (!q_u->buffer && (offered!=0)) {
+       if (!r->in.buffer && (r->in.offered != 0)) {
                return WERR_INVALID_PARAM;
        }
 
-       if (offered > MAX_RPC_DATA_SIZE) {
+       if (r->in.offered > MAX_RPC_DATA_SIZE) {
                return WERR_INVALID_PARAM;
        }
 
-       rpcbuf_move(q_u->buffer, &r_u->buffer);
-       buffer = r_u->buffer;
-
-       DEBUG(4,("_spoolss_getprinterdriverdirectory\n"));
+       DEBUG(4,("_spoolss_GetPrinterDriverDirectory\n"));
 
-       *needed=0;
+       *r->out.needed = 0;
 
-       switch(level) {
+       switch (r->in.level) {
        case 1:
-               return getprinterdriverdir_level_1(name, uni_environment, buffer, offered, needed);
+               werror = getprinterdriverdir_level_1(p->mem_ctx,
+                                                    r->in.server,
+                                                    r->in.environment,
+                                                    &r->out.info->info1,
+                                                    r->in.offered,
+                                                    r->out.needed);
+               if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
+                       TALLOC_FREE(r->out.info);
+               }
+               break;
        default:
                return WERR_UNKNOWN_LEVEL;
        }
+
+       return werror;
 }
 
 /****************************************************************************
@@ -10243,17 +10218,6 @@ WERROR _spoolss_GetPrinterDriver(pipes_struct *p,
        return WERR_NOT_SUPPORTED;
 }
 
-/****************************************************************
- _spoolss_GetPrinterDriverDirectory
-****************************************************************/
-
-WERROR _spoolss_GetPrinterDriverDirectory(pipes_struct *p,
-                                         struct spoolss_GetPrinterDriverDirectory *r)
-{
-       p->rng_fault_state = true;
-       return WERR_NOT_SUPPORTED;
-}
-
 /****************************************************************
  _spoolss_EnumPrintProcessors
 ****************************************************************/