32 #ifdef HAVE_NBTOOL_CONFIG_H
33 #include "nbtool_config.h"
40 #ifndef HAVE_NBTOOL_CONFIG_H
49 fgetln(FILE *fp,
size_t *len)
51 static char *
buf = NULL;
52 static size_t bufsiz = 0;
58 if ((buf = malloc(bufsiz)) == NULL)
62 if (fgets(buf, bufsiz, fp) == NULL)
66 while ((ptr = strchr(&buf[*len],
'\n')) == NULL) {
67 size_t nbufsiz = bufsiz + BUFSIZ;
68 char *nbuf = realloc(buf, nbufsiz);
79 if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) {
89 *len = (ptr -
buf) + 1;
97 main(
int argc,
char *argv[])
102 while ((p = fgetln(stdin, &len)) != NULL) {
103 (void)printf(
"%zu %s", len, p);