Erich Hoover : include: Add macros for retrieving control message headers.

Alexandre Julliard julliard at winehq.org
Wed Nov 3 11:37:04 CDT 2010


Module: wine
Branch: master
Commit: cac2c176efd85c06b55dfebb623be66ad548b317
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cac2c176efd85c06b55dfebb623be66ad548b317

Author: Erich Hoover <ehoover at mines.edu>
Date:   Tue Nov  2 16:35:04 2010 -0600

include: Add macros for retrieving control message headers.

---

 include/ws2def.h |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/include/ws2def.h b/include/ws2def.h
index 00b10ab..8c1fc4a 100644
--- a/include/ws2def.h
+++ b/include/ws2def.h
@@ -78,4 +78,21 @@ typedef enum {
     ScopeLevelGlobal       = 14
 } SCOPE_LEVEL;
 
+/*
+ * Macros for retrieving control message data returned by WSARecvMsg()
+ */
+#define WSA_CMSG_DATA(cmsg)     ((UCHAR*)((WSACMSGHDR*)(cmsg)+1))
+#define WSA_CMSG_FIRSTHDR(mhdr) ((mhdr)->Control.len >= sizeof(WSACMSGHDR) ? (WSACMSGHDR *) (mhdr)->Control.buf : (WSACMSGHDR *) 0)
+#define WSA_CMSG_ALIGN(len)     (((len) + sizeof(SIZE_T) - 1) & ~(sizeof(SIZE_T) - 1))
+/*
+ * Next Header: If the response is too short (or the next message in the response
+ * is too short) then return NULL, otherwise return the next control message.
+ */
+#define WSA_CMSG_NXTHDR(mhdr,cmsg) \
+        (!(cmsg) ? WSA_CMSG_FIRSTHDR(mhdr) : \
+         ((mhdr)->Control.len < sizeof(WSACMSGHDR) ? NULL : \
+         (((unsigned char*)(((WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)))+1) > ((unsigned char*)(mhdr)->Control.buf + (mhdr)->Control.len)) ? NULL : \
+          (((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)+WSA_CMSG_ALIGN(((WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len)))->cmsg_len) > ((unsigned char*)(mhdr)->Control.buf + (mhdr)->Control.len)) ? NULL : \
+           (WSACMSGHDR*)((unsigned char*)cmsg + WSA_CMSG_ALIGN(cmsg->cmsg_len))))))
+
 #endif /* _WS2DEF_ */




More information about the wine-cvs mailing list