spoolss: rework spoolss_GetPrinterDataEx and spoolss_SetPrinterDataEx.
authorGünther Deschner <gd@samba.org>
Fri, 4 Dec 2009 23:50:18 +0000 (00:50 +0100)
committerGünther Deschner <gd@samba.org>
Mon, 7 Dec 2009 13:42:12 +0000 (14:42 +0100)
Guenther

librpc/gen_ndr/cli_spoolss.c
librpc/gen_ndr/cli_spoolss.h
librpc/gen_ndr/ndr_spoolss.c
librpc/gen_ndr/ndr_spoolss.h
librpc/gen_ndr/spoolss.h
librpc/gen_ndr/srv_spoolss.c
librpc/idl/spoolss.idl
librpc/ndr/ndr_spoolss_buf.c
librpc/ndr/ndr_spoolss_buf.h

index 0a5c2a6eb7fc62850aa21059df1cbc9def134f48..e63a78195f6b715f1c56fd8a658d2f62c5a4c325 100644 (file)
@@ -11710,8 +11710,8 @@ struct tevent_req *rpccli_spoolss_SetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
                                                        const char *_key_name /* [in] [charset(UTF16)] */,
                                                        const char *_value_name /* [in] [charset(UTF16)] */,
                                                        enum winreg_Type _type /* [in]  */,
-                                                       uint8_t *_buffer /* [in] [ref,size_is(offered)] */,
-                                                       uint32_t _offered /* [in]  */)
+                                                       union spoolss_PrinterData _data /* [in] [subcontext(4),switch_is(type)] */,
+                                                       uint32_t __offered /* [in] [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */)
 {
        struct tevent_req *req;
        struct rpccli_spoolss_SetPrinterDataEx_state *state;
@@ -11730,8 +11730,8 @@ struct tevent_req *rpccli_spoolss_SetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
        state->orig.in.key_name = _key_name;
        state->orig.in.value_name = _value_name;
        state->orig.in.type = _type;
-       state->orig.in.buffer = _buffer;
-       state->orig.in.offered = _offered;
+       state->orig.in.data = _data;
+       state->orig.in._offered = __offered;
 
        /* Out parameters */
 
@@ -11814,8 +11814,8 @@ NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli,
                                         const char *key_name /* [in] [charset(UTF16)] */,
                                         const char *value_name /* [in] [charset(UTF16)] */,
                                         enum winreg_Type type /* [in]  */,
-                                        uint8_t *buffer /* [in] [ref,size_is(offered)] */,
-                                        uint32_t offered /* [in]  */,
+                                        union spoolss_PrinterData data /* [in] [subcontext(4),switch_is(type)] */,
+                                        uint32_t _offered /* [in] [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */,
                                         WERROR *werror)
 {
        struct spoolss_SetPrinterDataEx r;
@@ -11826,8 +11826,8 @@ NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli,
        r.in.key_name = key_name;
        r.in.value_name = value_name;
        r.in.type = type;
-       r.in.buffer = buffer;
-       r.in.offered = offered;
+       r.in.data = data;
+       r.in._offered = _offered;
 
        status = cli->dispatch(cli,
                                mem_ctx,
@@ -11868,9 +11868,9 @@ struct tevent_req *rpccli_spoolss_GetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
                                                        struct policy_handle *_handle /* [in] [ref] */,
                                                        const char *_key_name /* [in] [charset(UTF16)] */,
                                                        const char *_value_name /* [in] [charset(UTF16)] */,
-                                                       enum winreg_Type *_type /* [out] [ref] */,
-                                                       uint8_t *_buffer /* [out] [ref,size_is(offered)] */,
                                                        uint32_t _offered /* [in]  */,
+                                                       enum winreg_Type *_type /* [out] [ref] */,
+                                                       union spoolss_PrinterData *_data /* [out] [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */,
                                                        uint32_t *_needed /* [out] [ref] */)
 {
        struct tevent_req *req;
@@ -11893,7 +11893,7 @@ struct tevent_req *rpccli_spoolss_GetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
 
        /* Out parameters */
        state->orig.out.type = _type;
-       state->orig.out.buffer = _buffer;
+       state->orig.out.data = _data;
        state->orig.out.needed = _needed;
 
        /* Result */
@@ -11943,7 +11943,7 @@ static void rpccli_spoolss_GetPrinterDataEx_done(struct tevent_req *subreq)
 
        /* Copy out parameters */
        *state->orig.out.type = *state->tmp.out.type;
-       memcpy(state->orig.out.buffer, state->tmp.out.buffer, (state->tmp.in.offered) * sizeof(*state->orig.out.buffer));
+       *state->orig.out.data = *state->tmp.out.data;
        *state->orig.out.needed = *state->tmp.out.needed;
 
        /* Copy result */
@@ -11983,9 +11983,9 @@ NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli,
                                         struct policy_handle *handle /* [in] [ref] */,
                                         const char *key_name /* [in] [charset(UTF16)] */,
                                         const char *value_name /* [in] [charset(UTF16)] */,
-                                        enum winreg_Type *type /* [out] [ref] */,
-                                        uint8_t *buffer /* [out] [ref,size_is(offered)] */,
                                         uint32_t offered /* [in]  */,
+                                        enum winreg_Type *type /* [out] [ref] */,
+                                        union spoolss_PrinterData *data /* [out] [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */,
                                         uint32_t *needed /* [out] [ref] */,
                                         WERROR *werror)
 {
@@ -12014,7 +12014,7 @@ NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli,
 
        /* Return variables */
        *type = *r.out.type;
-       memcpy(buffer, r.out.buffer, (r.in.offered) * sizeof(*buffer));
+       *data = *r.out.data;
        *needed = *r.out.needed;
 
        /* Return result */
index 58a45ee672f7ed82216737a0d9f1c926c840cb49..f2c13536282a8285c59fca1abeecdd7e725ee7de 100644 (file)
@@ -1199,8 +1199,8 @@ struct tevent_req *rpccli_spoolss_SetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
                                                        const char *_key_name /* [in] [charset(UTF16)] */,
                                                        const char *_value_name /* [in] [charset(UTF16)] */,
                                                        enum winreg_Type _type /* [in]  */,
-                                                       uint8_t *_buffer /* [in] [ref,size_is(offered)] */,
-                                                       uint32_t _offered /* [in]  */);
+                                                       union spoolss_PrinterData _data /* [in] [subcontext(4),switch_is(type)] */,
+                                                       uint32_t __offered /* [in] [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */);
 NTSTATUS rpccli_spoolss_SetPrinterDataEx_recv(struct tevent_req *req,
                                              TALLOC_CTX *mem_ctx,
                                              WERROR *result);
