Last change
on this file since 1716 was
1716,
checked in by mmc, 14 years ago
|
Fixed the Perl bindings to handle binary data properly. Users on vhub.org
stumbled into this. Image data was getting truncated on the first embedded
null byte, instead of keeping the entire length of the binary data.
|
File size:
2.0 KB
|
Rev | Line | |
---|
[665] | 1 | #include "rappture.h" |
---|
[481] | 2 | #include <string> |
---|
| 3 | |
---|
| 4 | #include "EXTERN.h" |
---|
| 5 | #include "perl.h" |
---|
| 6 | #include "XSUB.h" |
---|
| 7 | |
---|
| 8 | #include "ppport.h" |
---|
| 9 | |
---|
| 10 | using namespace std; |
---|
| 11 | |
---|
[1089] | 12 | MODULE = Rappture PACKAGE = Rappture::RpLibrary |
---|
[481] | 13 | PROTOTYPES: ENABLE |
---|
| 14 | |
---|
| 15 | RpLibrary * |
---|
| 16 | RpLibrary::new(filename = "") |
---|
[1095] | 17 | const char *filename |
---|
[1089] | 18 | CODE: |
---|
[481] | 19 | RpLibrary *library; |
---|
[1089] | 20 | if ((filename == NULL) || (*filename == '\0')) |
---|
| 21 | library = new RpLibrary(); |
---|
| 22 | else |
---|
| 23 | library = new RpLibrary(filename); |
---|
[481] | 24 | |
---|
[1089] | 25 | if (library->isNull()) |
---|
[481] | 26 | { |
---|
| 27 | delete library; |
---|
[1089] | 28 | XSRETURN_UNDEF; |
---|
[481] | 29 | } |
---|
[1089] | 30 | else |
---|
| 31 | RETVAL = library; |
---|
| 32 | OUTPUT: |
---|
| 33 | RETVAL |
---|
[481] | 34 | |
---|
| 35 | void * |
---|
| 36 | RpLibrary::DESTROY() |
---|
[1089] | 37 | CODE: |
---|
| 38 | RETVAL = 0; |
---|
[481] | 39 | |
---|
[1716] | 40 | SV * |
---|
[481] | 41 | RpLibrary::get( path ) |
---|
[1095] | 42 | const char *path |
---|
[1089] | 43 | CODE: |
---|
| 44 | string result; |
---|
| 45 | result = THIS->get(path); |
---|
[1716] | 46 | RETVAL = newSVpvn(result.data(),result.length()); |
---|
[1089] | 47 | OUTPUT: |
---|
| 48 | RETVAL |
---|
[481] | 49 | |
---|
| 50 | void |
---|
| 51 | RpLibrary::put( path, value, append ) |
---|
[1095] | 52 | const char *path |
---|
| 53 | const char *value |
---|
[481] | 54 | int append |
---|
[1089] | 55 | CODE: |
---|
| 56 | THIS->put(path,value,"",append); |
---|
[591] | 57 | |
---|
[481] | 58 | void |
---|
[605] | 59 | RpLibrary::putFile( path, fileName, compress, append ) |
---|
[1095] | 60 | const char *path |
---|
| 61 | const char *fileName |
---|
[605] | 62 | int compress |
---|
[591] | 63 | int append |
---|
[1089] | 64 | CODE: |
---|
| 65 | THIS->putFile(path,fileName,compress,append); |
---|
[591] | 66 | |
---|
| 67 | void |
---|
[481] | 68 | RpLibrary::result() |
---|
[1089] | 69 | CODE: |
---|
| 70 | THIS->put("tool.version.rappture.language", "perl"); |
---|
| 71 | THIS->result(); |
---|
[481] | 72 | |
---|
[1089] | 73 | MODULE = Rappture PACKAGE = Rappture::RpUnits |
---|
[481] | 74 | |
---|
| 75 | const char * |
---|
| 76 | convert( fromVal, toUnitsName, showUnits = 1 ) |
---|
| 77 | const char *fromVal |
---|
| 78 | const char *toUnitsName |
---|
| 79 | int showUnits |
---|
[1089] | 80 | CODE: |
---|
| 81 | string result; |
---|
| 82 | result = RpUnits::convert(fromVal,toUnitsName,showUnits); |
---|
[481] | 83 | |
---|
| 84 | if (result.empty()) |
---|
| 85 | XSRETURN_UNDEF; |
---|
| 86 | |
---|
[1089] | 87 | RETVAL = result.c_str(); |
---|
| 88 | OUTPUT: |
---|
| 89 | RETVAL |
---|
[665] | 90 | |
---|
[1089] | 91 | MODULE = Rappture PACKAGE = Rappture::Utils |
---|
[665] | 92 | |
---|
| 93 | int |
---|
| 94 | progress( percent, message ) |
---|
| 95 | int percent |
---|
| 96 | const char *message |
---|
[1089] | 97 | CODE: |
---|
| 98 | RETVAL = Rappture::Utils::progress(percent,message); |
---|
| 99 | OUTPUT: |
---|
| 100 | RETVAL |
---|
Note: See
TracBrowser
for help on using the repository browser.