RDLINE(2) NAME rdline, rdlnlen, rdinit, rdfree SYNOPSIS #include "misc.c" Rdbuf *rdinit(int fd, int size); char *rdline(Rdbuf *rb) int rdlnlen(Rdbuf *rb) void rdfree(Rdbuf *rb) DESCRIPTION Rbinit() initializes a buffer of given size. You need not worry about the size. If the size is smaller for reading a line, then rdline() automatically reallocate the buffer. Rdfree() frees the allocated memory. Rdline() fixes the problem in Brdline() of BIO(2). That is, rdline() never loses last line even if the file does not end with '\n'. At end-of-file, rdline() returns nil. If the file is empty, rdline() returns nil. fd = open("foo.txt", OREAD); rb = rdinit(fd, 32*1024); while((p = rdline(rb))){ /* assign = */ /* you do something here. * the code below is an example */ print("%4d: %s\n", rdlnlen(rb), p); } rdfree(rb); NOTE The synopsis is changed from Kirara2.0. AUTHER Kenji Arisawa