- Timestamp:
- Apr 6, 2009, 10:26:05 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpEncode.cc
r1384 r1385 136 136 137 137 bool 138 Rappture::encoding::encode(Rappture::Outcome & err, Rappture::Buffer& buf,138 Rappture::encoding::encode(Rappture::Outcome &status, Rappture::Buffer& buf, 139 139 unsigned int flags) 140 140 { … … 151 151 } 152 152 if (outData.append(buf.bytes(), buf.size()) != (int)size) { 153 err.addError("can't append %lu bytes", size);154 return false; 155 } 156 if (!outData.encode( err, flags)) {153 status.addError("can't append %lu bytes", size); 154 return false; 155 } 156 if (!outData.encode(status, flags)) { 157 157 return false; 158 158 } … … 174 174 } 175 175 if (buf.append(outData.bytes(),outData.size()) != (int)outData.size()) { 176 err.addError("can't append %d bytes", outData.size());176 status.addError("can't append %d bytes", outData.size()); 177 177 return false; 178 178 } … … 189 189 * 190 190 * Full function call: 191 * Rappture::encoding::decode (buf,flags)191 * Rappture::encoding::decode(context, buf,flags) 192 192 * 193 193 * The check header flag is confusing here. … … 195 195 196 196 bool 197 Rappture::encoding::decode(Rappture::Outcome & err, Rappture::Buffer& buf,198 unsigned int flags)197 Rappture::encoding::decode(Rappture::Outcome &status, Rappture::Buffer& buf, 198 unsigned int flags) 199 199 { 200 200 Rappture::Buffer outData; … … 204 204 size_t size; 205 205 size = buf.size(); 206 if (size <= 0) {206 if (size == 0) { 207 207 return true; // Nothing to decode. 208 208 } 209 209 bytes = buf.bytes(); 210 210 if ((flags & RPENC_RAW) == 0) { 211 if ( strncmp(bytes, "@@RP-ENC:z\n", 11) == 0) {211 if ((size > 11) && (strncmp(bytes, "@@RP-ENC:z\n", 11) == 0)) { 212 212 bytes += 11; 213 213 size -= 11; 214 214 flags &= ~RPENC_B64; 215 215 flags |= RPENC_Z; 216 } else if ( strncmp(bytes, "@@RP-ENC:b64\n", 13) == 0){216 } else if ((size > 13) && (strncmp(bytes, "@@RP-ENC:b64\n", 13) == 0)){ 217 217 bytes += 13; 218 218 size -= 13; 219 219 flags &= ~RPENC_Z; 220 220 flags |= RPENC_B64; 221 } else if ( strncmp(bytes, "@@RP-ENC:zb64\n", 14) == 0){221 } else if ((size > 14) && (strncmp(bytes, "@@RP-ENC:zb64\n", 14) == 0)){ 222 222 bytes += 14; 223 223 size -= 14; … … 229 229 } 230 230 if (outData.append(bytes, size) != (int)size) { 231 err.addError("can't append %d bytes to buffer", size);232 return false; 233 } 234 if (!outData.decode( err, flags)) {231 status.addError("can't append %d bytes to buffer", size); 232 return false; 233 } 234 if (!outData.decode(status, flags)) { 235 235 return false; 236 236 }
Note: See TracChangeset
for help on using the changeset viewer.