- Timestamp:
- Aug 22, 2005, 9:07:04 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cee/rappture_interface.h
r21 r47 26 26 27 27 PyObject* rpRemove (PyObject* lib, const char* path); 28 c onst char* rpXml (PyObject* lib);28 char* rpXml (PyObject* lib); 29 29 30 30 /* -
trunk/src/cee/rappture_interface.c
r28 r47 722 722 * NULL will be returned. 723 723 * 724 * Returns pointer (c onst char*) to the c style string representing the724 * Returns pointer (char*) to the c style string representing the 725 725 * xml text of the Rappture object if successful, or 726 726 * NULL if something goes wrong. 727 727 * 728 * The return value's contents should not be changed because 729 * it is a pointer being borrowed from python's buffer space 730 * (hence the _const_) 731 */ 732 733 734 const char* rpXml(PyObject* lib) 728 * return value no longer needs to be const because i copy it 729 * to tmp space but it will need to be free'd now 730 */ 731 732 733 char* rpXml(PyObject* lib) 735 734 { 736 735 PyObject* mbr_fxn = NULL; /* pointer to fxn of class lib */ 737 736 PyObject* rslt = NULL; /* results from fxn call */ 737 char* tmpretVal = NULL; /* return value */ 738 738 char* retVal = NULL; /* return value */ 739 739 … … 750 750 if (rslt) { 751 751 // convert the result to c style strings 752 retVal = PyString_AsString(rslt); 752 tmpretVal = PyString_AsString(rslt); 753 retVal = (char*) calloc(strlen(tmpretVal),sizeof(char)); 754 strcpy(retVal,tmpretVal); 753 755 Py_DECREF(rslt); 754 756 } … … 762 764 } 763 765 764 return (const char*)retVal;766 return retVal; 765 767 766 768 } -
trunk/src/fortran/rappture_fortran.c
r29 r47 1176 1176 { 1177 1177 int length = -1; 1178 c onst char* xmlText = NULL;1178 char* xmlText = NULL; 1179 1179 1180 1180 PyObject* lib = NULL; … … 1190 1190 if (xmlText) { 1191 1191 length = strlen(xmlText) + 1; 1192 free(xmlText); 1192 1193 // printf("len = :%d:\n",length); 1193 1194 } … … 1203 1204 int length_out = 0; 1204 1205 int i = 0; 1205 c onst char* xmlText = NULL;1206 char* xmlText = NULL; 1206 1207 1207 1208 PyObject* lib = NULL; … … 1214 1215 xmlText = rpXml(lib); 1215 1216 1216 length_in = strlen(xmlText); 1217 length_out = retText_len; 1218 1219 strncpy(retText, xmlText, length_out); 1220 1221 // fortran-ify the string 1222 if (length_in < length_out) { 1223 for (i = length_in; i < length_out; i++) { 1224 retText[i] = ' '; 1225 } 1217 if (xmlText) { 1218 length_in = strlen(xmlText); 1219 length_out = retText_len; 1220 1221 strncpy(retText, xmlText, length_out); 1222 1223 // fortran-ify the string 1224 if (length_in < length_out) { 1225 for (i = length_in; i < length_out; i++) { 1226 retText[i] = ' '; 1227 } 1228 } 1229 *(retText+length_out-1) = ' '; 1230 1231 free(xmlText); 1226 1232 } 1227 *(retText+length_out-1) = ' ';1233 1228 1234 } 1229 1235 } … … 1233 1239 int rp_lib_write_xml(int* handle, char* outFile, int outFile_len) 1234 1240 { 1235 int retVal = 0;1241 int retVal = -1; 1236 1242 PyObject* lib = NULL; 1237 1243 FILE* outFH = NULL; 1238 1244 char* inOutFile = NULL; 1239 c onst char* xmlText = NULL;1245 char* xmlText = NULL; 1240 1246 1241 1247 inOutFile = null_terminate(outFile, outFile_len); … … 1251 1257 if (lib) { 1252 1258 xmlText = rpXml(lib); 1253 retVal = fputs(xmlText,outFH); 1259 if (xmlText) { 1260 retVal = fputs(xmlText,outFH); 1261 free(xmlText); 1262 } 1254 1263 } 1255 1264 }
Note: See TracChangeset
for help on using the changeset viewer.