cbmimage
Loading...
Searching...
No Matches
image handling functions

Classes

struct  cbmimage_fileimage_s
 Type that describes a CBM disk image on which to operate. More...
 
struct  cbmimage_i_d40_d64_d71_image_settings_s
 Image specific settings for D40, D64 and D71 images . More...
 
struct  cbmimage_i_d81_image_settings_s
 Image specific settings for D81 images . More...
 
struct  cbmimage_i_d80_d82_image_settings_s
 Image specific settings for D80 and D82 images . More...
 
struct  cbmimage_i_d1m_d2m_d4m_image_settings_s
 Image specific settings for CMD D1M, D2M and D4M images . More...
 
struct  cbmimage_i_dnp_image_settings_s
 Image specific settings for CMD DNP images . More...
 
struct  cbmimage_image_settings_s
 Image specific settings for all types of images . More...
 
struct  cbmimage_image_parameter_s
 Parameter of the image . More...
 

Typedefs

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_i_d40_d64_d71_image_settings_s cbmimage_i_d40_d64_d71_image_settings
 Image specific settings for D40, D64 and D71 images .
 
typedef struct cbmimage_i_d81_image_settings_s cbmimage_i_d81_image_settings
 Image specific settings for D81 images .
 
typedef struct cbmimage_i_d80_d82_image_settings_s cbmimage_i_d80_d82_image_settings
 Image specific settings for D80 and D82 images .
 
typedef struct cbmimage_i_d1m_d2m_d4m_image_settings_s cbmimage_i_d1m_d2m_d4m_image_settings
 Image specific settings for CMD D1M, D2M and D4M images .
 
typedef struct cbmimage_i_dnp_image_settings_s cbmimage_i_dnp_image_settings
 Image specific settings for CMD DNP images .
 
typedef struct cbmimage_image_settings_s cbmimage_image_settings
 Image specific settings for all types of images .
 
typedef struct cbmimage_image_parameter_s cbmimage_image_parameter
 Parameter of the image .
 

Enumerations

enum  cbmimage_imagetype_e {
  TYPE_UNKNOWN , TYPE_D40 , TYPE_D64 , TYPE_D64_40TRACK ,
  TYPE_D64_40TRACK_SPEEDDOS , TYPE_D64_40TRACK_DOLPHIN , TYPE_D64_40TRACK_PROLOGIC , TYPE_D64_42TRACK ,
  TYPE_D71 , TYPE_D81 , TYPE_D80 , TYPE_D82 ,
  TYPE_CMD_D1M , TYPE_CMD_D2M , TYPE_CMD_D4M , TYPE_CMD_NATIVE ,
  TYPE_LAST
}
 The type of the libcbmimage image. More...
 

Functions

void cbmimage_i_create_last_block (cbmimage_fileimage *image)
 
static cbmimage_fileimagecbmimage_i_fileimage_create (const uint8_t *buffer, size_t size, const char *filename, cbmimage_imagetype imagetype_hint)
 
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_fileimagecbmimage_image_open (const uint8_t *buffer, size_t size, cbmimage_imagetype imagetype_hint)
 open an in-memory CBM image
 
cbmimage_fileimagecbmimage_image_openfile (const char *filename, cbmimage_imagetype imagetype_hint)
 open a CBM image from a file
 
void cbmimage_image_readfile (cbmimage_fileimage *image, const char *filename)
 read a file and store it in a given CBM image
 
void cbmimage_image_writefile (cbmimage_fileimage *image, const char *filename)
 write the CBM image to a file
 
void cbmimage_image_close (cbmimage_fileimage *image)
 close a CBM image
 
void cbmimage_image_fat_dump (cbmimage_fileimage *image, int trackformat)
 dump a FAT structure of the image
 
const void * cbmimage_image_get_raw (cbmimage_fileimage *image)
 get a pointer to the raw image contents
 
size_t cbmimage_image_get_raw_size (cbmimage_fileimage *image)
 get the size of the raw image contents
 
const char * cbmimage_get_imagetype_name (cbmimage_fileimage *image)
 get the image type as string
 
