list.c (483B)
1 #include <u.h> 2 #include <libc.h> 3 4 #include "binlist/list.h" 5 6 Node sublist[] = { 7 {CData, 5, "hello"}, 8 {CData, 5, "world"}, 9 {CNull, 0, nil}, 10 }; 11 12 Node list[] = { 13 {CData, 5, "hwlst"}, 14 {CList, 0, sublist}, 15 {CNull, 0, nil}, 16 }; 17 18 void 19 main(void) 20 { 21 int fd = create("/tmp/blk", ORDWR, 0666); 22 23 writelist(fd, list); 24 25 seek(fd, 0, 0); 26 Node n; 27 readnodeheader(fd, &n); 28 seek(fd, n.count, 1); 29 30 Node *node = readlist(fd); 31 32 print("type %uhhd, count %ud\n", node[1].type, node[1].count); 33 }