Add stream helper library

This library provides thread-unsafe fgets()- and fread()-like
functions where the caller does not have to supply a buffer.  It
maintains a couple of static buffers and provides an API to use
them.

[rr: allow input from files other than stdin]
[jn: with tests, documentation, and error handling improvements]

Signed-off-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
David Barr
2010-08-09 17:39:43 -05:00
committed by Junio C Hamano
parent 1d73b52f5b
commit 3bbaec00a8
7 changed files with 274 additions and 2 deletions

12
vcs-svn/line_buffer.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef LINE_BUFFER_H_
#define LINE_BUFFER_H_
int buffer_init(const char *filename);
int buffer_deinit(void);
char *buffer_read_line(void);
char *buffer_read_string(uint32_t len);
void buffer_copy_bytes(uint32_t len);
void buffer_skip_bytes(uint32_t len);
void buffer_reset(void);
#endif