const char * cbmimage_get_filename (cbmimage_fileimage *image)
 get the file name of the image
 
uint16_t cbmimage_get_max_track (cbmimage_fileimage *image)
 get the maximum tracks of the image
 
uint16_t cbmimage_get_max_sectors (cbmimage_fileimage *image)
 get the maximum sectors on a track of the image
 
uint16_t cbmimage_get_max_lba (cbmimage_fileimage *image)
 get the maximum LBA of the image
 
uint16_t cbmimage_get_bytes_in_block (cbmimage_fileimage *image)
 get the number of blocks in a block of the image
 
uint16_t cbmimage_get_sectors_in_track (cbmimage_fileimage *image, uint16_t track)
 get the number of sectors on a specific track of the image
 

Detailed Description

Typedef Documentation

◆ cbmimage_i_d1m_d2m_d4m_image_settings

Image specific settings for CMD D1M, D2M and D4M images .

this type contains data that is specific to the D1M, D2M or D4M images

◆ cbmimage_i_d40_d64_d71_image_settings

Image specific settings for D40, D64 and D71 images .

this type contains data that is specific to the D64, D71 and D40 images (which are almost identical)

The main contents are sectors_in_track and track_lba_start. Because these images contain different number of sectors on a track, it is easier to handle it via these arrays instead of calculating it every time it is needed

◆ cbmimage_i_d80_d82_image_settings

Image specific settings for D80 and D82 images .

this type contains data that is specific to the D80 and D82 images (which are almost identical)

The main contents are sectors_in_track and track_lba_start. Because these images contain different number of sectors on a track, it is easier to handle it via these arrays instead of calculating it every time it is needed

◆ cbmimage_i_d81_image_settings

Image specific settings for D81 images .

this type contains data that is specific to the D81 images

◆ cbmimage_i_dnp_image_settings

Image specific settings for CMD DNP images .

this type contains data that is specific to the DNP images

◆ cbmimage_image_parameter

Parameter of the image .

this type contains data that is specific to the image at hand.

It is an own type, so the user cannot accidentially access it.

This type is subject to change and not part of the API.

◆ cbmimage_image_settings

Image specific settings for all types of images .

this type contains data that is specific to each image type, but that is needed from all types.

This type is subject to change and not part of the API.

◆ cbmimage_imagetype

The type of the libcbmimage image.

libcbmimage can handle different types of disk images. This enum contains all the type the libcbmimage can process.

Enumeration Type Documentation

◆ cbmimage_imagetype_e

The type of the libcbmimage image.

libcbmimage can handle different types of disk images. This enum contains all the type the libcbmimage can process.

Enumerator
TYPE_UNKNOWN 

the image type is unknown. In this case, libcbmimage tries to determine the type itself.

TYPE_D40 

2040/3040 5,25" SS format (similar to D64, but 20 sectors on track 18-24)

TYPE_D64 

2031/1540/1541/1570 5,25" SS file format

TYPE_D64_40TRACK 

1541 5,25" SS file format with 40 tracks

TYPE_D64_40TRACK_SPEEDDOS 

1541 5,25" SS file format with 40 tracks, SPEED DOS variant

TYPE_D64_40TRACK_DOLPHIN 

1541 5,25" SS file format with 40 tracks, Dolphin DOS variant

TYPE_D64_40TRACK_PROLOGIC 

1541 5,25" SS file format with 40 tracks, Prologic DOS variant

TYPE_D64_42TRACK 

1541 5,25" SS file format with 42 tracks

TYPE_D71 

1571 5,25" DS file format

TYPE_D81 

1581 3,5" file format

TYPE_D80 

8050 5,25" SS file format

TYPE_D82 

8250 5,25" DS file format

TYPE_CMD_D1M 

CMD FD2000/FD4000 800 KB file format.

TYPE_CMD_D2M 

CMD FD2000/FD4000 1,6 MB file format.

TYPE_CMD_D4M 

CMD FD4000 3,2 MB file format.

TYPE_CMD_NATIVE 

CMD Native Partition file format.

TYPE_LAST 

not a type, just an end marker

Function Documentation

◆ cbmimage_get_bytes_in_block()

