mirror of
https://github.com/git/git.git
synced 2026-01-10 10:13:33 +00:00
pkt-line: add functions to read/write flush terminated packet streams
write_packetized_from_fd() and write_packetized_from_buf() write a stream of packets. All content packets use the maximal packet size except for the last one. After the last content packet a `flush` control packet is written. read_packetized_to_strbuf() reads arbitrary sized packets until it detects a `flush` packet. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
edfb780cd4
commit
bb643d8bf8
@@ -25,6 +25,8 @@ void packet_buf_flush(struct strbuf *buf);
|
||||
void packet_buf_write(struct strbuf *buf, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
|
||||
int packet_flush_gently(int fd);
|
||||
int packet_write_fmt_gently(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
|
||||
int write_packetized_from_fd(int fd_in, int fd_out);
|
||||
int write_packetized_from_buf(const char *src_in, size_t len, int fd_out);
|
||||
|
||||
/*
|
||||
* Read a packetized line into the buffer, which must be at least size bytes
|
||||
@@ -77,8 +79,14 @@ char *packet_read_line(int fd, int *size);
|
||||
*/
|
||||
char *packet_read_line_buf(char **src_buf, size_t *src_len, int *size);
|
||||
|
||||
/*
|
||||
* Reads a stream of variable sized packets until a flush packet is detected.
|
||||
*/
|
||||
ssize_t read_packetized_to_strbuf(int fd_in, struct strbuf *sb_out);
|
||||
|
||||
#define DEFAULT_PACKET_MAX 1000
|
||||
#define LARGE_PACKET_MAX 65520
|
||||
#define LARGE_PACKET_DATA_MAX (LARGE_PACKET_MAX - 4)
|
||||
extern char packet_buffer[LARGE_PACKET_MAX];
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user