Changeset 4037 for neercs/trunk
- Timestamp:
- Nov 25, 2009, 1:36:22 PM (12 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/interpreter.c
r4035 r4037 161 161 } 162 162 163 if (screen_list->interpreter_props.output )163 if (screen_list->interpreter_props.output_err) 164 164 { 165 165 caca_set_color_ansi(screen_list->cv, CACA_RED, CACA_BLUE); 166 166 caca_printf(screen_list->cv, x + 2, y + 4, 167 screen_list->interpreter_props.output); 168 } 169 167 screen_list->interpreter_props.output_err); 168 } 169 if (screen_list->interpreter_props.output_res) 170 { 171 caca_set_color_ansi(screen_list->cv, CACA_LIGHTGREEN, CACA_BLUE); 172 caca_printf(screen_list->cv, x + 2, y + 4, 173 screen_list->interpreter_props.output_res); 174 } 170 175 } 171 176 … … 173 178 int python_init(struct screen_list *sl) 174 179 { 175 sl->interpreter_props.output = NULL; 180 sl->interpreter_props.output_err = NULL; 181 sl->interpreter_props.output_res = NULL; 176 182 Py_Initialize(); 177 183 … … 183 189 int python_close(struct screen_list *sl) 184 190 { 185 if (sl->interpreter_props.output) 186 free(sl->interpreter_props.output); 187 sl->interpreter_props.output = NULL; 191 if (sl->interpreter_props.output_err) 192 free(sl->interpreter_props.output_err); 193 if (sl->interpreter_props.output_res) 194 free(sl->interpreter_props.output_res); 195 sl->interpreter_props.output_err = NULL; 196 sl->interpreter_props.output_res = NULL; 188 197 Py_Finalize(); 189 198 return 0; … … 199 208 debug("py Executing '%s'\n", sl->interpreter_props.command); 200 209 201 if (sl->interpreter_props.output) 202 { 203 // FIXME free(sl->interpreter_props.output); 204 sl->interpreter_props.output = NULL; 205 } 206 210 if (sl->interpreter_props.output_err) 211 { 212 free(sl->interpreter_props.output_err); 213 sl->interpreter_props.output_err = NULL; 214 } 215 if (sl->interpreter_props.output_res) 216 { 217 free(sl->interpreter_props.output_res); 218 sl->interpreter_props.output_res = NULL; 219 } 220 207 221 PyObject *pModule, *pName, *pFunc, *pValue; 208 222 … … 211 225 if (!pName) 212 226 { 213 sl->interpreter_props.output = getPythonError();227 sl->interpreter_props.output_err = getPythonError(); 214 228 err = 1; 215 229 debug("py Error 1\n"); … … 228 242 if (pValue != NULL) { 229 243 char *res = getStringFromPyObject(pValue); 230 sl->interpreter_props.output = res;244 sl->interpreter_props.output_res = res; 231 245 debug("py Result of call: %s\n", res); 232 246 Py_DECREF(pValue); 247 err = 2; 233 248 } 234 249 else { 235 250 Py_DECREF(pFunc); 236 251 Py_DECREF(pModule); 237 sl->interpreter_props.output = getPythonError();252 sl->interpreter_props.output_err = getPythonError(); 238 253 err = 1; 239 254 debug("py Call failed\n"); … … 244 259 else 245 260 { 246 sl->interpreter_props.output = getPythonError();261 sl->interpreter_props.output_err = getPythonError(); 247 262 err = 1; 248 263 debug("py Error 2\n"); … … 252 267 else 253 268 { 254 sl->interpreter_props.output = getPythonError();269 sl->interpreter_props.output_err = getPythonError(); 255 270 err = 1; 256 debug("py: %s\n", sl->interpreter_props.output );271 debug("py: %s\n", sl->interpreter_props.output_err); 257 272 goto end; 258 273 } … … 287 302 char *evalue = getStringFromPyObject(value); 288 303 289 int r = asprintf(&err, " Error in %s : %s", etype, evalue);304 int r = asprintf(&err, "%s", evalue); 290 305 (void)r; 291 306 return err; … … 297 312 char *err = PyBytes_AS_STRING(PyUnicode_AsEncodedString(str, "utf-8", 298 313 "Error ~")); 299 return err; 314 315 char *ret = strdup(err); 316 return ret; 300 317 } 301 318 -
neercs/trunk/src/neercs.h
r4033 r4037 150 150 int size; 151 151 char *command; 152 char *output; 152 char *output_err; 153 char *output_res; 153 154 }; 154 155
Note: See TracChangeset
for help on using the changeset viewer.