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