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