2005-12-19 19:34:11 +03:00
/*
* types . c : converter functions between the internal representation
* and the Python objects
*
2007-12-07 13:08:06 +03:00
* Copyright ( C ) 2005 , 2007 Red Hat , Inc .
2005-12-19 19:34:11 +03:00
*
* Daniel Veillard < veillard @ redhat . com >
*/
2008-01-29 21:15:54 +03:00
# include <config.h>
2007-12-07 13:08:06 +03:00
2006-02-09 20:45:11 +03:00
# include "libvirt_wrap.h"
2005-12-19 19:34:11 +03:00
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_intWrap ( int val )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
# ifdef DEBUG
2006-02-09 20:45:11 +03:00
printf ( " libvirt_intWrap: val = %d \n " , val ) ;
2005-12-19 19:34:11 +03:00
# endif
ret = PyInt_FromLong ( ( long ) val ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_longWrap ( long val )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
# ifdef DEBUG
2006-02-09 20:45:11 +03:00
printf ( " libvirt_longWrap: val = %ld \n " , val ) ;
2005-12-19 19:34:11 +03:00
# endif
ret = PyInt_FromLong ( val ) ;
return ( ret ) ;
}
2006-11-15 22:40:00 +03: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 ) ;
2008-02-05 22:27:37 +03:00
}
2006-11-15 22:40:00 +03:00
2006-01-31 13:24:12 +03:00
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_longlongWrap ( long long val )
2006-01-31 13:24:12 +03:00
{
PyObject * ret ;
# ifdef DEBUG
2006-02-09 20:45:11 +03:00
printf ( " libvirt_longWrap: val = %ld \n " , val ) ;
2006-01-31 13:24:12 +03:00
# endif
ret = PyLong_FromUnsignedLongLong ( ( unsigned long long ) val ) ;
return ( ret ) ;
}
2005-12-19 19:34:11 +03:00
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_charPtrWrap ( char * str )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
2007-06-15 12:18:55 +04:00
# ifdef DEBUG
printf ( " libvirt_xmlcharPtrWrap: str = %s \n " , str ) ;
# endif
2005-12-19 19:34:11 +03:00
ret = PyString_FromString ( str ) ;
free ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_constcharPtrWrap ( const char * str )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
2007-06-15 12:18:55 +04:00
# ifdef DEBUG
printf ( " libvirt_xmlcharPtrWrap: str = %s \n " , str ) ;
# endif
2005-12-19 19:34:11 +03:00
ret = PyString_FromString ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_charPtrConstWrap ( const char * str )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
if ( str = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
2007-06-15 12:18:55 +04:00
# ifdef DEBUG
printf ( " libvirt_xmlcharPtrWrap: str = %s \n " , str ) ;
# endif
2005-12-19 19:34:11 +03:00
ret = PyString_FromString ( str ) ;
return ( ret ) ;
}
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_virDomainPtrWrap ( virDomainPtr node )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
# ifdef DEBUG
2006-02-09 20:45:11 +03:00
printf ( " libvirt_virDomainPtrWrap: node = %p \n " , node ) ;
2005-12-19 19:34:11 +03: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 18:42:50 +03: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 ) ;
}
2008-02-20 18:26:22 +03:00
PyObject *
libvirt_virStoragePoolPtrWrap ( virStoragePoolPtr node )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libvirt_virStoragePoolPtrWrap: node = %p \n " , node ) ;
# endif
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virStoragePoolPtr " ,
NULL ) ;
return ( ret ) ;
}
PyObject *
libvirt_virStorageVolPtrWrap ( virStorageVolPtr node )
{
PyObject * ret ;
# ifdef DEBUG
printf ( " libvirt_virStorageVolPtrWrap: node = %p \n " , node ) ;
# endif
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virStorageVolPtr " ,
NULL ) ;
return ( ret ) ;
}
2005-12-19 19:34:11 +03:00
PyObject *
2006-02-09 20:45:11 +03:00
libvirt_virConnectPtrWrap ( virConnectPtr node )
2005-12-19 19:34:11 +03:00
{
PyObject * ret ;
# ifdef DEBUG
2006-02-09 20:45:11 +03:00
printf ( " libvirt_virConnectPtrWrap: node = %p \n " , node ) ;
2005-12-19 19:34:11 +03:00
# endif
if ( node = = NULL ) {
Py_INCREF ( Py_None ) ;
return ( Py_None ) ;
}
ret =
PyCObject_FromVoidPtrAndDesc ( ( void * ) node , ( char * ) " virConnectPtr " ,
NULL ) ;
return ( ret ) ;
}