FIFO.cpp

Go to the documentation of this file.
00001 // FIFO.cpp,v 4.17 2006/05/05 13:10:09 jwillemsen Exp
00002 
00003 #include "ace/FIFO.h"
00004 
00005 #if !defined (__ACE_INLINE__)
00006 #include "ace/FIFO.inl"
00007 #endif /* __ACE_INLINE__ */
00008 
00009 #include "ace/Log_Msg.h"
00010 #include "ace/OS_NS_string.h"
00011 #include "ace/OS_NS_errno.h"
00012 #include "ace/OS_NS_sys_stat.h"
00013 #include "ace/OS_NS_fcntl.h"
00014 
00015 ACE_RCSID(ace, FIFO, "FIFO.cpp,v 4.17 2006/05/05 13:10:09 jwillemsen Exp")
00016 
00017 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 ACE_ALLOC_HOOK_DEFINE(ACE_FIFO)
00020 
00021 void
00022 ACE_FIFO::dump (void) const
00023 {
00024 #if defined (ACE_HAS_DUMP)
00025   ACE_TRACE ("ACE_FIFO::dump");
00026 
00027   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00028   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("rendezvous_ = %s"), this->rendezvous_));
00029   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00030 #endif /* ACE_HAS_DUMP */
00031 }
00032 
00033 int
00034 ACE_FIFO::open (const ACE_TCHAR *r, int flags, mode_t perms,
00035                 LPSECURITY_ATTRIBUTES sa)
00036 {
00037   ACE_TRACE ("ACE_FIFO::open");
00038   ACE_OS::strsncpy (this->rendezvous_, r, MAXPATHLEN);
00039 
00040   if ((flags & O_CREAT) != 0
00041       && ACE_OS::mkfifo (this->rendezvous_, perms) == -1
00042       && !(errno == EEXIST))
00043     return -1;
00044 
00045   this->set_handle (ACE_OS::open (this->rendezvous_, flags, 0, sa));
00046   return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0;
00047 }
00048 
00049 ACE_FIFO::ACE_FIFO (const ACE_TCHAR *fifo_name,
00050                     int flags,
00051                     mode_t perms,
00052                     LPSECURITY_ATTRIBUTES sa)
00053 {
00054   ACE_TRACE ("ACE_FIFO::ACE_FIFO");
00055   if (this->open (fifo_name, flags, perms, sa) == -1)
00056     ACE_ERROR ((LM_ERROR,  ACE_LIB_TEXT ("%p\n"),  ACE_LIB_TEXT ("ACE_FIFO")));
00057 }
00058 
00059 ACE_FIFO::ACE_FIFO (void)
00060 {
00061 //  ACE_TRACE ("ACE_FIFO::ACE_FIFO");
00062 }
00063 
00064 int
00065 ACE_FIFO::close (void)
00066 {
00067   ACE_TRACE ("ACE_FIFO::close");
00068   int result = 0;
00069 
00070   if (this->get_handle () != ACE_INVALID_HANDLE)
00071     {
00072       result = ACE_OS::close (this->get_handle ());
00073       this->set_handle (ACE_INVALID_HANDLE);
00074     }
00075  return result;
00076 }
00077 
00078 ACE_END_VERSIONED_NAMESPACE_DECL

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