@@ -1210,8 +1210,8 @@ NTSTATUS rpccli_spoolss_SetPrinterDataEx(struct rpc_pipe_client *cli,
                                         const char *key_name /* [in] [charset(UTF16)] */,
                                         const char *value_name /* [in] [charset(UTF16)] */,
                                         enum winreg_Type type /* [in]  */,
-                                        uint8_t *buffer /* [in] [ref,size_is(offered)] */,
-                                        uint32_t offered /* [in]  */,
+                                        union spoolss_PrinterData data /* [in] [subcontext(4),switch_is(type)] */,
+                                        uint32_t _offered /* [in] [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */,
                                         WERROR *werror);
 struct tevent_req *rpccli_spoolss_GetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
                                                        struct tevent_context *ev,
@@ -1219,9 +1219,9 @@ struct tevent_req *rpccli_spoolss_GetPrinterDataEx_send(TALLOC_CTX *mem_ctx,
                                                        struct policy_handle *_handle /* [in] [ref] */,
                                                        const char *_key_name /* [in] [charset(UTF16)] */,
                                                        const char *_value_name /* [in] [charset(UTF16)] */,
-                                                       enum winreg_Type *_type /* [out] [ref] */,
-                                                       uint8_t *_buffer /* [out] [ref,size_is(offered)] */,
                                                        uint32_t _offered /* [in]  */,
+                                                       enum winreg_Type *_type /* [out] [ref] */,
+                                                       union spoolss_PrinterData *_data /* [out] [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */,
                                                        uint32_t *_needed /* [out] [ref] */);
 NTSTATUS rpccli_spoolss_GetPrinterDataEx_recv(struct tevent_req *req,
                                              TALLOC_CTX *mem_ctx,
@@ -1231,9 +1231,9 @@ NTSTATUS rpccli_spoolss_GetPrinterDataEx(struct rpc_pipe_client *cli,
                                         struct policy_handle *handle /* [in] [ref] */,
                                         const char *key_name /* [in] [charset(UTF16)] */,
                                         const char *value_name /* [in] [charset(UTF16)] */,
-                                        enum winreg_Type *type /* [out] [ref] */,
-                                        uint8_t *buffer /* [out] [ref,size_is(offered)] */,
                                         uint32_t offered /* [in]  */,
+                                        enum winreg_Type *type /* [out] [ref] */,
+                                        union spoolss_PrinterData *data /* [out] [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */,
                                         uint32_t *needed /* [out] [ref] */,
                                         WERROR *werror);
 struct tevent_req *rpccli_spoolss_EnumPrinterDataEx_send(TALLOC_CTX *mem_ctx,
index f783a834ee751ad1bc5e2a7369a6ab4ec7914026..eba51dce91a59889a190039a7200640cae104d52 100644 (file)
@@ -27662,7 +27662,7 @@ _PUBLIC_ void ndr_print_spoolss_4c(struct ndr_print *ndr, const char *name, int
        ndr->depth--;
 }
 
-static enum ndr_err_code ndr_push_spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterDataEx *r)
+_PUBLIC_ enum ndr_err_code ndr_push__spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct _spoolss_SetPrinterDataEx *r)
 {
        if (flags & NDR_IN) {
                if (r->in.handle == NULL) {
@@ -27678,12 +27678,8 @@ static enum ndr_err_code ndr_push_spoolss_SetPrinterDataEx(struct ndr_push *ndr,
                NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, ndr_charset_length(r->in.value_name, CH_UTF16)));
                NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->in.value_name, ndr_charset_length(r->in.value_name, CH_UTF16), sizeof(uint16_t), CH_UTF16));
                NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type));
