IO_SAP.cpp

Go to the documentation of this file.
00001 // IO_SAP.cpp,v 4.23 2005/10/28 16:14:52 ossama Exp
00002 
00003 #include "ace/IO_SAP.h"
00004 
00005 #include "ace/Log_Msg.h"
00006 #include "ace/OS_NS_unistd.h"
00007 #include "ace/OS_NS_errno.h"
00008 #include "ace/OS_NS_fcntl.h"
00009 #include "ace/os_include/os_signal.h"
00010 
00011 #if !defined (__ACE_INLINE__)
00012 #include "ace/IO_SAP.inl"
00013 #endif /* __ACE_INLINE__ */
00014 
00015 ACE_RCSID(ace, IO_SAP, "IO_SAP.cpp,v 4.23 2005/10/28 16:14:52 ossama Exp")
00016 
00017 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 ACE_ALLOC_HOOK_DEFINE(ACE_IO_SAP)
00020 
00021 // This is the do-nothing constructor.  It does not perform a
00022 // ACE_OS::open system call.
00023 
00024 ACE_IO_SAP::ACE_IO_SAP (void)
00025   : handle_ (ACE_INVALID_HANDLE)
00026 {
00027   ACE_TRACE ("ACE_IO_SAP::ACE_IO_SAP");
00028 }
00029 
00030 void
00031 ACE_IO_SAP::dump (void) const
00032 {
00033 #if defined (ACE_HAS_DUMP)
00034   ACE_TRACE ("ACE_IO_SAP::dump");
00035 
00036   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00037   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("handle_ = %d"), this->handle_));
00038   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\npid_ = %d"), this->pid_));
00039   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00040 #endif /* ACE_HAS_DUMP */
00041 }
00042 
00043 // Cache for the process ID.
00044 pid_t ACE_IO_SAP::pid_ = 0;
00045 
00046 int
00047 ACE_IO_SAP::enable (int value) const
00048 {
00049   ACE_TRACE ("ACE_IO_SAP::enable");
00050   /* First-time in initialization. */
00051   if (ACE_IO_SAP::pid_ == 0)
00052     ACE_IO_SAP::pid_ = ACE_OS::getpid ();
00053 
00054   switch (value)
00055     {
00056 #if defined (SIGURG)
00057     case SIGURG:
00058     case ACE_SIGURG:
00059 #if defined (F_SETOWN)
00060       return ACE_OS::fcntl (this->handle_,
00061                             F_SETOWN,
00062                             ACE_IO_SAP::pid_);
00063 #else
00064       ACE_NOTSUP_RETURN (-1);
00065 #endif /* F_SETOWN */
00066 #endif /* SIGURG */
00067 #if defined (SIGIO)
00068     case SIGIO:
00069     case ACE_SIGIO:
00070 #if defined (F_SETOWN) && defined (FASYNC)
00071       if (ACE_OS::fcntl (this->handle_,
00072                          F_SETOWN,
00073                          ACE_IO_SAP::pid_) == -1
00074           || ACE::set_flags (this->handle_,
00075                              FASYNC) == -1)
00076         return -1;
00077       break;
00078 #else
00079       ACE_NOTSUP_RETURN (-1);
00080 #endif /* F_SETOWN && FASYNC */
00081 #else  // <==
00082       ACE_NOTSUP_RETURN (-1);
00083 #endif /* SIGIO <== */
00084     case ACE_NONBLOCK:
00085       if (ACE::set_flags (this->handle_,
00086                           ACE_NONBLOCK) == -1)
00087         return -1;
00088       break;
00089     default:
00090       return -1;
00091     }
00092 
00093   return 0;
00094 }
00095 
00096 int
00097 ACE_IO_SAP::disable (int value) const
00098 {
00099   ACE_TRACE ("ACE_IO_SAP::disable");
00100 
00101   switch (value)
00102     {
00103 #if defined (SIGURG)
00104     case SIGURG:
00105     case ACE_SIGURG:
00106 #if defined (F_SETOWN)
00107       if (ACE_OS::fcntl (this->handle_,
00108                          F_SETOWN, 0) == -1)
00109         return -1;
00110       break;
00111 #else
00112       ACE_NOTSUP_RETURN (-1);
00113 #endif /* F_SETOWN */
00114 #endif /* SIGURG */
00115 #if defined (SIGIO)
00116     case SIGIO:
00117     case ACE_SIGIO:
00118 #if defined (F_SETOWN) && defined (FASYNC)
00119       if (ACE_OS::fcntl (this->handle_,
00120                          F_SETOWN,
00121                          0) == -1
00122           || ACE::clr_flags (this->handle_, FASYNC) == -1)
00123         return -1;
00124       break;
00125 #else
00126       ACE_NOTSUP_RETURN (-1);
00127 #endif /* F_SETOWN && FASYNC */
00128 #else  // <==
00129       ACE_NOTSUP_RETURN (-1);
00130 #endif /* SIGIO <== */
00131     case ACE_NONBLOCK:
00132       if (ACE::clr_flags (this->handle_,
00133                                      ACE_NONBLOCK) == -1)
00134         return -1;
00135       break;
00136     default:
00137       return -1;
00138     }
00139   return 0;
00140 }
00141 
00142 ACE_END_VERSIONED_NAMESPACE_DECL

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