Changeset 4038
- Timestamp:
- Nov 25, 2009, 4:07:46 PM (14 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/configuration.c
r4022 r4038 67 67 get_window_manager}, 68 68 {.name = "socket_dir",.set = set_socket_dir,.get = get_window_manager}, 69 {.name = "delay",.set = set_delay,.get = NULL},69 {.name = "delay",.set = set_delay,.get = get_delay}, 70 70 71 71 {.name = "last",.set = NULL}, … … 322 322 { 323 323 int i = 0; 324 325 debug("Looking for '%s'\n", name); 326 324 327 while (strncmp(config_option[i].name, "last", strlen("last"))) 325 328 { 329 debug("%d Testing against '%s'\n", i, config_option[i].name); 326 330 if (!strncmp(name, config_option[i].name, strlen(name))) 327 331 { … … 476 480 char *get_window_manager(struct screen_list *screen_list) 477 481 { 482 debug("Window manager is %d\n", screen_list->wm_type); 478 483 switch (screen_list->wm_type) 479 484 { … … 487 492 return "hsplit"; 488 493 default: 489 return "invalid ";494 return "invalid window manager"; 490 495 } 491 496 return NULL; /* Not reached */ -
neercs/trunk/src/interpreter.c
r4037 r4038 182 182 Py_Initialize(); 183 183 184 PyInit_neercs( );184 PyInit_neercs(sl); 185 185 186 186 return 0; … … 219 219 } 220 220 221 PyObject *pModule, *pName, *pFunc , *pValue;221 PyObject *pModule, *pName, *pFunc; 222 222 223 223 /* Module from which to call the function */ … … 236 236 if (pModule != NULL) 237 237 { 238 pFunc = PyObject_GetAttrString(pModule, sl->interpreter_props.command); 239 if (pFunc && PyCallable_Check(pFunc)) 238 PyObject *o = PyRun_String(sl->interpreter_props.command, Py_eval_input, PyModule_GetDict(pModule), NULL); 239 debug("py object is %p\n", o); 240 if(!o) 240 241 { 241 pValue = PyObject_CallObject(pFunc, NULL); 242 if (pValue != NULL) { 243 char *res = getStringFromPyObject(pValue); 244 sl->interpreter_props.output_res = res; 245 debug("py Result of call: %s\n", res); 246 Py_DECREF(pValue); 247 err = 2; 248 } 249 else { 250 Py_DECREF(pFunc); 251 Py_DECREF(pModule); 252 sl->interpreter_props.output_err = getPythonError(); 253 err = 1; 254 debug("py Call failed\n"); 255 goto end; 256 return 1; 257 } 242 sl->interpreter_props.output_err = getPythonError(); 243 err = 1; 258 244 } 259 245 else 260 246 { 261 sl->interpreter_props.output_err = getPythonError(); 247 debug("py res : %s\n", getStringFromPyObject(o)); 248 sl->interpreter_props.output_res = getStringFromPyObject(o); 262 249 err = 1; 263 debug("py Error 2\n");264 goto end;265 250 } 251 goto end; 252 266 253 } 267 254 else … … 299 286 PyErr_Fetch(&type, &value, &traceback); 300 287 301 char *etype = getStringFromPyObject(type);302 288 char *evalue = getStringFromPyObject(value); 303 289 -
neercs/trunk/src/neercs.h
r4037 r4038 14 14 */ 15 15 16 #ifndef _NEERCS_H_ 17 #define _NEERCS_H_ 18 16 19 #include <stdint.h> 17 18 20 #include <caca.h> 19 21 … … 361 363 int get_key_value(char *line, struct option *option); 362 364 int fill_config(struct screen_list *screen_list); 363 365 struct config_line *get_config(const char *name); 364 366 365 367 /* Python interpreter */ … … 386 388 # define debug(format, ...) do {} while(0) 387 389 #endif 388 390 #endif /* _NEERCS_H_ */ -
neercs/trunk/src/py_module.c
r4035 r4038 37 37 #include "neercs.h" 38 38 39 /* FIXME : Find a way to pass a user pointer to PyModuleDef or something */ 40 struct screen_list *screen_list; 41 42 static PyObject* 43 neercs_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 } 39 64 40 65 static PyObject* … … 47 72 48 73 static 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."}, 51 76 {NULL, NULL, 0, NULL} 52 77 }; … … 57 82 }; 58 83 59 PyObject* PyInit_neercs( void)84 PyObject* PyInit_neercs(struct screen_list* sl) 60 85 { 86 screen_list = sl; 61 87 PyObject* o = PyModule_Create(&NeercsModule); 62 88 PyImport_AppendInittab("neercs", &PyInit_neercs); -
neercs/trunk/src/py_module.h
r4035 r4038 18 18 19 19 #include <Python.h> 20 #include "neercs.h" 20 21 21 PyObject* PyInit_neercs( void);22 PyObject* PyInit_neercs(struct screen_list* sl); 22 23 23 24 -
neercs/trunk/src/server.c
r4033 r4038 385 385 { 386 386 int i; 387 debug("Screen list at %p\n", screen_list); 388 387 389 /* Create socket and bind it */ 388 390 create_socket(screen_list, SOCK_SERVER);
Note: See TracChangeset
for help on using the changeset viewer.