line |
true |
false |
branch |
94
|
0 |
6 |
if (hash_id == 0) { |
100
|
0 |
6 |
assert(tail_bit_index < RHASH_HASH_COUNT); |
104
|
2 |
4 |
if (hash_id == id) { |
111
|
58 |
4 |
for (bit_index = tail_bit_index; id <= hash_id; bit_index++, id = id << 1) { |
112
|
0 |
58 |
assert(id != 0); |
113
|
0 |
58 |
assert(bit_index < RHASH_HASH_COUNT); |
115
|
56 |
2 |
if (hash_id & id) { |
122
|
0 |
4 |
assert(num > 1); |
127
|
0 |
6 |
assert(aligned_size >= sizeof(rhash_context_ext)); |
131
|
0 |
6 |
if (rctx == NULL) return NULL; |
142
|
0 |
6 |
assert(phash_ctx >= (char*)&rctx->vector[num]); |
145
|
60 |
6 |
for (bit_index = tail_bit_index, id = 1 << tail_bit_index, i = 0; |
149
|
58 |
2 |
if ((hash_id & id) != 0) { |
151
|
0 |
58 |
assert(info->context_size > 0); |
152
|
0 |
58 |
assert(((phash_ctx - (char*)0) & 7) == 0); /* hash context is aligned */ |
153
|
0 |
58 |
assert(info->init != NULL); |
159
|
2 |
56 |
if ((id & RHASH_BTIH) != 0) rctx->bt_ctx = phash_ctx; |
181
|
0 |
4 |
if (ctx == 0) return; |
182
|
0 |
4 |
assert(ectx->hash_vector_size <= RHASH_HASH_COUNT); |
186
|
30 |
4 |
for (i = 0; i < ectx->hash_vector_size; i++) { |
188
|
2 |
28 |
if (info->cleanup != 0) { |
207
|
0 |
3 |
assert(ectx->hash_vector_size > 0); |
208
|
0 |
3 |
assert(ectx->hash_vector_size <= RHASH_HASH_COUNT); |
212
|
4 |
3 |
for (i = 0; i < ectx->hash_vector_size; i++) { |
214
|
0 |
4 |
if (info->cleanup != 0) { |
218
|
0 |
4 |
assert(info->init != NULL); |
238
|
0 |
8 |
assert(ectx->hash_vector_size <= RHASH_HASH_COUNT); |
239
|
0 |
8 |
if (ectx->state != STATE_ACTIVE) return 0; /* do nothing if canceled */ |
244
|
60 |
8 |
for (i = 0; i < ectx->hash_vector_size; i++) { |
246
|
0 |
60 |
assert(info->update != 0); |
263
|
8 |
1 |
unsigned char* out = (first_result ? first_result : buffer); |
265
|
0 |
9 |
assert(ectx->hash_vector_size <= RHASH_HASH_COUNT); |
268
|
0 |
9 |
if ((ectx->flags & RCTX_FINALIZED_MASK) == |
272
|
62 |
9 |
for (i = 0; i < ectx->hash_vector_size; i++) { |
274
|
0 |
62 |
assert(info->final != 0); |
275
|
0 |
62 |
assert(info->info->digest_size < sizeof(buffer)); |
300
|
0 |
44 |
assert(ectx); |
301
|
44 |
0 |
assert(ectx->hash_vector_size > 0 && ectx->hash_vector_size <= RHASH_HASH_COUNT); |
|
0 |
44 |
assert(ectx->hash_vector_size > 0 && ectx->hash_vector_size <= RHASH_HASH_COUNT); |
304
|
5 |
39 |
if ((ectx->flags & RCTX_FINALIZED_MASK) == RCTX_AUTO_FINAL) { |
308
|
0 |
44 |
if (hash_id == 0) { |
313
|
0 |
397 |
if (i >= ectx->hash_vector_size) { |
318
|
44 |
353 |
if (info->info->hash_id == hash_id) break; |
322
|
8 |
36 |
if (info->info->flags & F_SWAP32) { |
323
|
0 |
8 |
assert((info->info->digest_size & 3) == 0); |
326
|
3 |
33 |
} else if (info->info->flags & F_SWAP64) { |
366
|
0 |
1 |
if (ctx == NULL) return -1; |
391
|
0 |
0 |
if (ectx->state != STATE_ACTIVE) return 0; /* do nothing if canceled */ |
393
|
0 |
0 |
if (ctx == NULL) { |
399
|
0 |
0 |
if (!pmem) return -1; /* errno is set to ENOMEM according to UNIX 98 */ |
404
|
0 |
0 |
while (!feof(fd)) { |
406
|
0 |
0 |
if (ectx->state != STATE_ACTIVE) break; |
410
|
0 |
0 |
if (ferror(fd)) { |
413
|
0 |
0 |
} else if (length) { |
416
|
0 |
0 |
if (ectx->callback) { |
441
|
0 |
0 |
if (hash_id == 0) { |
446
|
0 |
0 |
if ((fd = fopen(filepath, "rb")) == NULL) return -1; |
448
|
0 |
0 |
if ((ctx = rhash_init(hash_id)) == NULL) return -1; |
506
|
0 |
62 |
if (hash_id != (hash_id & -(int)hash_id)) return NULL; |
532
|
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; |
545
|
1 |
0 |
return (int)(info ? (info->flags & F_BS32 ? |
|
0 |
1 |
return (int)(info ? (info->flags & F_BS32 ? |
558
|
1 |
0 |
return (info ? info->name : 0); |
572
|
14 |
0 |
return (info ? info->magnet_name : 0); |
582
|
3 |
0 |
if ((flags & RHPR_NO_MAGNET) == 0) { |
586
|
3 |
0 |
if ((flags & RHPR_FILESIZE) != 0) { |
590
|
0 |
3 |
if (num == 0) size++; |
592
|
3 |
3 |
for (; num; num /= 10, size++); |
596
|
1 |
2 |
if (filepath) { |
601
|
8 |
3 |
for (bit = hash & -(int)hash; bit <= hash; bit <<= 1) { |
603
|
1 |
7 |
if ((bit & hash) == 0) continue; |
604
|
0 |
7 |
if ((name = rhash_get_magnet_name(bit)) == 0) continue; |
607
|
1 |
6 |
size += rhash_print(NULL, context, bit, |
634
|
3 |
3 |
if (output == NULL) return rhash_get_magnet_url_size( |
638
|
3 |
0 |
if ((flags & RHPR_NO_MAGNET) == 0) { |
643
|
3 |
0 |
if ((flags & RHPR_FILESIZE) != 0) { |
650
|
1 |
2 |
if (filepath) { |
658
|
6 |
3 |
for (i = 0; i < 2; i++) { |
662
|
3 |
3 |
: hash & ~(RHASH_ED2K | RHASH_AICH)); |
663
|
2 |
4 |
if (!hash) continue; |
666
|
7 |
4 |
for (bit = hash & -(int)hash; bit <= hash; bit <<= 1) { |
668
|
0 |
7 |
if ((bit & hash) == 0) continue; |
669
|
0 |
7 |
if (!(name = rhash_get_magnet_name(bit))) continue; |
676
|
1 |
6 |
output += rhash_print(output, context, bit, |
748
|
46 |
5 |
info = (hash_id != 0 ? rhash_info_by_id(hash_id) : |
751
|
0 |
51 |
if (info == NULL) return 0; |
753
|
0 |
51 |
assert(digest_size <= 64); |
756
|
44 |
7 |
if ((flags & RHPR_FORMAT) == 0) { |
758
|
7 |
37 |
flags |= (info->flags & RHASH_INFO_BASE32 ? RHPR_BASE32 : RHPR_HEX); |
761
|
7 |
44 |
if (output == NULL) { |
777
|
1 |
43 |
if ((flags & ~RHPR_UPPERCASE) == (RHPR_REVERSE | RHPR_HEX)) { |
781
|
8 |
1 |
for (; p < r; p++, r--) { |
823
|
0 |
0 |
if (bt == NULL) return RHASH_ERROR; |
873
|
0 |
0 |
for (i = 0; i < ctx->hash_vector_size; i++) { |
875
|
0 |
0 |
if (info->info->hash_id == (unsigned)ldata) |
893
|
0 |
0 |
if (ldata) ctx->flags |= RCTX_AUTO_FINAL; |