From: Francesco Chemolli Date: Tue, 24 Jan 2012 07:18:12 +0000 (+0100) Subject: TYying to emulate some missing mswindows socket defines in own header. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ba3cd7cb98e9cde3d9106447cff53d91a69217b;p=thirdparty%2Fsquid.git TYying to emulate some missing mswindows socket defines in own header. --- diff --git a/compat/cmsg.h b/compat/cmsg.h new file mode 100644 index 0000000000..3441ef29ff --- /dev/null +++ b/compat/cmsg.h @@ -0,0 +1,72 @@ +/* + * Compatibility-layer for CMSG_ + */ + +#ifndef CMSG_H_ +#define CMSG_H_ + +/* mostly windows-specific */ +#ifndef CMSG_SPACE +typedef struct { + unsigned int cmsg_len; + int cmsg_level; + int cmsg_type; + /* followed by UCHAR cmsg_data[]; */ +} cmsghdr; + +/* lifted off https://metacpan.org/source/SAMPO/Socket-PassAccessRights-0.03/passfd.c */ +#ifndef CMSG_DATA +# define CMSG_DATA(cmsg) ((cmsg)->cmsg_data) +#endif + +#ifndef CMSG_NXTHDR +# define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg) +#endif + +#ifndef CMSG_FIRSTHDR +# define CMSG_FIRSTHDR(mhdr) \ + ((size_t) (mhdr)->msg_controllen >= sizeof ( cmsghdr) \ + ? ( cmsghdr *) (mhdr)->msg_control : ( cmsghdr *) NULL) +#endif + +#ifndef CMSG_ALIGN +# define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \ + & ~(sizeof (size_t) - 1)) +#endif + +#ifndef CMSG_SPACE +# define CMSG_SPACE(len) (CMSG_ALIGN (len) \ + + CMSG_ALIGN (sizeof ( cmsghdr))) +#endif + +#ifndef CMSG_LEN +# define CMSG_LEN(len) (CMSG_ALIGN (sizeof ( cmsghdr)) + (len)) +#endif + +struct msghdr { + void *msg_name; /* Address to send to/receive from. */ + socklen_t msg_namelen; /* Length of address data. */ + + struct iovec *msg_iov; /* Vector of data to send/receive into. */ + size_t msg_iovlen; /* Number of elements in the vector. */ + + void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ + size_t msg_controllen; /* Ancillary data buffer length. + !! The type should be socklen_t but the + definition of the kernel is incompatible + with this. */ + + int msg_flags; /* Flags on received message. */ +}; + + +struct iovec { + +}; +struct sockaddr_un { + char sun_path[256]; /* pathname */ +}; + +#endif /* CMSG_SPACE */ + +#endif /* CMSG_H_ */ diff --git a/compat/os/mswin.h b/compat/os/mswin.h index 077e28a71d..055566182a 100644 --- a/compat/os/mswin.h +++ b/compat/os/mswin.h @@ -827,46 +827,6 @@ void syslog(int priority, const char *fmt, ...); #if _SQUID_MINGW_ /* broken mingw header... */ -# ifdef WSA_CMSG_FIRSTHDR -# define CMSG_FIRSTHDR(x) WSA_CMSG_FIRSTHDR(x) -# endif -# ifdef WSA_CMSG_NXTHDR -# define CMSG_NXTHDR(x, y) WSA_CMSG_NXTHDR(x, y) -# endif -# ifdef WSA_CMSG_DATA -# define CMSG_DATA(x) WSA_CMSG_DATA(x) -# endif -# ifdef WSA_CMSG_LEN -# define CMSG_LEN(x) WSA_CMSG_LEN(x) -# endif -# ifdef WSA_CMSG_SPACE -# define CMSG_SPACE(x) WSA_CMSG_SPACE(x) -# endif -# ifdef WSA_CMSG_FIRSTHDR -# define CMSG_FIRSTHDR(x) WSA_CMSG_FIRSTHDR(x) -# endif - -struct msghdr { - void *msg_name; /* Address to send to/receive from. */ - socklen_t msg_namelen; /* Length of address data. */ - - struct iovec *msg_iov; /* Vector of data to send/receive into. */ - size_t msg_iovlen; /* Number of elements in the vector. */ - - void *msg_control; /* Ancillary data (eg BSD filedesc passing). */ - size_t msg_controllen; /* Ancillary data buffer length. - !! The type should be socklen_t but the - definition of the kernel is incompatible - with this. */ - - int msg_flags; /* Flags on received message. */ -}; -struct iovec { - -}; -struct sockaddr_un { - char sun_path[256]; /* pathname */ -}; /* MinGW missing bits from sys/wait.h */ /* A status looks like: diff --git a/src/ipc/TypedMsgHdr.h b/src/ipc/TypedMsgHdr.h index 95afe00dd6..ef7dcbe401 100644 --- a/src/ipc/TypedMsgHdr.h +++ b/src/ipc/TypedMsgHdr.h @@ -17,6 +17,7 @@ #if HAVE_SYS_UN_H #include #endif +#include "compat/cmsg.h" class String;