*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)

*Fix a possible crash in Spell::DoAllEffectOnTarget

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-17 15:35:07 -07:00
parent f21f47005d
commit 26b5e033ff
2257 changed files with 750 additions and 103852 deletions
-31
View File
@@ -1,36 +1,27 @@
// $Id: ICMP_Socket.cpp 80826 2008-03-04 14:51:23Z wotte $
#include "ace/ICMP_Socket.h"
#if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1)
#include "ace/ACE.h"
#include "ace/Log_Msg.h"
#include "ace/OS_NS_netdb.h"
#include "ace/OS_NS_sys_socket.h"
ACE_RCSID (ace,
ICMP_Socket,
"$Id: ICMP_Socket.cpp 80826 2008-03-04 14:51:23Z wotte $")
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE (ACE_ICMP_Socket)
void
ACE_ICMP_Socket::dump (void) const
{
ACE_TRACE ("ACE_ICMP_Socket::dump");
}
ACE_ICMP_Socket::ACE_ICMP_Socket (void)
{
ACE_TRACE ("ACE_ICMP_Socket::ACE_ICMP_Socket");
}
ssize_t
ACE_ICMP_Socket::send (void const * buf,
size_t n,
@@ -38,7 +29,6 @@ ACE_ICMP_Socket::send (void const * buf,
int flags) const
{
ACE_TRACE ("ACE_ICMP_Socket::send");
return ACE_OS::sendto (this->get_handle (),
(char const *) buf,
n,
@@ -46,7 +36,6 @@ ACE_ICMP_Socket::send (void const * buf,
(sockaddr const *) addr.get_addr (),
addr.get_size ());
}
ssize_t
ACE_ICMP_Socket::recv (void * buf,
size_t n,
@@ -54,7 +43,6 @@ ACE_ICMP_Socket::recv (void * buf,
int flags) const
{
ACE_TRACE ("ACE_ICMP_Socket::recv");
int addr_len = addr.get_size ();
ssize_t status = ACE_OS::recvfrom (this->get_handle (),
(char *) buf,
@@ -63,10 +51,8 @@ ACE_ICMP_Socket::recv (void * buf,
(sockaddr *) addr.get_addr (),
(int*) &addr_len);
addr.set_size (addr_len);
return status;
}
ssize_t
ACE_ICMP_Socket::recv (void * buf,
size_t n,
@@ -74,25 +60,21 @@ ACE_ICMP_Socket::recv (void * buf,
ACE_Time_Value const * timeout) const
{
ACE_TRACE ("ACE_ICMP_Socket::recv");
return ACE::recv (this->get_handle (),
buf,
n,
flags,
timeout);
}
int
ACE_ICMP_Socket::open (ACE_Addr const & local,
int protocol,
int reuse_addr)
{
ACE_TRACE ("ACE_ICMP_Socket::open");
// Check if icmp protocol is supported on this host
int proto_number = -1;
protoent *proto;
if (! (proto = getprotobyname ("icmp")))
{
ACE_ERROR_RETURN
@@ -104,7 +86,6 @@ ACE_ICMP_Socket::open (ACE_Addr const & local,
-1);
}
proto_number = proto->p_proto;
if (proto_number != IPPROTO_ICMP || proto_number != protocol)
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -113,7 +94,6 @@ ACE_ICMP_Socket::open (ACE_Addr const & local,
ACE_TEXT ("currently supported.\n")),
-1);
}
if (ACE_SOCK::open (SOCK_RAW,
AF_INET,
protocol,
@@ -121,15 +101,12 @@ ACE_ICMP_Socket::open (ACE_Addr const & local,
{
return -1;
}
return this->shared_open (local);
}
int
ACE_ICMP_Socket::shared_open (ACE_Addr const & local)
{
ACE_TRACE ("ACE_ICMP_Socket::shared_open");
int error = 0;
if (local == ACE_Addr::sap_any)
{
@@ -144,15 +121,12 @@ ACE_ICMP_Socket::shared_open (ACE_Addr const & local)
{
error = 1;
}
if (error != 0)
{
this->close ();
}
return error ? -1 : 0;
}
unsigned short
ACE_ICMP_Socket::calculate_checksum (unsigned short * paddress,
int len)
@@ -166,22 +140,17 @@ ACE_ICMP_Socket::calculate_checksum (unsigned short * paddress,
sum += *w++;
nleft -= 2;
}
if (nleft == 1)
{
*((unsigned char *) &answer) = *((unsigned char *) w);
sum += answer;
}
// add back carry outs from top 16 bits to low 16 bits
sum = (sum >> 16) + (sum & 0xffff); // add hi 16 to low 16
sum += (sum >> 16); // add carry
answer = ~sum; // truncate to 16 bits
return (answer);
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_HAS_ICMP_SUPPORT == 1 */