diff options
| author | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-04 17:41:01 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-04-04 17:41:01 -0400 |
| commit | 20e247e31fb40bf2228a2ed84b93896fc48b5eff (patch) | |
| tree | 91f721c57a0565b66eae16562e1fbbf9a588d324 /include/matfile.h | |
| parent | 0ead69cdfa8886775212a85fed3aa962fc22902a (diff) | |
feat: Producing a Readable MAT-File
Producing a readable MAT-File of a 1x5 Array of doubles. The file is
somewhat manually generated, but currently works.
Diffstat (limited to 'include/matfile.h')
| -rw-r--r-- | include/matfile.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/include/matfile.h b/include/matfile.h new file mode 100644 index 0000000..586dbea --- /dev/null +++ b/include/matfile.h @@ -0,0 +1,92 @@ +#ifndef INCLUDE_MATFILE_H_ +#define INCLUDE_MATFILE_H_ + +#include <stdint.h> +#include <stdbool.h> +#include <stdio.h> + +typedef enum { + miINT8 = 1, + miUINT8 = 2, + miINT16 = 3, + miUINT16 = 4, + miINT32 = 5, + miUINT32 = 6, + miSINGLE = 7, + // 8 -- Reserved + miDOUBLE = 9, + // 10 -- Reserved + // 11 -- Reserved + miINT64 = 12, + miUINT64 = 13, + miMATRIX = 14, + miCOMPRESSED = 15, + miUTF8 = 16, + miUTF16 = 17, + miUTF32 = 18 +} mTypes_t; + +typedef enum { + mxCELL_CLASS = 1, + mxSTRUCT_CLASS = 2, + mxOBJECT_CLASS = 3, + mxCHAR_CLASS = 4, + mxSPARSE_CLASS = 5, + mxDOUBLE_CLASS = 6, + mxSINGLE_CLASS = 7, + mxINT8_CLASS = 8, + mxUINT8_CLASS = 9, + mxINT16_CLASS = 10, + mxUINT16_CLASS = 11, + mxINT32_CLASS = 12, + mxUINT32_CLASS = 13, + mxINT64_CLASS = 14, + mxUINT64_CLASS = 15, +} mClasses_t; + +typedef struct { + char description[116]; + uint32_t subsystem_offset_high; + uint32_t subsystem_offset_low; + uint16_t version; + uint16_t endian_indicator; +} mHeader_t; + +typedef struct { + uint32_t type; + uint32_t size; +} mTag_t; + +typedef struct { + uint16_t type; + uint16_t size; +} mSmallTag_t; + +typedef struct { + mTag_t tag; + void *data; +} mData_t; + +typedef struct { + mSmallTag_t tag; + uint32_t data; +} mSmallData_t; + +typedef struct { + uint8_t class; + struct { + uint8_t unused1 : 1; + uint8_t logical : 1; + uint8_t global : 1; + uint8_t complex : 1; + uint8_t unused2 : 4; + }; + uint16_t unused3; + uint32_t unused0; +} mArrayFlags_t; + +bool write_header(FILE *file); +bool write_data(FILE *file, mData_t data); +bool write_small_data(FILE *file, mSmallData_t data); + +#endif // INCLUDE_MATFILE_H_ |
