Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-09-10 14:20:24 +0400
committerJunio C Hamano <junkio@cox.net>2006-09-11 00:36:50 +0400
commit958c24b1b8f463bca857f45c41a2f8198e345c2f (patch)
tree8db09dbe9df18068f063c42d19de06b12d0a2625 /sideband.c
parent49a52b1d1fb120f52de3a67f1e4e5ae81512ab81 (diff)
Move sideband server side support into reusable form.
The server side support; this is just the very low level, and the caller needs to know which band it wants to send things out. Signed-off-by: Junio C Hamano <junkio@cox.net> (cherry picked from b786552b67878c7780c50def4c069d46dc54efbe commit)
Diffstat (limited to 'sideband.c')
-rw-r--r--sideband.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sideband.c b/sideband.c
index 861f6219db..1b14ff8892 100644
--- a/sideband.c
+++ b/sideband.c
@@ -46,3 +46,29 @@ int recv_sideband(const char *me, int in_stream, int out, int err, char *buf, in
}
return 0;
}
+
+/*
+ * fd is connected to the remote side; send the sideband data
+ * over multiplexed packet stream.
+ */
+ssize_t send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max)
+{
+ ssize_t ssz = sz;
+ const char *p = data;
+
+ while (sz) {
+ unsigned n;
+ char hdr[5];
+
+ n = sz;
+ if (packet_max - 5 < n)
+ n = packet_max - 5;
+ sprintf(hdr, "%04x", n + 5);
+ hdr[4] = band;
+ safe_write(fd, hdr, 5);
+ safe_write(fd, p, n);
+ p += n;
+ sz -= n;
+ }
+ return ssz;
+}