
/* Python wrapper functions auto-generated by pidl */
#include <Python.h>
#include "includes.h"
#include <pytalloc.h>
#include "librpc/rpc/pyrpc.h"
#include "librpc/rpc/pyrpc_util.h"
#include "librpc/gen_ndr/ndr_file_id.h"
#include "librpc/gen_ndr/ndr_file_id_c.h"

staticforward PyTypeObject file_id_Type;

void initfile_id(void);static PyTypeObject *Object_Type;

static PyObject *py_file_id_get_devid(PyObject *obj, void *closure)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(obj);
	PyObject *py_devid;
	py_devid = PyLong_FromLongLong(object->devid);
	return py_devid;
}

static int py_file_id_set_devid(PyObject *py_obj, PyObject *value, void *closure)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(py_obj);
	if (PyLong_Check(value)) {
		object->devid = PyLong_AsLongLong(value);
	} else if (PyInt_Check(value)) {
		object->devid = PyInt_AsLong(value);
	} else {
		PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
		  PyInt_Type.tp_name, PyLong_Type.tp_name);
		return -1;
	}
	return 0;
}

static PyObject *py_file_id_get_inode(PyObject *obj, void *closure)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(obj);
	PyObject *py_inode;
	py_inode = PyLong_FromLongLong(object->inode);
	return py_inode;
}

static int py_file_id_set_inode(PyObject *py_obj, PyObject *value, void *closure)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(py_obj);
	if (PyLong_Check(value)) {
		object->inode = PyLong_AsLongLong(value);
	} else if (PyInt_Check(value)) {
		object->inode = PyInt_AsLong(value);
	} else {
		PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
		  PyInt_Type.tp_name, PyLong_Type.tp_name);
		return -1;
	}
	return 0;
}

static PyObject *py_file_id_get_extid(PyObject *obj, void *closure)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(obj);
	PyObject *py_extid;
	py_extid = PyLong_FromLongLong(object->extid);
	return py_extid;
}

static int py_file_id_set_extid(PyObject *py_obj, PyObject *value, void *closure)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(py_obj);
	if (PyLong_Check(value)) {
		object->extid = PyLong_AsLongLong(value);
	} else if (PyInt_Check(value)) {
		object->extid = PyInt_AsLong(value);
	} else {
		PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
		  PyInt_Type.tp_name, PyLong_Type.tp_name);
		return -1;
	}
	return 0;
}

static PyGetSetDef py_file_id_getsetters[] = {
	{ discard_const_p(char, "devid"), py_file_id_get_devid, py_file_id_set_devid },
	{ discard_const_p(char, "inode"), py_file_id_get_inode, py_file_id_set_inode },
	{ discard_const_p(char, "extid"), py_file_id_get_extid, py_file_id_set_extid },
	{ NULL }
};

static PyObject *py_file_id_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
	return py_talloc_new(struct file_id, type);
}

static PyObject *py_file_id_ndr_pack(PyObject *py_obj)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(py_obj);
	DATA_BLOB blob;
	enum ndr_err_code err;
	err = ndr_push_struct_blob(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_push_flags_fn_t)ndr_push_file_id);
	if (err != NDR_ERR_SUCCESS) {
		PyErr_SetNdrError(err);
		return NULL;
	}

	return PyString_FromStringAndSize((char *)blob.data, blob.length);
}

static PyObject *py_file_id_ndr_unpack(PyObject *py_obj, PyObject *args)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(py_obj);
	DATA_BLOB blob;
	enum ndr_err_code err;
	if (!PyArg_ParseTuple(args, "s#:__ndr_unpack__", &blob.data, &blob.length))
		return NULL;

	err = ndr_pull_struct_blob_all(&blob, py_talloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_file_id);
	if (err != NDR_ERR_SUCCESS) {
		PyErr_SetNdrError(err);
		return NULL;
	}

	Py_RETURN_NONE;
}

static PyObject *py_file_id_ndr_print(PyObject *py_obj)
{
	struct file_id *object = (struct file_id *)py_talloc_get_ptr(py_obj);
	PyObject *ret;
	char *retstr;

	retstr = ndr_print_struct_string(py_talloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_file_id, "file_id", object);
	ret = PyString_FromString(retstr);
	talloc_free(retstr);

	return ret;
}

static PyMethodDef py_file_id_methods[] = {
	{ "__ndr_pack__", (PyCFunction)py_file_id_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
	{ "__ndr_unpack__", (PyCFunction)py_file_id_ndr_unpack, METH_VARARGS, "S.ndr_unpack(class, blob) -> None\nNDR unpack" },
	{ "__ndr_print__", (PyCFunction)py_file_id_ndr_print, METH_VARARGS, "S.ndr_print(object) -> None\nNDR print" },
	{ NULL, NULL, 0, NULL }
};


static PyTypeObject file_id_Type = {
	PyObject_HEAD_INIT(NULL) 0,
	.tp_name = "file_id.file_id",
	.tp_getset = py_file_id_getsetters,
	.tp_methods = py_file_id_methods,
	.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
	.tp_basicsize = sizeof(py_talloc_Object),
	.tp_new = py_file_id_new,
};

static PyMethodDef file_id_methods[] = {
	{ NULL, NULL, 0, NULL }
};

void initfile_id(void)
{
	PyObject *m;
	PyObject *dep_talloc;

	dep_talloc = PyImport_ImportModule("talloc");
	if (dep_talloc == NULL)
		return;

	Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
	if (Object_Type == NULL)
		return;

	file_id_Type.tp_base = Object_Type;

	if (PyType_Ready(&file_id_Type) < 0)
		return;
#ifdef PY_FILE_ID_PATCH
	PY_FILE_ID_PATCH(&file_id_Type);
#endif

	m = Py_InitModule3("file_id", file_id_methods, "file_id DCE/RPC");
	if (m == NULL)
		return;

	Py_INCREF((PyObject *)(void *)&file_id_Type);
	PyModule_AddObject(m, "file_id", (PyObject *)(void *)&file_id_Type);
#ifdef PY_MOD_FILE_ID_PATCH
	PY_MOD_FILE_ID_PATCH(m);
#endif

}
