From 33346eaee2add1bf9c801cf92f19664ffaa71f2b Mon Sep 17 00:00:00 2001 From: Jeff Armstrong Date: Tue, 12 Jul 2011 23:02:14 -0400 Subject: Added appl_write and basic resource functions. --- lib/py_aes.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'lib/py_aes.c') diff --git a/lib/py_aes.c b/lib/py_aes.c index e97f4d5..d4d315b 100644 --- a/lib/py_aes.c +++ b/lib/py_aes.c @@ -1,6 +1,8 @@ #include "ldg_Python.h" #include +extern PyObject *GEMError; + /* --- Application Library --- */ static PyObject* __CDECL py_appl_init(PyObject *self, PyObject *args) { @@ -18,6 +20,20 @@ int ret; return Py_BuildValue("i",ret); } +static PyObject* __CDECL py_appl_write(PyObject *self, PyObject *args) +{ +int ret; +int app_id; +char *message; +int msg_length; + + if(!PyArg_ParseTuple(args,"iiy*",&app_id,&msg_length,&message)) + return NULL; + + ret = appl_write(app_id,msg_length,message); + return Py_BuildValue("i",ret); +} + /* --- Forms Library --- */ static PyObject* __CDECL py_form_alert(PyObject *self, PyObject *args) { @@ -30,3 +46,36 @@ int x; x = form_alert(x,text); return Py_BuildValue("i",x); } + +/* --- Resources Library --- */ +static void __CDECL py_rsrc_load(PyObject *self, PyObject *args) +{ +char *file; +int x; + + if(!PyArg_ParseTuple(args,"s",&file)) + return NULL; + + if(rsrc_load(file) == 0) { + PyErr_SetString(GEMError,"Resource failed to load"); + return NULL; + } + return Py_BuildValue("i",x); +} + +static PyObject* __CDECL py_rsrc_gaddr(PyObject *self, PyObject *args) +{ +char *file; +int type, index; +void *gaddr; + + if(!PyArg_ParseTuple(args,"ii",&type,&index)) + return NULL; + + if(rsrc_gaddr(type,index,&gaddr) == 0) { + PyErr_SetString(GEMError,"Resource item was not found"); + return NULL; + } + + return PyCapsule_New(gaddr,NULL,NULL); +} -- cgit v1.2.3