Changeset 624:a5682d003ed9 in freeDiameter for extensions/dbg_interactive/dbg_interactive.c
- Timestamp:
- Dec 9, 2010, 5:14:24 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/dbg_interactive/dbg_interactive.c
r621 r624 38 38 39 39 /* wrapper generated by SWIG */ 40 extern void init_diwrap(void); 40 #if PY_VERSION_HEX >= 0x03000000 41 extern void PyInit__fDpy(void); 42 #define WRAPPER_INIT PyInit__fDpy() 43 #else /* PY_VERSION_HEX */ 44 extern void init_fDpy(void); 45 #define WRAPPER_INIT init_fDpy() 46 #endif /* PY_VERSION_HEX */ 47 48 /* The string created in the shadow proxy C string file */ 49 extern unsigned char fDpy_py[]; 50 extern unsigned int fDpy_py_len; 41 51 42 52 /* Run an interactive interpreter in a separate thread */ … … 63 73 static int di_main(char * conffile) 64 74 { 75 char * shadow_hlp = NULL; 76 int mustfree = 0; 65 77 TRACE_ENTRY("%p", conffile); 66 78 67 79 Py_Initialize(); 68 80 69 #if PY_VERSION_HEX >= 0x03000000 70 PyInit__diwrap(); 71 #else /* PY_VERSION_HEX */ 72 init_diwrap(); 73 #endif /* PY_VERSION_HEX */ 81 WRAPPER_INIT; 74 82 75 /* In future version, it might be better to use the diwrap.py file generated by SWIG here to get the proxy classes definitions */ 76 PyRun_SimpleString("from _diwrap import *\n"); 83 /* Small hack to avoid duplicating the string, we replace the last char by a \0. 84 It works if the python file is terminated with several \n */ 85 if ( (fDpy_py[fDpy_py_len - 2] == '\n') 86 && (fDpy_py[fDpy_py_len - 1] == '\n')) { 87 fDpy_py[fDpy_py_len - 1] = '\0'; 88 shadow_hlp = (char *)&fDpy_py[0]; 89 } else { 90 CHECK_MALLOC(shadow_hlp = malloc(fDpy_py_len + 1)); 91 memcpy(shadow_hlp, fDpy_py, fDpy_py_len); 92 shadow_hlp[fDpy_py_len] = '\0'; 93 mustfree=1; 94 } 95 96 PyRun_SimpleString("__file__ = \"\"\n"); 97 PyRun_SimpleString(shadow_hlp); 98 99 if (mustfree) 100 free(shadow_hlp); 101 102 77 103 if (TRACE_BOOL(INFO)) { 78 104 PyRun_SimpleString("print \"[dbg_interactive] \",FD_PROJECT_NAME,FD_PROJECT_VERSION_MAJOR,FD_PROJECT_VERSION_MINOR,FD_PROJECT_VERSION_REV\n");
Note: See TracChangeset
for help on using the changeset viewer.