r23779: Change from v2 or later to v3 or later.
[abartlet/samba.git/.git] / source3 / rpc_server / srv_spoolss.c
index 126581ba8084563c62646930218a66ccc25b6309..2f58fe39b8ee7acc782d6e692953c20041b5d788 100755 (executable)
@@ -1,15 +1,16 @@
 /* 
- *  Unix SMB/Netbios implementation.
- *  Version 1.9.
+ *  Unix SMB/CIFS implementation.
  *  RPC Pipe client / server routines
  *  Copyright (C) Andrew Tridgell              1992-2000,
  *  Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
- *  Copyright (C) Jean François Micouleau      1998-2000.
- *  Copyright (C) Jeremy Allison                                       2001.
+ *  Copyright (C) Jean François Micouleau      1998-2000,
+ *  Copyright (C) Jeremy Allison                    2001,
+ *  Copyright (C) Gerald Carter                2001-2002,
+ *  Copyright (C) Jim McDonough <jmcd@us.ibm.com>   2003.
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
 
 #include "includes.h"
 
-extern int DEBUGLEVEL;
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_RPC_SRV
+
+/********************************************************************
+ * api_spoolss_open_printer_ex (rarely seen - older call)
+ ********************************************************************/
+
+static BOOL api_spoolss_open_printer(pipes_struct *p)
+{
+       SPOOL_Q_OPEN_PRINTER q_u;
+       SPOOL_R_OPEN_PRINTER 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_open_printer("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_open_printer: unable to unmarshall SPOOL_Q_OPEN_PRINTER.\n"));
+               return False;
+       }
+
+       r_u.status = _spoolss_open_printer( p, &q_u, &r_u);
+       
+       if (!spoolss_io_r_open_printer("",&r_u,rdata,0)){
+               DEBUG(0,("spoolss_io_r_open_printer: unable to marshall SPOOL_R_OPEN_PRINTER.\n"));
+               return False;
+       }
+
+       return True;
+}
+
 
 /********************************************************************
  * api_spoolss_open_printer_ex
@@ -109,7 +141,7 @@ static BOOL api_spoolss_deleteprinterdata(pipes_struct *p)
                return False;
        }
        
-       r_u.status = _spoolss_deleteprinterdata( p, &q_u, &r_u);
+       r_u.status = _spoolss_deleteprinterdata( p, &q_u, &r_u );
 
        if (!spoolss_io_r_deleteprinterdata("", &r_u, rdata, 0)) {
                DEBUG(0,("spoolss_io_r_deleteprinterdata: unable to marshall SPOOL_R_DELETEPRINTERDATA.\n"));
@@ -213,6 +245,38 @@ static BOOL api_spoolss_deleteprinter(pipes_struct *p)
 }
 
 
+/********************************************************************
+ * api_spoolss_deleteprinterdriver
+ *
+ * called from the spoolss dispatcher
+ ********************************************************************/
+
+static BOOL api_spoolss_deleteprinterdriver(pipes_struct *p)
+{
+       SPOOL_Q_DELETEPRINTERDRIVER q_u;
+       SPOOL_R_DELETEPRINTERDRIVER 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_deleteprinterdriver("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_deleteprinterdriver: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVER.\n"));
+               return False;
+       }
+
+       r_u.status = _spoolss_deleteprinterdriver(p, &q_u, &r_u);
+
+       if (!spoolss_io_r_deleteprinterdriver("",&r_u,rdata,0)) {
+               DEBUG(0,("spoolss_io_r_deleteprinter: unable to marshall SPOOL_R_DELETEPRINTER.\n"));
+               return False;
+       }
+
+       return True;
+}
+
+
 /********************************************************************
  * api_spoolss_rffpcnex
  * ReplyFindFirstPrinterChangeNotifyEx
@@ -273,12 +337,12 @@ static BOOL api_spoolss_rfnpcnex(pipes_struct *p)
        r_u.status = _spoolss_rfnpcnex(p, &q_u, &r_u);
 
        if (!spoolss_io_r_rfnpcnex("", &r_u, rdata, 0)) {
-               safe_free(r_u.info.data);
+               SAFE_FREE(r_u.info.data);
                DEBUG(0,("spoolss_io_r_rfnpcnex: unable to marshall SPOOL_R_RFNPCNEX.\n"));
                return False;
        }
 
-       safe_free(r_u.info.data);
+       SAFE_FREE(r_u.info.data);
 
        return True;
 }
@@ -307,8 +371,8 @@ static BOOL api_spoolss_enumprinters(pipes_struct *p)
 
        r_u.status = _spoolss_enumprinters( p, &q_u, &r_u);
 
-       if (!new_spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
-               DEBUG(0,("new_spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
+       if (!spoolss_io_r_enumprinters("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_enumprinters: unable to marshall SPOOL_R_ENUMPRINTERS.\n"));
                return False;
        }
 
@@ -712,8 +776,8 @@ static BOOL api_spoolss_enumprinterdrivers(pipes_struct *p)
 
        r_u.status = _spoolss_enumprinterdrivers(p, &q_u, &r_u);
 
-       if (!new_spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
-               DEBUG(0,("new_spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
+       if (!spoolss_io_r_enumprinterdrivers("",&r_u,rdata,0)) {
+               DEBUG(0,("spoolss_io_r_enumprinterdrivers: unable to marshall SPOOL_R_ENUMPRINTERDRIVERS.\n"));
                return False;
        }
 
@@ -740,8 +804,8 @@ static BOOL api_spoolss_getform(pipes_struct *p)
 
        r_u.status = _spoolss_getform(p, &q_u, &r_u);
 
-       if (!new_spoolss_io_r_getform("",&r_u,rdata,0)) {
-               DEBUG(0,("new_spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n"));
+       if (!spoolss_io_r_getform("",&r_u,rdata,0)) {
+               DEBUG(0,("spoolss_io_r_getform: unable to marshall SPOOL_R_GETFORM.\n"));
                return False;
        }
 
@@ -766,10 +830,10 @@ static BOOL api_spoolss_enumforms(pipes_struct *p)
                return False;
        }
 
-       r_u.status = _new_spoolss_enumforms(p, &q_u, &r_u);
+       r_u.status = _spoolss_enumforms(p, &q_u, &r_u);
 
-       if (!new_spoolss_io_r_enumforms("",&r_u,rdata,0)) {
-               DEBUG(0,("new_spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
+       if (!spoolss_io_r_enumforms("",&r_u,rdata,0)) {
+               DEBUG(0,("spoolss_io_r_enumforms: unable to marshall SPOOL_R_ENUMFORMS.\n"));
                return False;
        }
 
@@ -796,8 +860,8 @@ static BOOL api_spoolss_enumports(pipes_struct *p)
 
        r_u.status = _spoolss_enumports(p, &q_u, &r_u);
 
-       if (!new_spoolss_io_r_enumports("",&r_u,rdata,0)) {
-               DEBUG(0,("new_spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
+       if (!spoolss_io_r_enumports("",&r_u,rdata,0)) {
+               DEBUG(0,("spoolss_io_r_enumports: unable to marshall SPOOL_R_ENUMPORTS.\n"));
                return False;
        }
 
@@ -846,6 +910,15 @@ static BOOL api_spoolss_addprinterdriver(pipes_struct *p)
        ZERO_STRUCT(r_u);
        
        if(!spoolss_io_q_addprinterdriver("", &q_u, data, 0)) {
+               if (q_u.level != 3 && q_u.level != 6) {
+                       /* Clever hack from Martin Zielinski <mz@seh.de>
+                        * to allow downgrade from level 8 (Vista).
+                        */
+                       DEBUG(3,("api_spoolss_addprinterdriver: unknown SPOOL_Q_ADDPRINTERDRIVER level %u.\n",
+                               (unsigned int)q_u.level ));
+                       setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
+                       return True;
+               }
                DEBUG(0,("spoolss_io_q_addprinterdriver: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVER.\n"));
                return False;
        }
