-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.c
More file actions
70 lines (65 loc) · 1.91 KB
/
demo.c
File metadata and controls
70 lines (65 loc) · 1.91 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
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
#include <stdio.h>
#include "table.h"
int main(void) {
#define FAIL_IF(x) if ((x) != 0) { goto error; }
table_handle_t h;
static char buf[10000];
static char readbuf[sizeof(buf) * 3];
uint32_t reallen;
int i;
static const char *str[] = {
"0", "1", "2",
"000003", "000000004", "0000005",
"000000006", "0007", "008",
"00000009", "10", "000011",
"0012", "00013", "0000014",
"15", "16", "17",
"00000018", "19", "000020",
"000021", "000000022", "0000023",
"0024", "00025", "0000026",
"00000027", "28", "000029",
"30", "31", "32",
"000033", "000000034", "0000035",
"0036", "00037", "0000038",
"000039", "000000040", "0000041",
"000000042", "0043", "044",
"45", "46", "47",
"0048", "00049", "0000050",
"000051", "000000052", "0000053",
"00000054", "55", "000056",
"000057", "000000058", "0000059",
"60", "61", "62",
"00000063", "64", "000065",
"000000066", "0067", "068",
"000069", "000000070", "0000071",
"0072", "00073", "0000074",
"75", "76", "77",
"000000078", "0079", "080",
"00000081", "82", "000083",
"0084", "00085", "0000086",
"000087", "000000088", "0000089",
"90", "91", "92",
"000093", "000000094", "0000095",
"0096", "00097", "0000098",
"00000099", "100", "000101",
};
const char *title[] = {
"number1 ",
"number2 ",
"value",
};
FAIL_IF(table_init(&h, buf, sizeof(buf), 3, "\n", title));
for (i = 0; i < sizeof(str) / sizeof(str[0]); i++) {
if (table_write(&h, str[i])) {
break;
}
}
FAIL_IF(table_read(&h, readbuf, sizeof(readbuf), &reallen));
printf("%s\n", readbuf);
table_destroy(&h);
printf("ok\n");
return 0;
error:
printf("error\n");
return -1;
}