Ignore:
Timestamp:
Nov 25, 2009, 4:07:46 PM (10 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Better python command handling
  • Added get(str) to neercs python module, doesn't work as I would like to
  • Avoid redefining everything while including neercs.h several times
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/py_module.c

    r4035 r4038  
    3737#include "neercs.h"
    3838
     39/* FIXME : Find a way to pass a user pointer to PyModuleDef or something */
     40struct screen_list *screen_list;
     41
     42static PyObject*
     43neercs_get(PyObject *self, PyObject *args)
     44{
     45    char *s = NULL;
     46   
     47    debug("Get using list at %p\n", screen_list);
     48   
     49    if(!PyArg_ParseTuple(args, "s", &s))
     50    {
     51        debug("py Can't parse\n");
     52        return NULL;
     53    }
     54    debug("py Argument : '%s'\n", s);
     55    struct config_line *c = get_config(s);
     56    debug("py config %p\n");
     57   
     58    if(c)
     59        return Py_BuildValue("s", c->get(screen_list));
     60    else
     61        return Py_BuildValue("s", "Invalid");
     62
     63}
    3964
    4065static PyObject*
     
    4772
    4873static PyMethodDef NeercsMethods[] = {
    49     {"version", neercs_version, METH_VARARGS,
    50         "Return the neercs version."},
     74    {"version", neercs_version, METH_VARARGS,  "Return the neercs version."},
     75    {"get", neercs_get, METH_VARARGS,  "Return the specified variable's value."},
    5176    {NULL, NULL, 0, NULL}
    5277};
     
    5782};
    5883
    59 PyObject* PyInit_neercs(void)
     84PyObject* PyInit_neercs(struct screen_list* sl)
    6085{
     86    screen_list = sl;
    6187    PyObject* o =  PyModule_Create(&NeercsModule);
    6288    PyImport_AppendInittab("neercs", &PyInit_neercs);
Note: See TracChangeset for help on using the changeset viewer.