MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / decode_sequence

Function decode_sequence

encoding/encoding.c:674–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

672
673
674static int decode_sequence(const unsigned char *coded, unsigned char *plain) {
675 ENCODING_LOG("[decode_sequence] Starting sequence decoding");
676
677 assert(CHAR_BIT == 8);
678 assert(coded && plain);
679
680 plain[0] = 0;
681 for (int block = 0; block < 8; block++) {
682 int offset = get_offset(block);
683 int octet = get_octet(block);
684
685 ENCODING_LOG("[decode_sequence] Decoding block %d, offset: %d, octet: %d", block, offset, octet);
686
687 int c = decode_char(coded[block]);
688 if (c < 0) {
689 ENCODING_LOG("[decode_sequence] Invalid character at block %d", block);
690 return octet;
691 }
692
693 plain[octet] |= shift_left(c, offset);
694 if (offset < 0) {
695 assert(octet < 4);
696 plain[octet + 1] = shift_left(c, 8 + offset);
697 ENCODING_LOG("[decode_sequence] Block overflows to next octet.");
698 }
699 }
700
701 ENCODING_LOG("[decode_sequence] Decoding completed successfully");
702 return 5;
703}
704
705
706/**

Callers 1

Calls 4

get_offsetFunction · 0.85
get_octetFunction · 0.85
decode_charFunction · 0.85
shift_leftFunction · 0.85

Tested by

no test coverage detected