Merge branch 'rs/nth-switch-code-simplification'
[git/git.git] / vcs-svn / line_buffer.h
CommitLineData
0009d350
RJ
1#ifndef LINE_BUFFER_H
2#define LINE_BUFFER_H
3bbaec00 3
d350822f
JN
4#include "strbuf.h"
5
6#define LINE_BUFFER_LEN 10000
7
8struct line_buffer {
9 char line_buffer[LINE_BUFFER_LEN];
d350822f
JN
10 FILE *infile;
11};
7e2fe3a9 12#define LINE_BUFFER_INIT { "", NULL }
d350822f 13
e5e45ca1 14int buffer_init(struct line_buffer *buf, const char *filename);
cb3f87cf 15int buffer_fdinit(struct line_buffer *buf, int fd);
e5e45ca1 16int buffer_deinit(struct line_buffer *buf);
b1c9b798
JN
17
18int 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);
21
efc749b4 22int buffer_ferror(struct line_buffer *buf);
e5e45ca1 23char *buffer_read_line(struct line_buffer *buf);
cc193f1f 24int buffer_read_char(struct line_buffer *buf);
896e4bfc 25size_t buffer_read_binary(struct line_buffer *buf, struct strbuf *sb, size_t len);
26557fc1
JN
26/* Returns number of bytes read (not necessarily written). */
27off_t buffer_copy_bytes(struct line_buffer *buf, off_t len);
d234f54b 28off_t buffer_skip_bytes(struct line_buffer *buf, off_t len);
3bbaec00
DB
29
30#endif