|
cbmimage
|
cbmimage API and their definitions More...
#include <stddef.h>#include <stdint.h>

Go to the source code of this file.
Classes | |
| struct | cbmimage_track_sector_s |
| Address on floppy: Track/Sector variant. More... | |
| struct | cbmimage_blockaddress_s |
| Address on drive. More... | |
| struct | cbmimage_dir_header_name_s |
| The name of a directory header or directory entry. More... | |
| struct | cbmimage_dir_header_s |
| A directory header. More... | |
| struct | cbmimage_dir_entry_s |
| A directory entry. More... | |
| struct | cbmimage_fileimage_s |
| Type that describes a CBM disk image on which to operate. More... | |
| struct | cbmimage_loop_s |
| cbmimage loop detector struct More... | |
| struct | cbmimage_blockaccessor_s |
| cbmimage block accessor data structure More... | |
| struct | cbmimage_fat_entry_s |
| cbmimage One entry of the FAT structure More... | |
| struct | cbmimage_fat_s |
| cbmimage FAT structure More... | |
| struct | cbmimage_chain_s |
| type to describe a chain that is followed More... | |
| struct | cbmimage_file_s |
| file handling data More... | |
Macros | |
| #define | CBMIMAGE_TS_INIT(_track, _sector) |
| initializer for a cbmimage_track_sector | |
| #define | CBMIMAGE_TS_SET(_ts, _track, _sector) |
| set a cbmimage_track_sector | |
| #define | CBMIMAGE_TS_CLEAR(_ts) |
| clear a cbmimage_track_sector | |
| #define | CBMIMAGE_BLOCK_INIT(_track, _sector, _lba) |
| initializer for a cbmimage_blockaddress | |
| #define | CBMIMAGE_BLOCK_INIT_FROM_TS(_track, _sector) |
| initializer for a cbmimage_blockaddress | |
| #define | CBMIMAGE_BLOCK_INIT_FROM_LBA(_lba) |
| initializer for a cbmimage_blockaddress | |
| #define | CBMIMAGE_BLOCK_SET_FROM_TS(_image, _block, _track, _sector) |
| initializer for a cbmimage_blockaddress | |
| #define | CBMIMAGE_BLOCK_SET_FROM_LBA(_image, _block, _lba) |
| initializer for a cbmimage_blockaddress | |
Typedefs | |
| typedef enum cbmimage_BAM_state_e | cbmimage_BAM_state |
| state of the BAM | |
| typedef struct cbmimage_track_sector_s | cbmimage_track_sector |
| Address on floppy: Track/Sector variant. | |
| typedef uint16_t | cbmimage_lba |
| Address on floppy: LBA variant. | |
| typedef struct cbmimage_blockaddress_s | cbmimage_blockaddress |
| Address on drive. | |
| typedef enum cbmimage_dir_type_e | cbmimage_dir_type |
| The type of a directory entry cbmimage_dir_entry_s. | |
| typedef enum cbmimage_geos_filetype_e | cbmimage_geos_filetype |
| The GEOS type of a directory entry cbmimage_dir_entry_s. | |
| typedef struct cbmimage_dir_header_name_s | cbmimage_dir_header_name |
| The name of a directory header or directory entry. | |
| typedef struct cbmimage_dir_header_s | cbmimage_dir_header |
| A directory header. | |
| typedef struct cbmimage_dir_entry_s | cbmimage_dir_entry |
| A directory entry. | |
| typedef enum cbmimage_imagetype_e | cbmimage_imagetype |
| The type of the libcbmimage image. | |
| typedef struct cbmimage_fileimage_s | cbmimage_fileimage |
| Type that describes a CBM disk image on which to operate. | |
| typedef struct cbmimage_loop_s | cbmimage_loop |
| cbmimage loop detector struct | |
| typedef struct cbmimage_blockaccessor_s | cbmimage_blockaccessor |
| cbmimage block accessor data structure | |
| typedef struct cbmimage_fat_entry_s | cbmimage_fat_entry |
| cbmimage One entry of the FAT structure | |
| typedef struct cbmimage_fat_s | cbmimage_fat |
| cbmimage FAT structure | |
| typedef struct cbmimage_chain_s | cbmimage_chain |
| type to describe a chain that is followed | |
| typedef struct cbmimage_file_s | cbmimage_file |
| file handling data | |
| typedef void | cbmimage_print_function_type(const char *text) |
| Type for a print() style callback. | |
Functions | |
| cbmimage_imagetype | cbmimage_image_guesstype (const uint8_t *buffer, size_t size, int *extra_errormap) |
| cbmimage_imagetype | cbmimage_image_file_guesstype (const char *filename) |
| cbmimage_fileimage * | cbmimage_image_open (const uint8_t *buffer, size_t size, cbmimage_imagetype) |
| open an in-memory CBM image | |
| cbmimage_fileimage * | cbmimage_image_openfile (const char *filename, cbmimage_imagetype) |
| open a CBM image from a file | |
| void | cbmimage_image_readfile (cbmimage_fileimage *, const char *filename) |
| read a file and store it in a given CBM image | |
| void | cbmimage_image_writefile (cbmimage_fileimage *, const char *filename) |
| write the CBM image to a file | |
| const void * | cbmimage_image_get_raw (cbmimage_fileimage *) |
| get a pointer to the raw image contents | |
| size_t | cbmimage_image_get_raw_size (cbmimage_fileimage *) |
| get the size of the raw image contents | |
| void | cbmimage_image_close (cbmimage_fileimage *) |
| close a CBM image | |
| void | cbmimage_image_fat_dump (cbmimage_fileimage *, int linear) |
| dump a FAT structure of the image | |
| const char * | cbmimage_get_imagetype_name (cbmimage_fileimage *) |
| get the image type as string | |
| const char * | cbmimage_get_filename (cbmimage_fileimage *) |
| get the file name of the image | |
| uint16_t | cbmimage_get_max_track (cbmimage_fileimage *) |
| get the maximum tracks of the image | |
| uint16_t | cbmimage_get_max_sectors (cbmimage_fileimage *) |
| get the maximum sectors on a track of the image | |
| uint16_t | cbmimage_get_max_lba (cbmimage_fileimage *) |
| get the maximum LBA of the image | |
| uint16_t | cbmimage_get_bytes_in_block (cbmimage_fileimage *) |
| get the number of blocks in a block of the image | |
| uint16_t | cbmimage_get_sectors_in_track (cbmimage_fileimage *, uint16_t track) |
| get the number of sectors on a specific track of the image | |
| int | cbmimage_blockaddress_ts_exists (cbmimage_fileimage *, uint8_t track, uint8_t sector) |
| check if T/S is valid | |
| int | cbmimage_blockaddress_lba_exists (cbmimage_fileimage *, uint16_t lba) |
| check if LBA is valid | |
| int | cbmimage_blockaddress_init_from_ts (cbmimage_fileimage *, cbmimage_blockaddress *block) |
| initialize a block address from its T/S specification | |
| int | cbmimage_blockaddress_init_from_lba (cbmimage_fileimage *, cbmimage_blockaddress *block) |
| initialize a block address from its T/S specification | |
| int | cbmimage_blockaddress_init_from_ts_value (cbmimage_fileimage *, cbmimage_blockaddress *block, uint8_t track, uint8_t sector) |
| initialize a block address when T/S are given | |
| int | cbmimage_blockaddress_init_from_lba_value (cbmimage_fileimage *, cbmimage_blockaddress *block, uint16_t lba) |
| initialize a block address when LBA is given | |
| int | cbmimage_blockaddress_advance (cbmimage_fileimage *, cbmimage_blockaddress *block) |
| advance a block address, going to the next block | |
| int | cbmimage_blockaddress_advance_in_track (cbmimage_fileimage *, cbmimage_blockaddress *block) |
| advance a block address, going to the next block in the same track | |
| int | cbmimage_blockaddress_add (cbmimage_fileimage *, cbmimage_blockaddress *blockresult, cbmimage_blockaddress block_adder) |
| add two block address together | |
| int | cbmimage_read_block (cbmimage_fileimage *, cbmimage_blockaddress block, void *buffer, size_t buffersize) |
| read a block from the image and copy it into the provided buffer | |
| int | cbmimage_write_block (cbmimage_fileimage *, cbmimage_blockaddress block, void *buffer, size_t buffersize) |
| write a block to the image by copying it from the provided buffer | |
| int | cbmimage_read_next_block (cbmimage_fileimage *, cbmimage_blockaddress *block, void *buffer, size_t buffersize) |
| read the next block from the image and copy it into the provided buffer | |
| cbmimage_blockaccessor * | cbmimage_blockaccessor_create (cbmimage_fileimage *image, cbmimage_blockaddress block) |
| create a block accessor for a specific block | |
| cbmimage_blockaccessor * | cbmimage_blockaccessor_create_from_ts (cbmimage_fileimage *image, uint8_t track, uint8_t sector) |
| create a block accessor for a specific T/S | |
| cbmimage_blockaccessor * | cbmimage_blockaccessor_create_from_lba (cbmimage_fileimage *image, uint16_t lba) |
| create a block accessor for a specific LBA | |
| void | cbmimage_blockaccessor_close (cbmimage_blockaccessor *accessor) |
| close a block accessor, freeing its resources | |
| int | cbmimage_blockaccessor_set_to (cbmimage_blockaccessor *accessor, cbmimage_blockaddress block) |
| set a block accessor for a specific block | |
| int | cbmimage_blockaccessor_set_to_ts (cbmimage_blockaccessor *accessor, uint8_t track, uint8_t sector) |
| set a block accessor for a specific T/S | |
| int | cbmimage_blockaccessor_set_to_lba (cbmimage_blockaccessor *accessor, uint16_t lba) |
| set a block accessor for a specific LBA | |
| int | cbmimage_blockaccessor_advance (cbmimage_blockaccessor *accessor) |
| advance a block accessor to the next block | |
| int | cbmimage_blockaccessor_follow (cbmimage_blockaccessor *accessor) |
| follow the block chain of a block accessor to the next block | |
| int | cbmimage_blockaccessor_get_next_block (cbmimage_blockaccessor *accessor, cbmimage_blockaddress *block_next) |
| get the next block of this accessor if we follow the chain | |
| int | cbmimage_bam_check_consistency (cbmimage_fileimage *) |
| check the consistency of a BAM | |
| int | cbmimage_get_blocks_free (cbmimage_fileimage *) |
| get the count of blocks free | |
| cbmimage_BAM_state | cbmimage_bam_get (cbmimage_fileimage *, cbmimage_blockaddress block) |
| get the unused/used state of a block in the BAM | |
| int | cbmimage_bam_get_free_on_track (cbmimage_fileimage *image, uint8_t track) |
| get the blocks free on a specific track | |
| cbmimage_dir_header * | cbmimage_dir_get_header (cbmimage_fileimage *) |
| get the header entry | |
| void | cbmimage_dir_get_header_close (cbmimage_dir_header *) |
| free the resources from a cbmimage_dir_get_header() | |
| cbmimage_dir_entry * | cbmimage_dir_get_first (cbmimage_fileimage *) |
| get the first (non-empty) directory entry | |
| int | cbmimage_dir_get_next (cbmimage_dir_entry *) |
| get the next (non-empty) directory entry | |
| int | cbmimage_dir_get_is_valid (cbmimage_dir_entry *) |
| get the next (non-empty) directory entry | |
| char * | cbmimage_dir_extract_name (cbmimage_dir_header_name *, char *name, size_t len) |
| extract the name of a directory entry as a C string | |
| int | cbmimage_dir_is_deleted (cbmimage_dir_entry *) |
| check if the directory entry points to a deleted file | |
| int | cbmimage_dir_chdir (cbmimage_dir_entry *) |
| perform a chdir to a partition marked by a directory entry | |
| int | cbmimage_dir_chdir_close (cbmimage_fileimage *) |
| "close a chdir"; that is, go back to the parent directory | |
| void | cbmimage_dir_get_close (cbmimage_dir_entry *) |
| free the resources from a cbmimage_dir_get_first() | |
| cbmimage_loop * | cbmimage_loop_create (cbmimage_fileimage *) |
| create a loop detector data structure | |
| void | cbmimage_loop_close (cbmimage_loop *) |
| free a loop detector data structure | |
| int | cbmimage_loop_mark (cbmimage_loop *, cbmimage_blockaddress block) |
| mark a block as used/visited | |
| int | cbmimage_loop_check (cbmimage_loop *, cbmimage_blockaddress block) |
| check if a block is marked as used/visited | |
| int | cbmimage_validate (cbmimage_fileimage *) |
| validate the disk (and the bam) | |
| cbmimage_file * | cbmimage_file_open_by_name (const char *filename) |
| open a file on the cbmimage where the name is known | |
| cbmimage_file * | cbmimage_file_open_by_dir_entry (cbmimage_dir_entry *dir_entry) |
| open a file on the cbmimage that has already een enumerated | |
| void | cbmimage_file_close (cbmimage_file *file) |
| close a file | |
| int | cbmimage_file_read_next_block (cbmimage_file *file, uint8_t *buffer, size_t buffer_size) |
| read a block from the file | |
| int | cbmimage_print_set_function (cbmimage_print_function_type print_function) |
| set the callback for output from the library | |
| cbmimage_fat * | cbmimage_fat_create (cbmimage_fileimage *image) |
| create a FAT structure | |
| int | cbmimage_fat_set (cbmimage_fat *, cbmimage_blockaddress block, cbmimage_blockaddress target) |
| set a block in the FAT to a target in the FAT | |
| int | cbmimage_fat_clear (cbmimage_fat *, cbmimage_blockaddress block) |
| set a block in the FAT to unused | |
| cbmimage_blockaddress | cbmimage_fat_get (cbmimage_fat *, cbmimage_blockaddress block) |
| get the target of a block in the FAT | |
| int | cbmimage_fat_is_used (cbmimage_fat *, cbmimage_blockaddress block) |
| check if a block in the FAT is marked as used | |
| void | cbmimage_fat_dump (cbmimage_fat *, int linear) |
| dump a FAT structure | |
| void | cbmimage_fat_close (cbmimage_fat *) |
| close a FAT structure | |
| cbmimage_chain * | cbmimage_chain_start (cbmimage_fileimage *, cbmimage_blockaddress) |
| start the chain processing for a file chain | |
| void | cbmimage_chain_close (cbmimage_chain *chain) |
| close the chain structure | |
| int | cbmimage_chain_advance (cbmimage_chain *chain) |
| advance to the next block of this chain | |
| int | cbmimage_chain_last_result (cbmimage_chain *chain) |
| check if this chain has been processed competely | |
| int | cbmimage_chain_is_done (cbmimage_chain *chain) |
| check if this chain has been processed competely | |
| int | cbmimage_chain_is_loop (cbmimage_chain *chain) |
| check if this chain has fallen into a loop | |
| cbmimage_blockaddress | cbmimage_chain_get_current (cbmimage_chain *chain) |
| get the address of the current block in this chain | |
| cbmimage_blockaddress | cbmimage_chain_get_next (cbmimage_chain *chain) |
| get the address of the next block in this chain | |
| uint8_t * | cbmimage_chain_get_data (cbmimage_chain *chain) |
| get a pointer to the data of the current block in this chain | |
Variables | |
| const cbmimage_blockaddress | cbmimage_block_unused |
| Definition of an empty cbmimage_blockaddress. | |
cbmimage API and their definitions
| #define CBMIMAGE_BLOCK_INIT | ( | _track, | |
| _sector, | |||
| _lba ) |
initializer for a cbmimage_blockaddress
This macro can be used like
cbmimage_blockaddress var = CBMIMAGE_BLOCK_INIT(track, sector, lba)
in order to initialize the var.
| [in] | _track | the track to use as initializer |
| [in] | _sector | the sector to use as initializer |
| [in] | _lba | the LBA to use as initializer |
| #define CBMIMAGE_BLOCK_INIT_FROM_LBA | ( | _lba | ) |
initializer for a cbmimage_blockaddress
This macro can be used like
cbmimage_blockaddress var = CBMIMAGE_BLOCK_INIT_FROM_LBA(lba)
in order to initialize the var.
| [in] | _lba | the LBA to use as initializer |
| #define CBMIMAGE_BLOCK_INIT_FROM_TS | ( | _track, | |
| _sector ) |
initializer for a cbmimage_blockaddress
This macro can be used like
cbmimage_blockaddress var = CBMIMAGE_BLOCK_INIT_FROM_TS(track, sector)
in order to initialize the var.
| [in] | _track | the track to use as initializer |
| [in] | _sector | the sector to use as initializer |
| #define CBMIMAGE_BLOCK_SET_FROM_LBA | ( | _image, | |
| _block, | |||
| _lba ) |
initializer for a cbmimage_blockaddress
This macro can be used like
CBMIMAGE_BLOCK_SET_FROM_LBA(image, block, lba)
in order to initialize the var.
| [in] | _image | pointer to the image data |
| [in,out] | _block | the cbmimage_blockaddress to be modified |
| [in] | _lba | the LBA to use as initializer |
| #define CBMIMAGE_BLOCK_SET_FROM_TS | ( | _image, | |
| _block, | |||
| _track, | |||
| _sector ) |
initializer for a cbmimage_blockaddress
This macro can be used like
CBMIMAGE_BLOCK_SET_FROM_TS(image, block, track, sector)
in order to initialize the var.
| [in] | _image | pointer to the image data |
| [in,out] | _block | the cbmimage_blockaddress to be modified |
| [in] | _track | the track to use as initializer |
| [in] | _sector | the sector to use as initializer |
| #define CBMIMAGE_TS_CLEAR | ( | _ts | ) |
clear a cbmimage_track_sector
Clearing a track/sectors means to put it into an "invalid" state
This macro can be used like
CBMIMAGE_TS_CLEAR(var)
in order to initialize the var with track and sector
| [in,out] | _ts | The variable which is modified |
| #define CBMIMAGE_TS_INIT | ( | _track, | |
| _sector ) |
initializer for a cbmimage_track_sector
This macro can be used like
cbmimage_track_sector var = CBMIMAGE_TS_INIT(track, sector)
in order to initialize the var.
| [in] | _track | the track to use as initializer |
| [in] | _sector | the sector to use as initializer |
| #define CBMIMAGE_TS_SET | ( | _ts, | |
| _track, | |||
| _sector ) |
set a cbmimage_track_sector
This macro can be used like
CBMIMAGE_TS_INIT(var, track, sector)
in order to initialize the var with track and sector
| [in,out] | _ts | The variable which is modified |
| [in] | _track | the track to use as initializer |
| [in] | _sector | the sector to use as initializer |
| typedef struct cbmimage_file_s cbmimage_file |
file handling data
The structure is used for processing a file from a file image.
| typedef void cbmimage_print_function_type(const char *text) |
Type for a print() style callback.
Used with cbmimage_print_set_function()
| int cbmimage_blockaddress_lba_exists | ( | cbmimage_fileimage * | image, |
| uint16_t | lba ) |
check if LBA is valid
| [in] | image | pointer to the image data |
| [in] | lba | the LBA of the block to be tested for existance |
| int cbmimage_blockaddress_ts_exists | ( | cbmimage_fileimage * | image, |
| uint8_t | track, | ||
| uint8_t | sector ) |
check if T/S is valid
| [in] | image | pointer to the image data |
| [in] | track | the track of the block to be tested for existance |
| [in] | sector | the sector of the block to be tested for existance |
|
extern |
Definition of an empty cbmimage_blockaddress.
Whenever you need to use an empty or unused block address, you can use this one instead of defining it on your own.