rendered paste body#include <stdio.h>#include <python2.4/Python.h>#include <python2.4/structmember.h>#include <sane/sane.h>#ifndef SANEPYTHON#define SANEPYTHON 1/* SANEHandle type */typedef struct { PyObject_HEAD SANE_Handle *handle;} PySANEHandle;static void PySANEHandle_dealloc(PySANEHandle* self);static PyObject* PySANEHandle_new(PyTypeObject *type, PyObject *args, PyObject *kwds);static PyTypeObject PySANEHandleType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "sane.SANEHandle", /*tp_name*/ sizeof(PySANEHandle), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)PySANEHandle_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ "SANEHandle object", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ PySANEHandle_new, /* tp_new */};/* SANEOptionDescriptor type */typedef struct { PyObject_HEAD const SANE_Option_Descriptor *descriptor; int option; PyObject *name; PyObject *title; PyObject *description; int type; int unit; int size; int capabilities; int constraintType; PyObject *constraint;} PySANEOptionDescriptor;static void PySANEOptionDescriptor_dealloc(PySANEOptionDescriptor* self);static PyObject* PySANEOptionDescriptor_new(PyTypeObject *type, PyObject *args, PyObject *kwds);static PyObject* PySANEOptionDescriptor_FromDescriptor(int option, const SANE_Option_Descriptor *descriptor);static PyObject* PySANEOptionDescriptor_str(PySANEOptionDescriptor* self);static PyMethodDef PySANEOptionDescriptor_methods[] = { {NULL} /* Sentinel */};static PyMemberDef PySANEOptionDescriptor_members[] = { {"option", T_INT, offsetof(PySANEOptionDescriptor, option), 0, "This descriptor describes the option with this number."}, {"name", T_OBJECT_EX, offsetof(PySANEOptionDescriptor, name), 0, "The name of the option."}, {"title", T_OBJECT_EX, offsetof(PySANEOptionDescriptor, title), 0, "The title of the option."}, {"description", T_OBJECT_EX, offsetof(PySANEOptionDescriptor, description), 0, "A brief description of the option."}, {"type", T_INT, offsetof(PySANEOptionDescriptor, type), 0, "The option is of this type."}, {"unit", T_INT, offsetof(PySANEOptionDescriptor, unit), 0, "The option uses this unit of measurement."}, {"size", T_INT, offsetof(PySANEOptionDescriptor, size), 0, "The option has this size."}, {"capabilities", T_INT, offsetof(PySANEOptionDescriptor, capabilities), 0, "Return the capabilities of this option."}, {"constraintType", T_INT, offsetof(PySANEOptionDescriptor, constraintType), 0, "Return the constraint type, if any, of this option."}, {"constraint", T_OBJECT_EX, offsetof(PySANEOptionDescriptor, constraint), 0, "The constraints as described by contentType."}, {NULL} /* Sentinel */};static PyTypeObject PySANEOptionDescriptorType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "sane.SANEOptionDescriptor", /*tp_name*/ sizeof(PySANEOptionDescriptor), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)PySANEOptionDescriptor_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ (reprfunc) PySANEOptionDescriptor_str, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ "SANEOptionDescriptor object", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ PySANEOptionDescriptor_methods, /* tp_methods */ PySANEOptionDescriptor_members, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ PySANEOptionDescriptor_new, /* tp_new */};/* Parameters type */typedef struct { PyObject_HEAD /* int format; int last_frame; int lines; int depth; int pixels_per_line; int bytes_per_line; */} PySANEParameters;static void PySANEParameters_dealloc(PySANEParameters* self);static PyObject* PySANEParameters_new(PyTypeObject *type, PyObject *args, PyObject *kwds);static PyTypeObject PySANEParametersType = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "sane.SANEParameters", /*tp_name*/ sizeof(PySANEParameters), /*tp_basicsize*/ 0, /*tp_itemsize*/ (destructor)PySANEParameters_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash */ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ "SANEParameters object", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ PySANEParameters_new, /* tp_new */};/* The module */static PyObject* py_sane_init(PyObject *self, PyObject *args);static PyObject* py_sane_strstatus(PyObject *self, PyObject *args);static PyObject* py_sane_exit(PyObject *self, PyObject *args);static PyObject* py_sane_get_devices(PyObject *self, PyObject *args);static PyObject* py_sane_open(PyObject *self, PyObject *args);static PyObject* py_sane_close(PyObject *self, PyObject *args);static PyObject* py_sane_get_option_descriptor(PyObject *self, PyObject *args);static PyObject* py_sane_control_option(PyObject *self, PyObject *args);static PyObject* py_sane_control_option(PyObject *self, PyObject *args);static PyObject* py_sane_get_parameters(PyObject *self, PyObject *args);static PyMethodDef module_methods[] = { {"sane_init", py_sane_init, METH_VARARGS, "Initialize SANE."}, {"sane_strstatus", py_sane_strstatus, METH_VARARGS, "Return a string version of the status code."}, {"sane_exit", py_sane_exit, METH_NOARGS, "Exit SANE."}, {"sane_get_devices", py_sane_get_devices, METH_VARARGS, "Get a list of SANE devices."}, {"sane_open", py_sane_open, METH_VARARGS, "Open a SANE handle."}, {"sane_close", py_sane_close, METH_VARARGS, "Close a SANE handle."}, {"sane_get_option_descriptor", py_sane_get_option_descriptor, METH_VARARGS, "Set the descriptor for an option."}, {"sane_control_option", py_sane_control_option, METH_VARARGS, "Set or get a control option."}, {"sane_get_parameters", py_sane_get_parameters, METH_VARARGS, "Get the device parameters."}, {NULL, NULL, 0, NULL}};#endif