mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
pkt-line: add stdio packet write functions
This adds three new functions to pkt-line.c: packet_fwrite, packet_fwrite_fmt and packet_fflush. Besides writing a pktline flush packet, packet_fflush also flushes the stdio buffer of the stream. Helped-by: Patrick Steinhardt <ps@pks.im> Helped-by: Jeff King <peff@peff.net> Signed-off-by: Jacob Vosmaer <jacob@gitlab.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
c4203212e3
commit
96328398b3
@@ -70,3 +70,15 @@ void write_or_die(int fd, const void *buf, size_t count)
|
||||
die_errno("write error");
|
||||
}
|
||||
}
|
||||
|
||||
void fwrite_or_die(FILE *f, const void *buf, size_t count)
|
||||
{
|
||||
if (fwrite(buf, 1, count, f) != count)
|
||||
die_errno("fwrite error");
|
||||
}
|
||||
|
||||
void fflush_or_die(FILE *f)
|
||||
{
|
||||
if (fflush(f))
|
||||
die_errno("fflush error");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user