Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Flag_Manip.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: Flag_Manip.cpp,v 1.1.1.1.40.1 2003/03/13 19:44:21 chad Exp $
00003 
00004 #include "Flag_Manip.h"
00005 
00006 #if defined (ACE_LACKS_INLINE_FUNCTIONS)
00007 #include "ace/Flag_Manip.i"
00008 #endif /* ACE_LACKS_INLINE_FUNCTIONS */
00009 
00010 ACE_RCSID(ace, Flag_Manip, "$Id: Flag_Manip.cpp,v 1.1.1.1.40.1 2003/03/13 19:44:21 chad Exp $")
00011 
00012 // Flags are file status flags to turn on.
00013 
00014 int
00015 ACE_Flag_Manip::set_flags (ACE_HANDLE handle, int flags)
00016 {
00017   ACE_TRACE ("ACE_Flag_Manip::set_flags");
00018 #if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_LACKS_FCNTL)
00019   switch (flags)
00020     {
00021     case ACE_NONBLOCK:
00022       // nonblocking argument (1)
00023       // blocking:            (0)
00024       {
00025         u_long nonblock = 1;
00026         return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
00027       }
00028     default:
00029       ACE_NOTSUP_RETURN (-1);
00030     }
00031 #else
00032   int val = ACE_OS::fcntl (handle, F_GETFL, 0);
00033 
00034   if (val == -1)
00035     return -1;
00036 
00037   // Turn on flags.
00038   ACE_SET_BITS (val, flags);
00039 
00040   if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
00041     return -1;
00042   else
00043     return 0;
00044 #endif /* ACE_WIN32 || ACE_LACKS_FCNTL */
00045 }
00046 
00047 // Flags are the file status flags to turn off.
00048 
00049 int
00050 ACE_Flag_Manip::clr_flags (ACE_HANDLE handle, int flags)
00051 {
00052   ACE_TRACE ("ACE_Flag_Manip::clr_flags");
00053 
00054 #if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_LACKS_FCNTL)
00055   switch (flags)
00056     {
00057     case ACE_NONBLOCK:
00058       // nonblocking argument (1)
00059       // blocking:            (0)
00060       {
00061         u_long nonblock = 0;
00062         return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
00063       }
00064     default:
00065       ACE_NOTSUP_RETURN (-1);
00066     }
00067 #else
00068   int val = ACE_OS::fcntl (handle, F_GETFL, 0);
00069 
00070   if (val == -1)
00071     return -1;
00072 
00073   // Turn flags off.
00074   ACE_CLR_BITS (val, flags);
00075 
00076   if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
00077     return -1;
00078   else
00079     return 0;
00080 #endif /* ACE_WIN32 || ACE_LACKS_FCNTL */
00081 }

Generated on Mon Jun 16 11:19:42 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002