libsf3
|
#include <stdint.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | sf3_str8 |
struct | sf3_str16 |
struct | sf3_str32 |
struct | sf3_str64 |
struct | sf3_identifier |
The basic header structure of every SF3 file. More... | |
Macros | |
#define | SF3_PACK __attribute__((packed)) |
#define | SF3_EXPORT static |
#define | SF3_INLINE static inline |
#define | SF3_SKIP_STR(STR) ((STR).str+(STR).length) |
Macro to retrieve a pointer past the variable size of an SF3 string. | |
#define | SF3_SKIP_STRP(STR) ((STR)->str+(STR)->length) |
#define | SF3_MAGIC {0x81, 0x53, 0x46, 0x33, 0x00, 0xE0, 0xD0, 0x0D, 0x0A, 0x0A} |
The SF3 file header magic identifier bytes. | |
Typedefs | |
typedef uint32_t | sf3_crc32_checksum |
Type for a CRC32 checksum. | |
typedef uint8_t | sf3_format_id |
typedef struct SF3_PACK sf3_str8 | sf3_str8 |
typedef struct SF3_PACK sf3_str16 | sf3_str16 |
typedef struct SF3_PACK sf3_str32 | sf3_str32 |
typedef struct SF3_PACK sf3_str64 | sf3_str64 |
Functions | |
SF3_EXPORT int | sf3_check (const void *addr, size_t size) |
SF3_EXPORT sf3_crc32_checksum | sf3_compute_checksum (const void *addr, size_t size) |
Computes a CRC32 checksum of the given block of memory. | |
SF3_EXPORT int | sf3_verify (const void *addr, size_t size) |
SF3_EXPORT int | sf3_write_header (sf3_format_id format, void *addr, size_t size) |
Variables | |
const uint32_t | sf3_crc32_tab [] |
#define SF3_EXPORT static |
Definition at line 13 of file sf3_core.h.
#define SF3_INLINE static inline |
Definition at line 16 of file sf3_core.h.
#define SF3_MAGIC {0x81, 0x53, 0x46, 0x33, 0x00, 0xE0, 0xD0, 0x0D, 0x0A, 0x0A} |
The SF3 file header magic identifier bytes.
Definition at line 67 of file sf3_core.h.
#define SF3_PACK __attribute__((packed)) |
Definition at line 9 of file sf3_core.h.
#define SF3_SKIP_STR | ( | STR | ) | ((STR).str+(STR).length) |
Macro to retrieve a pointer past the variable size of an SF3 string.
Definition at line 59 of file sf3_core.h.
#define SF3_SKIP_STRP | ( | STR | ) | ((STR)->str+(STR)->length) |
Macro to retrieve a pointer past the variable size of an SF3 string. This is a variant for the case where the value is a pointer to the string.
Definition at line 64 of file sf3_core.h.
typedef uint32_t sf3_crc32_checksum |
Type for a CRC32 checksum.
Definition at line 20 of file sf3_core.h.
typedef uint8_t sf3_format_id |
Type for an SF3 file format ID. Note that not all values are valid.
Definition at line 24 of file sf3_core.h.
SF3 string with a maximum length of 2^16-1. The string is null-terminated, and the entire length of the char array including the null terminator is in the length field.
SF3 string with a maximum length of 2^32-1. The string is null-terminated, and the entire length of the char array including the null terminator is in the length field.
SF3 string with a maximum length of 2^64-1. The string is null-terminated, and the entire length of the char array including the null terminator is in the length field.
SF3 string with a maximum length of 2^8-1. The string is null-terminated, and the entire length of the char array including the null terminator is in the length field.
SF3_EXPORT int sf3_check | ( | const void * | addr, |
size_t | size | ||
) |
Checks whether a chunk of memory is a valid SF3 file. If valid, returns the format id of the file. If invalid, returns zero.
Note that this will not check whether the entire file contents are valid, they may still be filled with completely bogus values. As such, this function makes no security guarantees whatsoever about the block of memory it is handed.
You will likely want to at least use sf3_verify instead, which will also compute the CRC32 checksum of the file contents to verify its integrity.
Definition at line 94 of file sf3_core.h.
SF3_EXPORT sf3_crc32_checksum sf3_compute_checksum | ( | const void * | addr, |
size_t | size | ||
) |
Computes a CRC32 checksum of the given block of memory.
Definition at line 152 of file sf3_core.h.
SF3_EXPORT int sf3_verify | ( | const void * | addr, |
size_t | size | ||
) |
Checks whether a chunk of memory is a valid SF3 file, including a CRC32 checksum verification. If valid, returns the format id of the file. If invalid, returns zero.
Note that this will not check whether the entire file contents are valid, they may still be filled with completely bogus values. As such, this function makes no security guarantees whatsoever about the block of memory it is handed, other than that the CRC32 checksum in the file header matches the checksum of the file contents.
Definition at line 172 of file sf3_core.h.
SF3_EXPORT int sf3_write_header | ( | sf3_format_id | format, |
void * | addr, | ||
size_t | size | ||
) |
Writes out the SF3 header and checksum.
The actual SF3 contents need to start at ADDR+16, and the header will be filled into the first 16 bytes of ADDR. The CRC32 checksum of the contents is computed for you.
This function returns zero if SIZE is less than 16.
Definition at line 190 of file sf3_core.h.
const uint32_t sf3_crc32_tab[] |
Definition at line 105 of file sf3_core.h.