aboutsummaryrefslogtreecommitdiff
path: root/sys/libbio/test.c
blob: 115ee4653bfa0e48a8040885e125fa897691aa81 (plain)
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
#include <u.h>
#include <libn.h>
#include <libbio.h>

// -----------------------------------------------------------------------
// Point of entry for testing


int
main()
{
    error err;
    bio·Tree t;
    mem·Arena *mem;
    Stream    *fd[2];

    io·Peeker     rdr;
    io·Putter     wtr;
    mem·Allocator al;

    mem = mem·newarena(mem·sys, nil);
    rdr = (io·Peeker){.get = &io·getbyte, .unget  = &io·ungetbyte};
    wtr = (io·Putter){.put = &io·putbyte, .putstr = &io·putstring};
    al  = (mem·Allocator) { .alloc = &mem·arenaalloc, .free = nil, };

    fd[0] = io·open("/home/nolln/root/data/test/example.nwk", "r");
    fd[1] = io·open("/home/nolln/root/data/test/example.proc.nwk", "w");

    t   = bio·readnewick(rdr, fd[0], al, mem);
    err = bio·writenewick(t, wtr, fd[1]);

    io·flush(fd[1]);
    io·close(fd[0]); 
    io·close(fd[1]);

    return 0;
}