Differences From Artifact [1b021abfd1]:
- File src/base64.m — part of check-in [813c00ccf0] at 2013-01-09 22:24:47 on branch trunk — Update copyright. (user: js, size: 4010) [annotate] [blame] [check-ins using]
To Artifact [9189d4cfcf]:
- File
src/base64.m
— part of check-in
[c5ef582958]
at
2013-03-04 17:20:15
on branch trunk
— Replace BOOL with bool.
The only places where BOOL is left are those where they are required by
the ABI. (user: js, size: 4035) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
91 92 93 94 95 96 97 | } [ret makeImmutable]; return ret; } | < > | | | | | | | | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | } [ret makeImmutable]; return ret; } bool of_base64_decode(OFDataArray *data, const char *string, size_t length) { const uint8_t *buffer = (const uint8_t*)string; size_t i; if ((length & 3) != 0) return false; if ([data itemSize] != 1) return false; for (i = 0; i < length; i += 4) { uint32_t sb = 0; uint8_t count = 3; char db[3]; int8_t tmp; if (buffer[i] > 0x7F || buffer[i + 1] > 0x7F || buffer[i + 2] > 0x7F || buffer[i + 3] > 0x7F) return false; if (buffer[i] == '=' || buffer[i + 1] == '=' || (buffer[i + 2] == '=' && buffer[i + 3] != '=')) return false; if (buffer[i + 2] == '=') count--; if (buffer[i + 3] == '=') count--; if ((tmp = of_base64_decode_table[buffer[i]]) == -1) return false; sb |= tmp << 18; if ((tmp = of_base64_decode_table[buffer[i + 1]]) == -1) return false; sb |= tmp << 12; if ((tmp = of_base64_decode_table[buffer[i + 2]]) == -1) return false; sb |= tmp << 6; if ((tmp = of_base64_decode_table[buffer[i + 3]]) == -1) return false; sb |= tmp; db[0] = (sb & 0xFF0000) >> 16; db[1] = (sb & 0x00FF00) >> 8; db[2] = sb & 0x0000FF; [data addItems: db count: count]; } return true; } |