diff options
41 files changed, 10755 insertions, 1120 deletions
diff --git a/packaging/README.Debian b/packaging/README.Debian new file mode 100644 index 0000000000..2eedd7a1ec --- /dev/null +++ b/packaging/README.Debian @@ -0,0 +1,2 @@ +Please see http://wiki.samba.org/index.php/Samba4/Debian for instructions +on building the Samba 4 Debian packages. diff --git a/packaging4/debian/README b/packaging4/debian/README deleted file mode 100644 index fb4f88e63e..0000000000 --- a/packaging4/debian/README +++ /dev/null @@ -1,30 +0,0 @@ -The Debian packaging for Samba 4 is maintained in the SVN -repository of the Debian Samba packaging team. - -(parts of this file are from their README.building) - -To build: - -: Check out the official Debian packaging: - - svn co svn://svn.debian.org/pkg-samba/branches/samba4 samba4/debian - -: Samba is not a native Debian package, so you will need to create -: an .orig.tar.gz tarball. Do something along the lines of: - - VER=$( dpkg-parsechangelog -lsamba4/debian/changelog | sed -n 's/^Version: \(.*:\|\)//p' | sed 's/-[0-9.]\+$//' ) - svn export samba4 samba-$VER - ( cd samba-$VER/source && ./autogen.sh ) - ( cd samba-$VER/source && ./script/mkversion.sh VERSION include/version.h ../../samba4/source/ ) - tar zcf samba_$VER.orig.tar.gz samba-$VER - -: With the .orig.tar.gz in place, you can now also export the debian/ -: directory: - - svn export samba4/debian samba-$VER/debian - -: Finally, build the package using whatever method you prefer: - - cd samba-$VER - debuild - diff --git a/source4/Makefile b/source4/Makefile index 66b092192e..546eb072d8 100644 --- a/source4/Makefile +++ b/source4/Makefile @@ -102,6 +102,7 @@ ejsscriptsrcdir := scripting/ejs pyscriptsrcdir := $(srcdir)/scripting/python kdcsrcdir := kdc ntp_signdsrcdir := ntp_signd +wmisrcdir := lib/wmi include data.mk diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk index 4d076684cd..999ed7717e 100644 --- a/source4/lib/basic.mk +++ b/source4/lib/basic.mk @@ -1,6 +1,28 @@ -[SUBSYSTEM::LZXPRESS] - -LZXPRESS_OBJ_FILES = $(libcompressionsrcdir)/lzxpress.o +# LIB BASIC subsystem +mkinclude samba3/config.mk +mkinclude socket/config.mk +mkinclude charset/config.mk +mkinclude ldb-samba/config.mk +mkinclude tls/config.mk +mkinclude registry/config.mk +mkinclude messaging/config.mk +mkinclude events/config.mk +mkinclude cmdline/config.mk +mkinclude socket_wrapper/config.mk +mkinclude nss_wrapper/config.mk +mkinclude appweb/config.mk +mkinclude stream/config.mk +mkinclude util/config.mk +mkinclude tdr/config.mk +mkinclude dbwrap/config.mk +mkinclude crypto/config.mk +mkinclude torture/config.mk +mkinclude com/config.mk +mkinclude wmi/config.mk + +[SUBSYSTEM::LIBCOMPRESSION] + +LIBCOMPRESSION_OBJ_FILES = lib/compression/mszip.o [SUBSYSTEM::GENCACHE] PRIVATE_DEPENDENCIES = TDB_WRAP diff --git a/source4/lib/com/README b/source4/lib/com/README new file mode 100644 index 0000000000..361024e02c --- /dev/null +++ b/source4/lib/com/README @@ -0,0 +1,9 @@ +This directory contains Samba's very simple COM implementation. +It is by no means finished yet. + +The main aim of this implementation is for use by our DCOM implementation, +which lives in the dcom subdirectory. The local version is used mostly for +testing. + +More information on this effort can be found in the DCOM whitepaper in +the lorikeet repository. diff --git a/source4/lib/com/classes/simple.c b/source4/lib/com/classes/simple.c new file mode 100644 index 0000000000..295f113207 --- /dev/null +++ b/source4/lib/com/classes/simple.c @@ -0,0 +1,122 @@ +/* + Unix SMB/CIFS implementation. + Simple class + Copyright (C) 2004-2005 Jelmer Vernooij <jelmer@samba.org> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/com/com.h" +#include "librpc/gen_ndr/com_dcom.h" + +static struct IClassFactory_vtable simple_classobject_vtable; +static struct IStream_vtable simple_IStream_vtable; + +static WERROR simple_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun) +{ + *iun = d; + return WERR_OK; +} + +static uint32_t simple_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + return 1; +} + +static uint32_t simple_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + return 1; +} + +static WERROR simple_IStream_Read (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *pv, uint32_t num_requested, uint32_t *num_readx, uint32_t num_read) +{ + printf("%d bytes are being read\n", num_read); + return WERR_OK; +} + +static WERROR simple_IStream_Write (struct IStream *d, TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t num_requested, uint32_t num_written) +{ + printf("%d bytes are being written\n", num_requested); + return WERR_OK; +} + +static WERROR simpleclass_IUnknown_QueryInterface (struct IUnknown *d, TALLOC_CTX *mem_ctx, struct GUID *iid, struct IUnknown **iun) +{ + /* FIXME: Return WERR_IFACE_NOT_SUPPORTED if IID != IID_IUNKNOWN and IID != IID_CLASSFACTORY */ + *iun = d; + return WERR_OK; +} + +static WERROR simpleclass_IClassFactory_CreateInstance (struct IClassFactory *d, TALLOC_CTX *mem_ctx, struct IUnknown *iunk, struct GUID *iid, struct IUnknown **ppv) +{ + struct IStream *ret; + /* FIXME: Check whether IID == ISTREAM_IID */ + ret = talloc(mem_ctx, struct IStream); + ret->ctx = NULL; + ret->vtable = &simple_IStream_vtable; + ret->object_data = NULL; + + *ppv = (struct IUnknown *)ret; + + return WERR_OK; +} + +static uint32_t simpleclass_IUnknown_AddRef (struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + return 1; +} + +static uint32_t simpleclass_IUnknown_Release (struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + return 1; +} + +/* Everything below this line should be autogenerated later on */ +static struct IClassFactory_vtable simple_classobject_vtable = { + { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } }, + simpleclass_IUnknown_QueryInterface, + simpleclass_IUnknown_AddRef, + simpleclass_IUnknown_Release, + simpleclass_IClassFactory_CreateInstance, + NULL, + NULL, + NULL +}; + +static struct IStream_vtable simple_IStream_vtable = { + { 0, 0, 0, { 0, 0 }, { 0, 0, 0, 0, 0, 0 } }, + simple_IUnknown_QueryInterface, + simple_IUnknown_AddRef, + simple_IUnknown_Release, + simple_IStream_Read, + simple_IStream_Write +}; + +NTSTATUS com_simple_init(void) +{ + struct GUID clsid; + struct IUnknown *class_object = talloc(talloc_autofree_context(), struct IUnknown); + + class_object->ctx = NULL; + class_object->object_data = NULL; + class_object->vtable = (struct IUnknown_vtable *)&simple_classobject_vtable; + + GUID_from_string(CLSID_SIMPLE, &clsid); + GUID_from_string(COM_ICLASSFACTORY_UUID, &simple_classobject_vtable.iid); + GUID_from_string(COM_ISTREAM_UUID, &simple_IStream_vtable.iid); + + return com_register_running_class(&clsid, PROGID_SIMPLE, class_object); +} diff --git a/source4/lib/com/com.h b/source4/lib/com/com.h new file mode 100644 index 0000000000..f88c914a04 --- /dev/null +++ b/source4/lib/com/com.h @@ -0,0 +1,38 @@ +/* + Unix SMB/CIFS implementation. + Utility functions for Samba + Copyright (C) Jelmer Vernooij 2008 + + 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __SAMBA_COM_H__ +#define __SAMBA_COM_H__ + +#include "librpc/gen_ndr/misc.h" + +struct com_context; +struct event_context; + +struct IUnknown *com_class_by_clsid(struct com_context *ctx, const struct GUID *clsid); +NTSTATUS com_register_running_class(struct GUID *clsid, const char *progid, struct IUnknown *p); + +struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid); + +WERROR com_init_ctx(struct com_context **ctx, struct event_context *event_ctx); +WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_ifaces, struct GUID *iid, struct IUnknown **ip, WERROR *results); +WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip); +NTSTATUS com_init(void); + +#endif /* __SAMBA_COM_H__ */ diff --git a/source4/lib/com/config.mk b/source4/lib/com/config.mk new file mode 100644 index 0000000000..5c8e98dc46 --- /dev/null +++ b/source4/lib/com/config.mk @@ -0,0 +1,15 @@ +[SUBSYSTEM::COM] + +COM_OBJ_FILES = $(addprefix lib/com/, tables.o rot.o main.o) + +[SUBSYSTEM::DCOM] +PUBLIC_DEPENDENCIES = com DCOM_PROXY_DCOM RPC_NDR_REMACT \ + RPC_NDR_OXIDRESOLVER + +DCOM_OBJ_FILES = $(addprefix lib/com/dcom/, main.o tables.o) + +[MODULE::com_simple] +SUBSYSTEM = COM +INIT_FUNCTION = com_simple_init + +com_simple_OBJ_FILES = lib/com/classes/simple.o diff --git a/source4/lib/com/dcom/dcom.h b/source4/lib/com/dcom/dcom.h new file mode 100644 index 0000000000..69bb7183b2 --- /dev/null +++ b/source4/lib/com/dcom/dcom.h @@ -0,0 +1,72 @@ +/* + Unix SMB/CIFS implementation. + COM standard objects + Copyright (C) Jelmer Vernooij 2004-2005. + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef _DCOM_H /* _DCOM_H */ +#define _DCOM_H + +struct cli_credentials; +struct dcerpc_pipe; + +#include "lib/com/com.h" +#include "librpc/gen_ndr/orpc.h" + +struct dcom_client_context { + struct dcom_server_credentials { + const char *server; + struct cli_credentials *credentials; + struct dcom_server_credentials *prev, *next; + } *credentials; + struct dcom_object_exporter { + uint64_t oxid; + char *host; + struct IRemUnknown *rem_unknown; + struct DUALSTRINGARRAY *bindings; + struct dcerpc_pipe *pipe; + struct dcom_object_exporter *prev, *next; + } *object_exporters; +}; + +typedef enum ndr_err_code (*marshal_fn)(TALLOC_CTX *mem_ctx, struct IUnknown *pv, struct OBJREF *o); +typedef enum ndr_err_code (*unmarshal_fn)(TALLOC_CTX *mem_ctx, struct OBJREF *o, struct IUnknown **pv); + + +struct dcom_client_context *dcom_client_init(struct com_context *ctx, struct cli_credentials *credentials); +struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx, uint64_t oxid); +struct dcom_object_exporter *object_exporter_by_ip(struct com_context *ctx, struct IUnknown *ip); +WERROR dcom_create_object(struct com_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct IUnknown ***ip, WERROR *results); +WERROR dcom_get_class_object(struct com_context *ctx, struct GUID *clsid, const char *server, struct GUID *iid, struct IUnknown **ip); +NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp); +NTSTATUS dcom_OBJREF_from_IUnknown(struct OBJREF *o, struct IUnknown *p); +NTSTATUS dcom_IUnknown_from_OBJREF(struct com_context *ctx, struct IUnknown **_p, struct OBJREF *o); +uint64_t dcom_get_current_oxid(void); +void dcom_add_server_credentials(struct com_context *ctx, const char *server, struct cli_credentials *credentials); +WERROR dcom_query_interface(struct IUnknown *d, uint32_t cRefs, uint16_t cIids, struct GUID *iids, struct IUnknown **ip, WERROR *results); + +#include "librpc/gen_ndr/com_dcom.h" + +NTSTATUS dcom_register_proxy(struct IUnknown_vtable *proxy_vtable); +struct IUnknown_vtable *dcom_proxy_vtable_by_iid(struct GUID *iid); +NTSTATUS dcom_register_marshal(struct GUID *clsid, marshal_fn marshal, unmarshal_fn unmarshal); + +#include "libcli/composite/composite.h" +void dcom_release_continue(struct composite_context *cr); +#define IUnknown_ipid(d) ((d)->obj.u_objref.u_standard.std.ipid) + +#endif /* _DCOM_H */ diff --git a/source4/lib/com/dcom/main.c b/source4/lib/com/dcom/main.c new file mode 100644 index 0000000000..a4b37f1927 --- /dev/null +++ b/source4/lib/com/dcom/main.c @@ -0,0 +1,707 @@ +/* + Unix SMB/CIFS implementation. + Main DCOM functionality + Copyright (C) 2004 Jelmer Vernooij <jelmer@samba.org> + Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "system/filesys.h" +#include "librpc/gen_ndr/epmapper.h" +#include "librpc/gen_ndr/ndr_remact_c.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "librpc/gen_ndr/dcom.h" +#include "lib/com/dcom/dcom.h" +#include "librpc/ndr/ndr_table.h" +#include "lib/util/dlinklist.h" +#include "auth/credentials/credentials.h" +#include "libcli/composite/composite.h" + +#define DCOM_NEGOTIATED_PROTOCOLS { EPM_PROTOCOL_TCP, EPM_PROTOCOL_SMB, EPM_PROTOCOL_NCALRPC } + +static NTSTATUS dcerpc_binding_from_STRINGBINDING(TALLOC_CTX *mem_ctx, struct dcerpc_binding **b_out, struct STRINGBINDING *bd) +{ + char *host, *endpoint; + struct dcerpc_binding *b; + + b = talloc_zero(mem_ctx, struct dcerpc_binding); + if (!b) { + return NT_STATUS_NO_MEMORY; + } + + b->transport = dcerpc_transport_by_endpoint_protocol(bd->wTowerId); + + if (b->transport == -1) { + DEBUG(1, ("Can't find transport match endpoint protocol %d\n", bd->wTowerId)); + talloc_free(b); + return NT_STATUS_NOT_SUPPORTED; + } + + host = talloc_strdup(b, bd->NetworkAddr); + endpoint = strchr(host, '['); + + if (endpoint) { + *endpoint = '\0'; + endpoint++; + + endpoint[strlen(endpoint)-1] = '\0'; + } + + b->host = host; + b->endpoint = talloc_strdup(b, endpoint); + + *b_out = b; + return NT_STATUS_OK; +} + +struct cli_credentials *dcom_get_server_credentials(struct com_context *ctx, const char *server) +{ + struct dcom_server_credentials *c; + struct cli_credentials *d; + + d = NULL; + for (c = ctx->dcom->credentials; c; c = c->next) { + if (c->server == NULL) { + d = c->credentials; + continue; + } + if (server && !strcmp(c->server, server)) return c->credentials; + } + return d; +} + +/** + * Register credentials for a specific server. + * + * @param ctx COM context + * @param server Name of server, can be NULL + * @param credentials Credentials object + */ +void dcom_add_server_credentials(struct com_context *ctx, const char *server, + struct cli_credentials *credentials) +{ + struct dcom_server_credentials *c; + + /* FIXME: Don't use talloc_find_parent_bytype */ + for (c = ctx->dcom->credentials; c; c = c->next) { + if ((server == NULL && c->server == NULL) || + (server != NULL && c->server != NULL && + !strcmp(c->server, server))) { + if (c->credentials && c->credentials != credentials) { + talloc_unlink(c, c->credentials); + c->credentials = credentials; + if (talloc_find_parent_bytype(c->credentials, struct dcom_server_credentials)) + (void)talloc_reference(c, c->credentials); + else + talloc_steal(c, c->credentials); + } + + return; + } + } + + c = talloc(ctx->event_ctx, struct dcom_server_credentials); + c->server = talloc_strdup(c, server); + c->credentials = credentials; + if (talloc_find_parent_bytype(c->credentials, struct dcom_server_credentials)) + (void)talloc_reference(c, c->credentials); + else + talloc_steal(c, c->credentials); + + DLIST_ADD(ctx->dcom->credentials, c); +} + +void dcom_update_credentials_for_aliases(struct com_context *ctx, + const char *server, + struct DUALSTRINGARRAY *pds) +{ + struct cli_credentials *cc; + struct dcerpc_binding *b; + uint32_t i; + NTSTATUS status; + + cc = dcom_get_server_credentials(ctx, server); + for (i = 0; pds->stringbindings[i]; ++i) { + if (pds->stringbindings[i]->wTowerId != EPM_PROTOCOL_TCP) + continue; + status = dcerpc_binding_from_STRINGBINDING(ctx, &b, pds->stringbindings[i]); + if (!NT_STATUS_IS_OK(status)) + continue; + dcom_add_server_credentials(ctx, b->host, cc); + talloc_free(b); + } +} + +struct dcom_client_context *dcom_client_init(struct com_context *ctx, struct cli_credentials *credentials) +{ + ctx->dcom = talloc_zero(ctx, struct dcom_client_context); + if (!credentials) { + credentials = cli_credentials_init(ctx); + cli_credentials_set_conf(credentials, ctx->lp_ctx); + cli_credentials_parse_string(credentials, "%", CRED_SPECIFIED); + } + dcom_set_server_credentials(ctx, NULL, credentials); + return ctx->dcom; +} + +static NTSTATUS dcom_connect_host(struct com_context *ctx, + struct dcerpc_pipe **p, const char *server) +{ + struct dcerpc_binding *bd; + const char * available_transports[] = { "ncacn_ip_tcp", "ncacn_np" }; + int i; + NTSTATUS status; + TALLOC_CTX *loc_ctx; + + if (server == NULL) { + return dcerpc_pipe_connect(ctx->event_ctx, p, "ncalrpc", + &ndr_table_IRemoteActivation, + dcom_get_server_credentials(ctx, NULL), ctx->event_ctx, ctx->lp_ctx); + } + loc_ctx = talloc_new(ctx); + + /* Allow server name to contain a binding string */ + if (strchr(server, ':') && + NT_STATUS_IS_OK(dcerpc_parse_binding(loc_ctx, server, &bd))) { + if (DEBUGLVL(11)) + bd->flags |= DCERPC_DEBUG_PRINT_BOTH; + status = dcerpc_pipe_connect_b(ctx->event_ctx, p, bd, + &ndr_table_IRemoteActivation, + dcom_get_server_credentials(ctx, bd->host), ctx->event_ctx, ctx->lp_ctx); + goto end; + } + + for (i = 0; i < ARRAY_SIZE(available_transports); i++) + { + char *binding = talloc_asprintf(loc_ctx, "%s:%s", available_transports[i], server); + if (!binding) { + status = NT_STATUS_NO_MEMORY; + goto end; + }; + status = dcerpc_pipe_connect(ctx->event_ctx, p, binding, &ndr_table_IRemoteActivation, + dcom_get_server_credentials(ctx, server), ctx->event_ctx, ctx->lp_ctx); + + if (NT_STATUS_IS_OK(status)) { + if (DEBUGLVL(11)) + (*p)->conn->flags |= DCERPC_DEBUG_PRINT_BOTH; + goto end; + } else { + DEBUG(1,(__location__": dcom_connect_host : %s\n", get_friendly_nt_error_msg(status))); + } + } + +end: + talloc_free(loc_ctx); + return status; +} + +struct dcom_object_exporter *object_exporter_by_oxid(struct com_context *ctx, + uint64_t oxid) +{ + struct dcom_object_exporter *ox; + for (ox = ctx->dcom->object_exporters; ox; ox = ox->next) { + if (ox->oxid == oxid) { + return ox; + } + } + + return NULL; +} + +struct dcom_object_exporter *object_exporter_update_oxid(struct com_context *ctx, uint64_t oxid, struct DUALSTRINGARRAY *bindings) +{ + struct dcom_object_exporter *ox; + ox = object_exporter_by_oxid(ctx, oxid); + if (!ox) { + ox = talloc_zero(ctx, struct dcom_object_exporter); + DLIST_ADD(ctx->dcom->object_exporters, ox); + ox->oxid = oxid; + } else { + talloc_free(ox->bindings); + } + ox->bindings = bindings; + talloc_steal(ox, bindings); + return ox; +} + +struct dcom_object_exporter *object_exporter_by_ip(struct com_context *ctx, struct IUnknown *ip) +{ + return object_exporter_by_oxid(ctx, ip->obj.u_objref.u_standard.std.oxid); +} + +WERROR dcom_create_object(struct com_context *ctx, struct GUID *clsid, const char *server, int num_ifaces, struct GUID *iid, struct IUnknown ***ip, WERROR *results) +{ + uint16_t protseq[] = DCOM_NEGOTIATED_PROTOCOLS; + struct dcerpc_pipe *p; + struct dcom_object_exporter *m; + NTSTATUS status; + struct RemoteActivation r; + struct DUALSTRINGARRAY *pds; + int i; + WERROR hr; + uint64_t oxid; + struct GUID ipidRemUnknown; + struct IUnknown *ru_template; + struct ORPCTHAT that; + uint32_t AuthnHint; + struct COMVERSION ServerVersion; + struct MInterfacePointer **ifaces; + TALLOC_CTX *loc_ctx; + + status = dcom_connect_host(ctx, &p, server); + if (NT_STATUS_IS_ERR(status)) { + DEBUG(1, ("Unable to connect to %s - %s\n", server, get_friendly_nt_error_msg(status))); + return ntstatus_to_werror(status); + } + loc_ctx = talloc_new(ctx); + + ifaces = talloc_array(loc_ctx, struct MInterfacePointer *, num_ifaces); + + ZERO_STRUCT(r.in); + r.in.this.version.MajorVersion = COM_MAJOR_VERSION; + r.in.this.version.MinorVersion = COM_MINOR_VERSION; + r.in.this.cid = GUID_random(); + r.in.Clsid = *clsid; + r.in.ClientImpLevel = RPC_C_IMP_LEVEL_IDENTIFY; + r.in.num_protseqs = ARRAY_SIZE(protseq); + r.in.protseq = protseq; + r.in.Interfaces = num_ifaces; + r.in.pIIDs = iid; + r.out.that = &that; + r.out.pOxid = &oxid; + r.out.pdsaOxidBindings = &pds; + r.out.ipidRemUnknown = &ipidRemUnknown; + r.out.AuthnHint = &AuthnHint; + r.out.ServerVersion = &ServerVersion; + r.out.hr = &hr; + r.out.ifaces = ifaces; + r.out.results = results; + + status = dcerpc_RemoteActivation(p, loc_ctx, &r); + talloc_free(p); + + if(NT_STATUS_IS_ERR(status)) { + DEBUG(1, ("Error while running RemoteActivation %s\n", nt_errstr(status))); + hr = ntstatus_to_werror(status); + goto end; + } + + if(!W_ERROR_IS_OK(r.out.result)) { + hr = r.out.result; + goto end; + } + + if(!W_ERROR_IS_OK(hr)) { + goto end; + } + + m = object_exporter_update_oxid(ctx, oxid, pds); + + ru_template = NULL; + *ip = talloc_array(ctx, struct IUnknown *, num_ifaces); + for (i = 0; i < num_ifaces; i++) { + (*ip)[i] = NULL; + if (W_ERROR_IS_OK(results[i])) { + status = dcom_IUnknown_from_OBJREF(ctx, &(*ip)[i], &r.out.ifaces[i]->obj); + if (!NT_STATUS_IS_OK(status)) { + results[i] = ntstatus_to_werror(status); + } else if (!ru_template) + ru_template = (*ip)[i]; + } + } + + /* TODO:avg check when exactly oxid should be updated,its lifetime etc */ + if (m->rem_unknown && memcmp(&m->rem_unknown->obj.u_objref.u_standard.std.ipid, &ipidRemUnknown, sizeof(ipidRemUnknown))) { + talloc_free(m->rem_unknown); + m->rem_unknown = NULL; + } + if (!m->rem_unknown) { + if (!ru_template) { + DEBUG(1,("dcom_create_object: Cannot Create IRemUnknown - template interface not available\n")); + hr = WERR_GENERAL_FAILURE; + } + m->rem_unknown = talloc_zero(m, struct IRemUnknown); + memcpy(m->rem_unknown, ru_template, sizeof(struct IUnknown)); + GUID_from_string(COM_IREMUNKNOWN_UUID, &m->rem_unknown->obj.iid); + m->rem_unknown->obj.u_objref.u_standard.std.ipid = ipidRemUnknown; + m->rem_unknown->vtable = (struct IRemUnknown_vtable *)dcom_proxy_vtable_by_iid(&m->rem_unknown->obj.iid); + /* TODO:avg copy stringbindigs?? */ + } + + dcom_update_credentials_for_aliases(ctx, server, pds); + { + char *c; + c = strchr(server, '['); + if (m->host) talloc_free(m->host); + m->host = c ? talloc_strndup(m, server, c - server) : talloc_strdup(m, server); + } + hr = WERR_OK; +end: + talloc_free(loc_ctx); + return hr; +} + +int find_similar_binding(struct STRINGBINDING **sb, const char *host) +{ + int i, l; + l = strlen(host); + for (i = 0; sb[i]; ++i) { + if ((sb[i]->wTowerId == EPM_PROTOCOL_TCP) && !strncasecmp(host, sb[i]->NetworkAddr, l) && (sb[i]->NetworkAddr[l] == '[')) + break; + } + return i; +} + +WERROR dcom_query_interface(struct IUnknown *d, uint32_t cRefs, uint16_t cIids, struct GUID *iids, struct IUnknown **ip, WERROR *results) +{ + struct dcom_object_exporter *ox; + struct REMQIRESULT *rqir; + WERROR result; + NTSTATUS status; + int i; + TALLOC_CTX *loc_ctx; + struct IUnknown ru; + + loc_ctx = talloc_new(d); + ox = object_exporter_by_ip(d->ctx, d); + + result = IRemUnknown_RemQueryInterface(ox->rem_unknown, loc_ctx, &IUnknown_ipid(d), cRefs, cIids, iids, &rqir); + if (!W_ERROR_IS_OK(result)) { + DEBUG(1, ("dcom_query_interface failed: %08X\n", W_ERROR_V(result))); + talloc_free(loc_ctx); + return result; + } + ru = *(struct IUnknown *)ox->rem_unknown; + for (i = 0; i < cIids; ++i) { + ip[i] = NULL; + results[i] = rqir[i].hResult; + if (W_ERROR_IS_OK(results[i])) { + ru.obj.iid = iids[i]; + ru.obj.u_objref.u_standard.std = rqir[i].std; + status = dcom_IUnknown_from_OBJREF(d->ctx, &ip[i], &ru.obj); + if (!NT_STATUS_IS_OK(status)) { + results[i] = ntstatus_to_werror(status); + } + } + } + + talloc_free(loc_ctx); + return WERR_OK; +} + +int is_ip_binding(const char* s) +{ + while (*s && (*s != '[')) { + if (((*s >= '0') && (*s <= '9')) || *s == '.') + ++s; + else + return 0; + } + return 1; +} + +NTSTATUS dcom_get_pipe(struct IUnknown *iface, struct dcerpc_pipe **pp) +{ + struct dcerpc_binding *binding; + struct GUID iid; + uint64_t oxid; + NTSTATUS status; + int i, j, isimilar; + struct dcerpc_pipe *p; + struct dcom_object_exporter *ox; + const struct ndr_interface_table *table; + + ox = object_exporter_by_oxid(iface->ctx, iface->obj.u_objref.u_standard.std.oxid); + if (!ox) { + DEBUG(0, ("dcom_get_pipe: OXID not found\n")); + return NT_STATUS_NOT_SUPPORTED; + } + + p = ox->pipe; + + iid = iface->vtable->iid; + table = ndr_table_by_uuid(&iid); + if (table == NULL) { + char *guid_str; + guid_str = GUID_string(NULL, &iid); + DEBUG(0,(__location__": dcom_get_pipe - unrecognized interface{%s}\n", guid_str)); + talloc_free(guid_str); + return NT_STATUS_NOT_SUPPORTED; + } + + if (p && p->last_fault_code) { + talloc_free(p); + ox->pipe = p = NULL; + } + + if (p) { + if (!GUID_equal(&p->syntax.uuid, &iid)) { + ox->pipe->syntax.uuid = iid; + + /* interface will always be present, so + * idl_iface_by_uuid can't return NULL */ + /* status = dcerpc_secondary_context(p, &p2, idl_iface_by_uuid(&iid)); */ + status = dcerpc_alter_context(p, p, &ndr_table_by_uuid(&iid)->syntax_id, &p->transfer_syntax); + } else + status = NT_STATUS_OK; + *pp = p; + return status; + } + + status = NT_STATUS_NO_MORE_ENTRIES; + + /* To avoid delays whe connecting nonroutable bindings we 1st check binding starting with hostname */ + /* FIX:low create concurrent connections to all bindings, fastest wins - Win2k and newer does this way???? */ + isimilar = find_similar_binding(ox->bindings->stringbindings, ox->host); + DEBUG(1, (__location__": dcom_get_pipe: host=%s, similar=%s\n", ox->host, ox->bindings->stringbindings[isimilar] ? ox->bindings->stringbindings[isimilar]->NetworkAddr : "None")); + j = isimilar - 1; + for (i = 0; ox->bindings->stringbindings[i]; ++i) { + if (!ox->bindings->stringbindings[++j]) j = 0; + /* FIXME:LOW Use also other transports if possible */ + if ((j != isimilar) && (ox->bindings->stringbindings[j]->wTowerId != EPM_PROTOCOL_TCP || !is_ip_binding(ox->bindings->stringbindings[j]->NetworkAddr))) { + DEBUG(9, ("dcom_get_pipe: Skipping stringbinding %24.24s\n", ox->bindings->stringbindings[j]->NetworkAddr)); + continue; + } + DEBUG(9, ("dcom_get_pipe: Trying stringbinding %s\n", ox->bindings->stringbindings[j]->NetworkAddr)); + status = dcerpc_binding_from_STRINGBINDING(iface->ctx, &binding, + ox->bindings->stringbindings[j]); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(1, ("Error parsing string binding")); + } else { + /* FIXME:LOW Make flags more flexible */ + binding->flags |= DCERPC_AUTH_NTLM | DCERPC_SIGN; + if (DEBUGLVL(11)) + binding->flags |= DCERPC_DEBUG_PRINT_BOTH; + status = dcerpc_pipe_connect_b(iface->ctx->event_ctx, &p, binding, + ndr_table_by_uuid(&iid), + dcom_get_server_credentials(iface->ctx, binding->host), + iface->ctx->event_ctx, iface->ctx->lp_ctx); + talloc_unlink(iface->ctx, binding); + } + if (NT_STATUS_IS_OK(status)) break; + } + + if (NT_STATUS_IS_ERR(status)) { + DEBUG(0, ("Unable to connect to remote host - %s\n", nt_errstr(status))); + return status; + } + + DEBUG(2, ("Successfully connected to OXID %llx\n", (long long)oxid)); + + ox->pipe = *pp = p; + + return NT_STATUS_OK; +} + +NTSTATUS dcom_OBJREF_from_IUnknown(struct OBJREF *o, struct IUnknown *p) +{ + /* FIXME: Cache generated objref objects? */ + ZERO_STRUCTP(o); + + if (!p) { + o->signature = OBJREF_SIGNATURE; + o->flags = OBJREF_NULL; + } else { + *o = p->obj; + switch(o->flags) { + case OBJREF_CUSTOM: { + marshal_fn marshal; + + marshal = dcom_marshal_by_clsid(&o->u_objref.u_custom.clsid); + if (marshal) { + return marshal(p, o); + } else { + return NT_STATUS_NOT_SUPPORTED; + } + } + } + } + + return NT_STATUS_OK; +} + +NTSTATUS dcom_IUnknown_from_OBJREF(struct com_context *ctx, struct IUnknown **_p, struct OBJREF *o) +{ + struct IUnknown *p; + struct dcom_object_exporter *ox; + + switch(o->flags) { + case OBJREF_NULL: + *_p = NULL; + return NT_STATUS_OK; + + case OBJREF_STANDARD: + p = talloc_zero(ctx, struct IUnknown); + p->ctx = ctx; + p->obj = *o; + p->vtable = dcom_proxy_vtable_by_iid(&o->iid); + + if (!p->vtable) { + DEBUG(0, ("Unable to find proxy class for interface with IID %s\n", GUID_string(ctx, &o->iid))); + return NT_STATUS_NOT_SUPPORTED; + } + + p->vtable->Release_send = dcom_release_send; + + ox = object_exporter_by_oxid(ctx, o->u_objref.u_standard.std.oxid); + /* FIXME: Add object to list of objects to ping */ + *_p = p; + return NT_STATUS_OK; + + case OBJREF_HANDLER: + p = talloc_zero(ctx, struct IUnknown); + p->ctx = ctx; + p->obj = *o; + ox = object_exporter_by_oxid(ctx, o->u_objref.u_handler.std.oxid ); + /* FIXME: Add object to list of objects to ping */ +/*FIXME p->vtable = dcom_vtable_by_clsid(&o->u_objref.u_handler.clsid);*/ + /* FIXME: Do the custom unmarshaling call */ + + *_p = p; + return NT_STATUS_NOT_SUPPORTED; + + case OBJREF_CUSTOM: + p = talloc_zero(ctx, struct IUnknown); + p->ctx = ctx; + p->vtable = NULL; + p->obj = *o; + unmarshal_fn unmarshal; + unmarshal = dcom_unmarshal_by_clsid(&o->u_objref.u_custom.clsid); + *_p = p; + if (unmarshal) { + return unmarshal(ctx, o, _p); + } else { + return NT_STATUS_NOT_SUPPORTED; + } + } + + return NT_STATUS_NOT_SUPPORTED; +} + +uint64_t dcom_get_current_oxid(void) +{ + return getpid(); +} + +/* FIXME:Fake async dcom_get_pipe_* */ +struct composite_context *dcom_get_pipe_send(struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + struct composite_context *c; + + c = composite_create(0, d->ctx->event_ctx); + if (c == NULL) return NULL; + c->private_data = d; + /* composite_done(c); bugged - callback is triggered twice by composite_continue and composite_done */ + c->state = COMPOSITE_STATE_DONE; /* this is workaround */ + + return c; +} + +NTSTATUS dcom_get_pipe_recv(struct composite_context *c, struct dcerpc_pipe **pp) +{ + NTSTATUS status; + + status = dcom_get_pipe((struct IUnknown *)c->private_data, pp); + talloc_free(c); + + return status; +} + +/* FIXME:avg put IUnknown_Release_out into header */ +struct IUnknown_Release_out { + uint32_t result; +}; + +void dcom_release_continue(struct composite_context *cr) +{ + struct composite_context *c; + struct IUnknown *d; + struct IUnknown_Release_out *out; + WERROR r; + + c = talloc_get_type(cr->async.private_data, struct composite_context); + d = c->private_data; + r = IRemUnknown_RemRelease_recv(cr); + talloc_free(d); + out = talloc_zero(c, struct IUnknown_Release_out); + out->result = W_ERROR_V(r); + c->private_data = out; + composite_done(c); +} + +struct composite_context *dcom_release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + struct composite_context *c, *cr; + struct REMINTERFACEREF iref; + struct dcom_object_exporter *ox; + + c = composite_create(d->ctx, d->ctx->event_ctx); + if (c == NULL) return NULL; + c->private_data = d; + + ox = object_exporter_by_ip(d->ctx, d); + iref.ipid = IUnknown_ipid(d); + iref.cPublicRefs = 5; + iref.cPrivateRefs = 0; + cr = IRemUnknown_RemRelease_send(ox->rem_unknown, mem_ctx, 1, &iref); + + composite_continue(c, cr, dcom_release_continue, c); + return c; +} + +uint32_t dcom_release_recv(struct composite_context *c) +{ + NTSTATUS status; + WERROR r; + + status = composite_wait(c); + if (!NT_STATUS_IS_OK(status)) + r = ntstatus_to_werror(status); + else + W_ERROR_V(r) = ((struct IUnknown_Release_out *)c->private_data)->result; + talloc_free(c); + return W_ERROR_IS_OK(r) ? 0 : W_ERROR_V(r); +} + +uint32_t dcom_release(void *interface, TALLOC_CTX *mem_ctx) +{ + struct composite_context *c; + + c = dcom_release_send(interface, mem_ctx); + return dcom_release_recv(c); +} + +void dcom_proxy_async_call_recv_pipe_send_rpc(struct composite_context *c_pipe) +{ + struct composite_context *c; + struct dcom_proxy_async_call_state *s; + struct dcerpc_pipe *p; + struct rpc_request *req; + NTSTATUS status; + + c = c_pipe->async.private_data; + s = talloc_get_type(c->private_data, struct dcom_proxy_async_call_state); + + status = dcom_get_pipe_recv(c_pipe, &p); + if (!NT_STATUS_IS_OK(status)) { + composite_error(c, NT_STATUS_RPC_NT_CALL_FAILED); + return; + } + + req = dcerpc_ndr_request_send(p, &s->d->obj.u_objref.u_standard.std.ipid, s->table, s->opnum, s, s->r); + composite_continue_rpc(c, req, s->continuation, c); +} diff --git a/source4/lib/com/dcom/tables.c b/source4/lib/com/dcom/tables.c new file mode 100644 index 0000000000..26a18a9ae9 --- /dev/null +++ b/source4/lib/com/dcom/tables.c @@ -0,0 +1,92 @@ +/* + Unix SMB/CIFS implementation. + DCOM proxy tables functionality + Copyright (C) 2005 Jelmer Vernooij <jelmer@samba.org> + Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/util/dlinklist.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "lib/com/dcom/dcom.h" + +static struct dcom_proxy { + struct IUnknown_vtable *vtable; + struct dcom_proxy *prev, *next; +} *proxies = NULL; + +NTSTATUS dcom_register_proxy(struct IUnknown_vtable *proxy_vtable) +{ + struct dcom_proxy *proxy = talloc(talloc_autofree_context(), struct dcom_proxy); + + proxy->vtable = proxy_vtable; + DLIST_ADD(proxies, proxy); + + return NT_STATUS_OK; +} + +struct IUnknown_vtable *dcom_proxy_vtable_by_iid(struct GUID *iid) +{ + struct dcom_proxy *p; + for (p = proxies; p; p = p->next) { + if (GUID_equal(&p->vtable->iid, iid)) { + return p->vtable; + } + } + return NULL; +} + +static struct dcom_marshal { + struct GUID clsid; + marshal_fn marshal; + unmarshal_fn unmarshal; + struct dcom_marshal *prev, *next; +} *marshals = NULL; + +NTSTATUS dcom_register_marshal(struct GUID *clsid, marshal_fn marshal, unmarshal_fn unmarshal) +{ + struct dcom_marshal *p = talloc(talloc_autofree_context(), struct dcom_marshal); + + p->clsid = *clsid; + p->marshal = marshal; + p->unmarshal = unmarshal; + DLIST_ADD(marshals, p); + return NT_STATUS_OK; +} + +_PUBLIC_ marshal_fn dcom_marshal_by_clsid(struct GUID *clsid) +{ + struct dcom_marshal *p; + for (p = marshals; p; p = p->next) { + if (GUID_equal(&p->clsid, clsid)) { + return p->marshal; + } + } + return NULL; +} + +_PUBLIC_ unmarshal_fn dcom_unmarshal_by_clsid(struct GUID *clsid) +{ + struct dcom_marshal *p; + for (p = marshals; p; p = p->next) { + if (GUID_equal(&p->clsid, clsid)) { + return p->unmarshal; + } + } + return NULL; +} + diff --git a/source4/lib/com/main.c b/source4/lib/com/main.c new file mode 100644 index 0000000000..3e4127f246 --- /dev/null +++ b/source4/lib/com/main.c @@ -0,0 +1,111 @@ +/* + Unix SMB/CIFS implementation. + Main COM functionality + Copyright (C) 2004 Jelmer Vernooij <jelmer@samba.org> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "dlinklist.h" +#include "lib/com/com.h" +#include "lib/events/events.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "build.h" + +WERROR com_init_ctx(struct com_context **ctx, struct event_context *event_ctx) +{ + *ctx = talloc(NULL, struct com_context); + if (event_ctx == NULL) { + event_ctx = event_context_init(*ctx); + } + (*ctx)->event_ctx = event_ctx; + return WERR_OK; +} + +WERROR com_create_object(struct com_context *ctx, struct GUID *clsid, int num_ifaces, struct GUID *iid, struct IUnknown **ip, WERROR *results) +{ + struct IUnknown *iunk = NULL; + struct IClassFactory *factory; + WERROR error; + int i; + struct GUID classfact_iid; + + GUID_from_string(DCERPC_ICLASSFACTORY_UUID, &classfact_iid); + + /* Obtain class object */ + error = com_get_class_object(ctx, clsid, &classfact_iid, (struct IUnknown **)&factory); + if (!W_ERROR_IS_OK(error)) { + DEBUG(3, ("Unable to obtain class object for %s\n", GUID_string(NULL, clsid))); + return error; + } + + /* Run IClassFactory::CreateInstance() */ + error = IClassFactory_CreateInstance(factory, ctx, NULL, &classfact_iid, &iunk); + if (!W_ERROR_IS_OK(error)) { + DEBUG(3, ("Error while calling IClassFactory::CreateInstance : %s\n", win_errstr(error))); + return error; + } + + if (!iunk) { + DEBUG(0, ("IClassFactory_CreateInstance returned success but result pointer is still NULL!\n")); + return WERR_GENERAL_FAILURE; + } + + /* Release class object */ + IUnknown_Release(factory, ctx); + + error = WERR_OK; + + /* Do one or more QueryInterface calls */ + for (i = 0; i < num_ifaces; i++) { + results[i] = IUnknown_QueryInterface(iunk, ctx, &iid[i], &ip[i]); + if (!W_ERROR_IS_OK(results[i])) error = results[i]; + } + + return error; +} + +WERROR com_get_class_object(struct com_context *ctx, struct GUID *clsid, struct GUID *iid, struct IUnknown **ip) +{ + struct IUnknown *iu; + + iu = com_class_by_clsid(ctx, clsid); + if (!iu) { + return WERR_CLASS_NOT_REGISTERED; + } + + return IUnknown_QueryInterface(iu, ctx, iid, ip); +} + +NTSTATUS com_init(void) +{ + static BOOL initialized = False; + + init_module_fn static_init[] = STATIC_com_MODULES; + init_module_fn *shared_init; + + if (initialized) return NT_STATUS_OK; + initialized = True; + + shared_init = load_samba_modules(NULL, "com"); + + run_init_functions(static_init); + run_init_functions(shared_init); + + talloc_free(shared_init); + + return NT_STATUS_OK; +} diff --git a/source4/lib/com/rot.c b/source4/lib/com/rot.c new file mode 100644 index 0000000000..34a5671f5b --- /dev/null +++ b/source4/lib/com/rot.c @@ -0,0 +1,34 @@ +/* + Unix SMB/CIFS implementation. + + Running object table functions + + Copyright (C) Jelmer Vernooij 2004-2005 + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +struct dcom_interface_p *dcom_get_local_iface_p(struct GUID *ipid) +{ + /* FIXME: Call the local ROT and do a + * rot_get_interface_pointer call */ + + /* FIXME: Perhaps have a local (thread-local) table with + * local DCOM objects so that not every DCOM call requires a lookup + * to the ROT? */ + return NULL; +} diff --git a/source4/lib/com/tables.c b/source4/lib/com/tables.c new file mode 100644 index 0000000000..d9989ecdbe --- /dev/null +++ b/source4/lib/com/tables.c @@ -0,0 +1,109 @@ +/* + Unix SMB/CIFS implementation. + COM class tables + Copyright (C) 2004 Jelmer Vernooij <jelmer@samba.org> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "dlinklist.h" +#include "lib/com/com.h" +#include "librpc/gen_ndr/ndr_misc.h" + +/* Specific implementation of one or more interfaces */ +struct com_class +{ + const char *progid; + struct GUID clsid; + + struct IUnknown *class_object; + struct com_class *prev, *next; +} * running_classes = NULL; + +static struct IUnknown *get_com_class_running(const struct GUID *clsid) +{ + struct com_class *c = running_classes; + + while(c) { + + if (GUID_equal(clsid, &c->clsid)) { + return c->class_object; + } + + c = c->next; + } + + return NULL; +} + +static struct IUnknown *get_com_class_so(TALLOC_CTX *mem_ctx, const struct GUID *clsid) +{ + char *mod_name; + char *clsid_str; + void *mod; + get_class_object_function f; + + clsid_str = GUID_string(mem_ctx, clsid); + mod_name = talloc_asprintf(mem_ctx, "%s.so", clsid_str); + talloc_free(clsid_str); + + mod = dlopen(mod_name, 0); + + if (!mod) { + return NULL; + } + + f = dlsym(mod, "get_class_object"); + + if (!f) { + return NULL; + } + + return f(clsid); +} + +struct IUnknown *com_class_by_clsid(struct com_context *ctx, const struct GUID *clsid) +{ + struct IUnknown *c; + + /* Check list of running COM classes first */ + c = get_com_class_running(clsid); + + if (c != NULL) { + return c; + } + + c = get_com_class_so(ctx, clsid); + + if (c != NULL) { + return c; + } + + return NULL; +} + +NTSTATUS com_register_running_class(struct GUID *clsid, const char *progid, struct IUnknown *p) +{ + struct com_class *l = talloc_zero(running_classes?running_classes:talloc_autofree_context(), struct com_class); + + l->clsid = *clsid; + l->progid = talloc_strdup(l, progid); + l->class_object = p; + + DLIST_ADD(running_classes, l); + + return NT_STATUS_OK; +} diff --git a/source4/lib/wmi/config.mk b/source4/lib/wmi/config.mk new file mode 100644 index 0000000000..28f6c73dcd --- /dev/null +++ b/source4/lib/wmi/config.mk @@ -0,0 +1,69 @@ +[SUBSYSTEM::WMI] +PUBLIC_DEPENDENCIES = RPC_NDR_OXIDRESOLVER \ + NDR_DCOM \ + RPC_NDR_REMACT \ + NDR_TABLE \ + DCOM_PROXY_DCOM \ + DCOM + +WMI_OBJ_FILES = $(addprefix $(wmisrcdir)/, wmicore.o wbemdata.o ../../librpc/gen_ndr/dcom_p.o) + +################################# +# Start BINARY wmic +[BINARY::wmic] +INSTALLDIR = BINDIR +PRIVATE_DEPENDENCIES = \ + POPT_SAMBA \ + POPT_CREDENTIALS \ + LIBPOPT \ + WMI + +wmic_OBJ_FILES = $(wmisrcdir)/tools/wmic.o +# End BINARY wmic +################################# + +################################# +# Start BINARY wmis +[BINARY::wmis] +INSTALLDIR = BINDIR +PRIVATE_DEPENDENCIES = \ + POPT_SAMBA \ + POPT_CREDENTIALS \ + LIBPOPT \ + WMI + +wmis_OBJ_FILES = \ + $(wmisrcdir)/tools/wmis.o + +# End BINARY wmis +################################# + +librpc/gen_ndr/dcom_p.c: idl + +####################### +# Start LIBRARY swig_dcerpc +[PYTHON::pywmi] +PUBLIC_DEPENDENCIES = LIBCLI_SMB NDR_MISC LIBSAMBA-UTIL LIBSAMBA-CONFIG WMI + +$(eval $(call python_py_module_template,wmi.py,$(wmisrcdir)/wmi.py)) + +pywmi_OBJ_FILES = $(wmisrcdir)/wmi_wrap.o +$(pywmi_OBJ_FILES): CFLAGS+=$(CFLAG_NO_UNUSED_MACROS) $(CFLAG_NO_CAST_QUAL) + +# End LIBRARY swig_dcerpc +####################### + +################################# +# Start BINARY pdhc +#[BINARY::pdhc] +#INSTALLDIR = BINDIR +#OBJ_FILES = \ +# pdhc.o +#PRIVATE_DEPENDENCIES = \ +# POPT_SAMBA \ +# POPT_CREDENTIALS \ +# LIBPOPT \ +# NDR_TABLE \ +# RPC_NDR_WINREG +# End BINARY pdhc +################################# diff --git a/source4/lib/wmi/tools/wmic.c b/source4/lib/wmi/tools/wmic.c new file mode 100644 index 0000000000..4b84c27c8d --- /dev/null +++ b/source4/lib/wmi/tools/wmic.c @@ -0,0 +1,221 @@ +/* + WMI Sample client + Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl> + Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/cmdline/popt_common.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/gen_ndr/ndr_oxidresolver.h" +#include "librpc/gen_ndr/ndr_oxidresolver_c.h" +#include "librpc/gen_ndr/ndr_dcom.h" +#include "librpc/gen_ndr/ndr_dcom_c.h" +#include "librpc/gen_ndr/ndr_remact_c.h" +#include "librpc/gen_ndr/ndr_epmapper_c.h" +#include "librpc/gen_ndr/com_dcom.h" + +#include "lib/com/dcom/dcom.h" +#include "lib/com/com.h" + +#include "lib/wmi/wmi.h" + +struct program_args { + char *hostname; + char *query; + char *ns; +}; + +static void parse_args(int argc, char *argv[], struct program_args *pmyargs) +{ + poptContext pc; + int opt, i; + + int argc_new; + char **argv_new; + + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION + {"namespace", 0, POPT_ARG_STRING, &pmyargs->ns, 0, + "WMI namespace, default to root\\cimv2", 0}, + POPT_TABLEEND + }; + + pc = poptGetContext("wmi", argc, (const char **) argv, + long_options, POPT_CONTEXT_KEEP_FIRST); + + poptSetOtherOptionHelp(pc, "//host query\n\nExample: wmic -U [domain/]adminuser%password //host \"select * from Win32_ComputerSystem\""); + + while ((opt = poptGetNextOpt(pc)) != -1) { + poptPrintUsage(pc, stdout, 0); + poptFreeContext(pc); + exit(1); + } + + argv_new = discard_const_p(char *, poptGetArgs(pc)); + + argc_new = argc; + for (i = 0; i < argc; i++) { + if (argv_new[i] == NULL) { + argc_new = i; + break; + } + } + + if (argc_new != 3 || argv_new[1][0] != '/' + || argv_new[1][1] != '/') { + poptPrintUsage(pc, stdout, 0); + poptFreeContext(pc); + exit(1); + } + + pmyargs->hostname = argv_new[1] + 2; + pmyargs->query = argv_new[2]; + poptFreeContext(pc); +} + +#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \ + DEBUG(0, ("ERROR: %s\n", msg)); \ + goto error; \ + } else { \ + DEBUG(1, ("OK : %s\n", msg)); \ + } + +#define RETURN_CVAR_ARRAY_STR(fmt, arr) {\ + uint32_t i;\ + char *r;\ +\ + if (!arr) {\ + return talloc_strdup(mem_ctx, "NULL");\ + }\ + r = talloc_strdup(mem_ctx, "(");\ + for (i = 0; i < arr->count; ++i) {\ + r = talloc_asprintf_append(r, fmt "%s", arr->item[i], (i+1 == arr->count)?"":",");\ + }\ + return talloc_asprintf_append(r, ")");\ +} + +char *string_CIMVAR(TALLOC_CTX *mem_ctx, union CIMVAR *v, enum CIMTYPE_ENUMERATION cimtype) +{ + switch (cimtype) { + case CIM_SINT8: return talloc_asprintf(mem_ctx, "%d", v->v_sint8); + case CIM_UINT8: return talloc_asprintf(mem_ctx, "%u", v->v_uint8); + case CIM_SINT16: return talloc_asprintf(mem_ctx, "%d", v->v_sint16); + case CIM_UINT16: return talloc_asprintf(mem_ctx, "%u", v->v_uint16); + case CIM_SINT32: return talloc_asprintf(mem_ctx, "%d", v->v_sint32); + case CIM_UINT32: return talloc_asprintf(mem_ctx, "%u", v->v_uint32); + case CIM_SINT64: return talloc_asprintf(mem_ctx, "%lld", v->v_sint64); + case CIM_UINT64: return talloc_asprintf(mem_ctx, "%llu", v->v_sint64); + case CIM_REAL32: return talloc_asprintf(mem_ctx, "%f", (double)v->v_uint32); + case CIM_REAL64: return talloc_asprintf(mem_ctx, "%f", (double)v->v_uint64); + case CIM_BOOLEAN: return talloc_asprintf(mem_ctx, "%s", v->v_boolean?"True":"False"); + case CIM_STRING: + case CIM_DATETIME: + case CIM_REFERENCE: return talloc_asprintf(mem_ctx, "%s", v->v_string); + case CIM_CHAR16: return talloc_asprintf(mem_ctx, "Unsupported"); + case CIM_OBJECT: return talloc_asprintf(mem_ctx, "Unsupported"); + case CIM_ARR_SINT8: RETURN_CVAR_ARRAY_STR("%d", v->a_sint8); + case CIM_ARR_UINT8: RETURN_CVAR_ARRAY_STR("%u", v->a_uint8); + case CIM_ARR_SINT16: RETURN_CVAR_ARRAY_STR("%d", v->a_sint16); + case CIM_ARR_UINT16: RETURN_CVAR_ARRAY_STR("%u", v->a_uint16); + case CIM_ARR_SINT32: RETURN_CVAR_ARRAY_STR("%d", v->a_sint32); + case CIM_ARR_UINT32: RETURN_CVAR_ARRAY_STR("%u", v->a_uint32); + case CIM_ARR_SINT64: RETURN_CVAR_ARRAY_STR("%lld", v->a_sint64); + case CIM_ARR_UINT64: RETURN_CVAR_ARRAY_STR("%llu", v->a_uint64); + case CIM_ARR_REAL32: RETURN_CVAR_ARRAY_STR("%f", v->a_real32); + case CIM_ARR_REAL64: RETURN_CVAR_ARRAY_STR("%f", v->a_real64); + case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY_STR("%d", v->a_boolean); + case CIM_ARR_STRING: RETURN_CVAR_ARRAY_STR("%s", v->a_string); + case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY_STR("%s", v->a_datetime); + case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY_STR("%s", v->a_reference); + default: return talloc_asprintf(mem_ctx, "Unsupported"); + } +} + +#undef RETURN_CVAR_ARRAY_STR + +int main(int argc, char **argv) +{ + struct program_args args = {}; + uint32_t cnt = 5, ret; + char *class_name = NULL; + WERROR result; + NTSTATUS status; + struct IWbemServices *pWS = NULL; + struct BSTR queryLanguage, query; + struct IEnumWbemClassObject *pEnum = NULL; + struct com_context *ctx = NULL; + + parse_args(argc, argv, &args); + + wmi_init(&ctx, cmdline_credentials); + + if (!args.ns) + args.ns = "root\\cimv2"; + result = WBEM_ConnectServer(ctx, args.hostname, args.ns, 0, 0, 0, 0, 0, 0, &pWS); + WERR_CHECK("Login to remote object."); + + queryLanguage.data = "WQL"; + query.data = args.query; + result = IWbemServices_ExecQuery(pWS, ctx, queryLanguage, query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_ENSURE_LOCATABLE, NULL, &pEnum); + WERR_CHECK("WMI query execute."); + + IEnumWbemClassObject_Reset(pEnum, ctx); + WERR_CHECK("Reset result of WMI query."); + + do { + uint32_t i, j; + struct WbemClassObject *co[cnt]; + + result = IEnumWbemClassObject_SmartNext(pEnum, ctx, 0xFFFFFFFF, cnt, co, &ret); + /* WERR_BADFUNC is OK, it means only that there is less returned objects than requested */ + if (!W_ERROR_EQUAL(result, WERR_BADFUNC)) { + WERR_CHECK("Retrieve result data."); + } else { + DEBUG(1, ("OK : Retrieved less objects than requested (it is normal).\n")); + } + if (!ret) break; + + for (i = 0; i < ret; ++i) { + if (!class_name || strcmp(co[i]->obj_class->__CLASS, class_name)) { + if (class_name) talloc_free(class_name); + class_name = talloc_strdup(ctx, co[i]->obj_class->__CLASS); + printf("CLASS: %s\n", class_name); + for (j = 0; j < co[i]->obj_class->__PROPERTY_COUNT; ++j) + printf("%s%s", j?"|":"", co[i]->obj_class->properties[j].name); + printf("\n"); + } + for (j = 0; j < co[i]->obj_class->__PROPERTY_COUNT; ++j) { + char *s; + s = string_CIMVAR(ctx, &co[i]->instance->data[j], co[i]->obj_class->properties[j].desc->cimtype & CIM_TYPEMASK); + printf("%s%s", j?"|":"", s); + } + printf("\n"); + } + } while (ret == cnt); + talloc_free(ctx); + return 0; +error: + status = werror_to_ntstatus(result); + fprintf(stderr, "NTSTATUS: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status)); + talloc_free(ctx); + return 1; +} diff --git a/source4/lib/wmi/tools/wmis.c b/source4/lib/wmi/tools/wmis.c new file mode 100644 index 0000000000..314fdd1cd7 --- /dev/null +++ b/source4/lib/wmi/tools/wmis.c @@ -0,0 +1,221 @@ +/* + WMI Sample client + Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl> + Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "lib/cmdline/popt_common.h" +#include "auth/credentials/credentials.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/gen_ndr/ndr_oxidresolver.h" +#include "librpc/gen_ndr/ndr_oxidresolver_c.h" +#include "librpc/gen_ndr/dcom.h" +#include "librpc/gen_ndr/ndr_dcom.h" +#include "librpc/gen_ndr/ndr_dcom_c.h" +#include "librpc/gen_ndr/ndr_remact_c.h" +#include "librpc/gen_ndr/ndr_epmapper_c.h" +#include "librpc/gen_ndr/com_dcom.h" + +#include "lib/com/dcom/dcom.h" +#include "librpc/gen_ndr/com_wmi.h" +#include "librpc/ndr/ndr_table.h" + +#include "lib/wmi/wmi.h" + +struct program_args { + char *hostname; + char *query; +}; + +static void parse_args(int argc, char *argv[], struct program_args *pmyargs) +{ + poptContext pc; + int opt, i; + + int argc_new; + char **argv_new; + + struct poptOption long_options[] = { + POPT_AUTOHELP + POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION + POPT_TABLEEND + }; + + pc = poptGetContext("wmi", argc, (const char **) argv, + long_options, POPT_CONTEXT_KEEP_FIRST); + + poptSetOtherOptionHelp(pc, "//host\n\nExample: wmis -U [domain/]adminuser%password //host"); + + while ((opt = poptGetNextOpt(pc)) != -1) { + poptPrintUsage(pc, stdout, 0); + poptFreeContext(pc); + exit(1); + } + + argv_new = discard_const_p(char *, poptGetArgs(pc)); + + argc_new = argc; + for (i = 0; i < argc; i++) { + if (argv_new[i] == NULL) { + argc_new = i; + break; + } + } + + if (argc_new < 2 || argv_new[1][0] != '/' + || argv_new[1][1] != '/') { + poptPrintUsage(pc, stdout, 0); + poptFreeContext(pc); + exit(1); + } + + pmyargs->hostname = argv_new[1] + 2; + poptFreeContext(pc); +} + +#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \ + DEBUG(0, ("ERROR: %s\n", msg)); \ + goto error; \ + } else { \ + DEBUG(1, ("OK : %s\n", msg)); \ + } +/* +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services) +{ + struct GUID clsid; + struct GUID iid; + WERROR result, coresult; + struct IUnknown **mqi; + struct IWbemLevel1Login *pL; + + if (user) { + char *cred; + struct cli_credentials *cc; + + cred = talloc_asprintf(NULL, "%s%%%s", user, password); + cc = cli_credentials_init(ctx); + cli_credentials_set_conf(cc); + cli_credentials_parse_string(cc, cred, CRED_SPECIFIED); + dcom_set_server_credentials(ctx, server, cc); + talloc_free(cred); + } + + GUID_from_string(CLSID_WBEMLEVEL1LOGIN, &clsid); + GUID_from_string(COM_IWBEMLEVEL1LOGIN_UUID, &iid); + result = dcom_create_object(ctx, &clsid, server, 1, &iid, &mqi, &coresult); + WERR_CHECK("dcom_create_object."); + result = coresult; + WERR_CHECK("Create remote WMI object."); + pL = (struct IWbemLevel1Login *)mqi[0]; + talloc_free(mqi); + + result = IWbemLevel1Login_NTLMLogin(pL, ctx, nspace, locale, flags, wbem_ctx, services); + WERR_CHECK("Login to remote object."); +error: + return result; +} +*/ +WERROR WBEM_RemoteExecute(struct IWbemServices *pWS, const char *cmdline, uint32_t *ret_code) +{ + struct IWbemClassObject *wco = NULL; + struct IWbemClassObject *inc, *outc, *in; + struct IWbemClassObject *out = NULL; + WERROR result; + union CIMVAR v; + TALLOC_CTX *ctx; + struct BSTR objectPath, methodName; + + ctx = talloc_new(0); + + objectPath.data = "Win32_Process"; + + result = IWbemServices_GetObject(pWS, ctx, objectPath, + WBEM_FLAG_RETURN_WBEM_COMPLETE, NULL, &wco, NULL); + WERR_CHECK("GetObject."); + + result = IWbemClassObject_GetMethod(wco, ctx, "Create", 0, &inc, &outc); + WERR_CHECK("IWbemClassObject_GetMethod."); + + result = IWbemClassObject_SpawnInstance(inc, ctx, 0, &in); + WERR_CHECK("IWbemClassObject_SpawnInstance."); + + v.v_string = cmdline; + result = IWbemClassObject_Put(in, ctx, "CommandLine", 0, &v, 0); + WERR_CHECK("IWbemClassObject_Put(CommandLine)."); + + methodName.data = "Create"; + result = IWbemServices_ExecMethod(pWS, ctx, objectPath, methodName, 0, NULL, in, &out, + NULL); + WERR_CHECK("IWbemServices_ExecMethod."); + + if (ret_code) { + result = WbemClassObject_Get(out->object_data, ctx, "ReturnValue", 0, &v, 0, 0); + WERR_CHECK("IWbemClassObject_Put(CommandLine)."); + *ret_code = v.v_uint32; + } +error: + talloc_free(ctx); + return result; +} + +int main(int argc, char **argv) +{ + struct program_args args = {}; + struct com_context *ctx = NULL; + WERROR result; + NTSTATUS status; + struct IWbemServices *pWS = NULL; + struct IEnumWbemClassObject *pEnum = NULL; + uint32_t cnt; + struct BSTR queryLanguage; + struct BSTR query; + + parse_args(argc, argv, &args); + + wmi_init(&ctx, cmdline_credentials); + result = WBEM_ConnectServer(ctx, args.hostname, "root\\cimv2", 0, 0, 0, 0, 0, 0, &pWS); + WERR_CHECK("WBEM_ConnectServer."); + + printf("1: Creating directory C:\\wmi_test_dir_tmp using method Win32_Process.Create\n"); + WBEM_RemoteExecute(pWS, "cmd.exe /C mkdir C:\\wmi_test_dir_tmp", &cnt); + WERR_CHECK("WBEM_RemoteExecute."); + printf("2: ReturnCode: %d\n", cnt); + + printf("3: Monitoring directory C:\\wmi_test_dir_tmp. Please create/delete files in that directory to see notifications, after 4 events program quits.\n"); + query.data = "SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE Targetinstance ISA 'CIM_DirectoryContainsFile' and TargetInstance.GroupComponent= 'Win32_Directory.Name=\"C:\\\\\\\\wmi_test_dir_tmp\"'"; + queryLanguage.data = "WQL"; + result = IWbemServices_ExecNotificationQuery(pWS, ctx, queryLanguage, + query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum); + WERR_CHECK("WMI query execute."); + for (cnt = 0; cnt < 4; ++cnt) { + struct WbemClassObject *co; + uint32_t ret; + result = IEnumWbemClassObject_SmartNext(pEnum, ctx, 0xFFFFFFFF, 1, &co, &ret); + WERR_CHECK("IEnumWbemClassObject_Next."); + printf("%s\n", co->obj_class->__CLASS); + } + +error: + status = werror_to_ntstatus(result); + fprintf(stderr, "NTSTATUS: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status)); + talloc_free(ctx); + return 1; +} diff --git a/source4/lib/wmi/wbemdata.c b/source4/lib/wmi/wbemdata.c new file mode 100644 index 0000000000..b24499ab5c --- /dev/null +++ b/source4/lib/wmi/wbemdata.c @@ -0,0 +1,654 @@ +/* + WMI Implementation + Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl> + Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "librpc/gen_ndr/dcom.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "librpc/ndr/libndr.h" +#include "librpc/ndr/libndr_proto.h" +#include "lib/com/com.h" +#include "lib/com/dcom/dcom.h" +#include "lib/util/dlinklist.h" +#include "librpc/ndr/libndr.h" +#include "librpc/gen_ndr/ndr_dcom.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/gen_ndr/ndr_misc.h" +#include "lib/talloc/talloc.h" +#include "libcli/composite/composite.h" +#include "lib/wmi/wmi.h" + +enum { + DATATYPE_CLASSOBJECT = 2, + DATATYPE_OBJECT = 3, + COFLAG_IS_CLASS = 4, +}; + +static enum ndr_err_code marshal(TALLOC_CTX *mem_ctx, struct IUnknown *pv, struct OBJREF *o) +{ + struct ndr_push *ndr; + struct WbemClassObject *wco; + struct MInterfacePointer *mp; + + mp = (struct MInterfacePointer *)((char *)o - offsetof(struct MInterfacePointer, obj)); /* FIXME:high remove this Mumbo Jumbo */ + wco = pv->object_data; + ndr = talloc_zero(mem_ctx, struct ndr_push); + ndr->flags = 0; + ndr->alloc_size = 1024; + ndr->data = talloc_array(mp, uint8_t, ndr->alloc_size); + + if (wco) { + uint32_t ofs; + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0x12345678)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + NDR_CHECK(ndr_push_WbemClassObject(ndr, NDR_SCALARS | NDR_BUFFERS, wco)); + ofs = ndr->offset; + ndr->offset = 4; + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ofs - 8)); + ndr->offset = ofs; + } else { + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0)); + } + o->u_objref.u_custom.pData = talloc_realloc(mp, ndr->data, uint8_t, ndr->offset); + o->u_objref.u_custom.size = ndr->offset; + mp->size = sizeof(struct OBJREF) - sizeof(union OBJREF_Types) + sizeof(struct u_custom) + o->u_objref.u_custom.size - 4; + if (DEBUGLVL(9)) { + NDR_PRINT_DEBUG(WbemClassObject, wco); + } + return NDR_ERR_SUCCESS; +} + +static enum ndr_err_code unmarshal(TALLOC_CTX *mem_ctx, struct OBJREF *o, struct IUnknown **pv) +{ + struct ndr_pull *ndr; + struct WbemClassObject *wco; + enum ndr_err_code ndr_err; + uint32_t u; + + mem_ctx = talloc_new(0); + ndr = talloc_zero(mem_ctx, struct ndr_pull); + ndr->current_mem_ctx = mem_ctx; + ndr->data = o->u_objref.u_custom.pData; + ndr->data_size = o->u_objref.u_custom.size; + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + if (!u) { + talloc_free(*pv); + *pv = NULL; + return NDR_ERR_SUCCESS; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + if (u + 8 > ndr->data_size) { + DEBUG(1, ("unmarshall_IWbemClassObject: Incorrect data_size")); + return NDR_ERR_BUFSIZE; + } + wco = talloc_zero(*pv, struct WbemClassObject); + ndr->current_mem_ctx = wco; + ndr_err = ndr_pull_WbemClassObject(ndr, NDR_SCALARS | NDR_BUFFERS, wco); + + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err) && (DEBUGLVL(9))) { + NDR_PRINT_DEBUG(WbemClassObject, wco); + } + + if (NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { + (*pv)->object_data = wco; + } else { + talloc_free(wco); + } + return NDR_ERR_SUCCESS; +} + +WERROR dcom_IWbemClassObject_from_WbemClassObject(struct com_context *ctx, struct IWbemClassObject **_p, struct WbemClassObject *wco) +{ + struct IWbemClassObject *p; + + p = talloc_zero(ctx, struct IWbemClassObject); + p->ctx = ctx; + p->obj.signature = 0x574f454d; + p->obj.flags = OBJREF_CUSTOM; + GUID_from_string("dc12a681-737f-11cf-884d-00aa004b2e24", &p->obj.iid); + GUID_from_string("4590f812-1d3a-11d0-891f-00aa004b2e24", &p->obj.u_objref.u_custom.clsid); + p->object_data = (void *)wco; + talloc_steal(p, p->object_data); + *_p = p; + return WERR_OK; +} + +WERROR IWbemClassObject_GetMethod(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, struct IWbemClassObject **in, struct IWbemClassObject **out) +{ + uint32_t i; + struct WbemClassObject *wco; + + wco = (struct WbemClassObject *)d->object_data; + for (i = 0; i < wco->obj_methods->count; ++i) + if (!strcmp(wco->obj_methods->method[i].name, name)) { + if (in) dcom_IWbemClassObject_from_WbemClassObject(d->ctx, in, wco->obj_methods->method[i].in); + if (out) dcom_IWbemClassObject_from_WbemClassObject(d->ctx, out, wco->obj_methods->method[i].out); + return WERR_OK; + } + return WERR_NOT_FOUND; +} + +void WbemClassObject_CreateInstance(struct WbemClassObject *wco) +{ + uint32_t i; + + wco->instance = talloc_zero(wco, struct WbemInstance); + wco->instance->default_flags = talloc_array(wco->instance, uint8_t, wco->obj_class->__PROPERTY_COUNT); + wco->instance->data = talloc_array(wco->instance, union CIMVAR, wco->obj_class->__PROPERTY_COUNT); + memset(wco->instance->data, 0, sizeof(union CIMVAR) * wco->obj_class->__PROPERTY_COUNT); + for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) { + wco->instance->default_flags[i] = 1; /* FIXME:high resolve this magic */ + } + wco->instance->__CLASS = wco->obj_class->__CLASS; + wco->instance->u2_4 = 4; + wco->instance->u3_1 = 1; +} + +WERROR IWbemClassObject_Clone(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, struct IWbemClassObject **copy) +{ + return WERR_NOT_SUPPORTED; +} + +WERROR IWbemClassObject_SpawnInstance(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, uint32_t flags, struct IWbemClassObject **instance) +{ + struct WbemClassObject *wco, *nwco; + + wco = (struct WbemClassObject *)d->object_data; + nwco = talloc_zero(mem_ctx, struct WbemClassObject); + nwco->flags = WCF_INSTANCE; + nwco->obj_class = wco->obj_class; + WbemClassObject_CreateInstance(nwco); + dcom_IWbemClassObject_from_WbemClassObject(d->ctx, instance, nwco); + return WERR_OK; +} + +void duplicate_WbemQualifier(TALLOC_CTX *mem_ctx, const struct WbemQualifier *src, struct WbemQualifier *dst) +{ + dst->name = src->name; + if (src->name) dst->name = talloc_strdup(mem_ctx, src->name); + + dst->flavors = src->flavors; + + dst->cimtype = src->cimtype; + + duplicate_CIMVAR(mem_ctx, &src->value, &dst->value, src->cimtype); +} + +void duplicate_CIMSTRINGS(TALLOC_CTX *mem_ctx, const struct CIMSTRINGS *src, struct CIMSTRINGS *dst) +{ + uint32_t i; + + dst->count = src->count; + for (i = 0; i < src->count; ++i) + dst->item[i] = talloc_strdup(mem_ctx, src->item[i]); +} + +void duplicate_WbemQualifiers(TALLOC_CTX *mem_ctx, const struct WbemQualifiers *src, struct WbemQualifiers *dst) +{ + uint32_t i; + + dst->count = src->count; + for (i = 0; i < src->count; ++i) { + dst->item[i] = talloc_zero(mem_ctx, struct WbemQualifier); + duplicate_WbemQualifier(dst->item[i], src->item[i], dst->item[i]); + } +} + +void duplicate_WbemClass(TALLOC_CTX *mem_ctx, const struct WbemClass *src, struct WbemClass *dst) +{ + uint32_t i; + + dst->u_0 = src->u_0; + + dst->__CLASS = src->__CLASS; + if (src->__CLASS) dst->__CLASS = talloc_strdup(mem_ctx, src->__CLASS); + + duplicate_CIMSTRINGS(mem_ctx, &src->__DERIVATION, &dst->__DERIVATION); + duplicate_WbemQualifiers(mem_ctx, &src->qualifiers, &dst->qualifiers); + + dst->__PROPERTY_COUNT = src->__PROPERTY_COUNT; + + dst->properties = talloc_array(mem_ctx, struct WbemClassProperty, src->__PROPERTY_COUNT); + for (i = 0; i < src->__PROPERTY_COUNT; ++i) { + dst->properties[i].property.name = talloc_strdup(dst->properties, src->properties[i].property.name); + dst->properties[i].property.desc = talloc_memdup(dst->properties, src->properties[i].property.desc, sizeof(*src->properties[i].property.desc)); + duplicate_WbemQualifiers(dst->properties[i].property.desc, &src->properties[i].property.desc->qualifiers, &dst->properties[i].property.desc->qualifiers); + } + + for (i = 0; i < src->__PROPERTY_COUNT; ++i) { + dst->properties[i].default_flags = src->properties[i].default_flags; + duplicate_CIMVAR(dst->properties, &src->properties[i].default_values, &dst->properties[i].default_values, src->properties[i].property.desc->cimtype); + } +} + +void duplicate_WbemMethod(TALLOC_CTX *mem_ctx, const struct WbemMethod *src, struct WbemMethod *dst) +{ + dst->name = src->name; + if (src->name) dst->name = talloc_strdup(mem_ctx, src->name); + + dst->u0 = src->u0; + dst->u1 = src->u1; + + dst->qualifiers = talloc_zero(mem_ctx, struct WbemQualifiers); + duplicate_WbemQualifiers(dst->qualifiers, src->qualifiers, dst->qualifiers); + + dst->in = src->in; + if (src->in) { + dst->in = talloc_zero(mem_ctx, struct WbemClassObject); + duplicate_WbemClassObject(dst->in, src->in, dst->in); + } + + dst->out = src->out; + if (src->out) { + dst->out = talloc_zero(mem_ctx, struct WbemClassObject); + duplicate_WbemClassObject(dst->out, src->out, dst->out); + } +} + +void duplicate_WbemMethods(TALLOC_CTX *mem_ctx, const struct WbemMethods *src, struct WbemMethods *dst) +{ + uint32_t i; + + dst->count = src->count; + dst->u0 = src->u0; + for (i = 0; i < src->count; ++i) + duplicate_WbemMethod(mem_ctx, &src->method[i], &dst->method[i]); +} + +void duplicate_WbemInstance(TALLOC_CTX *mem_ctx, const struct WbemInstance *src, struct WbemInstance *dst, const struct WbemClass *cls) +{ + uint32_t i; + + dst->u1_0 = src->u1_0; + + dst->__CLASS = src->__CLASS; + if (src->__CLASS) dst->__CLASS = talloc_strdup(mem_ctx, src->__CLASS); + + dst->default_flags = talloc_array(mem_ctx, uint8_t, cls->__PROPERTY_COUNT); + dst->data = talloc_array(mem_ctx, union CIMVAR, cls->__PROPERTY_COUNT); + for (i = 0; i < cls->__PROPERTY_COUNT; ++i) { + dst->default_flags[i] = src->default_flags[i]; + duplicate_CIMVAR(dst->data, &src->data[i], &dst->data[i], cls->properties[i].property.desc->cimtype); + } + + dst->u2_4 = src->u2_4; + dst->u3_1 = src->u3_1; +} + +void duplicate_WbemClassObject(TALLOC_CTX *mem_ctx, const struct WbemClassObject *src, struct WbemClassObject *dst) +{ + dst->flags = src->flags; + if (src->flags & WCF_CLASS) { + dst->__SERVER = talloc_strdup(mem_ctx, src->__SERVER); + dst->__NAMESPACE = talloc_strdup(mem_ctx, src->__NAMESPACE); + } + if (src->flags & WCF_DECORATIONS) { + dst->sup_class = talloc_zero(mem_ctx, struct WbemClass); + duplicate_WbemClass(dst->sup_class, src->sup_class, dst->sup_class); + + dst->sup_methods = talloc_zero(mem_ctx, struct WbemMethods); + duplicate_WbemMethods(dst->sup_methods, src->sup_methods, dst->sup_methods); + + dst->obj_methods = talloc_zero(mem_ctx, struct WbemMethods); + duplicate_WbemMethods(dst->obj_methods, src->obj_methods, dst->obj_methods); + } + if (src->flags & (WCF_CLASS | WCF_INSTANCE)) { + dst->obj_class = talloc_zero(mem_ctx, struct WbemClass); + duplicate_WbemClass(dst->obj_class, src->obj_class, dst->obj_class); + } + if (src->flags & WCF_INSTANCE) { + dst->instance = talloc_zero(mem_ctx, struct WbemInstance); + duplicate_WbemInstance(dst->instance, src->instance, dst->instance, src->obj_class); + } +} + +void duplicate_CIMVAR(TALLOC_CTX *mem_ctx, const union CIMVAR *src, union CIMVAR *dst, enum CIMTYPE_ENUMERATION cimtype) +{ + uint32_t i; + + switch (cimtype & CIM_TYPEMASK) { + case CIM_SINT8: + case CIM_UINT8: + case CIM_SINT16: + case CIM_UINT16: + case CIM_SINT32: + case CIM_UINT32: + case CIM_SINT64: + case CIM_UINT64: + case CIM_REAL32: + case CIM_REAL64: + case CIM_BOOLEAN: + *dst = *src; + break; + case CIM_STRING: + case CIM_DATETIME: + case CIM_REFERENCE: + dst->v_string = talloc_strdup(mem_ctx, src->v_string); + break; + case CIM_OBJECT: + dst->v_object = talloc_zero(mem_ctx, struct WbemClassObject); + duplicate_WbemClassObject(dst->v_object, src->v_object, dst->v_object); + break; + case CIM_ARR_SINT8: + case CIM_ARR_UINT8: + dst->a_uint8 = talloc_memdup(mem_ctx, src->a_uint8, sizeof(struct arr_uint8)); + dst->a_uint8->item = talloc_memdup(dst->a_uint8, src->a_uint8->item, src->a_uint8->count); + break; + case CIM_ARR_SINT16: + case CIM_ARR_UINT16: + case CIM_ARR_BOOLEAN: + dst->a_uint8 = talloc_memdup(mem_ctx, src->a_uint8, sizeof(struct arr_uint8)); + dst->a_uint8->item = talloc_memdup(dst->a_uint8, src->a_uint8->item, 2*src->a_uint8->count); + break; + case CIM_ARR_SINT32: + case CIM_ARR_UINT32: + case CIM_ARR_REAL32: + dst->a_uint8 = talloc_memdup(mem_ctx, src->a_uint8, sizeof(struct arr_uint8)); + dst->a_uint8->item = talloc_memdup(dst->a_uint8, src->a_uint8->item, 4*src->a_uint8->count); + break; + case CIM_ARR_SINT64: + case CIM_ARR_UINT64: + case CIM_ARR_REAL64: + dst->a_uint8 = talloc_memdup(mem_ctx, src->a_uint8, sizeof(struct arr_uint8)); + dst->a_uint8->item = talloc_memdup(dst->a_uint8, src->a_uint8->item, 8*src->a_uint8->count); + break; + case CIM_ARR_STRING: + case CIM_ARR_DATETIME: + case CIM_ARR_REFERENCE: + dst->a_uint8 = talloc_memdup(mem_ctx, src->a_uint8, sizeof(struct arr_uint8)); + dst->a_uint8->item = talloc_memdup(dst->a_uint8, src->a_uint8->item, 4*src->a_uint8->count); + for (i = 0; i < src->a_uint8->count; ++i) + dst->a_string->item[i] = talloc_strdup(dst->a_uint8->item, src->a_string->item[i]); + break; + default: + DEBUG(0, ("duplicate_CIMVAR: cimtype 0x%04X not supported\n", cimtype & CIM_TYPEMASK)); + break; + } +} + +WERROR WbemClassObject_Get(struct WbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION *cimtype, uint32_t *flavor) +{ + uint32_t i; + for (i = 0; i < d->obj_class->__PROPERTY_COUNT; ++i) { + if (!strcmp(d->obj_class->properties[i].property.name, name)) { + duplicate_CIMVAR(mem_ctx, &d->instance->data[i], val, d->obj_class->properties[i].property.desc->cimtype); + if (cimtype != NULL) + *cimtype = d->obj_class->properties[i].property.desc->cimtype; + if (flavor != NULL) + *flavor = 0; /* FIXME:avg implement flavor */ + return WERR_OK; + } + } + return WERR_NOT_FOUND; +} + +WERROR IWbemClassObject_Put(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION cimtype) +{ + struct WbemClassObject *wco; + uint32_t i; + + wco = (struct WbemClassObject *)d->object_data; + for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) { + if (!strcmp(wco->obj_class->properties[i].property.name, name)) { + if (cimtype && cimtype != wco->obj_class->properties[i].property.desc->cimtype) return WERR_INVALID_PARAM; + wco->instance->default_flags[i] = 0; + duplicate_CIMVAR(wco->instance, val, &wco->instance->data[i], wco->obj_class->properties[i].property.desc->cimtype); + return WERR_OK; + } + } + return WERR_NOT_FOUND; +} + +#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \ + DEBUG(1, ("ERROR: %s - %s\n", msg, wmi_errstr(result))); \ + return result; \ + } else { \ + DEBUG(1, ("OK : %s\n", msg)); \ + } + +struct pair_guid_ptr { + struct GUID guid; + void *ptr; + struct pair_guid_ptr *next, *prev; +}; + +static void *get_ptr_by_guid(struct pair_guid_ptr *list, struct GUID *uuid) +{ + for (; list; list = list->next) { + if (GUID_equal(&list->guid, uuid)) + return list->ptr; + } + return NULL; +} + +static void add_pair_guid_ptr(TALLOC_CTX *mem_ctx, struct pair_guid_ptr **list, struct GUID *uuid, void *ptr) +{ + struct pair_guid_ptr *e; + + e = talloc(mem_ctx, struct pair_guid_ptr); + e->guid = *uuid; + e->ptr = ptr; + talloc_steal(e, ptr); + DLIST_ADD(*list, e); +} + +struct IEnumWbemClassObject_data { + struct GUID guid; + struct IWbemFetchSmartEnum *pFSE; + struct IWbemWCOSmartEnum *pSE; + struct pair_guid_ptr *cache; +}; +#define NDR_CHECK_EXPR(expr) do { if (!(expr)) {\ + DEBUG(0, ("%s(%d): WBEMDATA_ERR(0x%08X): Error parsing(%s)\n", __FILE__, __LINE__, ndr->offset, #expr)); \ + return NDR_ERR_VALIDATE; \ + } \ + } while(0) + +#define NDR_CHECK_CONST(val, exp) NDR_CHECK_EXPR((val) == (exp)) + + +static enum ndr_err_code WBEMDATA_Parse(TALLOC_CTX *mem_ctx, uint8_t *data, uint32_t size, struct IEnumWbemClassObject *d, uint32_t uCount, struct WbemClassObject **apObjects) +{ + struct ndr_pull *ndr; + uint32_t u, i, ofs_next; + uint8_t u8, datatype; + struct GUID guid; + struct IEnumWbemClassObject_data *ecod; + + if (!uCount) + return NDR_ERR_BAD_SWITCH; + + ecod = d->object_data; + + ndr = talloc_zero(mem_ctx, struct ndr_pull); + ndr->current_mem_ctx = d->ctx; + ndr->data = data; + ndr->data_size = size; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_NOALIGN); + + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x0); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, *(const uint32_t *)"WBEM"); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, *(const uint32_t *)"DATA"); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x1A); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u + 6); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x0); + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &u8)); + NDR_CHECK_CONST(u8, 0x01); /* Major Version */ + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &u8)); + NDR_CHECK_EXPR(u8 <= 1); /* Minor Version 0 - Win2000, 1 - XP/2003 */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x8); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0xC); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u + 4); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, uCount); + for (i = 0; i < uCount; ++i) { + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x9); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u + 1); + NDR_CHECK(ndr_pull_uint8(ndr, NDR_SCALARS, &datatype)); + ofs_next = ndr->offset + u; + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_CHECK_CONST(u, 0x18); /* Length of header */ + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &u)); + NDR_PULL_NEED_BYTES(ndr, u + 16); + NDR_CHECK(ndr_pull_GUID(ndr, NDR_SCALARS, &guid)); + switch (datatype) { + case DATATYPE_CLASSOBJECT: + apObjects[i] = talloc_zero(d->ctx, struct WbemClassObject); + ndr->current_mem_ctx = apObjects[i]; + NDR_CHECK(ndr_pull_WbemClassObject(ndr, NDR_SCALARS|NDR_BUFFERS, apObjects[i])); + ndr->current_mem_ctx = d->ctx; + add_pair_guid_ptr(ecod, &ecod->cache, &guid, apObjects[i]->obj_class); + break; + case DATATYPE_OBJECT: + apObjects[i] = talloc_zero(d->ctx, struct WbemClassObject); + apObjects[i]->obj_class = get_ptr_by_guid(ecod->cache, &guid); + (void)talloc_reference(apObjects[i], apObjects[i]->obj_class); + ndr->current_mem_ctx = apObjects[i]; + NDR_CHECK(ndr_pull_WbemClassObject_Object(ndr, NDR_SCALARS|NDR_BUFFERS, apObjects[i])); + ndr->current_mem_ctx = d->ctx; + break; + default: + DEBUG(0, ("WBEMDATA_Parse: Data type %d not supported\n", datatype)); + return NDR_ERR_BAD_SWITCH; + } + ndr->offset = ofs_next; + if (DEBUGLVL(9)) { + NDR_PRINT_DEBUG(WbemClassObject, apObjects[i]); + } + } + return NDR_ERR_SUCCESS; +} + +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, struct WbemClassObject **apObjects, uint32_t *puReturned) +{ + WERROR result; + NTSTATUS status; + struct IEnumWbemClassObject_data *ecod; + TALLOC_CTX *loc_ctx; + uint32_t size; + uint8_t *data; + + loc_ctx = talloc_new(0); + ecod = d->object_data; + if (!ecod) { + struct GUID iid; + WERROR coresult; + + d->object_data = ecod = talloc_zero(d, struct IEnumWbemClassObject_data); + GUID_from_string(COM_IWBEMFETCHSMARTENUM_UUID, &iid); + result = dcom_query_interface((struct IUnknown *)d, 5, 1, &iid, (struct IUnknown **)&ecod->pFSE, &coresult); + WERR_CHECK("dcom_query_interface."); + result = coresult; + WERR_CHECK("Retrieve enumerator of result(IWbemFetchSmartEnum)."); + + result = IWbemFetchSmartEnum_Fetch(ecod->pFSE, mem_ctx, &ecod->pSE); + WERR_CHECK("Retrieve enumerator of result(IWbemWCOSmartEnum)."); + + ecod->guid = GUID_random(); + d->vtable->Release_send = dcom_proxy_IEnumWbemClassObject_Release_send; + } + + result = IWbemWCOSmartEnum_Next(ecod->pSE, loc_ctx, &ecod->guid, lTimeout, uCount, puReturned, &size, &data); + if (!W_ERROR_EQUAL(result, WERR_BADFUNC)) { + WERR_CHECK("IWbemWCOSmartEnum_Next."); + } + + if (data) { + NDR_CHECK(WBEMDATA_Parse(mem_ctx, data, size, d, *puReturned, apObjects)); + } + if (!W_ERROR_IS_OK(result)) { + status = werror_to_ntstatus(result); + DEBUG(9, ("dcom_proxy_IEnumWbemClassObject_Next: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status))); + } + talloc_free(loc_ctx); + return result; +} + +struct composite_context *dcom_proxy_IEnumWbemClassObject_Release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx) +{ + struct composite_context *c, *cr; + struct REMINTERFACEREF iref[3]; + struct dcom_object_exporter *ox; + struct IEnumWbemClassObject_data *ecod; + int n; + + c = composite_create(d->ctx, d->ctx->event_ctx); + if (c == NULL) return NULL; + c->private_data = d; + + ox = object_exporter_by_ip(d->ctx, d); + iref[0].ipid = IUnknown_ipid(d); + iref[0].cPublicRefs = 5; + iref[0].cPrivateRefs = 0; + n = 1; + + ecod = d->object_data; + if (ecod) { + if (ecod->pFSE) { + talloc_steal(d, ecod->pFSE); + iref[n].ipid = IUnknown_ipid(ecod->pFSE); + iref[n].cPublicRefs = 5; + iref[n].cPrivateRefs = 0; + ++n; + } + if (ecod->pSE) { + talloc_steal(d, ecod->pSE); + iref[n].ipid = IUnknown_ipid(ecod->pSE); + iref[n].cPublicRefs = 5; + iref[n].cPrivateRefs = 0; + ++n; + } + } + cr = IRemUnknown_RemRelease_send(ox->rem_unknown, mem_ctx, n, iref); + + composite_continue(c, cr, dcom_release_continue, c); + return c; +} + +NTSTATUS dcom_proxy_IWbemClassObject_init(void) +{ + struct GUID clsid; + GUID_from_string("4590f812-1d3a-11d0-891f-00aa004b2e24", &clsid); + dcom_register_marshal(&clsid, marshal, unmarshal); + +#if 0 + struct IEnumWbemClassObject_vtable *proxy_vtable; + proxy_vtable = (struct IEnumWbemClassObject_vtable *)dcom_proxy_vtable_by_iid((struct GUID *)&dcerpc_table_IEnumWbemClassObject.syntax_id.uuid); + if (proxy_vtable) + proxy_vtable->Release_send = dcom_proxy_IEnumWbemClassObject_Release_send; + else + DEBUG(0, ("WARNING: IEnumWbemClassObject should be initialized before IWbemClassObject.")); +#endif + + return NT_STATUS_OK; +} diff --git a/source4/lib/wmi/wmi.h b/source4/lib/wmi/wmi.h new file mode 100644 index 0000000000..085e01215f --- /dev/null +++ b/source4/lib/wmi/wmi.h @@ -0,0 +1,58 @@ +/* + Unix SMB/CIFS implementation. + Samba utility functions + Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008 + + 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 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef _WMI_H_ +#define _WMI_H_ + +#include "librpc/gen_ndr/com_wmi.h" + +/* The following definitions come from lib/wmi/wmicore.c */ + + +/** FIXME: Use credentials struct rather than user/password here */ +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, + const char *user, const char *password, + const char *locale, uint32_t flags, const char *authority, + struct IWbemContext* wbem_ctx, struct IWbemServices** services); +const char *wmi_errstr(WERROR werror); + +/* The following definitions come from lib/wmi/wbemdata.c */ + +WERROR dcom_IWbemClassObject_from_WbemClassObject(struct com_context *ctx, struct IWbemClassObject **_p, struct WbemClassObject *wco); +WERROR IWbemClassObject_GetMethod(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, struct IWbemClassObject **in, struct IWbemClassObject **out); +void WbemClassObject_CreateInstance(struct WbemClassObject *wco); +WERROR IWbemClassObject_Clone(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, struct IWbemClassObject **copy); +WERROR IWbemClassObject_SpawnInstance(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, uint32_t flags, struct IWbemClassObject **instance); +void duplicate_WbemQualifier(TALLOC_CTX *mem_ctx, const struct WbemQualifier *src, struct WbemQualifier *dst); +void duplicate_CIMSTRINGS(TALLOC_CTX *mem_ctx, const struct CIMSTRINGS *src, struct CIMSTRINGS *dst); +void duplicate_WbemQualifiers(TALLOC_CTX *mem_ctx, const struct WbemQualifiers *src, struct WbemQualifiers *dst); +void duplicate_WbemClass(TALLOC_CTX *mem_ctx, const struct WbemClass *src, struct WbemClass *dst); +void duplicate_WbemMethod(TALLOC_CTX *mem_ctx, const struct WbemMethod *src, struct WbemMethod *dst); +void duplicate_WbemMethods(TALLOC_CTX *mem_ctx, const struct WbemMethods *src, struct WbemMethods *dst); +void duplicate_WbemInstance(TALLOC_CTX *mem_ctx, const struct WbemInstance *src, struct WbemInstance *dst, const struct WbemClass *cls); +void duplicate_WbemClassObject(TALLOC_CTX *mem_ctx, const struct WbemClassObject *src, struct WbemClassObject *dst); +void duplicate_CIMVAR(TALLOC_CTX *mem_ctx, const union CIMVAR *src, union CIMVAR *dst, enum CIMTYPE_ENUMERATION cimtype); +WERROR WbemClassObject_Get(struct WbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION *cimtype, uint32_t *flavor); +WERROR IWbemClassObject_Put(struct IWbemClassObject *d, TALLOC_CTX *mem_ctx, const char *name, uint32_t flags, union CIMVAR *val, enum CIMTYPE_ENUMERATION cimtype); +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, struct WbemClassObject **apObjects, uint32_t *puReturned); +struct composite_context *dcom_proxy_IEnumWbemClassObject_Release_send(struct IUnknown *d, TALLOC_CTX *mem_ctx); + +void wmi_init(struct com_context **ctx, struct cli_credentials *credentials); + +#endif diff --git a/source4/lib/wmi/wmi.i b/source4/lib/wmi/wmi.i new file mode 100644 index 0000000000..2c8bbe517e --- /dev/null +++ b/source4/lib/wmi/wmi.i @@ -0,0 +1,352 @@ +/* + WMI Implementation + Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl> + Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +%module wmi + +%include "typemaps.i" +%include "libcli/util/errors.i" +%import "stdint.i" +%import "lib/talloc/talloc.i" + +%runtime %{ +void push_object(PyObject **stack, PyObject *o) +{ + if ((!*stack) || (*stack == Py_None)) { + *stack = o; + } else { + PyObject *o2, *o3; + if (!PyTuple_Check(*stack)) { + o2 = *stack; + *stack = PyTuple_New(1); + PyTuple_SetItem(*stack,0,o2); + } + o3 = PyTuple_New(1); + PyTuple_SetItem(o3,0,o); + o2 = *stack; + *stack = PySequence_Concat(o2,o3); + Py_DECREF(o2); + Py_DECREF(o3); + } +} +%} + +%{ +#include "includes.h" +#include "librpc/gen_ndr/misc.h" +#include "librpc/rpc/dcerpc.h" +#include "lib/com/dcom/dcom.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "lib/wmi/wmi.h" + + +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, + const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services); +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout,uint32_t uCount, + struct WbemClassObject **apObjects, uint32_t *puReturned); + +static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar); +static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco); + +static struct com_context *com_ctx; +static PyObject *ComError; +static PyObject *mod_win32_client; +static PyObject *mod_pywintypes; + +typedef struct IUnknown IUnknown; +typedef struct IWbemServices IWbemServices; +typedef struct IWbemClassObject IWbemClassObject; +typedef struct IEnumWbemClassObject IEnumWbemClassObject; +%} + +%wrapper %{ + +#define RETURN_CVAR_ARRAY(fmt, arr) {\ + PyObject *l, *o;\ + uint32_t i;\ +\ + if (!arr) {\ + Py_INCREF(Py_None);\ + return Py_None;\ + }\ + l = PyList_New(arr->count);\ + if (!l) return NULL;\ + for (i = 0; i < arr->count; ++i) {\ + o = _Py_BuildValue(fmt, arr->item[i]);\ + if (!o) {\ + Py_DECREF(l);\ + return NULL;\ + }\ + PyList_SET_ITEM(l, i, o);\ + }\ + return l;\ +} + +static PyObject *_Py_BuildValue(char *str, ...) +{ + PyObject * result = NULL; + va_list lst; + va_start(lst, str); + if (str && *str == 'I') { + uint32_t value = va_arg(lst, uint32_t); + if (value & 0x80000000) { + result = Py_BuildValue("L", (long)value); + } else { + result = Py_BuildValue("i", value); + } + } else { + result = Py_VaBuildValue(str, lst); + } + va_end(lst); + return result; +} + + +static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar) +{ + switch (cimtype) { + case CIM_SINT8: return Py_BuildValue("b", cvar->v_sint8); + case CIM_UINT8: return Py_BuildValue("B", cvar->v_uint8); + case CIM_SINT16: return Py_BuildValue("h", cvar->v_sint16); + case CIM_UINT16: return Py_BuildValue("H", cvar->v_uint16); + case CIM_SINT32: return Py_BuildValue("i", cvar->v_sint32); + case CIM_UINT32: return _Py_BuildValue("I", cvar->v_uint32); + case CIM_SINT64: return Py_BuildValue("L", cvar->v_sint64); + case CIM_UINT64: return Py_BuildValue("K", cvar->v_uint64); + case CIM_REAL32: return Py_BuildValue("f", cvar->v_real32); + case CIM_REAL64: return Py_BuildValue("d", cvar->v_real64); + case CIM_BOOLEAN: return Py_BuildValue("h", cvar->v_boolean); + case CIM_STRING: return Py_BuildValue("s", cvar->v_string); + case CIM_DATETIME: return Py_BuildValue("s", cvar->v_datetime); + case CIM_REFERENCE: return Py_BuildValue("s", cvar->v_reference); + case CIM_OBJECT: return PySWbemObject_FromWbemClassObject(cvar->v_object); + case CIM_ARR_SINT8: RETURN_CVAR_ARRAY("b", cvar->a_sint8); + case CIM_ARR_UINT8: RETURN_CVAR_ARRAY("B", cvar->a_uint8); + case CIM_ARR_SINT16: RETURN_CVAR_ARRAY("h", cvar->a_sint16); + case CIM_ARR_UINT16: RETURN_CVAR_ARRAY("H", cvar->a_uint16); + case CIM_ARR_SINT32: RETURN_CVAR_ARRAY("i", cvar->a_sint32); + case CIM_ARR_UINT32: RETURN_CVAR_ARRAY("I", cvar->a_uint32); + case CIM_ARR_SINT64: RETURN_CVAR_ARRAY("L", cvar->a_sint64); + case CIM_ARR_UINT64: RETURN_CVAR_ARRAY("K", cvar->a_uint64); + case CIM_ARR_REAL32: RETURN_CVAR_ARRAY("f", cvar->a_real32); + case CIM_ARR_REAL64: RETURN_CVAR_ARRAY("d", cvar->a_real64); + case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY("h", cvar->a_boolean); + case CIM_ARR_STRING: RETURN_CVAR_ARRAY("s", cvar->a_string); + case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY("s", cvar->a_datetime); + case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY("s", cvar->a_reference); + default: + { + char *str; + str = talloc_asprintf(NULL, "Unsupported CIMTYPE(0x%04X)", cimtype); + PyErr_SetString(PyExc_RuntimeError, str); + talloc_free(str); + return NULL; + } + } +} + +#undef RETURN_CVAR_ARRAY + +PyObject *PySWbemObject_InitProperites(PyObject *o, struct WbemClassObject *wco) +{ + PyObject *properties; + PyObject *addProp; + uint32_t i; + int32_t r; + PyObject *result; + + result = NULL; + properties = PyObject_GetAttrString(o, "Properties_"); + if (!properties) return NULL; + addProp = PyObject_GetAttrString(properties, "Add"); + if (!addProp) { + Py_DECREF(properties); + return NULL; + } + + for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) { + PyObject *args, *property; + + args = Py_BuildValue("(si)", wco->obj_class->properties[i].property.name, wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK); + if (!args) goto finish; + property = PyObject_CallObject(addProp, args); + Py_DECREF(args); + if (!property) goto finish; + if (wco->flags & WCF_INSTANCE) { + PyObject *value; + + if (wco->instance->default_flags[i] & 1) { + value = Py_None; + Py_INCREF(Py_None); + } else + value = PyObject_FromCVAR(wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK, &wco->instance->data[i]); + if (!value) { + Py_DECREF(property); + goto finish; + } + r = PyObject_SetAttrString(property, "Value", value); + Py_DECREF(value); + if (r == -1) { + PyErr_SetString(PyExc_RuntimeError, "Error setting value of property"); + goto finish; + } + } + Py_DECREF(property); + } + + Py_INCREF(Py_None); + result = Py_None; +finish: + Py_DECREF(addProp); + Py_DECREF(properties); + return result; +} + +static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco) +{ + PyObject *swo_class, *swo, *args, *result; + + swo_class = PyObject_GetAttrString(mod_win32_client, "SWbemObject"); + if (!swo_class) return NULL; + args = PyTuple_New(0); + if (!args) { + Py_DECREF(swo_class); + return NULL; + } + swo = PyObject_CallObject(swo_class, args); + Py_DECREF(args); + Py_DECREF(swo_class); + if (!swo) return NULL; + + result = PySWbemObject_InitProperites(swo, wco); + if (!result) { + Py_DECREF(swo); + return NULL; + } + Py_DECREF(result); + + return swo; +} + +%} + +%typemap(in, numinputs=0) struct com_context *ctx { + $1 = com_ctx; +} + +%typemap(in, numinputs=0) struct IWbemServices **services (struct IWbemServices *temp) { + $1 = &temp; +} + +%typemap(argout) struct IWbemServices **services { + PyObject *o; + o = SWIG_NewPointerObj(*$1, SWIGTYPE_p_IWbemServices, 0); + push_object(&$result, o); +} + +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, + const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services); + +%typemap(in, numinputs=0) struct IEnumWbemClassObject **ppEnum (struct IEnumWbemClassObject *temp) { + $1 = &temp; +} + +%typemap(argout) struct IEnumWbemClassObject **ppEnum { + PyObject *o; + o = SWIG_NewPointerObj(*$1, SWIGTYPE_p_IEnumWbemClassObject, 0); + push_object(&$result, o); +} + +typedef struct IUnknown { + %extend { + uint32_t Release(TALLOC_CTX *mem_ctx); + } +} IUnknown; + +%typemap(in) struct BSTR { + $1.data = PyString_AsString($input); +} + + +typedef struct IWbemServices { + %extend { + WERROR ExecQuery(TALLOC_CTX *mem_ctx, struct BSTR strQueryLanguage, struct BSTR strQuery, int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum); + WERROR ExecNotificationQuery(TALLOC_CTX *mem_ctx, struct BSTR strQueryLanguage, struct BSTR strQuery, int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum); + WERROR CreateInstanceEnum(TALLOC_CTX *mem_ctx, struct BSTR strClass, + int32_t lFlags, struct IWbemContext *pCtx, struct IEnumWbemClassObject **ppEnum); + } +} IWbemServices; + +typedef struct IEnumWbemClassObject { + %extend { + WERROR Reset(TALLOC_CTX *mem_ctx); + } +} IEnumWbemClassObject; + +%typemap(in, numinputs=1) (uint32_t uCount, struct WbemClassObject **apObjects, uint32_t *puReturned) (uint32_t uReturned) { + if (PyLong_Check($input)) + $1 = PyLong_AsUnsignedLong($input); + else if (PyInt_Check($input)) + $1 = PyInt_AsLong($input); + else { + PyErr_SetString(PyExc_TypeError,"Expected a long or an int"); + return NULL; + } + $2 = talloc_array(NULL, struct WbemClassObject *, $1); + $3 = &uReturned; +} + +%typemap(argout) (struct WbemClassObject **apObjects, uint32_t *puReturned) { + uint32_t i; + PyObject *o; + int32_t error; + + error = 0; + + $result = PyTuple_New(*$2); + for (i = 0; i < *$2; ++i) { + if (!error) { + o = PySWbemObject_FromWbemClassObject($1[i]); + if (!o) + --error; + else + error = PyTuple_SetItem($result, i, o); + } + talloc_free($1[i]); + } + talloc_free($1); + if (error) return NULL; +} + +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout, uint32_t uCount, + struct WbemClassObject **apObjects, uint32_t *puReturned); + +%init %{ + + mod_win32_client = PyImport_ImportModule("win32com.client"); + mod_pywintypes = PyImport_ImportModule("pywintypes"); + ComError = PyObject_GetAttrString(mod_pywintypes, "com_error"); + + wmi_init(&com_ctx, NULL); + { + PyObject *pModule; + + pModule = PyImport_ImportModule( "win32com.client" ); + } +%} diff --git a/source4/lib/wmi/wmi.py b/source4/lib/wmi/wmi.py new file mode 100644 index 0000000000..4bc59cfe41 --- /dev/null +++ b/source4/lib/wmi/wmi.py @@ -0,0 +1,95 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 1.3.36 +# +# Don't modify this file, modify the SWIG interface instead. + +import _wmi +import new +new_instancemethod = new.instancemethod +try: + _swig_property = property +except NameError: + pass # Python < 2.2 doesn't have 'property'. +def _swig_setattr_nondynamic(self,class_type,name,value,static=1): + if (name == "thisown"): return self.this.own(value) + if (name == "this"): + if type(value).__name__ == 'PySwigObject': + self.__dict__[name] = value + return + method = class_type.__swig_setmethods__.get(name,None) + if method: return method(self,value) + if (not static) or hasattr(self,name): + self.__dict__[name] = value + else: + raise AttributeError("You cannot add attributes to %s" % self) + +def _swig_setattr(self,class_type,name,value): + return _swig_setattr_nondynamic(self,class_type,name,value,0) + +def _swig_getattr(self,class_type,name): + if (name == "thisown"): return self.this.own() + method = class_type.__swig_getmethods__.get(name,None) + if method: return method(self) + raise AttributeError,name + +def _swig_repr(self): + try: strthis = "proxy of " + self.this.__repr__() + except: strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + +import types +try: + _object = types.ObjectType + _newclass = 1 +except AttributeError: + class _object : pass + _newclass = 0 +del types + + +def _swig_setattr_nondynamic_method(set): + def set_attr(self,name,value): + if (name == "thisown"): return self.this.own(value) + if hasattr(self,name) or (name == "this"): + set(self,name,value) + else: + raise AttributeError("You cannot add attributes to %s" % self) + return set_attr + + +WBEM_ConnectServer = _wmi.WBEM_ConnectServer +class IUnknown(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + __repr__ = _swig_repr + def __init__(self, *args, **kwargs): + _wmi.IUnknown_swiginit(self,_wmi.new_IUnknown(*args, **kwargs)) + __swig_destroy__ = _wmi.delete_IUnknown +IUnknown.Release = new_instancemethod(_wmi.IUnknown_Release,None,IUnknown) +IUnknown_swigregister = _wmi.IUnknown_swigregister +IUnknown_swigregister(IUnknown) + +class IWbemServices(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + __repr__ = _swig_repr + def __init__(self, *args, **kwargs): + _wmi.IWbemServices_swiginit(self,_wmi.new_IWbemServices(*args, **kwargs)) + __swig_destroy__ = _wmi.delete_IWbemServices +IWbemServices.ExecQuery = new_instancemethod(_wmi.IWbemServices_ExecQuery,None,IWbemServices) +IWbemServices.ExecNotificationQuery = new_instancemethod(_wmi.IWbemServices_ExecNotificationQuery,None,IWbemServices) +IWbemServices.CreateInstanceEnum = new_instancemethod(_wmi.IWbemServices_CreateInstanceEnum,None,IWbemServices) +IWbemServices_swigregister = _wmi.IWbemServices_swigregister +IWbemServices_swigregister(IWbemServices) + +class IEnumWbemClassObject(object): + thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag') + __repr__ = _swig_repr + def __init__(self, *args, **kwargs): + _wmi.IEnumWbemClassObject_swiginit(self,_wmi.new_IEnumWbemClassObject(*args, **kwargs)) + __swig_destroy__ = _wmi.delete_IEnumWbemClassObject +IEnumWbemClassObject.Reset = new_instancemethod(_wmi.IEnumWbemClassObject_Reset,None,IEnumWbemClassObject) +IEnumWbemClassObject_swigregister = _wmi.IEnumWbemClassObject_swigregister +IEnumWbemClassObject_swigregister(IEnumWbemClassObject) + +IEnumWbemClassObject_SmartNext = _wmi.IEnumWbemClassObject_SmartNext + + diff --git a/source4/lib/wmi/wmi_wrap.c b/source4/lib/wmi/wmi_wrap.c new file mode 100644 index 0000000000..ee5a8fcb0f --- /dev/null +++ b/source4/lib/wmi/wmi_wrap.c @@ -0,0 +1,4310 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 1.3.36 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +#define SWIGPYTHON +#define SWIG_PYTHON_NO_BUILD_NONE +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* exporting methods */ +#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + + + +/* Python.h has to appear first */ +#include <Python.h> + +/* ----------------------------------------------------------------------------- + * swigrun.swg + * + * This file contains generic CAPI SWIG runtime support for pointer + * type checking. + * ----------------------------------------------------------------------------- */ + +/* This should only be incremented when either the layout of swig_type_info changes, + or for whatever reason, the runtime changes incompatibly */ +#define SWIG_RUNTIME_VERSION "4" + +/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ +#ifdef SWIG_TYPE_TABLE +# define SWIG_QUOTE_STRING(x) #x +# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) +# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) +#else +# define SWIG_TYPE_TABLE_NAME +#endif + +/* + You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. + + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. +*/ + +#ifndef SWIGRUNTIME +# define SWIGRUNTIME SWIGINTERN +#endif + +#ifndef SWIGRUNTIMEINLINE +# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE +#endif + +/* Generic buffer size */ +#ifndef SWIG_BUFFER_SIZE +# define SWIG_BUFFER_SIZE 1024 +#endif + +/* Flags for pointer conversions */ +#define SWIG_POINTER_DISOWN 0x1 +#define SWIG_CAST_NEW_MEMORY 0x2 + +/* Flags for new pointer objects */ +#define SWIG_POINTER_OWN 0x1 + + +/* + Flags/methods for returning states. + + The swig conversion methods, as ConvertPtr, return and integer + that tells if the conversion was successful or not. And if not, + an error code can be returned (see swigerrors.swg for the codes). + + Use the following macros/flags to set or process the returning + states. + + In old swig versions, you usually write code as: + + if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { + // success code + } else { + //fail code + } + + Now you can be more explicit as: + + int res = SWIG_ConvertPtr(obj,vptr,ty.flags); + if (SWIG_IsOK(res)) { + // success code + } else { + // fail code + } + + that seems to be the same, but now you can also do + + Type *ptr; + int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); + if (SWIG_IsOK(res)) { + // success code + if (SWIG_IsNewObj(res) { + ... + delete *ptr; + } else { + ... + } + } else { + // fail code + } + + I.e., now SWIG_ConvertPtr can return new objects and you can + identify the case and take care of the deallocation. Of course that + requires also to SWIG_ConvertPtr to return new result values, as + + int SWIG_ConvertPtr(obj, ptr,...) { + if (<obj is ok>) { + if (<need new object>) { + *ptr = <ptr to new allocated object>; + return SWIG_NEWOBJ; + } else { + *ptr = <ptr to old object>; + return SWIG_OLDOBJ; + } + } else { + return SWIG_BADOBJ; + } + } + + Of course, returning the plain '0(success)/-1(fail)' still works, but you can be + more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the + swig errors code. + + Finally, if the SWIG_CASTRANK_MODE is enabled, the result code + allows to return the 'cast rank', for example, if you have this + + int food(double) + int fooi(int); + + and you call + + food(1) // cast rank '1' (1 -> 1.0) + fooi(1) // cast rank '0' + + just use the SWIG_AddCast()/SWIG_CheckState() + + + */ +#define SWIG_OK (0) +#define SWIG_ERROR (-1) +#define SWIG_IsOK(r) (r >= 0) +#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) + +/* The CastRankLimit says how many bits are used for the cast rank */ +#define SWIG_CASTRANKLIMIT (1 << 8) +/* The NewMask denotes the object was created (using new/malloc) */ +#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) +/* The TmpMask is for in/out typemaps that use temporal objects */ +#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) +/* Simple returning values */ +#define SWIG_BADOBJ (SWIG_ERROR) +#define SWIG_OLDOBJ (SWIG_OK) +#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) +#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) +/* Check, add and del mask methods */ +#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) +#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) +#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) +#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) +#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) +#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + + +/* Cast-Rank Mode */ +#if defined(SWIG_CASTRANK_MODE) +# ifndef SWIG_TypeRank +# define SWIG_TypeRank unsigned long +# endif +# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ +# define SWIG_MAXCASTRANK (2) +# endif +# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) +# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) +SWIGINTERNINLINE int SWIG_AddCast(int r) { + return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; +} +SWIGINTERNINLINE int SWIG_CheckState(int r) { + return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; +} +#else /* no cast-rank mode */ +# define SWIG_AddCast +# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) +#endif + + + + +#include <string.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef void *(*swig_converter_func)(void *, int *); +typedef struct swig_type_info *(*swig_dycast_func)(void **); + +/* Structure to store information on one type */ +typedef struct swig_type_info { + const char *name; /* mangled name of this type */ + const char *str; /* human readable name of this type */ + swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ + struct swig_cast_info *cast; /* linked list of types that can cast into this type */ + void *clientdata; /* language specific type data */ + int owndata; /* flag if the structure owns the clientdata */ +} swig_type_info; + +/* Structure to store a type and conversion function used for casting */ +typedef struct swig_cast_info { + swig_type_info *type; /* pointer to type that is equivalent to this type */ + swig_converter_func converter; /* function to cast the void pointers */ + struct swig_cast_info *next; /* pointer to next cast in linked list */ + struct swig_cast_info *prev; /* pointer to the previous cast */ +} swig_cast_info; + +/* Structure used to store module information + * Each module generates one structure like this, and the runtime collects + * all of these structures and stores them in a circularly linked list.*/ +typedef struct swig_module_info { + swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ + size_t size; /* Number of types in this module */ + struct swig_module_info *next; /* Pointer to next element in circularly linked list */ + swig_type_info **type_initial; /* Array of initially generated type structures */ + swig_cast_info **cast_initial; /* Array of initially generated casting structures */ + void *clientdata; /* Language specific module data */ +} swig_module_info; + +/* + Compare two type names skipping the space characters, therefore + "char*" == "char *" and "Class<int>" == "Class<int >", etc. + + Return 0 when the two name types are equivalent, as in + strncmp, but skipping ' '. +*/ +SWIGRUNTIME int +SWIG_TypeNameComp(const char *f1, const char *l1, + const char *f2, const char *l2) { + for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { + while ((*f1 == ' ') && (f1 != l1)) ++f1; + while ((*f2 == ' ') && (f2 != l2)) ++f2; + if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; + } + return (int)((l1 - f1) - (l2 - f2)); +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if not equal, 1 if equal +*/ +SWIGRUNTIME int +SWIG_TypeEquiv(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + +/* + Check type equivalence in a name list like <name1>|<name2>|... + Return 0 if equal, -1 if nb < tb, 1 if nb > tb +*/ +SWIGRUNTIME int +SWIG_TypeCompare(const char *nb, const char *tb) { + int equiv = 0; + const char* te = tb + strlen(tb); + const char* ne = nb; + while (!equiv && *ne) { + for (nb = ne; *ne; ++ne) { + if (*ne == '|') break; + } + equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; + if (*ne) ++ne; + } + return equiv; +} + + +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + +/* + Check the typename +*/ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheck(const char *c, swig_type_info *ty) { + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); +} + +/* Same as previous function, except strcmp is replaced with a pointer comparison */ +SWIGRUNTIME swig_cast_info * +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); +} + +/* + Cast a pointer up an inheritance hierarchy +*/ +SWIGRUNTIMEINLINE void * +SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { + return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); +} + +/* + Dynamic pointer casting. Down an inheritance hierarchy +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { + swig_type_info *lastty = ty; + if (!ty || !ty->dcast) return ty; + while (ty && (ty->dcast)) { + ty = (*ty->dcast)(ptr); + if (ty) lastty = ty; + } + return lastty; +} + +/* + Return the name associated with this type +*/ +SWIGRUNTIMEINLINE const char * +SWIG_TypeName(const swig_type_info *ty) { + return ty->name; +} + +/* + Return the pretty name associated with this type, + that is an unmangled type name in a form presentable to the user. +*/ +SWIGRUNTIME const char * +SWIG_TypePrettyName(const swig_type_info *type) { + /* The "str" field contains the equivalent pretty names of the + type, separated by vertical-bar characters. We choose + to print the last name, as it is often (?) the most + specific. */ + if (!type) return NULL; + if (type->str != NULL) { + const char *last_name = type->str; + const char *s; + for (s = type->str; *s; s++) + if (*s == '|') last_name = s+1; + return last_name; + } + else + return type->name; +} + +/* + Set the clientdata field for a type +*/ +SWIGRUNTIME void +SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { + swig_cast_info *cast = ti->cast; + /* if (ti->clientdata == clientdata) return; */ + ti->clientdata = clientdata; + + while (cast) { + if (!cast->converter) { + swig_type_info *tc = cast->type; + if (!tc->clientdata) { + SWIG_TypeClientData(tc, clientdata); + } + } + cast = cast->next; + } +} +SWIGRUNTIME void +SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { + SWIG_TypeClientData(ti, clientdata); + ti->owndata = 1; +} + +/* + Search for a swig_type_info structure only by mangled name + Search is a O(log #types) + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_MangledTypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + swig_module_info *iter = start; + do { + if (iter->size) { + register size_t l = 0; + register size_t r = iter->size - 1; + do { + /* since l+r >= 0, we can (>> 1) instead (/ 2) */ + register size_t i = (l + r) >> 1; + const char *iname = iter->types[i]->name; + if (iname) { + register int compare = strcmp(name, iname); + if (compare == 0) { + return iter->types[i]; + } else if (compare < 0) { + if (i) { + r = i - 1; + } else { + break; + } + } else if (compare > 0) { + l = i + 1; + } + } else { + break; /* should never happen */ + } + } while (l <= r); + } + iter = iter->next; + } while (iter != end); + return 0; +} + +/* + Search for a swig_type_info structure for either a mangled name or a human readable name. + It first searches the mangled names of the types, which is a O(log #types) + If a type is not found it then searches the human readable names, which is O(#types). + + We start searching at module start, and finish searching when start == end. + Note: if start == end at the beginning of the function, we go all the way around + the circular list. +*/ +SWIGRUNTIME swig_type_info * +SWIG_TypeQueryModule(swig_module_info *start, + swig_module_info *end, + const char *name) { + /* STEP 1: Search the name field using binary search */ + swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); + if (ret) { + return ret; + } else { + /* STEP 2: If the type hasn't been found, do a complete search + of the str field (the human readable name) */ + swig_module_info *iter = start; + do { + register size_t i = 0; + for (; i < iter->size; ++i) { + if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) + return iter->types[i]; + } + iter = iter->next; + } while (iter != end); + } + + /* neither found a match */ + return 0; +} + +/* + Pack binary data into a string +*/ +SWIGRUNTIME char * +SWIG_PackData(char *c, void *ptr, size_t sz) { + static const char hex[17] = "0123456789abcdef"; + register const unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register unsigned char uu = *u; + *(c++) = hex[(uu & 0xf0) >> 4]; + *(c++) = hex[uu & 0xf]; + } + return c; +} + +/* + Unpack binary data from a string +*/ +SWIGRUNTIME const char * +SWIG_UnpackData(const char *c, void *ptr, size_t sz) { + register unsigned char *u = (unsigned char *) ptr; + register const unsigned char *eu = u + sz; + for (; u != eu; ++u) { + register char d = *(c++); + register unsigned char uu; + if ((d >= '0') && (d <= '9')) + uu = ((d - '0') << 4); + else if ((d >= 'a') && (d <= 'f')) + uu = ((d - ('a'-10)) << 4); + else + return (char *) 0; + d = *(c++); + if ((d >= '0') && (d <= '9')) + uu |= (d - '0'); + else if ((d >= 'a') && (d <= 'f')) + uu |= (d - ('a'-10)); + else + return (char *) 0; + *u = uu; + } + return c; +} + +/* + Pack 'void *' into a string buffer. +*/ +SWIGRUNTIME char * +SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { + char *r = buff; + if ((2*sizeof(void *) + 2) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,&ptr,sizeof(void *)); + if (strlen(name) + 1 > (bsz - (r - buff))) return 0; + strcpy(r,name); + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + *ptr = (void *) 0; + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sizeof(void *)); +} + +SWIGRUNTIME char * +SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { + char *r = buff; + size_t lname = (name ? strlen(name) : 0); + if ((2*sz + 2 + lname) > bsz) return 0; + *(r++) = '_'; + r = SWIG_PackData(r,ptr,sz); + if (lname) { + strncpy(r,name,lname+1); + } else { + *r = 0; + } + return buff; +} + +SWIGRUNTIME const char * +SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { + if (*c != '_') { + if (strcmp(c,"NULL") == 0) { + memset(ptr,0,sz); + return name; + } else { + return 0; + } + } + return SWIG_UnpackData(++c,ptr,sz); +} + +#ifdef __cplusplus +} +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +/* Add PyOS_snprintf for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +# else +# define PyOS_snprintf snprintf +# endif +#endif + +/* A crude PyString_FromFormat implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 + +#ifndef SWIG_PYBUFFER_SIZE +# define SWIG_PYBUFFER_SIZE 1024 +#endif + +static PyObject * +PyString_FromFormat(const char *fmt, ...) { + va_list ap; + char buf[SWIG_PYBUFFER_SIZE * 2]; + int res; + va_start(ap, fmt); + res = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); +} +#endif + +/* Add PyObject_Del for old Pythons */ +#if PY_VERSION_HEX < 0x01060000 +# define PyObject_Del(op) PyMem_DEL((op)) +#endif +#ifndef PyObject_DEL +# define PyObject_DEL PyObject_Del +#endif + +/* A crude PyExc_StopIteration exception for old Pythons */ +#if PY_VERSION_HEX < 0x02020000 +# ifndef PyExc_StopIteration +# define PyExc_StopIteration PyExc_RuntimeError +# endif +# ifndef PyObject_GenericGetAttr +# define PyObject_GenericGetAttr 0 +# endif +#endif +/* Py_NotImplemented is defined in 2.1 and up. */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef Py_NotImplemented +# define Py_NotImplemented PyExc_RuntimeError +# endif +#endif + + +/* A crude PyString_AsStringAndSize implementation for old Pythons */ +#if PY_VERSION_HEX < 0x02010000 +# ifndef PyString_AsStringAndSize +# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} +# endif +#endif + +/* PySequence_Size for old Pythons */ +#if PY_VERSION_HEX < 0x02000000 +# ifndef PySequence_Size +# define PySequence_Size PySequence_Length +# endif +#endif + + +/* PyBool_FromLong for old Pythons */ +#if PY_VERSION_HEX < 0x02030000 +static +PyObject *PyBool_FromLong(long ok) +{ + PyObject *result = ok ? Py_True : Py_False; + Py_INCREF(result); + return result; +} +#endif + +/* Py_ssize_t for old Pythons */ +/* This code is as recommended by: */ +/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +# define PY_SSIZE_T_MAX INT_MAX +# define PY_SSIZE_T_MIN INT_MIN +#endif + +/* ----------------------------------------------------------------------------- + * error manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIME PyObject* +SWIG_Python_ErrorType(int code) { + PyObject* type = 0; + switch(code) { + case SWIG_MemoryError: + type = PyExc_MemoryError; + break; + case SWIG_IOError: + type = PyExc_IOError; + break; + case SWIG_RuntimeError: + type = PyExc_RuntimeError; + break; + case SWIG_IndexError: + type = PyExc_IndexError; + break; + case SWIG_TypeError: + type = PyExc_TypeError; + break; + case SWIG_DivisionByZero: + type = PyExc_ZeroDivisionError; + break; + case SWIG_OverflowError: + type = PyExc_OverflowError; + break; + case SWIG_SyntaxError: + type = PyExc_SyntaxError; + break; + case SWIG_ValueError: + type = PyExc_ValueError; + break; + case SWIG_SystemError: + type = PyExc_SystemError; + break; + case SWIG_AttributeError: + type = PyExc_AttributeError; + break; + default: + type = PyExc_RuntimeError; + } + return type; +} + + +SWIGRUNTIME void +SWIG_Python_AddErrorMsg(const char* mesg) +{ + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + + if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + PyErr_Clear(); + Py_XINCREF(type); + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + Py_DECREF(old_str); + Py_DECREF(value); + } else { + PyErr_SetString(PyExc_RuntimeError, mesg); + } +} + + + +#if defined(SWIG_PYTHON_NO_THREADS) +# if defined(SWIG_PYTHON_THREADS) +# undef SWIG_PYTHON_THREADS +# endif +#endif +#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ +# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) +# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ +# define SWIG_PYTHON_USE_GIL +# endif +# endif +# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ +# ifndef SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() +# endif +# ifdef __cplusplus /* C++ code */ + class SWIG_Python_Thread_Block { + bool status; + PyGILState_STATE state; + public: + void end() { if (status) { PyGILState_Release(state); status = false;} } + SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} + ~SWIG_Python_Thread_Block() { end(); } + }; + class SWIG_Python_Thread_Allow { + bool status; + PyThreadState *save; + public: + void end() { if (status) { PyEval_RestoreThread(save); status = false; }} + SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} + ~SWIG_Python_Thread_Allow() { end(); } + }; +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block +# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow +# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() +# else /* C code */ +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() +# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() +# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) +# endif +# else /* Old thread way, not implemented, user must provide it */ +# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) +# define SWIG_PYTHON_INITIALIZE_THREADS +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) +# define SWIG_PYTHON_THREAD_END_BLOCK +# endif +# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# endif +# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) +# define SWIG_PYTHON_THREAD_END_ALLOW +# endif +# endif +#else /* No thread support */ +# define SWIG_PYTHON_INITIALIZE_THREADS +# define SWIG_PYTHON_THREAD_BEGIN_BLOCK +# define SWIG_PYTHON_THREAD_END_BLOCK +# define SWIG_PYTHON_THREAD_BEGIN_ALLOW +# define SWIG_PYTHON_THREAD_END_ALLOW +#endif + +/* ----------------------------------------------------------------------------- + * Python API portion that goes into the runtime + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +/* ----------------------------------------------------------------------------- + * Constant declarations + * ----------------------------------------------------------------------------- */ + +/* Constant Types */ +#define SWIG_PY_POINTER 4 +#define SWIG_PY_BINARY 5 + +/* Constant information structure */ +typedef struct swig_const_info { + int type; + char *name; + long lvalue; + double dvalue; + void *pvalue; + swig_type_info **ptype; +} swig_const_info; + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + + +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * pyrun.swg + * + * This file contains the runtime support for Python modules + * and includes code for managing global variables and pointer + * type checking. + * + * ----------------------------------------------------------------------------- */ + +/* Common SWIG API */ + +/* for raw pointers */ +#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) +#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) +#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) +#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) +#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) +#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) +#define swig_owntype int + +/* for raw packed data */ +#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + +/* for class or struct pointers */ +#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) +#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) + +/* for C or C++ function pointers */ +#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) +#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) + +/* for C++ member pointers, ie, member methods */ +#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) +#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) + + +/* Runtime API */ + +#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) +#define SWIG_NewClientData(obj) PySwigClientData_New(obj) + +#define SWIG_SetErrorObj SWIG_Python_SetErrorObj +#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg +#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) +#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) +#define SWIG_fail goto fail + + +/* Runtime API implementation */ + +/* Error manipulation */ + +SWIGINTERN void +SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetObject(errtype, obj); + Py_DECREF(obj); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +SWIGINTERN void +SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(errtype, (char *) msg); + SWIG_PYTHON_THREAD_END_BLOCK; +} + +#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) + +/* Set a constant value */ + +SWIGINTERN void +SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { + PyDict_SetItemString(d, (char*) name, obj); + Py_DECREF(obj); +} + +/* Append a value to the result obj */ + +SWIGINTERN PyObject* +SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { +#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyList_Check(result)) { + PyObject *o2 = result; + result = PyList_New(1); + PyList_SetItem(result, 0, o2); + } + PyList_Append(result,obj); + Py_DECREF(obj); + } + return result; +#else + PyObject* o2; + PyObject* o3; + if (!result) { + result = obj; + } else if (result == Py_None) { + Py_DECREF(result); + result = obj; + } else { + if (!PyTuple_Check(result)) { + o2 = result; + result = PyTuple_New(1); + PyTuple_SET_ITEM(result, 0, o2); + } + o3 = PyTuple_New(1); + PyTuple_SET_ITEM(o3, 0, obj); + o2 = result; + result = PySequence_Concat(o2, o3); + Py_DECREF(o2); + Py_DECREF(o3); + } + return result; +#endif +} + +/* Unpack the argument tuple */ + +SWIGINTERN int +SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) +{ + if (!args) { + if (!min && !max) { + return 1; + } else { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", + name, (min == max ? "" : "at least "), (int)min); + return 0; + } + } + if (!PyTuple_Check(args)) { + PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); + return 0; + } else { + register Py_ssize_t l = PyTuple_GET_SIZE(args); + if (l < min) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at least "), (int)min, (int)l); + return 0; + } else if (l > max) { + PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", + name, (min == max ? "" : "at most "), (int)max, (int)l); + return 0; + } else { + register int i; + for (i = 0; i < l; ++i) { + objs[i] = PyTuple_GET_ITEM(args, i); + } + for (; l < max; ++l) { + objs[l] = 0; + } + return i + 1; + } + } +} + +/* A functor is a function object with one single object argument */ +#if PY_VERSION_HEX >= 0x02020000 +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); +#else +#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); +#endif + +/* + Helper for static pointer initialization for both C and C++ code, for example + static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); +*/ +#ifdef __cplusplus +#define SWIG_STATIC_POINTER(var) var +#else +#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var +#endif + +/* ----------------------------------------------------------------------------- + * Pointer declarations + * ----------------------------------------------------------------------------- */ + +/* Flags for new pointer objects */ +#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) +#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) + +#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* cc-mode */ +#endif +#endif + +/* How to access Py_None */ +#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# ifndef SWIG_PYTHON_NO_BUILD_NONE +# ifndef SWIG_PYTHON_BUILD_NONE +# define SWIG_PYTHON_BUILD_NONE +# endif +# endif +#endif + +#ifdef SWIG_PYTHON_BUILD_NONE +# ifdef Py_None +# undef Py_None +# define Py_None SWIG_Py_None() +# endif +SWIGRUNTIMEINLINE PyObject * +_SWIG_Py_None(void) +{ + PyObject *none = Py_BuildValue((char*)""); + Py_DECREF(none); + return none; +} +SWIGRUNTIME PyObject * +SWIG_Py_None(void) +{ + static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); + return none; +} +#endif + +/* The python void return value */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Py_Void(void) +{ + PyObject *none = Py_None; + Py_INCREF(none); + return none; +} + +/* PySwigClientData */ + +typedef struct { + PyObject *klass; + PyObject *newraw; + PyObject *newargs; + PyObject *destroy; + int delargs; + int implicitconv; +} PySwigClientData; + +SWIGRUNTIMEINLINE int +SWIG_Python_CheckImplicit(swig_type_info *ty) +{ + PySwigClientData *data = (PySwigClientData *)ty->clientdata; + return data ? data->implicitconv : 0; +} + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_ExceptionType(swig_type_info *desc) { + PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; + PyObject *klass = data ? data->klass : 0; + return (klass ? klass : PyExc_RuntimeError); +} + + +SWIGRUNTIME PySwigClientData * +PySwigClientData_New(PyObject* obj) +{ + if (!obj) { + return 0; + } else { + PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); + /* the klass element */ + data->klass = obj; + Py_INCREF(data->klass); + /* the newraw method and newargs arguments used to create a new raw instance */ + if (PyClass_Check(obj)) { + data->newraw = 0; + data->newargs = obj; + Py_INCREF(obj); + } else { +#if (PY_VERSION_HEX < 0x02020000) + data->newraw = 0; +#else + data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); +#endif + if (data->newraw) { + Py_INCREF(data->newraw); + data->newargs = PyTuple_New(1); + PyTuple_SetItem(data->newargs, 0, obj); + } else { + data->newargs = obj; + } + Py_INCREF(data->newargs); + } + /* the destroy method, aka as the C++ delete method */ + data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); + if (PyErr_Occurred()) { + PyErr_Clear(); + data->destroy = 0; + } + if (data->destroy) { + int flags; + Py_INCREF(data->destroy); + flags = PyCFunction_GET_FLAGS(data->destroy); +#ifdef METH_O + data->delargs = !(flags & (METH_O)); +#else + data->delargs = 0; +#endif + } else { + data->delargs = 0; + } + data->implicitconv = 0; + return data; + } +} + +SWIGRUNTIME void +PySwigClientData_Del(PySwigClientData* data) +{ + Py_XDECREF(data->newraw); + Py_XDECREF(data->newargs); + Py_XDECREF(data->destroy); +} + +/* =============== PySwigObject =====================*/ + +typedef struct { + PyObject_HEAD + void *ptr; + swig_type_info *ty; + int own; + PyObject *next; +} PySwigObject; + +SWIGRUNTIME PyObject * +PySwigObject_long(PySwigObject *v) +{ + return PyLong_FromVoidPtr(v->ptr); +} + +SWIGRUNTIME PyObject * +PySwigObject_format(const char* fmt, PySwigObject *v) +{ + PyObject *res = NULL; + PyObject *args = PyTuple_New(1); + if (args) { + if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { + PyObject *ofmt = PyString_FromString(fmt); + if (ofmt) { + res = PyString_Format(ofmt,args); + Py_DECREF(ofmt); + } + Py_DECREF(args); + } + } + return res; +} + +SWIGRUNTIME PyObject * +PySwigObject_oct(PySwigObject *v) +{ + return PySwigObject_format("%o",v); +} + +SWIGRUNTIME PyObject * +PySwigObject_hex(PySwigObject *v) +{ + return PySwigObject_format("%x",v); +} + +SWIGRUNTIME PyObject * +#ifdef METH_NOARGS +PySwigObject_repr(PySwigObject *v) +#else +PySwigObject_repr(PySwigObject *v, PyObject *args) +#endif +{ + const char *name = SWIG_TypePrettyName(v->ty); + PyObject *hex = PySwigObject_hex(v); + PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex)); + Py_DECREF(hex); + if (v->next) { +#ifdef METH_NOARGS + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); +#else + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); +#endif + PyString_ConcatAndDel(&repr,nrep); + } + return repr; +} + +SWIGRUNTIME int +PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ +#ifdef METH_NOARGS + PyObject *repr = PySwigObject_repr(v); +#else + PyObject *repr = PySwigObject_repr(v, NULL); +#endif + if (repr) { + fputs(PyString_AsString(repr), fp); + Py_DECREF(repr); + return 0; + } else { + return 1; + } +} + +SWIGRUNTIME PyObject * +PySwigObject_str(PySwigObject *v) +{ + char result[SWIG_BUFFER_SIZE]; + return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? + PyString_FromString(result) : 0; +} + +SWIGRUNTIME int +PySwigObject_compare(PySwigObject *v, PySwigObject *w) +{ + void *i = v->ptr; + void *j = w->ptr; + return (i < j) ? -1 : ((i > j) ? 1 : 0); +} + +SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); + +SWIGRUNTIME PyTypeObject* +PySwigObject_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); + return type; +} + +SWIGRUNTIMEINLINE int +PySwigObject_Check(PyObject *op) { + return ((op)->ob_type == PySwigObject_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); +} + +SWIGRUNTIME PyObject * +PySwigObject_New(void *ptr, swig_type_info *ty, int own); + +SWIGRUNTIME void +PySwigObject_dealloc(PyObject *v) +{ + PySwigObject *sobj = (PySwigObject *) v; + PyObject *next = sobj->next; + if (sobj->own == SWIG_POINTER_OWN) { + swig_type_info *ty = sobj->ty; + PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; + PyObject *destroy = data ? data->destroy : 0; + if (destroy) { + /* destroy is always a VARARGS method */ + PyObject *res; + if (data->delargs) { + /* we need to create a temporal object to carry the destroy operation */ + PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); + res = SWIG_Python_CallFunctor(destroy, tmp); + Py_DECREF(tmp); + } else { + PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); + PyObject *mself = PyCFunction_GET_SELF(destroy); + res = ((*meth)(mself, v)); + } + Py_XDECREF(res); + } +#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) + else { + const char *name = SWIG_TypePrettyName(ty); + printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); + } +#endif + } + Py_XDECREF(next); + PyObject_DEL(v); +} + +SWIGRUNTIME PyObject* +PySwigObject_append(PyObject* v, PyObject* next) +{ + PySwigObject *sobj = (PySwigObject *) v; +#ifndef METH_O + PyObject *tmp = 0; + if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; + next = tmp; +#endif + if (!PySwigObject_Check(next)) { + return NULL; + } + sobj->next = next; + Py_INCREF(next); + return SWIG_Py_Void(); +} + +SWIGRUNTIME PyObject* +#ifdef METH_NOARGS +PySwigObject_next(PyObject* v) +#else +PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *) v; + if (sobj->next) { + Py_INCREF(sobj->next); + return sobj->next; + } else { + return SWIG_Py_Void(); + } +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +PySwigObject_disown(PyObject *v) +#else +PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *)v; + sobj->own = 0; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +#ifdef METH_NOARGS +PySwigObject_acquire(PyObject *v) +#else +PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +#endif +{ + PySwigObject *sobj = (PySwigObject *)v; + sobj->own = SWIG_POINTER_OWN; + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject* +PySwigObject_own(PyObject *v, PyObject *args) +{ + PyObject *val = 0; +#if (PY_VERSION_HEX < 0x02020000) + if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) +#else + if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) +#endif + { + return NULL; + } + else + { + PySwigObject *sobj = (PySwigObject *)v; + PyObject *obj = PyBool_FromLong(sobj->own); + if (val) { +#ifdef METH_NOARGS + if (PyObject_IsTrue(val)) { + PySwigObject_acquire(v); + } else { + PySwigObject_disown(v); + } +#else + if (PyObject_IsTrue(val)) { + PySwigObject_acquire(v,args); + } else { + PySwigObject_disown(v,args); + } +#endif + } + return obj; + } +} + +#ifdef METH_O +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#else +static PyMethodDef +swigobject_methods[] = { + {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {0, 0, 0, 0} +}; +#endif + +#if PY_VERSION_HEX < 0x02020000 +SWIGINTERN PyObject * +PySwigObject_getattr(PySwigObject *sobj,char *name) +{ + return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); +} +#endif + +SWIGRUNTIME PyTypeObject* +_PySwigObject_type(void) { + static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; + + static PyNumberMethods PySwigObject_as_number = { + (binaryfunc)0, /*nb_add*/ + (binaryfunc)0, /*nb_subtract*/ + (binaryfunc)0, /*nb_multiply*/ + (binaryfunc)0, /*nb_divide*/ + (binaryfunc)0, /*nb_remainder*/ + (binaryfunc)0, /*nb_divmod*/ + (ternaryfunc)0,/*nb_power*/ + (unaryfunc)0, /*nb_negative*/ + (unaryfunc)0, /*nb_positive*/ + (unaryfunc)0, /*nb_absolute*/ + (inquiry)0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + (coercion)0, /*nb_coerce*/ + (unaryfunc)PySwigObject_long, /*nb_int*/ + (unaryfunc)PySwigObject_long, /*nb_long*/ + (unaryfunc)0, /*nb_float*/ + (unaryfunc)PySwigObject_oct, /*nb_oct*/ + (unaryfunc)PySwigObject_hex, /*nb_hex*/ +#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ +#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ +#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ + 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ +#endif + }; + + static PyTypeObject pyswigobject_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + (char *)"PySwigObject", /* tp_name */ + sizeof(PySwigObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PySwigObject_dealloc, /* tp_dealloc */ + (printfunc)PySwigObject_print, /* tp_print */ +#if PY_VERSION_HEX < 0x02020000 + (getattrfunc)PySwigObject_getattr, /* tp_getattr */ +#else + (getattrfunc)0, /* tp_getattr */ +#endif + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)PySwigObject_compare, /* tp_compare */ + (reprfunc)PySwigObject_repr, /* tp_repr */ + &PySwigObject_as_number, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)PySwigObject_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigobject_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + swigobject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + pyswigobject_type = tmp; + pyswigobject_type.ob_type = &PyType_Type; + type_init = 1; + } + return &pyswigobject_type; +} + +SWIGRUNTIME PyObject * +PySwigObject_New(void *ptr, swig_type_info *ty, int own) +{ + PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); + if (sobj) { + sobj->ptr = ptr; + sobj->ty = ty; + sobj->own = own; + sobj->next = 0; + } + return (PyObject *)sobj; +} + +/* ----------------------------------------------------------------------------- + * Implements a simple Swig Packed type, and use it instead of string + * ----------------------------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + void *pack; + swig_type_info *ty; + size_t size; +} PySwigPacked; + +SWIGRUNTIME int +PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +{ + char result[SWIG_BUFFER_SIZE]; + fputs("<Swig Packed ", fp); + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + fputs("at ", fp); + fputs(result, fp); + } + fputs(v->ty->name,fp); + fputs(">", fp); + return 0; +} + +SWIGRUNTIME PyObject * +PySwigPacked_repr(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { + return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name); + } else { + return PyString_FromFormat("<Swig Packed %s>", v->ty->name); + } +} + +SWIGRUNTIME PyObject * +PySwigPacked_str(PySwigPacked *v) +{ + char result[SWIG_BUFFER_SIZE]; + if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ + return PyString_FromFormat("%s%s", result, v->ty->name); + } else { + return PyString_FromString(v->ty->name); + } +} + +SWIGRUNTIME int +PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) +{ + size_t i = v->size; + size_t j = w->size; + int s = (i < j) ? -1 : ((i > j) ? 1 : 0); + return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); +} + +SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); + +SWIGRUNTIME PyTypeObject* +PySwigPacked_type(void) { + static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); + return type; +} + +SWIGRUNTIMEINLINE int +PySwigPacked_Check(PyObject *op) { + return ((op)->ob_type == _PySwigPacked_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); +} + +SWIGRUNTIME void +PySwigPacked_dealloc(PyObject *v) +{ + if (PySwigPacked_Check(v)) { + PySwigPacked *sobj = (PySwigPacked *) v; + free(sobj->pack); + } + PyObject_DEL(v); +} + +SWIGRUNTIME PyTypeObject* +_PySwigPacked_type(void) { + static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; + static PyTypeObject pyswigpacked_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + (char *)"PySwigPacked", /* tp_name */ + sizeof(PySwigPacked), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PySwigPacked_dealloc, /* tp_dealloc */ + (printfunc)PySwigPacked_print, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)PySwigPacked_compare, /* tp_compare */ + (reprfunc)PySwigPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)PySwigPacked_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + swigpacked_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ + 0, /* tp_bases */ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + pyswigpacked_type = tmp; + pyswigpacked_type.ob_type = &PyType_Type; + type_init = 1; + } + return &pyswigpacked_type; +} + +SWIGRUNTIME PyObject * +PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) +{ + PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); + if (sobj) { + void *pack = malloc(size); + if (pack) { + memcpy(pack, ptr, size); + sobj->pack = pack; + sobj->ty = ty; + sobj->size = size; + } else { + PyObject_DEL((PyObject *) sobj); + sobj = 0; + } + } + return (PyObject *) sobj; +} + +SWIGRUNTIME swig_type_info * +PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +{ + if (PySwigPacked_Check(obj)) { + PySwigPacked *sobj = (PySwigPacked *)obj; + if (sobj->size != size) return 0; + memcpy(ptr, sobj->pack, size); + return sobj->ty; + } else { + return 0; + } +} + +/* ----------------------------------------------------------------------------- + * pointers/data manipulation + * ----------------------------------------------------------------------------- */ + +SWIGRUNTIMEINLINE PyObject * +_SWIG_This(void) +{ + return PyString_FromString("this"); +} + +SWIGRUNTIME PyObject * +SWIG_This(void) +{ + static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); + return swig_this; +} + +/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ + +SWIGRUNTIME PySwigObject * +SWIG_Python_GetSwigThis(PyObject *pyobj) +{ + if (PySwigObject_Check(pyobj)) { + return (PySwigObject *) pyobj; + } else { + PyObject *obj = 0; +#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) + if (PyInstance_Check(pyobj)) { + obj = _PyInstance_Lookup(pyobj, SWIG_This()); + } else { + PyObject **dictptr = _PyObject_GetDictPtr(pyobj); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; + } else { +#ifdef PyWeakref_CheckProxy + if (PyWeakref_CheckProxy(pyobj)) { + PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); + return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; + } +#endif + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } + } + } +#else + obj = PyObject_GetAttr(pyobj,SWIG_This()); + if (obj) { + Py_DECREF(obj); + } else { + if (PyErr_Occurred()) PyErr_Clear(); + return 0; + } +#endif + if (obj && !PySwigObject_Check(obj)) { + /* a PyObject is called 'this', try to get the 'real this' + PySwigObject from it */ + return SWIG_Python_GetSwigThis(obj); + } + return (PySwigObject *)obj; + } +} + +/* Acquire a pointer value */ + +SWIGRUNTIME int +SWIG_Python_AcquirePtr(PyObject *obj, int own) { + if (own == SWIG_POINTER_OWN) { + PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + if (sobj) { + int oldown = sobj->own; + sobj->own = own; + return oldown; + } + } + return 0; +} + +/* Convert a pointer value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { + if (!obj) return SWIG_ERROR; + if (obj == Py_None) { + if (ptr) *ptr = 0; + return SWIG_OK; + } else { + PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); + if (own) + *own = 0; + while (sobj) { + void *vptr = sobj->ptr; + if (ty) { + swig_type_info *to = sobj->ty; + if (to == ty) { + /* no type cast needed */ + if (ptr) *ptr = vptr; + break; + } else { + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) { + sobj = (PySwigObject *)sobj->next; + } else { + if (ptr) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } + } + break; + } + } + } else { + if (ptr) *ptr = vptr; + break; + } + } + if (sobj) { + if (own) + *own = *own | sobj->own; + if (flags & SWIG_POINTER_DISOWN) { + sobj->own = 0; + } + return SWIG_OK; + } else { + int res = SWIG_ERROR; + if (flags & SWIG_POINTER_IMPLICIT_CONV) { + PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; + if (data && !data->implicitconv) { + PyObject *klass = data->klass; + if (klass) { + PyObject *impconv; + data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ + impconv = SWIG_Python_CallFunctor(klass, obj); + data->implicitconv = 0; + if (PyErr_Occurred()) { + PyErr_Clear(); + impconv = 0; + } + if (impconv) { + PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); + if (iobj) { + void *vptr; + res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); + if (SWIG_IsOK(res)) { + if (ptr) { + *ptr = vptr; + /* transfer the ownership to 'ptr' */ + iobj->own = 0; + res = SWIG_AddCast(res); + res = SWIG_AddNewMask(res); + } else { + res = SWIG_AddCast(res); + } + } + } + Py_DECREF(impconv); + } + } + } + } + return res; + } + } +} + +/* Convert a function ptr value */ + +SWIGRUNTIME int +SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { + if (!PyCFunction_Check(obj)) { + return SWIG_ConvertPtr(obj, ptr, ty, 0); + } else { + void *vptr = 0; + + /* here we get the method pointer for callbacks */ + const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); + const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; + if (desc) { + desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; + if (!desc) return SWIG_ERROR; + } + if (ty) { + swig_cast_info *tc = SWIG_TypeCheck(desc,ty); + if (tc) { + int newmemory = 0; + *ptr = SWIG_TypeCast(tc,vptr,&newmemory); + assert(!newmemory); /* newmemory handling not yet implemented */ + } else { + return SWIG_ERROR; + } + } else { + *ptr = vptr; + } + return SWIG_OK; + } +} + +/* Convert a packed value value */ + +SWIGRUNTIME int +SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { + swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); + if (!to) return SWIG_ERROR; + if (ty) { + if (to != ty) { + /* check type cast? */ + swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); + if (!tc) return SWIG_ERROR; + } + } + return SWIG_OK; +} + +/* ----------------------------------------------------------------------------- + * Create a new pointer object + * ----------------------------------------------------------------------------- */ + +/* + Create a new instance object, whitout calling __init__, and set the + 'this' attribute. +*/ + +SWIGRUNTIME PyObject* +SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) +{ +#if (PY_VERSION_HEX >= 0x02020000) + PyObject *inst = 0; + PyObject *newraw = data->newraw; + if (newraw) { + inst = PyObject_Call(newraw, data->newargs, NULL); + if (inst) { +#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + PyObject *dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + PyDict_SetItem(dict, SWIG_This(), swig_this); + } + } +#else + PyObject *key = SWIG_This(); + PyObject_SetAttr(inst, key, swig_this); +#endif + } + } else { + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + } + return inst; +#else +#if (PY_VERSION_HEX >= 0x02010000) + PyObject *inst; + PyObject *dict = PyDict_New(); + PyDict_SetItem(dict, SWIG_This(), swig_this); + inst = PyInstance_NewRaw(data->newargs, dict); + Py_DECREF(dict); + return (PyObject *) inst; +#else + PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); + if (inst == NULL) { + return NULL; + } + inst->in_class = (PyClassObject *)data->newargs; + Py_INCREF(inst->in_class); + inst->in_dict = PyDict_New(); + if (inst->in_dict == NULL) { + Py_DECREF(inst); + return NULL; + } +#ifdef Py_TPFLAGS_HAVE_WEAKREFS + inst->in_weakreflist = NULL; +#endif +#ifdef Py_TPFLAGS_GC + PyObject_GC_Init(inst); +#endif + PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); + return (PyObject *) inst; +#endif +#endif +} + +SWIGRUNTIME void +SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) +{ + PyObject *dict; +#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) + PyObject **dictptr = _PyObject_GetDictPtr(inst); + if (dictptr != NULL) { + dict = *dictptr; + if (dict == NULL) { + dict = PyDict_New(); + *dictptr = dict; + } + PyDict_SetItem(dict, SWIG_This(), swig_this); + return; + } +#endif + dict = PyObject_GetAttrString(inst, (char*)"__dict__"); + PyDict_SetItem(dict, SWIG_This(), swig_this); + Py_DECREF(dict); +} + + +SWIGINTERN PyObject * +SWIG_Python_InitShadowInstance(PyObject *args) { + PyObject *obj[2]; + if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { + return NULL; + } else { + PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + if (sthis) { + PySwigObject_append((PyObject*) sthis, obj[1]); + } else { + SWIG_Python_SetSwigThis(obj[0], obj[1]); + } + return SWIG_Py_Void(); + } +} + +/* Create a new pointer object */ + +SWIGRUNTIME PyObject * +SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { + if (!ptr) { + return SWIG_Py_Void(); + } else { + int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; + PyObject *robj = PySwigObject_New(ptr, type, own); + PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; + if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { + PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); + if (inst) { + Py_DECREF(robj); + robj = inst; + } + } + return robj; + } +} + +/* Create a new packed object */ + +SWIGRUNTIMEINLINE PyObject * +SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { + return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); +} + +/* -----------------------------------------------------------------------------* + * Get type list + * -----------------------------------------------------------------------------*/ + +#ifdef SWIG_LINK_RUNTIME +void *SWIG_ReturnGlobalTypeList(void *); +#endif + +SWIGRUNTIME swig_module_info * +SWIG_Python_GetModule(void) { + static void *type_pointer = (void *)0; + /* first check if module already created */ + if (!type_pointer) { +#ifdef SWIG_LINK_RUNTIME + type_pointer = SWIG_ReturnGlobalTypeList((void *)0); +#else + type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); + if (PyErr_Occurred()) { + PyErr_Clear(); + type_pointer = (void *)0; + } +#endif + } + return (swig_module_info *) type_pointer; +} + +#if PY_MAJOR_VERSION < 2 +/* PyModule_AddObject function was introduced in Python 2.0. The following function + is copied out of Python/modsupport.c in python version 2.3.4 */ +SWIGINTERN int +PyModule_AddObject(PyObject *m, char *name, PyObject *o) +{ + PyObject *dict; + if (!PyModule_Check(m)) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs module as first arg"); + return SWIG_ERROR; + } + if (!o) { + PyErr_SetString(PyExc_TypeError, + "PyModule_AddObject() needs non-NULL value"); + return SWIG_ERROR; + } + + dict = PyModule_GetDict(m); + if (dict == NULL) { + /* Internal error -- modules must have a dict! */ + PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", + PyModule_GetName(m)); + return SWIG_ERROR; + } + if (PyDict_SetItemString(dict, name, o)) + return SWIG_ERROR; + Py_DECREF(o); + return SWIG_OK; +} +#endif + +SWIGRUNTIME void +SWIG_Python_DestroyModule(void *vptr) +{ + swig_module_info *swig_module = (swig_module_info *) vptr; + swig_type_info **types = swig_module->types; + size_t i; + for (i =0; i < swig_module->size; ++i) { + swig_type_info *ty = types[i]; + if (ty->owndata) { + PySwigClientData *data = (PySwigClientData *) ty->clientdata; + if (data) PySwigClientData_Del(data); + } + } + Py_DECREF(SWIG_This()); +} + +SWIGRUNTIME void +SWIG_Python_SetModule(swig_module_info *swig_module) { + static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ + + PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, + swig_empty_runtime_method_table); + PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); + if (pointer && module) { + PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); + } else { + Py_XDECREF(pointer); + } +} + +/* The python cached type query */ +SWIGRUNTIME PyObject * +SWIG_Python_TypeCache(void) { + static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); + return cache; +} + +SWIGRUNTIME swig_type_info * +SWIG_Python_TypeQuery(const char *type) +{ + PyObject *cache = SWIG_Python_TypeCache(); + PyObject *key = PyString_FromString(type); + PyObject *obj = PyDict_GetItem(cache, key); + swig_type_info *descriptor; + if (obj) { + descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); + } else { + swig_module_info *swig_module = SWIG_Python_GetModule(); + descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); + if (descriptor) { + obj = PyCObject_FromVoidPtr(descriptor, NULL); + PyDict_SetItem(cache, key, obj); + Py_DECREF(obj); + } + } + Py_DECREF(key); + return descriptor; +} + +/* + For backward compatibility only +*/ +#define SWIG_POINTER_EXCEPTION 0 +#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) +#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) + +SWIGRUNTIME int +SWIG_Python_AddErrMesg(const char* mesg, int infront) +{ + if (PyErr_Occurred()) { + PyObject *type = 0; + PyObject *value = 0; + PyObject *traceback = 0; + PyErr_Fetch(&type, &value, &traceback); + if (value) { + PyObject *old_str = PyObject_Str(value); + Py_XINCREF(type); + PyErr_Clear(); + if (infront) { + PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); + } else { + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); + } + Py_DECREF(old_str); + } + return 1; + } else { + return 0; + } +} + +SWIGRUNTIME int +SWIG_Python_ArgFail(int argnum) +{ + if (PyErr_Occurred()) { + /* add information about failing argument */ + char mesg[256]; + PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); + return SWIG_Python_AddErrMesg(mesg, 1); + } else { + return 0; + } +} + +SWIGRUNTIMEINLINE const char * +PySwigObject_GetDesc(PyObject *self) +{ + PySwigObject *v = (PySwigObject *)self; + swig_type_info *ty = v ? v->ty : 0; + return ty ? ty->str : (char*)""; +} + +SWIGRUNTIME void +SWIG_Python_TypeError(const char *type, PyObject *obj) +{ + if (type) { +#if defined(SWIG_COBJECT_TYPES) + if (obj && PySwigObject_Check(obj)) { + const char *otype = (const char *) PySwigObject_GetDesc(obj); + if (otype) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", + type, otype); + return; + } + } else +#endif + { + const char *otype = (obj ? obj->ob_type->tp_name : 0); + if (otype) { + PyObject *str = PyObject_Str(obj); + const char *cstr = str ? PyString_AsString(str) : 0; + if (cstr) { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", + type, otype, cstr); + } else { + PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", + type, otype); + } + Py_XDECREF(str); + return; + } + } + PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); + } else { + PyErr_Format(PyExc_TypeError, "unexpected type is received"); + } +} + + +/* Convert a pointer value, signal an exception on a type mismatch */ +SWIGRUNTIME void * +SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { + void *result; + if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { + PyErr_Clear(); + if (flags & SWIG_POINTER_EXCEPTION) { + SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); + SWIG_Python_ArgFail(argnum); + } + } + return result; +} + + +#ifdef __cplusplus +#if 0 +{ /* cc-mode */ +#endif +} +#endif + + + +#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0) + +#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else + + + +void push_object(PyObject **stack, PyObject *o) +{ + if ((!*stack) || (*stack == Py_None)) { + *stack = o; + } else { + PyObject *o2, *o3; + if (!PyTuple_Check(*stack)) { + o2 = *stack; + *stack = PyTuple_New(1); + PyTuple_SetItem(*stack,0,o2); + } + o3 = PyTuple_New(1); + PyTuple_SetItem(o3,0,o); + o2 = *stack; + *stack = PySequence_Concat(o2,o3); + Py_DECREF(o2); + Py_DECREF(o3); + } +} + + +/* -------- TYPES TABLE (BEGIN) -------- */ + +#define SWIGTYPE_p_BSTR swig_types[0] +#define SWIGTYPE_p_IEnumWbemClassObject swig_types[1] +#define SWIGTYPE_p_IUnknown swig_types[2] +#define SWIGTYPE_p_IWbemContext swig_types[3] +#define SWIGTYPE_p_IWbemServices swig_types[4] +#define SWIGTYPE_p_TALLOC_CTX swig_types[5] +#define SWIGTYPE_p_char swig_types[6] +#define SWIGTYPE_p_com_context swig_types[7] +#define SWIGTYPE_p_int swig_types[8] +#define SWIGTYPE_p_long_long swig_types[9] +#define SWIGTYPE_p_p_IEnumWbemClassObject swig_types[10] +#define SWIGTYPE_p_p_IWbemServices swig_types[11] +#define SWIGTYPE_p_p_WbemClassObject swig_types[12] +#define SWIGTYPE_p_short swig_types[13] +#define SWIGTYPE_p_signed_char swig_types[14] +#define SWIGTYPE_p_unsigned_char swig_types[15] +#define SWIGTYPE_p_unsigned_int swig_types[16] +#define SWIGTYPE_p_unsigned_long_long swig_types[17] +#define SWIGTYPE_p_unsigned_short swig_types[18] +static swig_type_info *swig_types[20]; +static swig_module_info swig_module = {swig_types, 19, 0, 0, 0, 0}; +#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name) +#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name) + +/* -------- TYPES TABLE (END) -------- */ + +#if (PY_VERSION_HEX <= 0x02000000) +# if !defined(SWIG_PYTHON_CLASSIC) +# error "This python version requires swig to be run with the '-classic' option" +# endif +#endif +#if (PY_VERSION_HEX <= 0x02020000) +# error "This python version requires swig to be run with the '-nomodern' option" +#endif +#if (PY_VERSION_HEX <= 0x02020000) +# error "This python version requires swig to be run with the '-nomodernargs' option" +#endif +#ifndef METH_O +# error "This python version requires swig to be run with the '-nofastunpack' option" +#endif +#ifdef SWIG_TypeQuery +# undef SWIG_TypeQuery +#endif +#define SWIG_TypeQuery SWIG_Python_TypeQuery + +/*----------------------------------------------- + @(target):= _wmi.so + ------------------------------------------------*/ +#define SWIG_init init_wmi + +#define SWIG_name "_wmi" + +#define SWIGVERSION 0x010336 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "libcli/util/pyerrors.h" + + +#include "includes.h" +#include "librpc/gen_ndr/misc.h" +#include "librpc/rpc/dcerpc.h" +#include "lib/com/dcom/dcom.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "lib/wmi/wmi.h" + + +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const char *nspace, const char *user, const char *password, + const char *locale, uint32_t flags, const char *authority, struct IWbemContext* wbem_ctx, struct IWbemServices** services); +WERROR IEnumWbemClassObject_SmartNext(struct IEnumWbemClassObject *d, TALLOC_CTX *mem_ctx, int32_t lTimeout,uint32_t uCount, + struct WbemClassObject **apObjects, uint32_t *puReturned); + +static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar); +static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco); + +static struct com_context *com_ctx; +static PyObject *ComError; +static PyObject *mod_win32_client; +static PyObject *mod_pywintypes; + +typedef struct IUnknown IUnknown; +typedef struct IWbemServices IWbemServices; +typedef struct IWbemClassObject IWbemClassObject; +typedef struct IEnumWbemClassObject IEnumWbemClassObject; + + +SWIGINTERN swig_type_info* +SWIG_pchar_descriptor(void) +{ + static int init = 0; + static swig_type_info* info = 0; + if (!init) { + info = SWIG_TypeQuery("_p_char"); + init = 1; + } + return info; +} + + +SWIGINTERN int +SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) +{ + if (PyString_Check(obj)) { + char *cstr; Py_ssize_t len; + PyString_AsStringAndSize(obj, &cstr, &len); + if (cptr) { + if (alloc) { + /* + In python the user should not be able to modify the inner + string representation. To warranty that, if you define + SWIG_PYTHON_SAFE_CSTRINGS, a new/copy of the python string + buffer is always returned. + + The default behavior is just to return the pointer value, + so, be careful. + */ +#if defined(SWIG_PYTHON_SAFE_CSTRINGS) + if (*alloc != SWIG_OLDOBJ) +#else + if (*alloc == SWIG_NEWOBJ) +#endif + { + *cptr = (char *)memcpy((char *)malloc((len + 1)*sizeof(char)), cstr, sizeof(char)*(len + 1)); + *alloc = SWIG_NEWOBJ; + } + else { + *cptr = cstr; + *alloc = SWIG_OLDOBJ; + } + } else { + *cptr = PyString_AsString(obj); + } + } + if (psize) *psize = len + 1; + return SWIG_OK; + } else { + swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); + if (pchar_descriptor) { + void* vptr = 0; + if (SWIG_ConvertPtr(obj, &vptr, pchar_descriptor, 0) == SWIG_OK) { + if (cptr) *cptr = (char *) vptr; + if (psize) *psize = vptr ? (strlen((char *)vptr) + 1) : 0; + if (alloc) *alloc = SWIG_OLDOBJ; + return SWIG_OK; + } + } + } + return SWIG_TypeError; +} + + + + + +#include <limits.h> +#if !defined(SWIG_NO_LLONG_MAX) +# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__) +# define LLONG_MAX __LONG_LONG_MAX__ +# define LLONG_MIN (-LLONG_MAX - 1LL) +# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL) +# endif +#endif + + +SWIGINTERN int +SWIG_AsVal_double (PyObject *obj, double *val) +{ + int res = SWIG_TypeError; + if (PyFloat_Check(obj)) { + if (val) *val = PyFloat_AsDouble(obj); + return SWIG_OK; + } else if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + double v = PyLong_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + double d = PyFloat_AsDouble(obj); + if (!PyErr_Occurred()) { + if (val) *val = d; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_AddCast(SWIG_OK)); + } else { + PyErr_Clear(); + } + } + } +#endif + return res; +} + + +#include <float.h> + + +#include <math.h> + + +SWIGINTERNINLINE int +SWIG_CanCastAsInteger(double *d, double min, double max) { + double x = *d; + if ((min <= x && x <= max)) { + double fx = floor(x); + double cx = ceil(x); + double rd = ((x - fx) < 0.5) ? fx : cx; /* simple rint */ + if ((errno == EDOM) || (errno == ERANGE)) { + errno = 0; + } else { + double summ, reps, diff; + if (rd < x) { + diff = x - rd; + } else if (rd > x) { + diff = rd - x; + } else { + return 1; + } + summ = rd + x; + reps = diff/summ; + if (reps < 8*DBL_EPSILON) { + *d = rd; + return 1; + } + } + } + return 0; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) +{ + if (PyInt_Check(obj)) { + long v = PyInt_AsLong(obj); + if (v >= 0) { + if (val) *val = v; + return SWIG_OK; + } else { + return SWIG_OverflowError; + } + } else if (PyLong_Check(obj)) { + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + unsigned long v = PyLong_AsUnsignedLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, 0, ULONG_MAX)) { + if (val) *val = (unsigned long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_unsigned_SS_int (PyObject * obj, unsigned int *val) +{ + unsigned long v; + int res = SWIG_AsVal_unsigned_SS_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v > UINT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (unsigned int)(v); + } + } + return res; +} + + + #define SWIG_From_long PyInt_FromLong + + +SWIGINTERNINLINE PyObject* +SWIG_From_unsigned_SS_long (unsigned long value) +{ + return (value > LONG_MAX) ? + PyLong_FromUnsignedLong(value) : PyInt_FromLong((long)(value)); +} + + +SWIGINTERNINLINE PyObject * +SWIG_From_unsigned_SS_int (unsigned int value) +{ + return SWIG_From_unsigned_SS_long (value); +} + + +SWIGINTERN int +SWIG_AsVal_long (PyObject *obj, long* val) +{ + if (PyInt_Check(obj)) { + if (val) *val = PyInt_AsLong(obj); + return SWIG_OK; + } else if (PyLong_Check(obj)) { + long v = PyLong_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_OK; + } else { + PyErr_Clear(); + } + } +#ifdef SWIG_PYTHON_CAST_MODE + { + int dispatch = 0; + long v = PyInt_AsLong(obj); + if (!PyErr_Occurred()) { + if (val) *val = v; + return SWIG_AddCast(SWIG_OK); + } else { + PyErr_Clear(); + } + if (!dispatch) { + double d; + int res = SWIG_AddCast(SWIG_AsVal_double (obj,&d)); + if (SWIG_IsOK(res) && SWIG_CanCastAsInteger(&d, LONG_MIN, LONG_MAX)) { + if (val) *val = (long)(d); + return res; + } + } + } +#endif + return SWIG_TypeError; +} + + +SWIGINTERN int +SWIG_AsVal_int (PyObject * obj, int *val) +{ + long v; + int res = SWIG_AsVal_long (obj, &v); + if (SWIG_IsOK(res)) { + if ((v < INT_MIN || v > INT_MAX)) { + return SWIG_OverflowError; + } else { + if (val) *val = (int)(v); + } + } + return res; +} + +#ifdef __cplusplus +extern "C" { +#endif + + +#define RETURN_CVAR_ARRAY(fmt, arr) {\ + PyObject *l, *o;\ + uint32_t i;\ +\ + if (!arr) {\ + Py_INCREF(Py_None);\ + return Py_None;\ + }\ + l = PyList_New(arr->count);\ + if (!l) return NULL;\ + for (i = 0; i < arr->count; ++i) {\ + o = _Py_BuildValue(fmt, arr->item[i]);\ + if (!o) {\ + Py_DECREF(l);\ + return NULL;\ + }\ + PyList_SET_ITEM(l, i, o);\ + }\ + return l;\ +} + +static PyObject *_Py_BuildValue(char *str, ...) +{ + PyObject * result = NULL; + va_list lst; + va_start(lst, str); + if (str && *str == 'I') { + uint32_t value = va_arg(lst, uint32_t); + if (value & 0x80000000) { + result = Py_BuildValue("L", (long)value); + } else { + result = Py_BuildValue("i", value); + } + } else { + result = Py_VaBuildValue(str, lst); + } + va_end(lst); + return result; +} + + +static PyObject *PyObject_FromCVAR(uint32_t cimtype, union CIMVAR *cvar) +{ + switch (cimtype) { + case CIM_SINT8: return Py_BuildValue("b", cvar->v_sint8); + case CIM_UINT8: return Py_BuildValue("B", cvar->v_uint8); + case CIM_SINT16: return Py_BuildValue("h", cvar->v_sint16); + case CIM_UINT16: return Py_BuildValue("H", cvar->v_uint16); + case CIM_SINT32: return Py_BuildValue("i", cvar->v_sint32); + case CIM_UINT32: return _Py_BuildValue("I", cvar->v_uint32); + case CIM_SINT64: return Py_BuildValue("L", cvar->v_sint64); + case CIM_UINT64: return Py_BuildValue("K", cvar->v_uint64); + case CIM_REAL32: return Py_BuildValue("f", cvar->v_real32); + case CIM_REAL64: return Py_BuildValue("d", cvar->v_real64); + case CIM_BOOLEAN: return Py_BuildValue("h", cvar->v_boolean); + case CIM_STRING: return Py_BuildValue("s", cvar->v_string); + case CIM_DATETIME: return Py_BuildValue("s", cvar->v_datetime); + case CIM_REFERENCE: return Py_BuildValue("s", cvar->v_reference); + case CIM_OBJECT: return PySWbemObject_FromWbemClassObject(cvar->v_object); + case CIM_ARR_SINT8: RETURN_CVAR_ARRAY("b", cvar->a_sint8); + case CIM_ARR_UINT8: RETURN_CVAR_ARRAY("B", cvar->a_uint8); + case CIM_ARR_SINT16: RETURN_CVAR_ARRAY("h", cvar->a_sint16); + case CIM_ARR_UINT16: RETURN_CVAR_ARRAY("H", cvar->a_uint16); + case CIM_ARR_SINT32: RETURN_CVAR_ARRAY("i", cvar->a_sint32); + case CIM_ARR_UINT32: RETURN_CVAR_ARRAY("I", cvar->a_uint32); + case CIM_ARR_SINT64: RETURN_CVAR_ARRAY("L", cvar->a_sint64); + case CIM_ARR_UINT64: RETURN_CVAR_ARRAY("K", cvar->a_uint64); + case CIM_ARR_REAL32: RETURN_CVAR_ARRAY("f", cvar->a_real32); + case CIM_ARR_REAL64: RETURN_CVAR_ARRAY("d", cvar->a_real64); + case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY("h", cvar->a_boolean); + case CIM_ARR_STRING: RETURN_CVAR_ARRAY("s", cvar->a_string); + case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY("s", cvar->a_datetime); + case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY("s", cvar->a_reference); + default: + { + char *str; + str = talloc_asprintf(NULL, "Unsupported CIMTYPE(0x%04X)", cimtype); + PyErr_SetString(PyExc_RuntimeError, str); + talloc_free(str); + return NULL; + } + } +} + +#undef RETURN_CVAR_ARRAY + +PyObject *PySWbemObject_InitProperites(PyObject *o, struct WbemClassObject *wco) +{ + PyObject *properties; + PyObject *addProp; + uint32_t i; + int32_t r; + PyObject *result; + + result = NULL; + properties = PyObject_GetAttrString(o, "Properties_"); + if (!properties) return NULL; + addProp = PyObject_GetAttrString(properties, "Add"); + if (!addProp) { + Py_DECREF(properties); + return NULL; + } + + for (i = 0; i < wco->obj_class->__PROPERTY_COUNT; ++i) { + PyObject *args, *property; + + args = Py_BuildValue("(si)", wco->obj_class->properties[i].property.name, wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK); + if (!args) goto finish; + property = PyObject_CallObject(addProp, args); + Py_DECREF(args); + if (!property) goto finish; + if (wco->flags & WCF_INSTANCE) { + PyObject *value; + + if (wco->instance->default_flags[i] & 1) { + value = Py_None; + Py_INCREF(Py_None); + } else + value = PyObject_FromCVAR(wco->obj_class->properties[i].property.desc->cimtype & CIM_TYPEMASK, &wco->instance->data[i]); + if (!value) { + Py_DECREF(property); + goto finish; + } + r = PyObject_SetAttrString(property, "Value", value); + Py_DECREF(value); + if (r == -1) { + PyErr_SetString(PyExc_RuntimeError, "Error setting value of property"); + goto finish; + } + } + Py_DECREF(property); + } + + Py_INCREF(Py_None); + result = Py_None; +finish: + Py_DECREF(addProp); + Py_DECREF(properties); + return result; +} + +static PyObject *PySWbemObject_FromWbemClassObject(struct WbemClassObject *wco) +{ + PyObject *swo_class, *swo, *args, *result; + + swo_class = PyObject_GetAttrString(mod_win32_client, "SWbemObject"); + if (!swo_class) return NULL; + args = PyTuple_New(0); + if (!args) { + Py_DECREF(swo_class); + return NULL; + } + swo = PyObject_CallObject(swo_class, args); + Py_DECREF(args); + Py_DECREF(swo_class); + if (!swo) return NULL; + + result = PySWbemObject_InitProperites(swo, wco); + if (!result) { + Py_DECREF(swo); + return NULL; + } + Py_DECREF(result); + + return swo; +} + + +SWIGINTERN PyObject *_wrap_WBEM_ConnectServer(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + struct com_context *arg1 = (struct com_context *) 0 ; + char *arg2 = (char *) 0 ; + char *arg3 = (char *) 0 ; + char *arg4 = (char *) 0 ; + char *arg5 = (char *) 0 ; + char *arg6 = (char *) 0 ; + uint32_t arg7 ; + char *arg8 = (char *) 0 ; + struct IWbemContext *arg9 = (struct IWbemContext *) 0 ; + struct IWbemServices **arg10 = (struct IWbemServices **) 0 ; + int res2 ; + char *buf2 = 0 ; + int alloc2 = 0 ; + int res3 ; + char *buf3 = 0 ; + int alloc3 = 0 ; + int res4 ; + char *buf4 = 0 ; + int alloc4 = 0 ; + int res5 ; + char *buf5 = 0 ; + int alloc5 = 0 ; + int res6 ; + char *buf6 = 0 ; + int alloc6 = 0 ; + unsigned int val7 ; + int ecode7 = 0 ; + int res8 ; + char *buf8 = 0 ; + int alloc8 = 0 ; + void *argp9 = 0 ; + int res9 = 0 ; + struct IWbemServices *temp10 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + PyObject * obj5 = 0 ; + PyObject * obj6 = 0 ; + PyObject * obj7 = 0 ; + char * kwnames[] = { + (char *) "server",(char *) "nspace",(char *) "user",(char *) "password",(char *) "locale",(char *) "flags",(char *) "authority",(char *) "wbem_ctx", NULL + }; + WERROR result; + + { + arg1 = com_ctx; + } + { + arg10 = &temp10; + } + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOOOOO:WBEM_ConnectServer",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4,&obj5,&obj6,&obj7)) SWIG_fail; + res2 = SWIG_AsCharPtrAndSize(obj0, &buf2, NULL, &alloc2); + if (!SWIG_IsOK(res2)) { + SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "WBEM_ConnectServer" "', argument " "2"" of type '" "char const *""'"); + } + arg2 = (char *)(buf2); + res3 = SWIG_AsCharPtrAndSize(obj1, &buf3, NULL, &alloc3); + if (!SWIG_IsOK(res3)) { + SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "WBEM_ConnectServer" "', argument " "3"" of type '" "char const *""'"); + } + arg3 = (char *)(buf3); + res4 = SWIG_AsCharPtrAndSize(obj2, &buf4, NULL, &alloc4); + if (!SWIG_IsOK(res4)) { + SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "WBEM_ConnectServer" "', argument " "4"" of type '" "char const *""'"); + } + arg4 = (char *)(buf4); + res5 = SWIG_AsCharPtrAndSize(obj3, &buf5, NULL, &alloc5); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "WBEM_ConnectServer" "', argument " "5"" of type '" "char const *""'"); + } + arg5 = (char *)(buf5); + res6 = SWIG_AsCharPtrAndSize(obj4, &buf6, NULL, &alloc6); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "WBEM_ConnectServer" "', argument " "6"" of type '" "char const *""'"); + } + arg6 = (char *)(buf6); + ecode7 = SWIG_AsVal_unsigned_SS_int(obj5, &val7); + if (!SWIG_IsOK(ecode7)) { + SWIG_exception_fail(SWIG_ArgError(ecode7), "in method '" "WBEM_ConnectServer" "', argument " "7"" of type '" "uint32_t""'"); + } + arg7 = (uint32_t)(val7); + res8 = SWIG_AsCharPtrAndSize(obj6, &buf8, NULL, &alloc8); + if (!SWIG_IsOK(res8)) { + SWIG_exception_fail(SWIG_ArgError(res8), "in method '" "WBEM_ConnectServer" "', argument " "8"" of type '" "char const *""'"); + } + arg8 = (char *)(buf8); + res9 = SWIG_ConvertPtr(obj7, &argp9,SWIGTYPE_p_IWbemContext, 0 | 0 ); + if (!SWIG_IsOK(res9)) { + SWIG_exception_fail(SWIG_ArgError(res9), "in method '" "WBEM_ConnectServer" "', argument " "9"" of type '" "struct IWbemContext *""'"); + } + arg9 = (struct IWbemContext *)(argp9); + result = WBEM_ConnectServer(arg1,(char const *)arg2,(char const *)arg3,(char const *)arg4,(char const *)arg5,(char const *)arg6,arg7,(char const *)arg8,arg9,arg10); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + { + PyObject *o; + o = SWIG_NewPointerObj(*arg10, SWIGTYPE_p_IWbemServices, 0); + push_object(&resultobj, o); + } + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); + if (alloc6 == SWIG_NEWOBJ) free((char*)buf6); + if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); + return resultobj; +fail: + if (alloc2 == SWIG_NEWOBJ) free((char*)buf2); + if (alloc3 == SWIG_NEWOBJ) free((char*)buf3); + if (alloc4 == SWIG_NEWOBJ) free((char*)buf4); + if (alloc5 == SWIG_NEWOBJ) free((char*)buf5); + if (alloc6 == SWIG_NEWOBJ) free((char*)buf6); + if (alloc8 == SWIG_NEWOBJ) free((char*)buf8); + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IUnknown_Release(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + IUnknown *arg1 = (IUnknown *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + uint32_t result; + + arg2 = NULL; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IUnknown, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IUnknown_Release" "', argument " "1"" of type '" "IUnknown *""'"); + } + arg1 = (IUnknown *)(argp1); + result = (uint32_t)IUnknown_Release(arg1,arg2); + resultobj = SWIG_From_unsigned_SS_int((unsigned int)(result)); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IUnknown(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + IUnknown *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args,"new_IUnknown",0,0,0)) SWIG_fail; + result = (IUnknown *)calloc(1, sizeof(IUnknown)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IUnknown, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_IUnknown(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + IUnknown *arg1 = (IUnknown *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IUnknown, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IUnknown" "', argument " "1"" of type '" "IUnknown *""'"); + } + arg1 = (IUnknown *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *IUnknown_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_IUnknown, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *IUnknown_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_IWbemServices_ExecQuery(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + IWbemServices *arg1 = (IWbemServices *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + struct BSTR arg3 ; + struct BSTR arg4 ; + int32_t arg5 ; + struct IWbemContext *arg6 = (struct IWbemContext *) 0 ; + struct IEnumWbemClassObject **arg7 = (struct IEnumWbemClassObject **) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + struct IEnumWbemClassObject *temp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "strQueryLanguage",(char *) "strQuery",(char *) "lFlags",(char *) "pCtx", NULL + }; + WERROR result; + + arg2 = NULL; + { + arg7 = &temp7; + } + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:IWbemServices_ExecQuery",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_ExecQuery" "', argument " "1"" of type '" "IWbemServices *""'"); + } + arg1 = (IWbemServices *)(argp1); + { + (&arg3)->data = PyString_AsString(obj1); + } + { + (&arg4)->data = PyString_AsString(obj2); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "IWbemServices_ExecQuery" "', argument " "5"" of type '" "int32_t""'"); + } + arg5 = (int32_t)(val5); + res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_IWbemContext, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "IWbemServices_ExecQuery" "', argument " "6"" of type '" "struct IWbemContext *""'"); + } + arg6 = (struct IWbemContext *)(argp6); + result = IWbemServices_ExecQuery(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + { + PyObject *o; + o = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_IEnumWbemClassObject, 0); + push_object(&resultobj, o); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IWbemServices_ExecNotificationQuery(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + IWbemServices *arg1 = (IWbemServices *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + struct BSTR arg3 ; + struct BSTR arg4 ; + int32_t arg5 ; + struct IWbemContext *arg6 = (struct IWbemContext *) 0 ; + struct IEnumWbemClassObject **arg7 = (struct IEnumWbemClassObject **) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val5 ; + int ecode5 = 0 ; + void *argp6 = 0 ; + int res6 = 0 ; + struct IEnumWbemClassObject *temp7 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + PyObject * obj4 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "strQueryLanguage",(char *) "strQuery",(char *) "lFlags",(char *) "pCtx", NULL + }; + WERROR result; + + arg2 = NULL; + { + arg7 = &temp7; + } + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOOO:IWbemServices_ExecNotificationQuery",kwnames,&obj0,&obj1,&obj2,&obj3,&obj4)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "1"" of type '" "IWbemServices *""'"); + } + arg1 = (IWbemServices *)(argp1); + { + (&arg3)->data = PyString_AsString(obj1); + } + { + (&arg4)->data = PyString_AsString(obj2); + } + ecode5 = SWIG_AsVal_int(obj3, &val5); + if (!SWIG_IsOK(ecode5)) { + SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "5"" of type '" "int32_t""'"); + } + arg5 = (int32_t)(val5); + res6 = SWIG_ConvertPtr(obj4, &argp6,SWIGTYPE_p_IWbemContext, 0 | 0 ); + if (!SWIG_IsOK(res6)) { + SWIG_exception_fail(SWIG_ArgError(res6), "in method '" "IWbemServices_ExecNotificationQuery" "', argument " "6"" of type '" "struct IWbemContext *""'"); + } + arg6 = (struct IWbemContext *)(argp6); + result = IWbemServices_ExecNotificationQuery(arg1,arg2,arg3,arg4,arg5,arg6,arg7); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + { + PyObject *o; + o = SWIG_NewPointerObj(*arg7, SWIGTYPE_p_IEnumWbemClassObject, 0); + push_object(&resultobj, o); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_IWbemServices_CreateInstanceEnum(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + IWbemServices *arg1 = (IWbemServices *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + struct BSTR arg3 ; + int32_t arg4 ; + struct IWbemContext *arg5 = (struct IWbemContext *) 0 ; + struct IEnumWbemClassObject **arg6 = (struct IEnumWbemClassObject **) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val4 ; + int ecode4 = 0 ; + void *argp5 = 0 ; + int res5 = 0 ; + struct IEnumWbemClassObject *temp6 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + PyObject * obj3 = 0 ; + char * kwnames[] = { + (char *) "self",(char *) "strClass",(char *) "lFlags",(char *) "pCtx", NULL + }; + WERROR result; + + arg2 = NULL; + { + arg6 = &temp6; + } + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOOO:IWbemServices_CreateInstanceEnum",kwnames,&obj0,&obj1,&obj2,&obj3)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IWbemServices, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "1"" of type '" "IWbemServices *""'"); + } + arg1 = (IWbemServices *)(argp1); + { + (&arg3)->data = PyString_AsString(obj1); + } + ecode4 = SWIG_AsVal_int(obj2, &val4); + if (!SWIG_IsOK(ecode4)) { + SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "4"" of type '" "int32_t""'"); + } + arg4 = (int32_t)(val4); + res5 = SWIG_ConvertPtr(obj3, &argp5,SWIGTYPE_p_IWbemContext, 0 | 0 ); + if (!SWIG_IsOK(res5)) { + SWIG_exception_fail(SWIG_ArgError(res5), "in method '" "IWbemServices_CreateInstanceEnum" "', argument " "5"" of type '" "struct IWbemContext *""'"); + } + arg5 = (struct IWbemContext *)(argp5); + result = IWbemServices_CreateInstanceEnum(arg1,arg2,arg3,arg4,arg5,arg6); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + { + PyObject *o; + o = SWIG_NewPointerObj(*arg6, SWIGTYPE_p_IEnumWbemClassObject, 0); + push_object(&resultobj, o); + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IWbemServices(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + IWbemServices *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args,"new_IWbemServices",0,0,0)) SWIG_fail; + result = (IWbemServices *)calloc(1, sizeof(IWbemServices)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IWbemServices, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_IWbemServices(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + IWbemServices *arg1 = (IWbemServices *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IWbemServices, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IWbemServices" "', argument " "1"" of type '" "IWbemServices *""'"); + } + arg1 = (IWbemServices *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *IWbemServices_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_IWbemServices, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *IWbemServices_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_IEnumWbemClassObject_Reset(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + IEnumWbemClassObject *arg1 = (IEnumWbemClassObject *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + WERROR result; + + arg2 = NULL; + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IEnumWbemClassObject, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IEnumWbemClassObject_Reset" "', argument " "1"" of type '" "IEnumWbemClassObject *""'"); + } + arg1 = (IEnumWbemClassObject *)(argp1); + result = IEnumWbemClassObject_Reset(arg1,arg2); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_new_IEnumWbemClassObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + IEnumWbemClassObject *result = 0 ; + + if (!SWIG_Python_UnpackTuple(args,"new_IEnumWbemClassObject",0,0,0)) SWIG_fail; + result = (IEnumWbemClassObject *)calloc(1, sizeof(IEnumWbemClassObject)); + resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_IEnumWbemClassObject, SWIG_POINTER_NEW | 0 ); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *_wrap_delete_IEnumWbemClassObject(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + IEnumWbemClassObject *arg1 = (IEnumWbemClassObject *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject *swig_obj[1] ; + + if (!args) SWIG_fail; + swig_obj[0] = args; + res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_IEnumWbemClassObject, SWIG_POINTER_DISOWN | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IEnumWbemClassObject" "', argument " "1"" of type '" "IEnumWbemClassObject *""'"); + } + arg1 = (IEnumWbemClassObject *)(argp1); + free((char *) arg1); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + +SWIGINTERN PyObject *IEnumWbemClassObject_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *obj; + if (!SWIG_Python_UnpackTuple(args,(char*)"swigregister", 1, 1,&obj)) return NULL; + SWIG_TypeNewClientData(SWIGTYPE_p_IEnumWbemClassObject, SWIG_NewClientData(obj)); + return SWIG_Py_Void(); +} + +SWIGINTERN PyObject *IEnumWbemClassObject_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + return SWIG_Python_InitShadowInstance(args); +} + +SWIGINTERN PyObject *_wrap_IEnumWbemClassObject_SmartNext(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) { + PyObject *resultobj = 0; + struct IEnumWbemClassObject *arg1 = (struct IEnumWbemClassObject *) 0 ; + TALLOC_CTX *arg2 = (TALLOC_CTX *) 0 ; + int32_t arg3 ; + uint32_t arg4 ; + struct WbemClassObject **arg5 = (struct WbemClassObject **) 0 ; + uint32_t *arg6 = (uint32_t *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int val3 ; + int ecode3 = 0 ; + uint32_t uReturned4 ; + PyObject * obj0 = 0 ; + PyObject * obj1 = 0 ; + PyObject * obj2 = 0 ; + char * kwnames[] = { + (char *) "d",(char *) "lTimeout",(char *) "uCount", NULL + }; + WERROR result; + + arg2 = NULL; + if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OOO:IEnumWbemClassObject_SmartNext",kwnames,&obj0,&obj1,&obj2)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_IEnumWbemClassObject, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IEnumWbemClassObject_SmartNext" "', argument " "1"" of type '" "struct IEnumWbemClassObject *""'"); + } + arg1 = (struct IEnumWbemClassObject *)(argp1); + ecode3 = SWIG_AsVal_int(obj1, &val3); + if (!SWIG_IsOK(ecode3)) { + SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IEnumWbemClassObject_SmartNext" "', argument " "3"" of type '" "int32_t""'"); + } + arg3 = (int32_t)(val3); + { + if (PyLong_Check(obj2)) + arg4 = PyLong_AsUnsignedLong(obj2); + else if (PyInt_Check(obj2)) + arg4 = PyInt_AsLong(obj2); + else { + PyErr_SetString(PyExc_TypeError,"Expected a long or an int"); + return NULL; + } + arg5 = talloc_array(NULL, struct WbemClassObject *, arg4); + arg6 = &uReturned4; + } + result = IEnumWbemClassObject_SmartNext(arg1,arg2,arg3,arg4,arg5,arg6); + if (!W_ERROR_IS_OK(result)) { + PyErr_SetWERROR(result); + SWIG_fail; + } else if (resultobj == NULL) { + resultobj = Py_None; + } + { + uint32_t i; + PyObject *o; + int32_t error; + + error = 0; + + resultobj = PyTuple_New(*arg6); + for (i = 0; i < *arg6; ++i) { + if (!error) { + o = PySWbemObject_FromWbemClassObject(arg5[i]); + if (!o) + --error; + else + error = PyTuple_SetItem(resultobj, i, o); + } + talloc_free(arg5[i]); + } + talloc_free(arg5); + if (error) return NULL; + } + return resultobj; +fail: + return NULL; +} + + +static PyMethodDef SwigMethods[] = { + { (char *)"WBEM_ConnectServer", (PyCFunction) _wrap_WBEM_ConnectServer, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"IUnknown_Release", (PyCFunction)_wrap_IUnknown_Release, METH_O, NULL}, + { (char *)"new_IUnknown", (PyCFunction)_wrap_new_IUnknown, METH_NOARGS, NULL}, + { (char *)"delete_IUnknown", (PyCFunction)_wrap_delete_IUnknown, METH_O, NULL}, + { (char *)"IUnknown_swigregister", IUnknown_swigregister, METH_VARARGS, NULL}, + { (char *)"IUnknown_swiginit", IUnknown_swiginit, METH_VARARGS, NULL}, + { (char *)"IWbemServices_ExecQuery", (PyCFunction) _wrap_IWbemServices_ExecQuery, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"IWbemServices_ExecNotificationQuery", (PyCFunction) _wrap_IWbemServices_ExecNotificationQuery, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"IWbemServices_CreateInstanceEnum", (PyCFunction) _wrap_IWbemServices_CreateInstanceEnum, METH_VARARGS | METH_KEYWORDS, NULL}, + { (char *)"new_IWbemServices", (PyCFunction)_wrap_new_IWbemServices, METH_NOARGS, NULL}, + { (char *)"delete_IWbemServices", (PyCFunction)_wrap_delete_IWbemServices, METH_O, NULL}, + { (char *)"IWbemServices_swigregister", IWbemServices_swigregister, METH_VARARGS, NULL}, + { (char *)"IWbemServices_swiginit", IWbemServices_swiginit, METH_VARARGS, NULL}, + { (char *)"IEnumWbemClassObject_Reset", (PyCFunction)_wrap_IEnumWbemClassObject_Reset, METH_O, NULL}, + { (char *)"new_IEnumWbemClassObject", (PyCFunction)_wrap_new_IEnumWbemClassObject, METH_NOARGS, NULL}, + { (char *)"delete_IEnumWbemClassObject", (PyCFunction)_wrap_delete_IEnumWbemClassObject, METH_O, NULL}, + { (char *)"IEnumWbemClassObject_swigregister", IEnumWbemClassObject_swigregister, METH_VARARGS, NULL}, + { (char *)"IEnumWbemClassObject_swiginit", IEnumWbemClassObject_swiginit, METH_VARARGS, NULL}, + { (char *)"IEnumWbemClassObject_SmartNext", (PyCFunction) _wrap_IEnumWbemClassObject_SmartNext, METH_VARARGS | METH_KEYWORDS, NULL}, + { NULL, NULL, 0, NULL } +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */ + +static swig_type_info _swigt__p_BSTR = {"_p_BSTR", "struct BSTR *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_IEnumWbemClassObject = {"_p_IEnumWbemClassObject", "struct IEnumWbemClassObject *|IEnumWbemClassObject *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_IUnknown = {"_p_IUnknown", "struct IUnknown *|IUnknown *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_IWbemContext = {"_p_IWbemContext", "struct IWbemContext *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_IWbemServices = {"_p_IWbemServices", "struct IWbemServices *|IWbemServices *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_TALLOC_CTX = {"_p_TALLOC_CTX", "TALLOC_CTX *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_com_context = {"_p_com_context", "struct com_context *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_int = {"_p_int", "intptr_t *|int *|int_least32_t *|int_fast32_t *|int32_t *|int_fast16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_long_long = {"_p_long_long", "int_least64_t *|int_fast64_t *|int64_t *|long long *|intmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_IEnumWbemClassObject = {"_p_p_IEnumWbemClassObject", "struct IEnumWbemClassObject **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_IWbemServices = {"_p_p_IWbemServices", "struct IWbemServices **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_p_WbemClassObject = {"_p_p_WbemClassObject", "struct WbemClassObject **", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_short = {"_p_short", "short *|int_least16_t *|int16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_signed_char = {"_p_signed_char", "signed char *|int_least8_t *|int_fast8_t *|int8_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_char = {"_p_unsigned_char", "unsigned char *|uint_least8_t *|uint_fast8_t *|uint8_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_int = {"_p_unsigned_int", "uintptr_t *|uint_least32_t *|uint_fast32_t *|uint32_t *|unsigned int *|uint_fast16_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_long_long = {"_p_unsigned_long_long", "uint_least64_t *|uint_fast64_t *|uint64_t *|unsigned long long *|uintmax_t *", 0, 0, (void*)0, 0}; +static swig_type_info _swigt__p_unsigned_short = {"_p_unsigned_short", "unsigned short *|uint_least16_t *|uint16_t *", 0, 0, (void*)0, 0}; + +static swig_type_info *swig_type_initial[] = { + &_swigt__p_BSTR, + &_swigt__p_IEnumWbemClassObject, + &_swigt__p_IUnknown, + &_swigt__p_IWbemContext, + &_swigt__p_IWbemServices, + &_swigt__p_TALLOC_CTX, + &_swigt__p_char, + &_swigt__p_com_context, + &_swigt__p_int, + &_swigt__p_long_long, + &_swigt__p_p_IEnumWbemClassObject, + &_swigt__p_p_IWbemServices, + &_swigt__p_p_WbemClassObject, + &_swigt__p_short, + &_swigt__p_signed_char, + &_swigt__p_unsigned_char, + &_swigt__p_unsigned_int, + &_swigt__p_unsigned_long_long, + &_swigt__p_unsigned_short, +}; + +static swig_cast_info _swigc__p_BSTR[] = { {&_swigt__p_BSTR, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IEnumWbemClassObject[] = { {&_swigt__p_IEnumWbemClassObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IUnknown[] = { {&_swigt__p_IUnknown, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IWbemContext[] = { {&_swigt__p_IWbemContext, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_IWbemServices[] = { {&_swigt__p_IWbemServices, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_TALLOC_CTX[] = { {&_swigt__p_TALLOC_CTX, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_com_context[] = { {&_swigt__p_com_context, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_int[] = { {&_swigt__p_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_long_long[] = { {&_swigt__p_long_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_IEnumWbemClassObject[] = { {&_swigt__p_p_IEnumWbemClassObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_IWbemServices[] = { {&_swigt__p_p_IWbemServices, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_p_WbemClassObject[] = { {&_swigt__p_p_WbemClassObject, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_short[] = { {&_swigt__p_short, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_signed_char[] = { {&_swigt__p_signed_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_char[] = { {&_swigt__p_unsigned_char, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_int[] = { {&_swigt__p_unsigned_int, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_long_long[] = { {&_swigt__p_unsigned_long_long, 0, 0, 0},{0, 0, 0, 0}}; +static swig_cast_info _swigc__p_unsigned_short[] = { {&_swigt__p_unsigned_short, 0, 0, 0},{0, 0, 0, 0}}; + +static swig_cast_info *swig_cast_initial[] = { + _swigc__p_BSTR, + _swigc__p_IEnumWbemClassObject, + _swigc__p_IUnknown, + _swigc__p_IWbemContext, + _swigc__p_IWbemServices, + _swigc__p_TALLOC_CTX, + _swigc__p_char, + _swigc__p_com_context, + _swigc__p_int, + _swigc__p_long_long, + _swigc__p_p_IEnumWbemClassObject, + _swigc__p_p_IWbemServices, + _swigc__p_p_WbemClassObject, + _swigc__p_short, + _swigc__p_signed_char, + _swigc__p_unsigned_char, + _swigc__p_unsigned_int, + _swigc__p_unsigned_long_long, + _swigc__p_unsigned_short, +}; + + +/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */ + +static swig_const_info swig_const_table[] = { +{0, 0, 0, 0.0, 0, 0}}; + +#ifdef __cplusplus +} +#endif +/* ----------------------------------------------------------------------------- + * Type initialization: + * This problem is tough by the requirement that no dynamic + * memory is used. Also, since swig_type_info structures store pointers to + * swig_cast_info structures and swig_cast_info structures store pointers back + * to swig_type_info structures, we need some lookup code at initialization. + * The idea is that swig generates all the structures that are needed. + * The runtime then collects these partially filled structures. + * The SWIG_InitializeModule function takes these initial arrays out of + * swig_module, and does all the lookup, filling in the swig_module.types + * array with the correct data and linking the correct swig_cast_info + * structures together. + * + * The generated swig_type_info structures are assigned staticly to an initial + * array. We just loop through that array, and handle each type individually. + * First we lookup if this type has been already loaded, and if so, use the + * loaded structure instead of the generated one. Then we have to fill in the + * cast linked list. The cast data is initially stored in something like a + * two-dimensional array. Each row corresponds to a type (there are the same + * number of rows as there are in the swig_type_initial array). Each entry in + * a column is one of the swig_cast_info structures for that type. + * The cast_initial array is actually an array of arrays, because each row has + * a variable number of columns. So to actually build the cast linked list, + * we find the array of casts associated with the type, and loop through it + * adding the casts to the list. The one last trick we need to do is making + * sure the type pointer in the swig_cast_info struct is correct. + * + * First off, we lookup the cast->type name to see if it is already loaded. + * There are three cases to handle: + * 1) If the cast->type has already been loaded AND the type we are adding + * casting info to has not been loaded (it is in this module), THEN we + * replace the cast->type pointer with the type pointer that has already + * been loaded. + * 2) If BOTH types (the one we are adding casting info to, and the + * cast->type) are loaded, THEN the cast info has already been loaded by + * the previous module so we just ignore it. + * 3) Finally, if cast->type has not already been loaded, then we add that + * swig_cast_info to the linked list (because the cast->type) pointer will + * be correct. + * ----------------------------------------------------------------------------- */ + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* c-mode */ +#endif +#endif + +#if 0 +#define SWIGRUNTIME_DEBUG +#endif + + +SWIGRUNTIME void +SWIG_InitializeModule(void *clientdata) { + size_t i; + swig_module_info *module_head, *iter; + int found, init; + + clientdata = clientdata; + + /* check to see if the circular list has been setup, if not, set it up */ + if (swig_module.next==0) { + /* Initialize the swig_module */ + swig_module.type_initial = swig_type_initial; + swig_module.cast_initial = swig_cast_initial; + swig_module.next = &swig_module; + init = 1; + } else { + init = 0; + } + + /* Try and load any already created modules */ + module_head = SWIG_GetModule(clientdata); + if (!module_head) { + /* This is the first module loaded for this interpreter */ + /* so set the swig module into the interpreter */ + SWIG_SetModule(clientdata, &swig_module); + module_head = &swig_module; + } else { + /* the interpreter has loaded a SWIG module, but has it loaded this one? */ + found=0; + iter=module_head; + do { + if (iter==&swig_module) { + found=1; + break; + } + iter=iter->next; + } while (iter!= module_head); + + /* if the is found in the list, then all is done and we may leave */ + if (found) return; + /* otherwise we must add out module into the list */ + swig_module.next = module_head->next; + module_head->next = &swig_module; + } + + /* When multiple interpeters are used, a module could have already been initialized in + a different interpreter, but not yet have a pointer in this interpreter. + In this case, we do not want to continue adding types... everything should be + set up already */ + if (init == 0) return; + + /* Now work on filling in swig_module.types */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: size %d\n", swig_module.size); +#endif + for (i = 0; i < swig_module.size; ++i) { + swig_type_info *type = 0; + swig_type_info *ret; + swig_cast_info *cast; + +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); +#endif + + /* if there is another module already loaded */ + if (swig_module.next != &swig_module) { + type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name); + } + if (type) { + /* Overwrite clientdata field */ +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found type %s\n", type->name); +#endif + if (swig_module.type_initial[i]->clientdata) { + type->clientdata = swig_module.type_initial[i]->clientdata; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name); +#endif + } + } else { + type = swig_module.type_initial[i]; + } + + /* Insert casting types */ + cast = swig_module.cast_initial[i]; + while (cast->type) { + /* Don't need to add information already in the list */ + ret = 0; +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: look cast %s\n", cast->type->name); +#endif + if (swig_module.next != &swig_module) { + ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name); +#ifdef SWIGRUNTIME_DEBUG + if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name); +#endif + } + if (ret) { + if (type == swig_module.type_initial[i]) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: skip old type %s\n", ret->name); +#endif + cast->type = ret; + ret = 0; + } else { + /* Check for casting already in the list */ + swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type); +#ifdef SWIGRUNTIME_DEBUG + if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name); +#endif + if (!ocast) ret = 0; + } + } + + if (!ret) { +#ifdef SWIGRUNTIME_DEBUG + printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name); +#endif + if (type->cast) { + type->cast->prev = cast; + cast->next = type->cast; + } + type->cast = cast; + } + cast++; + } + /* Set entry in modules->types array equal to the type */ + swig_module.types[i] = type; + } + swig_module.types[i] = 0; + +#ifdef SWIGRUNTIME_DEBUG + printf("**** SWIG_InitializeModule: Cast List ******\n"); + for (i = 0; i < swig_module.size; ++i) { + int j = 0; + swig_cast_info *cast = swig_module.cast_initial[i]; + printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name); + while (cast->type) { + printf("SWIG_InitializeModule: cast type %s\n", cast->type->name); + cast++; + ++j; + } + printf("---- Total casts: %d\n",j); + } + printf("**** SWIG_InitializeModule: Cast List ******\n"); +#endif +} + +/* This function will propagate the clientdata field of type to +* any new swig_type_info structures that have been added into the list +* of equivalent types. It is like calling +* SWIG_TypeClientData(type, clientdata) a second time. +*/ +SWIGRUNTIME void +SWIG_PropagateClientData(void) { + size_t i; + swig_cast_info *equiv; + static int init_run = 0; + + if (init_run) return; + init_run = 1; + + for (i = 0; i < swig_module.size; i++) { + if (swig_module.types[i]->clientdata) { + equiv = swig_module.types[i]->cast; + while (equiv) { + if (!equiv->converter) { + if (equiv->type && !equiv->type->clientdata) + SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata); + } + equiv = equiv->next; + } + } + } +} + +#ifdef __cplusplus +#if 0 +{ + /* c-mode */ +#endif +} +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + + /* Python-specific SWIG API */ +#define SWIG_newvarlink() SWIG_Python_newvarlink() +#define SWIG_addvarlink(p, name, get_attr, set_attr) SWIG_Python_addvarlink(p, name, get_attr, set_attr) +#define SWIG_InstallConstants(d, constants) SWIG_Python_InstallConstants(d, constants) + + /* ----------------------------------------------------------------------------- + * global variable support code. + * ----------------------------------------------------------------------------- */ + + typedef struct swig_globalvar { + char *name; /* Name of global variable */ + PyObject *(*get_attr)(void); /* Return the current value */ + int (*set_attr)(PyObject *); /* Set the value */ + struct swig_globalvar *next; + } swig_globalvar; + + typedef struct swig_varlinkobject { + PyObject_HEAD + swig_globalvar *vars; + } swig_varlinkobject; + + SWIGINTERN PyObject * + swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { + return PyString_FromString("<Swig global variables>"); + } + + SWIGINTERN PyObject * + swig_varlink_str(swig_varlinkobject *v) { + PyObject *str = PyString_FromString("("); + swig_globalvar *var; + for (var = v->vars; var; var=var->next) { + PyString_ConcatAndDel(&str,PyString_FromString(var->name)); + if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); + } + PyString_ConcatAndDel(&str,PyString_FromString(")")); + return str; + } + + SWIGINTERN int + swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { + PyObject *str = swig_varlink_str(v); + fprintf(fp,"Swig global variables "); + fprintf(fp,"%s\n", PyString_AsString(str)); + Py_DECREF(str); + return 0; + } + + SWIGINTERN void + swig_varlink_dealloc(swig_varlinkobject *v) { + swig_globalvar *var = v->vars; + while (var) { + swig_globalvar *n = var->next; + free(var->name); + free(var); + var = n; + } + } + + SWIGINTERN PyObject * + swig_varlink_getattr(swig_varlinkobject *v, char *n) { + PyObject *res = NULL; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->get_attr)(); + break; + } + var = var->next; + } + if (res == NULL && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; + } + + SWIGINTERN int + swig_varlink_setattr(swig_varlinkobject *v, char *n, PyObject *p) { + int res = 1; + swig_globalvar *var = v->vars; + while (var) { + if (strcmp(var->name,n) == 0) { + res = (*var->set_attr)(p); + break; + } + var = var->next; + } + if (res == 1 && !PyErr_Occurred()) { + PyErr_SetString(PyExc_NameError,"Unknown C global variable"); + } + return res; + } + + SWIGINTERN PyTypeObject* + swig_varlink_type(void) { + static char varlink__doc__[] = "Swig var link object"; + static PyTypeObject varlink_type; + static int type_init = 0; + if (!type_init) { + const PyTypeObject tmp + = { + PyObject_HEAD_INIT(NULL) + 0, /* Number of items in variable part (ob_size) */ + (char *)"swigvarlink", /* Type name (tp_name) */ + sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ + 0, /* Itemsize (tp_itemsize) */ + (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */ + (printfunc) swig_varlink_print, /* Print (tp_print) */ + (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */ + (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */ + 0, /* tp_compare */ + (reprfunc) swig_varlink_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)swig_varlink_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + 0, /* tp_flags */ + varlink__doc__, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ +#if PY_VERSION_HEX >= 0x02020000 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ +#endif +#if PY_VERSION_HEX >= 0x02030000 + 0, /* tp_del */ +#endif +#ifdef COUNT_ALLOCS + 0,0,0,0 /* tp_alloc -> tp_next */ +#endif + }; + varlink_type = tmp; + varlink_type.ob_type = &PyType_Type; + type_init = 1; + } + return &varlink_type; + } + + /* Create a variable linking object for use later */ + SWIGINTERN PyObject * + SWIG_Python_newvarlink(void) { + swig_varlinkobject *result = PyObject_NEW(swig_varlinkobject, swig_varlink_type()); + if (result) { + result->vars = 0; + } + return ((PyObject*) result); + } + + SWIGINTERN void + SWIG_Python_addvarlink(PyObject *p, char *name, PyObject *(*get_attr)(void), int (*set_attr)(PyObject *p)) { + swig_varlinkobject *v = (swig_varlinkobject *) p; + swig_globalvar *gv = (swig_globalvar *) malloc(sizeof(swig_globalvar)); + if (gv) { + size_t size = strlen(name)+1; + gv->name = (char *)malloc(size); + if (gv->name) { + strncpy(gv->name,name,size); + gv->get_attr = get_attr; + gv->set_attr = set_attr; + gv->next = v->vars; + } + } + v->vars = gv; + } + + SWIGINTERN PyObject * + SWIG_globals(void) { + static PyObject *_SWIG_globals = 0; + if (!_SWIG_globals) _SWIG_globals = SWIG_newvarlink(); + return _SWIG_globals; + } + + /* ----------------------------------------------------------------------------- + * constants/methods manipulation + * ----------------------------------------------------------------------------- */ + + /* Install Constants */ + SWIGINTERN void + SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) { + PyObject *obj = 0; + size_t i; + for (i = 0; constants[i].type; ++i) { + switch(constants[i].type) { + case SWIG_PY_POINTER: + obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0); + break; + case SWIG_PY_BINARY: + obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype)); + break; + default: + obj = 0; + break; + } + if (obj) { + PyDict_SetItemString(d, constants[i].name, obj); + Py_DECREF(obj); + } + } + } + + /* -----------------------------------------------------------------------------*/ + /* Fix SwigMethods to carry the callback ptrs when needed */ + /* -----------------------------------------------------------------------------*/ + + SWIGINTERN void + SWIG_Python_FixMethods(PyMethodDef *methods, + swig_const_info *const_table, + swig_type_info **types, + swig_type_info **types_initial) { + size_t i; + for (i = 0; methods[i].ml_name; ++i) { + const char *c = methods[i].ml_doc; + if (c && (c = strstr(c, "swig_ptr: "))) { + int j; + swig_const_info *ci = 0; + const char *name = c + 10; + for (j = 0; const_table[j].type; ++j) { + if (strncmp(const_table[j].name, name, + strlen(const_table[j].name)) == 0) { + ci = &(const_table[j]); + break; + } + } + if (ci) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + strncpy(buff, methods[i].ml_doc, ldoc); + buff += ldoc; + strncpy(buff, "swig_ptr: ", 10); + buff += 10; + SWIG_PackVoidPtr(buff, ptr, ty->name, lptr); + methods[i].ml_doc = ndoc; + } + } + } + } + } + } + +#ifdef __cplusplus +} +#endif + +/* -----------------------------------------------------------------------------* + * Partial Init method + * -----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" +#endif +SWIGEXPORT void SWIG_init(void) { + PyObject *m, *d; + + /* Fix SwigMethods to carry the callback ptrs when needed */ + SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); + + m = Py_InitModule((char *) SWIG_name, SwigMethods); + d = PyModule_GetDict(m); + + SWIG_InitializeModule(0); + SWIG_InstallConstants(d,swig_const_table); + + + + + mod_win32_client = PyImport_ImportModule("win32com.client"); + mod_pywintypes = PyImport_ImportModule("pywintypes"); + ComError = PyObject_GetAttrString(mod_pywintypes, "com_error"); + + wmi_init(&com_ctx, NULL); + { + PyObject *pModule; + + pModule = PyImport_ImportModule( "win32com.client" ); + } + +} + diff --git a/source4/lib/wmi/wmicore.c b/source4/lib/wmi/wmicore.c new file mode 100644 index 0000000000..fbd6b339bf --- /dev/null +++ b/source4/lib/wmi/wmicore.c @@ -0,0 +1,264 @@ +/* + WMI Sample client + Copyright (C) 2006 Andrzej Hajda <andrzej.hajda@wp.pl> + Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org> + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "auth/credentials/credentials.h" +#include "librpc/gen_ndr/com_dcom.h" +#include "lib/com/dcom/dcom.h" +#include "librpc/gen_ndr/wmi.h" +#include "librpc/gen_ndr/com_wmi.h" +#include "librpc/rpc/dcerpc.h" +#include "librpc/ndr/ndr_table.h" +#include "param/param.h" + +struct IWbemServices; +struct IWbemContext; + +#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \ + DEBUG(0, ("ERROR: %s\n", msg)); \ + goto end; \ + } else { \ + DEBUG(1, ("OK : %s\n", msg)); \ + } + +void wmi_init(struct com_context **ctx, struct cli_credentials *credentials) +{ + dcerpc_init(); + ndr_table_init(); + + /* FIXME: Register DCOM proxies? */ + + com_init_ctx(ctx, NULL); + dcom_client_init(*ctx, credentials); +} + +/** FIXME: Use credentials struct rather than user/password here */ +WERROR WBEM_ConnectServer(struct com_context *ctx, const char *server, const uint16_t *nspace, + const char *user, const char *password, + const char *locale, uint32_t flags, const char *authority, + struct IWbemContext* wbem_ctx, struct IWbemServices** services) +{ + struct GUID clsid; + struct GUID iid; + WERROR result, coresult; + struct IUnknown **mqi; + struct IWbemLevel1Login *pL; + + if (user) { + char *cred; + struct cli_credentials *cc; + + cred = talloc_asprintf(NULL, "%s%%%s", user, password); + cc = cli_credentials_init(cred); + cli_credentials_set_conf(cc, global_loadparm); + cli_credentials_parse_string(cc, cred, CRED_SPECIFIED); + dcom_set_server_credentials(ctx, server, cc); + talloc_free(cred); + } + + GUID_from_string(CLSID_WBEMLEVEL1LOGIN, &clsid); + GUID_from_string(COM_IWBEMLEVEL1LOGIN_UUID, &iid); + result = dcom_create_object(ctx, &clsid, server, 1, &iid, &mqi, &coresult); + WERR_CHECK("dcom_create_object."); + result = coresult; + WERR_CHECK("Create remote WMI object."); + pL = (struct IWbemLevel1Login *)mqi[0]; + talloc_free(mqi); + + result = IWbemLevel1Login_NTLMLogin(pL, ctx, nspace, locale, flags, wbem_ctx, services); + WERR_CHECK("Login to remote object."); + + IUnknown_Release((struct IUnknown *)pL, ctx); +end: + return result; +} + +struct werror_code_struct { + const char *dos_errstr; + WERROR werror; +}; + +static const struct werror_code_struct wmi_errs[] = +{ + { "RPC_S_CALL_FAILED", W_ERROR(RPC_S_CALL_FAILED) }, + + { "WBEM_NO_ERROR", W_ERROR(WBEM_NO_ERROR) }, + { "WBEM_S_NO_ERROR", W_ERROR(WBEM_S_NO_ERROR) }, + { "WBEM_S_SAME", W_ERROR(WBEM_S_SAME) }, + { "WBEM_S_FALSE", W_ERROR(WBEM_S_FALSE) }, + { "WBEM_S_ALREADY_EXISTS", W_ERROR(WBEM_S_ALREADY_EXISTS) }, + { "WBEM_S_RESET_TO_DEFAULT", W_ERROR(WBEM_S_RESET_TO_DEFAULT) }, + { "WBEM_S_DIFFERENT", W_ERROR(WBEM_S_DIFFERENT) }, + { "WBEM_S_TIMEDOUT", W_ERROR(WBEM_S_TIMEDOUT) }, + { "WBEM_S_NO_MORE_DATA", W_ERROR(WBEM_S_NO_MORE_DATA) }, + { "WBEM_S_OPERATION_CANCELLED", W_ERROR(WBEM_S_OPERATION_CANCELLED) }, + { "WBEM_S_PENDING", W_ERROR(WBEM_S_PENDING) }, + { "WBEM_S_DUPLICATE_OBJECTS", W_ERROR(WBEM_S_DUPLICATE_OBJECTS) }, + { "WBEM_S_ACCESS_DENIED", W_ERROR(WBEM_S_ACCESS_DENIED) }, + { "WBEM_S_PARTIAL_RESULTS", W_ERROR(WBEM_S_PARTIAL_RESULTS) }, + { "WBEM_S_NO_POSTHOOK", W_ERROR(WBEM_S_NO_POSTHOOK) }, + { "WBEM_S_POSTHOOK_WITH_BOTH", W_ERROR(WBEM_S_POSTHOOK_WITH_BOTH) }, + { "WBEM_S_POSTHOOK_WITH_NEW", W_ERROR(WBEM_S_POSTHOOK_WITH_NEW) }, + { "WBEM_S_POSTHOOK_WITH_STATUS", W_ERROR(WBEM_S_POSTHOOK_WITH_STATUS) }, + { "WBEM_S_POSTHOOK_WITH_OLD", W_ERROR(WBEM_S_POSTHOOK_WITH_OLD) }, + { "WBEM_S_REDO_PREHOOK_WITH_ORIGINAL_OBJECT", W_ERROR(WBEM_S_REDO_PREHOOK_WITH_ORIGINAL_OBJECT) }, + { "WBEM_S_SOURCE_NOT_AVAILABLE", W_ERROR(WBEM_S_SOURCE_NOT_AVAILABLE) }, + { "WBEM_E_FAILED", W_ERROR(WBEM_E_FAILED) }, + { "WBEM_E_NOT_FOUND", W_ERROR(WBEM_E_NOT_FOUND) }, + { "WBEM_E_ACCESS_DENIED", W_ERROR(WBEM_E_ACCESS_DENIED) }, + { "WBEM_E_PROVIDER_FAILURE", W_ERROR(WBEM_E_PROVIDER_FAILURE) }, + { "WBEM_E_TYPE_MISMATCH", W_ERROR(WBEM_E_TYPE_MISMATCH) }, + { "WBEM_E_OUT_OF_MEMORY", W_ERROR(WBEM_E_OUT_OF_MEMORY) }, + { "WBEM_E_INVALID_CONTEXT", W_ERROR(WBEM_E_INVALID_CONTEXT) }, + { "WBEM_E_INVALID_PARAMETER", W_ERROR(WBEM_E_INVALID_PARAMETER) }, + { "WBEM_E_NOT_AVAILABLE", W_ERROR(WBEM_E_NOT_AVAILABLE) }, + { "WBEM_E_CRITICAL_ERROR", W_ERROR(WBEM_E_CRITICAL_ERROR) }, + { "WBEM_E_INVALID_STREAM", W_ERROR(WBEM_E_INVALID_STREAM) }, + { "WBEM_E_NOT_SUPPORTED", W_ERROR(WBEM_E_NOT_SUPPORTED) }, + { "WBEM_E_INVALID_SUPERCLASS", W_ERROR(WBEM_E_INVALID_SUPERCLASS) }, + { "WBEM_E_INVALID_NAMESPACE", W_ERROR(WBEM_E_INVALID_NAMESPACE) }, + { "WBEM_E_INVALID_OBJECT", W_ERROR(WBEM_E_INVALID_OBJECT) }, + { "WBEM_E_INVALID_CLASS", W_ERROR(WBEM_E_INVALID_CLASS) }, + { "WBEM_E_PROVIDER_NOT_FOUND", W_ERROR(WBEM_E_PROVIDER_NOT_FOUND) }, + { "WBEM_E_INVALID_PROVIDER_REGISTRATION", W_ERROR(WBEM_E_INVALID_PROVIDER_REGISTRATION) }, + { "WBEM_E_PROVIDER_LOAD_FAILURE", W_ERROR(WBEM_E_PROVIDER_LOAD_FAILURE) }, + { "WBEM_E_INITIALIZATION_FAILURE", W_ERROR(WBEM_E_INITIALIZATION_FAILURE) }, + { "WBEM_E_TRANSPORT_FAILURE", W_ERROR(WBEM_E_TRANSPORT_FAILURE) }, + { "WBEM_E_INVALID_OPERATION", W_ERROR(WBEM_E_INVALID_OPERATION) }, + { "WBEM_E_INVALID_QUERY", W_ERROR(WBEM_E_INVALID_QUERY) }, + { "WBEM_E_INVALID_QUERY_TYPE", W_ERROR(WBEM_E_INVALID_QUERY_TYPE) }, + { "WBEM_E_ALREADY_EXISTS", W_ERROR(WBEM_E_ALREADY_EXISTS) }, + { "WBEM_E_OVERRIDE_NOT_ALLOWED", W_ERROR(WBEM_E_OVERRIDE_NOT_ALLOWED) }, + { "WBEM_E_PROPAGATED_QUALIFIER", W_ERROR(WBEM_E_PROPAGATED_QUALIFIER) }, + { "WBEM_E_PROPAGATED_PROPERTY", W_ERROR(WBEM_E_PROPAGATED_PROPERTY) }, + { "WBEM_E_UNEXPECTED", W_ERROR(WBEM_E_UNEXPECTED) }, + { "WBEM_E_ILLEGAL_OPERATION", W_ERROR(WBEM_E_ILLEGAL_OPERATION) }, + { "WBEM_E_CANNOT_BE_KEY", W_ERROR(WBEM_E_CANNOT_BE_KEY) }, + { "WBEM_E_INCOMPLETE_CLASS", W_ERROR(WBEM_E_INCOMPLETE_CLASS) }, + { "WBEM_E_INVALID_SYNTAX", W_ERROR(WBEM_E_INVALID_SYNTAX) }, + { "WBEM_E_NONDECORATED_OBJECT", W_ERROR(WBEM_E_NONDECORATED_OBJECT) }, + { "WBEM_E_READ_ONLY", W_ERROR(WBEM_E_READ_ONLY) }, + { "WBEM_E_PROVIDER_NOT_CAPABLE", W_ERROR(WBEM_E_PROVIDER_NOT_CAPABLE) }, + { "WBEM_E_CLASS_HAS_CHILDREN", W_ERROR(WBEM_E_CLASS_HAS_CHILDREN) }, + { "WBEM_E_CLASS_HAS_INSTANCES", W_ERROR(WBEM_E_CLASS_HAS_INSTANCES) }, + { "WBEM_E_QUERY_NOT_IMPLEMENTED", W_ERROR(WBEM_E_QUERY_NOT_IMPLEMENTED) }, + { "WBEM_E_ILLEGAL_NULL", W_ERROR(WBEM_E_ILLEGAL_NULL) }, + { "WBEM_E_INVALID_QUALIFIER_TYPE", W_ERROR(WBEM_E_INVALID_QUALIFIER_TYPE) }, + { "WBEM_E_INVALID_PROPERTY_TYPE", W_ERROR(WBEM_E_INVALID_PROPERTY_TYPE) }, + { "WBEM_E_VALUE_OUT_OF_RANGE", W_ERROR(WBEM_E_VALUE_OUT_OF_RANGE) }, + { "WBEM_E_CANNOT_BE_SINGLETON", W_ERROR(WBEM_E_CANNOT_BE_SINGLETON) }, + { "WBEM_E_INVALID_CIM_TYPE", W_ERROR(WBEM_E_INVALID_CIM_TYPE) }, + { "WBEM_E_INVALID_METHOD", W_ERROR(WBEM_E_INVALID_METHOD) }, + { "WBEM_E_INVALID_METHOD_PARAMETERS", W_ERROR(WBEM_E_INVALID_METHOD_PARAMETERS) }, + { "WBEM_E_SYSTEM_PROPERTY", W_ERROR(WBEM_E_SYSTEM_PROPERTY) }, + { "WBEM_E_INVALID_PROPERTY", W_ERROR(WBEM_E_INVALID_PROPERTY) }, + { "WBEM_E_CALL_CANCELLED", W_ERROR(WBEM_E_CALL_CANCELLED) }, + { "WBEM_E_SHUTTING_DOWN", W_ERROR(WBEM_E_SHUTTING_DOWN) }, + { "WBEM_E_PROPAGATED_METHOD", W_ERROR(WBEM_E_PROPAGATED_METHOD) }, + { "WBEM_E_UNSUPPORTED_PARAMETER", W_ERROR(WBEM_E_UNSUPPORTED_PARAMETER) }, + { "WBEM_E_MISSING_PARAMETER_ID", W_ERROR(WBEM_E_MISSING_PARAMETER_ID) }, + { "WBEM_E_INVALID_PARAMETER_ID", W_ERROR(WBEM_E_INVALID_PARAMETER_ID) }, + { "WBEM_E_NONCONSECUTIVE_PARAMETER_IDS", W_ERROR(WBEM_E_NONCONSECUTIVE_PARAMETER_IDS) }, + { "WBEM_E_PARAMETER_ID_ON_RETVAL", W_ERROR(WBEM_E_PARAMETER_ID_ON_RETVAL) }, + { "WBEM_E_INVALID_OBJECT_PATH", W_ERROR(WBEM_E_INVALID_OBJECT_PATH) }, + { "WBEM_E_OUT_OF_DISK_SPACE", W_ERROR(WBEM_E_OUT_OF_DISK_SPACE) }, + { "WBEM_E_BUFFER_TOO_SMALL", W_ERROR(WBEM_E_BUFFER_TOO_SMALL) }, + { "WBEM_E_UNSUPPORTED_PUT_EXTENSION", W_ERROR(WBEM_E_UNSUPPORTED_PUT_EXTENSION) }, + { "WBEM_E_UNKNOWN_OBJECT_TYPE", W_ERROR(WBEM_E_UNKNOWN_OBJECT_TYPE) }, + { "WBEM_E_UNKNOWN_PACKET_TYPE", W_ERROR(WBEM_E_UNKNOWN_PACKET_TYPE) }, + { "WBEM_E_MARSHAL_VERSION_MISMATCH", W_ERROR(WBEM_E_MARSHAL_VERSION_MISMATCH) }, + { "WBEM_E_MARSHAL_INVALID_SIGNATURE", W_ERROR(WBEM_E_MARSHAL_INVALID_SIGNATURE) }, + { "WBEM_E_INVALID_QUALIFIER", W_ERROR(WBEM_E_INVALID_QUALIFIER) }, + { "WBEM_E_INVALID_DUPLICATE_PARAMETER", W_ERROR(WBEM_E_INVALID_DUPLICATE_PARAMETER) }, + { "WBEM_E_TOO_MUCH_DATA", W_ERROR(WBEM_E_TOO_MUCH_DATA) }, + { "WBEM_E_SERVER_TOO_BUSY", W_ERROR(WBEM_E_SERVER_TOO_BUSY) }, + { "WBEM_E_INVALID_FLAVOR", W_ERROR(WBEM_E_INVALID_FLAVOR) }, + { "WBEM_E_CIRCULAR_REFERENCE", W_ERROR(WBEM_E_CIRCULAR_REFERENCE) }, + { "WBEM_E_UNSUPPORTED_CLASS_UPDATE", W_ERROR(WBEM_E_UNSUPPORTED_CLASS_UPDATE) }, + { "WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE", W_ERROR(WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE) }, + { "WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE", W_ERROR(WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE) }, + { "WBEM_E_TOO_MANY_PROPERTIES", W_ERROR(WBEM_E_TOO_MANY_PROPERTIES) }, + { "WBEM_E_UPDATE_TYPE_MISMATCH", W_ERROR(WBEM_E_UPDATE_TYPE_MISMATCH) }, + { "WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED", W_ERROR(WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED) }, + { "WBEM_E_UPDATE_PROPAGATED_METHOD", W_ERROR(WBEM_E_UPDATE_PROPAGATED_METHOD) }, + { "WBEM_E_METHOD_NOT_IMPLEMENTED", W_ERROR(WBEM_E_METHOD_NOT_IMPLEMENTED) }, + { "WBEM_E_METHOD_DISABLED", W_ERROR(WBEM_E_METHOD_DISABLED) }, + { "WBEM_E_REFRESHER_BUSY", W_ERROR(WBEM_E_REFRESHER_BUSY) }, + { "WBEM_E_UNPARSABLE_QUERY", W_ERROR(WBEM_E_UNPARSABLE_QUERY) }, + { "WBEM_E_NOT_EVENT_CLASS", W_ERROR(WBEM_E_NOT_EVENT_CLASS) }, + { "WBEM_E_MISSING_GROUP_WITHIN", W_ERROR(WBEM_E_MISSING_GROUP_WITHIN) }, + { "WBEM_E_MISSING_AGGREGATION_LIST", W_ERROR(WBEM_E_MISSING_AGGREGATION_LIST) }, + { "WBEM_E_PROPERTY_NOT_AN_OBJECT", W_ERROR(WBEM_E_PROPERTY_NOT_AN_OBJECT) }, + { "WBEM_E_AGGREGATING_BY_OBJECT", W_ERROR(WBEM_E_AGGREGATING_BY_OBJECT) }, + { "WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY", W_ERROR(WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY) }, + { "WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING", W_ERROR(WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING) }, + { "WBEM_E_QUEUE_OVERFLOW", W_ERROR(WBEM_E_QUEUE_OVERFLOW) }, + { "WBEM_E_PRIVILEGE_NOT_HELD", W_ERROR(WBEM_E_PRIVILEGE_NOT_HELD) }, + { "WBEM_E_INVALID_OPERATOR", W_ERROR(WBEM_E_INVALID_OPERATOR) }, + { "WBEM_E_LOCAL_CREDENTIALS", W_ERROR(WBEM_E_LOCAL_CREDENTIALS) }, + { "WBEM_E_CANNOT_BE_ABSTRACT", W_ERROR(WBEM_E_CANNOT_BE_ABSTRACT) }, + { "WBEM_E_AMENDED_OBJECT", W_ERROR(WBEM_E_AMENDED_OBJECT) }, + { "WBEM_E_CLIENT_TOO_SLOW", W_ERROR(WBEM_E_CLIENT_TOO_SLOW) }, + { "WBEM_E_NULL_SECURITY_DESCRIPTOR", W_ERROR(WBEM_E_NULL_SECURITY_DESCRIPTOR) }, + { "WBEM_E_TIMED_OUT", W_ERROR(WBEM_E_TIMED_OUT) }, + { "WBEM_E_INVALID_ASSOCIATION", W_ERROR(WBEM_E_INVALID_ASSOCIATION) }, + { "WBEM_E_AMBIGUOUS_OPERATION", W_ERROR(WBEM_E_AMBIGUOUS_OPERATION) }, + { "WBEM_E_QUOTA_VIOLATION", W_ERROR(WBEM_E_QUOTA_VIOLATION) }, + { "WBEM_E_RESERVED_001", W_ERROR(WBEM_E_RESERVED_001) }, + { "WBEM_E_RESERVED_002", W_ERROR(WBEM_E_RESERVED_002) }, + { "WBEM_E_UNSUPPORTED_LOCALE", W_ERROR(WBEM_E_UNSUPPORTED_LOCALE) }, + { "WBEM_E_HANDLE_OUT_OF_DATE", W_ERROR(WBEM_E_HANDLE_OUT_OF_DATE) }, + { "WBEM_E_CONNECTION_FAILED", W_ERROR(WBEM_E_CONNECTION_FAILED) }, + { "WBEM_E_INVALID_HANDLE_REQUEST", W_ERROR(WBEM_E_INVALID_HANDLE_REQUEST) }, + { "WBEM_E_PROPERTY_NAME_TOO_WIDE", W_ERROR(WBEM_E_PROPERTY_NAME_TOO_WIDE) }, + { "WBEM_E_CLASS_NAME_TOO_WIDE", W_ERROR(WBEM_E_CLASS_NAME_TOO_WIDE) }, + { "WBEM_E_METHOD_NAME_TOO_WIDE", W_ERROR(WBEM_E_METHOD_NAME_TOO_WIDE) }, + { "WBEM_E_QUALIFIER_NAME_TOO_WIDE", W_ERROR(WBEM_E_QUALIFIER_NAME_TOO_WIDE) }, + { "WBEM_E_RERUN_COMMAND", W_ERROR(WBEM_E_RERUN_COMMAND) }, + { "WBEM_E_DATABASE_VER_MISMATCH", W_ERROR(WBEM_E_DATABASE_VER_MISMATCH) }, + { "WBEM_E_VETO_DELETE", W_ERROR(WBEM_E_VETO_DELETE) }, + { "WBEM_E_VETO_PUT", W_ERROR(WBEM_E_VETO_PUT) }, + { "WBEM_E_INVALID_LOCALE", W_ERROR(WBEM_E_INVALID_LOCALE) }, + { "WBEM_E_PROVIDER_SUSPENDED", W_ERROR(WBEM_E_PROVIDER_SUSPENDED) }, + { "WBEM_E_SYNCHRONIZATION_REQUIRED", W_ERROR(WBEM_E_SYNCHRONIZATION_REQUIRED) }, + { "WBEM_E_NO_SCHEMA", W_ERROR(WBEM_E_NO_SCHEMA) }, + { "WBEM_E_PROVIDER_ALREADY_REGISTERED", W_ERROR(WBEM_E_PROVIDER_ALREADY_REGISTERED) }, + { "WBEM_E_PROVIDER_NOT_REGISTERED", W_ERROR(WBEM_E_PROVIDER_NOT_REGISTERED) }, + { "WBEM_E_FATAL_TRANSPORT_ERROR", W_ERROR(WBEM_E_FATAL_TRANSPORT_ERROR) }, + { "WBEM_E_ENCRYPTED_CONNECTION_REQUIRED", W_ERROR(WBEM_E_ENCRYPTED_CONNECTION_REQUIRED) }, + { "WBEM_E_PROVIDER_TIMED_OUT", W_ERROR(WBEM_E_PROVIDER_TIMED_OUT) }, + { "WBEM_E_NO_KEY", W_ERROR(WBEM_E_NO_KEY) }, + { "WBEM_E_PROVIDER_DISABLED", W_ERROR(WBEM_E_PROVIDER_DISABLED) }, + { NULL, W_ERROR(0) } +}; + +const char *wmi_errstr(WERROR werror) +{ + int idx = 0; + + while (wmi_errs[idx].dos_errstr != NULL) { + if (W_ERROR_V(wmi_errs[idx].werror) == + W_ERROR_V(werror)) + return wmi_errs[idx].dos_errstr; + idx++; + } + + return win_errstr(werror); +} diff --git a/source4/librpc/idl/dcom.idl b/source4/librpc/idl/dcom.idl new file mode 100644 index 0000000000..64e1c1850b --- /dev/null +++ b/source4/librpc/idl/dcom.idl @@ -0,0 +1,300 @@ +/** + DCOM interfaces + http://www.ietf.org/internet-drafts/draft-brown-dcom-v1-spec-04.txt + */ + +[ + uuid("18f70770-8e64-11cf-9af1-0020af6e72f4"), + pointer_default(unique), + version(0.0) +] interface dcom_Unknown +{ + void UseProtSeq(); + void GetCustomProtseqInfo(); + void UpdateResolverBindings(); +} + +[ + object, + uuid("00000000-0000-0000-C000-000000000046"), + pointer_default(unique), + helpstring("Base interface for all COM interfaces") +] +interface IUnknown +{ + /*****************/ + /* Function 0x00 */ + /* Returns the interface with the specified IID + if implemented by this object */ + [local] WERROR QueryInterface([in,unique] GUID *iid, + [out,iid_is(riid)] IUnknown **data); + + /*****************/ + /* Function 0x01 */ + [local] uint32 AddRef(); + + /*****************/ + /* Function 0x02 */ + [local] uint32 Release(); +} + + +[ + object, + uuid("00000001-0000-0000-C000-000000000046"), + pointer_default(unique) +] interface IClassFactory : IUnknown +{ + [local] WERROR CreateInstance([in,unique] MInterfacePointer *pUnknown, + [in,unique] GUID *iid, + [out, iid_is(riid),unique] MInterfacePointer *ppv); + + [call_as(CreateInstance)] WERROR RemoteCreateInstance(); + + /* Set lock to TRUE when you want to do a lock + and set it to FALSE when you want to unlock */ + [local] WERROR LockServer([in] uint8 lock); + + [call_as(LockServer)] WERROR RemoteLockServer(); +} + +/* The remote version of IUnknown. This interface exists on every */ +/* OXID (whether an OXID represents either a thread or a process is */ +/* implementation specific). It is used by clients to query for new */ +/* interfaces, get additional references (for marshaling), and release */ +/* outstanding references. */ +/* This interface is passed along during OXID resolution. */ +/* */ +[ + uuid("00000131-0000-0000-C000-000000000046"), + object, + pointer_default(unique), + helpstring("Remote version of IUnknown") +] +interface IRemUnknown : IUnknown +{ + typedef [public] struct + { + WERROR hResult; /* result of call */ + STDOBJREF std; /* data for returned interface */ + } + REMQIRESULT; + + [call_as(QueryInterface)] WERROR RemQueryInterface ( + [in,unique] GUID *ripid, /* interface to QI on */ + [in] uint32 cRefs, /* count of AddRefs requested */ + [in] uint16 cIids, /* count of IIDs that follow */ + [in, unique, size_is(cIids)] GUID *iids, /* IIDs to QI for */ + [out, size_is(cIids), unique] MInterfacePointer *ip + ); + + typedef struct + { + GUID ipid; /* ipid to AddRef/Release */ + uint32 cPublicRefs; + uint32 cPrivateRefs; + } REMINTERFACEREF; + + [call_as(AddRef)] WERROR RemAddRef ( + [in] uint16 cInterfaceRefs, + [in, size_is(cInterfaceRefs)] REMINTERFACEREF InterfaceRefs[], + [out, size_is(cInterfaceRefs), unique] WERROR *pResults + ); + + [call_as(Release)] WERROR RemRelease ( + [in] uint16 cInterfaceRefs, + [in, size_is(cInterfaceRefs)] REMINTERFACEREF InterfaceRefs[] + ); +} + +[ + uuid("00000140-0000-0000-c000-000000000046"), + pointer_default(unique), + object +] interface IClassActivator : IUnknown +{ + void GetClassObject([in] GUID clsid, + [in] uint32 context, + [in] uint32 locale, + [in] GUID iid, + [out, iid_is(iid)] MInterfacePointer data); +} + +[ + uuid("00000136-0000-0000-c000-000000000046"), + pointer_default(unique), + object +] interface ISCMLocalActivator : IClassActivator +{ + WERROR ISCMLocalActivator_CreateInstance( ); +} + +[ + pointer_default(unique), + uuid("c6f3ee72-ce7e-11d1-b71e-00c04fc3111a") +] interface IMachineLocalActivator +{ + WERROR IMachineLocalActivator_foo(); +} + +[ + pointer_default(unique), + uuid("e60c73e6-88f9-11cf-9af1-0020af6e72f4") +] interface ILocalObjectExporter +{ + WERROR ILocalObjectExporter_Foo(); +} + +/* Looks like this is the equivalent of .NET's + System.Activator class */ +[ + uuid("000001a0-0000-0000-c000-000000000046"), + pointer_default(unique), + object +] + interface ISystemActivator : IClassActivator +{ + WERROR ISystemActivatorRemoteCreateInstance([in] hyper unknown1, /* OXID ? */ + [in] MInterfacePointer iface1, + [in] hyper unknown2, + [out] uint32 unknown3, + [out] MInterfacePointer iface2); +} + + + +/* Derived from IRemUnknown, this interface supports Remote Query interface */ +/* for objects that supply additional data beyond the STDOBJREF in their */ +/* marshaled interface packets. */ +[ + object, + pointer_default(unique), + uuid("00000143-0000-0000-C000-000000000046") +] + +interface IRemUnknown2 : IRemUnknown +{ + [call_as(QueryInterface2)] WERROR RemQueryInterface2 ( + [in, unique] GUID *ripid, + [in] uint16 cIids, + [in, size_is(cIids), unique] GUID *iids, + [out, size_is(cIids), unique] WERROR *phr, + [out, size_is(cIids), unique] MInterfacePointer *ppMIF + ); +} + +[ + object, + pointer_default(unique), + uuid("00020400-0000-0000-C000-000000000046") +] interface IDispatch : IUnknown +{ + /*****************/ + /* Function 0x03 */ + WERROR GetTypeInfoCount( + [out, unique] uint16 *pctinfo); + + typedef struct { + } REF_ITypeInfo; + + /*****************/ + /* Function 0x04 */ + WERROR GetTypeInfo ( + [in] uint16 iTInfo, + [in] uint32 lcid, + [out, unique] REF_ITypeInfo *ppTInfo); + + /*****************/ + /* Function 0x05 */ + WERROR GetIDsOfNames( + [in, unique] GUID *riid, + /*FIXME[in,size_is(cNames)] OLESTR *rgszNames[], */ + [in] uint16 cNames, + [in] uint32 lcid, + [out,size_is(cNames), unique] uint32 *rgDispId); + + typedef struct { + uint16 vartype; + uint16 FIXME; + } VARIANT; + + typedef struct { + uint16 FIXME; + } DISPPARAMS; + + /* Exception ? */ + typedef struct { + uint16 FIXME; + } EXCEPINFO; + + /*****************/ + /* Function 0x06 */ + WERROR Invoke( + [in] uint32 dispIdMember, + [in, unique] GUID *riid, + [in] uint32 lcid, + [in] uint16 wFlags, + [out,in, unique] DISPPARAMS *pDispParams, + [out, unique] VARIANT *pVarResult, + [out, unique] EXCEPINFO *pExcepInfo, + [out, unique] uint16 *puArgErr); +} + +[ + object, + local, + uuid("00000003-0000-0000-C000-000000000046") +] interface IMarshal : IUnknown +{ + WERROR MarshalInterface(); + WERROR UnMarshalInterface(); +} + +[ + uuid(DA23F6DB-6F45-466C-9EED-0B65286F2D78), + helpstring("ICoffeeMachine Interface"), + pointer_default(unique), + object +] interface ICoffeeMachine : IUnknown +{ + WERROR MakeCoffee([in,string,charset(UTF16)] uint16 *flavor); +} + +[ + uuid("db7c21f8-fe33-4c11-aea5-ceb56f076fbb"), + helpstring("coffeemachine class") +] coclass coffeemachine +{ + interface icoffeemachine; +} + +[ + object, + pointer_default(unique), + uuid("0000000C-0000-0000-C000-000000000046"), + helpstring("Stream") +] +interface IStream : IUnknown +{ + WERROR Read( + [out, size_is(num_requested), length_is(num_read)] uint8 pv[], + [in] uint32 num_requested, + [in, unique] uint32 *num_readx, + [out] uint32 num_read + ); + + WERROR Write( + [in,size_is(num_requested),unique] uint8 *data, + [in] uint32 num_requested, + [out] uint32 num_written); +} + +[ + uuid("5e9ddec7-5767-11cf-beab-00aa006c3606"), + progid("Samba.Simple"), + helpstring("simple class"), + internal +] coclass simple +{ + interface IStream; +} diff --git a/source4/librpc/idl/wmi.idl b/source4/librpc/idl/wmi.idl new file mode 100644 index 0000000000..fe16e5e8ef --- /dev/null +++ b/source4/librpc/idl/wmi.idl @@ -0,0 +1,879 @@ +/* + * WMI IDL. + * See http://en.wikipedia.org/wiki/Windows_Management_Instrumentation for more information. + */ +#include "idl_types.h" + +import "dcom.idl"; + +[ + uuid("8BC3F05E-D86B-11d0-A075-00C04FB68820") +] coclass WbemLevel1Login +{ + interface IWbemLevel1Login; + +}; + +[local, object, uuid("dc12a681-737f-11cf-884d-00aa004b2e24")] + +interface IWbemClassObject : IUnknown +{ + + typedef struct { + [value(0x72657355)] uint32 flags; + [string, charset(UTF16)] uint16 data[]; + } BSTR; + + WERROR Delete( + [in, string, charset(UTF16)] uint16 *wszName + ); + +}; + +[ + uuid("9556dc99-828c-11cf-a37e-00aa003240c7"), + object, + pointer_default(unique) +] interface IWbemServices : IUnknown +{ + typedef [v1_enum] enum + { + RPC_S_CALL_FAILED = 1726, + + WBEM_NO_ERROR = 0, + WBEM_S_NO_ERROR = 0, + WBEM_S_SAME = 0, + WBEM_S_FALSE = 1, + WBEM_S_ALREADY_EXISTS = 0x40001, + WBEM_S_RESET_TO_DEFAULT = 0x40002, + WBEM_S_DIFFERENT = 0x40003, + WBEM_S_TIMEDOUT = 0x40004, + WBEM_S_NO_MORE_DATA = 0x40005, + WBEM_S_OPERATION_CANCELLED = 0x40006, + WBEM_S_PENDING = 0x40007, + WBEM_S_DUPLICATE_OBJECTS = 0x40008, + WBEM_S_ACCESS_DENIED = 0x40009, + WBEM_S_PARTIAL_RESULTS = 0x40010, + WBEM_S_NO_POSTHOOK = 0x40011, + WBEM_S_POSTHOOK_WITH_BOTH = 0x40012, + WBEM_S_POSTHOOK_WITH_NEW = 0x40013, + WBEM_S_POSTHOOK_WITH_STATUS = 0x40014, + WBEM_S_POSTHOOK_WITH_OLD = 0x40015, + WBEM_S_REDO_PREHOOK_WITH_ORIGINAL_OBJECT = 0x40016, + WBEM_S_SOURCE_NOT_AVAILABLE = 0x40017, + WBEM_E_FAILED = 0x80041001, + WBEM_E_NOT_FOUND = 0x80041002, + WBEM_E_ACCESS_DENIED = 0x80041003, + WBEM_E_PROVIDER_FAILURE = 0x80041004, + WBEM_E_TYPE_MISMATCH = 0x80041005, + WBEM_E_OUT_OF_MEMORY = 0x80041006, + WBEM_E_INVALID_CONTEXT = 0x80041007, + WBEM_E_INVALID_PARAMETER = 0x80041008, + WBEM_E_NOT_AVAILABLE = 0x80041009, + WBEM_E_CRITICAL_ERROR = 0x8004100A, + WBEM_E_INVALID_STREAM = 0x8004100B, + WBEM_E_NOT_SUPPORTED = 0x8004100C, + WBEM_E_INVALID_SUPERCLASS = 0x8004100D, + WBEM_E_INVALID_NAMESPACE = 0x8004100E, + WBEM_E_INVALID_OBJECT = 0x8004100F, + WBEM_E_INVALID_CLASS = 0x80041010, + WBEM_E_PROVIDER_NOT_FOUND = 0x80041011, + WBEM_E_INVALID_PROVIDER_REGISTRATION = 0x80041012, + WBEM_E_PROVIDER_LOAD_FAILURE = 0x80041013, + WBEM_E_INITIALIZATION_FAILURE = 0x80041014, + WBEM_E_TRANSPORT_FAILURE = 0x80041015, + WBEM_E_INVALID_OPERATION = 0x80041016, + WBEM_E_INVALID_QUERY = 0x80041017, + WBEM_E_INVALID_QUERY_TYPE = 0x80041018, + WBEM_E_ALREADY_EXISTS = 0x80041019, + WBEM_E_OVERRIDE_NOT_ALLOWED = 0x8004101A, + WBEM_E_PROPAGATED_QUALIFIER = 0x8004101B, + WBEM_E_PROPAGATED_PROPERTY = 0x8004101C, + WBEM_E_UNEXPECTED = 0x8004101D, + WBEM_E_ILLEGAL_OPERATION = 0x8004101E, + WBEM_E_CANNOT_BE_KEY = 0x8004101F, + WBEM_E_INCOMPLETE_CLASS = 0x80041020, + WBEM_E_INVALID_SYNTAX = 0x80041021, + WBEM_E_NONDECORATED_OBJECT = 0x80041022, + WBEM_E_READ_ONLY = 0x80041023, + WBEM_E_PROVIDER_NOT_CAPABLE = 0x80041024, + WBEM_E_CLASS_HAS_CHILDREN = 0x80041025, + WBEM_E_CLASS_HAS_INSTANCES = 0x80041026, + WBEM_E_QUERY_NOT_IMPLEMENTED = 0x80041027, + WBEM_E_ILLEGAL_NULL = 0x80041028, + WBEM_E_INVALID_QUALIFIER_TYPE = 0x80041029, + WBEM_E_INVALID_PROPERTY_TYPE = 0x8004102A, + WBEM_E_VALUE_OUT_OF_RANGE = 0x8004102B, + WBEM_E_CANNOT_BE_SINGLETON = 0x8004102C, + WBEM_E_INVALID_CIM_TYPE = 0x8004102D, + WBEM_E_INVALID_METHOD = 0x8004102E, + WBEM_E_INVALID_METHOD_PARAMETERS = 0x8004102F, + WBEM_E_SYSTEM_PROPERTY = 0x80041030, + WBEM_E_INVALID_PROPERTY = 0x80041031, + WBEM_E_CALL_CANCELLED = 0x80041032, + WBEM_E_SHUTTING_DOWN = 0x80041033, + WBEM_E_PROPAGATED_METHOD = 0x80041034, + WBEM_E_UNSUPPORTED_PARAMETER = 0x80041035, + WBEM_E_MISSING_PARAMETER_ID = 0x80041036, + WBEM_E_INVALID_PARAMETER_ID = 0x80041037, + WBEM_E_NONCONSECUTIVE_PARAMETER_IDS = 0x80041038, + WBEM_E_PARAMETER_ID_ON_RETVAL = 0x80041039, + WBEM_E_INVALID_OBJECT_PATH = 0x8004103A, + WBEM_E_OUT_OF_DISK_SPACE = 0x8004103B, + WBEM_E_BUFFER_TOO_SMALL = 0x8004103C, + WBEM_E_UNSUPPORTED_PUT_EXTENSION = 0x8004103D, + WBEM_E_UNKNOWN_OBJECT_TYPE = 0x8004103E, + WBEM_E_UNKNOWN_PACKET_TYPE = 0x8004103F, + WBEM_E_MARSHAL_VERSION_MISMATCH = 0x80041040, + WBEM_E_MARSHAL_INVALID_SIGNATURE = 0x80041041, + WBEM_E_INVALID_QUALIFIER = 0x80041042, + WBEM_E_INVALID_DUPLICATE_PARAMETER = 0x80041043, + WBEM_E_TOO_MUCH_DATA = 0x80041044, + WBEM_E_SERVER_TOO_BUSY = 0x80041045, + WBEM_E_INVALID_FLAVOR = 0x80041046, + WBEM_E_CIRCULAR_REFERENCE = 0x80041047, + WBEM_E_UNSUPPORTED_CLASS_UPDATE = 0x80041048, + WBEM_E_CANNOT_CHANGE_KEY_INHERITANCE = 0x80041049, + WBEM_E_CANNOT_CHANGE_INDEX_INHERITANCE = 0x80041050, + WBEM_E_TOO_MANY_PROPERTIES = 0x80041051, + WBEM_E_UPDATE_TYPE_MISMATCH = 0x80041052, + WBEM_E_UPDATE_OVERRIDE_NOT_ALLOWED = 0x80041053, + WBEM_E_UPDATE_PROPAGATED_METHOD = 0x80041054, + WBEM_E_METHOD_NOT_IMPLEMENTED = 0x80041055, + WBEM_E_METHOD_DISABLED = 0x80041056, + WBEM_E_REFRESHER_BUSY = 0x80041057, + WBEM_E_UNPARSABLE_QUERY = 0x80041058, + WBEM_E_NOT_EVENT_CLASS = 0x80041059, + WBEM_E_MISSING_GROUP_WITHIN = 0x8004105A, + WBEM_E_MISSING_AGGREGATION_LIST = 0x8004105B, + WBEM_E_PROPERTY_NOT_AN_OBJECT = 0x8004105C, + WBEM_E_AGGREGATING_BY_OBJECT = 0x8004105D, + WBEM_E_UNINTERPRETABLE_PROVIDER_QUERY = 0x8004105F, + WBEM_E_BACKUP_RESTORE_WINMGMT_RUNNING = 0x80041060, + WBEM_E_QUEUE_OVERFLOW = 0x80041061, + WBEM_E_PRIVILEGE_NOT_HELD = 0x80041062, + WBEM_E_INVALID_OPERATOR = 0x80041063, + WBEM_E_LOCAL_CREDENTIALS = 0x80041064, + WBEM_E_CANNOT_BE_ABSTRACT = 0x80041065, + WBEM_E_AMENDED_OBJECT = 0x80041066, + WBEM_E_CLIENT_TOO_SLOW = 0x80041067, + WBEM_E_NULL_SECURITY_DESCRIPTOR = 0x80041068, + WBEM_E_TIMED_OUT = 0x80041069, + WBEM_E_INVALID_ASSOCIATION = 0x8004106A, + WBEM_E_AMBIGUOUS_OPERATION = 0x8004106B, + WBEM_E_QUOTA_VIOLATION = 0x8004106C, + WBEM_E_RESERVED_001 = 0x8004106D, + WBEM_E_RESERVED_002 = 0x8004106E, + WBEM_E_UNSUPPORTED_LOCALE = 0x8004106F, + WBEM_E_HANDLE_OUT_OF_DATE = 0x80041070, + WBEM_E_CONNECTION_FAILED = 0x80041071, + WBEM_E_INVALID_HANDLE_REQUEST = 0x80041072, + WBEM_E_PROPERTY_NAME_TOO_WIDE = 0x80041073, + WBEM_E_CLASS_NAME_TOO_WIDE = 0x80041074, + WBEM_E_METHOD_NAME_TOO_WIDE = 0x80041075, + WBEM_E_QUALIFIER_NAME_TOO_WIDE = 0x80041076, + WBEM_E_RERUN_COMMAND = 0x80041077, + WBEM_E_DATABASE_VER_MISMATCH = 0x80041078, + WBEM_E_VETO_DELETE = 0x80041079, + WBEM_E_VETO_PUT = 0x8004107A, + WBEM_E_INVALID_LOCALE = 0x80041080, + WBEM_E_PROVIDER_SUSPENDED = 0x80041081, + WBEM_E_SYNCHRONIZATION_REQUIRED = 0x80041082, + WBEM_E_NO_SCHEMA = 0x80041083, + WBEM_E_PROVIDER_ALREADY_REGISTERED = 0x80041084, + WBEM_E_PROVIDER_NOT_REGISTERED = 0x80041085, + WBEM_E_FATAL_TRANSPORT_ERROR = 0x80041086, + WBEM_E_ENCRYPTED_CONNECTION_REQUIRED = 0x80041087, + WBEM_E_PROVIDER_TIMED_OUT = 0x80041088, + WBEM_E_NO_KEY = 0x80041089, + WBEM_E_PROVIDER_DISABLED = 0x8004108a + } WBEMSTATUS; + + typedef [public,noprint] enum + { + WBEM_FLAG_RETURN_IMMEDIATELY = 0x10, + WBEM_FLAG_RETURN_WBEM_COMPLETE = 0, + WBEM_FLAG_BIDIRECTIONAL = 0, + WBEM_FLAG_FORWARD_ONLY = 0x20, + WBEM_FLAG_NO_ERROR_OBJECT = 0x40, + WBEM_FLAG_RETURN_ERROR_OBJECT = 0, + WBEM_FLAG_SEND_STATUS = 0x80, + WBEM_FLAG_DONT_SEND_STATUS = 0, + WBEM_FLAG_ENSURE_LOCATABLE = 0x100, + WBEM_FLAG_DIRECT_READ = 0x200, + WBEM_FLAG_SEND_ONLY_SELECTED = 0, + + WBEM_RETURN_WHEN_COMPLETE = 0, + WBEM_RETURN_IMMEDIATELY = 0x10, + + WBEM_MASK_RESERVED_FLAGS = 0x1F000, + + WBEM_FLAG_USE_AMENDED_QUALIFIERS = 0x20000, + + WBEM_FLAG_STRONG_VALIDATION = 0x100000 + + } WBEM_GENERIC_FLAG_TYPE; + + typedef [public,noprint,v1_enum] enum tag_WBEM_TIMEOUT_TYPE + { + WBEM_NO_WAIT = 0, + WBEM_INFINITE = 0xFFFFFFFF + } WBEM_TIMEOUT_TYPE; + + typedef [public,v1_enum] enum + { + CIM_EMPTY = 0, + + CIM_SINT8 = 16, + CIM_UINT8 = 17, + CIM_SINT16 = 2, + CIM_UINT16 = 18, + CIM_SINT32 = 3, + CIM_UINT32 = 19, + CIM_SINT64 = 20, + CIM_UINT64 = 21, + CIM_REAL32 = 4, + CIM_REAL64 = 5, + CIM_BOOLEAN = 11, + CIM_STRING = 8, + CIM_DATETIME = 101, + CIM_REFERENCE = 102, + CIM_CHAR16 = 103, + CIM_OBJECT = 13, + + CIM_FLAG_ARRAY = 0x2000, + + CIM_ARR_SINT8 = CIM_FLAG_ARRAY | CIM_SINT8, + CIM_ARR_UINT8 = CIM_FLAG_ARRAY | CIM_UINT8, + CIM_ARR_SINT16 = CIM_FLAG_ARRAY | CIM_SINT16, + CIM_ARR_UINT16 = CIM_FLAG_ARRAY | CIM_UINT16, + CIM_ARR_SINT32 = CIM_FLAG_ARRAY | CIM_SINT32, + CIM_ARR_UINT32 = CIM_FLAG_ARRAY | CIM_UINT32, + CIM_ARR_SINT64 = CIM_FLAG_ARRAY | CIM_SINT64, + CIM_ARR_UINT64 = CIM_FLAG_ARRAY | CIM_UINT64, + CIM_ARR_REAL32 = CIM_FLAG_ARRAY | CIM_REAL32, + CIM_ARR_REAL64 = CIM_FLAG_ARRAY | CIM_REAL64, + CIM_ARR_BOOLEAN = CIM_FLAG_ARRAY | CIM_BOOLEAN, + CIM_ARR_STRING = CIM_FLAG_ARRAY | CIM_STRING, + CIM_ARR_DATETIME = CIM_FLAG_ARRAY | CIM_DATETIME, + CIM_ARR_REFERENCE = CIM_FLAG_ARRAY | CIM_REFERENCE, + CIM_ARR_CHAR16 = CIM_FLAG_ARRAY | CIM_CHAR16, + CIM_ARR_OBJECT = CIM_FLAG_ARRAY | CIM_OBJECT, + + CIM_ILLEGAL = 0xfff, + CIM_TYPEMASK = 0x2FFF + } CIMTYPE_ENUMERATION; + + typedef [public] struct { + uint32 count; + int8 item[count]; + } arr_int8; + + typedef [public] struct { + uint32 count; + uint8 item[count]; + } arr_uint8; + + typedef [public] struct { + uint32 count; + int16 item[count]; + } arr_int16; + + typedef [public] struct { + uint32 count; + uint16 item[count]; + } arr_uint16; + + typedef [public] struct { + uint32 count; + int32 item[count]; + } arr_int32; + + typedef [public] struct { + uint32 count; + uint32 item[count]; + } arr_uint32; + + typedef [public] struct { + uint32 count; + dlong item[count]; + } arr_dlong; + + typedef [public] struct { + uint32 count; + udlong item[count]; + } arr_udlong; + + typedef [public] struct { + uint32 count; + [relative,charset(UTF16)] uint16 *item[count]; + } arr_CIMSTRING; + + typedef [public] struct { + uint32 count; + [relative,subcontext(4)] WbemClassObject *item[count]; + } arr_WbemClassObject; + +// FIXME:avg implement rest of types + typedef [public,nodiscriminant] union + { + [case(CIM_SINT8)] int8 v_sint8; + [case(CIM_UINT8)] uint8 v_uint8; + [case(CIM_SINT16)] int16 v_sint16; + [case(CIM_UINT16)] uint16 v_uint16; + [case(CIM_SINT32)] int32 v_sint32; + [case(CIM_UINT32)] uint32 v_uint32; + [case(CIM_SINT64)] dlong v_sint64; + [case(CIM_UINT64)] udlong v_uint64; + [case(CIM_REAL32)] uint32 v_real32; + [case(CIM_REAL64)] udlong v_real64; + [case(CIM_BOOLEAN)] uint16 v_boolean; + [case(CIM_STRING),relative,charset(UTF16)] uint16 *v_string; + [case(CIM_DATETIME),relative,charset(UTF16)] uint16 *v_datetime; + [case(CIM_REFERENCE),relative,charset(UTF16)] uint16 *v_reference; + [case(CIM_OBJECT),subcontext(4),relative] WbemClassObject *v_object; + + [case(CIM_ARR_SINT8),relative] arr_int8 *a_sint8; + [case(CIM_ARR_UINT8),relative] arr_uint8 *a_uint8; + [case(CIM_ARR_SINT16),relative] arr_int16 *a_sint16; + [case(CIM_ARR_UINT16),relative] arr_uint16 *a_uint16; + [case(CIM_ARR_SINT32),relative] arr_int32 *a_sint32; + [case(CIM_ARR_UINT32),relative] arr_uint32 *a_uint32; + [case(CIM_ARR_SINT64),relative] arr_dlong *a_sint64; + [case(CIM_ARR_UINT64),relative] arr_udlong *a_uint64; + [case(CIM_ARR_REAL32),relative] arr_uint32 *a_real32; + [case(CIM_ARR_REAL64),relative] arr_udlong *a_real64; + [case(CIM_ARR_BOOLEAN),relative] arr_uint16 *a_boolean; + [case(CIM_ARR_STRING),relative] arr_CIMSTRING *a_string; + [case(CIM_ARR_DATETIME),relative] arr_CIMSTRING *a_datetime; + [case(CIM_ARR_REFERENCE),relative] arr_CIMSTRING *a_reference; + [case(CIM_ARR_OBJECT),relative] arr_WbemClassObject *a_object; + } CIMVAR; + + typedef [public,bitmap8bit] bitmap + { + WBEM_FLAVOR_FLAG_PROPAGATE_TO_INSTANCE = 0x1, + WBEM_FLAVOR_FLAG_PROPAGATE_TO_DERIVED_CLASS = 0x2, +// WBEM_FLAVOR_MASK_PROPAGATION = 0x0F, + + WBEM_FLAVOR_NOT_OVERRIDABLE = 0x10, +// WBEM_FLAVOR_MASK_PERMISSIONS = 0x10, + + WBEM_FLAVOR_ORIGIN_PROPAGATED = 0x20, + WBEM_FLAVOR_ORIGIN_SYSTEM = 0x40, +// WBEM_FLAVOR_MASK_ORIGIN = 0x60, + + WBEM_FLAVOR_AMENDED = 0x80 +// WBEM_FLAVOR_MASK_AMENDED = 0x80 + + } WBEM_FLAVOR_TYPE; + + typedef [public,bitmap8bit] bitmap + { + WCF_DECORATIONS = 1, + WCF_INSTANCE = 2, + WCF_CLASS = 4, + WCF_CLASS_PART_INTERNAL = 8 +// WCF_CLASS_PART_SHARED = 0x104 + } WCO_FLAGS; + + typedef [public,nopush,nopull] struct + { + [relative,charset(UTF16)] uint16 *name; + WBEM_FLAVOR_TYPE flavors; + CIMTYPE_ENUMERATION cimtype; + [switch_is(cimtype)] CIMVAR value; + } WbemQualifier; + + typedef [public,nopush,nopull] struct + { + uint32 count; + [ref] WbemQualifier* item[count]; + } WbemQualifiers; + + typedef [public] struct + { + uint32 cimtype; + uint16 nr; + uint32 offset; + uint32 depth; + WbemQualifiers qualifiers; + } WbemPropertyDesc; + + typedef [public] struct + { + [relative,charset(UTF16)] uint16 *name; + [relative] WbemPropertyDesc *desc; + } WbemProperty; + + typedef [public,nopull,nopush] struct + { + uint32 count; + [ref,charset(UTF16)] uint16 *item[count]; + } CIMSTRINGS; + + typedef [public,bitmap8bit] bitmap { + DEFAULT_FLAG_EMPTY = 1, + DEFAULT_FLAG_INHERITED = 2 + } DEFAULT_FLAGS; + + typedef struct { + WbemProperty property; + uint8 default_flags; + [switch_is(property.desc->cimtype)] CIMVAR default_values; + } WbemClassProperty; + + + typedef [public,nopush,nopull,noprint,flag(NDR_NOALIGN)] struct + { + uint8 u_0; + [relative, null_is_ffffffff,charset(UTF16)] uint16 *__CLASS; + uint32 data_size; + CIMSTRINGS __DERIVATION; + WbemQualifiers qualifiers; + uint32 __PROPERTY_COUNT; + WbemClassProperty properties[__PROPERTY_COUNT]; + } WbemClass; + + typedef [public] struct + { + [relative,null_is_ffffffff,charset(UTF16)] uint16 *name; + uint32 u0; + uint32 u1; + [relative] WbemQualifiers *qualifiers; + [subcontext(4),relative] WbemClassObject *in; + [subcontext(4),relative] WbemClassObject *out; + } WbemMethod; + + typedef [public,flag(NDR_NOALIGN)] struct + { + uint16 count; + uint16 u0; // It has value 5F5F if there are no methods + WbemMethod method[count]; + } WbemMethods; + + typedef [public,flag(NDR_NOALIGN),nopush,nopull,noprint] struct + { + uint8 u1_0; + [relative,charset(UTF16)] uint16 *__CLASS; + uint8 *default_flags; + uint32 *data; + uint32 u2_4; + uint8 u3_1; + } WbemInstance; + + typedef [public,nopush,nopull,noprint,flag(NDR_NOALIGN)] struct + { + WCO_FLAGS flags; + [ref,charset(UTF16)] uint16 *__SERVER; + [ref,charset(UTF16)] uint16 *__NAMESPACE; + WbemClass *sup_class; + WbemMethods *sup_methods; + WbemClass *obj_class; + WbemMethods *obj_methods; + WbemInstance *instance; + } WbemClassObject; + +// typedef [public] struct { +// [value(0x72657355)] uint32 fFlags; +// uint32 clSize; +// [value(2*clSize)] uint32 _bsize; +// [value(clSize)] uint32 _wsize; +// [flag(NDR_NOALIGN)] uint16 asData[clSize]; +// } BSTR1; + //typedef [public,nopush,nopull,noprint,string,charset(UTF16)] uint16 *BSTR; + + WERROR OpenNamespace( +// [in] BSTR *strNamespace, +// [in] int32 lFlags +// [in] IWbemContext* pCtx, +// [out] IWbemServices** ppWorkingNamespace, +// [out] IWbemCallResult** ppResult + ); + + WERROR CancelAsyncCall( +// [in] IWbemObjectSink* pSink + ); + + WERROR QueryObjectSink( +// [in] long lFlags +// [out] IWbemObjectSink** ppResponseHandler + ); + + // Classes and instances. + // ====================== + + WERROR GetObject( + [in] BSTR strObjectPath, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, +// [in,out,unique] IUnknown** ppObject, +// [in,out,unique] IUnknown** ppCallResult + [in,out,unique] IWbemClassObject** ppObject, + [in,out,unique] IWbemCallResult** ppCallResult + ); + + WERROR GetObjectAsync( +// [in] BSTR strObjectPath, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + WERROR PutClass( +// [in] IWbemClassObject* pObject, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [out, OPTIONAL] IWbemCallResult** ppCallResult + ); + + WERROR PutClassAsync( +// [in] IWbemClassObject* pObject, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + WERROR DeleteClass( +// [in] BSTR strClass, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [out, OPTIONAL] IWbemCallResult** ppCallResult + ); + + WERROR DeleteClassAsync( +// [in] BSTR strClass, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + WERROR CreateClassEnum( +// [in] BSTR strSuperclass, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [out] IEnumWbemClassObject** ppEnum + ); + + WERROR CreateClassEnumAsync( +// [in] BSTR strSuperclass, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + WERROR PutInstance( +// [in] IWbemClassObject* pInst, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [out, OPTIONAL] IWbemCallResult** ppCallResult + ); + + WERROR PutInstanceAsync( +// [in] IWbemClassObject* pInst, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + WERROR DeleteInstance( +// [in] BSTR strObjectPath, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [out, OPTIONAL] IWbemCallResult** ppCallResult + ); + + WERROR DeleteInstanceAsync( +// [in] BSTR strObjectPath, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + WERROR CreateInstanceEnum( + [in] BSTR strFilter, // allow more things than a class name + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out] IEnumWbemClassObject** ppEnum + ); + + WERROR CreateInstanceEnumAsync( +// [in] BSTR strFilter, // allow more things than a class name +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + WERROR ExecQuery( + [in] BSTR strQueryLanguage, + [in] BSTR strQuery, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out] IEnumWbemClassObject** ppEnum + ); + + WERROR ExecQueryAsync( +// [in] BSTR strQueryLanguage, +// [in] BSTR strQuery, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + + WERROR ExecNotificationQuery( + [in] BSTR strQueryLanguage, + [in] BSTR strQuery, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out] IEnumWbemClassObject** ppEnum + ); + + WERROR ExecNotificationQueryAsync( +// [in] BSTR strQueryLanguage, +// [in] BSTR strQuery, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemObjectSink* pResponseHandler + ); + + // Methods + // ======= + + WERROR ExecMethod( + [in] BSTR strObjectPath, + [in] BSTR strMethodName, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [in,unique] IWbemClassObject* pInParams, + [in,out,unique] IWbemClassObject** ppOutParams, + [in,out,unique] IWbemCallResult** ppCallResult + ); + + WERROR ExecMethodAsync( +// [in] BSTR strObjectPath, +// [in] BSTR strMethodName, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [in] IWbemClassObject* pInParams, +// [in] IWbemObjectSink* pResponseHandler + ); +} + +[ + object, + uuid(027947e1-d731-11ce-a357-000000000001), + pointer_default(unique) +] interface IEnumWbemClassObject : IUnknown +{ + WERROR Reset(); + + [call_as(Next)] WERROR IEnumWbemClassObject_Next( + [in] int32 lTimeout, + [in] uint32 uCount, + [out, size_is(uCount), length_is(*puReturned)] + IWbemClassObject** apObjects, + [out] uint32* puReturned + ); + + WERROR NextAsync( +// [in] ULONG uCount +// [in] IWbemObjectSink* pSink + ); + + WERROR IEnumWbemClassObject_Clone( +// [out] IEnumWbemClassObject** ppEnum + ); + + WERROR Skip( +// [in] long lTimeout, +// [in] ULONG nCount + ); +}; + +[ + object, + local, + uuid("44aca674-e8fc-11d0-a07c-00c04fb68820"), + pointer_default(unique) +] interface IWbemContext : IUnknown +{ + WERROR Clone([out] IWbemContext** ppNewCopy); + + WERROR GetNames( +// [in] long lFlags, +// [out] SAFEARRAY (BSTR)* pNames + ); + + WERROR BeginEnumeration([in] long lFlags); + + WERROR Next( +// [in] long lFlags, +// [out] BSTR* pstrName, +// [out] VARIANT* pValue + ); + + WERROR EndEnumeration(); + + + WERROR SetValue( +// [in, string] LPCWSTR wszName, +// [in] long lFlags +// [in] VARIANT* pValue + ); + + WERROR GetValue( +// [in, string] LPCWSTR wszName, +// [in] long lFlags, +// [out] VARIANT* pValue + ); + + WERROR DeleteValue( +// [in, string] LPCWSTR wszName, +// [in] long lFlags + ); + + WERROR DeleteAll(); +} + +[ + object, + uuid("F309AD18-D86A-11d0-A075-00C04FB68820"), + pointer_default(unique) +] interface IWbemLevel1Login : IUnknown +{ + WERROR EstablishPosition( +// [in, unique, string] LPWSTR wszClientMachineName, +// [in] uint32 dwProcessId, +// [out] uint32* phAuthEventHandle + ); + + WERROR RequestChallenge( +// [in, unique, string] LPWSTR wszNetworkResource, +// [in, unique, string] LPWSTR wszUser, +// [out] WBEM_128BITS Nonce + ); + + WERROR WBEMLogin( +// [in, unique, string] LPWSTR wszPreferredLocale, +// [in, unique] WBEM_128BITS AccessToken, +// [in] long lFlags +// [in] IWbemContext* pCtx, +// [out] IWbemServices** ppNamespace + ); + + WERROR NTLMLogin( + [in,unique,string,charset(UTF16)] uint16 *wszNetworkResource, + [in,unique,string,charset(UTF16)] uint16 *wszPreferredLocale, + [in] long lFlags, + [in,unique] IWbemContext* pCtx, + [out,ref] IWbemServices** ppNamespace + ); + +} + +[ + object, + uuid("423ec01e-2e35-11d2-b604-00104b703efd"), + pointer_default(unique) +] interface IWbemWCOSmartEnum : IUnknown +{ + typedef struct { + uint32 size; + char data[size]; + } WBEMDATA; + + typedef enum { + WTYPE_SCHEMA = 1, + WTYPE_CLASS = 2, + WTYPE_OBJECT = 3 + } WTYPES; + + typedef [relative_base] struct { +// [relative] WBEMDATA4 *data; /* 0x9 */ + uint32 data_size; + uint8 wtype; + } WBEMDATA4; + + typedef [relative_base] struct { + [relative] WBEMDATA4 *data; /* 0x9 */ + uint32 data_size; + uint8 wtype; + } WBEMDATA3; + + typedef [relative_base] struct { + [relative,size_is(obj_num)] WBEMDATA3 *data; /* 0x8 */ + uint32 data_size; + uint32 obj_num; + } WBEMDATA2; + + typedef [relative_base] struct { + [relative] WBEMDATA2 *data; /* 0x8 */ + uint32 data_size; + } WBEMDATA1; + + typedef [relative_base] struct { + uint32 u1_0; /* 0 */ + hyper signature; /* 'WBEMDATA' */ + [relative] WBEMDATA1 *data; /* 0x1A */ + uint32 data_size; + uint32 u2_0; /* 0 */ + uint8 ver_major; /* 1 */ + uint8 ver_minor; /* 0 - Win2000, 1 - WinXP/2003 */ + } WBEMDATA0; + + WERROR IWbemWCOSmartEnum_Next( + [in,ref] GUID *gEWCO, + [in] uint32 lTimeOut, + [in] uint32 uCount, +// [in] uint32 unknown, +// [in,ref] GUID *gWCO, + [out,ref] uint32 *puReturned, + [out,ref] uint32 *pSize, +// [out,ref] WBEMDATA0 **pData + [out,ref,noprint,size_is(,*pSize)] uint8 **pData + ); +} + +[ + object, + uuid("1c1c45ee-4395-11d2-b60b-00104b703efd"), + pointer_default(unique) +] interface IWbemFetchSmartEnum : IUnknown +{ + WERROR Fetch( + [out] IWbemWCOSmartEnum** ppEnum + ); + WERROR Test( + [out] WbemClassObject** ppEnum + ); +} + +[ + object, +// restricted, + uuid(44aca675-e8fc-11d0-a07c-00c04fb68820) +] interface IWbemCallResult : IUnknown +{ + WERROR GetResultObject( + [in] long lTimeout, + [out] IUnknown** ppResultObject +// [out] IWbemClassObject** ppResultObject + ); + + WERROR GetResultString( + [in] long lTimeout +// [out] BSTR* pstrResultString + ); + + WERROR GetResultServices( + [in] long lTimeout, + [out] IWbemServices** ppServices + ); + + WERROR GetCallStatus( + [in] long lTimeout, + [out] long* plStatus + ); +} + diff --git a/source4/librpc/scripts/build_idl.sh b/source4/librpc/scripts/build_idl.sh index 3f13b64a2e..5b2d09f654 100755 --- a/source4/librpc/scripts/build_idl.sh +++ b/source4/librpc/scripts/build_idl.sh @@ -8,7 +8,7 @@ PIDL_EXTRA_ARGS="$*" [ -d $OUTDIR ] || mkdir -p $OUTDIR || exit 1 -PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --python $PIDL_EXTRA_ARGS" +PIDL="$PIDL --outputdir $OUTDIR --header --ndr-parser --server --client --swig --python --dcom-proxy --com-header $PIDL_EXTRA_ARGS" if [ x$FULLBUILD = xFULL ]; then echo Rebuilding all idl files in $IDLDIR diff --git a/source4/main.mk b/source4/main.mk index 28db54c10f..017c58786a 100644 --- a/source4/main.mk +++ b/source4/main.mk @@ -26,6 +26,9 @@ mkinclude lib/dbwrap/config.mk mkinclude lib/crypto/config.mk mkinclude lib/torture/config.mk mkinclude lib/basic.mk +mkinclude lib/com/config.mk +# WMI fails at the moment +mkinclude lib/wmi/config.mk mkinclude param/config.mk mkinclude smb_server/config.mk mkinclude rpc_server/config.mk diff --git a/source4/pidl/TODO b/source4/pidl/TODO index bc5c49a46f..8886441a75 100644 --- a/source4/pidl/TODO +++ b/source4/pidl/TODO @@ -1,3 +1,8 @@ +- warn when union instances don't have a discriminant + +- EJS output backend shouldn't use the NDR levels stuff but instead + as the "C levels" and NDR levels don't necessarily match. + - true multiple dimension array / strings in arrays support - compatibility mode for generating MIDL-readable data: diff --git a/source4/pidl/idl.yp b/source4/pidl/idl.yp index a0323af8ee..8589982a2c 100644 --- a/source4/pidl/idl.yp +++ b/source4/pidl/idl.yp @@ -67,17 +67,24 @@ interface_names: | interface_names 'interface' identifier ';' { push(@{$_[1]}, $_[2]); $_[1] } ; -interface: property_list 'interface' identifier '{' definitions '}' optional_semicolon +interface: property_list 'interface' identifier base_interface '{' definitions '}' optional_semicolon {{ "TYPE" => "INTERFACE", "PROPERTIES" => $_[1], "NAME" => $_[3], - "DATA" => $_[5], + "BASE" => $_[4], + "DATA" => $_[6], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ; +base_interface: + #empty + | ':' identifier { $_[2] } +; + + cpp_quote: 'cpp_quote' '(' text ')' {{ "TYPE" => "CPP_QUOTE", diff --git a/source4/pidl/lib/Parse/Pidl/IDL.pm b/source4/pidl/lib/Parse/Pidl/IDL.pm index 4adb4dcea8..06d54fb4b5 100644 --- a/source4/pidl/lib/Parse/Pidl/IDL.pm +++ b/source4/pidl/lib/Parse/Pidl/IDL.pm @@ -38,7 +38,7 @@ sub new { "import" => 7, "include" => 13 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { 'cpp_quote' => 11, 'importlib' => 10, @@ -124,7 +124,7 @@ sub new { } }, {#State 16 - DEFAULT => -114 + DEFAULT => -116 }, {#State 17 DEFAULT => -11 @@ -184,7 +184,7 @@ sub new { } }, {#State 26 - DEFAULT => -110 + DEFAULT => -112 }, {#State 27 ACTIONS => { @@ -193,23 +193,27 @@ sub new { }, {#State 28 ACTIONS => { - "{" => 37 + ":" => 37 + }, + DEFAULT => -17, + GOTOS => { + 'base_interface' => 38 } }, {#State 29 ACTIONS => { - "," => 38, - "]" => 39 + "," => 39, + "]" => 40 } }, {#State 30 ACTIONS => { - "(" => 40 + "(" => 41 }, - DEFAULT => -87 + DEFAULT => -89 }, {#State 31 - DEFAULT => -85 + DEFAULT => -87 }, {#State 32 DEFAULT => -8 @@ -218,7 +222,7 @@ sub new { DEFAULT => -9 }, {#State 34 - DEFAULT => -17 + DEFAULT => -19 }, {#State 35 DEFAULT => -12 @@ -226,1457 +230,1473 @@ sub new { {#State 36 DEFAULT => -14, GOTOS => { - 'interface_names' => 41 + 'interface_names' => 42 } }, {#State 37 ACTIONS => { - "const" => 51 + 'IDENTIFIER' => 26 }, - DEFAULT => -83, GOTOS => { - 'typedecl' => 42, - 'function' => 43, - 'definitions' => 45, - 'bitmap' => 44, - 'definition' => 48, - 'property_list' => 47, - 'usertype' => 46, - 'const' => 50, - 'struct' => 49, - 'typedef' => 53, - 'enum' => 52, - 'union' => 54 + 'identifier' => 43 } }, {#State 38 ACTIONS => { + "{" => 44 + } + }, + {#State 39 + ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { 'identifier' => 30, - 'property' => 55 + 'property' => 45 } }, - {#State 39 - DEFAULT => -84 - }, {#State 40 + DEFAULT => -86 + }, + {#State 41 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'text' => 61, - 'anytext' => 56, - 'constant' => 57, - 'commalisttext' => 59 + 'identifier' => 50, + 'text' => 51, + 'anytext' => 46, + 'constant' => 47, + 'commalisttext' => 49 } }, - {#State 41 + {#State 42 ACTIONS => { - "}" => 62, - "interface" => 63 + "}" => 52, + "interface" => 53 } }, - {#State 42 - DEFAULT => -23 - }, {#State 43 - DEFAULT => -20 + DEFAULT => -18 }, {#State 44 - DEFAULT => -31 - }, - {#State 45 ACTIONS => { - "}" => 64, - "const" => 51 + "const" => 63 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'typedecl' => 42, - 'function' => 43, - 'bitmap' => 44, - 'definition' => 65, - 'property_list' => 47, - 'usertype' => 46, - 'struct' => 49, - 'const' => 50, - 'typedef' => 53, - 'enum' => 52, - 'union' => 54 + 'typedecl' => 54, + 'function' => 55, + 'definitions' => 57, + 'bitmap' => 56, + 'definition' => 60, + 'property_list' => 59, + 'usertype' => 58, + 'const' => 62, + 'struct' => 61, + 'typedef' => 65, + 'enum' => 64, + 'union' => 66 } }, + {#State 45 + DEFAULT => -88 + }, {#State 46 ACTIONS => { - ";" => 66 - } + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 + }, + DEFAULT => -91 }, {#State 47 - ACTIONS => { - "typedef" => 67, - 'IDENTIFIER' => 26, - "signed" => 75, - "union" => 68, - "enum" => 77, - "bitmap" => 78, - 'void' => 69, - "unsigned" => 79, - "[" => 20, - "struct" => 74 - }, - GOTOS => { - 'existingtype' => 76, - 'bitmap' => 44, - 'usertype' => 71, - 'property_list' => 70, - 'identifier' => 72, - 'struct' => 49, - 'enum' => 52, - 'type' => 80, - 'union' => 54, - 'sign' => 73 - } + DEFAULT => -95 }, {#State 48 - DEFAULT => -18 + DEFAULT => -115 }, {#State 49 - DEFAULT => -28 + ACTIONS => { + "," => 82, + ")" => 83 + } }, {#State 50 - DEFAULT => -21 + DEFAULT => -94 }, {#State 51 + DEFAULT => -96 + }, + {#State 52 ACTIONS => { - 'IDENTIFIER' => 26 + ";" => 85 }, + DEFAULT => -117, GOTOS => { - 'identifier' => 81 + 'optional_semicolon' => 84 } }, - {#State 52 - DEFAULT => -30 - }, {#State 53 - DEFAULT => -22 + ACTIONS => { + 'IDENTIFIER' => 26 + }, + GOTOS => { + 'identifier' => 86 + } }, {#State 54 - DEFAULT => -29 + DEFAULT => -25 }, {#State 55 - DEFAULT => -86 + DEFAULT => -22 }, {#State 56 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -89 + DEFAULT => -33 }, {#State 57 - DEFAULT => -93 + ACTIONS => { + "}" => 87, + "const" => 63 + }, + DEFAULT => -85, + GOTOS => { + 'typedecl' => 54, + 'function' => 55, + 'bitmap' => 56, + 'definition' => 88, + 'property_list' => 59, + 'usertype' => 58, + 'struct' => 61, + 'const' => 62, + 'typedef' => 65, + 'enum' => 64, + 'union' => 66 + } }, {#State 58 - DEFAULT => -113 + ACTIONS => { + ";" => 89 + } }, {#State 59 ACTIONS => { - "," => 97, - ")" => 98 + "typedef" => 90, + 'IDENTIFIER' => 26, + "signed" => 98, + "union" => 91, + "enum" => 100, + "bitmap" => 101, + 'void' => 92, + "unsigned" => 102, + "[" => 20, + "struct" => 97 + }, + GOTOS => { + 'existingtype' => 99, + 'bitmap' => 56, + 'usertype' => 94, + 'property_list' => 93, + 'identifier' => 95, + 'struct' => 61, + 'enum' => 64, + 'type' => 103, + 'union' => 66, + 'sign' => 96 } }, {#State 60 - DEFAULT => -92 + DEFAULT => -20 }, {#State 61 - DEFAULT => -94 + DEFAULT => -30 }, {#State 62 - ACTIONS => { - ";" => 99 - }, - DEFAULT => -115, - GOTOS => { - 'optional_semicolon' => 100 - } + DEFAULT => -23 }, {#State 63 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 101 + 'identifier' => 104 } }, {#State 64 - ACTIONS => { - ";" => 99 - }, - DEFAULT => -115, - GOTOS => { - 'optional_semicolon' => 102 - } + DEFAULT => -32 }, {#State 65 - DEFAULT => -19 + DEFAULT => -24 }, {#State 66 - DEFAULT => -32 + DEFAULT => -31 }, {#State 67 ACTIONS => { - 'IDENTIFIER' => 26, - "signed" => 75, - 'void' => 69, - "unsigned" => 79 - }, - DEFAULT => -83, - GOTOS => { - 'existingtype' => 76, - 'bitmap' => 44, - 'usertype' => 71, - 'property_list' => 70, - 'identifier' => 72, - 'struct' => 49, - 'enum' => 52, - 'type' => 103, - 'union' => 54, - 'sign' => 73 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 + }, + DEFAULT => -93, + GOTOS => { + 'identifier' => 50, + 'anytext' => 105, + 'text' => 51, + 'constant' => 47 } }, {#State 68 ACTIONS => { - 'IDENTIFIER' => 104 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 }, - DEFAULT => -112, + DEFAULT => -93, GOTOS => { - 'optional_identifier' => 105 + 'identifier' => 50, + 'anytext' => 106, + 'text' => 51, + 'constant' => 47 } }, {#State 69 - DEFAULT => -39 - }, - {#State 70 - ACTIONS => { - "union" => 68, - "enum" => 77, - "bitmap" => 78, - "[" => 20, - "struct" => 74 - } - }, - {#State 71 - DEFAULT => -37 - }, - {#State 72 - DEFAULT => -36 - }, - {#State 73 ACTIONS => { + 'CONSTANT' => 48, + 'TEXT' => 16, 'IDENTIFIER' => 26 }, + DEFAULT => -93, GOTOS => { - 'identifier' => 106 + 'identifier' => 50, + 'anytext' => 107, + 'text' => 51, + 'constant' => 47 } }, - {#State 74 + {#State 70 ACTIONS => { - 'IDENTIFIER' => 104 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 }, - DEFAULT => -112, + DEFAULT => -93, GOTOS => { - 'optional_identifier' => 107 + 'identifier' => 50, + 'anytext' => 108, + 'text' => 51, + 'constant' => 47 } }, - {#State 75 - DEFAULT => -33 - }, - {#State 76 - DEFAULT => -38 - }, - {#State 77 + {#State 71 ACTIONS => { - 'IDENTIFIER' => 104 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 }, - DEFAULT => -112, + DEFAULT => -93, GOTOS => { - 'optional_identifier' => 108 + 'identifier' => 50, + 'anytext' => 109, + 'text' => 51, + 'constant' => 47 } }, - {#State 78 + {#State 72 ACTIONS => { - 'IDENTIFIER' => 104 + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 }, - DEFAULT => -112, + DEFAULT => -93, GOTOS => { - 'optional_identifier' => 109 + 'identifier' => 50, + 'anytext' => 110, + 'text' => 51, + 'constant' => 47 } }, - {#State 79 - DEFAULT => -34 - }, - {#State 80 + {#State 73 ACTIONS => { + 'CONSTANT' => 48, + 'TEXT' => 16, 'IDENTIFIER' => 26 }, + DEFAULT => -93, GOTOS => { - 'identifier' => 110 - } - }, - {#State 81 - DEFAULT => -72, - GOTOS => { - 'pointers' => 111 + 'identifier' => 50, + 'anytext' => 46, + 'text' => 51, + 'constant' => 47, + 'commalisttext' => 111 } }, - {#State 82 + {#State 74 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 112, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 83 + {#State 75 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 113, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 84 + {#State 76 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 114, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 85 + {#State 77 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 115, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 46, + 'text' => 51, + 'constant' => 47, + 'commalisttext' => 115 } }, - {#State 86 + {#State 78 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 116, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 87 + {#State 79 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 117, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 88 + {#State 80 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 118, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 89 + {#State 81 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 56, - 'text' => 61, - 'constant' => 57, - 'commalisttext' => 119 + 'identifier' => 50, + 'anytext' => 119, + 'text' => 51, + 'constant' => 47 } }, - {#State 90 + {#State 82 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, + 'identifier' => 50, 'anytext' => 120, - 'text' => 61, - 'constant' => 57 + 'text' => 51, + 'constant' => 47 } }, - {#State 91 + {#State 83 + DEFAULT => -90 + }, + {#State 84 + DEFAULT => -13 + }, + {#State 85 + DEFAULT => -118 + }, + {#State 86 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 - }, - DEFAULT => -91, - GOTOS => { - 'identifier' => 60, - 'anytext' => 121, - 'text' => 61, - 'constant' => 57 + ";" => 121 } }, - {#State 92 + {#State 87 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + ";" => 85 }, - DEFAULT => -91, + DEFAULT => -117, GOTOS => { - 'identifier' => 60, - 'anytext' => 122, - 'text' => 61, - 'constant' => 57 + 'optional_semicolon' => 122 } }, - {#State 93 + {#State 88 + DEFAULT => -21 + }, + {#State 89 + DEFAULT => -34 + }, + {#State 90 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + 'IDENTIFIER' => 26, + "signed" => 98, + 'void' => 92, + "unsigned" => 102 }, - DEFAULT => -91, + DEFAULT => -85, GOTOS => { - 'identifier' => 60, - 'anytext' => 56, - 'text' => 61, - 'constant' => 57, - 'commalisttext' => 123 + 'existingtype' => 99, + 'bitmap' => 56, + 'usertype' => 94, + 'property_list' => 93, + 'identifier' => 95, + 'struct' => 61, + 'enum' => 64, + 'type' => 123, + 'union' => 66, + 'sign' => 96 } }, - {#State 94 + {#State 91 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + 'IDENTIFIER' => 124 }, - DEFAULT => -91, + DEFAULT => -114, GOTOS => { - 'identifier' => 60, - 'anytext' => 124, - 'text' => 61, - 'constant' => 57 + 'optional_identifier' => 125 } }, - {#State 95 + {#State 92 + DEFAULT => -41 + }, + {#State 93 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 - }, - DEFAULT => -91, - GOTOS => { - 'identifier' => 60, - 'anytext' => 125, - 'text' => 61, - 'constant' => 57 + "union" => 91, + "enum" => 100, + "bitmap" => 101, + "[" => 20, + "struct" => 97 } }, + {#State 94 + DEFAULT => -39 + }, + {#State 95 + DEFAULT => -38 + }, {#State 96 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, GOTOS => { - 'identifier' => 60, - 'anytext' => 126, - 'text' => 61, - 'constant' => 57 + 'identifier' => 126 } }, {#State 97 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + 'IDENTIFIER' => 124 }, - DEFAULT => -91, + DEFAULT => -114, GOTOS => { - 'identifier' => 60, - 'anytext' => 127, - 'text' => 61, - 'constant' => 57 + 'optional_identifier' => 127 } }, {#State 98 - DEFAULT => -88 + DEFAULT => -35 }, {#State 99 - DEFAULT => -116 + DEFAULT => -40 }, {#State 100 - DEFAULT => -13 + ACTIONS => { + 'IDENTIFIER' => 124 + }, + DEFAULT => -114, + GOTOS => { + 'optional_identifier' => 128 + } }, {#State 101 ACTIONS => { - ";" => 128 + 'IDENTIFIER' => 124 + }, + DEFAULT => -114, + GOTOS => { + 'optional_identifier' => 129 } }, {#State 102 - DEFAULT => -16 + DEFAULT => -36 }, {#State 103 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 129 + 'identifier' => 130 } }, {#State 104 - DEFAULT => -111 + DEFAULT => -74, + GOTOS => { + 'pointers' => 131 + } }, {#State 105 ACTIONS => { - "{" => 131 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -68, - GOTOS => { - 'union_body' => 132, - 'opt_union_body' => 130 - } + DEFAULT => -106 }, {#State 106 - DEFAULT => -35 + ACTIONS => { + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 + }, + DEFAULT => -97 }, {#State 107 ACTIONS => { - "{" => 134 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -58, - GOTOS => { - 'struct_body' => 133, - 'opt_struct_body' => 135 - } + DEFAULT => -105 }, {#State 108 ACTIONS => { - "{" => 136 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -41, - GOTOS => { - 'opt_enum_body' => 138, - 'enum_body' => 137 - } + DEFAULT => -101 }, {#State 109 ACTIONS => { - "{" => 140 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -49, - GOTOS => { - 'bitmap_body' => 141, - 'opt_bitmap_body' => 139 - } + DEFAULT => -109 }, {#State 110 ACTIONS => { - "(" => 142 - } + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 + }, + DEFAULT => -108 }, {#State 111 ACTIONS => { - 'IDENTIFIER' => 26, - "*" => 144 - }, - GOTOS => { - 'identifier' => 143 + "}" => 132, + "," => 82 } }, {#State 112 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -104 + DEFAULT => -103 }, {#State 113 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -95 + DEFAULT => -104 }, {#State 114 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -99 + DEFAULT => -107 }, {#State 115 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -107 + "," => 82, + ")" => 133 + } }, {#State 116 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -106 + DEFAULT => -102 }, {#State 117 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -97 + DEFAULT => -99 }, {#State 118 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 }, - DEFAULT => -103 + DEFAULT => -98 }, {#State 119 ACTIONS => { - "}" => 145, - "," => 97 - } + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 + }, + DEFAULT => -100 }, {#State 120 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 }, - DEFAULT => -101 + DEFAULT => -92 }, {#State 121 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -102 + DEFAULT => -15 }, {#State 122 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -105 + DEFAULT => -16 }, {#State 123 ACTIONS => { - "," => 97, - ")" => 146 + 'IDENTIFIER' => 26 + }, + GOTOS => { + 'identifier' => 134 } }, {#State 124 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -100 + DEFAULT => -113 }, {#State 125 ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 + "{" => 136 }, - DEFAULT => -96 + DEFAULT => -70, + GOTOS => { + 'union_body' => 137, + 'opt_union_body' => 135 + } }, {#State 126 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -98 + DEFAULT => -37 }, {#State 127 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 + "{" => 139 }, - DEFAULT => -90 + DEFAULT => -60, + GOTOS => { + 'struct_body' => 138, + 'opt_struct_body' => 140 + } }, {#State 128 - DEFAULT => -15 + ACTIONS => { + "{" => 141 + }, + DEFAULT => -43, + GOTOS => { + 'opt_enum_body' => 143, + 'enum_body' => 142 + } }, {#State 129 ACTIONS => { - "[" => 147 + "{" => 145 }, - DEFAULT => -80, + DEFAULT => -51, GOTOS => { - 'array_len' => 148 + 'bitmap_body' => 146, + 'opt_bitmap_body' => 144 } }, {#State 130 - DEFAULT => -70 + ACTIONS => { + "(" => 147 + } }, {#State 131 - DEFAULT => -65, + ACTIONS => { + 'IDENTIFIER' => 26, + "*" => 149 + }, GOTOS => { - 'union_elements' => 149 + 'identifier' => 148 } }, {#State 132 - DEFAULT => -69 + ACTIONS => { + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 + }, + DEFAULT => -93, + GOTOS => { + 'identifier' => 50, + 'anytext' => 150, + 'text' => 51, + 'constant' => 47 + } }, {#State 133 - DEFAULT => -59 + ACTIONS => { + 'CONSTANT' => 48, + 'TEXT' => 16, + 'IDENTIFIER' => 26 + }, + DEFAULT => -93, + GOTOS => { + 'identifier' => 50, + 'anytext' => 151, + 'text' => 51, + 'constant' => 47 + } }, {#State 134 - DEFAULT => -74, + ACTIONS => { + "[" => 152 + }, + DEFAULT => -82, GOTOS => { - 'element_list1' => 150 + 'array_len' => 153 } }, {#State 135 - DEFAULT => -60 + DEFAULT => -72 }, {#State 136 - ACTIONS => { - 'IDENTIFIER' => 26 - }, + DEFAULT => -67, GOTOS => { - 'identifier' => 151, - 'enum_element' => 152, - 'enum_elements' => 153 + 'union_elements' => 154 } }, {#State 137 - DEFAULT => -42 + DEFAULT => -71 }, {#State 138 - DEFAULT => -43 + DEFAULT => -61 }, {#State 139 - DEFAULT => -51 + DEFAULT => -76, + GOTOS => { + 'element_list1' => 155 + } }, {#State 140 + DEFAULT => -62 + }, + {#State 141 ACTIONS => { 'IDENTIFIER' => 26 }, - DEFAULT => -54, GOTOS => { 'identifier' => 156, - 'bitmap_element' => 155, - 'bitmap_elements' => 154, - 'opt_bitmap_elements' => 157 + 'enum_element' => 157, + 'enum_elements' => 158 } }, - {#State 141 - DEFAULT => -50 - }, {#State 142 - ACTIONS => { - "," => -76, - "void" => 161, - ")" => -76 - }, - DEFAULT => -83, - GOTOS => { - 'base_element' => 158, - 'element_list2' => 160, - 'property_list' => 159 - } + DEFAULT => -44 }, {#State 143 - ACTIONS => { - "[" => 147, - "=" => 163 - }, - GOTOS => { - 'array_len' => 162 - } + DEFAULT => -45 }, {#State 144 - DEFAULT => -73 + DEFAULT => -53 }, {#State 145 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -56, GOTOS => { - 'identifier' => 60, - 'anytext' => 164, - 'text' => 61, - 'constant' => 57 + 'identifier' => 161, + 'bitmap_element' => 160, + 'bitmap_elements' => 159, + 'opt_bitmap_elements' => 162 } }, {#State 146 + DEFAULT => -52 + }, + {#State 147 ACTIONS => { - 'CONSTANT' => 58, - 'TEXT' => 16, - 'IDENTIFIER' => 26 + "," => -78, + "void" => 166, + ")" => -78 }, - DEFAULT => -91, + DEFAULT => -85, GOTOS => { - 'identifier' => 60, - 'anytext' => 165, - 'text' => 61, - 'constant' => 57 + 'base_element' => 163, + 'element_list2' => 165, + 'property_list' => 164 } }, - {#State 147 + {#State 148 ACTIONS => { - 'CONSTANT' => 58, + "[" => 152, + "=" => 168 + }, + GOTOS => { + 'array_len' => 167 + } + }, + {#State 149 + DEFAULT => -75 + }, + {#State 150 + ACTIONS => { + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 + }, + DEFAULT => -111 + }, + {#State 151 + ACTIONS => { + ":" => 67, + "<" => 70, + "~" => 71, + "?" => 69, + "{" => 73, + "=" => 76 + }, + DEFAULT => -110 + }, + {#State 152 + ACTIONS => { + 'CONSTANT' => 48, 'TEXT' => 16, - "]" => 166, + "]" => 169, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 167, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 170, + 'text' => 51, + 'constant' => 47 } }, - {#State 148 + {#State 153 ACTIONS => { - ";" => 168 + ";" => 171 } }, - {#State 149 + {#State 154 ACTIONS => { - "}" => 169 + "}" => 172 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'optional_base_element' => 171, - 'property_list' => 170 + 'optional_base_element' => 174, + 'property_list' => 173 } }, - {#State 150 + {#State 155 ACTIONS => { - "}" => 172 + "}" => 175 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'base_element' => 173, - 'property_list' => 159 + 'base_element' => 176, + 'property_list' => 164 } }, - {#State 151 + {#State 156 ACTIONS => { - "=" => 174 + "=" => 177 }, - DEFAULT => -46 + DEFAULT => -48 }, - {#State 152 - DEFAULT => -44 + {#State 157 + DEFAULT => -46 }, - {#State 153 + {#State 158 ACTIONS => { - "}" => 175, - "," => 176 + "}" => 178, + "," => 179 } }, - {#State 154 + {#State 159 ACTIONS => { - "," => 177 + "," => 180 }, - DEFAULT => -55 + DEFAULT => -57 }, - {#State 155 - DEFAULT => -52 + {#State 160 + DEFAULT => -54 }, - {#State 156 + {#State 161 ACTIONS => { - "=" => 178 + "=" => 181 } }, - {#State 157 + {#State 162 ACTIONS => { - "}" => 179 + "}" => 182 } }, - {#State 158 - DEFAULT => -78 + {#State 163 + DEFAULT => -80 }, - {#State 159 + {#State 164 ACTIONS => { 'IDENTIFIER' => 26, - "signed" => 75, - 'void' => 69, - "unsigned" => 79, + "signed" => 98, + 'void' => 92, + "unsigned" => 102, "[" => 20 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'existingtype' => 76, - 'bitmap' => 44, - 'usertype' => 71, - 'property_list' => 70, - 'identifier' => 72, - 'struct' => 49, - 'enum' => 52, - 'type' => 180, - 'union' => 54, - 'sign' => 73 + 'existingtype' => 99, + 'bitmap' => 56, + 'usertype' => 94, + 'property_list' => 93, + 'identifier' => 95, + 'struct' => 61, + 'enum' => 64, + 'type' => 183, + 'union' => 66, + 'sign' => 96 } }, - {#State 160 + {#State 165 ACTIONS => { - "," => 181, - ")" => 182 + "," => 184, + ")" => 185 } }, - {#State 161 - DEFAULT => -77 + {#State 166 + DEFAULT => -79 }, - {#State 162 + {#State 167 ACTIONS => { - "=" => 183 + "=" => 186 } }, - {#State 163 + {#State 168 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 184, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 187, + 'text' => 51, + 'constant' => 47 } }, - {#State 164 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -109 - }, - {#State 165 - ACTIONS => { - ":" => 82, - "<" => 84, - "~" => 85, - "?" => 88, - "{" => 89, - "=" => 92 - }, - DEFAULT => -108 - }, - {#State 166 + {#State 169 ACTIONS => { - "[" => 147 + "[" => 152 }, - DEFAULT => -80, + DEFAULT => -82, GOTOS => { - 'array_len' => 185 + 'array_len' => 188 } }, - {#State 167 + {#State 170 ACTIONS => { - "-" => 83, - ":" => 82, - "?" => 88, - "<" => 84, - "+" => 86, - "~" => 85, - "&" => 90, - "{" => 89, - "/" => 91, - "=" => 92, - "|" => 94, - "(" => 93, - "*" => 87, - "." => 95, - "]" => 186, - ">" => 96 + "-" => 68, + ":" => 67, + "?" => 69, + "<" => 70, + "+" => 72, + "~" => 71, + "&" => 74, + "{" => 73, + "/" => 75, + "=" => 76, + "|" => 78, + "(" => 77, + "*" => 79, + "." => 80, + "]" => 189, + ">" => 81 } }, - {#State 168 - DEFAULT => -27 + {#State 171 + DEFAULT => -29 }, - {#State 169 - DEFAULT => -67 + {#State 172 + DEFAULT => -69 }, - {#State 170 + {#State 173 ACTIONS => { "[" => 20 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'base_or_empty' => 187, - 'base_element' => 188, - 'empty_element' => 189, - 'property_list' => 190 + 'base_or_empty' => 190, + 'base_element' => 191, + 'empty_element' => 192, + 'property_list' => 193 } }, - {#State 171 - DEFAULT => -66 + {#State 174 + DEFAULT => -68 }, - {#State 172 - DEFAULT => -57 + {#State 175 + DEFAULT => -59 }, - {#State 173 + {#State 176 ACTIONS => { - ";" => 191 + ";" => 194 } }, - {#State 174 + {#State 177 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 192, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 195, + 'text' => 51, + 'constant' => 47 } }, - {#State 175 - DEFAULT => -40 + {#State 178 + DEFAULT => -42 }, - {#State 176 + {#State 179 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 151, - 'enum_element' => 193 + 'identifier' => 156, + 'enum_element' => 196 } }, - {#State 177 + {#State 180 ACTIONS => { 'IDENTIFIER' => 26 }, GOTOS => { - 'identifier' => 156, - 'bitmap_element' => 194 + 'identifier' => 161, + 'bitmap_element' => 197 } }, - {#State 178 + {#State 181 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 195, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 198, + 'text' => 51, + 'constant' => 47 } }, - {#State 179 - DEFAULT => -48 + {#State 182 + DEFAULT => -50 }, - {#State 180 - DEFAULT => -72, + {#State 183 + DEFAULT => -74, GOTOS => { - 'pointers' => 196 + 'pointers' => 199 } }, - {#State 181 - DEFAULT => -83, + {#State 184 + DEFAULT => -85, GOTOS => { - 'base_element' => 197, - 'property_list' => 159 + 'base_element' => 200, + 'property_list' => 164 } }, - {#State 182 + {#State 185 ACTIONS => { - ";" => 198 + ";" => 201 } }, - {#State 183 + {#State 186 ACTIONS => { - 'CONSTANT' => 58, + 'CONSTANT' => 48, 'TEXT' => 16, 'IDENTIFIER' => 26 }, - DEFAULT => -91, + DEFAULT => -93, GOTOS => { - 'identifier' => 60, - 'anytext' => 199, - 'text' => 61, - 'constant' => 57 + 'identifier' => 50, + 'anytext' => 202, + 'text' => 51, + 'constant' => 47 } }, - {#State 184 + {#State 187 ACTIONS => { - "-" => 83, - ":" => 82, - "?" => 88, - "<" => 84, - ";" => 200, - "+" => 86, - "~" => 85, - "&" => 90, - "{" => 89, - "/" => 91, - "=" => 92, - "|" => 94, - "(" => 93, - "*" => 87, - "." => 95, - ">" => 96 + "-" => 68, + ":" => 67, + "?" => 69, + "<" => 70, + ";" => 203, + "+" => 72, + "~" => 71, + "&" => 74, + "{" => 73, + "/" => 75, + "=" => 76, + "|" => 78, + "(" => 77, + "*" => 79, + "." => 80, + ">" => 81 } }, - {#State 185 - DEFAULT => -81 + {#State 188 + DEFAULT => -83 }, - {#State 186 + {#State 189 ACTIONS => { - "[" => 147 + "[" => 152 }, - DEFAULT => -80, + DEFAULT => -82, GOTOS => { - 'array_len' => 201 + 'array_len' => 204 } }, - {#State 187 - DEFAULT => -64 + {#State 190 + DEFAULT => -66 }, - {#State 188 + {#State 191 ACTIONS => { - ";" => 202 + ";" => 205 } }, - {#State 189 - DEFAULT => -63 + {#State 192 + DEFAULT => -65 }, - {#State 190 + {#State 193 ACTIONS => { 'IDENTIFIER' => 26, - "signed" => 75, - ";" => 203, - 'void' => 69, - "unsigned" => 79, + "signed" => 98, + ";" => 206, + 'void' => 92, + "unsigned" => 102, "[" => 20 }, - DEFAULT => -83, + DEFAULT => -85, GOTOS => { - 'existingtype' => 76, - 'bitmap' => 44, - 'usertype' => 71, - 'property_list' => 70, - 'identifier' => 72, - 'struct' => 49, - 'enum' => 52, - 'type' => 180, - 'union' => 54, - 'sign' => 73 + 'existingtype' => 99, + 'bitmap' => 56, + 'usertype' => 94, + 'property_list' => 93, + 'identifier' => 95, + 'struct' => 61, + 'enum' => 64, + 'type' => 183, + 'union' => 66, + 'sign' => 96 } }, - {#State 191 - DEFAULT => -75 - }, - {#State 192 - ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -47 - }, - {#State 193 - DEFAULT => -45 - }, {#State 194 - DEFAULT => -53 + DEFAULT => -77 }, {#State 195 ACTIONS => { - "-" => 83, - ":" => 82, - "<" => 84, - "+" => 86, - "~" => 85, - "*" => 87, - "?" => 88, - "{" => 89, - "&" => 90, - "/" => 91, - "=" => 92, - "(" => 93, - "|" => 94, - "." => 95, - ">" => 96 - }, - DEFAULT => -56 + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 + }, + DEFAULT => -49 }, {#State 196 - ACTIONS => { - 'IDENTIFIER' => 26, - "*" => 144 - }, - GOTOS => { - 'identifier' => 204 - } + DEFAULT => -47 }, {#State 197 - DEFAULT => -79 + DEFAULT => -55 }, {#State 198 - DEFAULT => -26 + ACTIONS => { + "-" => 68, + ":" => 67, + "<" => 70, + "+" => 72, + "~" => 71, + "*" => 79, + "?" => 69, + "{" => 73, + "&" => 74, + "/" => 75, + "=" => 76, + "(" => 77, + "|" => 78, + "." => 80, + ">" => 81 + }, + DEFAULT => -58 }, {#State 199 ACTIONS => { - "-" => 83, - ":" => 82, - "?" => 88, - "<" => 84, - ";" => 205, - "+" => 86, - "~" => 85, - "&" => 90, - "{" => 89, - "/" => 91, - "=" => 92, - "|" => 94, - "(" => 93, - "*" => 87, - "." => 95, - ">" => 96 + 'IDENTIFIER' => 26, + "*" => 149 + }, + GOTOS => { + 'identifier' => 207 } }, {#State 200 - DEFAULT => -24 + DEFAULT => -81 }, {#State 201 - DEFAULT => -82 + DEFAULT => -28 }, {#State 202 - DEFAULT => -62 + ACTIONS => { + "-" => 68, + ":" => 67, + "?" => 69, + "<" => 70, + ";" => 208, + "+" => 72, + "~" => 71, + "&" => 74, + "{" => 73, + "/" => 75, + "=" => 76, + "|" => 78, + "(" => 77, + "*" => 79, + "." => 80, + ">" => 81 + } }, {#State 203 - DEFAULT => -61 + DEFAULT => -26 }, {#State 204 + DEFAULT => -84 + }, + {#State 205 + DEFAULT => -64 + }, + {#State 206 + DEFAULT => -63 + }, + {#State 207 ACTIONS => { - "[" => 147 + "[" => 152 }, - DEFAULT => -80, + DEFAULT => -82, GOTOS => { - 'array_len' => 206 + 'array_len' => 209 } }, - {#State 205 - DEFAULT => -25 + {#State 208 + DEFAULT => -27 }, - {#State 206 - DEFAULT => -71 + {#State 209 + DEFAULT => -73 } ], yyrules => @@ -1791,22 +1811,32 @@ sub { push(@{$_[1]}, $_[2]); $_[1] } ], [#Rule 16 - 'interface', 7, + 'interface', 8, sub #line 71 "pidl/idl.yp" {{ "TYPE" => "INTERFACE", "PROPERTIES" => $_[1], "NAME" => $_[3], - "DATA" => $_[5], + "BASE" => $_[4], + "DATA" => $_[6], "FILE" => $_[0]->YYData->{FILE}, "LINE" => $_[0]->YYData->{LINE}, }} ], [#Rule 17 + 'base_interface', 0, undef + ], + [#Rule 18 + 'base_interface', 2, +sub +#line 84 "pidl/idl.yp" +{ $_[2] } + ], + [#Rule 19 'cpp_quote', 4, sub -#line 82 "pidl/idl.yp" +#line 89 "pidl/idl.yp" {{ "TYPE" => "CPP_QUOTE", "FILE" => $_[0]->YYData->{FILE}, @@ -1814,34 +1844,34 @@ sub "DATA" => $_[3] }} ], - [#Rule 18 + [#Rule 20 'definitions', 1, sub -#line 91 "pidl/idl.yp" +#line 98 "pidl/idl.yp" { [ $_[1] ] } ], - [#Rule 19 + [#Rule 21 'definitions', 2, sub -#line 92 "pidl/idl.yp" +#line 99 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], - [#Rule 20 + [#Rule 22 'definition', 1, undef ], - [#Rule 21 + [#Rule 23 'definition', 1, undef ], - [#Rule 22 + [#Rule 24 'definition', 1, undef ], - [#Rule 23 + [#Rule 25 'definition', 1, undef ], - [#Rule 24 + [#Rule 26 'const', 7, sub -#line 100 "pidl/idl.yp" +#line 107 "pidl/idl.yp" {{ "TYPE" => "CONST", "DTYPE" => $_[2], @@ -1852,10 +1882,10 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 25 + [#Rule 27 'const', 8, sub -#line 110 "pidl/idl.yp" +#line 117 "pidl/idl.yp" {{ "TYPE" => "CONST", "DTYPE" => $_[2], @@ -1867,10 +1897,10 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 26 + [#Rule 28 'function', 7, sub -#line 124 "pidl/idl.yp" +#line 131 "pidl/idl.yp" {{ "TYPE" => "FUNCTION", "NAME" => $_[3], @@ -1881,10 +1911,10 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 27 + [#Rule 29 'typedef', 6, sub -#line 136 "pidl/idl.yp" +#line 143 "pidl/idl.yp" {{ "TYPE" => "TYPEDEF", "PROPERTIES" => $_[1], @@ -1895,67 +1925,67 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 28 + [#Rule 30 'usertype', 1, undef ], - [#Rule 29 + [#Rule 31 'usertype', 1, undef ], - [#Rule 30 + [#Rule 32 'usertype', 1, undef ], - [#Rule 31 + [#Rule 33 'usertype', 1, undef ], - [#Rule 32 + [#Rule 34 'typedecl', 2, sub -#line 149 "pidl/idl.yp" +#line 156 "pidl/idl.yp" { $_[1] } ], - [#Rule 33 + [#Rule 35 'sign', 1, undef ], - [#Rule 34 + [#Rule 36 'sign', 1, undef ], - [#Rule 35 + [#Rule 37 'existingtype', 2, sub -#line 154 "pidl/idl.yp" +#line 161 "pidl/idl.yp" { ($_[1]?$_[1]:"signed") ." $_[2]" } ], - [#Rule 36 + [#Rule 38 'existingtype', 1, undef ], - [#Rule 37 + [#Rule 39 'type', 1, undef ], - [#Rule 38 + [#Rule 40 'type', 1, undef ], - [#Rule 39 + [#Rule 41 'type', 1, sub -#line 158 "pidl/idl.yp" +#line 165 "pidl/idl.yp" { "void" } ], - [#Rule 40 + [#Rule 42 'enum_body', 3, sub -#line 160 "pidl/idl.yp" +#line 167 "pidl/idl.yp" { $_[2] } ], - [#Rule 41 + [#Rule 43 'opt_enum_body', 0, undef ], - [#Rule 42 + [#Rule 44 'opt_enum_body', 1, undef ], - [#Rule 43 + [#Rule 45 'enum', 4, sub -#line 163 "pidl/idl.yp" +#line 170 "pidl/idl.yp" {{ "TYPE" => "ENUM", "PROPERTIES" => $_[1], @@ -1963,43 +1993,43 @@ sub "ELEMENTS" => $_[4] }} ], - [#Rule 44 + [#Rule 46 'enum_elements', 1, sub -#line 172 "pidl/idl.yp" +#line 179 "pidl/idl.yp" { [ $_[1] ] } ], - [#Rule 45 + [#Rule 47 'enum_elements', 3, sub -#line 173 "pidl/idl.yp" +#line 180 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 46 + [#Rule 48 'enum_element', 1, undef ], - [#Rule 47 + [#Rule 49 'enum_element', 3, sub -#line 177 "pidl/idl.yp" +#line 184 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], - [#Rule 48 + [#Rule 50 'bitmap_body', 3, sub -#line 180 "pidl/idl.yp" +#line 187 "pidl/idl.yp" { $_[2] } ], - [#Rule 49 + [#Rule 51 'opt_bitmap_body', 0, undef ], - [#Rule 50 + [#Rule 52 'opt_bitmap_body', 1, undef ], - [#Rule 51 + [#Rule 53 'bitmap', 4, sub -#line 183 "pidl/idl.yp" +#line 190 "pidl/idl.yp" {{ "TYPE" => "BITMAP", "PROPERTIES" => $_[1], @@ -2007,46 +2037,46 @@ sub "ELEMENTS" => $_[4] }} ], - [#Rule 52 + [#Rule 54 'bitmap_elements', 1, sub -#line 192 "pidl/idl.yp" +#line 199 "pidl/idl.yp" { [ $_[1] ] } ], - [#Rule 53 + [#Rule 55 'bitmap_elements', 3, sub -#line 193 "pidl/idl.yp" +#line 200 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 54 + [#Rule 56 'opt_bitmap_elements', 0, undef ], - [#Rule 55 + [#Rule 57 'opt_bitmap_elements', 1, undef ], - [#Rule 56 + [#Rule 58 'bitmap_element', 3, sub -#line 198 "pidl/idl.yp" +#line 205 "pidl/idl.yp" { "$_[1] ( $_[3] )" } ], - [#Rule 57 + [#Rule 59 'struct_body', 3, sub -#line 201 "pidl/idl.yp" +#line 208 "pidl/idl.yp" { $_[2] } ], - [#Rule 58 + [#Rule 60 'opt_struct_body', 0, undef ], - [#Rule 59 + [#Rule 61 'opt_struct_body', 1, undef ], - [#Rule 60 + [#Rule 62 'struct', 4, sub -#line 205 "pidl/idl.yp" +#line 212 "pidl/idl.yp" {{ "TYPE" => "STRUCT", "PROPERTIES" => $_[1], @@ -2054,10 +2084,10 @@ sub "ELEMENTS" => $_[4] }} ], - [#Rule 61 + [#Rule 63 'empty_element', 2, sub -#line 214 "pidl/idl.yp" +#line 221 "pidl/idl.yp" {{ "NAME" => "", "TYPE" => "EMPTY", @@ -2068,43 +2098,43 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 62 + [#Rule 64 'base_or_empty', 2, undef ], - [#Rule 63 + [#Rule 65 'base_or_empty', 1, undef ], - [#Rule 64 + [#Rule 66 'optional_base_element', 2, sub -#line 228 "pidl/idl.yp" +#line 235 "pidl/idl.yp" { $_[2]->{PROPERTIES} = FlattenHash([$_[1],$_[2]->{PROPERTIES}]); $_[2] } ], - [#Rule 65 + [#Rule 67 'union_elements', 0, undef ], - [#Rule 66 + [#Rule 68 'union_elements', 2, sub -#line 233 "pidl/idl.yp" +#line 240 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], - [#Rule 67 + [#Rule 69 'union_body', 3, sub -#line 236 "pidl/idl.yp" +#line 243 "pidl/idl.yp" { $_[2] } ], - [#Rule 68 + [#Rule 70 'opt_union_body', 0, undef ], - [#Rule 69 + [#Rule 71 'opt_union_body', 1, undef ], - [#Rule 70 + [#Rule 72 'union', 4, sub -#line 240 "pidl/idl.yp" +#line 247 "pidl/idl.yp" {{ "TYPE" => "UNION", "PROPERTIES" => $_[1], @@ -2112,10 +2142,10 @@ sub "ELEMENTS" => $_[4] }} ], - [#Rule 71 + [#Rule 73 'base_element', 5, sub -#line 249 "pidl/idl.yp" +#line 256 "pidl/idl.yp" {{ "NAME" => $_[4], "TYPE" => $_[2], @@ -2126,232 +2156,232 @@ sub "LINE" => $_[0]->YYData->{LINE}, }} ], - [#Rule 72 + [#Rule 74 'pointers', 0, sub -#line 263 "pidl/idl.yp" +#line 270 "pidl/idl.yp" { 0 } ], - [#Rule 73 + [#Rule 75 'pointers', 2, sub -#line 264 "pidl/idl.yp" +#line 271 "pidl/idl.yp" { $_[1]+1 } ], - [#Rule 74 + [#Rule 76 'element_list1', 0, sub -#line 268 "pidl/idl.yp" +#line 275 "pidl/idl.yp" { [] } ], - [#Rule 75 + [#Rule 77 'element_list1', 3, sub -#line 269 "pidl/idl.yp" +#line 276 "pidl/idl.yp" { push(@{$_[1]}, $_[2]); $_[1] } ], - [#Rule 76 + [#Rule 78 'element_list2', 0, undef ], - [#Rule 77 + [#Rule 79 'element_list2', 1, undef ], - [#Rule 78 + [#Rule 80 'element_list2', 1, sub -#line 275 "pidl/idl.yp" +#line 282 "pidl/idl.yp" { [ $_[1] ] } ], - [#Rule 79 + [#Rule 81 'element_list2', 3, sub -#line 276 "pidl/idl.yp" +#line 283 "pidl/idl.yp" { push(@{$_[1]}, $_[3]); $_[1] } ], - [#Rule 80 + [#Rule 82 'array_len', 0, undef ], - [#Rule 81 + [#Rule 83 'array_len', 3, sub -#line 281 "pidl/idl.yp" +#line 288 "pidl/idl.yp" { push(@{$_[3]}, "*"); $_[3] } ], - [#Rule 82 + [#Rule 84 'array_len', 4, sub -#line 282 "pidl/idl.yp" +#line 289 "pidl/idl.yp" { push(@{$_[4]}, "$_[2]"); $_[4] } ], - [#Rule 83 + [#Rule 85 'property_list', 0, undef ], - [#Rule 84 + [#Rule 86 'property_list', 4, sub -#line 288 "pidl/idl.yp" +#line 295 "pidl/idl.yp" { FlattenHash([$_[1],$_[3]]); } ], - [#Rule 85 + [#Rule 87 'properties', 1, sub -#line 291 "pidl/idl.yp" +#line 298 "pidl/idl.yp" { $_[1] } ], - [#Rule 86 + [#Rule 88 'properties', 3, sub -#line 292 "pidl/idl.yp" +#line 299 "pidl/idl.yp" { FlattenHash([$_[1], $_[3]]); } ], - [#Rule 87 + [#Rule 89 'property', 1, sub -#line 295 "pidl/idl.yp" +#line 302 "pidl/idl.yp" {{ "$_[1]" => "1" }} ], - [#Rule 88 + [#Rule 90 'property', 4, sub -#line 296 "pidl/idl.yp" +#line 303 "pidl/idl.yp" {{ "$_[1]" => "$_[3]" }} ], - [#Rule 89 + [#Rule 91 'commalisttext', 1, undef ], - [#Rule 90 + [#Rule 92 'commalisttext', 3, sub -#line 301 "pidl/idl.yp" +#line 308 "pidl/idl.yp" { "$_[1],$_[3]" } ], - [#Rule 91 + [#Rule 93 'anytext', 0, sub -#line 305 "pidl/idl.yp" +#line 312 "pidl/idl.yp" { "" } ], - [#Rule 92 - 'anytext', 1, undef - ], - [#Rule 93 - 'anytext', 1, undef - ], [#Rule 94 'anytext', 1, undef ], [#Rule 95 - 'anytext', 3, -sub -#line 307 "pidl/idl.yp" -{ "$_[1]$_[2]$_[3]" } + 'anytext', 1, undef ], [#Rule 96 - 'anytext', 3, -sub -#line 308 "pidl/idl.yp" -{ "$_[1]$_[2]$_[3]" } + 'anytext', 1, undef ], [#Rule 97 'anytext', 3, sub -#line 309 "pidl/idl.yp" +#line 314 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 98 'anytext', 3, sub -#line 310 "pidl/idl.yp" +#line 315 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 99 'anytext', 3, sub -#line 311 "pidl/idl.yp" +#line 316 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 100 'anytext', 3, sub -#line 312 "pidl/idl.yp" +#line 317 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 101 'anytext', 3, sub -#line 313 "pidl/idl.yp" +#line 318 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 102 'anytext', 3, sub -#line 314 "pidl/idl.yp" +#line 319 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 103 'anytext', 3, sub -#line 315 "pidl/idl.yp" +#line 320 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 104 'anytext', 3, sub -#line 316 "pidl/idl.yp" +#line 321 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 105 'anytext', 3, sub -#line 317 "pidl/idl.yp" +#line 322 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 106 'anytext', 3, sub -#line 318 "pidl/idl.yp" +#line 323 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 107 'anytext', 3, sub -#line 319 "pidl/idl.yp" +#line 324 "pidl/idl.yp" { "$_[1]$_[2]$_[3]" } ], [#Rule 108 + 'anytext', 3, +sub +#line 325 "pidl/idl.yp" +{ "$_[1]$_[2]$_[3]" } + ], + [#Rule 109 + 'anytext', 3, +sub +#line 326 "pidl/idl.yp" +{ "$_[1]$_[2]$_[3]" } + ], + [#Rule 110 'anytext', 5, sub -#line 320 "pidl/idl.yp" +#line 327 "pidl/idl.yp" { "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], - [#Rule 109 + [#Rule 111 'anytext', 5, sub -#line 321 "pidl/idl.yp" +#line 328 "pidl/idl.yp" { "$_[1]$_[2]$_[3]$_[4]$_[5]" } ], - [#Rule 110 + [#Rule 112 'identifier', 1, undef ], - [#Rule 111 + [#Rule 113 'optional_identifier', 1, undef ], - [#Rule 112 + [#Rule 114 'optional_identifier', 0, undef ], - [#Rule 113 + [#Rule 115 'constant', 1, undef ], - [#Rule 114 + [#Rule 116 'text', 1, sub -#line 335 "pidl/idl.yp" +#line 342 "pidl/idl.yp" { "\"$_[1]\"" } ], - [#Rule 115 + [#Rule 117 'optional_semicolon', 0, undef ], - [#Rule 116 + [#Rule 118 'optional_semicolon', 1, undef ] ], @@ -2359,7 +2389,7 @@ sub bless($self,$class); } -#line 346 "pidl/idl.yp" +#line 353 "pidl/idl.yp" use Parse::Pidl qw(error); diff --git a/source4/pidl/lib/Parse/Pidl/NDR.pm b/source4/pidl/lib/Parse/Pidl/NDR.pm index 10bd29715b..5eb5cbc195 100644 --- a/source4/pidl/lib/Parse/Pidl/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/NDR.pm @@ -876,6 +876,7 @@ my %property_list = ( "unique" => ["ELEMENT"], "ignore" => ["ELEMENT"], "relative" => ["ELEMENT"], + "null_is_ffffffff" => ["ELEMENT"], "relative_base" => ["TYPEDEF", "STRUCT", "UNION"], "gensize" => ["TYPEDEF", "STRUCT", "UNION"], @@ -1080,8 +1081,9 @@ sub ValidUnion($) ValidProperties($union,"UNION"); - if (has_property($union->{PARENT}, "nodiscriminant") and has_property($union->{PARENT}, "switch_type")) { - fatal($union->{PARENT}, $union->{PARENT}->{NAME} . ": switch_type() on union without discriminant"); + if (has_property($union->{PARENT}, "nodiscriminant") and + has_property($union->{PARENT}, "switch_type")) { + fatal($union->{PARENT}, $union->{PARENT}->{NAME} . ": switch_type(" . $union->{PARENT}->{PROPERTIES}->{switch_type} . ") on union without discriminant"); } return unless defined($union->{ELEMENTS}); @@ -1100,7 +1102,7 @@ sub ValidUnion($) } if (has_property($e, "ref")) { - fatal($e, el_name($e) . " : embedded ref pointers are not supported yet\n"); + fatal($e, el_name($e) . ": embedded ref pointers are not supported yet\n"); } diff --git a/source4/pidl/lib/Parse/Pidl/ODL.pm b/source4/pidl/lib/Parse/Pidl/ODL.pm new file mode 100644 index 0000000000..f6df34afa8 --- /dev/null +++ b/source4/pidl/lib/Parse/Pidl/ODL.pm @@ -0,0 +1,116 @@ +########################################## +# Converts ODL stuctures to IDL structures +# (C) 2004-2005, 2008 Jelmer Vernooij <jelmer@samba.org> + +package Parse::Pidl::ODL; + +use Parse::Pidl qw(error); +use Parse::Pidl::IDL; +use Parse::Pidl::Util qw(has_property unmake_str); +use Parse::Pidl::Typelist qw(hasType getType); +use strict; + +use vars qw($VERSION); +$VERSION = '0.01'; + +sub FunctionAddObjArgs($) +{ + my $e = shift; + + unshift(@{$e->{ELEMENTS}}, { + 'NAME' => 'ORPCthis', + 'POINTERS' => 0, + 'PROPERTIES' => { 'in' => '1' }, + 'TYPE' => 'ORPCTHIS', + 'FILE' => $e->{FILE}, + 'LINE' => $e->{LINE} + }); + unshift(@{$e->{ELEMENTS}}, { + 'NAME' => 'ORPCthat', + 'POINTERS' => 1, + 'PROPERTIES' => { 'out' => '1', 'ref' => '1' }, + 'TYPE' => 'ORPCTHAT', + 'FILE' => $e->{FILE}, + 'LINE' => $e->{LINE} + }); +} + +sub ReplaceInterfacePointers($) +{ + my $e = shift; + foreach my $x (@{$e->{ELEMENTS}}) { + next unless (hasType($x->{TYPE})); + next unless getType($x->{TYPE})->{DATA}->{TYPE} eq "INTERFACE"; + + $x->{TYPE} = "MInterfacePointer"; + } +} + +# Add ORPC specific bits to an interface. +sub ODL2IDL +{ + my ($odl, $basedir, $opt_incdirs) = (@_); + my $addedorpc = 0; + my $interfaces = {}; + + foreach my $x (@$odl) { + if ($x->{TYPE} eq "IMPORT") { + foreach my $idl_file (@{$x->{PATHS}}) { + $idl_file = unmake_str($idl_file); + my $podl = Parse::Pidl::IDL::parse_file("$basedir/$idl_file", $opt_incdirs); + if (defined(@$podl)) { + require Parse::Pidl::Typelist; + + Parse::Pidl::Typelist::LoadIdl($podl); + my $pidl = ODL2IDL($podl, $basedir, $opt_incdirs); + + foreach my $y (@$pidl) { + if ($y->{TYPE} eq "INTERFACE") { + $interfaces->{$y->{NAME}} = $y; + } + } + } else { + error($x, "Failed to parse $idl_file"); + } + } + } + + if ($x->{TYPE} eq "INTERFACE") { + $interfaces->{$x->{NAME}} = $x; + # Add [in] ORPCTHIS *this, [out] ORPCTHAT *that + # and replace interfacepointers with MInterfacePointer + # for 'object' interfaces + if (has_property($x, "object")) { + foreach my $e (@{$x->{DATA}}) { + ($e->{TYPE} eq "FUNCTION") && FunctionAddObjArgs($e); + ReplaceInterfacePointers($e); + } + $addedorpc = 1; + } + + if ($x->{BASE}) { + my $base = $interfaces->{$x->{BASE}}; + + unless (defined($base)) { + error($x, "Undefined base interface `$x->{BASE}'"); + } else { + foreach my $fn (reverse @{$base->{DATA}}) { + next unless ($fn->{TYPE} eq "FUNCTION"); + push (@{$x->{INHERITED_FUNCTIONS}}, $fn); + } + } + } + } + } + + unshift (@$odl, { + TYPE => "IMPORT", + PATHS => [ "\"orpc.idl\"" ], + FILE => undef, + LINE => undef + }) if ($addedorpc); + + return $odl; +} + +1; diff --git a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm index d2ab407eb0..2a23fad4a7 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba3/ClientNDR.pm @@ -13,9 +13,7 @@ use Exporter; use strict; use Parse::Pidl qw(fatal warning); -use Parse::Pidl::Typelist qw(hasType getType mapTypeName scalar_is_reference); -use Parse::Pidl::Util qw(has_property is_constant ParseExpr); -use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred); +use Parse::Pidl::Util qw(has_property ParseExpr); use Parse::Pidl::Samba4 qw(DeclLong); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv); diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm new file mode 100644 index 0000000000..996689b4b6 --- /dev/null +++ b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Header.pm @@ -0,0 +1,155 @@ +# COM Header generation +# (C) 2005 Jelmer Vernooij <jelmer@samba.org> + +package Parse::Pidl::Samba4::COM::Header; + +use Parse::Pidl::Typelist qw(mapTypeName); +use Parse::Pidl::Util qw(has_property is_constant); + +use vars qw($VERSION); +$VERSION = '0.01'; + +use strict; + +sub GetArgumentProtoList($) +{ + my $f = shift; + my $res = ""; + + foreach my $a (@{$f->{ELEMENTS}}) { + + $res .= ", " . mapTypeName($a->{TYPE}) . " "; + + my $l = $a->{POINTERS}; + $l-- if (Parse::Pidl::Typelist::scalar_is_reference($a->{TYPE})); + foreach my $i (1..$l) { + $res .= "*"; + } + + if (defined $a->{ARRAY_LEN}[0] && !is_constant($a->{ARRAY_LEN}[0]) && + !$a->{POINTERS}) { + $res .= "*"; + } + $res .= $a->{NAME}; + if (defined $a->{ARRAY_LEN}[0] && is_constant($a->{ARRAY_LEN}[0])) { + $res .= "[$a->{ARRAY_LEN}[0]]"; + } + } + + return $res; +} + +sub GetArgumentList($) +{ + my $f = shift; + my $res = ""; + + foreach (@{$f->{ELEMENTS}}) { $res .= ", $_->{NAME}"; } + + return $res; +} + +##################################################################### +# generate vtable structure for COM interface +sub HeaderVTable($) +{ + my $interface = shift; + my $res; + $res .= "#define " . uc($interface->{NAME}) . "_METHODS \\\n"; + if (defined($interface->{BASE})) { + $res .= "\t" . uc($interface->{BASE} . "_METHODS") . "\\\n"; + } + + my $data = $interface->{DATA}; + foreach my $d (@{$data}) { + $res .= "\t" . mapTypeName($d->{RETURN_TYPE}) . " (*$d->{NAME}) (struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . GetArgumentProtoList($d) . ");\\\n" if ($d->{TYPE} eq "FUNCTION"); + } + $res .= "\n"; + $res .= "struct $interface->{NAME}_vtable {\n"; + $res .= "\tstruct GUID iid;\n"; + $res .= "\t" . uc($interface->{NAME}) . "_METHODS\n"; + $res .= "};\n\n"; + + return $res; +} + +sub ParseInterface($) +{ + my $if = shift; + my $res; + + $res .= "\n#ifndef _$if->{NAME}_\n"; + $res .= "#define _$if->{NAME}_\n"; + + $res .="\n\n/* $if->{NAME} */\n"; + + $res .="#define COM_" . uc($if->{NAME}) . "_UUID $if->{PROPERTIES}->{uuid}\n\n"; + + $res .="struct $if->{NAME}_vtable;\n\n"; + + $res .="struct $if->{NAME} { + struct OBJREF obj; + struct com_context *ctx; + struct $if->{NAME}_vtable *vtable; + void *object_data; +};\n\n"; + + $res.=HeaderVTable($if); + + foreach my $d (@{$if->{DATA}}) { + next if ($d->{TYPE} ne "FUNCTION"); + + $res .= "#define $if->{NAME}_$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . ") "; + + $res .= "((interface)->vtable->$d->{NAME}(interface, mem_ctx" . GetArgumentList($d) . "))"; + + $res .="\n"; + } + + $res .= "#endif\n"; + + return $res; +} + +sub ParseCoClass($) +{ + my ($c) = @_; + my $res = ""; + $res .= "#define CLSID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{uuid}\n"; + if (has_property($c, "progid")) { + $res .= "#define PROGID_" . uc($c->{NAME}) . " $c->{PROPERTIES}->{progid}\n"; + } + $res .= "\n"; + return $res; +} + +sub Parse($$) +{ + my ($idl,$ndr_header) = @_; + my $res = ""; + + $res .= "#include \"librpc/gen_ndr/orpc.h\"\n" . + "#include \"$ndr_header\"\n\n"; + + foreach (@{$idl}) + { + if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) { + $res .="struct $_->{NAME};\n"; + } + } + + foreach (@{$idl}) + { + if ($_->{TYPE} eq "INTERFACE" && has_property($_, "object")) { + $res.=ParseInterface($_); + } + + if ($_->{TYPE} eq "COCLASS") { + $res.=ParseCoClass($_); + } + } + + return $res; +} + +1; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm new file mode 100644 index 0000000000..f7eb36f317 --- /dev/null +++ b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Proxy.pm @@ -0,0 +1,221 @@ +################################################### +# DCOM parser for Samba +# Basically the glue between COM and DCE/RPC with NDR +# Copyright jelmer@samba.org 2003-2005 +# released under the GNU GPL + +package Parse::Pidl::Samba4::COM::Proxy; + +use Parse::Pidl::Samba4::COM::Header; +use Parse::Pidl::Typelist qw(mapTypeName); +use Parse::Pidl::Util qw(has_property); + +use vars qw($VERSION); +$VERSION = '0.01'; + +use strict; + +my($res); + +sub ParseVTable($$) +{ + my ($interface, $name) = @_; + + # Generate the vtable + $res .="\tstruct $interface->{NAME}_vtable $name = {"; + + if (defined($interface->{BASE})) { + $res .= "\n\t\t{},"; + } + + my $data = $interface->{DATA}; + + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { + $res .= "\n\t\tdcom_proxy_$interface->{NAME}_$d->{NAME}"; + $res .= ","; + } + } + + $res .= "\n\t};\n\n"; +} + +sub ParseRegFunc($) +{ + my $interface = shift; + + $res .= "static NTSTATUS dcom_proxy_$interface->{NAME}_init(void) +{ + struct $interface->{NAME}_vtable *proxy_vtable = talloc(talloc_autofree_context(), struct $interface->{NAME}_vtable); +"; + + if (defined($interface->{BASE})) { + $res.= " + struct GUID base_iid; + const void *base_vtable; + + base_iid = ndr_table_$interface->{BASE}.syntax_id.uuid; + + base_vtable = dcom_proxy_vtable_by_iid(&base_iid); + if (base_vtable == NULL) { + DEBUG(0, (\"No proxy registered for base interface '$interface->{BASE}'\\n\")); + return NT_STATUS_FOOBAR; + } + + memcpy(&proxy_vtable, base_vtable, sizeof(struct $interface->{BASE}_vtable)); + +"; + } + foreach my $x (@{$interface->{DATA}}) { + next unless ($x->{TYPE} eq "FUNCTION"); + + $res .= "\tproxy_vtable->$x->{NAME} = dcom_proxy_$interface->{NAME}_$x->{NAME};\n"; + } + + $res.= " + proxy_vtable->iid = ndr_table_$interface->{NAME}.syntax_id.uuid; + + return dcom_register_proxy((struct IUnknown_vtable *)proxy_vtable); +}\n\n"; +} + +##################################################################### +# parse a function +sub ParseFunction($$) +{ + my ($interface, $fn) = @_; + my $name = $fn->{NAME}; + my $uname = uc $name; + + my $tn = mapTypeName($fn->{RETURN_TYPE}); + + $res.=" +static $tn dcom_proxy_$interface->{NAME}_$name(struct $interface->{NAME} *d, TALLOC_CTX *mem_ctx" . Parse::Pidl::Samba4::COM::Header::GetArgumentProtoList($fn) . ") +{ + struct dcerpc_pipe *p; + NTSTATUS status = dcom_get_pipe(d, &p); + struct $name r; + struct rpc_request *req; + + if (NT_STATUS_IS_ERR(status)) { + return status; + } + + ZERO_STRUCT(r.in.ORPCthis); + r.in.ORPCthis.version.MajorVersion = COM_MAJOR_VERSION; + r.in.ORPCthis.version.MinorVersion = COM_MINOR_VERSION; +"; + + # Put arguments into r + foreach my $a (@{$fn->{ELEMENTS}}) { + next unless (has_property($a, "in")); + if (Parse::Pidl::Typelist::typeIs($a->{TYPE}, "INTERFACE")) { + $res .="\tNDR_CHECK(dcom_OBJREF_from_IUnknown(&r.in.$a->{NAME}.obj, $a->{NAME}));\n"; + } else { + $res .= "\tr.in.$a->{NAME} = $a->{NAME};\n"; + } + } + + $res .=" + if (p->conn->flags & DCERPC_DEBUG_PRINT_IN) { + NDR_PRINT_IN_DEBUG($name, &r); + } + + status = dcerpc_ndr_request(p, &d->ipid, &ndr_table_$interface->{NAME}, NDR_$uname, mem_ctx, &r); + + if (NT_STATUS_IS_OK(status) && (p->conn->flags & DCERPC_DEBUG_PRINT_OUT)) { + NDR_PRINT_OUT_DEBUG($name, r); + } + +"; + + # Put r info back into arguments + foreach my $a (@{$fn->{ELEMENTS}}) { + next unless (has_property($a, "out")); + + if (Parse::Pidl::Typelist::typeIs($a->{TYPE}, "INTERFACE")) { + $res .="\tNDR_CHECK(dcom_IUnknown_from_OBJREF(d->ctx, &$a->{NAME}, r.out.$a->{NAME}.obj));\n"; + } else { + $res .= "\t*$a->{NAME} = r.out.$a->{NAME};\n"; + } + + } + + if ($fn->{RETURN_TYPE} eq "NTSTATUS") { + $res .= "\tif (NT_STATUS_IS_OK(status)) status = r.out.result;\n"; + } + + $res .= + " + return r.out.result; +}\n\n"; +} + +##################################################################### +# parse the interface definitions +sub ParseInterface($) +{ + my($interface) = shift; + my($data) = $interface->{DATA}; + $res = "/* DCOM proxy for $interface->{NAME} generated by pidl */\n\n"; + foreach my $d (@{$data}) { + ($d->{TYPE} eq "FUNCTION") && + ParseFunction($interface, $d); + } + + ParseRegFunc($interface); +} + +sub RegistrationFunction($$) +{ + my $idl = shift; + my $basename = shift; + + my $res = "\n\nNTSTATUS dcom_$basename\_init(void)\n"; + $res .= "{\n"; + $res .="\tNTSTATUS status = NT_STATUS_OK;\n"; + foreach my $interface (@{$idl}) { + next if $interface->{TYPE} ne "INTERFACE"; + next if not has_property($interface, "object"); + + my $data = $interface->{DATA}; + my $count = 0; + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { $count++; } + } + + next if ($count == 0); + + $res .= "\tstatus = dcom_$interface->{NAME}_init();\n"; + $res .= "\tif (NT_STATUS_IS_ERR(status)) {\n"; + $res .= "\t\treturn status;\n"; + $res .= "\t}\n\n"; + } + $res .= "\treturn status;\n"; + $res .= "}\n\n"; + + return $res; +} + +sub Parse($$) +{ + my ($pidl,$comh_filename) = @_; + my $res = ""; + + $res .= "#include \"includes.h\"\n" . + "#include \"lib/com/dcom/dcom.h\"\n" . + "#include \"$comh_filename\"\n" . + "#include \"librpc/rpc/dcerpc.h\"\n"; + + foreach (@{$pidl}) { + next if ($_->{TYPE} ne "INTERFACE"); + next if has_property($_, "local"); + next unless has_property($_, "object"); + + $res .= ParseInterface($_); + } + + return $res; +} + +1; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm new file mode 100644 index 0000000000..150acbfde9 --- /dev/null +++ b/source4/pidl/lib/Parse/Pidl/Samba4/COM/Stub.pm @@ -0,0 +1,327 @@ +################################################### +# DCOM stub boilerplate generator +# Copyright jelmer@samba.org 2004-2005 +# Copyright tridge@samba.org 2003 +# Copyright metze@samba.org 2004 +# released under the GNU GPL + +package Parse::Pidl::Samba4::COM::Stub; + +use Parse::Pidl::Util qw(has_property); +use strict; + +use vars qw($VERSION); +$VERSION = '0.01'; + +my($res); + +sub pidl($) +{ + $res .= shift; +} + +##################################################### +# generate the switch statement for function dispatch +sub gen_dispatch_switch($) +{ + my $data = shift; + + my $count = 0; + foreach my $d (@{$data}) { + next if ($d->{TYPE} ne "FUNCTION"); + + pidl "\tcase $count: {\n"; + if ($d->{RETURN_TYPE} && $d->{RETURN_TYPE} ne "void") { + pidl "\t\tNTSTATUS result;\n"; + } + pidl "\t\tstruct $d->{NAME} *r2 = r;\n"; + pidl "\t\tif (DEBUGLEVEL > 10) {\n"; + pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($d->{NAME}, NDR_IN, r2);\n"; + pidl "\t\t}\n"; + if ($d->{RETURN_TYPE} && $d->{RETURN_TYPE} ne "void") { + pidl "\t\tresult = vtable->$d->{NAME}(iface, mem_ctx, r2);\n"; + } else { + pidl "\t\tvtable->$d->{NAME}(iface, mem_ctx, r2);\n"; + } + pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n"; + pidl "\t\t\tDEBUG(5,(\"function $d->{NAME} will reply async\\n\"));\n"; + pidl "\t\t}\n"; + pidl "\t\tbreak;\n\t}\n"; + $count++; + } +} + +##################################################### +# generate the switch statement for function reply +sub gen_reply_switch($) +{ + my $data = shift; + + my $count = 0; + foreach my $d (@{$data}) { + next if ($d->{TYPE} ne "FUNCTION"); + + pidl "\tcase $count: {\n"; + pidl "\t\tstruct $d->{NAME} *r2 = r;\n"; + pidl "\t\tif (dce_call->state_flags & DCESRV_CALL_STATE_FLAG_ASYNC) {\n"; + pidl "\t\t\tDEBUG(5,(\"function $d->{NAME} replied async\\n\"));\n"; + pidl "\t\t}\n"; + pidl "\t\tif (DEBUGLEVEL > 10 && dce_call->fault_code == 0) {\n"; + pidl "\t\t\tNDR_PRINT_FUNCTION_DEBUG($d->{NAME}, NDR_OUT | NDR_SET_VALUES, r2);\n"; + pidl "\t\t}\n"; + pidl "\t\tif (dce_call->fault_code != 0) {\n"; + pidl "\t\t\tDEBUG(2,(\"dcerpc_fault %s in $d->{NAME}\\n\", dcerpc_errstr(mem_ctx, dce_call->fault_code)));\n"; + pidl "\t\t}\n"; + pidl "\t\tbreak;\n\t}\n"; + $count++; + } +} + +##################################################################### +# produce boilerplate code for a interface +sub Boilerplate_Iface($) +{ + my($interface) = shift; + my($data) = $interface->{DATA}; + my $name = $interface->{NAME}; + my $uname = uc $name; + my $uuid = Parse::Pidl::Util::make_str($interface->{PROPERTIES}->{uuid}); + my $if_version = $interface->{PROPERTIES}->{version}; + + pidl " +static NTSTATUS $name\__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface) +{ +#ifdef DCESRV_INTERFACE_$uname\_BIND + return DCESRV_INTERFACE_$uname\_BIND(dce_call,iface); +#else + return NT_STATUS_OK; +#endif +} + +static void $name\__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface) +{ +#ifdef DCESRV_INTERFACE_$uname\_UNBIND + DCESRV_INTERFACE_$uname\_UNBIND(context, iface); +#else + return; +#endif +} + +static NTSTATUS $name\__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r) +{ + NTSTATUS status; + uint16_t opnum = dce_call->pkt.u.request.opnum; + + dce_call->fault_code = 0; + + if (opnum >= dcerpc_table_$name.num_calls) { + dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NET_WRITE_FAULT; + } + + *r = talloc_size(mem_ctx, dcerpc_table_$name.calls[opnum].struct_size); + NT_STATUS_HAVE_NO_MEMORY(*r); + + /* unravel the NDR for the packet */ + status = dcerpc_table_$name.calls[opnum].ndr_pull(pull, NDR_IN, *r); + if (!NT_STATUS_IS_OK(status)) { + dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN, + &dce_call->pkt.u.request.stub_and_verifier); + dce_call->fault_code = DCERPC_FAULT_NDR; + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +static NTSTATUS $name\__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) +{ + uint16_t opnum = dce_call->pkt.u.request.opnum; + struct GUID ipid = dce_call->pkt.u.request.object.object; + struct dcom_interface_p *iface = dcom_get_local_iface_p(&ipid); + const struct dcom_$name\_vtable *vtable = iface->vtable; + + switch (opnum) { +"; + gen_dispatch_switch($data); + +pidl " + default: + dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR; + break; + } + + if (dce_call->fault_code != 0) { + dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN, + &dce_call->pkt.u.request.stub_and_verifier); + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +static NTSTATUS $name\__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) +{ + uint16_t opnum = dce_call->pkt.u.request.opnum; + + switch (opnum) { +"; + gen_reply_switch($data); + +pidl " + default: + dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR; + break; + } + + if (dce_call->fault_code != 0) { + dcerpc_log_packet(&dcerpc_table_$name, opnum, NDR_IN, + &dce_call->pkt.u.request.stub_and_verifier); + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +static NTSTATUS $name\__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r) +{ + NTSTATUS status; + uint16_t opnum = dce_call->pkt.u.request.opnum; + + status = dcerpc_table_$name.calls[opnum].ndr_push(push, NDR_OUT, r); + if (!NT_STATUS_IS_OK(status)) { + dce_call->fault_code = DCERPC_FAULT_NDR; + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +static const struct dcesrv_interface $name\_interface = { + .name = \"$name\", + .uuid = $uuid, + .if_version = $if_version, + .bind = $name\__op_bind, + .unbind = $name\__op_unbind, + .ndr_pull = $name\__op_ndr_pull, + .dispatch = $name\__op_dispatch, + .reply = $name\__op_reply, + .ndr_push = $name\__op_ndr_push +}; + +"; +} + +##################################################################### +# produce boilerplate code for an endpoint server +sub Boilerplate_Ep_Server($) +{ + my($interface) = shift; + my $name = $interface->{NAME}; + my $uname = uc $name; + + pidl " +static NTSTATUS $name\__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server) +{ + int i; + + for (i=0;i<dcerpc_table_$name.endpoints->count;i++) { + NTSTATUS ret; + const char *name = dcerpc_table_$name.endpoints->names[i]; + + ret = dcesrv_interface_register(dce_ctx, name, &$name\_interface, NULL); + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(1,(\"$name\_op_init_server: failed to register endpoint \'%s\'\\n\",name)); + return ret; + } + } + + return NT_STATUS_OK; +} + +static BOOL $name\__op_interface_by_uuid(struct dcesrv_interface *iface, const char *uuid, uint32_t if_version) +{ + if (dcerpc_table_$name.if_version == if_version && + strcmp(dcerpc_table_$name.uuid, uuid)==0) { + memcpy(iface,&dcerpc_table_$name, sizeof(*iface)); + return True; + } + + return False; +} + +static BOOL $name\__op_interface_by_name(struct dcesrv_interface *iface, const char *name) +{ + if (strcmp(dcerpc_table_$name.name, name)==0) { + memcpy(iface,&dcerpc_table_$name, sizeof(*iface)); + return True; + } + + return False; +} + +NTSTATUS dcerpc_server_$name\_init(void) +{ + NTSTATUS ret; + struct dcesrv_endpoint_server ep_server; + + /* fill in our name */ + ep_server.name = \"$name\"; + + /* fill in all the operations */ + ep_server.init_server = $name\__op_init_server; + + ep_server.interface_by_uuid = $name\__op_interface_by_uuid; + ep_server.interface_by_name = $name\__op_interface_by_name; + + /* register ourselves with the DCERPC subsystem. */ + ret = dcerpc_register_ep_server(&ep_server); + + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(0,(\"Failed to register \'$name\' endpoint server!\\n\")); + return ret; + } + + return ret; +} + +"; +} + +##################################################################### +# dcom interface stub from a parsed IDL structure +sub ParseInterface($) +{ + my($interface) = shift; + + return "" if has_property($interface, "local"); + + my($data) = $interface->{DATA}; + my $count = 0; + + $res = ""; + + if (!defined $interface->{PROPERTIES}->{uuid}) { + return $res; + } + + if (!defined $interface->{PROPERTIES}->{version}) { + $interface->{PROPERTIES}->{version} = "0.0"; + } + + foreach my $d (@{$data}) { + if ($d->{TYPE} eq "FUNCTION") { $count++; } + } + + if ($count == 0) { + return $res; + } + + $res = "/* dcom interface stub generated by pidl */\n\n"; + Boilerplate_Iface($interface); + Boilerplate_Ep_Server($interface); + + return $res; +} + +1; diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm index 2e77ff01b8..611f0adb92 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Header.pm @@ -334,10 +334,10 @@ sub HeaderFunction($) sub HeaderImport { my @imports = @_; - foreach (@imports) { - s/\.idl\"$//; - s/^\"//; - pidl choose_header("librpc/gen_ndr/$_\.h", "gen_ndr/$_.h") . "\n"; + foreach my $import (@imports) { + $import = unmake_str($import); + $import =~ s/\.idl$//; + pidl choose_header("librpc/gen_ndr/$import\.h", "gen_ndr/$import.h") . "\n"; } } diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm index 745777d012..0a6360f8ac 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm @@ -13,7 +13,7 @@ require Exporter; use strict; use Parse::Pidl::Typelist qw(hasType getType mapTypeName typeHasBody); -use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid); +use Parse::Pidl::Util qw(has_property ParseExpr ParseExprExt print_uuid unmake_str); use Parse::Pidl::CUtil qw(get_pointer_to get_value_of get_array_element); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::Samba4 qw(is_intree choose_header); @@ -2225,6 +2225,20 @@ sub AuthServiceStruct($$$) $self->pidl(""); } +sub FunctionCallEntry($$) +{ + my ($self, $d) = @_; + next if not defined($d->{OPNUM}); + $self->pidl("\t{"); + $self->pidl("\t\t\"$d->{NAME}\","); + $self->pidl("\t\tsizeof(struct $d->{NAME}),"); + $self->pidl("\t\t(ndr_push_flags_fn_t) ndr_push_$d->{NAME},"); + $self->pidl("\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},"); + $self->pidl("\t\t(ndr_print_function_t) ndr_print_$d->{NAME},"); + $self->pidl("\t\t".($d->{ASYNC}?"true":"false").","); + $self->pidl("\t},"); +} + ##################################################################### # produce a function call table sub FunctionTable($$) @@ -2237,16 +2251,9 @@ sub FunctionTable($$) return unless defined ($interface->{PROPERTIES}->{uuid}); $self->pidl("static const struct ndr_interface_call $interface->{NAME}\_calls[] = {"); - foreach my $d (@{$interface->{FUNCTIONS}}) { - next if not defined($d->{OPNUM}); - $self->pidl("\t{"); - $self->pidl("\t\t\"$d->{NAME}\","); - $self->pidl("\t\tsizeof(struct $d->{NAME}),"); - $self->pidl("\t\t(ndr_push_flags_fn_t) ndr_push_$d->{NAME},"); - $self->pidl("\t\t(ndr_pull_flags_fn_t) ndr_pull_$d->{NAME},"); - $self->pidl("\t\t(ndr_print_function_t) ndr_print_$d->{NAME},"); - $self->pidl("\t\t".($d->{ASYNC}?"true":"false").","); - $self->pidl("\t},"); + + foreach my $d (@{$interface->{INHERITED_FUNCTIONS}},@{$interface->{FUNCTIONS}}) { + $self->FunctionCallEntry($d); $count++; } $self->pidl("\t{ NULL, 0, NULL, NULL, NULL, false }"); @@ -2298,8 +2305,8 @@ sub HeaderImport my $self = shift; my @imports = @_; foreach (@imports) { - s/\.idl\"$//; - s/^\"//; + $_ = unmake_str($_); + s/\.idl$//; $self->pidl(choose_header("librpc/gen_ndr/ndr_$_\.h", "gen_ndr/ndr_$_.h")); } } @@ -2355,7 +2362,7 @@ sub HeaderInterface($$$) foreach (@{$interface->{FUNCTIONS}}) { next if has_property($_, "noopnum"); - next if grep(/$_->{NAME}/,@{$interface->{INHERITED_FUNCTIONS}}); + next if grep(/^$_->{NAME}$/,@{$interface->{INHERITED_FUNCTIONS}}); my $u_name = uc $_->{NAME}; my $val = sprintf("0x%02x", $count); diff --git a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm index 60d0dafc8a..74cec5a827 100644 --- a/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/source4/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -9,8 +9,9 @@ use Exporter; @ISA = qw(Exporter); use strict; +use Parse::Pidl qw(warning fatal); use Parse::Pidl::Typelist qw(hasType resolveType getType mapTypeName expandAlias); -use Parse::Pidl::Util qw(has_property ParseExpr); +use Parse::Pidl::Util qw(has_property ParseExpr unmake_str); use Parse::Pidl::NDR qw(GetPrevLevel GetNextLevel ContainsDeferred is_charset_array); use Parse::Pidl::CUtil qw(get_value_of get_pointer_to); use Parse::Pidl::Samba4::Header qw(GenerateFunctionInEnv GenerateFunctionOutEnv EnvSubstituteValue GenerateStructEnv); @@ -59,8 +60,8 @@ sub Import my $self = shift; my @imports = @_; foreach (@imports) { - s/\.idl\"$//; - s/^\"//; + $_ = unmake_str($_); + s/\.idl$//; $self->pidl_hdr("#include \"librpc/gen_ndr/py_$_\.h\"\n"); } } @@ -846,7 +847,7 @@ sub ConvertObjectFromPythonData($$$$$$) return; } - if ($actual_ctype->{TYPE} eq "STRUCT") { + if ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") { $self->pidl("PY_CHECK_TYPE($ctype->{NAME}, $cvar, $fail);"); $self->assign($target, "py_talloc_get_ptr($cvar)"); return; @@ -889,7 +890,7 @@ sub ConvertObjectFromPythonData($$$$$$) return; } - die("unknown type ".mapTypeName($ctype) . ": $cvar"); + fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar"); } @@ -1025,11 +1026,13 @@ sub ConvertObjectToPythonData($$$$$) return $self->ConvertScalarToPython(Parse::Pidl::Typelist::bitmap_type_fn($actual_ctype), $cvar); } elsif ($actual_ctype->{TYPE} eq "SCALAR") { return $self->ConvertScalarToPython($actual_ctype->{NAME}, $cvar); - } elsif ($actual_ctype->{TYPE} eq "STRUCT") { + } elsif ($actual_ctype->{TYPE} eq "UNION") { + fatal($ctype, "union without discriminant: " . mapTypeName($ctype) . ": $cvar"); + } elsif ($actual_ctype->{TYPE} eq "STRUCT" or $actual_ctype->{TYPE} eq "INTERFACE") { return "py_talloc_import_ex(&$ctype->{NAME}_Type, $mem_ctx, $cvar)"; } - die("unknown type ".mapTypeName($ctype) . ": $cvar"); + fatal($ctype, "unknown type $actual_ctype->{TYPE} for ".mapTypeName($ctype) . ": $cvar"); } sub fail_on_null($$$) diff --git a/source4/pidl/lib/Parse/Pidl/Typelist.pm b/source4/pidl/lib/Parse/Pidl/Typelist.pm index 8ba1ae47af..c5c458ac6b 100644 --- a/source4/pidl/lib/Parse/Pidl/Typelist.pm +++ b/source4/pidl/lib/Parse/Pidl/Typelist.pm @@ -245,7 +245,7 @@ sub mapType($$) return mapType($t->{DATA}, $n) if ($t->{TYPE} eq "TYPEDEF"); return mapScalarType($n) if ($t->{TYPE} eq "SCALAR"); return "enum $n" if ($t->{TYPE} eq "ENUM"); - return "struct $n" if ($t->{TYPE} eq "STRUCT"); + return "struct $n" if ($t->{TYPE} eq "STRUCT" or $t->{TYPE} eq "INTERFACE"); return "union $n" if ($t->{TYPE} eq "UNION"); return mapScalarType(bitmap_type_fn($t)) if ($t->{TYPE} eq "BITMAP"); die("Unknown type $t->{TYPE}"); @@ -273,6 +273,13 @@ sub LoadIdl($) foreach my $x (@{$idl}) { next if $x->{TYPE} ne "INTERFACE"; + # DCOM interfaces can be types as well + addType({ + NAME => $x->{NAME}, + TYPE => "TYPEDEF", + DATA => $x + }) if (has_property($x, "object")); + foreach my $y (@{$x->{DATA}}) { addType($y) if ( $y->{TYPE} eq "TYPEDEF" diff --git a/source4/pidl/pidl b/source4/pidl/pidl index b7a22f0499..0a6b0a97ca 100755 --- a/source4/pidl/pidl +++ b/source4/pidl/pidl @@ -409,6 +409,7 @@ use Getopt::Long; use File::Basename; use Parse::Pidl qw ( $VERSION ); use Parse::Pidl::Util; +use Parse::Pidl::ODL; ##################################################################### # save a data structure into a file @@ -483,6 +484,8 @@ my($opt_quiet) = 0; my($opt_outputdir) = '.'; my($opt_verbose) = 0; my($opt_warn_compat) = 0; +my($opt_dcom_proxy); +my($opt_com_header); ######################################### # display help text @@ -523,6 +526,8 @@ Samba 4 output: --swig[=OUTFILE] create swig wrapper file [BASENAME.i] --server[=OUTFILE] create server boilerplate [ndr_BASENAME_s.c] --template print a template for a pipe + --dcom-proxy[=OUTFILE] create DCOM proxy [ndr_BASENAME_p.c] + --com-header[=OUTFILE] create header for COM [com_BASENAME.h] Samba 3 output: --samba3-ndr-client[=OUTF] create client calls for Samba3 @@ -566,6 +571,8 @@ my $result = GetOptions ( 'python' => \$opt_python, 'diff' => \$opt_diff, 'swig:s' => \$opt_swig, + 'dcom-proxy:s' => \$opt_dcom_proxy, + 'com-header:s' => \$opt_com_header, 'quiet' => \$opt_quiet, 'verbose' => \$opt_verbose, 'warn-compat' => \$opt_warn_compat, @@ -626,11 +633,31 @@ sub process_file($) unlink($tempfile); } + my $comh_filename = ($opt_com_header or "$outputdir/com_$basename.h"); + if (defined($opt_com_header)) { + require Parse::Pidl::Samba4::COM::Header; + my $res = Parse::Pidl::Samba4::COM::Header::Parse($pidl,"$outputdir/ndr_$basename.h"); + if ($res) { + FileSave($comh_filename, $res); + } + } + + if (defined($opt_dcom_proxy)) { + require Parse::Pidl::Samba4::COM::Proxy; + my $res = Parse::Pidl::Samba4::COM::Proxy::Parse($pidl,$comh_filename); + if ($res) { + my ($client) = ($opt_dcom_proxy or "$outputdir/$basename\_p.c"); + FileSave($client, $res); + } + } + if ($opt_warn_compat) { require Parse::Pidl::Compat; Parse::Pidl::Compat::Check($pidl); } + $pidl = Parse::Pidl::ODL::ODL2IDL($pidl, dirname($idl_file), \@opt_incdirs); + if (defined($opt_ws_parser) or defined($opt_client) or defined($opt_server) or |