Sync with HEAD to get enumprinterkey api.
authorJim McDonough <jmcd@samba.org>
Fri, 8 Nov 2002 20:36:31 +0000 (20:36 +0000)
committerJim McDonough <jmcd@samba.org>
Fri, 8 Nov 2002 20:36:31 +0000 (20:36 +0000)
source/rpc_client/cli_spoolss.c
source/rpc_parse/parse_spoolss.c

index 92077f963779ecfd98eacc8fa29d6663f1ed346c..15a3db389e562a19d9493214390dd9c3e35fc96c 100644 (file)
@@ -2362,4 +2362,104 @@ WERROR cli_spoolss_deleteprinterdataex(struct cli_state *cli, TALLOC_CTX *mem_ct
        return result;
 }
 
+WERROR cli_spoolss_enumprinterkey(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+                                 uint32 offered, uint32 *needed,
+                                 POLICY_HND *hnd, char *keyname,
+                                 uint16 **keylist, uint32 *len)
+{
+       prs_struct qbuf, rbuf;
+       SPOOL_Q_ENUMPRINTERKEY q;
+       SPOOL_R_ENUMPRINTERKEY 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_enumprinterkey(&q, hnd, keyname, offered);
+
+       /* Marshall data and send request */
+
+       if (!spoolss_io_q_enumprinterkey("", &q, &qbuf, 0) ||
+           !rpc_api_pipe_req(cli, SPOOLSS_ENUMPRINTERKEY, &qbuf, &rbuf))
+               goto done;
+
+       /* Unmarshall response */
+
+       if (!spoolss_io_r_enumprinterkey("", &r, &rbuf, 0))
+               goto done;
+       
+       result = r.status;
+
+       if (needed)
+               *needed = r.needed;
+
+       if (!W_ERROR_IS_OK(r.status))
+               goto done;      
+
+       /* Copy results */
+       
+       if (keylist) {
+               *keylist = (uint16 *)malloc(r.keys.buf_len * 2);
+               memcpy(*keylist, r.keys.buffer, r.keys.buf_len * 2);
+               if (len)
+                       *len = r.keys.buf_len * 2;
+       }
+
+ done:
+       prs_mem_free(&qbuf);
+       prs_mem_free(&rbuf);
+
+       return result;  
+}
+
+WERROR cli_spoolss_deleteprinterkey(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+                                   POLICY_HND *hnd, char *keyname)
+{
+       prs_struct qbuf, rbuf;
+       SPOOL_Q_DELETEPRINTERKEY q;
+       SPOOL_R_DELETEPRINTERKEY 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_deleteprinterkey(&q, hnd, keyname);
+
+       /* Marshall data and send request */
+
+       if (!spoolss_io_q_deleteprinterkey("", &q, &qbuf, 0) ||
+           !rpc_api_pipe_req(cli, SPOOLSS_DELETEPRINTERKEY, &qbuf, &rbuf))
+               goto done;
+
+       /* Unmarshall response */
+
+       if (!spoolss_io_r_deleteprinterkey("", &r, &rbuf, 0))
+               goto done;
+       
+       result = r.status;
+
+       if (!W_ERROR_IS_OK(r.status))
+               goto done;      
+
+ done:
+       prs_mem_free(&qbuf);
+       prs_mem_free(&rbuf);
+
+       return result;          
+}
+
 /** @} **/
index d8cd7c17296b9a0475688fa000567e6c2aca596e..91322a8fae18d560a6e2073b63ff779d6736d3bb 100644 (file)
@@ -7014,6 +7014,20 @@ BOOL spoolss_io_r_setprinterdataex(char *desc, SPOOL_R_SETPRINTERDATAEX *r_u, pr
        return True;
 }
 
+/*******************************************************************
+ * read a structure.
+ ********************************************************************/  
+BOOL make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u, 
+                                  POLICY_HND *hnd, char *key, uint32 size)
+{
+       DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
+
+       memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+       init_unistr2(&q_u->key, key, strlen(key)+1);
+       q_u->size = size;
+
+       return True;
+}
 
 /*******************************************************************
  * read a structure.
@@ -7068,6 +7082,21 @@ BOOL spoolss_io_r_enumprinterkey(char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_st
        return True;
 }
 
+/*******************************************************************
+ * read a structure.
+ ********************************************************************/  
+
+BOOL make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY *q_u, 
+                                    POLICY_HND *hnd, char *keyname)
+{
+       DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
+
+       memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
+       init_unistr2(&q_u->keyname, keyname, strlen(keyname)+1);
+
+       return True;
+}
+
 /*******************************************************************
  * read a structure.
  ********************************************************************/