From fc7771f359d377a5fd8c30a92521f09b65347de0 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Tue, 5 Aug 2014 12:20:11 +1000 Subject: [PATCH] SICS-764: Provide access to the asynnet socket descriptor's write buffer. We need this to implement a "capture" command that doesn't cause SICS to commit suicide if you capture a "run" command. NOTE: This is a bit dodgy because we're trusting callers not to modify the write buffer. --- asynnet.c | 11 +++++++++++ asynnet.h | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/asynnet.c b/asynnet.c index b0cdf87c..7b69728b 100644 --- a/asynnet.c +++ b/asynnet.c @@ -632,3 +632,14 @@ int ANETreadTillTerm(int handle, } return ANETTIMEOUT; } + +char *ANETgetWBuffer(int handle) { + pSocketDescriptor sock; + int len; + char *wdata; + + sock = findSocketDescriptor(handle); + wdata = (char *) GetRWBufferData(sock->writeBuffer, &len); + wdata[len] = '\0'; + return wdata; +} diff --git a/asynnet.h b/asynnet.h index 9912b70f..c52566c8 100644 --- a/asynnet.h +++ b/asynnet.h @@ -207,4 +207,9 @@ int ANETreadTillTerm(int handle, * \param userData An opaque pointer with data for lcb */ void ANETsetLog(ANETlog lcb, void *userData); +/** + * \brief Return a pointer to the socket descriptor write buffer + * \param handle Connection object socket handle + */ +char *ANETgetWBuffer(int handle); #endif /*ASYNNET_H_ */