Changeset 5730
- Timestamp:
- Jun 22, 2015, 1:35:34 PM (9 years ago)
- Location:
- trunk/src/core
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/Makefile.in
r4364 r5730 36 36 -DRAPPTURE_VERSION=\"$(RAPPTURE_VERSION)\" 37 37 38 CC_SWITCHES = $(CFLAGS) $(CFLAGS_DEBUG) $(INCLUDES) $(DEFINES) 39 CXX_SWITCHES = $(CFLAGS) $(CFLAGS_DEBUG) $(INCLUDES) $(DEFINES) 38 CC_SWITCHES = $(CFLAGS) $(CFLAGS_DEBUG) $(INCLUDES) $(DEFINES) 39 CXX_SWITCHES = $(CFLAGS) $(CFLAGS_DEBUG) $(INCLUDES) $(DEFINES) 40 40 41 41 INCLUDES = \ … … 104 104 xerror.h 105 105 106 # Build the scew and b64 libraries directly into Rappture for now. 106 # Build the scew and b64 libraries directly into Rappture for now. 107 107 # Note: This works because of viewpath-ing. See the VPATH variable. 108 108 B64_OBJS = \ … … 153 153 RpDXWriter.h \ 154 154 RpDXWriterFInterface.h \ 155 RpDXWriterFStubs.h 155 RpDXWriterFStubs.h 156 156 OBJS += \ 157 157 RpDXWriter.o \ 158 RpDXWriterFInterface.o 158 RpDXWriterFInterface.o 159 159 endif 160 160 … … 192 192 .cc.o: 193 193 $(CXX) $(CXX_SWITCHES) -c $? 194 .c.o: 194 .c.o: 195 195 $(CCC) $(CC_SWITCHES) -c $? 196 196 -
trunk/src/core/RpBindingsDict.cc
r5673 r5730 26 26 * function's caller. 27 27 * 28 * Returns the key of the object in the dictionary 28 * Returns the key of the object in the dictionary 29 29 * On Error, returns 0 (which also means nothing can be stored at 0) 30 30 */ … … 120 120 * This function stores the RpUnits names specified by 'objectName' 121 121 * into the UnitsStr dictionary. This is helpful for writing bindings 122 * for languages that can not accept pointers to provide back to the 122 * for languages that can not accept pointers to provide back to the 123 123 * function's caller. 124 124 * … … 152 152 * This function retrieves the RpUnits name referenced to by 'objKey' 153 153 * from the UnitsStr dictionary. This is helpful for writing bindings 154 * for languages that can not accept pointers to provide back to the 154 * for languages that can not accept pointers to provide back to the 155 155 * function's caller. 156 156 * -
trunk/src/core/RpBuffer.cc
r5673 r5730 37 37 {} 38 38 39 40 39 /** 41 40 * Construct an empty Buffer of specified size. … … 48 47 {} 49 48 50 51 49 /** 52 50 * Construct a Buffer loaded with initial data. … … 89 87 } 90 88 91 92 89 Buffer 93 90 Buffer::operator+(const Buffer& b) const … … 98 95 } 99 96 100 101 97 Buffer& 102 98 Buffer::operator+=(const Buffer& b) … … 106 102 } 107 103 108 109 104 Buffer::~Buffer() 110 105 {} 111 112 106 113 107 bool … … 142 136 } 143 137 // Read the file contents directly onto the end of the old buffer. 144 numBytesRead = fread((char *)bytes() + oldSize, sizeof(char), 138 numBytesRead = fread((char *)bytes() + oldSize, sizeof(char), 145 139 stat.st_size, f); 146 140 fclose(f); 147 141 if (numBytesRead != (size_t)stat.st_size) { 148 status.addError("can't read %ld bytes from \"%s\": %s", stat.st_size, 142 status.addError("can't read %ld bytes from \"%s\": %s", stat.st_size, 149 143 path, strerror(errno)); 150 144 return false; … … 155 149 } 156 150 157 158 bool 159 Buffer::dump (Outcome &status, const char* path) 151 bool 152 Buffer::dump(Outcome &status, const char* path) 160 153 { 161 154 status.addContext("Rappture::Buffer::dump()"); … … 179 172 } 180 173 181 182 174 bool 183 175 Buffer::encode(Outcome &status, unsigned int flags) … … 218 210 return true; 219 211 } 220 221 212 222 213 bool … … 273 264 } 274 265 275 276 bool 277 Buffer::do_compress(Outcome& status, SimpleCharBuffer& bin, 266 bool 267 Buffer::do_compress(Outcome& status, SimpleCharBuffer& bin, 278 268 SimpleCharBuffer& bout) 279 269 { … … 419 409 } 420 410 421 422 411 bool 423 412 Buffer::do_base64_enc(Outcome& status, const SimpleCharBuffer& bin, … … 439 428 } 440 429 441 442 430 bool 443 431 Buffer::do_base64_dec(Outcome& status, const SimpleCharBuffer& bin, … … 458 446 } 459 447 460 461 } 462 463 464 448 } -
trunk/src/core/RpBuffer.h
r5673 r5730 25 25 }; 26 26 27 28 27 #ifdef __cplusplus 29 28 extern "C" { 30 29 #endif // ifdef __cplusplus 31 30 … … 44 43 */ 45 44 46 class Buffer : public SimpleCharBuffer {45 class Buffer : public SimpleCharBuffer { 47 46 public: 48 47 Buffer(); … … 74 73 75 74 bool do_compress(Outcome& status, SimpleCharBuffer& bin, 76 SimpleCharBuffer& bout 77 bool do_decompress( 78 SimpleCharBuffer& bout);75 SimpleCharBuffer& bout); 76 bool do_decompress(Outcome& status, SimpleCharBuffer& bin, 77 SimpleCharBuffer& bout); 79 78 bool do_base64_enc(Outcome& status, const SimpleCharBuffer& bin, 80 SimpleCharBuffer& bout 79 SimpleCharBuffer& bout); 81 80 bool do_base64_dec(Outcome& status, const SimpleCharBuffer& bin, 82 SimpleCharBuffer& bout 81 SimpleCharBuffer& bout); 83 82 }; 84 83 … … 86 85 87 86 #ifdef __cplusplus 88 87 } 89 88 #endif // ifdef __cplusplus 90 89 -
trunk/src/core/RpBufferCInterface.cc
r5673 r5730 249 249 flags |= RPENC_B64; 250 250 } 251 ((Rappture::Buffer*)buf->_buf)->encode(s, flags); 252 RpOutcomeToCOutcome(&s,&status); 253 return status; 254 } 255 256 RapptureOutcome 257 RapptureBufferDecode(RapptureBuffer* buf, int decompress, int base64 251 ((Rappture::Buffer*)buf->_buf)->encode(s, flags); 252 RpOutcomeToCOutcome(&s,&status); 253 return status; 254 } 255 256 RapptureOutcome 257 RapptureBufferDecode(RapptureBuffer* buf, int decompress, int base64) 258 258 { 259 259 Rappture::Outcome s; … … 289 289 290 290 #ifdef __cplusplus 291 291 } 292 292 #endif // ifdef __cplusplus -
trunk/src/core/RpBufferCInterface.h
r5673 r5730 1 2 1 /* 3 2 * ---------------------------------------------------------------------- … … 12 11 * ====================================================================== 13 12 */ 14 15 13 16 14 #ifndef _RAPPTURE_BUFFER_C_H … … 39 37 bool (*decode)(Outcome &result, bool, bool); 40 38 */ 41 } RapptureBuffer;39 } RapptureBuffer; 42 40 43 41 int RapptureBufferInit(RapptureBuffer* buf); … … 53 51 RapptureOutcome RapptureBufferDump(RapptureBuffer* buf, const char* filename); 54 52 RapptureOutcome RapptureBufferEncode(RapptureBuffer* buf, int compress, 55 int base64);56 RapptureOutcome RapptureBufferDecode(RapptureBuffer* buf, 57 int decompress, int base64);53 int base64); 54 RapptureOutcome RapptureBufferDecode(RapptureBuffer* buf, 55 int decompress, int base64); 58 56 59 57 #ifdef __cplusplus -
trunk/src/core/RpDict.h
r5673 r5730 22 22 /**************************************************************************/ 23 23 24 template < 25 26 24 template <typename KeyType, 25 typename ValType, 26 class _Compare=std::equal_to<KeyType> > 27 27 class RpDict; 28 28 29 template < 30 31 29 template <typename KeyType, 30 typename ValType, 31 class _Compare=std::equal_to<KeyType> > 32 32 class RpDictEntry; 33 33 34 template < 35 36 34 template <typename KeyType, 35 typename ValType, 36 class _Compare=std::equal_to<KeyType> > 37 37 class RpDictIterator; 38 39 38 40 39 /* … … 48 47 * because RpBindingsDict uses it. 49 48 */ 50 51 49 52 50 /**************************************************************************/ … … 93 91 private: 94 92 95 RpDict<KeyType,ValType,_Compare>& 96 tablePtr; /* pointer to the table we want to 93 RpDict<KeyType,ValType,_Compare>& 94 tablePtr; /* pointer to the table we want to 97 95 * iterate */ 98 96 int srchNextIndex; /* Index of next bucket to be 99 97 * enumerated after present one. */ 100 RpDictEntry<KeyType,ValType,_Compare>* 98 RpDictEntry<KeyType,ValType,_Compare>* 101 99 srchNextEntryPtr; /* Next entry to be enumerated in the 102 100 * the current bucket. */ 103 101 104 102 }; 105 106 103 107 104 template <typename KeyType, typename ValType, class _Compare> … … 113 110 // operator==(const RpDictEntry& entry) const; 114 111 // 115 //operator!=(const RpDictEntry& lhs, const RpDictEntry& rhs) const 112 //operator!=(const RpDictEntry& lhs, const RpDictEntry& rhs) const 116 113 //{ 117 114 // if (lhs.key != rhs.key) … … 189 186 }; 190 187 191 192 188 template <typename KeyType, typename ValType, class _Compare> 193 189 class RpDict … … 207 203 // 208 204 /*virtual*/ RpDict<KeyType,ValType,_Compare>& 209 set( 210 211 212 213 205 set(KeyType& key, 206 ValType& value, 207 RpDictHint hint=NULL, 208 int *newPtr=NULL, 209 bool ci=false); 214 210 215 211 // find an RpUnits object that should exist in RpUnitsTable 216 // 212 // 217 213 /*virtual*/ RpDictEntry<KeyType,ValType,_Compare>& 218 find( 219 220 bool ci=false);221 222 /*virtual*/ RpDictEntry<KeyType,ValType,_Compare>& operator[]( 214 find(KeyType& key, 215 RpDictHint hint = NULL, 216 bool ci=false); 217 218 /*virtual*/ RpDictEntry<KeyType,ValType,_Compare>& operator[](KeyType& key) 223 219 { 224 220 return find(key,NULL); 225 221 } 226 222 227 RpDict<KeyType,ValType,_Compare>& setCI( bool val);223 RpDict<KeyType,ValType,_Compare>& setCI(bool val); 228 224 bool getCI(); 229 225 RpDict<KeyType,ValType,_Compare>& toggleCI(); … … 263 259 } 264 260 265 // copy constructor 261 // copy constructor 266 262 // RpDict (const RpDict& dict); 267 263 … … 283 279 const int REBUILD_MULTIPLIER; 284 280 285 RpDictEntry<KeyType,ValType,_Compare> 281 RpDictEntry<KeyType,ValType,_Compare> 286 282 **buckets; /* Pointer to bucket array. Each 287 283 * element points to first entry in … … 314 310 315 311 RpDictEntry<KeyType,ValType,_Compare>* 316 search( KeyType& key, RpDictHint hint = NULL, bool ci = false);312 search(KeyType& key, RpDictHint hint = NULL, bool ci = false); 317 313 318 314 // static void RpDict::RebuildTable (); … … 326 322 }; 327 323 328 329 324 /*--------------------------------------------------------------------------*/ 330 325 /*--------------------------------------------------------------------------*/ … … 340 335 * Side Effects: 341 336 * none. 342 * 337 * 343 338 * 344 339 *************************************************************************/ 345 346 340 template <typename KeyType, typename ValType, class _Compare> 347 341 int … … 350 344 return numEntries; 351 345 } 352 353 346 354 347 /************************************************************************** … … 359 352 * 360 353 * Results: 361 * Returns a reference to the RpDict object allowing the user to chain 354 * Returns a reference to the RpDict object allowing the user to chain 362 355 * together different commands such as 363 356 * rpdict_obj.set(key).find(a).erase(a); … … 370 363 template <typename KeyType, typename ValType, class _Compare> 371 364 RpDict<KeyType,ValType,_Compare>& 372 RpDict<KeyType,ValType,_Compare>::set( 373 374 375 376 bool ci)365 RpDict<KeyType,ValType,_Compare>::set(KeyType& key, 366 ValType& value, 367 RpDictHint hint, 368 int* newPtr, 369 bool ci) 377 370 { 378 371 RpDictEntry<KeyType,ValType,_Compare> *hPtr = NULL; … … 466 459 *---------------------------------------------------------------------- 467 460 */ 468 469 461 template <typename KeyType, typename ValType, class _Compare> 470 462 RpDictEntry<KeyType,ValType,_Compare>& 471 RpDict<KeyType,ValType,_Compare>::find( 472 473 bool ci)463 RpDict<KeyType,ValType,_Compare>::find(KeyType& key, 464 RpDictHint hint, 465 bool ci) 474 466 { 475 467 RpDictEntry<KeyType,ValType,_Compare> *hPtr = NULL; … … 503 495 *---------------------------------------------------------------------- 504 496 */ 505 506 497 template <typename KeyType, typename ValType, class _Compare> 507 498 RpDictEntry<KeyType,ValType,_Compare>* 508 RpDict<KeyType,ValType,_Compare>::search( 509 510 bool ci)511 512 499 RpDict<KeyType,ValType,_Compare>::search(KeyType& key, 500 RpDictHint hint, 501 bool ci) 502 // bool ci, 503 // RpDictEntryList* entryList) 513 504 { 514 505 RpDictEntry<KeyType,ValType,_Compare> *hPtr = NULL; … … 572 563 } 573 564 574 575 576 565 /************************************************************************** 577 566 * … … 589 578 /* 590 579 template <typename KeyType,typename ValType,class _Compare> 591 RpDict<KeyType,ValType,_Compare>& 592 RpDictIterator<KeyType,ValType,_Compare>::getTable() 580 RpDict<KeyType,ValType,_Compare>& 581 RpDictIterator<KeyType,ValType,_Compare>::getTable() 593 582 { 594 583 return tablePtr; … … 606 595 * Side Effects: 607 596 * moves iterator to the beginning of the hash table. 608 * 597 * 609 598 * 610 599 *************************************************************************/ … … 630 619 * Side Effects: 631 620 * moves iterator to the next entry of the hash table if it exists. 632 * 621 * 633 622 * 634 623 *************************************************************************/ 635 636 624 template <typename KeyType,typename ValType,class _Compare> 637 625 RpDictEntry<KeyType,ValType,_Compare>* … … 669 657 template <typename KeyType, typename ValType, class _Compare> 670 658 RpDict<KeyType,ValType,_Compare>& 671 RpDict<KeyType,ValType,_Compare>::setCI( bool val)659 RpDict<KeyType,ValType,_Compare>::setCI(bool val) 672 660 { 673 661 caseInsensitive = val; … … 764 752 return *nullEntry; 765 753 } 766 767 754 768 755 /* … … 784 771 *---------------------------------------------------------------------- 785 772 */ 786 787 773 template <typename KeyType, typename ValType, class _Compare> 788 774 void … … 794 780 795 781 // check to see if the object is associated with a table 796 // if object is not associated with a table, there is no 782 // if object is not associated with a table, there is no 797 783 // need to try to remove it from the table. 798 784 if (tablePtr) { … … 804 790 805 791 // remove the entry from the buckets 806 // 792 // 807 793 // if entry is the first entry in the bucket 808 794 // move the bucket to point to the next entry … … 812 798 else { 813 799 // if the entry is not the first entry in the bucket 814 // search for the entry 800 // search for the entry 815 801 for (prevPtr = *bucketPtr; ; prevPtr = prevPtr->nextPtr) { 816 802 … … 821 807 prevPtr->nextPtr = nextPtr; 822 808 break; 823 } 809 } 824 810 } // end for loop 825 811 } // end else … … 843 829 } 844 830 845 846 831 /* 847 832 *---------------------------------------------------------------------- … … 859 844 *---------------------------------------------------------------------- 860 845 */ 861 862 846 template <typename KeyType, typename ValType, class _Compare> 863 847 const KeyType* … … 884 868 *---------------------------------------------------------------------- 885 869 */ 886 887 870 template <typename KeyType, typename ValType, class _Compare> 888 871 const ValType* … … 907 890 *---------------------------------------------------------------------- 908 891 */ 909 910 892 template <typename KeyType, typename ValType, class _Compare> 911 893 const ValType* … … 944 926 *---------------------------------------------------------------------- 945 927 */ 946 947 928 template <typename KeyType, typename ValType, class _Compare> 948 929 bool … … 954 935 return false; 955 936 } 956 957 937 958 938 /*************************************************************************/ … … 978 958 *---------------------------------------------------------------------- 979 959 */ 980 981 960 template <typename KeyType, typename ValType, class _Compare> 982 961 void 983 962 RpDict<KeyType,ValType,_Compare>::RebuildTable() 984 963 { 985 int oldSize=0, count=0, index=0; 964 int oldSize=0, count=0, index=0; 986 965 RpDictEntry<KeyType,ValType,_Compare> **oldBuckets = NULL; 987 966 RpDictEntry<KeyType,ValType,_Compare> **oldChainPtr = NULL, **newChainPtr = NULL; … … 996 975 */ 997 976 998 999 977 numBuckets *= 4; 1000 978 … … 1054 1032 *---------------------------------------------------------------------- 1055 1033 */ 1056 1057 1034 template <typename KeyType, typename ValType, class _Compare> 1058 1035 unsigned int … … 1082 1059 * I chose the one below (multiply by 9 and add new character) 1083 1060 * because of the following reasons: 1084 * 1061 * 1085 1062 * 1. Multiplying by 10 is perfect for keys that are decimal strings, 1086 1063 * and multiplying by 9 is just about as good. … … 1091 1068 * works well both for decimal and non-decimal strings. 1092 1069 */ 1093 1094 1095 1070 template <typename KeyType, typename ValType, class _Compare> 1096 1071 unsigned int … … 1158 1133 * --------------------------------------------------------------------- 1159 1134 */ 1160 1161 1135 template <typename KeyType, typename ValType, class _Compare> 1162 1136 int … … 1166 1140 } 1167 1141 1168 1169 1170 1142 #endif -
trunk/src/core/b64/cdecode.h
r5673 r5730 24 24 int base64_decode_value(char value_in); 25 25 26 int base64_decode_block(const char* code_in, const int length_in, 26 int base64_decode_block(const char* code_in, const int length_in, 27 27 char* plaintext_out, base64_decodestate* state_in); 28 28 -
trunk/src/core/b64/decode.h
r5673 r5730 22 22 base64_decodestate _state; 23 23 int _buffersize; 24 24 25 25 decoder(int buffersize_in = 4096) 26 26 : _buffersize(buffersize_in) -
trunk/src/core/b64/encode.h
r5673 r5730 15 15 { 16 16 17 extern "C" 17 extern "C" 18 18 { 19 19 #include "cencode.h" -
trunk/src/core/rappture_fortran.c
r5673 r5730 100 100 # define rp_lib_element_id RP_LIB_ELEMENT_ID 101 101 # define rp_lib_element_type RP_LIB_ELEMENT_TYPE 102 # define rp_lib_element_str RP_LIB_ELEMENT_STR 102 # define rp_lib_element_str RP_LIB_ELEMENT_STR 103 103 # define rp_lib_element_obj RP_LIB_ELEMENT_OBJ 104 104 # define rp_lib_child_num RP_LIB_CHILD_NUM … … 130 130 131 131 extern "C" 132 void rp_lib_element_comp( int* handle,133 134 135 136 int retText_len);137 138 extern "C" 139 void rp_lib_element_id( int* handle,140 141 142 143 int retText_len);144 145 extern "C" 146 void rp_lib_element_type( 147 148 149 150 int retText_len);151 152 extern "C" 153 void rp_lib_element_str( int* handle,154 char* path,155 156 157 158 159 int retText_len);160 161 extern "C" 162 int rp_lib_element_obj( int* handle,163 164 int path_len);165 166 extern "C" 167 int rp_lib_child_num( int* handle,168 char* path,169 170 171 extern "C" 172 int rp_lib_child_comp( 173 174 175 176 177 178 179 180 181 182 extern "C" 183 int rp_lib_child_id( 184 185 186 187 188 189 190 191 192 193 extern "C" 194 int rp_lib_child_type( 195 196 197 198 199 200 201 202 203 204 extern "C" 205 int rp_lib_child_str( 206 207 208 209 210 211 212 213 214 215 216 217 extern "C" 218 int rp_lib_child_obj( int* handle,219 char* path,220 char* type,221 222 int type_len223 ); 224 225 extern "C" 226 void rp_lib_get( int* handle, 227 char* path,228 char* retText,229 int path_len,230 int retText_len ); 231 232 extern "C" 233 double rp_lib_get_double( int* handle, 234 char* path,235 int path_len); 236 237 extern "C" 238 void rp_lib_put_str( int* handle, 239 char* path,240 char* value,241 int* append,242 int path_len,243 int value_len ); 244 245 extern "C" 246 void rp_lib_put_id_str( int* handle, 247 char* path,248 char* value,249 char* id,250 int* append,251 int path_len,252 int value_len,253 int id_len ); 254 255 extern "C" 256 void rp_lib_put_obj( int* handle, 257 char* path,258 int* valHandle,259 int* append,260 int path_len ); 261 262 extern "C" 263 void rp_lib_put_id_obj( int* handle, 264 char* path,265 int* valHandle,266 char* id,267 int* append,268 int path_len,269 int id_len ); 270 271 extern "C" 272 int rp_lib_remove( int* handle, 273 char* path,274 int path_len); 275 276 extern "C" 277 int rp_lib_xml_len( int* handle); 278 279 extern "C" 280 void rp_lib_xml( int* handle, 281 char* retText,282 int retText_len); 283 284 extern "C" 285 int rp_lib_write_xml( int* handle, 286 char* outFile,287 int outFile_len); 132 void rp_lib_element_comp(int* handle, 133 char* path, 134 char* retText, 135 int path_len, 136 int retText_len); 137 138 extern "C" 139 void rp_lib_element_id(int* handle, 140 char* path, 141 char* retText, 142 int path_len, 143 int retText_len); 144 145 extern "C" 146 void rp_lib_element_type(int* handle, 147 char* path, 148 char* retText, 149 int path_len, 150 int retText_len); 151 152 extern "C" 153 void rp_lib_element_str(int* handle, 154 char* path, 155 char* flavor, 156 char* retText, 157 int path_len, 158 int flavor_len, 159 int retText_len); 160 161 extern "C" 162 int rp_lib_element_obj(int* handle, 163 char* path, 164 int path_len); 165 166 extern "C" 167 int rp_lib_child_num(int* handle, 168 char* path, 169 int path_len); 170 171 extern "C" 172 int rp_lib_child_comp(int* handle, /* integer handle of library */ 173 char* path, /* DOM path of requested object */ 174 char* type, /* specific name of element */ 175 int* childNum, /* child number for iteration */ 176 char* retText, /* buffer to store return text */ 177 int path_len, /* length of path */ 178 int type_len, /* length of type */ 179 int retText_len /* length of return text buffer */ 180 ); 181 182 extern "C" 183 int rp_lib_child_id(int* handle, /* integer handle of library */ 184 char* path, /* DOM path of requested object */ 185 char* type, /* specific name of element */ 186 int* childNum, /* child number for iteration */ 187 char* retText, /* buffer to store return text */ 188 int path_len, /* length of path */ 189 int type_len, /* length of type */ 190 int retText_len /* length of return text buffer */ 191 ); 192 193 extern "C" 194 int rp_lib_child_type(int* handle, /* integer handle of library */ 195 char* path, /* DOM path of requested object */ 196 char* type, /* specific name of element */ 197 int* childNum, /* child number for iteration */ 198 char* retText, /* buffer to store return text */ 199 int path_len, /* length of path */ 200 int type_len, /* length of type */ 201 int retText_len /* length of return text buffer */ 202 ); 203 204 extern "C" 205 int rp_lib_child_str(int* handle, /* integer handle of library */ 206 char* path, /* DOM path of requested object */ 207 char* flavor, /* information you want returned*/ 208 char* type, /* specific name of element */ 209 int* childNum, /* child number for iteration */ 210 char* retText, /* buffer to store return text */ 211 int path_len, /* length of path */ 212 int flavor_len, /* length of flavor */ 213 int type_len, /* length of type */ 214 int retText_len /* length of return text buffer */ 215 ); 216 217 extern "C" 218 int rp_lib_child_obj(int* handle, 219 char* path, 220 char* type, 221 int path_len, 222 int type_len); 223 224 extern "C" 225 void rp_lib_get(int* handle, 226 char* path, 227 char* retText, 228 int path_len, 229 int retText_len); 230 231 extern "C" 232 double rp_lib_get_double(int* handle, 233 char* path, 234 int path_len); 235 236 extern "C" 237 void rp_lib_put_str(int* handle, 238 char* path, 239 char* value, 240 int* append, 241 int path_len, 242 int value_len); 243 244 extern "C" 245 void rp_lib_put_id_str(int* handle, 246 char* path, 247 char* value, 248 char* id, 249 int* append, 250 int path_len, 251 int value_len, 252 int id_len); 253 254 extern "C" 255 void rp_lib_put_obj(int* handle, 256 char* path, 257 int* valHandle, 258 int* append, 259 int path_len); 260 261 extern "C" 262 void rp_lib_put_id_obj(int* handle, 263 char* path, 264 int* valHandle, 265 char* id, 266 int* append, 267 int path_len, 268 int id_len); 269 270 extern "C" 271 int rp_lib_remove(int* handle, 272 char* path, 273 int path_len); 274 275 extern "C" 276 int rp_lib_xml_len(int* handle); 277 278 extern "C" 279 void rp_lib_xml(int* handle, 280 char* retText, 281 int retText_len); 282 283 extern "C" 284 int rp_lib_write_xml(int* handle, 285 char* outFile, 286 int outFile_len); 287 288 288 extern "C" 289 289 void rp_quit(); … … 306 306 307 307 // global vars 308 // dictionary to hold the python objects that 308 // dictionary to hold the python objects that 309 309 // cannot be sent to fortran 310 310 … … 313 313 int rapptureStarted = 0; 314 314 315 void rp_init() { 315 void rp_init() 316 { 316 317 // 317 318 PyObject* rpClass = NULL; 318 319 int retVal = 0; 319 320 320 321 // initialize the interpreter 321 322 Py_Initialize(); … … 329 330 } 330 331 331 int rp_lib(const char* filePath, int filePath_len) 332 int rp_lib(const char* filePath, int filePath_len) 332 333 { 333 334 PyObject* lib = NULL; … … 341 342 342 343 inFilePath = null_terminate((char*)filePath, filePath_len); 343 344 344 345 // error checking to make sure inText is valid??? 345 346 346 347 // grab the rappture class from the dictionary 347 348 rpClass = getObject(0); … … 367 368 368 369 int rp_lib_element_obj(int* handle, /* integer handle of library */ 369 char* path, /* null terminated path */ 370 int path_len 371 ) 370 char* path, /* null terminated path */ 371 int path_len) 372 372 { 373 373 int newObjHandle = -1; … … 388 388 if (lib) { 389 389 retObj = (PyObject*) rpElement(lib, inPath, flavor); 390 390 391 391 if (retObj) { 392 392 … … 406 406 } 407 407 408 void rp_lib_element_comp( 409 410 411 412 413 408 void rp_lib_element_comp(int* handle, /* integer handle of library */ 409 char* path, /* null terminated path */ 410 char* retText, /* return buffer for fortran*/ 411 int path_len, 412 int retText_len /* length of return text buffer */ 413 ) 414 414 { 415 415 char* inPath = NULL; … … 426 426 427 427 rp_lib_element_str(handle,inPath,"component",retText,path_len,10,retText_len); 428 429 if (inPath) { 430 free(inPath); 431 inPath = NULL; 432 } 433 434 } 435 436 void rp_lib_element_id( 437 438 439 440 441 )428 429 if (inPath) { 430 free(inPath); 431 inPath = NULL; 432 } 433 434 } 435 436 void rp_lib_element_id(int* handle, /* integer handle of library */ 437 char* path, /* null terminated path */ 438 char* retText, /* return buffer for fortran*/ 439 int path_len, 440 int retText_len /* length of return text buffer */ 441 ) 442 442 { 443 443 char* inPath = NULL; … … 459 459 } 460 460 461 void rp_lib_element_type( 462 463 464 465 466 461 void rp_lib_element_type(int* handle, /* integer handle of library */ 462 char* path, /* null terminated path */ 463 char* retText, /* return buffer for fortran*/ 464 int path_len, 465 int retText_len /* length of return text buffer */ 466 ) 467 467 { 468 468 char* inPath = NULL; … … 483 483 } 484 484 485 void rp_lib_element_str( 486 487 488 489 490 491 485 void rp_lib_element_str(int* handle, /* integer handle of library */ 486 char* path, /* null terminated path */ 487 char* flavor, /* null terminated flavor */ 488 char* retText, /* return buffer for fortran*/ 489 int path_len, 490 int flavor_len, 491 int retText_len /* length of return text buffer */ 492 492 ) 493 493 { … … 498 498 499 499 PyObject* lib = NULL; 500 500 501 501 char* retObj = NULL; 502 502 503 503 char* inPath = NULL; 504 504 char* inFlavor = NULL; … … 517 517 if (retObj) { 518 518 xmlText = retObj; 519 519 520 520 fortranify(xmlText, retText, retText_len); 521 521 522 522 /* 523 523 length_in = strlen(xmlText); … … 534 534 *(retText+length_out-1) = ' '; 535 535 */ 536 536 537 537 free(retObj); 538 538 retObj = NULL; 539 539 } 540 540 else { 541 541 542 542 } 543 543 } … … 546 546 } 547 547 } 548 548 549 549 if (inPath) { 550 550 free(inPath); … … 559 559 } 560 560 561 int rp_lib_child_num( int* handle, 562 char* path, 563 int path_len 564 ) 561 int rp_lib_child_num(int* handle, 562 char* path, 563 int path_len) 565 564 { 566 565 int numChildren = 0; … … 571 570 572 571 inPath = null_terminate(path,path_len); 573 572 574 573 if (rapptureStarted) { 575 574 if ((handle) && (*handle != 0)) { … … 583 582 } 584 583 else { 585 584 586 585 } 587 586 } … … 599 598 600 599 601 int rp_lib_child_comp (int* handle, /* integer handle of library */602 603 604 605 606 607 608 609 600 int rp_lib_child_comp(int* handle, /* integer handle of library */ 601 char* path, /* DOM path of requested object */ 602 char* type, /* specific name of element */ 603 int* childNum, /* child number for iteration */ 604 char* retText, /* buffer to store return text */ 605 int path_len, /* length of path */ 606 int type_len, /* length of type */ 607 int retText_len /* length of return text buffer */ 608 ) 610 609 { 611 610 int retVal = 0; … … 631 630 } 632 631 633 retVal = rp_lib_child_str( handle, 634 inPath, 635 "component", 636 inType, 637 childNum, 638 retText, 639 path_len, 640 10, 641 type_len, 642 retText_len 643 ); 632 retVal = rp_lib_child_str(handle, 633 inPath, 634 "component", 635 inType, 636 childNum, 637 retText, 638 path_len, 639 10, 640 type_len, 641 retText_len); 644 642 645 643 if (inPath) { … … 656 654 } 657 655 658 int rp_lib_child_id( 659 660 661 662 663 664 665 666 656 int rp_lib_child_id(int* handle, /* integer handle of library */ 657 char* path, /* DOM path of requested object */ 658 char* type, /* specific name of element */ 659 int* childNum, /* child number for iteration */ 660 char* retText, /* buffer to store return text */ 661 int path_len, /* length of path */ 662 int type_len, /* length of type */ 663 int retText_len /* length of return text buffer */ 664 ) 667 665 { 668 666 int retVal = 0; … … 687 685 } 688 686 689 retVal = rp_lib_child_str( handle, 690 inPath, 691 "id", 692 inType, 693 childNum, 694 retText, 695 path_len, 696 3, 697 type_len, 698 retText_len 699 ); 687 retVal = rp_lib_child_str(handle, 688 inPath, 689 "id", 690 inType, 691 childNum, 692 retText, 693 path_len, 694 3, 695 type_len, 696 retText_len); 700 697 701 698 if (inPath) { … … 712 709 } 713 710 714 int rp_lib_child_type (int* handle, /* integer handle of library */715 716 717 718 719 720 721 722 711 int rp_lib_child_type(int* handle, /* integer handle of library */ 712 char* path, /* DOM path of requested object */ 713 char* type, /* specific name of element */ 714 int* childNum, /* child number for iteration */ 715 char* retText, /* buffer to store return text */ 716 int path_len, /* length of path */ 717 int type_len, /* length of type */ 718 int retText_len /* length of return text buffer */ 719 ) 723 720 { 724 721 int retVal = 0; … … 743 740 } 744 741 745 retVal = rp_lib_child_str( handle, 746 inPath, 747 "type", 748 inType, 749 childNum, 750 retText, 751 path_len, 752 5, 753 type_len, 754 retText_len 755 ); 742 retVal = rp_lib_child_str(handle, 743 inPath, 744 "type", 745 inType, 746 childNum, 747 retText, 748 path_len, 749 5, 750 type_len, 751 retText_len); 756 752 757 753 if (inPath) { … … 768 764 } 769 765 770 int rp_lib_child_str (int* handle, /* integer handle of library */771 772 773 774 775 776 777 778 779 780 766 int rp_lib_child_str(int* handle, /* integer handle of library */ 767 char* path, /* DOM path of requested object */ 768 char* flavor, /* information you want returned*/ 769 char* type, /* specific name of element */ 770 int* childNum, /* child number for iteration */ 771 char* retText, /* buffer to store return text */ 772 int path_len, /* length of path */ 773 int flavor_len, /* length of flavor */ 774 int type_len, /* length of type */ 775 int retText_len /* length of return text buffer */ 776 ) 781 777 { 782 778 int retVal = 0; … … 787 783 PyObject* list = NULL; 788 784 PyObject* list_item = NULL; 789 785 790 786 char* xmlChild = NULL; 791 787 char* inPath = NULL; 792 788 char* inType = NULL; 793 789 char* inFlavor = NULL; 794 790 795 791 inPath = null_terminate(path,path_len); 796 792 inFlavor = null_terminate(flavor,flavor_len); … … 801 797 lib = getObject(*handle); 802 798 if (lib) { 803 if (objType(inFlavor) == 1) {799 if (objType(inFlavor) == 1) { 804 800 805 801 list = rpChildren_f(lib, inPath, inFlavor); … … 832 828 } 833 829 } 834 else {835 836 }837 830 } 838 831 } … … 855 848 } 856 849 857 858 850 return retVal; 859 851 } 860 852 861 int rp_lib_child_obj ( int* handle, 862 char* path, 863 char* type, 864 int path_len, 865 int type_len 866 ) 853 int rp_lib_child_obj(int* handle, 854 char* path, 855 char* type, 856 int path_len, 857 int type_len) 867 858 { 868 859 int newObjHandle = -1; … … 870 861 PyObject* lib = NULL; 871 862 PyObject* list = NULL; 872 863 873 864 char* inPath = NULL; 874 865 char* inType = NULL; … … 880 871 if ((handle) && (*handle != 0)) { 881 872 lib = getObject(*handle); 882 873 883 874 if (lib) { 884 875 list = rpChildren_f(lib, inPath, "object"); … … 889 880 // Py_DECREF(list); 890 881 } 891 else {892 893 }894 882 } 895 883 } … … 907 895 908 896 return newObjHandle; 909 910 } 911 912 913 void rp_lib_get( int* handle, /* integer handle of library */ 914 char* path, /* null terminated path */ 915 char* retText, /* return text buffer for fortran*/ 916 int path_len, 917 int retText_len /* length of return text buffer */ 918 ) 897 } 898 899 900 void rp_lib_get(int* handle, /* integer handle of library */ 901 char* path, /* null terminated path */ 902 char* retText, /* return text buffer for fortran*/ 903 int path_len, 904 int retText_len /* length of return text buffer */ 905 ) 919 906 { 920 907 // int length_in = 0; … … 924 911 925 912 PyObject* lib = NULL; 926 913 927 914 char* inPath = NULL; 928 915 … … 932 919 if ((handle) && (*handle != 0)) { 933 920 lib = getObject(*handle); 934 921 935 922 if (lib) { 936 // retObj is a borrowed object 923 // retObj is a borrowed object 937 924 // whose contents must not be modified 938 925 xmlText = rpGet(lib, inPath); 939 926 940 927 if (xmlText) { 941 928 942 929 fortranify(xmlText, retText, retText_len); 943 930 944 931 /* 945 932 length_in = strlen(xmlText); … … 957 944 */ 958 945 } 959 960 946 } 961 947 } … … 966 952 inPath = NULL; 967 953 } 968 969 } 970 971 double rp_lib_get_double( int* handle, /* integer handle of library */ 972 char* path, /* null terminated path */ 973 int path_len 974 ) 954 } 955 956 double rp_lib_get_double(int* handle, /* integer handle of library */ 957 char* path, /* null terminated path */ 958 int path_len) 975 959 { 976 960 double retVal = 0.0; … … 978 962 979 963 PyObject* lib = NULL; 980 964 981 965 char* inPath = NULL; 982 966 … … 988 972 if ((handle) && (*handle != 0)) { 989 973 lib = getObject(*handle); 990 974 991 975 if (lib) { 992 // retObj is a borrowed object 976 // retObj is a borrowed object 993 977 // whose contents must not be modified 994 978 xmlText = rpGet(lib, inPath); 995 979 996 980 if (xmlText) { 997 981 retVal = atof(xmlText); 998 982 } 999 1000 983 } 1001 984 } … … 1011 994 1012 995 1013 void rp_lib_put_str( int* handle, 1014 char* path, 1015 char* value, 1016 int* append, 1017 int path_len, 1018 int value_len 1019 ) 996 void rp_lib_put_str(int* handle, 997 char* path, 998 char* value, 999 int* append, 1000 int path_len, 1001 int value_len) 1020 1002 { 1021 1003 char* inPath = NULL; … … 1024 1006 inPath = null_terminate(path,path_len); 1025 1007 inValue = null_terminate(value,value_len); 1026 1027 1008 1028 1009 if (inPath) { … … 1054 1035 1055 1036 1056 void rp_lib_put_id_str ( int* handle, 1057 char* path, 1058 char* value, 1059 char* id, 1060 int* append, 1061 int path_len, 1062 int value_len, 1063 int id_len 1064 ) 1065 { 1066 PyObject* lib = NULL; 1067 1037 void rp_lib_put_id_str(int* handle, 1038 char* path, 1039 char* value, 1040 char* id, 1041 int* append, 1042 int path_len, 1043 int value_len, 1044 int id_len) 1045 { 1046 PyObject* lib = NULL; 1047 1068 1048 char* inPath = NULL; 1069 1049 char* inValue = NULL; … … 1077 1057 if ((handle) && (*handle != 0)) { 1078 1058 lib = getObject(*handle); 1079 1059 1080 1060 if (lib) { 1081 1061 rpPut(lib, inPath, inValue, inId, *append); … … 1098 1078 inId = NULL; 1099 1079 } 1100 1101 } 1102 1103 void rp_lib_put_obj( int* handle, 1104 char* path, 1105 int* valHandle, 1106 int* append, 1107 int path_len 1108 ) 1080 } 1081 1082 void rp_lib_put_obj(int* handle, 1083 char* path, 1084 int* valHandle, 1085 int* append, 1086 int path_len) 1109 1087 { 1110 1088 char* inPath = NULL; … … 1125 1103 } 1126 1104 1127 void rp_lib_put_id_obj ( int* handle, 1128 char* path, 1129 int* valHandle, 1130 char* id, 1131 int* append, 1132 int path_len, 1133 int id_len 1134 ) 1105 void rp_lib_put_id_obj(int* handle, 1106 char* path, 1107 int* valHandle, 1108 char* id, 1109 int* append, 1110 int path_len, 1111 int id_len) 1135 1112 { 1136 1113 PyObject* lib = NULL; 1137 1114 PyObject* value = NULL; 1138 1115 1139 1116 char* inPath = NULL; 1140 1117 char* inId = NULL; … … 1147 1124 lib = getObject(*handle); 1148 1125 value = getObject(*valHandle); 1149 1126 1150 1127 if (lib && value) { 1151 // retObj is a borrowed object 1128 // retObj is a borrowed object 1152 1129 // whose contents must not be modified 1153 1130 rpPutObj(lib, inPath, value, inId, *append); … … 1165 1142 inId = NULL; 1166 1143 } 1167 1168 } 1169 1170 int rp_lib_remove (int* handle, char* path, int path_len) 1144 } 1145 1146 int rp_lib_remove(int* handle, char* path, int path_len) 1171 1147 { 1172 1148 int newObjHandle = -1; … … 1174 1150 PyObject* lib = NULL; 1175 1151 PyObject* removedObj = NULL; 1176 1152 1177 1153 char* inPath = NULL; 1178 1154 … … 1185 1161 if (lib) { 1186 1162 removedObj = rpRemove(lib, inPath); 1187 1163 1188 1164 if (removedObj) { 1189 1165 newObjHandle = storeObject(removedObj); 1190 1166 // Py_DECREF(removedObj); 1191 1167 } 1192 1193 1168 } 1194 1169 } 1195 1170 } 1196 1171 1197 1172 if (inPath) { 1198 1173 free(inPath); … … 1203 1178 } 1204 1179 1205 int rp_lib_xml_len 1180 int rp_lib_xml_len(int* handle) 1206 1181 { 1207 1182 int length = -1; … … 1229 1204 } 1230 1205 1231 void 1206 void rp_lib_xml(int* handle, char* retText, int retText_len) 1232 1207 { 1233 1208 // int length_in = 0; … … 1237 1212 1238 1213 PyObject* lib = NULL; 1239 1214 1240 1215 if (rapptureStarted) { 1241 1216 if ((handle) && (*handle != 0)) { … … 1244 1219 if (lib) { 1245 1220 xmlText = rpXml(lib); 1246 1221 1247 1222 if (xmlText) { 1248 1223 … … 1266 1241 free(xmlText); 1267 1242 } 1268 1269 1243 } 1270 1244 } … … 1321 1295 1322 1296 RpDictEntry DICT_TEMPLATE *hPtr; 1323 // RpDictIterator DICT_TEMPLATE iter((RpDict&)*this); 1297 // RpDictIterator DICT_TEMPLATE iter((RpDict&)*this); 1324 1298 RpDictIterator DICT_TEMPLATE iter(fortObjDict); 1325 1326 hPtr = iter.first(); 1327 1299 1300 hPtr = iter.first(); 1301 1328 1302 while (hPtr) { 1329 1303 Py_DECREF(*(hPtr->getValue())); 1330 1304 hPtr->erase(); 1331 hPtr = iter.next(); 1305 hPtr = iter.next(); 1332 1306 } 1333 1307 … … 1341 1315 } 1342 1316 1343 void rp_result(int* handle) { 1317 void rp_result(int* handle) 1318 { 1344 1319 PyObject* lib = NULL; 1345 1320 … … 1353 1328 } 1354 1329 1355 int objType( char* flavor) 1330 int objType( char* flavor) 1356 1331 { 1357 1332 if (flavor == NULL) { … … 1359 1334 return 0; 1360 1335 } 1361 else if ((*flavor == 'o')&&(strncmp(flavor,"object", 6)==0)){1336 else if ((*flavor == 'o') && (strncmp(flavor,"object", 6) == 0)) { 1362 1337 // return a PyObject* 1363 1338 return 0; 1364 1339 } 1365 else if ( 1366 ((*flavor == 't')&&(strncmp(flavor,"type", 4) == 0)) 1367 ||((*flavor == 'i')&&(strncmp(flavor,"id", 2) == 0)) 1368 ||((*flavor == 'c')&&(strncmp(flavor,"component", 9) == 0))) 1340 else if (((*flavor == 't') && (strncmp(flavor,"type", 4) == 0)) || 1341 ((*flavor == 'i') && (strncmp(flavor,"id", 2) == 0)) || 1342 ((*flavor == 'c') && (strncmp(flavor,"component", 9) == 0))) 1369 1343 { 1370 1344 // return a char* … … 1378 1352 } 1379 1353 1380 int storeObject(PyObject* objectName) {1381 1354 int storeObject(PyObject* objectName) 1355 { 1382 1356 int retVal = -1; 1383 1357 int dictKey = fortObjDict.size(); … … 1388 1362 // no error checking to make sure it was successful in entering 1389 1363 // the new entry. 1390 fortObjDict.set(dictKey,objectName, &newEntry); 1391 } 1392 1364 fortObjDict.set(dictKey,objectName, &newEntry); 1365 } 1366 1393 1367 retVal = dictKey; 1394 1368 return retVal; 1395 1369 } 1396 1370 1397 PyObject* getObject(int objKey) {1398 1371 PyObject* getObject(int objKey) 1372 { 1399 1373 PyObject* retVal = *(fortObjDict.find(objKey).getValue()); 1400 1374 … … 1404 1378 1405 1379 return retVal; 1406 1407 } 1380 } -
trunk/src/core/scew_extras.c
r5673 r5730 119 119 } 120 120 121 122 121 XML_Char const* 123 scew_element_set_contents_binary( 124 125 unsigned int* nbytes)122 scew_element_set_contents_binary(scew_element* element, 123 XML_Char const* bytes, 124 unsigned int* nbytes) 126 125 { 127 126 XML_Char* out = NULL;
Note: See TracChangeset
for help on using the changeset viewer.