LibSAPLibSAP is a library for handling SAP archives written in ANSI C. It provides both low-level routines handling SAP archives considered as physical format (disk images) and high-level routines handling SAP archives considered as logic format (compatible with DOS BASIC Thomson).
Open a SAP archivesapID sap_OpenArchive(const char filename[], int *format); Returns the identifier of the SAP archive. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_ETOOMANY : too many SAP archives are opened simultaneously. SAP_ENOENT : specified SAP archive does not exist. SAP_EBADF : The specified file is not a SAP archive. Create a SAP archivesapID sap_CreateArchive(const char filename[], int format); Returns the identifier of the SAP archive. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_ETOOMANY : too many SAP archives are opened simultaneously. SAP_EPERM : Can not create file on the recording medium. Close a SAP archiveint sap_CloseArchive(sapID id); Returns SAP_OK. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. Fill a SAP archiveint sap_FillArchive(sapID id, sapsector_t *sapsector); Fills an archive created by sap_CreateArchive() sector by sector, starting from sector 1 of track 0. At each call, the sector number is incremented by 1 and, if the current track becomes full, the next track is selected. Returns SAP_OK. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_ENOSPC : SAP archive is full. Read a SAP sectorint sap_ReadSector(sapID id, int track, int sect, sapsector_t *sapsector); The result is in the structure sapsector. Returns SAP_OK flags or a combination of the following codes: SAP_NO_STD_FMT : the format is non-standard sector. SAP_PROTECTED : the sector is write protected. SAP_BAD_SECTOR : the sector has bad identifiers (track, sector) SAP_CRC_ERROR : CRC error on data sector. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : archive the SAP is being filled by sap_FillArchive() Read a range of SAP sectorsint sap_ReadSectorEx(sapID id, int track, int sect, int nsects, unsigned char data[]); Returns SAP_OK. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() Write a SAP sectorint sap_WriteSector(sapID id, int track, int sect, sapsector_t *sapsector); All fields in the sector must be specified, except the two fields for the CRC which will be calculated by the routine itself. Returns SAP_OK. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() Write a range of SAP sectorsint sap_WriteSectorEx(sapID id, int track, int sect, int nsects, const unsigned char data[]); Returns SAP_OK. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() Format a SAP archiveint sap_FormatArchive(sapID id, int capacity); Returns SAP_OK. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() Store the directory of a SAP archiveint sap_ListArchive(sapID id, char buffer[], int buffer_size); Returns the number of lines of the list. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() Add a file to a SAP archiveint sap_AddFile(sapID id, const char filename[]); Returns the size of the file added in bytes. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() SAP_ENOENT : the file does not exist. SAP_ENFILE : the file is empty. SAP_ENOSPC : the SAP archive directory is full. SAP_EFBIG : the file is too big compared with the free space of the SAP archive. Delete a file in a SAP archiveint sap_DeleteFile(sapID id, const char pattern[]); Returns the size of the file(s) deleted in bytes. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() SAP_ENOENT : the file does not exist. Extract a file from a SAP archiveint sap_ExtractFile(sapID id, const char pattern[]); Returns the size of the file(s) extracted in bytes. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() SAP_ENOENT : the file does not exist in the SAP archive (invalid error when pattern contains at least one wildcard). SAP_EPERM : Can not write the file to the media. Get informations of a SAP fileint sap_GetFileInfo(sapID id, const char filename[], sapfileinfo_t *info); Returns SAP_OK. On failure, SAP_ERROR is returned and the 'sap_errno' variable is set to one of the following error codes: SAP_EINVAL : SAP archive identifier (SAPID) is invalid. SAP_EEMPTY : SAP archive is empty. SAP_EBUSY : SAP archive is being filled by sap_FillArchive() SAP_ENOENT : the file does not exist. |