summaryrefslogtreecommitdiffstats
path: root/contrib/python-uuid/uuid.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:49:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:49:25 +0000
commit464df1d5e5ab1322e2dd0a7796939fff1aeefa9a (patch)
tree6a403684e0978f0287d7f0ec0e5aab1fd31a59e1 /contrib/python-uuid/uuid.c
parentInitial commit. (diff)
downloade2fsprogs-464df1d5e5ab1322e2dd0a7796939fff1aeefa9a.tar.xz
e2fsprogs-464df1d5e5ab1322e2dd0a7796939fff1aeefa9a.zip
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'contrib/python-uuid/uuid.c')
-rw-r--r--contrib/python-uuid/uuid.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/contrib/python-uuid/uuid.c b/contrib/python-uuid/uuid.c
new file mode 100644
index 0000000..34dd56a
--- /dev/null
+++ b/contrib/python-uuid/uuid.c
@@ -0,0 +1,23 @@
+#include <Python.h>
+#include <time.h>
+#include <uuid/uuid.h>
+
+static PyObject * _uuid_generate(PyObject *self, PyObject *args)
+{
+ uuid_t u;
+ char uuid[37];
+ if (!PyArg_ParseTuple(args, "")) return NULL;
+ uuid_generate(u);
+ uuid_unparse(u, uuid);
+ return Py_BuildValue("s", uuid);
+}
+
+static PyMethodDef _uuid_methods[] = {
+ {"generate", _uuid_generate, METH_VARARGS, "Generate UUID"},
+ {NULL, NULL, 0, NULL}
+};
+
+void inite2fsprogs_uuid(void)
+{
+ (void) Py_InitModule("e2fsprogs_uuid", _uuid_methods);
+}