Author: jelmer
Date: 2007-09-27 01:31:43 +0000 (Thu, 27 Sep 2007)
New Revision: 25371

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25371

Log:
Add uuid module.
Added:
   branches/4.0-python/source/scripting/python/uuidmodule.c
Modified:
   branches/4.0-python/
   branches/4.0-python/.bzrignore
   branches/4.0-python/source/lib/basic.mk
   branches/4.0-python/source/scripting/python/config.mk
   branches/4.0-python/source/scripting/python/provision.py
   branches/4.0-python/source/scripting/python/talloc.c
   branches/4.0-python/source/setup/provision


Changeset:

Property changes on: branches/4.0-python
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:file-ids
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/4.0-python/.bzrignore
===================================================================
--- branches/4.0-python/.bzrignore      2007-09-27 01:26:19 UTC (rev 25370)
+++ branches/4.0-python/.bzrignore      2007-09-27 01:31:43 UTC (rev 25371)
@@ -211,3 +211,4 @@
 source/lib/ldb/swig/ldb.py
 source/lib/tdb/swig/tdb.py
 source/lib/tdb/swig/tdb_wrap.c
+source/scripting/python/talloc.h

Modified: branches/4.0-python/source/lib/basic.mk
===================================================================
--- branches/4.0-python/source/lib/basic.mk     2007-09-27 01:26:19 UTC (rev 
25370)
+++ branches/4.0-python/source/lib/basic.mk     2007-09-27 01:31:43 UTC (rev 
25371)
@@ -15,7 +15,6 @@
 include util/config.mk
 include tdr/config.mk
 include dbwrap/config.mk
-include python/config.mk
 
 ##############################
 # Start SUBSYSTEM LIBCRYPTO

Modified: branches/4.0-python/source/scripting/python/config.mk
===================================================================
--- branches/4.0-python/source/scripting/python/config.mk       2007-09-27 
01:26:19 UTC (rev 25370)
+++ branches/4.0-python/source/scripting/python/config.mk       2007-09-27 
01:31:43 UTC (rev 25371)
@@ -7,3 +7,8 @@
 PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG talloc_python
 OBJ_FILES = \
                        parammodule.o
+
+[PYTHON::python_uuid]
+PRIVATE_DEPENDENCIES = LIBNDR talloc_python
+OBJ_FILES = \
+                       uuidmodule.o

Modified: branches/4.0-python/source/scripting/python/provision.py
===================================================================
--- branches/4.0-python/source/scripting/python/provision.py    2007-09-27 
01:26:19 UTC (rev 25370)
+++ branches/4.0-python/source/scripting/python/provision.py    2007-09-27 
01:31:43 UTC (rev 25371)
@@ -233,6 +233,7 @@
         return False
     return True
 
+
 def setup_ldb(ldif, info, dbname, erase=True, failok=False):
     ldb = open_ldb(info, dbname, erase)
     if setup_add_ldif(ldif, info, ldb, failok):

Modified: branches/4.0-python/source/scripting/python/talloc.c
===================================================================
--- branches/4.0-python/source/scripting/python/talloc.c        2007-09-27 
01:26:19 UTC (rev 25370)
+++ branches/4.0-python/source/scripting/python/talloc.c        2007-09-27 
01:31:43 UTC (rev 25371)
@@ -25,6 +25,7 @@
 #include "Python.h"
 #include "param/param.h"
 
-TALLOC_CTX *PyMemCtx() {
+TALLOC_CTX *PyMemCtx(void)
+{
        return talloc_autofree_context();
 }

Added: branches/4.0-python/source/scripting/python/uuidmodule.c
===================================================================
--- branches/4.0-python/source/scripting/python/uuidmodule.c    2007-09-27 
01:26:19 UTC (rev 25370)
+++ branches/4.0-python/source/scripting/python/uuidmodule.c    2007-09-27 
01:31:43 UTC (rev 25371)
@@ -0,0 +1,58 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Jelmer Vernooij <[EMAIL PROTECTED]> 2007
+   
+   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/>.
+*/
+
+#include "includes.h"
+#include "scripting/python/talloc.h"
+#include "Python.h"
+#include "librpc/ndr/libndr.h"
+
+static PyObject *uuid_random(PyObject *self, PyObject *args)
+{
+       struct GUID guid;
+       char *str;
+
+       if (!PyArg_ParseTuple(args, ""))
+               return NULL;
+
+       guid = GUID_random();
+
+       str = GUID_string(PyMemCtx(), &guid);
+       if (str == NULL) {
+               PyErr_SetString(PyExc_TypeError, "can't convert uuid to 
string");
+               return NULL;
+       }
+
+       talloc_free(str);
+
+       return PyString_FromString(str);
+}
+
+static PyMethodDef methods[] = {
+       { "random", (PyCFunction)uuid_random, METH_VARARGS, NULL},
+       { NULL, NULL }
+};
+
+PyDoc_STRVAR(param_doc, "UUID helper routines");
+
+PyMODINIT_FUNC inituuid(void)
+{
+       PyObject *mod = Py_InitModule3("uuid", methods, param_doc);
+       if (mod == NULL)
+               return;
+}

Modified: branches/4.0-python/source/setup/provision
===================================================================
--- branches/4.0-python/source/setup/provision  2007-09-27 01:26:19 UTC (rev 
25370)
+++ branches/4.0-python/source/setup/provision  2007-09-27 01:31:43 UTC (rev 
25371)
@@ -5,7 +5,7 @@
 #      Released under the GNU GPL v2 or later
 #
 
-from samba import getopt
+import getopt
 import optparse
 import sys
 

Reply via email to