-               if (r->in.buffer == NULL) {
-                       return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
-               }
-               NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->in.offered));
-               NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->in.buffer, r->in.offered));
-               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in.offered));
+               NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->in.data));
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->in._offered));
        }
        if (flags & NDR_OUT) {
                NDR_CHECK(ndr_push_WERROR(ndr, NDR_SCALARS, r->out.result));
@@ -27691,6 +27687,21 @@ static enum ndr_err_code ndr_push_spoolss_SetPrinterDataEx(struct ndr_push *ndr,
        return NDR_ERR_SUCCESS;
 }
 
+_PUBLIC_ enum ndr_err_code ndr_push___spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct __spoolss_SetPrinterDataEx *r)
+{
+       if (flags & NDR_IN) {
+               NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type));
+       }
+       if (flags & NDR_OUT) {
+               if (r->out.data == NULL) {
+                       return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
+               }
+               NDR_CHECK(ndr_push_set_switch_value(ndr, r->out.data, r->in.type));
+               NDR_CHECK(ndr_push_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.data));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
 static enum ndr_err_code ndr_pull_spoolss_SetPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_SetPrinterDataEx *r)
 {
        TALLOC_CTX *_mem_save_handle_0;
@@ -27717,15 +27728,14 @@ static enum ndr_err_code ndr_pull_spoolss_SetPrinterDataEx(struct ndr_pull *ndr,
                NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t)));
                NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->in.value_name, ndr_get_array_length(ndr, &r->in.value_name), sizeof(uint16_t), CH_UTF16));
                NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, &r->in.type));
-               NDR_CHECK(ndr_pull_array_size(ndr, &r->in.buffer));
-               if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
-                       NDR_PULL_ALLOC_N(ndr, r->in.buffer, ndr_get_array_size(ndr, &r->in.buffer));
-               }
-               NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->in.buffer, ndr_get_array_size(ndr, &r->in.buffer)));
-               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered));
-               if (r->in.buffer) {
-                       NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->in.buffer, r->in.offered));
+               {
+                       struct ndr_pull *_ndr_data;
+                       NDR_CHECK(ndr_pull_subcontext_start(ndr, &_ndr_data, 4, -1));
+                       NDR_CHECK(ndr_pull_set_switch_value(_ndr_data, &r->in.data, r->in.type));
+                       NDR_CHECK(ndr_pull_spoolss_PrinterData(_ndr_data, NDR_SCALARS|NDR_BUFFERS, &r->in.data));
+                       NDR_CHECK(ndr_pull_subcontext_end(ndr, _ndr_data, 4, -1));
                }
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in._offered));
        }
        if (flags & NDR_OUT) {
                NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result));
@@ -27750,11 +27760,9 @@ _PUBLIC_ void ndr_print_spoolss_SetPrinterDataEx(struct ndr_print *ndr, const ch
                ndr_print_string(ndr, "key_name", r->in.key_name);
                ndr_print_string(ndr, "value_name", r->in.value_name);
                ndr_print_winreg_Type(ndr, "type", r->in.type);
-               ndr_print_ptr(ndr, "buffer", r->in.buffer);
-               ndr->depth++;
-               ndr_print_array_uint8(ndr, "buffer", r->in.buffer, r->in.offered);
-               ndr->depth--;
-               ndr_print_uint32(ndr, "offered", r->in.offered);
+               ndr_print_set_switch_value(ndr, &r->in.data, r->in.type);
+               ndr_print_spoolss_PrinterData(ndr, "data", &r->in.data);
+               ndr_print_uint32(ndr, "_offered", (ndr->flags & LIBNDR_PRINT_SET_VALUES)?ndr_size_spoolss_PrinterData(&r->in.data, r->in.type, ndr->iconv_convenience, flags):r->in._offered);
                ndr->depth--;
        }
        if (flags & NDR_OUT) {
@@ -27766,7 +27774,7 @@ _PUBLIC_ void ndr_print_spoolss_SetPrinterDataEx(struct ndr_print *ndr, const ch
        ndr->depth--;
 }
 
-static enum ndr_err_code ndr_push_spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDataEx *r)
+_PUBLIC_ enum ndr_err_code ndr_push__spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct _spoolss_GetPrinterDataEx *r)
 {
        if (flags & NDR_IN) {
                if (r->in.handle == NULL) {
@@ -27788,11 +27796,10 @@ static enum ndr_err_code ndr_push_spoolss_GetPrinterDataEx(struct ndr_push *ndr,
                        return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
                }
                NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, *r->out.type));
-               if (r->out.buffer == NULL) {
+               if (r->out.data == NULL) {
                        return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
                }
-               NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, r->in.offered));
-               NDR_CHECK(ndr_push_array_uint8(ndr, NDR_SCALARS, r->out.buffer, r->in.offered));
+               NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, *r->out.data));
                if (r->out.needed == NULL) {
                        return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
                }
