Changeset 788 for trunk


Ignore:
Timestamp:
Jul 30, 2007 10:08:29 AM (17 years ago)
Author:
dkearney
Message:

adjustments to entity references encoding to include the length of the string to encode and decode.
this is used for the python bindings, so we can know the length of the string being returned and allow embedded nulls.

Location:
trunk/src/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/RpEntityRef.cc

    r623 r788  
    4040const char*
    4141EntityRef::decode (
    42     const char* value
     42    const char* value,
     43    unsigned int len
    4344)
    4445{
    4546    unsigned int pos = 0;
    46     unsigned int len = 0;
    4747
    4848    if (value == NULL) {
     
    5252
    5353    _bout.clear();
    54     len = strlen(value);
     54    if (len == 0) {
     55        len = strlen(value);
     56    }
    5557
    5658    while (pos < len) {
     
    112114const char*
    113115EntityRef::encode (
    114     const char* value
     116    const char* value,
     117    unsigned int len
    115118)
    116119{
    117120    unsigned int pos = 0;
    118     unsigned int len = 0;
    119121
    120122
     
    125127
    126128    _bout.clear();
    127     len = strlen(value);
     129    if (len == 0) {
     130        len = strlen(value);
     131    }
    128132
    129133    while (pos < len) {
     
    156160}
    157161
     162int
     163EntityRef::size () {
     164    return _bout.size();
     165}
     166
     167
    158168#ifdef __cplusplus
    159169    } // extern c
  • trunk/src/core/RpEntityRef.h

    r623 r788  
    4242{
    4343    public:
    44         const char* encode (const char* in);
    45         const char* decode (const char* in);
     44        const char* encode (const char* in, unsigned int len);
     45        const char* decode (const char* in, unsigned int len);
     46        int size();
    4647
    4748        EntityRef () {};
  • trunk/src/core/RpLibrary.cc

    r769 r788  
    15391539    status &= Rappture::encoding::decode(inData,0);
    15401540    status.addContext("RpLibrary::getSting");
    1541     inData.append("\0",1);
     1541    // inData.append("\0",1);
    15421542
    15431543    if (translateFlag == RPLIB_TRANSLATE) {
    1544         translatedContents = ERTranslator.decode(inData.bytes());
     1544        translatedContents = ERTranslator.decode(inData.bytes(),inData.size());
    15451545        if (translatedContents == NULL) {
    15461546            // translation failed
     
    15511551        }
    15521552        else {
    1553             retStr = std::string(translatedContents);
     1553            // subtract 1 from size because ERTranslator adds extra NULL
     1554            retStr = std::string(translatedContents,ERTranslator.size()-1);
    15541555            translatedContents = NULL;
    15551556        }
    15561557    }
    15571558    else {
    1558         retStr = std::string(inData.bytes());
     1559        retStr = std::string(inData.bytes(),inData.size());
    15591560    }
    15601561
     
    17011702
    17021703    if (translateFlag == RPLIB_TRANSLATE) {
    1703         translatedContents = ERTranslator.decode(retCStr);
     1704        translatedContents = ERTranslator.decode(retCStr,0);
    17041705        if (translatedContents == NULL) {
    17051706            // translation failed
     
    17691770
    17701771        if (translateFlag == RPLIB_TRANSLATE) {
    1771             translatedContents = ERTranslator.encode(value.c_str());
     1772            translatedContents = ERTranslator.encode(value.c_str(),0);
    17721773        }
    17731774        else {
Note: See TracChangeset for help on using the changeset viewer.