summaryrefslogtreecommitdiff
path: root/source3/python
diff options
context:
space:
mode:
Diffstat (limited to 'source3/python')
-rw-r--r--source3/python/py_common.h35
-rw-r--r--source3/python/py_lsa.h46
-rw-r--r--source3/python/py_lsa_proto.h13
-rw-r--r--source3/python/py_ntsec.c284
-rw-r--r--source3/python/py_samr.h83
-rw-r--r--source3/python/py_spoolss.h46
-rw-r--r--source3/python/py_spoolss_forms_conv.c79
-rw-r--r--source3/python/py_spoolss_jobs_conv.c102
-rw-r--r--source3/python/py_spoolss_ports.c137
-rw-r--r--source3/python/py_tdb.c614
-rw-r--r--source3/python/py_tdb.h29
-rw-r--r--source3/python/py_winreg.c82
-rw-r--r--source3/python/py_winreg.h29
13 files changed, 1579 insertions, 0 deletions
diff --git a/source3/python/py_common.h b/source3/python/py_common.h
new file mode 100644
index 0000000000..1f5188971d
--- /dev/null
+++ b/source3/python/py_common.h
@@ -0,0 +1,35 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 _PY_COMMON_H
+#define _PY_COMMON_H
+
+#include "includes.h"
+
+/* Return a cli_state struct opened on the specified pipe. If credentials
+ are passed use them. */
+
+typedef struct cli_state *(cli_pipe_fn)(
+ struct cli_state *cli, char *system_name,
+ struct ntuser_creds *creds);
+
+#include "python/py_common_proto.h"
+
+#endif /* _PY_COMMON_H */
diff --git a/source3/python/py_lsa.h b/source3/python/py_lsa.h
new file mode 100644
index 0000000000..f9a30d2f7e
--- /dev/null
+++ b/source3/python/py_lsa.h
@@ -0,0 +1,46 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 _PY_LSA_H
+#define _PY_LSA_H
+
+#include "includes.h"
+#include "Python.h"
+
+#include "python/py_common_proto.h"
+
+/* LSA policy handle object */
+
+typedef struct {
+ PyObject_HEAD
+ struct cli_state *cli;
+ TALLOC_CTX *mem_ctx;
+ POLICY_HND pol;
+} lsa_policy_hnd_object;
+
+/* Exceptions raised by this module */
+
+extern PyTypeObject lsa_policy_hnd_type;
+
+extern PyObject *lsa_error;
+
+#include "python/py_lsa_proto.h"
+
+#endif /* _PY_LSA_H */
diff --git a/source3/python/py_lsa_proto.h b/source3/python/py_lsa_proto.h
new file mode 100644
index 0000000000..1c6f6ab1d1
--- /dev/null
+++ b/source3/python/py_lsa_proto.h
@@ -0,0 +1,13 @@
+#ifndef _PY_LSA_PROTO_H
+#define _PY_LSA_PROTO_H
+
+/* This file is automatically generated with "make proto". DO NOT EDIT */
+
+
+/* The following definitions come from python/py_lsa.c */
+
+PyObject *new_lsa_policy_hnd_object(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *pol);
+void initlsa(void);
+
+#endif /* _PY_LSA_PROTO_H */
diff --git a/source3/python/py_ntsec.c b/source3/python/py_ntsec.c
new file mode 100644
index 0000000000..f216d96aa8
--- /dev/null
+++ b/source3/python/py_ntsec.c
@@ -0,0 +1,284 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 "Python.h"
+
+#include "python/py_common_proto.h"
+
+/* Convert a SID to a Python dict */
+
+BOOL py_from_SID(PyObject **obj, DOM_SID *sid)
+{
+ fstring sidstr;
+
+ if (!sid) {
+ Py_INCREF(Py_None);
+ *obj = Py_None;
+ return True;
+ }
+
+ if (!sid_to_string(sidstr, sid))
+ return False;
+
+ *obj = PyString_FromString(sidstr);
+
+ return True;
+}
+
+BOOL py_to_SID(DOM_SID *sid, PyObject *obj)
+{
+ if (!PyString_Check(obj))
+ return False;
+
+ return string_to_sid(sid, PyString_AsString(obj));
+}
+
+BOOL py_from_ACE(PyObject **dict, SEC_ACE *ace)
+{
+ PyObject *obj;
+
+ if (!ace) {
+ Py_INCREF(Py_None);
+ *dict = Py_None;
+ return True;
+ }
+
+ *dict = PyDict_New();
+
+ PyDict_SetItemString(*dict, "type", PyInt_FromLong(ace->type));
+ PyDict_SetItemString(*dict, "flags", PyInt_FromLong(ace->flags));
+ PyDict_SetItemString(*dict, "mask", PyInt_FromLong(ace->info.mask));
+
+ if (py_from_SID(&obj, &ace->trustee))
+ PyDict_SetItemString(*dict, "trustee", obj);
+
+ return True;
+}
+
+BOOL py_to_ACE(SEC_ACE *ace, PyObject *dict)
+{
+ PyObject *obj;
+ uint8 ace_type, ace_flags;
+ DOM_SID trustee;
+ SEC_ACCESS sec_access;
+
+ if (!PyDict_Check(dict))
+ return False;
+
+ if (!(obj = PyDict_GetItemString(dict, "type")) ||
+ !PyInt_Check(obj))
+ return False;
+
+ ace_type = PyInt_AsLong(obj);
+
+ if (!(obj = PyDict_GetItemString(dict, "flags")) ||
+ !PyInt_Check(obj))
+ return False;
+
+ ace_flags = PyInt_AsLong(obj);
+
+ if (!(obj = PyDict_GetItemString(dict, "trustee")) ||
+ !PyString_Check(obj))
+ return False;
+
+ if (!py_to_SID(&trustee, obj))
+ return False;
+
+ if (!(obj = PyDict_GetItemString(dict, "mask")) ||
+ !PyInt_Check(obj))
+ return False;
+
+ sec_access.mask = PyInt_AsLong(obj);
+
+ init_sec_ace(ace, &trustee, ace_type, sec_access, ace_flags);
+
+ /* Fill in size field */
+
+ ace->size = SEC_ACE_HEADER_SIZE + sid_size(&trustee);
+
+ return True;
+}
+
+BOOL py_from_ACL(PyObject **dict, SEC_ACL *acl)
+{
+ PyObject *ace_list;
+ int i;
+
+ if (!acl) {
+ Py_INCREF(Py_None);
+ *dict = Py_None;
+ return True;
+ }
+
+ *dict = PyDict_New();
+
+ PyDict_SetItemString(*dict, "revision", PyInt_FromLong(acl->revision));
+
+ ace_list = PyList_New(acl->num_aces);
+
+ for (i = 0; i < acl->num_aces; i++) {
+ PyObject *obj;
+
+ if (py_from_ACE(&obj, &acl->ace[i]))
+ PyList_SetItem(ace_list, i, obj);
+ }
+
+ PyDict_SetItemString(*dict, "ace_list", ace_list);
+
+ return True;
+}
+
+BOOL py_to_ACL(SEC_ACL *acl, PyObject *dict, TALLOC_CTX *mem_ctx)
+{
+ PyObject *obj;
+ uint32 i;
+
+ if (!(obj = PyDict_GetItemString(dict, "revision")) ||
+ !PyInt_Check(obj))
+ return False;
+
+ acl->revision = PyInt_AsLong(obj);
+
+ if (!(obj = PyDict_GetItemString(dict, "ace_list")) ||
+ !PyList_Check(obj))
+ return False;
+
+ acl->num_aces = PyList_Size(obj);
+
+ acl->ace = talloc(mem_ctx, acl->num_aces * sizeof(SEC_ACE));
+ acl->size = SEC_ACL_HEADER_SIZE;
+
+ for (i = 0; i < acl->num_aces; i++) {
+ PyObject *py_ace = PyList_GetItem(obj, i);
+
+ if (!py_to_ACE(&acl->ace[i], py_ace))
+ return False;
+
+ acl->size += acl->ace[i].size;
+ }
+
+ return True;
+}
+
+BOOL py_from_SECDESC(PyObject **dict, SEC_DESC *sd)
+{
+ PyObject *obj;
+
+ *dict = PyDict_New();
+
+ PyDict_SetItemString(*dict, "revision", PyInt_FromLong(sd->revision));
+
+ if (py_from_SID(&obj, sd->owner_sid))
+ PyDict_SetItemString(*dict, "owner_sid", obj);
+
+ if (py_from_SID(&obj, sd->grp_sid))
+ PyDict_SetItemString(*dict, "group_sid", obj);
+
+ if (py_from_ACL(&obj, sd->dacl))
+ PyDict_SetItemString(*dict, "dacl", obj);
+
+ if (py_from_ACL(&obj, sd->sacl))
+ PyDict_SetItemString(*dict, "sacl", obj);
+
+ return True;
+}
+
+BOOL py_to_SECDESC(SEC_DESC **sd, PyObject *dict, TALLOC_CTX *mem_ctx)
+{
+ PyObject *obj;
+ uint16 revision;
+ DOM_SID owner_sid, group_sid;
+ SEC_ACL sacl, dacl;
+ BOOL got_dacl = False, got_sacl = False;
+ BOOL got_owner_sid = False, got_group_sid = False;
+
+ ZERO_STRUCT(dacl); ZERO_STRUCT(sacl);
+ ZERO_STRUCT(owner_sid); ZERO_STRUCT(group_sid);
+
+ if (!(obj = PyDict_GetItemString(dict, "revision")))
+ return False;
+
+ revision = PyInt_AsLong(obj);
+
+ if ((obj = PyDict_GetItemString(dict, "owner_sid"))) {
+
+ if (obj != Py_None) {
+
+ if (!py_to_SID(&owner_sid, obj))
+ return False;
+
+ got_owner_sid = True;
+ }
+ }
+
+ if ((obj = PyDict_GetItemString(dict, "group_sid"))) {
+
+ if (obj != Py_None) {
+
+ if (!py_to_SID(&group_sid, obj))
+ return False;
+
+ got_group_sid = True;
+ }
+ }
+
+ if ((obj = PyDict_GetItemString(dict, "dacl"))) {
+
+ if (obj != Py_None) {
+
+ if (!py_to_ACL(&dacl, obj, mem_ctx))
+ return False;
+
+ got_dacl = True;
+ }
+ }
+
+ if ((obj = PyDict_GetItemString(dict, "sacl"))) {
+
+ if (obj != Py_None) {
+
+ if (!py_to_ACL(&sacl, obj, mem_ctx))
+ return False;
+
+ got_sacl = True;
+ }
+ }
+
+#if 0 /* For new secdesc code */
+ *sd = make_sec_desc(mem_ctx, revision,
+ got_owner_sid ? &owner_sid : NULL,
+ got_group_sid ? &group_sid : NULL,
+ got_sacl ? &sacl : NULL,
+ got_dacl ? &dacl : NULL);
+#else
+ {
+ size_t sd_size;
+
+ *sd = make_sec_desc(mem_ctx, revision,
+ got_owner_sid ? &owner_sid : NULL,
+ got_group_sid ? &group_sid : NULL,
+ got_sacl ? &sacl : NULL,
+ got_dacl ? &dacl : NULL, &sd_size);
+ }
+#endif
+
+ return True;
+}
diff --git a/source3/python/py_samr.h b/source3/python/py_samr.h
new file mode 100644
index 0000000000..22c3660ef9
--- /dev/null
+++ b/source3/python/py_samr.h
@@ -0,0 +1,83 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 _PY_SAMR_H
+#define _PY_SAMR_H
+
+#include "includes.h"
+#include "Python.h"
+
+#include "python/py_common_proto.h"
+
+/* SAMR connect policy handle object */
+
+typedef struct {
+ PyObject_HEAD
+ struct cli_state *cli;
+ TALLOC_CTX *mem_ctx;
+ POLICY_HND connect_pol;
+} samr_connect_hnd_object;
+
+/* SAMR domain policy handle object */
+
+typedef struct {
+ PyObject_HEAD
+ struct cli_state *cli;
+ TALLOC_CTX *mem_ctx;
+ POLICY_HND domain_pol;
+} samr_domain_hnd_object;
+
+/* SAMR user policy handle object */
+
+typedef struct {
+ PyObject_HEAD
+ struct cli_state *cli;
+ TALLOC_CTX *mem_ctx;
+ POLICY_HND user_pol;
+} samr_user_hnd_object;
+
+/* SAMR group policy handle object */
+
+typedef struct {
+ PyObject_HEAD
+ struct cli_state *cli;
+ TALLOC_CTX *mem_ctx;
+ POLICY_HND group_pol;
+} samr_group_hnd_object;
+
+/* SAMR alias policy handle object */
+
+typedef struct {
+ PyObject_HEAD
+ struct cli_state *cli;
+ TALLOC_CTX *mem_ctx;
+ POLICY_HND alias_pol;
+} samr_alias_hnd_object;
+
+extern PyTypeObject samr_connect_hnd_type, samr_domain_hnd_type,
+ samr_user_hnd_type, samr_group_hnd_type, samr_alias_hnd_type;
+
+/* Exceptions raised by this module */
+
+extern PyObject *samr_error;
+
+/* #include "python/py_samr_proto.h" */
+
+#endif /* _PY_SAMR_H */
diff --git a/source3/python/py_spoolss.h b/source3/python/py_spoolss.h
new file mode 100644
index 0000000000..40a6ae972e
--- /dev/null
+++ b/source3/python/py_spoolss.h
@@ -0,0 +1,46 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 _PY_SPOOLSS_H
+#define _PY_SPOOLSS_H
+
+#include "includes.h"
+#include "Python.h"
+
+#include "python/py_common_proto.h"
+
+/* Spoolss policy handle object */
+
+typedef struct {
+ PyObject_HEAD
+ struct cli_state *cli;
+ TALLOC_CTX *mem_ctx;
+ POLICY_HND pol;
+} spoolss_policy_hnd_object;
+
+/* Exceptions raised by this module */
+
+extern PyTypeObject spoolss_policy_hnd_type;
+
+extern PyObject *spoolss_error, *spoolss_werror;
+
+#include "python/py_spoolss_proto.h"
+
+#endif /* _PY_SPOOLSS_H */
diff --git a/source3/python/py_spoolss_forms_conv.c b/source3/python/py_spoolss_forms_conv.c
new file mode 100644
index 0000000000..6ef953cbc9
--- /dev/null
+++ b/source3/python/py_spoolss_forms_conv.c
@@ -0,0 +1,79 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 "python/py_spoolss.h"
+#include "python/py_conv.h"
+
+struct pyconv py_FORM[] = {
+ { "flags", PY_UINT32, offsetof(FORM, flags) },
+ { "width", PY_UINT32, offsetof(FORM, size_x) },
+ { "length", PY_UINT32, offsetof(FORM, size_y) },
+ { "top", PY_UINT32, offsetof(FORM, top) },
+ { "left", PY_UINT32, offsetof(FORM, left) },
+ { "right", PY_UINT32, offsetof(FORM, right) },
+ { "bottom", PY_UINT32, offsetof(FORM, bottom) },
+ { NULL }
+};
+
+struct pyconv py_FORM_1[] = {
+ { "flags", PY_UINT32, offsetof(FORM_1, flag) },
+ { "width", PY_UINT32, offsetof(FORM_1, width) },
+ { "length", PY_UINT32, offsetof(FORM_1, length) },
+ { "top", PY_UINT32, offsetof(FORM_1, top) },
+ { "left", PY_UINT32, offsetof(FORM_1, left) },
+ { "right", PY_UINT32, offsetof(FORM_1, right) },
+ { "bottom", PY_UINT32, offsetof(FORM_1, bottom) },
+ { "name", PY_UNISTR, offsetof(FORM_1, name) },
+ { NULL }
+};
+
+BOOL py_from_FORM_1(PyObject **dict, FORM_1 *form)
+{
+ *dict = from_struct(form, py_FORM_1);
+
+ PyDict_SetItemString(*dict, "level", PyInt_FromLong(1));
+
+ return True;
+}
+
+BOOL py_to_FORM(FORM *form, PyObject *dict)
+{
+ PyObject *obj, *dict_copy = PyDict_Copy(dict);
+ char *name;
+
+ obj = PyDict_GetItemString(dict, "name");
+
+ if (!obj || !PyString_Check(obj))
+ return False;
+
+ PyDict_DelItemString(dict_copy, "level");
+ PyDict_DelItemString(dict_copy, "name");
+
+ if (!to_struct(form, dict_copy, py_FORM)) {
+ Py_DECREF(dict_copy);
+ return False;
+ }
+
+ name = PyString_AsString(obj);
+
+ init_unistr2(&form->name, name, strlen(name) + 1);
+
+ return True;
+}
diff --git a/source3/python/py_spoolss_jobs_conv.c b/source3/python/py_spoolss_jobs_conv.c
new file mode 100644
index 0000000000..cb04ec6713
--- /dev/null
+++ b/source3/python/py_spoolss_jobs_conv.c
@@ -0,0 +1,102 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 "python/py_spoolss.h"
+#include "python/py_conv.h"
+
+struct pyconv py_JOB_INFO_1[] = {
+ { "jobid", PY_UINT32, offsetof(JOB_INFO_1, jobid) },
+ { "printer_name", PY_UNISTR, offsetof(JOB_INFO_1, printername) },
+ { "server_name", PY_UNISTR, offsetof(JOB_INFO_1, machinename) },
+ { "user_name", PY_UNISTR, offsetof(JOB_INFO_1, username) },
+ { "document_name", PY_UNISTR, offsetof(JOB_INFO_1, document) },
+ { "data_type", PY_UNISTR, offsetof(JOB_INFO_1, datatype) },
+ { "text_status", PY_UNISTR, offsetof(JOB_INFO_1, text_status) },
+ { "status", PY_UINT32, offsetof(JOB_INFO_1, status) },
+ { "priority", PY_UINT32, offsetof(JOB_INFO_1, priority) },
+ { "position", PY_UINT32, offsetof(JOB_INFO_1, position) },
+ { "total_pages", PY_UINT32, offsetof(JOB_INFO_1, totalpages) },
+ { "pages_printed", PY_UINT32, offsetof(JOB_INFO_1, pagesprinted) },
+ { NULL }
+};
+
+struct pyconv py_JOB_INFO_2[] = {
+ { "jobid", PY_UINT32, offsetof(JOB_INFO_2, jobid) },
+ { "printer_name", PY_UNISTR, offsetof(JOB_INFO_2, printername) },
+ { "server_name", PY_UNISTR, offsetof(JOB_INFO_2, machinename) },
+ { "user_name", PY_UNISTR, offsetof(JOB_INFO_2, username) },
+ { "document_name", PY_UNISTR, offsetof(JOB_INFO_2, document) },
+ { "notify_name", PY_UNISTR, offsetof(JOB_INFO_2, notifyname) },
+ { "data_type", PY_UNISTR, offsetof(JOB_INFO_2, datatype) },
+ { "print_processor", PY_UNISTR, offsetof(JOB_INFO_2, printprocessor) },
+ { "parameters", PY_UNISTR, offsetof(JOB_INFO_2, parameters) },
+ { "driver_name", PY_UNISTR, offsetof(JOB_INFO_2, drivername) },
+ { "text_status", PY_UNISTR, offsetof(JOB_INFO_2, text_status) },
+ { "status", PY_UINT32, offsetof(JOB_INFO_2, status) },
+ { "priority", PY_UINT32, offsetof(JOB_INFO_2, priority) },
+ { "position", PY_UINT32, offsetof(JOB_INFO_2, position) },
+ { "start_time", PY_UINT32, offsetof(JOB_INFO_2, starttime) },
+ { "until_time", PY_UINT32, offsetof(JOB_INFO_2, untiltime) },
+ { "total_pages", PY_UINT32, offsetof(JOB_INFO_2, totalpages) },
+ { "size", PY_UINT32, offsetof(JOB_INFO_2, size) },
+ { "time_elapsed", PY_UINT32, offsetof(JOB_INFO_2, timeelapsed) },
+ { "pages_printed", PY_UINT32, offsetof(JOB_INFO_2, pagesprinted) },
+ { NULL }
+};
+
+struct pyconv py_DOC_INFO_1[] = {
+ { "document_name", PY_UNISTR, offsetof(DOC_INFO_1, docname) },
+ { "output_file", PY_UNISTR, offsetof(DOC_INFO_1, outputfile) },
+ { "data_type", PY_UNISTR, offsetof(DOC_INFO_1, datatype) },
+ { NULL }
+};
+
+BOOL py_from_JOB_INFO_1(PyObject **dict, JOB_INFO_1 *info)
+{
+ *dict = from_struct(info, py_JOB_INFO_1);
+ return True;
+}
+
+BOOL py_to_JOB_INFO_1(JOB_INFO_1 *info, PyObject *dict)
+{
+ return False;
+}
+
+BOOL py_from_JOB_INFO_2(PyObject **dict, JOB_INFO_2 *info)
+{
+ *dict = from_struct(info, py_JOB_INFO_2);
+ return True;
+}
+
+BOOL py_to_JOB_INFO_2(JOB_INFO_2 *info, PyObject *dict)
+{
+ return False;
+}
+
+BOOL py_from_DOC_INFO_1(PyObject **dict, DOC_INFO_1 *info)
+{
+ *dict = from_struct(info, py_DOC_INFO_1);
+ return True;
+}
+
+BOOL py_to_DOC_INFO_1(DOC_INFO_1 *info, PyObject *dict)
+{
+ return to_struct(info, dict, py_DOC_INFO_1);
+}
diff --git a/source3/python/py_spoolss_ports.c b/source3/python/py_spoolss_ports.c
new file mode 100644
index 0000000000..b5f2102e5e
--- /dev/null
+++ b/source3/python/py_spoolss_ports.c
@@ -0,0 +1,137 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 "python/py_spoolss.h"
+
+/* Enumerate ports */
+
+PyObject *spoolss_enumports(PyObject *self, PyObject *args, PyObject *kw)
+{
+ WERROR werror;
+ PyObject *result = NULL, *creds = NULL;
+ int level = 1;
+ uint32 i, needed, num_ports;
+ static char *kwlist[] = {"server", "level", "creds", NULL};
+ TALLOC_CTX *mem_ctx = NULL;
+ struct cli_state *cli = NULL;
+ char *server, *errstr;
+ PORT_INFO_CTR ctr;
+
+ /* Parse parameters */
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kw, "s|iO", kwlist, &server, &level, &creds))
+ return NULL;
+
+ if (server[0] != '\\' || server[1] != '\\') {
+ PyErr_SetString(PyExc_ValueError, "UNC name required");
+ return NULL;
+ }
+
+ server += 2;
+
+ if (creds && creds != Py_None && !PyDict_Check(creds)) {
+ PyErr_SetString(PyExc_TypeError,
+ "credentials must be dictionary or None");
+ return NULL;
+ }
+
+ if (!(cli = open_pipe_creds(server, creds, PIPE_SPOOLSS, &errstr))) {
+ PyErr_SetString(spoolss_error, errstr);
+ free(errstr);
+ goto done;
+ }
+
+ if (!(mem_ctx = talloc_init())) {
+ PyErr_SetString(
+ spoolss_error, "unable to init talloc context\n");
+ goto done;
+ }
+
+ /* Call rpc function */
+
+ werror = cli_spoolss_enum_ports(
+ cli, mem_ctx, 0, &needed, level, &num_ports, &ctr);
+
+ if (W_ERROR_V(werror) == ERRinsufficientbuffer)
+ werror = cli_spoolss_enum_ports(
+ cli, mem_ctx, needed, NULL, level,
+ &num_ports, &ctr);
+
+ if (!W_ERROR_IS_OK(werror)) {
+ PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
+ goto done;
+ }
+
+ /* Return value */
+
+ switch (level) {
+ case 1:
+ result = PyDict_New();
+
+ for (i = 0; i < num_ports; i++) {
+ PyObject *value;
+ fstring name;
+
+ rpcstr_pull(name, ctr.port.info_1[i].port_name.buffer,
+ sizeof(fstring), -1, STR_TERMINATE);
+
+ py_from_PORT_INFO_1(&value, &ctr.port.info_1[i]);
+
+ PyDict_SetItemString(
+ value, "level", PyInt_FromLong(1));
+
+ PyDict_SetItemString(result, name, value);
+ }
+
+ break;
+ case 2:
+ result = PyDict_New();
+
+ for(i = 0; i < num_ports; i++) {
+ PyObject *value;
+ fstring name;
+
+ rpcstr_pull(name, ctr.port.info_2[i].port_name.buffer,
+ sizeof(fstring), -1, STR_TERMINATE);
+
+ py_from_PORT_INFO_2(&value, &ctr.port.info_2[i]);
+
+ PyDict_SetItemString(
+ value, "level", PyInt_FromLong(2));
+
+ PyDict_SetItemString(result, name, value);
+ }
+
+ break;
+ default:
+ PyErr_SetString(spoolss_error, "unknown info level");
+ goto done;
+ }
+
+ done:
+ if (cli)
+ cli_shutdown(cli);
+
+ if (mem_ctx)
+ talloc_destroy(mem_ctx);
+
+ return result;
+}
diff --git a/source3/python/py_tdb.c b/source3/python/py_tdb.c
new file mode 100644
index 0000000000..4969c1047e
--- /dev/null
+++ b/source3/python/py_tdb.c
@@ -0,0 +1,614 @@
+/*
+ Python wrappers for TDB module
+
+ Copyright (C) Tim Potter, 2002
+
+ 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.
+*/
+
+/*
+ NOTE: Since tdb is licenced under the GPL any program that uses these bindings
+ must be distributed under the GPL license terms since this is what
+ the GPL requires.
+
+ http://www.gnu.org/licenses/gpl-faq.html#IfInterpreterIsGPL
+*/
+
+#include "includes.h"
+#include "Python.h"
+
+/* Tdb exception */
+
+PyObject *py_tdb_error;
+
+/* tdb handle object */
+
+typedef struct {
+ PyObject_HEAD
+ TDB_CONTEXT *tdb;
+} tdb_hnd_object;
+
+PyTypeObject tdb_hnd_type;
+
+PyObject *new_tdb_hnd_object(TDB_CONTEXT *tdb)
+{
+ tdb_hnd_object *obj;
+
+ obj = PyObject_New(tdb_hnd_object, &tdb_hnd_type);
+ obj->tdb = tdb;
+
+ return (PyObject *)obj;
+}
+
+PyObject *py_tdb_close(PyObject *self, PyObject *args)
+{
+ tdb_hnd_object *obj;
+
+ if (!PyArg_ParseTuple(args, "O!", &tdb_hnd_type, &obj))
+ return NULL;
+
+ if (tdb_close(obj->tdb) == -1) {
+ obj->tdb = NULL;
+ PyErr_SetString(py_tdb_error, strerror(errno));
+ return NULL;
+ }
+
+ obj->tdb = NULL;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+PyObject *py_tdb_open(PyObject *self, PyObject *args, PyObject *kw)
+{
+ static char *kwlist[] = { "name", "hash_size", "tdb_flags",
+ "open_flags", "mode", NULL };
+ char *name;
+ int hash_size = 0, flags = TDB_DEFAULT, open_flags = -1, open_mode = 0600;
+ TDB_CONTEXT *tdb;
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kw, "s|iiii", kwlist, &name, &hash_size, &flags,
+ &open_flags, &open_mode))
+ return NULL;
+
+ /* Default open_flags to read/write */
+
+ if (open_flags == -1) {
+ if (access(name, W_OK) == -1)
+ open_flags = O_RDONLY;
+ else
+ open_flags = O_RDWR;
+ }
+
+ if (!(tdb = tdb_open(name, hash_size, flags, open_flags, open_mode))) {
+ PyErr_SetString(py_tdb_error, strerror(errno));
+ return NULL;
+ }
+
+ return new_tdb_hnd_object(tdb);
+}
+
+/*
+ * Allow a tdb to act as a python mapping (dictionary)
+ */
+
+static int tdb_traverse_count(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA value,
+ void *state)
+{
+ /* Do nothing - tdb_traverse will return the number of records
+ traversed. */
+
+ return 0;
+}
+
+static int tdb_hnd_length(tdb_hnd_object *obj)
+{
+ int result;
+
+ result = tdb_traverse(obj->tdb, tdb_traverse_count, NULL);
+
+ return result;
+}
+
+static PyObject *tdb_hnd_subscript(tdb_hnd_object *obj, PyObject *key)
+{
+ TDB_DATA drec, krec;
+ PyObject *result;
+
+ if (!PyArg_Parse(key, "s#", &krec.dptr, &krec.dsize))
+ return NULL;
+
+ drec = tdb_fetch(obj->tdb, krec);
+
+ if (!drec.dptr) {
+ PyErr_SetString(PyExc_KeyError,
+ PyString_AsString(key));
+ return NULL;
+ }
+
+ result = PyString_FromStringAndSize(drec.dptr, drec.dsize);
+ free(drec.dptr);
+
+ return result;
+}
+
+static int tdb_ass_subscript(tdb_hnd_object *obj, PyObject *key, PyObject *value)
+{
+ TDB_DATA krec, drec;
+
+ if (!PyArg_Parse(key, "s#", &krec.dptr, &krec.dsize)) {
+ PyErr_SetString(PyExc_TypeError,
+ "tdb mappings have string indices only");
+ return -1;
+ }
+
+ if (!obj->tdb) {
+ PyErr_SetString(
+ py_tdb_error, "tdb object has been closed");
+ return -1;
+ }
+
+ if (!value) {
+
+ /* Delete value */
+
+ if (tdb_delete(obj->tdb, krec) == -1) {
+ PyErr_SetString(PyExc_KeyError,
+ PyString_AsString(value));
+ return -1;
+ }
+
+ } else {
+
+ /* Set value */
+
+ if (!PyArg_Parse(value, "s#", &drec.dptr, &drec.dsize)) {
+ PyErr_SetString(PyExc_TypeError,
+ "tdb mappings have string elements only");
+ return -1;
+ }
+
+ errno = 0;
+
+ if (tdb_store(obj->tdb, krec, drec, 0) < 0 ) {
+ if (errno != 0)
+ PyErr_SetFromErrno(py_tdb_error);
+ else
+ PyErr_SetString(
+ py_tdb_error,
+ (char *)tdb_errorstr(obj->tdb));
+
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static PyMappingMethods tdb_mapping = {
+ (inquiry) tdb_hnd_length,
+ (binaryfunc) tdb_hnd_subscript,
+ (objobjargproc) tdb_ass_subscript
+};
+
+/*
+ * Utility methods
+ */
+
+/* Return non-zero if a given key exists in the tdb */
+
+PyObject *py_tdb_hnd_has_key(PyObject *self, PyObject *args)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+ TDB_DATA key;
+
+ if (!PyArg_ParseTuple(args, "s#", &key.dptr, &key.dsize))
+ return NULL;
+
+ if (!obj->tdb) {
+ PyErr_SetString(
+ py_tdb_error, "tdb object has been closed");
+ return NULL;
+ }
+
+ return PyInt_FromLong(tdb_exists(obj->tdb, key));
+}
+
+/* Return a list of keys in the tdb */
+
+static int tdb_traverse_keys(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA value,
+ void *state)
+{
+ PyObject *key_list = (PyObject *)state;
+
+ PyList_Append(key_list,
+ PyString_FromStringAndSize(key.dptr, key.dsize));
+
+ return 0;
+}
+
+PyObject *py_tdb_hnd_keys(PyObject *self, PyObject *args)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+ PyObject *key_list = PyList_New(0);
+
+ if (!obj->tdb) {
+ PyErr_SetString(py_tdb_error, "tdb object has been closed");
+ return NULL;
+ }
+
+ if (tdb_traverse(obj->tdb, tdb_traverse_keys, key_list) == -1) {
+ PyErr_SetString(py_tdb_error, "error traversing tdb");
+ Py_DECREF(key_list);
+ return NULL;
+ }
+
+ return key_list;
+}
+
+PyObject *py_tdb_hnd_first_key(PyObject *self, PyObject *args)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+ TDB_DATA key;
+
+ if (!obj->tdb) {
+ PyErr_SetString(py_tdb_error, "tdb object has been closed");
+ return NULL;
+ }
+
+ key = tdb_firstkey(obj->tdb);
+
+ return Py_BuildValue("s#", key.dptr, key.dsize);
+}
+
+PyObject *py_tdb_hnd_next_key(PyObject *self, PyObject *py_oldkey)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+ TDB_DATA key, oldkey;
+
+ if (!obj->tdb) {
+ PyErr_SetString(py_tdb_error, "tdb object has been closed");
+ return NULL;
+ }
+
+ if (!PyArg_Parse(py_oldkey, "s#", &oldkey.dptr, &oldkey.dsize))
+ return NULL;
+
+ key = tdb_nextkey(obj->tdb, oldkey);
+
+ return Py_BuildValue("s#", key.dptr, key.dsize);
+}
+
+/*
+ * Locking routines
+ */
+
+PyObject *py_tdb_hnd_lock_all(PyObject *self, PyObject *args)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+ int result;
+
+ if (!obj->tdb) {
+ PyErr_SetString(py_tdb_error, "tdb object has been closed");
+ return NULL;
+ }
+
+ result = tdb_lockall(obj->tdb);
+
+ return PyInt_FromLong(result != -1);
+}
+
+PyObject *py_tdb_hnd_unlock_all(PyObject *self, PyObject *args)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+
+ if (!obj->tdb) {
+ PyErr_SetString(py_tdb_error, "tdb object has been closed");
+ return NULL;
+ }
+
+ tdb_unlockall(obj->tdb);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+/* Return an array of keys from a python object which must be a string or a
+ list of strings. */
+
+static BOOL make_lock_list(PyObject *py_keys, TDB_DATA **keys, int *num_keys)
+{
+ /* Are we a list or a string? */
+
+ if (!PyList_Check(py_keys) && !PyString_Check(py_keys)) {
+ PyErr_SetString(PyExc_TypeError, "arg must be list of string");
+ return False;
+ }
+
+ if (PyList_Check(py_keys)) {
+ int i;
+
+ /* Turn python list into array of keys */
+
+ *num_keys = PyList_Size(py_keys);
+ *keys = (TDB_DATA *)malloc(sizeof(TDB_DATA) * (*num_keys));
+
+ for (i = 0; i < *num_keys; i++) {
+ PyObject *key = PyList_GetItem(py_keys, i);
+
+ if (!PyString_Check(key)) {
+ PyErr_SetString(
+ PyExc_TypeError,
+ "list elements must be strings");
+ return False;
+ }
+
+ PyArg_Parse(key, "s#", &(*keys)[i].dptr,
+ &(*keys)[i].dsize);
+ }
+
+ } else {
+
+ /* Turn python string into a single key */
+
+ *keys = (TDB_DATA *)malloc(sizeof(TDB_DATA));
+ *num_keys = 1;
+ PyArg_Parse(py_keys, "s#", &(*keys)->dptr, &(*keys)->dsize);
+ }
+
+ return True;
+}
+
+PyObject *py_tdb_hnd_lock(PyObject *self, PyObject *args)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+ PyObject *py_keys;
+ TDB_DATA *keys;
+ int num_keys, result;
+
+ if (!obj->tdb) {
+ PyErr_SetString(py_tdb_error, "tdb object has been closed");
+ return NULL;
+ }
+
+ if (!PyArg_ParseTuple(args, "O", &py_keys))
+ return NULL;
+
+ if (!make_lock_list(py_keys, &keys, &num_keys))
+ return NULL;
+
+ result = tdb_lockkeys(obj->tdb, num_keys, keys);
+
+ free(keys);
+
+ return PyInt_FromLong(result != -1);
+}
+
+PyObject *py_tdb_hnd_unlock(PyObject *self, PyObject *args)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+
+ if (!obj->tdb) {
+ PyErr_SetString(py_tdb_error, "tdb object has been closed");
+ return NULL;
+ }
+
+ if (!PyArg_ParseTuple(args, ""))
+ return NULL;
+
+ tdb_unlockkeys(obj->tdb);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+/*
+ * tdb traversal
+ */
+
+struct traverse_info {
+ PyObject *callback;
+ PyObject *state;
+};
+
+static int tdb_traverse_traverse(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA value,
+ void *state)
+{
+ struct traverse_info *info = state;
+ PyObject *arglist, *py_result;
+ int result;
+
+ arglist = Py_BuildValue("(s#s#O)", key.dptr, key.dsize, value.dptr,
+ value.dsize, info->state);
+
+ py_result = PyEval_CallObject(info->callback, arglist);
+
+ Py_DECREF(arglist);
+
+ if (!PyInt_Check(py_result)) {
+ result = 1; /* Hmm - non-integer object returned by callback */
+ goto done;
+ }
+
+ result = PyInt_AsLong(py_result);
+
+done:
+ Py_DECREF(py_result);
+ return result;
+}
+
+PyObject *py_tdb_hnd_traverse(PyObject *self, PyObject *args, PyObject *kw)
+{
+ tdb_hnd_object *obj = (tdb_hnd_object *)self;
+ static char *kwlist[] = { "traverse_fn", "state", NULL };
+ PyObject *state = Py_None, *callback;
+ struct traverse_info info;
+ int result;
+
+ if (!PyArg_ParseTupleAndKeywords(
+ args, kw, "O|O", kwlist, &callback, &state))
+ return NULL;
+
+ if (!PyCallable_Check(callback)) {
+ PyErr_SetString(PyExc_TypeError, "parameter must be callable");
+ return NULL;
+ }
+
+ Py_INCREF(callback);
+ Py_INCREF(state);
+
+ info.callback = callback;
+ info.state = state;
+
+ result = tdb_traverse(obj->tdb, tdb_traverse_traverse, &info);
+
+ Py_DECREF(callback);
+ Py_DECREF(state);
+
+ return PyInt_FromLong(result);
+}
+
+/*
+ * Method dispatch table for this module
+ */
+
+static PyMethodDef tdb_methods[] = {
+ { "open", (PyCFunction)py_tdb_open, METH_VARARGS | METH_KEYWORDS },
+ { "close", (PyCFunction)py_tdb_close, METH_VARARGS },
+ { NULL }
+};
+
+/*
+ * Methods on a tdb object
+ */
+
+static PyMethodDef tdb_hnd_methods[] = {
+ { "keys", (PyCFunction)py_tdb_hnd_keys, METH_VARARGS },
+ { "has_key", (PyCFunction)py_tdb_hnd_has_key, METH_VARARGS },
+ { "first_key", (PyCFunction)py_tdb_hnd_first_key, METH_VARARGS },
+ { "next_key", (PyCFunction)py_tdb_hnd_next_key, METH_VARARGS },
+ { "lock_all", (PyCFunction)py_tdb_hnd_lock_all, METH_VARARGS },
+ { "unlock_all", (PyCFunction)py_tdb_hnd_unlock_all, METH_VARARGS },
+ { "lock", (PyCFunction)py_tdb_hnd_lock, METH_VARARGS },
+ { "unlock", (PyCFunction)py_tdb_hnd_unlock, METH_VARARGS },
+ { "traverse", (PyCFunction)py_tdb_hnd_traverse, METH_VARARGS | METH_KEYWORDS },
+ { NULL }
+};
+
+/* Deallocate a tdb handle object */
+
+static void tdb_hnd_dealloc(PyObject* self)
+{
+ tdb_hnd_object *hnd = (tdb_hnd_object *)self;
+
+ if (hnd->tdb) {
+ tdb_close(hnd->tdb);
+ hnd->tdb = NULL;
+ }
+}
+
+/* Return tdb handle attributes */
+
+static PyObject *tdb_hnd_getattr(PyObject *self, char *attrname)
+{
+ return Py_FindMethod(tdb_hnd_methods, self, attrname);
+}
+
+static char tdb_hnd_type_doc[] =
+"Python wrapper for tdb.";
+
+PyTypeObject tdb_hnd_type = {
+ PyObject_HEAD_INIT(NULL)
+ 0,
+ "tdb",
+ sizeof(tdb_hnd_object),
+ 0,
+ tdb_hnd_dealloc, /* tp_dealloc*/
+ 0, /* tp_print*/
+ tdb_hnd_getattr, /* tp_getattr*/
+ 0, /* tp_setattr*/
+ 0, /* tp_compare*/
+ 0, /* tp_repr*/
+ 0, /* tp_as_number*/
+ 0, /* tp_as_sequence*/
+ &tdb_mapping, /* tp_as_mapping*/
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ tdb_hnd_type_doc, /* tp_doc */
+};
+
+/* Constants */
+
+static struct const_vals {
+ char *name;
+ uint32 value;
+} module_const_vals[] = {
+
+ /* Flags for tdb_open() */
+
+ { "TDB_DEFAULT", TDB_DEFAULT },
+ { "TDB_CLEAR_IF_FIRST", TDB_CLEAR_IF_FIRST },
+ { "TDB_INTERNAL", TDB_INTERNAL },
+ { "TDB_NOLOCK", TDB_NOLOCK },
+ { "TDB_NOMMAP", TDB_NOMMAP },
+ { "TDB_CONVERT", TDB_CONVERT },
+ { "TDB_BIGENDIAN", TDB_BIGENDIAN },
+
+ { NULL },
+};
+
+static void const_init(PyObject *dict)
+{
+ struct const_vals *tmp;
+ PyObject *obj;
+
+ for (tmp = module_const_vals; tmp->name; tmp++) {
+ obj = PyInt_FromLong(tmp->value);
+ PyDict_SetItemString(dict, tmp->name, obj);
+ Py_DECREF(obj);
+ }
+}
+
+/* Module initialisation */
+
+void inittdb(void)
+{
+ PyObject *module, *dict;
+
+ /* Initialise module */
+
+ module = Py_InitModule("tdb", tdb_methods);
+ dict = PyModule_GetDict(module);
+
+ py_tdb_error = PyErr_NewException("tdb.error", NULL, NULL);
+ PyDict_SetItemString(dict, "error", py_tdb_error);
+
+ /* Initialise policy handle object */
+
+ tdb_hnd_type.ob_type = &PyType_Type;
+
+ PyDict_SetItemString(dict, "tdb.hnd",
+ (PyObject *)&tdb_hnd_type);
+
+ /* Initialise constants */
+
+ const_init(dict);
+}
diff --git a/source3/python/py_tdb.h b/source3/python/py_tdb.h
new file mode 100644
index 0000000000..794a20cf2b
--- /dev/null
+++ b/source3/python/py_tdb.h
@@ -0,0 +1,29 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 _PY_TDB_H
+#define _PY_TDB_H
+
+#include "includes.h"
+#include "Python.h"
+
+#include "python/py_common_proto.h"
+
+#endif /* _PY_TDB_H */
diff --git a/source3/python/py_winreg.c b/source3/python/py_winreg.c
new file mode 100644
index 0000000000..ce27f5c533
--- /dev/null
+++ b/source3/python/py_winreg.c
@@ -0,0 +1,82 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 "python/py_winreg.h"
+
+static struct const_vals {
+ char *name;
+ uint32 value;
+} module_const_vals[] = {
+
+ /* Registry value types */
+
+ { "REG_NONE", REG_NONE },
+ { "REG_SZ", REG_SZ },
+ { "REG_EXPAND_SZ", REG_EXPAND_SZ },
+ { "REG_BINARY", REG_BINARY },
+ { "REG_DWORD", REG_DWORD },
+ { "REG_DWORD_LE", REG_DWORD_LE },
+ { "REG_DWORD_BE", REG_DWORD_BE },
+ { "REG_LINK", REG_LINK },
+ { "REG_MULTI_SZ", REG_MULTI_SZ },
+ { "REG_RESOURCE_LIST", REG_RESOURCE_LIST },
+ { "REG_FULL_RESOURCE_DESCRIPTOR", REG_FULL_RESOURCE_DESCRIPTOR },
+ { "REG_RESOURCE_REQUIREMENTS_LIST", REG_RESOURCE_REQUIREMENTS_LIST },
+
+ { NULL },
+};
+
+static void const_init(PyObject *dict)
+{
+ struct const_vals *tmp;
+ PyObject *obj;
+
+ for (tmp = module_const_vals; tmp->name; tmp++) {
+ obj = PyInt_FromLong(tmp->value);
+ PyDict_SetItemString(dict, tmp->name, obj);
+ Py_DECREF(obj);
+ }
+}
+
+/*
+ * Module initialisation
+ */
+
+static PyMethodDef winreg_methods[] = {
+ { NULL }
+};
+
+void initwinreg(void)
+{
+ PyObject *module, *dict;
+
+ /* Initialise module */
+
+ module = Py_InitModule("winreg", winreg_methods);
+ dict = PyModule_GetDict(module);
+
+ /* Initialise constants */
+
+ const_init(dict);
+
+ /* Do samba initialisation */
+
+ py_samba_init();
+}
diff --git a/source3/python/py_winreg.h b/source3/python/py_winreg.h
new file mode 100644
index 0000000000..088be724e2
--- /dev/null
+++ b/source3/python/py_winreg.h
@@ -0,0 +1,29 @@
+/*
+ Python wrappers for DCERPC/SMB client routines.
+
+ Copyright (C) Tim Potter, 2002
+
+ 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 _PY_WINREG_H
+#define _PY_WINREG_H
+
+#include "includes.h"
+#include "Python.h"
+
+#include "python/py_common_proto.h"
+
+#endif /* _PY_WINREG_H */