lib-util: move set_blocking() call into own file.
authorGünther Deschner <gd@samba.org>
Wed, 10 Jun 2009 19:22:33 +0000 (21:22 +0200)
committerGünther Deschner <gd@samba.org>
Wed, 10 Jun 2009 19:25:57 +0000 (21:25 +0200)
Guenther

lib/util/blocking.c [new file with mode: 0644]
lib/util/config.mk
lib/util/util.c
source3/Makefile.in

diff --git a/lib/util/blocking.c b/lib/util/blocking.c
new file mode 100644 (file)
index 0000000..f5933cc
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Andrew Tridgell 1992-1998
+   Copyright (C) Jeremy Allison 2001-2002
+   Copyright (C) Simo Sorce 2001
+   Copyright (C) Jim McDonough (jmcd@us.ibm.com)  2003.
+   Copyright (C) James J Myers 2003
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "system/network.h"
+#include "system/filesys.h"
+#include "system/locale.h"
+#undef malloc
+#undef strcasecmp
+#undef strncasecmp
+#undef strdup
+#undef realloc
+
+/**
+ Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
+ else
+  if SYSV use O_NDELAY
+  if BSD use FNDELAY
+**/
+
+_PUBLIC_ int set_blocking(int fd, bool set)
+{
+       int val;
+#ifdef O_NONBLOCK
+#define FLAG_TO_SET O_NONBLOCK
+#else
+#ifdef SYSV
+#define FLAG_TO_SET O_NDELAY
+#else /* BSD */
+#define FLAG_TO_SET FNDELAY
+#endif
+#endif
+
+       if((val = fcntl(fd, F_GETFL, 0)) == -1)
+               return -1;
+       if(set) /* Turn blocking on - ie. clear nonblock flag */
+               val &= ~FLAG_TO_SET;
+       else
+               val |= FLAG_TO_SET;
+       return fcntl( fd, F_SETFL, val);
+#undef FLAG_TO_SET
+}
index 3bda8ec188945dc42ccb28a59f7eca8e40876c26..ad39096c5654fff2f950e44a27b0a85f16031768 100644 (file)
@@ -22,6 +22,7 @@ LIBSAMBA-UTIL_OBJ_FILES = $(addprefix $(libutilsrcdir)/, \
                util_file.o \
                data_blob.o \
                util.o \
+               blocking.o \
                util_net.o \
                fsusage.o \
                ms_fnmatch.o \
index 0148bdb00d4d43a4246130b9e5993c6f67253d48..29b47f5858f685cb870e98d861af357a7cc47c7b 100644 (file)
@@ -145,37 +145,6 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid,
 }       
 
 
-/**
- Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
- else
-  if SYSV use O_NDELAY
-  if BSD use FNDELAY
-**/
-
-_PUBLIC_ int set_blocking(int fd, bool set)
-{
-       int val;
-#ifdef O_NONBLOCK
-#define FLAG_TO_SET O_NONBLOCK
-#else
-#ifdef SYSV
-#define FLAG_TO_SET O_NDELAY
-#else /* BSD */
-#define FLAG_TO_SET FNDELAY
-#endif
-#endif
-
-       if((val = fcntl(fd, F_GETFL, 0)) == -1)
-               return -1;
-       if(set) /* Turn blocking on - ie. clear nonblock flag */
-               val &= ~FLAG_TO_SET;
-       else
-               val |= FLAG_TO_SET;
-       return fcntl( fd, F_SETFL, val);
-#undef FLAG_TO_SET
-}
-
-
 /**
  Sleep for a specified number of milliseconds.
 **/
index d93c7a76a5c73a9618c3e0df540ee6e553cea83e..33555846fd779700a3103334e2dd3774b61b13df 100644 (file)
@@ -356,7 +356,8 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
                   ../lib/util/genrand.o ../lib/util/util_net.o \
                   ../lib/util/become_daemon.o ../lib/util/system.o \
                   ../lib/util/tevent_unix.o ../lib/util/tevent_ntstatus.o \
-                  ../lib/util/smb_threads.o ../lib/util/util_id.o
+                  ../lib/util/smb_threads.o ../lib/util/util_id.o \
+                  ../lib/util/blocking.o
 
 CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
                         ../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \