| 350 | } |
| 351 | |
| 352 | int mime_code::pop_end(string* out, size_t max /* = 0 */) |
| 353 | { |
| 354 | if (m_pBuf == NULL) { |
| 355 | logger_error("call push_pop first"); |
| 356 | return -1; |
| 357 | } |
| 358 | if (m_encoding) { |
| 359 | encode_finish(m_pBuf); |
| 360 | } else { |
| 361 | decode_finish(m_pBuf); |
| 362 | } |
| 363 | |
| 364 | if (out == NULL) { |
| 365 | m_pBuf->clear(); |
| 366 | return 0; |
| 367 | } |
| 368 | |
| 369 | size_t n = m_pBuf->length(); |
| 370 | if (n == 0) { |
| 371 | return 0; |
| 372 | } |
| 373 | if (max > 0 && n > max) { |
| 374 | n = max; |
| 375 | } |
| 376 | out->append(m_pBuf->c_str(), n); |
| 377 | m_pBuf->clear(); |
| 378 | return (int) (n); |
| 379 | } |
| 380 | |
| 381 | void mime_code::clear() |
| 382 | { |