@@ -27802,10 +27809,11 @@ static enum ndr_err_code ndr_push_spoolss_GetPrinterDataEx(struct ndr_push *ndr,
        return NDR_ERR_SUCCESS;
 }
 
-static enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDataEx *r)
+_PUBLIC_ enum ndr_err_code ndr_pull__spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct _spoolss_GetPrinterDataEx *r)
 {
        TALLOC_CTX *_mem_save_handle_0;
        TALLOC_CTX *_mem_save_type_0;
+       TALLOC_CTX *_mem_save_data_0;
        TALLOC_CTX *_mem_save_needed_0;
        if (flags & NDR_IN) {
                ZERO_STRUCT(r->out);
@@ -27834,8 +27842,8 @@ static enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr,
                NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->in.offered));
                NDR_PULL_ALLOC(ndr, r->out.type);
                ZERO_STRUCTP(r->out.type);
-               NDR_PULL_ALLOC_N(ndr, r->out.buffer, r->in.offered);
-               memset(r->out.buffer, 0, (r->in.offered) * sizeof(*r->out.buffer));
+               NDR_PULL_ALLOC(ndr, r->out.data);
+               ZERO_STRUCTP(r->out.data);
                NDR_PULL_ALLOC(ndr, r->out.needed);
                ZERO_STRUCTP(r->out.needed);
        }
@@ -27847,11 +27855,13 @@ static enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr,
                NDR_PULL_SET_MEM_CTX(ndr, r->out.type, LIBNDR_FLAG_REF_ALLOC);
                NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, r->out.type));
                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_type_0, LIBNDR_FLAG_REF_ALLOC);
-               NDR_CHECK(ndr_pull_array_size(ndr, &r->out.buffer));
                if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
-                       NDR_PULL_ALLOC_N(ndr, r->out.buffer, ndr_get_array_size(ndr, &r->out.buffer));
+                       NDR_PULL_ALLOC(ndr, r->out.data);
                }
-               NDR_CHECK(ndr_pull_array_uint8(ndr, NDR_SCALARS, r->out.buffer, ndr_get_array_size(ndr, &r->out.buffer)));
+               _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr);
+               NDR_PULL_SET_MEM_CTX(ndr, r->out.data, LIBNDR_FLAG_REF_ALLOC);
+               NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, r->out.data));
+               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, LIBNDR_FLAG_REF_ALLOC);
                if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
                        NDR_PULL_ALLOC(ndr, r->out.needed);
                }
@@ -27860,9 +27870,44 @@ static enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr,
                NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, r->out.needed));
                NDR_PULL_SET_MEM_CTX(ndr, _mem_save_needed_0, LIBNDR_FLAG_REF_ALLOC);
                NDR_CHECK(ndr_pull_WERROR(ndr, NDR_SCALARS, &r->out.result));
-               if (r->out.buffer) {
-                       NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->out.buffer, r->in.offered));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push___spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct __spoolss_GetPrinterDataEx *r)
+{
+       if (flags & NDR_IN) {
+               NDR_CHECK(ndr_push_winreg_Type(ndr, NDR_SCALARS, r->in.type));
+       }
+       if (flags & NDR_OUT) {
+               if (r->out.data == NULL) {
+                       return ndr_push_error(ndr, NDR_ERR_INVALID_POINTER, "NULL [ref] pointer");
                }
+               NDR_CHECK(ndr_push_set_switch_value(ndr, r->out.data, r->in.type));
+               NDR_CHECK(ndr_push_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.data));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull___spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct __spoolss_GetPrinterDataEx *r)
+{
+       TALLOC_CTX *_mem_save_data_0;
+       if (flags & NDR_IN) {
+               ZERO_STRUCT(r->out);
+
+               NDR_CHECK(ndr_pull_winreg_Type(ndr, NDR_SCALARS, &r->in.type));
+               NDR_PULL_ALLOC(ndr, r->out.data);
+               ZERO_STRUCTP(r->out.data);
+       }
+       if (flags & NDR_OUT) {
+               if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+                       NDR_PULL_ALLOC(ndr, r->out.data);
+               }
+               _mem_save_data_0 = NDR_PULL_GET_MEM_CTX(ndr);
+               NDR_PULL_SET_MEM_CTX(ndr, r->out.data, LIBNDR_FLAG_REF_ALLOC);
+               NDR_CHECK(ndr_pull_set_switch_value(ndr, r->out.data, r->in.type));
+               NDR_CHECK(ndr_pull_spoolss_PrinterData(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.data));
+               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_data_0, LIBNDR_FLAG_REF_ALLOC);
        }
        return NDR_ERR_SUCCESS;
 }