@@ -946,7 +1019,33 @@ static BOOL api_spoolss_setprinterdata(pipes_struct *p)
 
 /****************************************************************************
 ****************************************************************************/
+static BOOL api_spoolss_reset_printer(pipes_struct *p)
+{
+       SPOOL_Q_RESETPRINTER q_u;
+       SPOOL_R_RESETPRINTER 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_resetprinter("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_setprinterdata: unable to unmarshall SPOOL_Q_SETPRINTERDATA.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_resetprinter(p, &q_u, &r_u);
+
+       if(!spoolss_io_r_resetprinter("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_setprinterdata: unable to marshall SPOOL_R_RESETPRINTER.\n"));
+               return False;
+       }
+
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
 static BOOL api_spoolss_addform(pipes_struct *p)
 {
        SPOOL_Q_ADDFORM q_u;
@@ -1059,6 +1158,38 @@ static BOOL api_spoolss_enumprintprocessors(pipes_struct *p)
 /****************************************************************************
 ****************************************************************************/
 
+static BOOL api_spoolss_addprintprocessor(pipes_struct *p)
+{
+       SPOOL_Q_ADDPRINTPROCESSOR q_u;
+       SPOOL_R_ADDPRINTPROCESSOR 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_addprintprocessor("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_addprintprocessor: unable to unmarshall SPOOL_Q_ADDPRINTPROCESSOR.\n"));
+               return False;
+       }
+       
+       /* for now, just indicate success and ignore the add.  We'll
+          automatically set the winprint processor for printer
+          entries later.  Used to debug the LexMark Optra S 1855 PCL
+          driver --jerry */
+       r_u.status = WERR_OK;
+
+       if(!spoolss_io_r_addprintprocessor("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_addprintprocessor: unable to marshall SPOOL_R_ADDPRINTPROCESSOR.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
 static BOOL api_spoolss_enumprintprocdatatypes(pipes_struct *p)
 {
        SPOOL_Q_ENUMPRINTPROCDATATYPES q_u;
@@ -1122,6 +1253,9 @@ static BOOL api_spoolss_getjob(pipes_struct *p)
        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_getjob("", &q_u, data, 0)) {
                DEBUG(0,("spoolss_io_q_getjob: unable to unmarshall SPOOL_Q_GETJOB.\n"));
                return False;
@@ -1137,12 +1271,307 @@ static BOOL api_spoolss_getjob(pipes_struct *p)
        return True;
 }
 
+/********************************************************************
+ * api_spoolss_getprinterdataex
+ *
+ * called from the spoolss dispatcher
+ ********************************************************************/
+
+static BOOL api_spoolss_getprinterdataex(pipes_struct *p)
+{
+       SPOOL_Q_GETPRINTERDATAEX q_u;
+       SPOOL_R_GETPRINTERDATAEX r_u;
+       prs_struct *data = &p->in_data.data;
+       prs_struct *rdata = &p->out_data.rdata;
+
+       ZERO_STRUCT(q_u);
+       ZERO_STRUCT(r_u);
+
+       /* read the stream and fill the struct */
+       if (!spoolss_io_q_getprinterdataex("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_getprinterdataex: unable to unmarshall SPOOL_Q_GETPRINTERDATAEX.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_getprinterdataex( p, &q_u, &r_u);
+
+       if (!spoolss_io_r_getprinterdataex("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_getprinterdataex: unable to marshall SPOOL_R_GETPRINTERDATAEX.\n"));
+               return False;
+       }
+
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_setprinterdataex(pipes_struct *p)
+{
+       SPOOL_Q_SETPRINTERDATAEX q_u;
+       SPOOL_R_SETPRINTERDATAEX 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_setprinterdataex("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_setprinterdataex: unable to unmarshall SPOOL_Q_SETPRINTERDATAEX.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_setprinterdataex(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_setprinterdataex("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_setprinterdataex: unable to marshall SPOOL_R_SETPRINTERDATAEX.\n"));
+               return False;
+       }
+
+       return True;
+}
+
+
+/****************************************************************************
+****************************************************************************/
+
+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;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_enumprinterdataex(pipes_struct *p)
+{
+       SPOOL_Q_ENUMPRINTERDATAEX q_u;
+       SPOOL_R_ENUMPRINTERDATAEX 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_enumprinterdataex("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_enumprinterdataex: unable to unmarshall SPOOL_Q_ENUMPRINTERDATAEX.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_enumprinterdataex(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_enumprinterdataex("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_enumprinterdataex: unable to marshall SPOOL_R_ENUMPRINTERDATAEX.\n"));
+               return False;
+       }
+
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_getprintprocessordirectory(pipes_struct *p)
+{
+       SPOOL_Q_GETPRINTPROCESSORDIRECTORY q_u;
+       SPOOL_R_GETPRINTPROCESSORDIRECTORY 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_getprintprocessordirectory("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_getprintprocessordirectory: unable to unmarshall SPOOL_Q_GETPRINTPROCESSORDIRECTORY.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_getprintprocessordirectory(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_getprintprocessordirectory("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_getprintprocessordirectory: unable to marshall SPOOL_R_GETPRINTPROCESSORDIRECTORY.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_deleteprinterdataex(pipes_struct *p)
+{
+       SPOOL_Q_DELETEPRINTERDATAEX q_u;
+       SPOOL_R_DELETEPRINTERDATAEX 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_deleteprinterdataex("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_deleteprinterdataex: unable to unmarshall SPOOL_Q_DELETEPRINTERDATAEX.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_deleteprinterdataex(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_deleteprinterdataex("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_deleteprinterdataex: unable to marshall SPOOL_R_DELETEPRINTERDATAEX.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_deleteprinterkey(pipes_struct *p)
+{
+       SPOOL_Q_DELETEPRINTERKEY q_u;
+       SPOOL_R_DELETEPRINTERKEY 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_deleteprinterkey("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_deleteprinterkey: unable to unmarshall SPOOL_Q_DELETEPRINTERKEY.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_deleteprinterkey(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_deleteprinterkey("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_deleteprinterkey: unable to marshall SPOOL_R_DELETEPRINTERKEY.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_addprinterdriverex(pipes_struct *p)
+{
+       SPOOL_Q_ADDPRINTERDRIVEREX q_u;
+       SPOOL_R_ADDPRINTERDRIVEREX 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_addprinterdriverex("", &q_u, data, 0)) {
+               if (q_u.level != 3 && q_u.level != 6) {
+                       /* Clever hack from Martin Zielinski <mz@seh.de>
+                        * to allow downgrade from level 8 (Vista).
+                        */
+                       DEBUG(3,("api_spoolss_addprinterdriverex: unknown SPOOL_Q_ADDPRINTERDRIVEREX level %u.\n",
+                               (unsigned int)q_u.level ));
+                       setup_fault_pdu(p, NT_STATUS(DCERPC_FAULT_INVALID_TAG));
+                       return True;
+               }
+               DEBUG(0,("spoolss_io_q_addprinterdriverex: unable to unmarshall SPOOL_Q_ADDPRINTERDRIVEREX.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_addprinterdriverex(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_addprinterdriverex("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_addprinterdriverex: unable to marshall SPOOL_R_ADDPRINTERDRIVEREX.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p)
+{
+       SPOOL_Q_DELETEPRINTERDRIVEREX q_u;
+       SPOOL_R_DELETEPRINTERDRIVEREX 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_deleteprinterdriverex("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_deleteprinterdriverex: unable to unmarshall SPOOL_Q_DELETEPRINTERDRIVEREX.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_deleteprinterdriverex(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_deleteprinterdriverex("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_deleteprinterdriverex: unable to marshall SPOOL_R_DELETEPRINTERDRIVEREX.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_xcvdataport(pipes_struct *p)
+{
+       SPOOL_Q_XCVDATAPORT q_u;
+       SPOOL_R_XCVDATAPORT 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_xcvdataport("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_XCVDATAPORT.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_xcvdataport(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_xcvdataport("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_XCVDATAPORT.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
 /*******************************************************************
 \pipe\spoolss commands
 ********************************************************************/
 
-struct api_struct api_spoolss_cmds[] = 
-{
+  struct api_struct api_spoolss_cmds[] = 
+    {
+ {"SPOOLSS_OPENPRINTER",               SPOOLSS_OPENPRINTER,               api_spoolss_open_printer              },
  {"SPOOLSS_OPENPRINTEREX",             SPOOLSS_OPENPRINTEREX,             api_spoolss_open_printer_ex           },
  {"SPOOLSS_GETPRINTERDATA",            SPOOLSS_GETPRINTERDATA,            api_spoolss_getprinterdata            },
  {"SPOOLSS_CLOSEPRINTER",              SPOOLSS_CLOSEPRINTER,              api_spoolss_closeprinter              },
@@ -1169,25 +1598,41 @@ struct api_struct api_spoolss_cmds[] =
  {"SPOOLSS_ENUMPRINTERDRIVERS",        SPOOLSS_ENUMPRINTERDRIVERS,        api_spoolss_enumprinterdrivers        },
  {"SPOOLSS_ADDPRINTEREX",              SPOOLSS_ADDPRINTEREX,              api_spoolss_addprinterex              },
  {"SPOOLSS_ADDPRINTERDRIVER",          SPOOLSS_ADDPRINTERDRIVER,          api_spoolss_addprinterdriver          },
+ {"SPOOLSS_DELETEPRINTERDRIVER",       SPOOLSS_DELETEPRINTERDRIVER,       api_spoolss_deleteprinterdriver       },
  {"SPOOLSS_GETPRINTERDRIVERDIRECTORY", SPOOLSS_GETPRINTERDRIVERDIRECTORY, api_spoolss_getprinterdriverdirectory },
  {"SPOOLSS_ENUMPRINTERDATA",           SPOOLSS_ENUMPRINTERDATA,           api_spoolss_enumprinterdata           },
  {"SPOOLSS_SETPRINTERDATA",            SPOOLSS_SETPRINTERDATA,            api_spoolss_setprinterdata            },
+ {"SPOOLSS_RESETPRINTER",              SPOOLSS_RESETPRINTER,              api_spoolss_reset_printer             },
  {"SPOOLSS_DELETEPRINTERDATA",         SPOOLSS_DELETEPRINTERDATA,         api_spoolss_deleteprinterdata         },
  {"SPOOLSS_ADDFORM",                   SPOOLSS_ADDFORM,                   api_spoolss_addform                   },
  {"SPOOLSS_DELETEFORM",                SPOOLSS_DELETEFORM,                api_spoolss_deleteform                },
  {"SPOOLSS_GETFORM",                   SPOOLSS_GETFORM,                   api_spoolss_getform                   },
  {"SPOOLSS_SETFORM",                   SPOOLSS_SETFORM,                   api_spoolss_setform                   },
+ {"SPOOLSS_ADDPRINTPROCESSOR",         SPOOLSS_ADDPRINTPROCESSOR,         api_spoolss_addprintprocessor         },
  {"SPOOLSS_ENUMPRINTPROCESSORS",       SPOOLSS_ENUMPRINTPROCESSORS,       api_spoolss_enumprintprocessors       },
  {"SPOOLSS_ENUMMONITORS",              SPOOLSS_ENUMMONITORS,              api_spoolss_enumprintmonitors         },
  {"SPOOLSS_GETJOB",                    SPOOLSS_GETJOB,                    api_spoolss_getjob                    },
  {"SPOOLSS_ENUMPRINTPROCDATATYPES",    SPOOLSS_ENUMPRINTPROCDATATYPES,    api_spoolss_enumprintprocdatatypes    },
- { NULL,                               0,                                 NULL                                  }
+ {"SPOOLSS_GETPRINTERDATAEX",          SPOOLSS_GETPRINTERDATAEX,          api_spoolss_getprinterdataex          },
+ {"SPOOLSS_SETPRINTERDATAEX",          SPOOLSS_SETPRINTERDATAEX,          api_spoolss_setprinterdataex          },
+ {"SPOOLSS_DELETEPRINTERDATAEX",       SPOOLSS_DELETEPRINTERDATAEX,       api_spoolss_deleteprinterdataex       },
+ {"SPOOLSS_ENUMPRINTERDATAEX",         SPOOLSS_ENUMPRINTERDATAEX,         api_spoolss_enumprinterdataex         },
+ {"SPOOLSS_ENUMPRINTERKEY",            SPOOLSS_ENUMPRINTERKEY,            api_spoolss_enumprinterkey            },
+ {"SPOOLSS_DELETEPRINTERKEY",          SPOOLSS_DELETEPRINTERKEY,          api_spoolss_deleteprinterkey          },
+ {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
+ {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
+ {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
+ {"SPOOLSS_XCVDATAPORT",               SPOOLSS_XCVDATAPORT,               api_spoolss_xcvdataport               },
 };
 
-/*******************************************************************
-receives a spoolss pipe and responds.
-********************************************************************/
-BOOL api_spoolss_rpc(pipes_struct *p)
+void spoolss_get_pipe_fns( struct api_struct **fns, int *n_fns )
+{
+       *fns = api_spoolss_cmds;
+       *n_fns = sizeof(api_spoolss_cmds) / sizeof(struct api_struct);
+}
+
+NTSTATUS rpc_spoolss_init(void)
 {
-       return api_rpcTNP(p, "api_spoolss_rpc", api_spoolss_cmds);
+  return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "spoolss", "spoolss", api_spoolss_cmds,
+                                   sizeof(api_spoolss_cmds) / sizeof(struct api_struct));
 }