line |
true |
false |
branch |
76
|
0 |
6 |
if (hash_id == 0) { |
82
|
0 |
6 |
assert(tail_bit_index < RHASH_HASH_COUNT); |
86
|
2 |
4 |
if (hash_id == id) { |
93
|
64 |
4 |
for (bit_index = tail_bit_index; id <= hash_id; bit_index++, id = id << 1) { |
94
|
0 |
64 |
assert(id != 0); |
95
|
0 |
64 |
assert(bit_index < RHASH_HASH_COUNT); |
97
|
62 |
2 |
if (hash_id & id) { |
104
|
0 |
4 |
assert(num > 1); |
109
|
0 |
6 |
assert(aligned_size >= sizeof(rhash_context_ext)); |
113
|
0 |
6 |
if (rctx == NULL) return NULL; |
124
|
0 |
6 |
assert(phash_ctx >= (char*)&rctx->vector[num]); |
127
|
66 |
6 |
for (bit_index = tail_bit_index, id = 1 << tail_bit_index, i = 0; |
131
|
64 |
2 |
if ((hash_id & id) != 0) { |
133
|
0 |
64 |
assert(info->context_size > 0); |
134
|
0 |
64 |
assert(((phash_ctx - (char*)0) & 7) == 0); /* hash context is aligned */ |
135
|
0 |
64 |
assert(info->init != NULL); |
141
|
2 |
62 |
if ((id & RHASH_BTIH) != 0) rctx->bt_ctx = phash_ctx; |
158
|
0 |
4 |
if (ctx == 0) return; |
159
|
0 |
4 |
assert(ectx->hash_vector_size <= RHASH_HASH_COUNT); |
163
|
33 |
4 |
for (i = 0; i < ectx->hash_vector_size; i++) { |
165
|
2 |
31 |
if (info->cleanup != 0) { |
178
|
0 |
3 |
assert(ectx->hash_vector_size > 0); |
179
|
0 |
3 |
assert(ectx->hash_vector_size <= RHASH_HASH_COUNT); |
183
|
4 |
3 |
for (i = 0; i < ectx->hash_vector_size; i++) { |
185
|
0 |
4 |
if (info->cleanup != 0) { |
189
|
0 |
4 |
assert(info->init != NULL); |
200
|
0 |
8 |
assert(ectx->hash_vector_size <= RHASH_HASH_COUNT); |
201
|
0 |
8 |
if (ectx->state != STATE_ACTIVE) return 0; /* do nothing if canceled */ |
206
|
66 |
8 |
for (i = 0; i < ectx->hash_vector_size; i++) { |
208
|
0 |
66 |
assert(info->update != 0); |
218
|
8 |
1 |
unsigned char* out = (first_result ? first_result : buffer); |
220
|
0 |
9 |
assert(ectx->hash_vector_size <= RHASH_HASH_COUNT); |
223
|
0 |
9 |
if ((ectx->flags & RCTX_FINALIZED_MASK) == |
227
|
68 |
9 |
for (i = 0; i < ectx->hash_vector_size; i++) { |
229
|
0 |
68 |
assert(info->final != 0); |
230
|
0 |
68 |
assert(info->info->digest_size < sizeof(buffer)); |
255
|
0 |
47 |
assert(ectx); |
256
|
47 |
0 |
assert(ectx->hash_vector_size > 0 && ectx->hash_vector_size <= RHASH_HASH_COUNT); |
|
0 |
47 |
assert(ectx->hash_vector_size > 0 && ectx->hash_vector_size <= RHASH_HASH_COUNT); |
259
|
5 |
42 |
if ((ectx->flags & RCTX_FINALIZED_MASK) == RCTX_AUTO_FINAL) { |
263
|
0 |
47 |
if (hash_id == 0) { |
268
|
0 |
481 |
if (i >= ectx->hash_vector_size) { |
273
|
47 |
434 |
if (info->info->hash_id == hash_id) break; |
277
|
9 |
38 |
if (info->info->flags & F_SWAP32) { |
278
|
0 |
9 |
assert((info->info->digest_size & 3) == 0); |
281
|
3 |
35 |
} else if (info->info->flags & F_SWAP64) { |
301
|
0 |
1 |
if (ctx == NULL) return -1; |
316
|
0 |
0 |
if (ectx->state != STATE_ACTIVE) return 0; /* do nothing if canceled */ |
318
|
0 |
0 |
if (ctx == NULL) { |
324
|
0 |
0 |
if (!pmem) return -1; /* errno is set to ENOMEM according to UNIX 98 */ |
329
|
0 |
0 |
while (!feof(fd)) { |
331
|
0 |
0 |
if (ectx->state != STATE_ACTIVE) break; |
335
|
0 |
0 |
if (ferror(fd)) { |
338
|
0 |
0 |
} else if (length) { |
341
|
0 |
0 |
if (ectx->callback) { |
358
|
0 |
0 |
if (hash_id == 0) { |
363
|
0 |
0 |
if ((fd = fopen(filepath, "rb")) == NULL) return -1; |
365
|
0 |
0 |
if ((ctx = rhash_init(hash_id)) == NULL) { |
420
|
2 |
0 |
if (hash_id == 0 || (hash_id & (hash_id - 1)) != 0) return -1; |
|
0 |
2 |
if (hash_id == 0 || (hash_id & (hash_id - 1)) != 0) return -1; |
427
|
1 |
0 |
return (int)(info ? (info->flags & F_BS32 ? |
|
0 |
1 |
return (int)(info ? (info->flags & F_BS32 ? |
434
|
1 |
0 |
return (info ? info->name : 0); |
440
|
14 |
0 |
return (info ? info->magnet_name : 0); |
450
|
3 |
0 |
if ((flags & RHPR_NO_MAGNET) == 0) { |
454
|
3 |
0 |
if ((flags & RHPR_FILESIZE) != 0) { |
458
|
0 |
3 |
if (num == 0) size++; |
460
|
3 |
3 |
for (; num; num /= 10, size++); |
464
|
1 |
2 |
if (filepath) { |
469
|
8 |
3 |
for (bit = hash & -(int)hash; bit <= hash; bit <<= 1) { |
471
|
1 |
7 |
if ((bit & hash) == 0) continue; |
472
|
0 |
7 |
if ((name = rhash_get_magnet_name(bit)) == 0) continue; |
475
|
1 |
6 |
size += rhash_print(NULL, context, bit, |
488
|
3 |
3 |
if (output == NULL) |
492
|
3 |
0 |
if ((flags & RHPR_NO_MAGNET) == 0) { |
497
|
3 |
0 |
if ((flags & RHPR_FILESIZE) != 0) { |
505
|
1 |
2 |
if (filepath) { |
512
|
6 |
3 |
for (i = 0; i < 2; i++) { |
516
|
3 |
3 |
: hash & ~(RHASH_ED2K | RHASH_AICH)); |
517
|
2 |
4 |
if (!hash) continue; |
520
|
7 |
4 |
for (bit = hash & -(int)hash; bit <= hash; bit <<= 1) { |
522
|
0 |
7 |
if ((bit & hash) == 0) continue; |
523
|
0 |
7 |
if (!(name = rhash_get_magnet_name(bit))) continue; |
530
|
1 |
6 |
output += rhash_print(output, context, bit, |
562
|
0 |
1 |
if (flags & RHPR_URLENCODE) { |
579
|
49 |
5 |
info = (hash_id != 0 ? rhash_info_by_id(hash_id) : |
582
|
0 |
54 |
if (info == NULL) return 0; |
584
|
0 |
54 |
assert(digest_size <= 64); |
587
|
47 |
7 |
if ((flags & RHPR_FORMAT) == 0) { |
589
|
7 |
40 |
flags |= (info->flags & RHASH_INFO_BASE32 ? RHPR_BASE32 : RHPR_HEX); |
592
|
7 |
47 |
if (output == NULL) { |
593
|
0 |
7 |
size_t multiplier = (flags & RHPR_URLENCODE ? 3 : 1); |
609
|
1 |
46 |
if ((flags & ~RHPR_UPPERCASE) == (RHPR_REVERSE | RHPR_HEX)) { |
614
|
8 |
1 |
for (; p < r; p++, r--) { |
656
|
0 |
0 |
if (bt == NULL) return RHASH_ERROR; |
697
|
0 |
0 |
for (i = 0; i < ctx->hash_vector_size; i++) { |
699
|
0 |
0 |
if (info->info->hash_id == (unsigned)ldata) |
717
|
0 |
0 |
if (ldata) ctx->flags |= RCTX_AUTO_FINAL; |