12 int gcr_decode(
unsigned const char *gcr,
unsigned char *decoded)
14 unsigned char chkref[4], chksum = 0;
31 for(j = 1; j < 4; j++, decoded++)
38 for(i = 1; i < BLOCKSIZE/4; i++)
43 for(j = 0; j < 4; j++, decoded++)
54 return (chkref[1] != chksum) ? 5 : 0;
57 int gcr_encode(
unsigned const char *block,
unsigned char *encoded)
60 unsigned char chkref[4] = { 0x07, 0, 0, 0};
72 for(j = 1; j < 4; j++, block++)
80 chkref[1] ^= (chkref[2] ^ chkref[3]);
83 for(i = 1; i < BLOCKSIZE/4; i++)
88 for(j = 0; j < 4; j++, block++)
101 chkref[2] = chkref[3] = 0;
int CBMAPIDECL gcr_4_to_5_encode(const unsigned char *source, unsigned char *dest, size_t sourceLength, size_t destLength)
Encode GCR data.
int CBMAPIDECL gcr_5_to_4_decode(const unsigned char *source, unsigned char *dest, size_t sourceLength, size_t destLength)
Decode GCR data.