@@ -27893,9 +27938,10 @@ _PUBLIC_ void ndr_print_spoolss_GetPrinterDataEx(struct ndr_print *ndr, const ch
                ndr->depth++;
                ndr_print_winreg_Type(ndr, "type", *r->out.type);
                ndr->depth--;
-               ndr_print_ptr(ndr, "buffer", r->out.buffer);
+               ndr_print_ptr(ndr, "data", r->out.data);
                ndr->depth++;
-               ndr_print_array_uint8(ndr, "buffer", r->out.buffer, r->in.offered);
+               ndr_print_set_switch_value(ndr, r->out.data, *r->out.type);
+               ndr_print_spoolss_PrinterData(ndr, "data", r->out.data);
                ndr->depth--;
                ndr_print_ptr(ndr, "needed", r->out.needed);
                ndr->depth++;
index 895e1e9a37094bccfb1c532ac291c37a89b59006..1c31a95ef4a19fc8b726e3ff0572e7c2869efd20 100644 (file)
@@ -716,7 +716,22 @@ void ndr_print_spoolss_DeletePrinterData(struct ndr_print *ndr, const char *name
 void ndr_print_spoolss_4a(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4a *r);
 void ndr_print_spoolss_4b(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4b *r);
 void ndr_print_spoolss_4c(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_4c *r);
+enum ndr_err_code ndr_push__spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct _spoolss_SetPrinterDataEx *r);
+enum ndr_err_code ndr_pull__spoolss_SetPrinterDataEx(struct ndr_pull *ndr, int flags, struct _spoolss_SetPrinterDataEx *r);
+void ndr_print__spoolss_SetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_SetPrinterDataEx *r);
+enum ndr_err_code ndr_push___spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct __spoolss_SetPrinterDataEx *r);
+enum ndr_err_code ndr_pull___spoolss_SetPrinterDataEx(struct ndr_pull *ndr, int flags, struct __spoolss_SetPrinterDataEx *r);
+void ndr_print___spoolss_SetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_SetPrinterDataEx *r);
+enum ndr_err_code ndr_push_spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterDataEx *r);
 void ndr_print_spoolss_SetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_SetPrinterDataEx *r);
+enum ndr_err_code ndr_push__spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct _spoolss_GetPrinterDataEx *r);
+enum ndr_err_code ndr_pull__spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct _spoolss_GetPrinterDataEx *r);
+void ndr_print__spoolss_GetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct _spoolss_GetPrinterDataEx *r);
+enum ndr_err_code ndr_push___spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct __spoolss_GetPrinterDataEx *r);
+enum ndr_err_code ndr_pull___spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct __spoolss_GetPrinterDataEx *r);
+void ndr_print___spoolss_GetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct __spoolss_GetPrinterDataEx *r);
+enum ndr_err_code ndr_push_spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDataEx *r);
+enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDataEx *r);
 void ndr_print_spoolss_GetPrinterDataEx(struct ndr_print *ndr, const char *name, int flags, const struct spoolss_GetPrinterDataEx *r);
 enum ndr_err_code ndr_push__spoolss_EnumPrinterDataEx(struct ndr_push *ndr, int flags, const struct _spoolss_EnumPrinterDataEx *r);
 enum ndr_err_code ndr_pull__spoolss_EnumPrinterDataEx(struct ndr_pull *ndr, int flags, struct _spoolss_EnumPrinterDataEx *r);
index e209cb464b8d206b6ef2885cb265f2f93e8963fe..d6c267c82a2153fa85f73432a40ff599ba5957b9 100644 (file)
@@ -3468,23 +3468,82 @@ struct spoolss_4c {
 };
 
 
+struct _spoolss_SetPrinterDataEx {
+       struct {
+               struct policy_handle *handle;/* [ref] */
+               const char *key_name;/* [charset(UTF16)] */
+               const char *value_name;/* [charset(UTF16)] */
+               enum winreg_Type type;
+               DATA_BLOB data;
+               uint32_t _offered;
+       } in;
+
+       struct {
+               WERROR result;
+       } out;
+
+};
+
+
+struct __spoolss_SetPrinterDataEx {
+       struct {
+               enum winreg_Type type;
+       } in;
+
+       struct {
+               union spoolss_PrinterData *data;/* [ref,switch_is(type)] */
+       } out;
+
+};
+
+
 struct spoolss_SetPrinterDataEx {
        struct {
                struct policy_handle *handle;/* [ref] */
                const char *key_name;/* [charset(UTF16)] */
                const char *value_name;/* [charset(UTF16)] */
                enum winreg_Type type;
-               uint8_t *buffer;/* [ref,size_is(offered)] */
+               union spoolss_PrinterData data;/* [subcontext(4),switch_is(type)] */
+               uint32_t _offered;/* [value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] */
+       } in;
+
+       struct {
+               WERROR result;
+       } out;
+
+};
+
+
+struct _spoolss_GetPrinterDataEx {
+       struct {
+               struct policy_handle *handle;/* [ref] */
+               const char *key_name;/* [charset(UTF16)] */
+               const char *value_name;/* [charset(UTF16)] */
                uint32_t offered;
        } in;
 
        struct {
+               enum winreg_Type *type;/* [ref] */
+               DATA_BLOB *data;/* [ref] */
+               uint32_t *needed;/* [ref] */
                WERROR result;
        } out;
 
 };
 
 
