2005-06-30 07:50:15 +04:00
|
|
|
#ifndef PKTLINE_H
|
|
|
|
#define PKTLINE_H
|
|
|
|
|
2006-06-26 12:27:07 +04:00
|
|
|
#include "git-compat-util.h"
|
2009-10-31 03:47:21 +03:00
|
|
|
#include "strbuf.h"
|
2006-06-26 12:27:07 +04:00
|
|
|
|
2005-06-30 07:50:15 +04:00
|
|
|
/*
|
2013-02-21 00:01:46 +04:00
|
|
|
* Write a packetized stream, where each line is preceded by
|
|
|
|
* its length (including the header) as a 4-byte hex number.
|
|
|
|
* A length of 'zero' means end of stream (and a length of 1-3
|
|
|
|
* would be an error).
|
|
|
|
*
|
|
|
|
* This is all pretty stupid, but we use this packetized line
|
|
|
|
* format to make a streaming format possible without ever
|
|
|
|
* over-running the read buffers. That way we'll never read
|
|
|
|
* into what might be the pack data (which should go to another
|
|
|
|
* process entirely).
|
|
|
|
*
|
|
|
|
* The writing side could use stdio, but since the reading
|
|
|
|
* side can't, we stay with pure read/write interfaces.
|
2005-06-30 07:50:15 +04:00
|
|
|
*/
|
|
|
|
void packet_flush(int fd);
|
2005-08-09 19:30:22 +04:00
|
|
|
void packet_write(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
|
2009-10-31 03:47:21 +03:00
|
|
|
void packet_buf_flush(struct strbuf *buf);
|
|
|
|
void packet_buf_write(struct strbuf *buf, const char *fmt, ...) __attribute__((format (printf, 2, 3)));
|
2005-06-30 07:50:15 +04:00
|
|
|
|
|
|
|
int packet_read_line(int fd, char *buffer, unsigned size);
|
2012-06-19 22:24:50 +04:00
|
|
|
int packet_read(int fd, char *buffer, unsigned size);
|
2009-10-31 03:47:21 +03:00
|
|
|
int packet_get_line(struct strbuf *out, char **src_buf, size_t *src_len);
|
2005-06-30 07:50:15 +04:00
|
|
|
|
|
|
|
#endif
|