Read integer encoded as 'encoding' from 'p' */
| 577 | |
| 578 | /* Read integer encoded as 'encoding' from 'p' */ |
| 579 | int64_t zipLoadInteger(unsigned char *p, unsigned char encoding) { |
| 580 | int16_t i16; |
| 581 | int32_t i32; |
| 582 | int64_t i64, ret = 0; |
| 583 | if (encoding == ZIP_INT_8B) { |
| 584 | ret = ((int8_t*)p)[0]; |
| 585 | } else if (encoding == ZIP_INT_16B) { |
| 586 | memcpy(&i16,p,sizeof(i16)); |
| 587 | memrev16ifbe(&i16); |
| 588 | ret = i16; |
| 589 | } else if (encoding == ZIP_INT_32B) { |
| 590 | memcpy(&i32,p,sizeof(i32)); |
| 591 | memrev32ifbe(&i32); |
| 592 | ret = i32; |
| 593 | } else if (encoding == ZIP_INT_24B) { |
| 594 | i32 = 0; |
| 595 | memcpy(((uint8_t*)&i32)+1,p,sizeof(i32)-sizeof(uint8_t)); |
| 596 | memrev32ifbe(&i32); |
| 597 | ret = i32>>8; |
| 598 | } else if (encoding == ZIP_INT_64B) { |
| 599 | memcpy(&i64,p,sizeof(i64)); |
| 600 | memrev64ifbe(&i64); |
| 601 | ret = i64; |
| 602 | } else if (encoding >= ZIP_INT_IMM_MIN && encoding <= ZIP_INT_IMM_MAX) { |
| 603 | ret = (encoding & ZIP_INT_IMM_MASK)-1; |
| 604 | } else { |
| 605 | assert(NULL); |
| 606 | } |
| 607 | return ret; |
| 608 | } |
| 609 | |
| 610 | /* Fills a struct with all information about an entry. |
| 611 | * This function is the "unsafe" alternative to the one blow. |
no outgoing calls
no test coverage detected