[83] | 1 | /* |
---|
| 2 | * ---------------------------------------------------------------------- |
---|
| 3 | * INTERFACE: Fortran Rappture Library Source |
---|
| 4 | * |
---|
| 5 | * ====================================================================== |
---|
| 6 | * AUTHOR: Derrick Kearney, Purdue University |
---|
[591] | 7 | * Copyright (c) 2004-2007 Purdue Research Foundation |
---|
[115] | 8 | * |
---|
| 9 | * See the file "license.terms" for information on usage and |
---|
| 10 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
[83] | 11 | * ====================================================================== |
---|
| 12 | */ |
---|
| 13 | |
---|
[77] | 14 | #include "RpLibraryFInterface.h" |
---|
[93] | 15 | #include "RpBindingsDict.h" |
---|
[84] | 16 | #include "RpLibraryFStubs.c" |
---|
[1086] | 17 | #include "RpDXWriter.h" |
---|
[77] | 18 | |
---|
[119] | 19 | /**********************************************************************/ |
---|
| 20 | // FUNCTION: rp_lib(const char* filePath, int filePath_len) |
---|
| 21 | /// Open the file at 'filePath' and return Rappture Library Object. |
---|
| 22 | /** |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | int rp_lib(const char* filePath, int filePath_len) { |
---|
| 26 | |
---|
[77] | 27 | RpLibrary* lib = NULL; |
---|
| 28 | int handle = -1; |
---|
| 29 | std::string inFilePath = ""; |
---|
| 30 | |
---|
| 31 | inFilePath = null_terminate_str(filePath, filePath_len); |
---|
[83] | 32 | |
---|
[77] | 33 | // create a RapptureIO object and store in dictionary |
---|
| 34 | lib = new RpLibrary(inFilePath); |
---|
| 35 | |
---|
| 36 | if (lib) { |
---|
[1105] | 37 | handle = storeObject_Void((void*)lib); |
---|
[77] | 38 | } |
---|
| 39 | |
---|
| 40 | return handle; |
---|
| 41 | } |
---|
| 42 | |
---|
[119] | 43 | /**********************************************************************/ |
---|
| 44 | // FUNCTION: rp_lib_element_obj() |
---|
| 45 | /// Return the node located at 'path'. |
---|
| 46 | /** |
---|
| 47 | */ |
---|
[77] | 48 | int rp_lib_element_obj(int* handle, /* integer handle of library */ |
---|
| 49 | char* path, /* null terminated path */ |
---|
| 50 | int path_len |
---|
| 51 | ) |
---|
| 52 | { |
---|
| 53 | int newObjHandle = -1; |
---|
| 54 | |
---|
| 55 | std::string inPath = ""; |
---|
| 56 | |
---|
| 57 | RpLibrary* lib = NULL; |
---|
| 58 | RpLibrary* retObj = NULL; |
---|
| 59 | |
---|
| 60 | inPath = null_terminate_str(path,path_len); |
---|
| 61 | |
---|
| 62 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 63 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[77] | 64 | if (lib) { |
---|
| 65 | retObj = lib->element(inPath); |
---|
[83] | 66 | |
---|
[77] | 67 | if (retObj) { |
---|
[1105] | 68 | newObjHandle = storeObject_Void((void*)retObj); |
---|
[77] | 69 | } |
---|
| 70 | } |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | return newObjHandle; |
---|
| 74 | } |
---|
| 75 | |
---|
[119] | 76 | /**********************************************************************/ |
---|
| 77 | // FUNCTION: rp_lib_element_comp() |
---|
| 78 | /// Return the component name of the node located at 'path'. |
---|
| 79 | /** |
---|
| 80 | */ |
---|
[77] | 81 | void rp_lib_element_comp( int* handle, /* integer handle of library */ |
---|
| 82 | char* path, /* null terminated path */ |
---|
| 83 | char* retText, /* return buffer for fortran*/ |
---|
| 84 | int path_len, |
---|
| 85 | int retText_len /* length of return text buffer */ |
---|
| 86 | ) |
---|
| 87 | { |
---|
| 88 | std::string inPath = ""; |
---|
| 89 | RpLibrary* lib = NULL; |
---|
| 90 | std::string retStr = ""; |
---|
| 91 | |
---|
| 92 | inPath = null_terminate_str(path,path_len); |
---|
| 93 | |
---|
[1086] | 94 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[77] | 95 | |
---|
| 96 | if (lib) { |
---|
| 97 | retStr = lib->element(inPath)->nodeComp(); |
---|
| 98 | if (!retStr.empty()) { |
---|
| 99 | fortranify(retStr.c_str(),retText,retText_len); |
---|
| 100 | } |
---|
| 101 | } |
---|
[83] | 102 | |
---|
[77] | 103 | } |
---|
| 104 | |
---|
[119] | 105 | /**********************************************************************/ |
---|
| 106 | // FUNCTION: rp_lib_element_id() |
---|
| 107 | /// Return the 'id' of node located at 'path'. |
---|
| 108 | /** |
---|
| 109 | */ |
---|
| 110 | void rp_lib_element_id( int* handle, /* integer handle of library */ |
---|
| 111 | char* path, /* path of element within xml */ |
---|
| 112 | char* retText, /* return buffer for fortran */ |
---|
[77] | 113 | int path_len, |
---|
[119] | 114 | int retText_len /* length of return text buffer */ |
---|
[77] | 115 | ) |
---|
| 116 | { |
---|
| 117 | std::string inPath = ""; |
---|
| 118 | RpLibrary* lib = NULL; |
---|
| 119 | std::string retStr = ""; |
---|
| 120 | |
---|
| 121 | inPath = null_terminate_str(path,path_len); |
---|
| 122 | |
---|
[1086] | 123 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[77] | 124 | |
---|
| 125 | if (lib) { |
---|
| 126 | retStr = lib->element(inPath)->nodeId(); |
---|
| 127 | if (!retStr.empty()) { |
---|
| 128 | fortranify(retStr.c_str(),retText,retText_len); |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | } |
---|
| 132 | |
---|
[119] | 133 | /**********************************************************************/ |
---|
| 134 | // FUNCTION: rp_lib_element_type() |
---|
| 135 | /// Return the type of the node located at 'path'. |
---|
| 136 | /** |
---|
| 137 | */ |
---|
| 138 | void rp_lib_element_type( int* handle, /* integer handle of library */ |
---|
[83] | 139 | char* path, /* search path inside xml */ |
---|
[77] | 140 | char* retText, /* return buffer for fortran*/ |
---|
| 141 | int path_len, |
---|
[119] | 142 | int retText_len /* length of return text buffer */ |
---|
[77] | 143 | ) |
---|
| 144 | { |
---|
| 145 | std::string inPath = ""; |
---|
| 146 | RpLibrary* lib = NULL; |
---|
| 147 | std::string retStr = ""; |
---|
| 148 | |
---|
| 149 | inPath = null_terminate_str(path,path_len); |
---|
| 150 | |
---|
[1086] | 151 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[77] | 152 | |
---|
| 153 | if (lib) { |
---|
| 154 | retStr = lib->element(inPath)->nodeType(); |
---|
| 155 | fortranify(retStr.c_str(),retText,retText_len); |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | |
---|
[119] | 159 | /**********************************************************************/ |
---|
| 160 | // FUNCTION: rp_lib_children(const char* filePath, int filePath_len) |
---|
| 161 | /// Retrieve the next child of 'path' from the Rappture Library Object. |
---|
| 162 | /** |
---|
| 163 | */ |
---|
[83] | 164 | int rp_lib_children ( int* handle, /* integer handle of library */ |
---|
| 165 | char* path, /* search path of the xml */ |
---|
| 166 | int* childHandle, /*integer hanlde of last returned child*/ |
---|
| 167 | int path_len /* length of the search path buffer */ |
---|
| 168 | ) { |
---|
| 169 | |
---|
| 170 | std::string inPath = ""; |
---|
| 171 | RpLibrary* lib = NULL; |
---|
| 172 | RpLibrary* childNode = NULL; |
---|
| 173 | int newObjHandle = -1; |
---|
| 174 | |
---|
| 175 | inPath = null_terminate_str(path,path_len); |
---|
| 176 | |
---|
| 177 | if (handle && (*handle >= 0) ) { |
---|
[1086] | 178 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 179 | if (lib) { |
---|
[165] | 180 | |
---|
| 181 | if (*childHandle > 0) { |
---|
[83] | 182 | // check to see if there were any previously returned children |
---|
[1086] | 183 | childNode = (RpLibrary*) getObject_Void(*childHandle); |
---|
[83] | 184 | } |
---|
| 185 | |
---|
| 186 | // call the children base method |
---|
[165] | 187 | childNode = lib->children(inPath,childNode); |
---|
[83] | 188 | |
---|
| 189 | // store the childNode in the dictionary. |
---|
| 190 | // |
---|
| 191 | // because the base method is using static memory to get store the |
---|
[165] | 192 | // children we should be able to check and see if the childHandle |
---|
| 193 | // was valid. |
---|
[83] | 194 | // if so, then we can just return the childHandle back to the user |
---|
| 195 | // if not, store the object in the dictionary and return the new |
---|
| 196 | // handle. |
---|
| 197 | |
---|
| 198 | if (childNode) { |
---|
| 199 | if (*childHandle < 1) { |
---|
[1105] | 200 | newObjHandle = storeObject_Void((void*)childNode); |
---|
[83] | 201 | } |
---|
| 202 | else { |
---|
[1105] | 203 | newObjHandle = storeObject_Void((void*)childNode,*childHandle); |
---|
[83] | 204 | } |
---|
| 205 | } |
---|
| 206 | } |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | return newObjHandle; |
---|
| 210 | |
---|
| 211 | } |
---|
| 212 | |
---|
[119] | 213 | /**********************************************************************/ |
---|
[122] | 214 | // FUNCTION: rp_lib_get() |
---|
[119] | 215 | /// Get data located at 'path' and return it as a string value. |
---|
| 216 | /** |
---|
| 217 | */ |
---|
[2549] | 218 | void |
---|
| 219 | rp_lib_get( |
---|
| 220 | int* handle, /* integer handle of library */ |
---|
| 221 | char* path, /* null terminated path */ |
---|
| 222 | char* retText, /* return text buffer for fortran*/ |
---|
[2555] | 223 | int path_len, |
---|
[2549] | 224 | int retText_len) /* length of return text buffer */ |
---|
[77] | 225 | { |
---|
| 226 | std::string xmlText = ""; |
---|
| 227 | |
---|
| 228 | RpLibrary* lib = NULL; |
---|
[83] | 229 | |
---|
[77] | 230 | std::string inPath = ""; |
---|
| 231 | |
---|
[2555] | 232 | inPath = null_terminate_str(path, path_len); |
---|
[77] | 233 | |
---|
| 234 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 235 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 236 | |
---|
[77] | 237 | if (lib) { |
---|
[125] | 238 | xmlText = lib->get(inPath); |
---|
| 239 | if (!xmlText.empty()) { |
---|
| 240 | fortranify(xmlText.c_str(),retText,retText_len); |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | |
---|
| 247 | /**********************************************************************/ |
---|
| 248 | // FUNCTION: rp_lib_get_str() |
---|
| 249 | /// Get data located at 'path' and return it as a string value. |
---|
| 250 | /** |
---|
| 251 | */ |
---|
[2549] | 252 | void |
---|
| 253 | rp_lib_get_str( |
---|
| 254 | int* handle, /* integer handle of library */ |
---|
| 255 | char* path, /* null terminated path */ |
---|
| 256 | char* retText, /* return text buffer for fortran*/ |
---|
| 257 | int path_len, |
---|
| 258 | int retText_len) /* length of return text buffer */ |
---|
[125] | 259 | { |
---|
| 260 | std::string xmlText = ""; |
---|
| 261 | |
---|
| 262 | RpLibrary* lib = NULL; |
---|
| 263 | |
---|
| 264 | std::string inPath = ""; |
---|
| 265 | |
---|
| 266 | inPath = null_terminate_str(path,path_len); |
---|
| 267 | |
---|
| 268 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 269 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[125] | 270 | |
---|
| 271 | if (lib) { |
---|
[77] | 272 | xmlText = lib->getString(inPath); |
---|
| 273 | if (!xmlText.empty()) { |
---|
| 274 | fortranify(xmlText.c_str(),retText,retText_len); |
---|
| 275 | } |
---|
| 276 | |
---|
| 277 | } |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | |
---|
[125] | 281 | |
---|
[119] | 282 | /**********************************************************************/ |
---|
| 283 | // FUNCTION: rp_lib_get_double() |
---|
| 284 | /// Get data located at 'path' and return it as a double precision value. |
---|
| 285 | /** |
---|
| 286 | */ |
---|
[2549] | 287 | double |
---|
| 288 | rp_lib_get_double( |
---|
| 289 | int* handle, /* integer handle of library */ |
---|
| 290 | char* path, /* null terminated path */ |
---|
| 291 | int path_len) |
---|
[77] | 292 | { |
---|
| 293 | double retVal = 0.0; |
---|
| 294 | |
---|
| 295 | RpLibrary* lib = NULL; |
---|
[83] | 296 | |
---|
[77] | 297 | std::string inPath = ""; |
---|
| 298 | |
---|
| 299 | inPath = null_terminate_str(path,path_len); |
---|
| 300 | |
---|
| 301 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 302 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 303 | |
---|
[77] | 304 | if (lib) { |
---|
| 305 | retVal = lib->getDouble(inPath); |
---|
| 306 | } |
---|
| 307 | } |
---|
| 308 | |
---|
| 309 | return retVal; |
---|
| 310 | } |
---|
| 311 | |
---|
| 312 | |
---|
[119] | 313 | /**********************************************************************/ |
---|
[496] | 314 | // FUNCTION: rp_lib_get_integer() |
---|
| 315 | /// Get data located at 'path' and return it as an integer value. |
---|
| 316 | /** |
---|
| 317 | */ |
---|
| 318 | int rp_lib_get_integer( int* handle, /* integer handle of library */ |
---|
| 319 | char* path, /* null terminated path */ |
---|
| 320 | int path_len |
---|
| 321 | ) |
---|
| 322 | { |
---|
| 323 | int retVal = 0; |
---|
| 324 | |
---|
| 325 | RpLibrary* lib = NULL; |
---|
| 326 | |
---|
| 327 | std::string inPath = ""; |
---|
| 328 | |
---|
| 329 | inPath = null_terminate_str(path,path_len); |
---|
| 330 | |
---|
| 331 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 332 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[496] | 333 | |
---|
| 334 | if (lib) { |
---|
| 335 | retVal = lib->getInt(inPath); |
---|
| 336 | } |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | return retVal; |
---|
| 340 | } |
---|
| 341 | |
---|
| 342 | |
---|
| 343 | /**********************************************************************/ |
---|
| 344 | // FUNCTION: rp_lib_get_boolean() |
---|
| 345 | /// Get data located at 'path' and return it as an integer value. |
---|
| 346 | /** |
---|
| 347 | */ |
---|
| 348 | int rp_lib_get_boolean( int* handle, /* integer handle of library */ |
---|
| 349 | char* path, /* null terminated path */ |
---|
| 350 | int path_len |
---|
| 351 | ) |
---|
| 352 | { |
---|
| 353 | bool value = false; |
---|
| 354 | int retVal = 0; |
---|
| 355 | |
---|
| 356 | RpLibrary* lib = NULL; |
---|
| 357 | |
---|
| 358 | std::string inPath = ""; |
---|
| 359 | |
---|
| 360 | inPath = null_terminate_str(path,path_len); |
---|
| 361 | |
---|
| 362 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 363 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[496] | 364 | |
---|
| 365 | if (lib) { |
---|
| 366 | value = lib->getBool(inPath); |
---|
| 367 | if (value == true) { |
---|
| 368 | retVal = 1; |
---|
| 369 | } |
---|
| 370 | else { |
---|
| 371 | retVal = 0; |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | return retVal; |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | |
---|
| 380 | /**********************************************************************/ |
---|
[2408] | 381 | // FUNCTION: rp_lib_get_file() |
---|
| 382 | /// Get data located at 'path' and write it to the file 'fileName'. |
---|
| 383 | /** |
---|
| 384 | * Returns if any bytes were written to the file |
---|
| 385 | */ |
---|
| 386 | int rp_lib_get_file ( int* handle, /* integer handle of library */ |
---|
| 387 | char* path, /* null terminated path */ |
---|
| 388 | char* fileName, /* name of file to write data to */ |
---|
| 389 | int path_len, /* length of the path variable */ |
---|
| 390 | int fileName_len /* length of the fileName variable */ |
---|
| 391 | ) |
---|
| 392 | { |
---|
| 393 | size_t nbytes = 0; |
---|
| 394 | |
---|
| 395 | RpLibrary* lib = NULL; |
---|
| 396 | |
---|
| 397 | std::string inPath = ""; |
---|
| 398 | std::string filePath = ""; |
---|
| 399 | |
---|
| 400 | inPath = null_terminate_str(path,path_len); |
---|
| 401 | filePath = null_terminate_str(fileName,fileName_len); |
---|
| 402 | |
---|
| 403 | if ((handle) && (*handle != 0)) { |
---|
| 404 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
| 405 | |
---|
| 406 | if (lib) { |
---|
| 407 | nbytes = lib->getFile(inPath, filePath); |
---|
| 408 | } |
---|
| 409 | } |
---|
| 410 | |
---|
[2529] | 411 | return nbytes; |
---|
[2408] | 412 | } |
---|
| 413 | |
---|
| 414 | |
---|
| 415 | |
---|
| 416 | /**********************************************************************/ |
---|
[119] | 417 | // FUNCTION: rp_lib_put_str() |
---|
| 418 | /// Put string into Rappture Library Object at location 'path'. |
---|
| 419 | /** |
---|
| 420 | */ |
---|
[77] | 421 | void rp_lib_put_str( int* handle, |
---|
| 422 | char* path, |
---|
| 423 | char* value, |
---|
| 424 | int* append, |
---|
| 425 | int path_len, |
---|
| 426 | int value_len |
---|
[83] | 427 | ) |
---|
[77] | 428 | { |
---|
| 429 | std::string inPath = ""; |
---|
| 430 | std::string inValue = ""; |
---|
| 431 | RpLibrary* lib = NULL; |
---|
| 432 | |
---|
| 433 | inPath = null_terminate_str(path,path_len); |
---|
| 434 | inValue = null_terminate_str(value,value_len); |
---|
| 435 | |
---|
| 436 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 437 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[77] | 438 | |
---|
| 439 | if (lib) { |
---|
| 440 | lib->put(inPath,inValue,"",*append); |
---|
| 441 | } |
---|
| 442 | } |
---|
[83] | 443 | |
---|
[77] | 444 | return; |
---|
[83] | 445 | |
---|
[77] | 446 | } |
---|
| 447 | |
---|
| 448 | |
---|
[119] | 449 | /**********************************************************************/ |
---|
| 450 | // FUNCTION: rp_lib_put_id_str() |
---|
| 451 | /// Put string into Rappture Library Object at location 'path' with id = 'id' |
---|
| 452 | /** |
---|
| 453 | */ |
---|
[77] | 454 | void rp_lib_put_id_str ( int* handle, |
---|
| 455 | char* path, |
---|
| 456 | char* value, |
---|
| 457 | char* id, |
---|
| 458 | int* append, |
---|
| 459 | int path_len, |
---|
| 460 | int value_len, |
---|
| 461 | int id_len |
---|
| 462 | ) |
---|
| 463 | { |
---|
| 464 | RpLibrary* lib = NULL; |
---|
[83] | 465 | |
---|
[77] | 466 | std::string inPath = ""; |
---|
| 467 | std::string inValue = ""; |
---|
| 468 | std::string inId = ""; |
---|
| 469 | |
---|
| 470 | inPath = null_terminate_str(path,path_len); |
---|
| 471 | inValue = null_terminate_str(value,value_len); |
---|
| 472 | inId = null_terminate_str(id,id_len); |
---|
| 473 | |
---|
| 474 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 475 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 476 | |
---|
[77] | 477 | if (lib) { |
---|
| 478 | lib->put(inPath,inValue,inId,*append); |
---|
| 479 | } |
---|
| 480 | } |
---|
| 481 | |
---|
| 482 | } |
---|
| 483 | |
---|
[591] | 484 | |
---|
| 485 | /**********************************************************************/ |
---|
| 486 | // FUNCTION: rp_lib_put_data() |
---|
| 487 | /// Put string into Rappture Library Object at location 'path'. |
---|
| 488 | /** |
---|
| 489 | */ |
---|
[2549] | 490 | void |
---|
| 491 | rp_lib_put_data( |
---|
| 492 | int* handle, |
---|
| 493 | char* path, |
---|
| 494 | char* bytes, |
---|
| 495 | int* nbytes, |
---|
| 496 | int* append, |
---|
| 497 | int path_len, |
---|
| 498 | int bytes_len) |
---|
[591] | 499 | { |
---|
| 500 | std::string inPath = ""; |
---|
| 501 | RpLibrary* lib = NULL; |
---|
[597] | 502 | int bufferSize = 0; |
---|
[591] | 503 | |
---|
| 504 | inPath = null_terminate_str(path,path_len); |
---|
| 505 | |
---|
[597] | 506 | if (*nbytes < bytes_len) { |
---|
| 507 | bufferSize = *nbytes; |
---|
| 508 | } |
---|
| 509 | else { |
---|
| 510 | bufferSize = bytes_len; |
---|
| 511 | } |
---|
| 512 | |
---|
[591] | 513 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 514 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[591] | 515 | |
---|
| 516 | if (lib) { |
---|
[597] | 517 | lib->putData(inPath,bytes,bufferSize,*append); |
---|
[591] | 518 | } |
---|
| 519 | } |
---|
| 520 | |
---|
| 521 | return; |
---|
| 522 | |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | |
---|
| 526 | /**********************************************************************/ |
---|
| 527 | // FUNCTION: rp_lib_put_file() |
---|
| 528 | /// Put string into Rappture Library Object at location 'path'. |
---|
| 529 | /** |
---|
| 530 | */ |
---|
[2549] | 531 | void |
---|
| 532 | rp_lib_put_file( |
---|
| 533 | int* handle, |
---|
| 534 | char* path, |
---|
| 535 | char* fileName, |
---|
| 536 | int* compress, |
---|
| 537 | int* append, |
---|
| 538 | int path_len, |
---|
| 539 | int fileName_len) |
---|
[591] | 540 | { |
---|
| 541 | std::string inPath = ""; |
---|
| 542 | std::string inFileName = ""; |
---|
| 543 | RpLibrary* lib = NULL; |
---|
| 544 | |
---|
| 545 | inPath = null_terminate_str(path,path_len); |
---|
| 546 | inFileName = null_terminate_str(fileName,fileName_len); |
---|
| 547 | |
---|
| 548 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 549 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[591] | 550 | |
---|
| 551 | if (lib) { |
---|
[597] | 552 | lib->putFile(inPath,inFileName,*compress,*append); |
---|
[591] | 553 | } |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | return; |
---|
| 557 | |
---|
| 558 | } |
---|
| 559 | |
---|
| 560 | |
---|
[2549] | 561 | void |
---|
| 562 | rp_lib_put_obj( |
---|
| 563 | int* handle, |
---|
| 564 | char* path, |
---|
| 565 | int* valHandle, |
---|
| 566 | int* append, |
---|
| 567 | int path_len) |
---|
[1086] | 568 | { |
---|
| 569 | std::string inPath = ""; |
---|
| 570 | RpLibrary* lib = NULL; |
---|
| 571 | // Rp_Obj does not currently exist |
---|
| 572 | Rappture::DXWriter* obj = NULL; |
---|
| 573 | char* objStr = NULL; |
---|
[77] | 574 | |
---|
[1086] | 575 | |
---|
| 576 | inPath = null_terminate_str(path,path_len); |
---|
| 577 | |
---|
| 578 | if ((handle) && (*handle != 0)) { |
---|
| 579 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
| 580 | if (!lib) { |
---|
| 581 | // return error, lib was not found |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | obj = (Rappture::DXWriter*) getObject_Void(*valHandle); |
---|
| 585 | if (!obj) { |
---|
| 586 | // return error, obj was not found |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | // textsize function does not currently exist |
---|
| 590 | objStr = (char*) malloc(obj->size()*sizeof(char)); |
---|
| 591 | obj->write(objStr); |
---|
| 592 | lib->put(inPath,objStr,"",*append); |
---|
| 593 | free(objStr); |
---|
| 594 | } |
---|
| 595 | } |
---|
| 596 | |
---|
[119] | 597 | /**********************************************************************/ |
---|
| 598 | // FUNCTION: rp_lib_write_xml() |
---|
| 599 | /// Write the xml text into a file. |
---|
| 600 | /** |
---|
| 601 | * \sa {rp_result} |
---|
| 602 | */ |
---|
[77] | 603 | int rp_lib_write_xml(int* handle, char* outFile, int outFile_len) |
---|
| 604 | { |
---|
| 605 | int retVal = -1; |
---|
| 606 | RpLibrary* lib = NULL; |
---|
| 607 | std::string inOutFile = ""; |
---|
| 608 | std::string xmlText = ""; |
---|
| 609 | std::fstream file; |
---|
| 610 | |
---|
| 611 | inOutFile = null_terminate_str(outFile, outFile_len); |
---|
| 612 | |
---|
| 613 | if (!inOutFile.empty() ) { |
---|
| 614 | file.open(inOutFile.c_str(),std::ios::out); |
---|
| 615 | } |
---|
| 616 | |
---|
| 617 | if ( file.is_open() ) { |
---|
| 618 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 619 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[77] | 620 | |
---|
| 621 | if (lib) { |
---|
| 622 | xmlText = lib->xml(); |
---|
| 623 | if (!xmlText.empty()) { |
---|
| 624 | file << xmlText; |
---|
| 625 | retVal = 0; |
---|
| 626 | } |
---|
| 627 | } |
---|
| 628 | } |
---|
| 629 | |
---|
| 630 | file.close(); |
---|
| 631 | } |
---|
| 632 | |
---|
| 633 | return retVal; |
---|
| 634 | } |
---|
| 635 | |
---|
[119] | 636 | /**********************************************************************/ |
---|
| 637 | // FUNCTION: rp_lib_xml() |
---|
| 638 | /// Return this node's xml text |
---|
| 639 | /** |
---|
| 640 | */ |
---|
[83] | 641 | void rp_lib_xml(int* handle, char* retText, int retText_len) |
---|
| 642 | { |
---|
| 643 | std::string xmlText = ""; |
---|
| 644 | |
---|
| 645 | RpLibrary* lib = NULL; |
---|
| 646 | |
---|
| 647 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 648 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 649 | |
---|
| 650 | if (lib) { |
---|
| 651 | xmlText = lib->xml(); |
---|
| 652 | if (!xmlText.empty()) { |
---|
| 653 | fortranify(xmlText.c_str(), retText, retText_len); |
---|
| 654 | } |
---|
| 655 | } |
---|
| 656 | } |
---|
| 657 | } |
---|
| 658 | |
---|
[119] | 659 | /**********************************************************************/ |
---|
| 660 | // FUNCTION: rp_lib_node_comp() |
---|
| 661 | /// Return this node's component name |
---|
| 662 | /** |
---|
| 663 | */ |
---|
[83] | 664 | void rp_lib_node_comp ( int* handle, char* retText, int retText_len ) { |
---|
| 665 | |
---|
| 666 | std::string retStr = ""; |
---|
| 667 | RpLibrary* node = NULL; |
---|
| 668 | |
---|
| 669 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 670 | node = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 671 | |
---|
| 672 | if (node) { |
---|
| 673 | retStr = node->nodeComp(); |
---|
| 674 | if (!retStr.empty()) { |
---|
| 675 | fortranify(retStr.c_str(), retText, retText_len); |
---|
| 676 | } |
---|
| 677 | } |
---|
| 678 | } |
---|
| 679 | } |
---|
| 680 | |
---|
[119] | 681 | /**********************************************************************/ |
---|
| 682 | // FUNCTION: rp_lib_node_type() |
---|
| 683 | /// Return this node's type |
---|
| 684 | /** |
---|
| 685 | */ |
---|
[83] | 686 | void rp_lib_node_type ( int* handle, char* retText, int retText_len ) { |
---|
| 687 | |
---|
| 688 | std::string retStr = ""; |
---|
| 689 | RpLibrary* node = NULL; |
---|
| 690 | |
---|
| 691 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 692 | node = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 693 | |
---|
| 694 | if (node) { |
---|
| 695 | retStr = node->nodeType(); |
---|
| 696 | if (!retStr.empty()) { |
---|
| 697 | fortranify(retStr.c_str(), retText, retText_len); |
---|
| 698 | } |
---|
| 699 | } |
---|
| 700 | } |
---|
| 701 | } |
---|
| 702 | |
---|
[119] | 703 | /**********************************************************************/ |
---|
| 704 | // FUNCTION: rp_lib_node_id() |
---|
| 705 | /// Return this node's id. |
---|
| 706 | /** |
---|
| 707 | */ |
---|
[83] | 708 | void rp_lib_node_id ( int* handle, char* retText, int retText_len ) { |
---|
| 709 | |
---|
| 710 | std::string retStr = ""; |
---|
| 711 | RpLibrary* node = NULL; |
---|
| 712 | |
---|
| 713 | if ((handle) && (*handle != 0)) { |
---|
[1086] | 714 | node = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 715 | |
---|
| 716 | if (node) { |
---|
| 717 | retStr = node->nodeId(); |
---|
| 718 | if (!retStr.empty()) { |
---|
| 719 | fortranify(retStr.c_str(), retText, retText_len); |
---|
| 720 | } |
---|
| 721 | } |
---|
| 722 | } |
---|
| 723 | } |
---|
| 724 | |
---|
[119] | 725 | /**********************************************************************/ |
---|
| 726 | // FUNCTION: rp_result() |
---|
| 727 | /// Write xml text to a run.xml file and signal the program has completed |
---|
| 728 | /** |
---|
| 729 | */ |
---|
[83] | 730 | void rp_result(int* handle) { |
---|
| 731 | RpLibrary* lib = NULL; |
---|
| 732 | |
---|
| 733 | if (handle && *handle != 0) { |
---|
[1086] | 734 | lib = (RpLibrary*) getObject_Void(*handle); |
---|
[83] | 735 | if (lib) { |
---|
[789] | 736 | lib->put("tool.version.rappture.language", "fortran"); |
---|
[83] | 737 | lib->result(); |
---|
| 738 | } |
---|
| 739 | } |
---|
[119] | 740 | |
---|
| 741 | // do no delete this, still working on testing this |
---|
| 742 | cleanLibDict(); |
---|
[83] | 743 | } |
---|
| 744 | |
---|