Flag_Manip.cpp

Go to the documentation of this file.
00001 // Flag_Manip.cpp,v 1.10 2006/02/09 17:03:20 jtc Exp
00002 
00003 #include "ace/Flag_Manip.h"
00004 
00005 #if defined (ACE_LACKS_FCNTL)
00006 #  include "ace/OS_NS_stropts.h"
00007 #  include "ace/OS_NS_errno.h"
00008 #endif /* ACE_LACKS_FCNTL */
00009 
00010 #if !defined (__ACE_INLINE__)
00011 #include "ace/Flag_Manip.inl"
00012 #endif /* __ACE_INLINE__ */
00013 
00014 #if defined (CYGWIN32)
00015 #  include "ace/os_include/os_termios.h"
00016 #endif /* CYGWIN32 */
00017 
00018 ACE_RCSID (ace,
00019            Flag_Manip,
00020            "Flag_Manip.cpp,v 1.10 2006/02/09 17:03:20 jtc Exp")
00021 
00022 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00023 
00024 // Flags are file status flags to turn on.
00025 
00026 int
00027 ACE::set_flags (ACE_HANDLE handle, int flags)
00028 {
00029   ACE_TRACE ("ACE::set_flags");
00030 #if defined (ACE_LACKS_FCNTL)
00031   switch (flags)
00032     {
00033     case ACE_NONBLOCK:
00034       // nonblocking argument (1)
00035       // blocking:            (0)
00036       {
00037         int nonblock = 1;
00038         return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
00039       }
00040     default:
00041       ACE_NOTSUP_RETURN (-1);
00042     }
00043 #else
00044   int val = ACE_OS::fcntl (handle, F_GETFL, 0);
00045 
00046   if (val == -1)
00047     return -1;
00048 
00049   // Turn on flags.
00050   ACE_SET_BITS (val, flags);
00051 
00052   if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
00053     return -1;
00054   else
00055     return 0;
00056 #endif /* ACE_LACKS_FCNTL */
00057 }
00058 
00059 // Flags are the file status flags to turn off.
00060 
00061 int
00062 ACE::clr_flags (ACE_HANDLE handle, int flags)
00063 {
00064   ACE_TRACE ("ACE::clr_flags");
00065 
00066 #if defined (ACE_LACKS_FCNTL)
00067   switch (flags)
00068     {
00069     case ACE_NONBLOCK:
00070       // nonblocking argument (1)
00071       // blocking:            (0)
00072       {
00073         int nonblock = 0;
00074         return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
00075       }
00076     default:
00077       ACE_NOTSUP_RETURN (-1);
00078     }
00079 #else
00080   int val = ACE_OS::fcntl (handle, F_GETFL, 0);
00081 
00082   if (val == -1)
00083     return -1;
00084 
00085   // Turn flags off.
00086   ACE_CLR_BITS (val, flags);
00087 
00088   if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
00089     return -1;
00090   else
00091     return 0;
00092 #endif /* ACE_LACKS_FCNTL */
00093 }
00094 
00095 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:51 2006 for ACE by doxygen 1.3.6