idl: define printcap IPC message format
authorDavid Disseldorp <ddiss@suse.de>
Tue, 24 May 2011 09:41:27 +0000 (11:41 +0200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 26 May 2011 18:25:14 +0000 (20:25 +0200)
Signed-off-by: Günther Deschner <gd@samba.org>
source3/Makefile.in
source3/librpc/gen_ndr/ndr_printcap.c [new file with mode: 0644]
source3/librpc/gen_ndr/ndr_printcap.h [new file with mode: 0644]
source3/librpc/gen_ndr/printcap.h [new file with mode: 0644]
source3/librpc/idl/printcap.idl [new file with mode: 0644]

index 82e108ac2052fb7238440fa5174a0f9503c36b01..b7fdfcebdc3ebf0ab6b6def8f796a3bf122c868b 100644 (file)
@@ -1272,7 +1272,8 @@ samba3-idl::
         srcdir="$(srcdir)" ../librpc/build_idl.sh ../librpc/idl/*.idl
        @PIDL_OUTPUTDIR="librpc/gen_ndr" PIDL_ARGS="$(PIDL_ARGS)" CPP="$(CPP)" PIDL="../pidl/pidl" \
         srcdir="$(srcdir)" $(srcdir)/script/build_idl.sh \
-               librpc/idl/messaging.idl librpc/idl/libnetapi.idl librpc/idl/notify.idl
+               librpc/idl/messaging.idl librpc/idl/libnetapi.idl librpc/idl/notify.idl \
+               librpc/idl/printcap.idl
 
 #####################################################################
 
diff --git a/source3/librpc/gen_ndr/ndr_printcap.c b/source3/librpc/gen_ndr/ndr_printcap.c
new file mode 100644 (file)
index 0000000..b6c7ba6
--- /dev/null
@@ -0,0 +1,168 @@
+/* parser auto-generated by pidl */
+
+#include "includes.h"
+#include "librpc/gen_ndr/ndr_printcap.h"
+
+static enum ndr_err_code ndr_push_pcap_printer(struct ndr_push *ndr, int ndr_flags, const struct pcap_printer *r)
+{
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_push_align(ndr, 4));
+               NDR_CHECK(ndr_push_unique_ptr(ndr, r->name));
+               NDR_CHECK(ndr_push_unique_ptr(ndr, r->info));
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+               if (r->name) {
+                       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->name, CH_UTF8)));
+                       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+                       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->name, CH_UTF8)));
+                       NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, ndr_charset_length(r->name, CH_UTF8), sizeof(uint8_t), CH_UTF8));
+               }
+               if (r->info) {
+                       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->info, CH_UTF8)));
+                       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+                       NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->info, CH_UTF8)));
+                       NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->info, ndr_charset_length(r->info, CH_UTF8), sizeof(uint8_t), CH_UTF8));
+               }
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_pcap_printer(struct ndr_pull *ndr, int ndr_flags, struct pcap_printer *r)
+{
+       uint32_t _ptr_name;
+       TALLOC_CTX *_mem_save_name_0;
+       uint32_t _ptr_info;
+       TALLOC_CTX *_mem_save_info_0;
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_pull_align(ndr, 4));
+               NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name));
+               if (_ptr_name) {
+                       NDR_PULL_ALLOC(ndr, r->name);
+               } else {
+                       r->name = NULL;
+               }
+               NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info));
+               if (_ptr_info) {
+                       NDR_PULL_ALLOC(ndr, r->info);
+               } else {
+                       r->info = NULL;
+               }
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+               if (r->name) {
+                       _mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+                       NDR_PULL_SET_MEM_CTX(ndr, r->name, 0);
+                       NDR_CHECK(ndr_pull_array_size(ndr, &r->name));
+                       NDR_CHECK(ndr_pull_array_length(ndr, &r->name));
+                       if (ndr_get_array_length(ndr, &r->name) > ndr_get_array_size(ndr, &r->name)) {
+                               return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->name), ndr_get_array_length(ndr, &r->name));
+                       }
+                       NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->name), sizeof(uint8_t)));
+                       NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->name, ndr_get_array_length(ndr, &r->name), sizeof(uint8_t), CH_UTF8));
+                       NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, 0);
+               }
+               if (r->info) {
+                       _mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
+                       NDR_PULL_SET_MEM_CTX(ndr, r->info, 0);
+                       NDR_CHECK(ndr_pull_array_size(ndr, &r->info));
+                       NDR_CHECK(ndr_pull_array_length(ndr, &r->info));
+                       if (ndr_get_array_length(ndr, &r->info) > ndr_get_array_size(ndr, &r->info)) {
+                               return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->info), ndr_get_array_length(ndr, &r->info));
+                       }
+                       NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->info), sizeof(uint8_t)));
+                       NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->info, ndr_get_array_length(ndr, &r->info), sizeof(uint8_t), CH_UTF8));
+                       NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
+               }
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_pcap_printer(struct ndr_print *ndr, const char *name, const struct pcap_printer *r)
+{
+       ndr_print_struct(ndr, name, "pcap_printer");
+       ndr->depth++;
+       ndr_print_ptr(ndr, "name", r->name);
+       ndr->depth++;
+       if (r->name) {
+               ndr_print_string(ndr, "name", r->name);
+       }
+       ndr->depth--;
+       ndr_print_ptr(ndr, "info", r->info);
+       ndr->depth++;
+       if (r->info) {
+               ndr_print_string(ndr, "info", r->info);
+       }
+       ndr->depth--;
+       ndr->depth--;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_pcap_data(struct ndr_push *ndr, int ndr_flags, const struct pcap_data *r)
+{
+       uint32_t cntr_printers_0;
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
+               NDR_CHECK(ndr_push_align(ndr, 4));
+               NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->status));
+               NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
+               for (cntr_printers_0 = 0; cntr_printers_0 < r->count; cntr_printers_0++) {
+                       NDR_CHECK(ndr_push_pcap_printer(ndr, NDR_SCALARS, &r->printers[cntr_printers_0]));
+               }
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+               for (cntr_printers_0 = 0; cntr_printers_0 < r->count; cntr_printers_0++) {
+                       NDR_CHECK(ndr_push_pcap_printer(ndr, NDR_BUFFERS, &r->printers[cntr_printers_0]));
+               }
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_pcap_data(struct ndr_pull *ndr, int ndr_flags, struct pcap_data *r)
+{
+       uint32_t cntr_printers_0;
+       TALLOC_CTX *_mem_save_printers_0;
+       if (ndr_flags & NDR_SCALARS) {
+               NDR_CHECK(ndr_pull_array_size(ndr, &r->printers));
+               NDR_CHECK(ndr_pull_align(ndr, 4));
+               NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->status));
+               NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count));
+               NDR_PULL_ALLOC_N(ndr, r->printers, ndr_get_array_size(ndr, &r->printers));
+               _mem_save_printers_0 = NDR_PULL_GET_MEM_CTX(ndr);
+               NDR_PULL_SET_MEM_CTX(ndr, r->printers, 0);
+               for (cntr_printers_0 = 0; cntr_printers_0 < r->count; cntr_printers_0++) {
+                       NDR_CHECK(ndr_pull_pcap_printer(ndr, NDR_SCALARS, &r->printers[cntr_printers_0]));
+               }
+               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printers_0, 0);
+               if (r->printers) {
+                       NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->printers, r->count));
+               }
+       }
+       if (ndr_flags & NDR_BUFFERS) {
+               _mem_save_printers_0 = NDR_PULL_GET_MEM_CTX(ndr);
+               NDR_PULL_SET_MEM_CTX(ndr, r->printers, 0);
+               for (cntr_printers_0 = 0; cntr_printers_0 < r->count; cntr_printers_0++) {
+                       NDR_CHECK(ndr_pull_pcap_printer(ndr, NDR_BUFFERS, &r->printers[cntr_printers_0]));
+               }
+               NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printers_0, 0);
+       }
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_pcap_data(struct ndr_print *ndr, const char *name, const struct pcap_data *r)
+{
+       uint32_t cntr_printers_0;
+       ndr_print_struct(ndr, name, "pcap_data");
+       ndr->depth++;
+       ndr_print_NTSTATUS(ndr, "status", r->status);
+       ndr_print_uint32(ndr, "count", r->count);
+       ndr->print(ndr, "%s: ARRAY(%d)", "printers", (int)r->count);
+       ndr->depth++;
+       for (cntr_printers_0=0;cntr_printers_0<r->count;cntr_printers_0++) {
+               char *idx_0=NULL;
+               if (asprintf(&idx_0, "[%d]", cntr_printers_0) != -1) {
+                       ndr_print_pcap_printer(ndr, "printers", &r->printers[cntr_printers_0]);
+                       free(idx_0);
+               }
+       }
+       ndr->depth--;
+       ndr->depth--;
+}
diff --git a/source3/librpc/gen_ndr/ndr_printcap.h b/source3/librpc/gen_ndr/ndr_printcap.h
new file mode 100644 (file)
index 0000000..37589da
--- /dev/null
@@ -0,0 +1,14 @@
+/* header auto-generated by pidl */
+
+#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/printcap.h"
+
+#ifndef _HEADER_NDR_printcap
+#define _HEADER_NDR_printcap
+
+#define NDR_PRINTCAP_CALL_COUNT (0)
+void ndr_print_pcap_printer(struct ndr_print *ndr, const char *name, const struct pcap_printer *r);
+enum ndr_err_code ndr_push_pcap_data(struct ndr_push *ndr, int ndr_flags, const struct pcap_data *r);
+enum ndr_err_code ndr_pull_pcap_data(struct ndr_pull *ndr, int ndr_flags, struct pcap_data *r);
+void ndr_print_pcap_data(struct ndr_print *ndr, const char *name, const struct pcap_data *r);
+#endif /* _HEADER_NDR_printcap */
diff --git a/source3/librpc/gen_ndr/printcap.h b/source3/librpc/gen_ndr/printcap.h
new file mode 100644 (file)
index 0000000..c8d6350
--- /dev/null
@@ -0,0 +1,21 @@
+/* header auto-generated by pidl */
+
+#include <stdint.h>
+
+#include "libcli/util/ntstatus.h"
+
+#ifndef _HEADER_printcap
+#define _HEADER_printcap
+
+struct pcap_printer {
+       const char *name;/* [unique,charset(UTF8)] */
+       const char *info;/* [unique,charset(UTF8)] */
+};
+
+struct pcap_data {
+       NTSTATUS status;
+       uint32_t count;
+       struct pcap_printer *printers;/* [size_is(count)] */
+}/* [public] */;
+
+#endif /* _HEADER_printcap */
diff --git a/source3/librpc/idl/printcap.idl b/source3/librpc/idl/printcap.idl
new file mode 100644 (file)
index 0000000..5ab380c
--- /dev/null
@@ -0,0 +1,17 @@
+#include "idl_types.h"
+[
+       pointer_default(unique)
+]
+interface printcap
+{
+       typedef struct {
+               [charset(UTF8),string] uint8 *name;
+               [charset(UTF8),string] uint8 *info;
+       } pcap_printer;
+
+       typedef [public] struct {
+               NTSTATUS status;
+               uint32 count;
+               [size_is(count)] pcap_printer printers[];
+       } pcap_data;
+}