-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtdb.h
More file actions
44 lines (38 loc) · 1.09 KB
/
tdb.h
File metadata and controls
44 lines (38 loc) · 1.09 KB
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
#pragma once
#include "../parser/parsetree.h"
#include "../const.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
/*
tdb is a custom file format.
Layout is:
u64bit int - number of records
8bit int - number of columns
For each column:
Byte representing column name length
x bytes for column name
Four bytes for column datatype
Byte for column datalength
Records..
*/
typedef struct TDB {
char alias[CHARMAXSIZE];
u_int32_t records;
size_t colCount;
char lengths[ARRAYMAXSIZE];
Datatype datatypes[ARRAYMAXSIZE];
char colNames[ARRAYMAXSIZE][CHARMAXSIZE];
char path[CHARMAXSIZE];
size_t metadataSize;
} TDB;
size_t writeTdbMetadata(char* path, TDB tbldef);
size_t writeTdbMetadataToFD(FILE* f, TDB tbldef);
TDB readTdbMetadata(char* path);
TDB readTdbMetadaFromFD(FILE* f);
void buildPathToTDBtable(char* ptr_target, char* tblName);
void TDBtoChar(char* buff, void* data, TDB tbldef);