uint16_t cbmimage_get_bytes_in_block ( cbmimage_fileimage * image)

get the number of blocks in a block of the image

Parameters
[in]imagepointer to the image data
Returns
Number of bytes in a block in the image
Remarks
  • Most CBM images contain 256 (= 0x100) bytes in each block. Note however that the functions are generic, so thus assumption does not need to hold true.
    In fact, some image types (namely, D81, D1M, D2M, D4M) only give the illusion that the floppy handles 256 byte blocks. The physical blocks have different sizes (512 and 1024 byte blocks)!

    In the future, some image types might present options to address the blocks in these other numberings.

◆ cbmimage_get_filename()

const char * cbmimage_get_filename ( cbmimage_fileimage * image)

get the file name of the image

Parameters
[in]imagepointer to the image data
Returns
Pointer to a string that contains the file name of the image.
Remarks
  • The pointer points inside of the image structure. Do not write to it, as it will break subsequent processes.
  • When the image is closed, the pointer gets invalid.

◆ cbmimage_get_imagetype_name()

const char * cbmimage_get_imagetype_name ( cbmimage_fileimage * image)

get the image type as string

Parameters
[in]imagepointer to the image data
Returns
Pointer to a string that contains the name of the image type.
Remarks
  • The pointer points inside of the image structure. Do not write to it, as it will break subsequent processes.
  • When the image is closed, the pointer gets invalid.

◆ cbmimage_get_max_lba()

uint16_t cbmimage_get_max_lba ( cbmimage_fileimage * image)

get the maximum LBA of the image

Parameters
[in]imagepointer to the image data
Returns
the biggest possible LBA of this image

◆ cbmimage_get_max_sectors()

uint16_t cbmimage_get_max_sectors ( cbmimage_fileimage * image)

get the maximum sectors on a track of the image

Parameters
[in]imagepointer to the image data
Returns
Maximum number of sectors on a track in the image
Remarks
  • This is the maximum number of sectors on a track. Please not that for a specific track, the number of sectors can be lower!
    To obtain the number of sectors on a specific track, use cbmimage_get_sectors_in_track() instead!
  • As the CBM sector numbering goes, the sector range is from 0 to the result of this call minus 1.
    For example, for D64 images, this function will return 21, giving a range of 0 .. 20.

◆ cbmimage_get_max_track()

uint16_t cbmimage_get_max_track ( cbmimage_fileimage * image)

get the maximum tracks of the image

Parameters
[in]imagepointer to the image data
Returns
Number of tracks in the image
Remarks
  • As the CBM track numbering goes, the track range is from 1 to the result of this call.
    For example, for D64 images, this function will return 35, giving a range of 1 .. 35.

◆ cbmimage_get_sectors_in_track()

uint16_t cbmimage_get_sectors_in_track ( cbmimage_fileimage * image,
uint16_t track )

get the number of sectors on a specific track of the image

Parameters
[in]imagepointer to the image data
[in]trackthe track number for which to obtain the number of sectors
Returns
Number of sectors on this specific track in the image
Remarks
  • This is the number of sectors on this specific track. Due to the nature of many CBM disk images, the number of sectors can vary from track to track.
    To obtain the maximum number of sectors on any track, use cbmimage_get_max_sectors() instead!
  • As the CBM sector numbering goes, the sector range is from 0 to the result of this call minus 1.
    For example, for D64 images on the first speed zone (i.e., tracks 1 to 17), this function will return 21, giving a range of 0 .. 20.

◆ cbmimage_i_create_last_block()

void cbmimage_i_create_last_block ( cbmimage_fileimage * image)

store the last block into the image settings structure

It is important to know the last block for some internal tests.

Parameters
[in]imagepointer to the image data

◆ cbmimage_i_fileimage_create()

static cbmimage_fileimage * cbmimage_i_fileimage_create ( const uint8_t * buffer,
size_t size,
const char * filename,
cbmimage_imagetype imagetype_hint )
static

create an image data structure

Internal helper for cbmimage_image_open() and cbmimage_image_openfile(). Create image data structure after all (filename and file data or memory data) are known.

