Merge of incomplete rffpcnex testing code from APPLIANCE_HEAD.
authorTim Potter <tpot@samba.org>
Thu, 8 Aug 2002 04:58:19 +0000 (04:58 +0000)
committerTim Potter <tpot@samba.org>
Thu, 8 Aug 2002 04:58:19 +0000 (04:58 +0000)
(This used to be commit fe43c2ac2d2e1dd3b3a25c807d4dd379c5ac4960)

source3/rpc_client/cli_spoolss_notify.c
source3/rpc_parse/parse_spoolss.c
source3/rpc_server/srv_spoolss.c
source3/rpc_server/srv_spoolss_nt.c
source3/rpcclient/cmd_spoolss.c

index 922b0fbb1da8aa7350ed1a714158605d519aabe9..f03046558ee5a15ef5190928ac7c76f9736fd2bd 100644 (file)
@@ -221,3 +221,47 @@ done:
 
        return result;
 }
+
+WERROR cli_spoolss_rffpcnex(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+                           POLICY_HND *pol, uint32 flags, uint32 options,
+                           char *localmachine, uint32 printerlocal,
+                           SPOOL_NOTIFY_OPTION *option)
+{
+       prs_struct qbuf, rbuf;
+       SPOOL_Q_RFFPCNEX q;
+       SPOOL_R_RFFPCNEX r;
+       WERROR result = W_ERROR(ERRgeneral);
+
+       ZERO_STRUCT(q);
+       ZERO_STRUCT(r);
+
+       /* Initialise parse structures */
+
+       prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+       prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+       /* Initialise input parameters */
+
+       make_spoolss_q_rffpcnex(
+               &q, pol, flags, options, localmachine, printerlocal,
+               option);
+
+       /* Marshall data and send request */
+
+       if(!spoolss_io_q_rffpcnex("", &q,  &qbuf, 0) ||
+          !rpc_api_pipe_req(cli, SPOOLSS_RFFPCNEX, &qbuf, &rbuf)) 
+               goto done;
+
+       /* Unmarshall response */
+       
+       if(!spoolss_io_r_rffpcnex("", &r, &rbuf, 0))
+               goto done;
+
+       result = r.status;
+
+done:
+       prs_mem_free(&qbuf);
+       prs_mem_free(&rbuf);
+
+       return result;
+}
index bc1691d26baeb83079a8cc38c4845abb0a7fdb03..ab8c4e1ab6d543051c8a1247ae21806eac0ceec2 100644 (file)
@@ -7528,3 +7528,31 @@ BOOL make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA *q_u,
 
        return True;
 }
+
+/*******************************************************************
+ * init a structure.
+ ********************************************************************/
+
+BOOL make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, POLICY_HND *handle,
+                            uint32 flags, uint32 options, char *localmachine,
+                            uint32 printerlocal, SPOOL_NOTIFY_OPTION *option)
+{
+        memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
+
+       q_u->flags = flags;
+       q_u->options = options;
+
+       q_u->localmachine_ptr = 1;
+
+       init_unistr2(&q_u->localmachine, localmachine, 
+                    strlen(localmachine) + 1);
+
+       q_u->printerlocal = printerlocal;
+
+       if (option)
+               q_u->option_ptr = 1;
+
+       q_u->option = option;
+
+       return True;
+}
index 6e3463e79bd3b7edaec74adb94d1547a9275f502..5924c5831bc5939d39f6e6d280c73c3ea2904d5c 100755 (executable)
@@ -1515,6 +1515,65 @@ static BOOL api_spoolss_deleteprinterdriverex(pipes_struct *p)
        return True;
 }
 
