2007-11-21 15:07:16 +03:00
/*
Unix SMB / CIFS implementation .
Samba utility functions
Copyright ( C ) Jelmer Vernooij < jelmer @ samba . org > 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/>.
*/
2008-01-13 05:32:44 +03:00
# include <Python.h>
2009-10-23 09:23:01 +04:00
# include "includes.h"
2007-11-21 15:07:16 +03:00
# include "librpc/ndr/libndr.h"
static PyObject * uuid_random ( PyObject * self , PyObject * args )
{
struct GUID guid ;
2008-03-13 01:53:32 +03:00
PyObject * pyobj ;
2007-11-21 15:07:16 +03:00
char * str ;
2008-04-15 14:15:43 +04:00
if ( ! PyArg_ParseTuple ( args , " " ) )
2007-11-21 15:07:16 +03:00
return NULL ;
guid = GUID_random ( ) ;
str = GUID_string ( NULL , & guid ) ;
if ( str = = NULL ) {
PyErr_SetString ( PyExc_TypeError , " can't convert uuid to string " ) ;
return NULL ;
}
2008-03-13 01:53:32 +03:00
pyobj = PyString_FromString ( str ) ;
2007-11-21 15:07:16 +03:00
talloc_free ( str ) ;
2008-03-13 01:53:32 +03:00
return pyobj ;
2007-11-21 15:07:16 +03:00
}
static PyMethodDef methods [ ] = {
2008-05-11 05:31:26 +04:00
{ " uuid4 " , ( PyCFunction ) uuid_random , METH_VARARGS , NULL } ,
2007-11-21 15:07:16 +03:00
{ NULL , NULL }
} ;
2008-01-13 08:07:20 +03:00
void inituuid ( void )
2007-11-21 15:07:16 +03:00
{
2008-04-15 14:15:43 +04:00
PyObject * mod = Py_InitModule3 ( " uuid " , methods , " UUID helper routines " ) ;
2007-11-21 15:07:16 +03:00
if ( mod = = NULL )
return ;
}