OpenCBM
Macros | Functions
gcr_4b5b.c File Reference

Shared library / DLL for accessing the driver Commodore GCR conversion functions. More...

#include "debug.h"
#include "opencbm.h"
#include <stddef.h>

Go to the source code of this file.

Macros

#define DBG_USERMODE
 
#define DBG_PROGNAME   "OPENCBM.DLL"
 
#define DLL
 mark: We are building the DLL */
 

Functions

int CBMAPIDECL gcr_5_to_4_decode (const unsigned char *source, unsigned char *dest, size_t sourceLength, size_t destLength)
 Decode GCR data. More...
 
int CBMAPIDECL gcr_4_to_5_encode (const unsigned char *source, unsigned char *dest, size_t sourceLength, size_t destLength)
 Encode GCR data. More...
 

Detailed Description

Shared library / DLL for accessing the driver Commodore GCR conversion functions.



Author
Wolfgang Moser

Definition in file gcr_4b5b.c.

Macro Definition Documentation

#define DBG_PROGNAME   "OPENCBM.DLL"

The name of the executable

Definition at line 24 of file gcr_4b5b.c.

#define DBG_USERMODE

Mark: We are in user-space (for debug.h)

Definition at line 21 of file gcr_4b5b.c.

Function Documentation

int CBMAPIDECL gcr_4_to_5_encode ( const unsigned char *  source,
unsigned char *  dest,
size_t  sourceLength,
size_t  destLength 
)

Encode GCR data.

This function encodes a buffer of 4 plain bytes into a buffer of 5 GCR bytes

Parameters
sourceThe pointer to the source buffer of 4 read-only plain bytes
destThe pointer to the destination buffer of 5 GCR bytes
sourceLengthThe size of the source buffer, it should be greater or equal to 4. If the size given is less than or equal to 0 this is taken as assertion, since it denotes unwanted programming behaviour.
destLengthThe size of the destination buffer, it should be greater or equal to 5. If the size given is less than or equal to 0 this is taken as assertion, since it denotes unwanted programming behaviour.
Returns
0 means (partial) success, -1 means failure due to invalid buffer pointers or a sourceLength of less than or equal to 0.

Remarks:

The function in fact can be called with buffer lengths less than recommended, it then does partial conversions as long as there is input available or as long as output buffer bytes are allowed to be written.

The source and destination buffer pointers are allowed to overlap partially. As long as destination is less than or equal to source or as long as destination is bigger than source+3, it is allowed to let the buffers overlap. Other conditions are taken as assertions since conversion errors will occur (data taken as input gets overwritten before). This behaviour allows to construct in-place buffer conversions.

Definition at line 206 of file gcr_4b5b.c.

References DBG_ASSERT, DBG_PREFIX, DBG_WARN, FUNC_ENTER, and FUNC_LEAVE_INT.

int CBMAPIDECL gcr_5_to_4_decode ( const unsigned char *  source,
unsigned char *  dest,
size_t  sourceLength,
size_t  destLength 
)

Decode GCR data.

This function decodes a buffer of 5 GCR bytes into a buffer of 4 plain bytes

Parameters
sourceThe pointer to the source buffer of 5 read-only GCR bytes
destThe pointer to the destination buffer of 4 plain bytes
sourceLengthThe size of the source buffer, it should be greater or equal to 5. If the size given is less than or equal to 0, this is taken as assertion, since it denotes unwanted programming behaviour.
destLengthThe size of the destination buffer, it should be greater or equal to 4. If the size given is less than or equal to 0 this is taken as assertion, since it denotes unwanted programming behaviour.
Returns
0 means (partial) success, -1 means failure due to invalid buffer pointers or a sourceLength of less than or equal to 0. Codes from 1 to 255 denote a bitmask of 8 bits with each representing an illegal GCR nybble code, when set to one.

Remarks:

The function in fact can be called with buffer lengths less than recommended, it then does partial conversions as long as there is input available or as long as output buffer bytes are allowed to be written.

The source and destination buffer pointers are allowed to overlap partially. As long as destination is less than source+2 or as long as destination is bigger than source+4, it is allowed to let the buffers overlap. Other conditions are taken as assertions since conversion errors will occur (data taken as input gets overwritten before). This behaviour allows to construct in-place buffer conversions.

Definition at line 81 of file gcr_4b5b.c.

References DBG_ASSERT, DBG_PREFIX, DBG_WARN, FUNC_ENTER, and FUNC_LEAVE_INT.