id128.c revision 5afbe712db5cc68213a24c45396ffb43fab05e3e
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2013 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <Python.h>
#include <systemd/sd-messages.h>
#include "pyutil.h"
"Python interface to the libsystemd-id128 library.\n\n"
"Provides SD_MESSAGE_* constants and functions to query and generate\n"
"128-bit unique identifiers."
);
"randomize() -> UUID\n\n"
"Return a new random 128-bit unique identifier.\n"
"Wraps sd_id128_randomize(3)."
);
"get_machine() -> UUID\n\n"
"Return a 128-bit unique identifier for this machine.\n"
"Wraps sd_id128_get_machine(3)."
);
"get_boot() -> UUID\n\n"
"Return a 128-bit unique identifier for this boot.\n"
"Wraps sd_id128_get_boot(3)."
);
if (!uuid)
return NULL;
kwargs = PyDict_New();
return NULL;
return NULL;
}
sd_id128_t id; \
int r; \
\
\
if (r < 0) { \
errno = -r; \
return PyErr_SetFromErrno(PyExc_IOError); \
} \
\
}
static PyMethodDef methods[] = {
};
if (!obj)
return -1;
}
#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC initid128(void) {
PyObject *m;
if (m == NULL)
return;
/* a series of lines like 'add_id() ;' follow */
#define JOINER ;
#include "id128-constants.h"
}
#else
static struct PyModuleDef module = {
"id128", /* name of module */
module__doc__, /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module */
};
PyMODINIT_FUNC PyInit_id128(void) {
PyObject *m;
m = PyModule_Create(&module);
if (m == NULL)
return NULL;
if ( /* a series of lines like 'add_id() ||' follow */
#define JOINER ||
#include "id128-constants.h"
Py_DECREF(m);
return NULL;
}
return m;
}
#endif