From: "Shawn O. Pearce" <spearce@spearce.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 4/7] Refactor packet_write to prepare to integrate with sideband
Date: Wed, 30 Jan 2008 01:22:06 -0500 [thread overview]
Message-ID: <20080130062206.GD15838@spearce.org> (raw)
Simple refactoring to move the actual formatting into a
helper function. Later we'll integrate this new helper
with sideband support, so we can embed a packet line
within a multiplexed sideband stream.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
pkt-line.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/pkt-line.c b/pkt-line.c
index 355546a..5917e1d 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -43,16 +43,16 @@ void packet_flush(int fd)
}
#define hex(a) (hexchar[(a) & 15])
-void packet_write(int fd, const char *fmt, ...)
+static void packet_vwrite(
+ int fd,
+ const char *fmt,
+ va_list args)
{
static char buffer[1000];
static char hexchar[] = "0123456789abcdef";
- va_list args;
unsigned n;
- va_start(args, fmt);
n = vsnprintf(buffer + 4, sizeof(buffer) - 4, fmt, args);
- va_end(args);
if (n >= sizeof(buffer)-4)
die("protocol error: impossibly long line");
n += 4;
@@ -63,6 +63,15 @@ void packet_write(int fd, const char *fmt, ...)
safe_write(fd, buffer, n);
}
+void packet_write(int fd, const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ packet_vwrite(fd, fmt, args);
+ va_end(args);
+}
+
static void safe_read(int fd, void *buffer, unsigned size)
{
size_t n = 0;
--
1.5.4.rc5.1126.g6ba14
reply other threads:[~2008-01-30 6:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080130062206.GD15838@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).