1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#ifndef INCLUDE_MATFILE_H_
#define INCLUDE_MATFILE_H_
#include <stdbool.h>
#include <stdint.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_
|