6 #include "line_stream.h"
8 #include "lt/lt_adapters.h"
18 LineStream *create_line_stream(const char *filename,
30 LineStream *line_stream = PUSH_LT(
32 malloc(sizeof(LineStream)),
34 if (line_stream == NULL) {
35 throw_error(ERROR_TYPE_LIBC);
40 line_stream->stream = PUSH_LT(
42 fopen(filename, mode),
44 if (line_stream->stream == NULL) {
45 throw_error(ERROR_TYPE_LIBC);
49 line_stream->buffer = PUSH_LT(
51 malloc(sizeof(char) * capacity),
53 if (line_stream->buffer == NULL) {
54 throw_error(ERROR_TYPE_LIBC);
58 line_stream->capacity = capacity;
63 void destroy_line_stream(LineStream *line_stream)
67 RETURN_LT0(line_stream->lt);
70 const char *line_stream_next(LineStream *line_stream)
73 return fgets(line_stream->buffer,
74 (int) line_stream->capacity,