// // Copyright (c) 2026 Jacob McDonnell // // SPDX-License-Identifier: BSD-2-Clause // #ifndef INCLUDE_MATFILE_H_ #define INCLUDE_MATFILE_H_ #include #include #include 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_