]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
TYying to emulate some missing mswindows socket defines in own header.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 24 Jan 2012 07:18:12 +0000 (08:18 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Tue, 24 Jan 2012 07:18:12 +0000 (08:18 +0100)
compat/cmsg.h [new file with mode: 0644]
compat/os/mswin.h
src/ipc/TypedMsgHdr.h

diff --git a/compat/cmsg.h b/compat/cmsg.h
new file mode 100644 (file)
index 0000000..3441ef2
--- /dev/null
@@ -0,0 +1,72 @@
+/*\r
+ * Compatibility-layer for CMSG_\r
+ */\r
+\r
+#ifndef CMSG_H_\r
+#define CMSG_H_\r
+\r
+/* mostly windows-specific */\r
+#ifndef CMSG_SPACE\r
+typedef struct  {\r
+        unsigned int    cmsg_len;\r
+        int  cmsg_level;\r
+        int     cmsg_type;\r
+        /* followed by UCHAR cmsg_data[]; */\r
+} cmsghdr;\r
+\r
+/* lifted off https://metacpan.org/source/SAMPO/Socket-PassAccessRights-0.03/passfd.c */\r
+#ifndef CMSG_DATA\r
+# define CMSG_DATA(cmsg) ((cmsg)->cmsg_data)\r
+#endif\r
+\r
+#ifndef CMSG_NXTHDR\r
+# define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)\r
+#endif\r
+\r
+#ifndef CMSG_FIRSTHDR\r
+# define CMSG_FIRSTHDR(mhdr) \\r
+  ((size_t) (mhdr)->msg_controllen >= sizeof ( cmsghdr)        \\r
+   ? ( cmsghdr *) (mhdr)->msg_control : ( cmsghdr *) NULL)\r
+#endif\r
+\r
+#ifndef CMSG_ALIGN\r
+# define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \\r
+             & ~(sizeof (size_t) - 1))\r
+#endif\r
+\r
+#ifndef CMSG_SPACE\r
+# define CMSG_SPACE(len) (CMSG_ALIGN (len) \\r
+             + CMSG_ALIGN (sizeof ( cmsghdr)))\r
+#endif\r
+\r
+#ifndef CMSG_LEN\r
+# define CMSG_LEN(len)   (CMSG_ALIGN (sizeof ( cmsghdr)) + (len))\r
+#endif\r
+\r
+struct msghdr {\r
+    void *msg_name;             /* Address to send to/receive from.  */\r
+    socklen_t msg_namelen;      /* Length of address data.  */\r
+\r
+    struct iovec *msg_iov;      /* Vector of data to send/receive into.  */\r
+    size_t msg_iovlen;          /* Number of elements in the vector.  */\r
+\r
+    void *msg_control;          /* Ancillary data (eg BSD filedesc passing). */\r
+    size_t msg_controllen;      /* Ancillary data buffer length.\r
+                                   !! The type should be socklen_t but the\r
+                                   definition of the kernel is incompatible\r
+                                   with this.  */\r
+\r
+    int msg_flags;              /* Flags on received message.  */\r
+};\r
+\r
+\r
+struct iovec {\r
+\r
+};\r
+struct sockaddr_un {\r
+        char sun_path[256];   /* pathname */\r
+};\r
+\r
+#endif /* CMSG_SPACE */\r
+\r
+#endif /* CMSG_H_ */\r
index 077e28a71d0c9e1346ed64bf26c60a0a8d20d162..055566182a14ac9294660ab7f0c8582f231eb1ec 100644 (file)
@@ -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:
index 95afe00dd67201606bae090f2e26e68ac79c77fb..ef7dcbe40138b5e5cd75966ffeb2bb6aaf258de3 100644 (file)
@@ -17,6 +17,7 @@
 #if HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif
+#include "compat/cmsg.h"
 
 class String;