2005-12-19 16:34:11 +00:00
|
|
|
/*
|
|
|
|
* types.c: converter functions between the internal representation
|
|
|
|
* and the Python objects
|
|
|
|
*
|
2007-12-07 10:08:06 +00:00
|
|
|
* Copyright (C) 2005, 2007 Red Hat, Inc.
|
2005-12-19 16:34:11 +00:00
|
|
|
*
|
|
|
|
* Daniel Veillard <veillard@redhat.com>
|
|
|
|
*/
|
|
|
|
|
2007-12-07 10:08:06 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2006-02-09 17:45:11 +00:00
|
|
|
#include "libvirt_wrap.h"
|
2005-12-19 16:34:11 +00:00
|
|
|
|
|
|
|
PyObject *
|
2006-02-09 17:45:11 +00:00
|
|
|
libvirt_intWrap(int val)
|
2005-12-19 16:34:11 +00:00
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2006-02-09 17:45:11 +00:00
|
|
|
printf("libvirt_intWrap: val = %d\n", val);
|
2005-12-19 16:34:11 +00:00
|
|
|
#endif
|
|
|
|
ret = PyInt_FromLong((long) val);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
2006-02-09 17:45:11 +00:00
|
|
|
libvirt_longWrap(long val)
|
2005-12-19 16:34:11 +00:00
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2006-02-09 17:45:11 +00:00
|
|
|
printf("libvirt_longWrap: val = %ld\n", val);
|
2005-12-19 16:34:11 +00:00
|
|
|
#endif
|
|
|
|
ret = PyInt_FromLong(val);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2006-11-15 19:40:00 +00:00
|
|
|
PyObject *
|
|
|
|
libvirt_ulongWrap(unsigned long val)
|
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("libvirt_ulongWrap: val = %lu\n", val);
|
|
|
|
#endif
|
|
|
|
ret = PyLong_FromLong(val);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2006-01-31 10:24:12 +00:00
|
|
|
PyObject *
|
2006-02-09 17:45:11 +00:00
|
|
|
libvirt_longlongWrap(long long val)
|
2006-01-31 10:24:12 +00:00
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2006-02-09 17:45:11 +00:00
|
|
|
printf("libvirt_longWrap: val = %ld\n", val);
|
2006-01-31 10:24:12 +00:00
|
|
|
#endif
|
|
|
|
ret = PyLong_FromUnsignedLongLong((unsigned long long) val);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2005-12-19 16:34:11 +00:00
|
|
|
PyObject *
|
2006-02-09 17:45:11 +00:00
|
|
|
libvirt_charPtrWrap(char *str)
|
2005-12-19 16:34:11 +00:00
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
if (str == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return (Py_None);
|
|
|
|
}
|
2007-06-15 08:18:55 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("libvirt_xmlcharPtrWrap: str = %s\n", str);
|
|
|
|
#endif
|
2005-12-19 16:34:11 +00:00
|
|
|
ret = PyString_FromString(str);
|
|
|
|
free(str);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
2006-02-09 17:45:11 +00:00
|
|
|
libvirt_constcharPtrWrap(const char *str)
|
2005-12-19 16:34:11 +00:00
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
if (str == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return (Py_None);
|
|
|
|
}
|
2007-06-15 08:18:55 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("libvirt_xmlcharPtrWrap: str = %s\n", str);
|
|
|
|
#endif
|
2005-12-19 16:34:11 +00:00
|
|
|
ret = PyString_FromString(str);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
2006-02-09 17:45:11 +00:00
|
|
|
libvirt_charPtrConstWrap(const char *str)
|
2005-12-19 16:34:11 +00:00
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
if (str == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return (Py_None);
|
|
|
|
}
|
2007-06-15 08:18:55 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
printf("libvirt_xmlcharPtrWrap: str = %s\n", str);
|
|
|
|
#endif
|
2005-12-19 16:34:11 +00:00
|
|
|
ret = PyString_FromString(str);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
2006-02-09 17:45:11 +00:00
|
|
|
libvirt_virDomainPtrWrap(virDomainPtr node)
|
2005-12-19 16:34:11 +00:00
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2006-02-09 17:45:11 +00:00
|
|
|
printf("libvirt_virDomainPtrWrap: node = %p\n", node);
|
2005-12-19 16:34:11 +00:00
|
|
|
#endif
|
|
|
|
if (node == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return (Py_None);
|
|
|
|
}
|
|
|
|
ret =
|
|
|
|
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virDomainPtr",
|
|
|
|
NULL);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2007-03-09 15:42:50 +00:00
|
|
|
PyObject *
|
|
|
|
libvirt_virNetworkPtrWrap(virNetworkPtr node)
|
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
printf("libvirt_virNetworkPtrWrap: node = %p\n", node);
|
|
|
|
#endif
|
|
|
|
if (node == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return (Py_None);
|
|
|
|
}
|
|
|
|
ret =
|
|
|
|
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virNetworkPtr",
|
|
|
|
NULL);
|
|
|
|
return (ret);
|
|
|
|
}
|
|
|
|
|
2005-12-19 16:34:11 +00:00
|
|
|
PyObject *
|
2006-02-09 17:45:11 +00:00
|
|
|
libvirt_virConnectPtrWrap(virConnectPtr node)
|
2005-12-19 16:34:11 +00:00
|
|
|
{
|
|
|
|
PyObject *ret;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2006-02-09 17:45:11 +00:00
|
|
|
printf("libvirt_virConnectPtrWrap: node = %p\n", node);
|
2005-12-19 16:34:11 +00:00
|
|
|
#endif
|
|
|
|
if (node == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return (Py_None);
|
|
|
|
}
|
|
|
|
ret =
|
|
|
|
PyCObject_FromVoidPtrAndDesc((void *) node, (char *) "virConnectPtr",
|
|
|
|
NULL);
|
|
|
|
return (ret);
|
|
|
|
}
|