1#ifndef LINE_BUFFER_H_
2#define LINE_BUFFER_H_
34
#include "strbuf.h"
56
#define LINE_BUFFER_LEN 10000
78
struct line_buffer {
9char line_buffer[LINE_BUFFER_LEN];
10FILE *infile;
11};
12#define LINE_BUFFER_INIT { "", NULL }
1314
int buffer_init(struct line_buffer *buf, const char *filename);
15int buffer_fdinit(struct line_buffer *buf, int fd);
16int buffer_deinit(struct line_buffer *buf);
1718
int buffer_tmpfile_init(struct line_buffer *buf);
19FILE *buffer_tmpfile_rewind(struct line_buffer *buf); /* prepare to write. */
20long buffer_tmpfile_prepare_to_read(struct line_buffer *buf);
2122
int buffer_ferror(struct line_buffer *buf);
23char *buffer_read_line(struct line_buffer *buf);
24int buffer_read_char(struct line_buffer *buf);
25size_t buffer_read_binary(struct line_buffer *buf, struct strbuf *sb, size_t len);
26/* Returns number of bytes read (not necessarily written). */
27off_t buffer_copy_bytes(struct line_buffer *buf, off_t len);
28off_t buffer_skip_bytes(struct line_buffer *buf, off_t len);
2930
#endif