+#if 0
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_replyopenprinter(pipes_struct *p)
+{
+       SPOOL_Q_REPLYOPENPRINTER q_u;
+       SPOOL_R_REPLYOPENPRINTER 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_replyopenprinter("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_replyopenprinter: unable to unmarshall SPOOL_Q_REPLYOPENPRINTER.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_replyopenprinter(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_replyopenprinter("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_replyopenprinter: unable to marshall SPOOL_R_REPLYOPENPRINTER.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
+/****************************************************************************
+****************************************************************************/
+
+static BOOL api_spoolss_replycloseprinter(pipes_struct *p)
+{
+       SPOOL_Q_REPLYCLOSEPRINTER q_u;
+       SPOOL_R_REPLYCLOSEPRINTER 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_replycloseprinter("", &q_u, data, 0)) {
+               DEBUG(0,("spoolss_io_q_replycloseprinter: unable to unmarshall SPOOL_Q_REPLYCLOSEPRINTER.\n"));
+               return False;
+       }
+       
+       r_u.status = _spoolss_replycloseprinter(p, &q_u, &r_u);
+                               
+       if(!spoolss_io_r_replycloseprinter("", &r_u, rdata, 0)) {
+               DEBUG(0,("spoolss_io_r_replycloseprinter: unable to marshall SPOOL_R_REPLYCLOSEPRINTER.\n"));
+               return False;
+       }
+       
+       return True;
+}
+
+#endif
 
 /*******************************************************************
 \pipe\spoolss commands
@@ -1573,6 +1632,10 @@ struct api_struct api_spoolss_cmds[] =
  {"SPOOLSS_GETPRINTPROCESSORDIRECTORY",SPOOLSS_GETPRINTPROCESSORDIRECTORY,api_spoolss_getprintprocessordirectory},
  {"SPOOLSS_ADDPRINTERDRIVEREX",        SPOOLSS_ADDPRINTERDRIVEREX,        api_spoolss_addprinterdriverex        },
  {"SPOOLSS_DELETEPRINTERDRIVEREX",     SPOOLSS_DELETEPRINTERDRIVEREX,     api_spoolss_deleteprinterdriverex     },
+#if 0
+ {"SPOOLSS_REPLYOPENPRINTER",          SPOOLSS_REPLYOPENPRINTER,          api_spoolss_replyopenprinter          },
+ {"SPOOLSS_REPLYCLOSEPRINTER",         SPOOLSS_REPLYCLOSEPRINTER,         api_spoolss_replycloseprinter         },
+#endif
  { NULL,                               0,                                 NULL                                  }
 };
 
index 20a586a6fb487636580b9930dfd14e8e65730a98..558a7a47d767b11083df6d7af359b7cd00686e65 100644 (file)
@@ -8372,3 +8372,24 @@ WERROR _spoolss_getprintprocessordirectory(pipes_struct *p, SPOOL_Q_GETPRINTPROC
 
        return result;
 }
+
+#if 0
+
+WERROR _spoolss_replyopenprinter(pipes_struct *p, SPOOL_Q_REPLYOPENPRINTER *q_u, 
+                                SPOOL_R_REPLYOPENPRINTER *r_u)
+{
+       DEBUG(5,("_spoolss_replyopenprinter\n"));
+
+       DEBUG(10, ("replyopenprinter for localprinter %d\n", q_u->printer));
+
+       return WERR_OK;
+}
+
+WERROR _spoolss_replycloseprinter(pipes_struct *p, SPOOL_Q_REPLYCLOSEPRINTER *q_u, 
+                                 SPOOL_R_REPLYCLOSEPRINTER *r_u)
+{
+       DEBUG(5,("_spoolss_replycloseprinter\n"));
+       return WERR_OK;
+}
+
+#endif
index 47e3f123ba76e86774d3404f350af99a8437a79f..22e2db41f313e156e57355eeeeecddb6c2bca9b1 100644 (file)
@@ -1796,6 +1796,85 @@ done:
        return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
 }
 
+static NTSTATUS cmd_spoolss_rffpcnex(struct cli_state *cli, 
+                                    TALLOC_CTX *mem_ctx, int argc, 
+                                    char **argv)
+{
+       fstring servername, printername;
+       POLICY_HND hnd;
+       BOOL got_hnd = False;
+       WERROR result;
+       SPOOL_NOTIFY_OPTION option;
+
+       if (argc != 2) {
+               printf("Usage: %s printername\n", argv[0]);
+               result = WERR_OK;
+               goto done;
+       }
+
+       /* Open printer */
+
+       slprintf(servername, sizeof(fstring) - 1, "\\\\%s", cli->desthost);
+       strupper(servername);
+
+       slprintf(printername, sizeof(fstring) - 1, "\\\\%s\\%s", cli->desthost,
+                argv[1]);
+       strupper(printername);
+
+       result = cli_spoolss_open_printer_ex(
+               cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, 
+               servername, cli->user_name, &hnd);
+
+       if (!W_ERROR_IS_OK(result)) {
+               printf("Error opening %s\n", argv[1]);
+               goto done;
+       }
+
+       got_hnd = True;
+
+       /* Create spool options */
+
+       ZERO_STRUCT(option);
+
+       option.version = 2;
+       option.option_type_ptr = 1;
+       option.count = option.ctr.count = 2;
+
+       option.ctr.type = (SPOOL_NOTIFY_OPTION_TYPE *)talloc(
+               mem_ctx, sizeof(SPOOL_NOTIFY_OPTION_TYPE) * 2);
+
+       ZERO_STRUCT(option.ctr.type[0]);
+       option.ctr.type[0].type = PRINTER_NOTIFY_TYPE;
+       option.ctr.type[0].count = option.ctr.type[0].count2 = 1;
+       option.ctr.type[0].fields_ptr = 1;
+       option.ctr.type[0].fields[0] = PRINTER_NOTIFY_SERVER_NAME;
+
+       ZERO_STRUCT(option.ctr.type[1]);
+       option.ctr.type[1].type = JOB_NOTIFY_TYPE;
+       option.ctr.type[1].count = option.ctr.type[1].count2 = 1;
+       option.ctr.type[1].fields_ptr = 1;
+       option.ctr.type[1].fields[0] = JOB_NOTIFY_PRINTER_NAME;
+
+       /* Send rffpcnex */
+
+       slprintf(servername, sizeof(fstring) - 1, "\\\\%s", myhostname());
+       strupper(servername);
+
+       result = cli_spoolss_rffpcnex(
+               cli, mem_ctx, &hnd, 0, 0, servername, 123, &option);
+
+       if (!W_ERROR_IS_OK(result)) {
+               printf("Error rffpcnex %s\n", argv[1]);
+               goto done;
+       }
+
+done:          
+       if (got_hnd)
+               cli_spoolss_close_printer(cli, mem_ctx, &hnd);
+
+       return W_ERROR_IS_OK(result) ? NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL;
+}
+
 /* List of commands exported by this module */
 struct cmd_set spoolss_commands[] = {
 
@@ -1824,6 +1903,7 @@ struct cmd_set spoolss_commands[] = {
        { "enumforms",          cmd_spoolss_enum_forms,         PIPE_SPOOLSS, "Enumerate forms",                     "" },
        { "setprinter",         cmd_spoolss_setprinter,         PIPE_SPOOLSS, "Set printer comment",                 "" },
        { "setprinterdata",     cmd_spoolss_setprinterdata,     PIPE_SPOOLSS, "Set REG_SZ printer data",             "" },
+       { "rffpcnex",           cmd_spoolss_rffpcnex,           PIPE_SPOOLSS, "Rffpcnex test", "" },
 
        { NULL }
 };