+struct __spoolss_GetPrinterDataEx {
+       struct {
+               enum winreg_Type type;
+       } in;
+
+       struct {
+               union spoolss_PrinterData *data;/* [ref,switch_is(type)] */
+       } out;
+
+};
+
+
 struct spoolss_GetPrinterDataEx {
        struct {
                struct policy_handle *handle;/* [ref] */
@@ -3495,7 +3554,7 @@ struct spoolss_GetPrinterDataEx {
 
        struct {
                enum winreg_Type *type;/* [ref] */
-               uint8_t *buffer;/* [ref,size_is(offered)] */
+               union spoolss_PrinterData *data;/* [subcontext_size(offered),ref,subcontext(4),switch_is(*type)] */
                uint32_t *needed;/* [ref] */
                WERROR result;
        } out;
index 3b981f0dbb377a90351a1a7ac5b48a84bab09d2b..bc50c0bb5f1316eaa768cdb265fa8b53a8919c62 100644 (file)
@@ -6147,8 +6147,8 @@ static bool api_spoolss_GetPrinterDataEx(pipes_struct *p)
                return false;
        }
 
-       r->out.buffer = talloc_zero_array(r, uint8_t, r->in.offered);
-       if (r->out.buffer == NULL) {
+       r->out.data = talloc_zero(r, union spoolss_PrinterData);
+       if (r->out.data == NULL) {
                talloc_free(r);
                return false;
        }
@@ -9465,8 +9465,8 @@ NTSTATUS rpc_spoolss_dispatch(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
                        return NT_STATUS_NO_MEMORY;
                        }
 
-                       r->out.buffer = talloc_zero_array(mem_ctx, uint8_t, r->in.offered);
-                       if (r->out.buffer == NULL) {
+                       r->out.data = talloc_zero(mem_ctx, union spoolss_PrinterData);
+                       if (r->out.data == NULL) {
                        return NT_STATUS_NO_MEMORY;
                        }
 
index 154a4efdaf5a82cdc877a2d3a80ec687c77d252f..725166f2a69d6a4313b18387ad4e8f4d87e15594 100644 (file)
@@ -2525,24 +2525,49 @@ import "misc.idl", "security.idl", "winreg.idl";
 
        /******************/
        /* Function: 0x4d */
-       WERROR spoolss_SetPrinterDataEx(
+       [noopnum,nopull,noprint,public] WERROR _spoolss_SetPrinterDataEx(
                [in,ref] policy_handle *handle,
-               [in]     [string,charset(UTF16)] uint16 key_name[],
-               [in]     [string,charset(UTF16)] uint16 value_name[],
-               [in]     winreg_Type type,
-               [in,ref] [size_is(offered)] uint8 *buffer,
-               [in]     uint32 offered
+               [in] [string,charset(UTF16)] uint16 key_name[],
+               [in] [string,charset(UTF16)] uint16 value_name[],
+               [in] winreg_Type type,
+               [in] DATA_BLOB data,
+               [in] uint32 _offered
+       );
+       [noopnum,nopull,noprint,public] void __spoolss_SetPrinterDataEx(
+               [in] winreg_Type type,
+               [out,ref,switch_is(type)] spoolss_PrinterData *data
+       );
+       [nopush] WERROR spoolss_SetPrinterDataEx(
+               [in,ref] policy_handle *handle,
+               [in] [string,charset(UTF16)] uint16 key_name[],
+               [in] [string,charset(UTF16)] uint16 value_name[],
+               [in] winreg_Type type,
+               [in,subcontext(4),switch_is(type)] spoolss_PrinterData data,
+               [in,value(ndr_size_spoolss_PrinterData(&data,type,ndr->iconv_convenience,flags))] uint32 _offered
        );
 
        /******************/
        /* Function: 0x4e */
-       WERROR spoolss_GetPrinterDataEx(
+       [noopnum,noprint,public] WERROR _spoolss_GetPrinterDataEx(
                [in,ref] policy_handle *handle,
                [in]     [string,charset(UTF16)] uint16 key_name[],
                [in]     [string,charset(UTF16)] uint16 value_name[],
+               [in]     uint32 offered,
                [out,ref] winreg_Type *type,
-               [out,ref] [size_is(offered)] uint8 *buffer,
+               [out,ref] DATA_BLOB *data,
+               [out,ref] uint32 *needed
+       );
+       [noopnum,noprint,public] void __spoolss_GetPrinterDataEx(
+               [in] winreg_Type type,
+               [out,ref,switch_is(type)] spoolss_PrinterData *data
+       );
+       [nopull,nopush,public] WERROR spoolss_GetPrinterDataEx(
+               [in,ref] policy_handle *handle,
+               [in]     [string,charset(UTF16)] uint16 key_name[],
+               [in]     [string,charset(UTF16)] uint16 value_name[],
                [in]     uint32 offered,
+               [out,ref] winreg_Type *type,
+               [out,ref,subcontext(4),subcontext_size(offered),switch_is(*type)] spoolss_PrinterData *data,
                [out,ref] uint32 *needed
        );
 
index 4965b5d709faf721170526f24c84fd41e6dfa621..84d430534fc603521b05c8768ec0e3aaf8c50c64 100644 (file)
@@ -693,6 +693,153 @@ enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flag
        return NDR_ERR_SUCCESS;
 }
 
+/*
+  spoolss_GetPrinterDataEx
+*/
+enum ndr_err_code ndr_push_spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDataEx *r)
+{
+       struct _spoolss_GetPrinterDataEx _r;
+       if (flags & NDR_IN) {
+               _r.in.handle    = r->in.handle;
+               _r.in.key_name  = r->in.key_name;
+               _r.in.value_name= r->in.value_name;
+               _r.in.offered   = r->in.offered;
+               NDR_CHECK(ndr_push__spoolss_GetPrinterDataEx(ndr, flags, &_r));
+       }
+       if (flags & NDR_OUT) {
+               struct ndr_push *_ndr_info;
+               DATA_BLOB blob = data_blob(NULL, 0);
+               _r.in.handle    = r->in.handle;
+               _r.in.key_name  = r->in.key_name;
+               _r.in.value_name= r->in.value_name;
+               _r.in.offered   = r->in.offered;
+               _r.out.type     = r->out.type;
+               _r.out.data     = &blob;
+               _r.out.needed   = r->out.needed;
+               _r.out.result   = r->out.result;
+               {
+                       struct __spoolss_GetPrinterDataEx __r;
+                       DATA_BLOB _blob;
+                       _ndr_info = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
+                       NDR_ERR_HAVE_NO_MEMORY(_ndr_info);
+                       _ndr_info->flags= ndr->flags;
+                       __r.in.type     = *r->out.type;
+                       __r.out.data    = r->out.data;
+                       NDR_CHECK(ndr_push___spoolss_GetPrinterDataEx(_ndr_info, flags, &__r));
+                       if (r->in.offered > _ndr_info->offset) {
+                               uint32_t _padding_len = r->in.offered - _ndr_info->offset;
+                               NDR_CHECK(ndr_push_zero(_ndr_info, _padding_len));
+                       }
+                       _blob = ndr_push_blob(_ndr_info);
+                       _r.out.data = &_blob;
+               }
+               NDR_CHECK(ndr_push__spoolss_GetPrinterDataEx(ndr, flags, &_r));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDataEx *r)
+{
+       struct _spoolss_GetPrinterDataEx _r;
+       if (flags & NDR_IN) {
+               DATA_BLOB blob = data_blob(NULL,0);
+               ZERO_STRUCT(r->out);
+
+               _r.in.handle    = r->in.handle;
+               _r.in.key_name  = r->in.key_name;
+               _r.in.value_name= r->in.value_name;
+               _r.in.offered   = r->in.offered;
+               _r.out.type     = r->out.type;
+               _r.out.data     = &blob;
+               _r.out.needed   = r->out.needed;
+               NDR_CHECK(ndr_pull__spoolss_GetPrinterDataEx(ndr, flags, &_r));
+               r->in.handle    = _r.in.handle;
+               r->in.key_name  = _r.in.key_name;
+               r->in.value_name= _r.in.value_name;
+               r->in.offered   = _r.in.offered;
+               r->out.needed   = _r.out.needed;
+       }
+       if (flags & NDR_OUT) {
+               DATA_BLOB blob = data_blob_talloc(ndr,NULL,0);
+               _r.in.handle    = r->in.handle;
+               _r.in.key_name  = r->in.key_name;
+               _r.in.value_name= r->in.value_name;
+               _r.in.offered   = r->in.offered;
+               _r.out.type     = r->out.type;
+               _r.out.data     = &blob;
+               _r.out.needed   = r->out.needed;
+               _r.out.result   = r->out.result;
+               NDR_CHECK(ndr_pull__spoolss_GetPrinterDataEx(ndr, flags, &_r));
+               r->out.type     = _r.out.type;
+               if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
+                       NDR_PULL_ALLOC(ndr, r->out.data);
+               }
+               ZERO_STRUCTP(r->out.data);
+               r->out.needed   = _r.out.needed;
+               r->out.result   = _r.out.result;
+               if (_r.out.data && _r.out.data->length != r->in.offered) {
+                       return ndr_pull_error(ndr, NDR_ERR_BUFSIZE,
+                               "SPOOLSS Buffer: r->in.offered[%u] doesn't match length of out buffer[%u]",
+                               (unsigned)r->in.offered, (unsigned)_r.out.data->length);
+               }
+               if (_r.out.data && _r.out.data->length > 0 && *r->out.needed <= _r.out.data->length) {
+                       struct __spoolss_GetPrinterDataEx __r;
+                       struct ndr_pull *_ndr_data = ndr_pull_init_blob(_r.out.data, ndr, ndr->iconv_convenience);
+                       NDR_ERR_HAVE_NO_MEMORY(_ndr_data);
+                       _ndr_data->flags= ndr->flags;
+                       __r.in.type     = *r->out.type;
+                       __r.out.data    = r->out.data;
+                       NDR_CHECK(ndr_pull___spoolss_GetPrinterDataEx(_ndr_data, flags, &__r));
+                       r->out.data     = __r.out.data;
+               } else {
+                       *r->out.type    = REG_NONE;
+               }
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+/*
+  spoolss_SetPrinterDataEx
+*/
+enum ndr_err_code ndr_push_spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterDataEx *r)
+{
+       struct _spoolss_SetPrinterDataEx _r;
+       if (flags & NDR_IN) {
+               struct ndr_push *_ndr_data;
+               struct __spoolss_SetPrinterDataEx __r;
+               DATA_BLOB _data_blob_data;
+
+               _ndr_data = ndr_push_init_ctx(ndr, ndr->iconv_convenience);
+               NDR_ERR_HAVE_NO_MEMORY(_ndr_data);
+               _ndr_data->flags= ndr->flags;
+
+               __r.in.type     = r->in.type;
+               __r.out.data    = discard_const_p(union spoolss_PrinterData, &r->in.data);
+               NDR_CHECK(ndr_push___spoolss_SetPrinterDataEx(_ndr_data, NDR_OUT, &__r));
+               _data_blob_data = ndr_push_blob(_ndr_data);
+
+               _r.in.handle    = r->in.handle;
+               _r.in.key_name  = r->in.key_name;
+               _r.in.value_name= r->in.value_name;
+               _r.in.type      = r->in.type;
+               _r.in.data      = _data_blob_data;
+               _r.in._offered  = _data_blob_data.length;
+               _r.out.result   = r->out.result;
+               NDR_CHECK(ndr_push__spoolss_SetPrinterDataEx(ndr, flags, &_r));
+       }
+       if (flags & NDR_OUT) {
+               _r.in.handle    = r->in.handle;
+               _r.in.key_name  = r->in.key_name;
+               _r.in.value_name= r->in.value_name;
+               _r.in.type      = r->in.type;
+               _r.in.data      = data_blob(NULL,0),
+               _r.in._offered  = r->in._offered;
+               _r.out.result   = r->out.result;
+               NDR_CHECK(ndr_push__spoolss_SetPrinterDataEx(ndr, flags, &_r));
+       }
+       return NDR_ERR_SUCCESS;
+}
+
 uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags)
 {
        if (!devmode) return 0;
index 74d0b52b3e743ba5222b306ff3cb092508378abf..478931e1f82b0c10ae6cbed947cc5e9ccae3efb9 100644 (file)
@@ -45,6 +45,9 @@ uint32_t ndr_size_spoolss_EnumPrinterDataEx_info(TALLOC_CTX *mem_ctx, struct smb
 enum ndr_err_code ndr_push_spoolss_GetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterData *r);
 enum ndr_err_code ndr_pull_spoolss_GetPrinterData(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterData *r);
 enum ndr_err_code ndr_push_spoolss_SetPrinterData(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterData *r);
+enum ndr_err_code ndr_push_spoolss_GetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_GetPrinterDataEx *r);
+enum ndr_err_code ndr_pull_spoolss_GetPrinterDataEx(struct ndr_pull *ndr, int flags, struct spoolss_GetPrinterDataEx *r);
+enum ndr_err_code ndr_push_spoolss_SetPrinterDataEx(struct ndr_push *ndr, int flags, const struct spoolss_SetPrinterDataEx *r);
 uint32_t _ndr_size_spoolss_DeviceMode(struct spoolss_DeviceMode *devmode, struct smb_iconv_convenience *ic, uint32_t flags);
 size_t ndr_size_spoolss_StringArray(const struct spoolss_StringArray *r, struct smb_iconv_convenience *ic, int flags);
 enum ndr_err_code ndr_push_spoolss_StringArray2(struct ndr_push *ndr, int ndr_flags, const struct spoolss_StringArray2 *r);