------------------------------------------------------------------------------
| 58 | |
| 59 | //------------------------------------------------------------------------------ |
| 60 | unsigned long vtkBase64Utilities::Encode( |
| 61 | const unsigned char* input, unsigned long length, unsigned char* output, int mark_end) |
| 62 | { |
| 63 | |
| 64 | const unsigned char* ptr = input; |
| 65 | const unsigned char* end = input + length; |
| 66 | unsigned char* optr = output; |
| 67 | |
| 68 | // Encode complete triplet |
| 69 | |
| 70 | while ((end - ptr) >= 3) |
| 71 | { |
| 72 | vtkBase64Utilities::EncodeTriplet( |
| 73 | ptr[0], ptr[1], ptr[2], &optr[0], &optr[1], &optr[2], &optr[3]); |
| 74 | ptr += 3; |
| 75 | optr += 4; |
| 76 | } |
| 77 | |
| 78 | // Encodes a 2-byte ending into 3 bytes and 1 pad byte and writes. |
| 79 | |
| 80 | if (end - ptr == 2) |
| 81 | { |
| 82 | vtkBase64Utilities::EncodePair(ptr[0], ptr[1], &optr[0], &optr[1], &optr[2], &optr[3]); |
| 83 | optr += 4; |
| 84 | } |
| 85 | |
| 86 | // Encodes a 1-byte ending into 2 bytes and 2 pad bytes |
| 87 | |
| 88 | else if (end - ptr == 1) |
| 89 | { |
| 90 | vtkBase64Utilities::EncodeSingle(ptr[0], &optr[0], &optr[1], &optr[2], &optr[3]); |
| 91 | optr += 4; |
| 92 | } |
| 93 | |
| 94 | // Do we need to mark the end |
| 95 | |
| 96 | else if (mark_end) |
| 97 | { |
| 98 | optr[0] = optr[1] = optr[2] = optr[3] = '='; |
| 99 | optr += 4; |
| 100 | } |
| 101 | |
| 102 | return optr - output; |
| 103 | } |
| 104 | |
| 105 | //------------------------------------------------------------------------------ |
| 106 | static constexpr unsigned char vtkBase64UtilitiesDecodeTable[256] = { |
no outgoing calls
no test coverage detected