[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / DEV_IO.cpp
blobb9a8e1f46b92385b7d470da5ec76703902be22f0
1 // $Id: DEV_IO.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/DEV_IO.h"
4 #include "ace/Log_Msg.h"
6 #if !defined (__ACE_INLINE__)
7 #include "ace/DEV_IO.inl"
8 #endif /* __ACE_INLINE__ */
10 ACE_RCSID(ace, DEV_IO, "$Id: DEV_IO.cpp 80826 2008-03-04 14:51:23Z wotte $")
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_ALLOC_HOOK_DEFINE(ACE_DEV_IO)
17 // Return the local endpoint address.
19 int
20 ACE_DEV_IO::get_local_addr (ACE_DEV_Addr &addr) const
22 ACE_TRACE ("ACE_DEV_IO::get_local_addr");
24 addr = this->addr_;
25 return 0;
28 // Return the address of the remotely connected peer (if there is
29 // one).
31 int
32 ACE_DEV_IO::get_remote_addr (ACE_DEV_Addr &addr) const
34 ACE_TRACE ("ACE_DEV_IO::get_remote_addr");
35 addr = this->addr_;
36 return 0;
39 void
40 ACE_DEV_IO::dump (void) const
42 #if defined (ACE_HAS_DUMP)
43 ACE_TRACE ("ACE_DEV_IO::dump");
45 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
46 this->addr_.dump ();
47 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
48 #endif /* ACE_HAS_DUMP */
51 // Simple-minded do nothing constructor.
53 ACE_DEV_IO::ACE_DEV_IO (void)
55 ACE_TRACE ("ACE_DEV_IO::ACE_DEV_IO");
58 // Send N char *ptrs and int lengths. Note that the char *'s precede
59 // the ints (basically, an varargs version of writev). The count N is
60 // the *total* number of trailing arguments, *not* a couple of the
61 // number of tuple pairs!
63 ssize_t
64 ACE_DEV_IO::send (size_t n, ...) const
66 ACE_TRACE ("ACE_DEV_IO::send");
67 va_list argp;
68 int total_tuples = static_cast<int> (n / 2);
69 iovec *iovp;
70 #if defined (ACE_HAS_ALLOCA)
71 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
72 #else
73 ACE_NEW_RETURN (iovp,
74 iovec[total_tuples],
75 -1);
76 #endif /* !defined (ACE_HAS_ALLOCA) */
78 va_start (argp, n);
80 for (int i = 0; i < total_tuples; i++)
82 iovp[i].iov_base = va_arg (argp, char *);
83 iovp[i].iov_len = va_arg (argp, int);
86 ssize_t result = ACE_OS::writev (this->get_handle (), iovp, total_tuples);
87 #if !defined (ACE_HAS_ALLOCA)
88 delete [] iovp;
89 #endif /* !defined (ACE_HAS_ALLOCA) */
90 va_end (argp);
91 return result;
94 // This is basically an interface to ACE_OS::readv, that doesn't use the
95 // struct iovec explicitly. The ... can be passed as an arbitrary
96 // number of (char *ptr, int len) tuples. However, the count N is the
97 // *total* number of trailing arguments, *not* a couple of the number
98 // of tuple pairs!
100 ssize_t
101 ACE_DEV_IO::recv (size_t n, ...) const
103 ACE_TRACE ("ACE_DEV_IO::recv");
104 va_list argp;
105 int total_tuples = static_cast<int> (n / 2);
106 iovec *iovp;
107 #if defined (ACE_HAS_ALLOCA)
108 iovp = (iovec *) alloca (total_tuples * sizeof (iovec));
109 #else
110 ACE_NEW_RETURN (iovp,
111 iovec[total_tuples],
112 -1);
113 #endif /* !defined (ACE_HAS_ALLOCA) */
115 va_start (argp, n);
117 for (int i = 0; i < total_tuples; i++)
119 iovp[i].iov_base = va_arg (argp, char *);
120 iovp[i].iov_len = va_arg (argp, int);
123 ssize_t result = ACE_OS::readv (this->get_handle (), iovp, total_tuples);
124 #if !defined (ACE_HAS_ALLOCA)
125 delete [] iovp;
126 #endif /* !defined (ACE_HAS_ALLOCA) */
127 va_end (argp);
128 return result;
131 ACE_END_VERSIONED_NAMESPACE_DECL