1 /* libguestfs python bindings
2 * Copyright (C) 2009-2011 Red Hat Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #define PY_SSIZE_T_CLEAN 1
27 #if PY_VERSION_HEX < 0x02050000
28 typedef int Py_ssize_t;
29 #define PY_SSIZE_T_MAX INT_MAX
30 #define PY_SSIZE_T_MIN INT_MIN
33 #ifndef HAVE_PYCAPSULE_NEW
40 static inline guestfs_h *
41 get_handle (PyObject *obj)
44 assert (obj != Py_None);
45 #ifndef HAVE_PYCAPSULE_NEW
46 return ((Pyguestfs_Object *) obj)->g;
48 return (guestfs_h*) PyCapsule_GetPointer(obj, "guestfs_h");
52 static inline PyObject *
53 put_handle (guestfs_h *g)
56 #ifndef HAVE_PYCAPSULE_NEW
58 PyCObject_FromVoidPtrAndDesc ((void *) g, (char *) "guestfs_h", NULL);
60 return PyCapsule_New ((void *) g, "guestfs_h", NULL);
64 extern PyObject *py_guestfs_create (PyObject *self, PyObject *args);
65 extern PyObject *py_guestfs_close (PyObject *self, PyObject *args);
66 extern PyObject *py_guestfs_set_event_callback (PyObject *self, PyObject *args);
67 extern PyObject *py_guestfs_delete_event_callback (PyObject *self, PyObject *args);
69 #endif /* guestfs_py_h */