OS_NS_stropts.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // OS_NS_stropts.inl,v 1.10 2006/05/16 13:05:51 jwillemsen Exp
00004 
00005 #include "ace/os_include/os_errno.h"
00006 #include "ace/OS_NS_unistd.h"
00007 #include "ace/OS_NS_string.h"
00008 #include "ace/OS_NS_macros.h"
00009 #include "ace/OS_Memory.h"
00010 #include "ace/OS_QoS.h"
00011 
00012 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00013 
00014 #if defined (ACE_LACKS_CONST_STRBUF_PTR)
00015 typedef struct strbuf *ACE_STRBUF_TYPE;
00016 #else
00017 typedef const struct strbuf *ACE_STRBUF_TYPE;
00018 #endif /* ACE_LACKS_CONST_STRBUF_PTR */
00019 
00020 ACE_INLINE
00021 ACE_Str_Buf::ACE_Str_Buf (void *b, int l, int max)
00022 {
00023   this->maxlen = max;
00024   this->len = l;
00025   this->buf = (char *) b;
00026 }
00027 
00028 ACE_INLINE
00029 ACE_Str_Buf::ACE_Str_Buf (strbuf &sb)
00030 {
00031   this->maxlen = sb.maxlen;
00032   this->len = sb.len;
00033   this->buf = sb.buf;
00034 }
00035 
00036 /*****************************************************************************/
00037 
00038 ACE_INLINE int
00039 ACE_OS::getmsg (ACE_HANDLE handle,
00040                 struct strbuf *ctl,
00041                 struct strbuf *data,
00042                 int *flags)
00043 {
00044   ACE_OS_TRACE ("ACE_OS::getmsg");
00045 #if defined (ACE_HAS_STREAM_PIPES)
00046   ACE_OSCALL_RETURN (::getmsg (handle, ctl, data, flags), int, -1);
00047 #else
00048   ACE_UNUSED_ARG (handle);
00049   ACE_UNUSED_ARG (ctl);
00050   ACE_UNUSED_ARG (data);
00051   ACE_UNUSED_ARG (flags);
00052 
00053   // I'm not sure how to implement this correctly.
00054   ACE_NOTSUP_RETURN (-1);
00055 #endif /* ACE_HAS_STREAM_PIPES */
00056 }
00057 
00058 ACE_INLINE int
00059 ACE_OS::getpmsg (ACE_HANDLE handle,
00060                  struct strbuf *ctl,
00061                  struct strbuf *data,
00062                  int *band,
00063                  int *flags)
00064 {
00065   ACE_OS_TRACE ("ACE_OS::getpmsg");
00066 #if defined (ACE_HAS_STREAM_PIPES)
00067   ACE_OSCALL_RETURN (::getpmsg (handle, ctl, data, band, flags), int, -1);
00068 #else
00069   ACE_UNUSED_ARG (handle);
00070   ACE_UNUSED_ARG (ctl);
00071   ACE_UNUSED_ARG (data);
00072   ACE_UNUSED_ARG (band);
00073   ACE_UNUSED_ARG (flags);
00074 
00075   // I'm not sure how to implement this correctly.
00076   ACE_NOTSUP_RETURN (-1);
00077 #endif /* ACE_HAS_STREAM_PIPES */
00078 }
00079 
00080 ACE_INLINE int
00081 ACE_OS::fattach (int handle, const char *path)
00082 {
00083   ACE_OS_TRACE ("ACE_OS::fattach");
00084 #if defined (ACE_HAS_STREAM_PIPES)
00085   ACE_OSCALL_RETURN (::fattach (handle, path), int, -1);
00086 #else
00087   ACE_UNUSED_ARG (handle);
00088   ACE_UNUSED_ARG (path);
00089 
00090   ACE_NOTSUP_RETURN (-1);
00091 #endif /* ACE_HAS_STREAM_PIPES */
00092 }
00093 
00094 ACE_INLINE int
00095 ACE_OS::fdetach (const char *file)
00096 {
00097   ACE_OS_TRACE ("ACE_OS::fdetach");
00098 #if defined (ACE_HAS_STREAM_PIPES)
00099   ACE_OSCALL_RETURN (::fdetach (file), int, -1);
00100 #else
00101   ACE_UNUSED_ARG (file);
00102 
00103   ACE_NOTSUP_RETURN (-1);
00104 #endif /* ACE_HAS_STREAM_PIPES */
00105 }
00106 
00107 ACE_INLINE int
00108 ACE_OS::ioctl (ACE_HANDLE handle,
00109                ACE_IOCTL_TYPE_ARG2 cmd,
00110                void *val)
00111 {
00112   ACE_OS_TRACE ("ACE_OS::ioctl");
00113 
00114 #if defined (ACE_WIN32)
00115   ACE_SOCKET sock = (ACE_SOCKET) handle;
00116   ACE_SOCKCALL_RETURN (::ioctlsocket (sock, cmd, reinterpret_cast<unsigned long *> (val)), int, -1);
00117 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x620)
00118   ACE_OSCALL_RETURN (::ioctl (handle, cmd, reinterpret_cast<int> (val)),
00119                      int, -1);
00120 #else
00121   ACE_OSCALL_RETURN (::ioctl (handle, cmd, val), int, -1);
00122 #endif /* ACE_WIN32 */
00123 }
00124 
00125 ACE_INLINE int
00126 ACE_OS::isastream (ACE_HANDLE handle)
00127 {
00128   ACE_OS_TRACE ("ACE_OS::isastream");
00129 #if defined (ACE_HAS_STREAM_PIPES)
00130   ACE_OSCALL_RETURN (::isastream (handle), int, -1);
00131 #else
00132   ACE_UNUSED_ARG (handle);
00133 
00134   ACE_NOTSUP_RETURN (-1);
00135 #endif /* ACE_HAS_STREAM_PIPES */
00136 }
00137 
00138 ACE_INLINE int
00139 ACE_OS::putmsg (ACE_HANDLE handle, const struct strbuf *ctl,
00140                 const struct strbuf *data, int flags)
00141 {
00142   ACE_OS_TRACE ("ACE_OS::putmsg");
00143 #if defined (ACE_HAS_STREAM_PIPES)
00144   ACE_OSCALL_RETURN (::putmsg (handle,
00145                                (ACE_STRBUF_TYPE) ctl,
00146                                (ACE_STRBUF_TYPE) data,
00147                                flags), int, -1);
00148 #else
00149   ACE_UNUSED_ARG (flags);
00150   ssize_t result;
00151   if (ctl == 0 && data == 0)
00152     {
00153       errno = EINVAL;
00154       return 0;
00155     }
00156   // Handle the two easy cases.
00157   else if (ctl != 0)
00158     {
00159       result =  ACE_OS::write (handle, ctl->buf, ctl->len);
00160       return static_cast<int> (result);
00161     }
00162   else if (data != 0)
00163     {
00164       result = ACE_OS::write (handle, data->buf, data->len);
00165       return static_cast<int> (result);
00166     }
00167   else
00168     {
00169       // This is the hard case.
00170       char *buf;
00171       ACE_NEW_RETURN (buf, char [ctl->len + data->len], -1);
00172       ACE_OS::memcpy (buf, ctl->buf, ctl->len);
00173       ACE_OS::memcpy (buf + ctl->len, data->buf, data->len);
00174       result = ACE_OS::write (handle, buf, ctl->len + data->len);
00175       delete [] buf;
00176       return static_cast<int> (result);
00177     }
00178 #endif /* ACE_HAS_STREAM_PIPES */
00179 }
00180 
00181 ACE_INLINE int
00182 ACE_OS::putpmsg (ACE_HANDLE handle,
00183                  const struct strbuf *ctl,
00184                  const struct strbuf *data,
00185                  int band,
00186                  int flags)
00187 {
00188   ACE_OS_TRACE ("ACE_OS::putpmsg");
00189 #if defined (ACE_HAS_STREAM_PIPES)
00190   ACE_OSCALL_RETURN (::putpmsg (handle,
00191                                 (ACE_STRBUF_TYPE) ctl,
00192                                 (ACE_STRBUF_TYPE) data,
00193                                 band, flags), int, -1);
00194 #else
00195   ACE_UNUSED_ARG (flags);
00196   ACE_UNUSED_ARG (band);
00197   return ACE_OS::putmsg (handle, ctl, data, flags);
00198 #endif /* ACE_HAS_STREAM_PIPES */
00199 }
00200 
00201 ACE_END_VERSIONED_NAMESPACE_DECL

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