summaryrefslogtreecommitdiff
path: root/rbutil/sansapatcher/sansapatcher.c
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/sansapatcher/sansapatcher.c')
-rw-r--r--rbutil/sansapatcher/sansapatcher.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c
index e2e9c88936..8d3191901a 100644
--- a/rbutil/sansapatcher/sansapatcher.c
+++ b/rbutil/sansapatcher/sansapatcher.c
@@ -173,10 +173,10 @@ sansa_memmem (haystack, haystack_len, needle, needle_len)
173 173
174 for (begin = (const char *) haystack; begin <= last_possible; ++begin) 174 for (begin = (const char *) haystack; begin <= last_possible; ++begin)
175 if (begin[0] == ((const char *) needle)[0] && 175 if (begin[0] == ((const char *) needle)[0] &&
176 !memcmp ((const void *) &begin[1], 176 !memcmp ((const void *) &begin[1],
177 (const void *) ((const char *) needle + 1), 177 (const void *) ((const char *) needle + 1),
178 needle_len - 1)) 178 needle_len - 1))
179 return (void *) begin; 179 return (void *) begin;
180 180
181 return NULL; 181 return NULL;
182} 182}
@@ -197,15 +197,15 @@ sansa_memmem (haystack, haystack_len, needle, needle_len)
197 */ 197 */
198 198
199/* crc_tab[] -- this crcTable is being build by chksum_crc32GenTab(). 199/* crc_tab[] -- this crcTable is being build by chksum_crc32GenTab().
200 * so make sure, you call it before using the other 200 * so make sure, you call it before using the other
201 * functions! 201 * functions!
202 */ 202 */
203static unsigned int crc_tab[256]; 203static unsigned int crc_tab[256];
204 204
205/* chksum_crc() -- to a given block, this one calculates the 205/* chksum_crc() -- to a given block, this one calculates the
206 * crc32-checksum until the length is 206 * crc32-checksum until the length is
207 * reached. the crc32-checksum will be 207 * reached. the crc32-checksum will be
208 * the result. 208 * the result.
209 */ 209 */
210static unsigned int chksum_crc32 (const unsigned char *block, unsigned int length) 210static unsigned int chksum_crc32 (const unsigned char *block, unsigned int length)
211{ 211{
@@ -221,32 +221,32 @@ static unsigned int chksum_crc32 (const unsigned char *block, unsigned int lengt
221} 221}
222 222
223/* chksum_crc32gentab() -- to a global crc_tab[256], this one will 223/* chksum_crc32gentab() -- to a global crc_tab[256], this one will
224 * calculate the crcTable for crc32-checksums. 224 * calculate the crcTable for crc32-checksums.
225 * it is generated to the polynom [..] 225 * it is generated to the polynom [..]
226 */ 226 */
227 227
228static void chksum_crc32gentab (void) 228static void chksum_crc32gentab (void)
229{ 229{
230 unsigned long crc, poly; 230 unsigned long crc, poly;
231 int i, j; 231 int i, j;
232 232
233 poly = 0xEDB88320L; 233 poly = 0xEDB88320L;
234 for (i = 0; i < 256; i++) 234 for (i = 0; i < 256; i++)
235 { 235 {
236 crc = i; 236 crc = i;
237 for (j = 8; j > 0; j--) 237 for (j = 8; j > 0; j--)
238 { 238 {
239 if (crc & 1) 239 if (crc & 1)
240 { 240 {
241 crc = (crc >> 1) ^ poly; 241 crc = (crc >> 1) ^ poly;
242 } 242 }
243 else 243 else
244 { 244 {
245 crc >>= 1; 245 crc >>= 1;
246 } 246 }
247 } 247 }
248 crc_tab[i] = crc; 248 crc_tab[i] = crc;
249 } 249 }
250} 250}
251 251
252/* Known keys for Sansa E200 and C200 firmwares: */ 252/* Known keys for Sansa E200 and C200 firmwares: */