Parameters
[in]bufferpointer to the raw image data
[in]sizethe size of the buffer
[in]filenamepointer to the name of the file that was opened
[in]imagetype_hintIf the type of the image is known, specify it here; otherwise, use TYPE_UNKNOWN.
Returns
pointer to the image data
Todo
add error handling and an error result

◆ cbmimage_image_close()

void cbmimage_image_close ( cbmimage_fileimage * image)

close a CBM image

Upon close, all resources are freed

Parameters
[in]imagepointer to the image data
Remarks

◆ cbmimage_image_fat_dump()

void cbmimage_image_fat_dump ( cbmimage_fileimage * image,
int trackformat )

dump a FAT structure of the image

Parameters
[in]imagepointer to the image data
[in]trackformat
  • if 0, show the FAT as linear following of LBAs.
  • else, show the FAT in the structure that the disk layout defines (track/sector) The value of trackformat defines how many values at most are output into one line

◆ cbmimage_image_file_guesstype()

cbmimage_imagetype cbmimage_image_file_guesstype ( const char * filename)

guess the image type of an image file

Internal helper for cbmimage_image_open() and cbmimage_image_openfile().

Parameters
[in]filenamepointer to the name of the file that should be opened
Returns
the guessed image type
Todo
currently, only the file size is considered. Add more thorough tests

◆ cbmimage_image_get_raw()

const void * cbmimage_image_get_raw ( cbmimage_fileimage * image)

get a pointer to the raw image contents

Parameters
[in]imagepointer to the image data
Returns
  • Pointer to the raw image data
  • 0 if an error occurred
Remarks
  • Be careful! Use the pointer only for reading! libcbmimage can act strangely if essential data is changed without libcbmimage knowing about it!
  • The size of the buffer can be obtained with cbmimage_image_get_raw_size().

◆ cbmimage_image_get_raw_size()

size_t cbmimage_image_get_raw_size ( cbmimage_fileimage * image)

get the size of the raw image contents

Parameters
[in]imagepointer to the image data
Returns
  • size of the raw image contents (in byte)
  • 0 if there is no raw image content
Remarks

◆ cbmimage_image_guesstype()

cbmimage_imagetype cbmimage_image_guesstype ( const uint8_t * buffer,
size_t size,
int * extra_errormap )

guess the image type of an image

Internal helper for cbmimage_image_open() and cbmimage_image_openfile().

Parameters
[in]bufferpointer to the raw image data
[in]sizethe size of the buffer
[in]extra_errormap
  • 0 if the image already has an error map
  • != 0 otherwise
Returns
the guessed image type
Todo
currently, only the file size is considered. Add more thorough tests

◆ cbmimage_image_open()

cbmimage_fileimage * cbmimage_image_open ( const uint8_t * buffer,
size_t size,
cbmimage_imagetype imagetype_hint )

open an in-memory CBM image

Parameters
[in]bufferpointer to the raw image data
[in]sizethe size of the buffer
[in]imagetype_hintIf the type of the image is known, specify it here; otherwise, use TYPE_UNKNOWN.
Returns
pointer to the image data
Remarks

◆ cbmimage_image_openfile()

cbmimage_fileimage * cbmimage_image_openfile ( const char * filename,
cbmimage_imagetype imagetype_hint )

open a CBM image from a file

Parameters
[in]filenamepointer to the name of the file that should be opened
[in]imagetype_hintIf the type of the image is known, specify it here; otherwise, use TYPE_UNKNOWN.
Returns
pointer to the image data
Remarks

◆ cbmimage_image_readfile()

void cbmimage_image_readfile ( cbmimage_fileimage * image,
const char * filename )

read a file and store it in a given CBM image

Parameters
[in]imagepointer to the image data
[in]filenamepointer to the name of the file that should be opened
Todo
add error handling and an error result

◆ cbmimage_image_writefile()

void cbmimage_image_writefile ( cbmimage_fileimage * image,
const char * filename )

write the CBM image to a file

Parameters
[in]imagepointer to the image data
[in]filenamepointer to the name of the file that should be opened
Todo
add error handling and an error result