[gnio] Add GSocketMsgFlags enum with computed values



commit 05ceaff228d74c2c0ac0a5faab908f5048385830
Author: Alexander Larsson <alexl redhat com>
Date:   Wed May 6 16:19:03 2009 +0200

    Add GSocketMsgFlags enum with computed values
---
 configure.ac  |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gio/gsocket.h |   11 +++++++++
 2 files changed, 78 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 5400f3c..c2c1f8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,6 +120,73 @@ AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
 AM_CONDITIONAL(OS_UNIX, test "$os_win32" != "yes")
 AM_CONDITIONAL(OS_LINUX, test "$os_linux" = "yes")
 
+# GLIB_CHECK_VALUE(SYMBOL, INCLUDES, ACTION-IF-FAIL)
+# ---------------------------------------------------------------
+AC_DEFUN([GLIB_CHECK_VALUE],
+[AC_CACHE_CHECK([value of $1], AS_TR_SH([glib_cv_value_$1]),
+  [_AC_COMPUTE_INT([$1], AS_TR_SH([glib_cv_value_$1]), [$2], [$3])])
+])dnl
+
+# Internet address families
+if test $os_win32 = yes; then
+  glib_inet_includes=["
+#include <winsock2.h>
+  "]
+else
+  glib_inet_includes=["
+#include <sys/types.h>
+#include <sys/socket.h>
+  "]
+fi
+
+glib_failed=false
+GLIB_CHECK_VALUE(MSG_PEEK, $glib_inet_includes, glib_failed=true)
+GLIB_CHECK_VALUE(MSG_OOB, $glib_inet_includes, glib_failed=true)
+GLIB_CHECK_VALUE(MSG_DONTROUTE, $glib_inet_includes, glib_failed=true)
+if $glib_failed ; then
+  AC_MSG_ERROR([Could not determine values for MSG_* constants])
+fi
+
+AC_CONFIG_COMMANDS([gio/gnioconfig.h],
+[
+	outfile=gnioconfig.h-tmp
+	cat > $outfile <<\_______EOF
+/* gnioconfig.h
+ *
+ * This is a generated file.  Please modify 'configure.in'
+ */
+
+#ifndef __G_NIOCONFIG_H__
+#define __G_NIOCONFIG_H__
+
+#include <glib/gmacros.h>
+
+_______EOF
+
+	cat >>$outfile <<_______EOF
+#define GLIB_SYSDEF_MSG_OOB $g_msg_oob
+#define GLIB_SYSDEF_MSG_PEEK $g_msg_peek
+#define GLIB_SYSDEF_MSG_DONTROUTE $g_msg_dontroute
+_______EOF
+
+	cat >>$outfile <<_______EOF
+
+#endif /* GNIOCONFIG_H */
+_______EOF
+
+	if cmp -s $outfile gio/gnioconfig.h; then
+	  AC_MSG_NOTICE([gnioconfig.h is unchanged])
+	  rm -f $outfile
+	else
+	  mv $outfile gio/gnioconfig.h
+	fi
+],[
+g_msg_peek=$glib_cv_value_MSG_PEEK
+g_msg_oob=$glib_cv_value_MSG_OOB
+g_msg_dontroute=$glib_cv_value_MSG_DONTROUTE
+])
+
+
 AC_OUTPUT([
   docs/reference/gio/Makefile
   docs/reference/Makefile
diff --git a/gio/gsocket.h b/gio/gsocket.h
index 49a5940..dd65b29 100644
--- a/gio/gsocket.h
+++ b/gio/gsocket.h
@@ -21,6 +21,9 @@
 #ifndef _gsocket_h_
 #define _gsocket_h_
 
+/* TODO: On merge, move to glibconfig.h */
+#include <gio/gnioconfig.h>
+
 #include <gio/gsocketcontrolmessage.h>
 #include <gio/gsocketaddress.h>
 #include <gio/gioenums.h>
@@ -62,6 +65,14 @@ typedef enum
   G_SOCKET_TYPE_SEQPACKET,
 } GSocketType;
 
+typedef enum
+{
+  G_SOCKET_MSG_INVALID,
+  G_SOCKET_MSG_OOB = GLIB_SYSDEF_MSG_OOB,
+  G_SOCKET_MSG_PEEK = GLIB_SYSDEF_MSG_PEEK,
+  G_SOCKET_MSG_DONTROUTE = GLIB_SYSDEF_MSG_DONTROUTE
+} GSocketMsgFlags;
+
 typedef struct
 {
   gpointer buffer;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]