summaryrefslogtreecommitdiff
path: root/apps/drwho
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-09-13 00:46:32 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-09-13 00:46:32 +0000
commitfa3040d9c38a89222e37fe6984ca19b8521e9083 (patch)
treea296123168f99596aa98b807c1705ba65a65d5ee /apps/drwho
parent94ce50a5e25d79c1b4b408502ac65b9e709a1747 (diff)
downloadATCD-fa3040d9c38a89222e37fe6984ca19b8521e9083.tar.gz
*** empty log message ***
Diffstat (limited to 'apps/drwho')
-rw-r--r--apps/drwho/CM_Client.cpp60
-rw-r--r--apps/drwho/CM_Client.h9
-rw-r--r--apps/drwho/CM_Server.cpp38
-rw-r--r--apps/drwho/Comm_Manager.h8
-rw-r--r--apps/drwho/Drwho_Node.cpp17
-rw-r--r--apps/drwho/Drwho_Node.h8
-rw-r--r--apps/drwho/HT_Client.cpp4
-rw-r--r--apps/drwho/HT_Client.h2
-rw-r--r--apps/drwho/HT_Server.h2
-rw-r--r--apps/drwho/PM_Client.cpp16
-rw-r--r--apps/drwho/Protocol_Record.cpp53
-rw-r--r--apps/drwho/Protocol_Record.h20
12 files changed, 120 insertions, 117 deletions
diff --git a/apps/drwho/CM_Client.cpp b/apps/drwho/CM_Client.cpp
index f7968a4b976..cc1aba7d7de 100644
--- a/apps/drwho/CM_Client.cpp
+++ b/apps/drwho/CM_Client.cpp
@@ -1,6 +1,5 @@
// $Id$
-#include "global.h"
#include "Options.h"
#include "Multicast_Manager.h"
#include "CM_Client.h"
@@ -12,16 +11,16 @@ CM_Client::open (short port_number)
{
int max_packet_size = UDP_PACKET_SIZE;
- Comm_Manager::sokfd = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
+ Comm_Manager::sokfd_ = ACE_OS::socket (PF_INET, SOCK_DGRAM, 0);
- if (Comm_Manager::sokfd == ACE_INVALID_HANDLE)
+ if (Comm_Manager::sokfd_ == ACE_INVALID_HANDLE)
return -1;
- ACE_OS::memset ((char *) &this->sin,
+ ACE_OS::memset ((char *) &this->sin_,
0,
- sizeof this->sin);
- this->sin.sin_family = AF_INET;
- this->sin.sin_port = htons (port_number);
+ sizeof this->sin_);
+ this->sin_.sin_family = AF_INET;
+ this->sin_.sin_port = htons (port_number);
return 1;
}
@@ -30,18 +29,18 @@ int
CM_Client::receive (int timeout)
{
FD_ZERO (&this->read_fd_);
- FD_SET (Comm_Manager::sokfd, &this->read_fd_);
+ FD_SET (Comm_Manager::sokfd_, &this->read_fd_);
if (timeout > 0)
{
- this->time_out_.tv_sec = timeout;
- this->time_out_.tv_usec = 0;
- this->top_ = &time_out;
+ this->time_out_.sec (timeout);
+ this->time_out_.usec (0);
+ this->top_ = &time_out_;
}
while (Multicast_Manager::outstanding_hosts_remain ())
{
- if (ACE_OS::select (Comm_Manager::sokfd + 1,
+ if (ACE_OS::select (Comm_Manager::sokfd_ + 1,
&this->read_fd_,
0,
0,
@@ -49,11 +48,12 @@ CM_Client::receive (int timeout)
break;
else
{
- int sin_len = sizeof this->sin;
- ssize_t n = ACE_OS::recvfrom (Comm_Manager::sokfd,
- this->recv_packet_, UDP_PACKET_SIZE,
+ int sin_len = sizeof this->sin_;
+ ssize_t n = ACE_OS::recvfrom (Comm_Manager::sokfd_,
+ this->recv_packet_,
+ UDP_PACKET_SIZE,
0,
- (sockaddr *) &this->sin,
+ (sockaddr *) &this->sin_,
&sin_len);
if (n < 0)
return -1;
@@ -68,13 +68,13 @@ CM_Client::receive (int timeout)
ACE_DEBUG ((LM_DEBUG,
"receiving from server host %s (%s)\n",
np->h_name,
- inet_ntoa (this->sin.sin_addr)));
+ inet_ntoa (this->sin_.sin_addr)));
}
- if (this->demux (this->recv_packet, n) < 0)
+ if (this->demux (this->recv_packet_, n) < 0)
return -1;
- Multicast_Manager::checkoff_host (this->sin.sin_addr);
+ Multicast_Manager::checkoff_host (this->sin_.sin_addr);
}
}
}
@@ -93,38 +93,38 @@ CM_Client::send (void)
{
int packet_length = 0;
- if (this->mux (this->send_packet, packet_length) < 0)
+ if (this->mux (this->send_packet_, packet_length) < 0)
return -1;
// Ship off the info to all the hosts.
- while (Multicast_Manager::get_next_host_addr (this->sin.sin_addr) != 0)
+ while (Multicast_Manager::get_next_host_addr (this->sin_.sin_addr) != 0)
{
if (Options::get_opt (Options::DEBUG) != 0)
{
- hostent *np = ACE_OS::gethostbyaddr ((char *) &this->sin.sin_addr,
- sizeof this->sin.sin_addr,
+ hostent *np = ACE_OS::gethostbyaddr ((char *) &this->sin_.sin_addr,
+ sizeof this->sin_.sin_addr,
AF_INET);
ACE_DEBUG ((LM_DEBUG,
"sending to server host %s (%s)\n",
np->h_name,
- inet_ntoa (this->sin.sin_addr)));
+ inet_ntoa (this->sin_.sin_addr)));
}
- if (sendto (Comm_Manager::sokfd,
- this->send_packet,
+ if (sendto (Comm_Manager::sokfd_,
+ this->send_packet_,
packet_length,
0,
- (sockaddr *) &this->sin,
- sizeof this->sin) < 0)
+ (sockaddr *) &this->sin_,
+ sizeof this->sin_) < 0)
return -1;
}
return 1;
}
CM_Client::CM_Client (void)
- : top (0)
+ : top_ (0)
{
}
@@ -134,6 +134,6 @@ CM_Client::~CM_Client (void)
ACE_DEBUG ((LM_DEBUG,
"disposing CM_Client\n"));
- ACE_OS::closesocket (Comm_Manager::sokfd);
+ ACE_OS::closesocket (Comm_Manager::sokfd_);
}
diff --git a/apps/drwho/CM_Client.h b/apps/drwho/CM_Client.h
index 30e58de5d52..09bc7e40d8f 100644
--- a/apps/drwho/CM_Client.h
+++ b/apps/drwho/CM_Client.h
@@ -7,7 +7,7 @@
// drwho
//
// = FILENAME
-// BS_Server.h
+// CM_Client.h
//
// = DESCRIPTION
// Provides a virtual communcations layer for the client in the
@@ -18,10 +18,9 @@
//
// ============================================================================
-#if defined (_CM_CLIENT_H)
+#if !defined (_CM_CLIENT_H)
#define _CM_CLIENT_H
-#include "global.h"
#include "Comm_Manager.h"
class CM_Client : public Comm_Manager
@@ -45,8 +44,8 @@ public:
private:
fd_set read_fd_;
- timeval time_out_;
- timeval *top_;
+ ACE_Time_Value time_out_;
+ ACE_Time_Value *top_;
};
#endif /* _CM_CLIENT_H */
diff --git a/apps/drwho/CM_Server.cpp b/apps/drwho/CM_Server.cpp
index 4fd30308af3..12e6e97c6ed 100644
--- a/apps/drwho/CM_Server.cpp
+++ b/apps/drwho/CM_Server.cpp
@@ -11,23 +11,23 @@ CM_Server::open (short port_number)
{
int max_packet_size = UDP_PACKET_SIZE;
- this->sokfd = socket (PF_INET, SOCK_DGRAM, 0);
+ this->sokfd_ = socket (PF_INET, SOCK_DGRAM, 0);
- if (this->sokfd < 0)
+ if (this->sokfd_ < 0)
return -1;
- ACE_OS::memset (&this->sin, sizeof this->sin, 0);
- this->sin.sin_family = AF_INET;
- this->sin.sin_port = htons (port_number);
- this->sin.sin_addr.s_addr = INADDR_ANY;
+ ACE_OS::memset (&this->sin_, sizeof this->sin_, 0);
+ this->sin_.sin_family = AF_INET;
+ this->sin_.sin_port = htons (port_number);
+ this->sin_.sin_addr.s_addr = INADDR_ANY;
// This call fails if an rflo daemon is already running.
- if (ACE_OS::bind (this->sokfd,
- (sockaddr *) &this->sin,
- sizeof this->sin) < 0)
+ if (ACE_OS::bind (this->sokfd_,
+ (sockaddr *) &this->sin_,
+ sizeof this->sin_) < 0)
return -1;
- if (ACE_OS::setsockopt (this->sokfd,
+ if (ACE_OS::setsockopt (this->sokfd_,
SOL_SOCKET,
SO_SNDBUF,
(char *) &max_packet_size,
@@ -40,16 +40,16 @@ CM_Server::open (short port_number)
int
CM_Server::receive (int)
{
- int sin_len = sizeof this->sin;
+ int sin_len = sizeof this->sin_;
if (Options::get_opt (Options::DEBUG) != 0)
ACE_DEBUG ((LM_DEBUG, "waiting for client to send...\n"));
- ssize_t n = recvfrom (this->sokfd,
+ ssize_t n = recvfrom (this->sokfd_,
this->recv_packet,
UDP_PACKET_SIZE,
0,
- (sockaddr *) &this->sin,
+ (sockaddr *) &this->sin_,
&sin_len);
if (n == -1)
return -1;
@@ -57,7 +57,7 @@ CM_Server::receive (int)
if (Options::get_opt (Options::DEBUG) != 0)
ACE_DEBUG ((LM_DEBUG,
"receiving from client host %s\n",
- ACE_OS::inet_ntoa (this->sin.sin_addr)));
+ ACE_OS::inet_ntoa (this->sin_.sin_addr)));
if (this->demux (this->recv_packet, n) < 0)
return -1;
@@ -77,14 +77,14 @@ CM_Server::send (void)
if (Options::get_opt (Options::DEBUG) != 0)
ACE_DEBUG ((LM_DEBUG,
"sending to client host %s\n",
- ACE_OS::inet_ntoa (this->sin.sin_addr)));
+ ACE_OS::inet_ntoa (this->sin_.sin_addr)));
- if (sendto (this->sokfd,
+ if (sendto (this->sokfd_,
this->send_packet,
packet_length,
0,
- (sockaddr *) &this->sin,
- sizeof this->sin) < 0)
+ (sockaddr *) &this->sin_,
+ sizeof this->sin_) < 0)
return -1;
return 1;
@@ -100,5 +100,5 @@ CM_Server::~CM_Server (void)
ACE_DEBUG ((LM_DEBUG,
"CM_Server\n"));
- ACE_OS::closesocket (this->sokfd);
+ ACE_OS::closesocket (this->sokfd_);
}
diff --git a/apps/drwho/Comm_Manager.h b/apps/drwho/Comm_Manager.h
index 21d44ec5f63..0dfd6b7c72e 100644
--- a/apps/drwho/Comm_Manager.h
+++ b/apps/drwho/Comm_Manager.h
@@ -24,10 +24,10 @@ class Comm_Manager
// = TITLE
// Provides a virtual communcations layer for the drwho program.
protected:
- char recv_packet[UDP_PACKET_SIZE];
- char send_packet[UDP_PACKET_SIZE];
- sockaddr_in sin;
- int sokfd;
+ char recv_packet_[UDP_PACKET_SIZE];
+ char send_packet_[UDP_PACKET_SIZE];
+ sockaddr_in sin_;
+ int sokfd_;
virtual int mux (char *packet, int &packet_length) = 0;
virtual int demux (char *packet, int &packet_length) = 0;
diff --git a/apps/drwho/Drwho_Node.cpp b/apps/drwho/Drwho_Node.cpp
index 93ac6f1d751..6f614c7d4d5 100644
--- a/apps/drwho/Drwho_Node.cpp
+++ b/apps/drwho/Drwho_Node.cpp
@@ -2,7 +2,7 @@
#include "Drwho_Node.h"
-Drwho_Node::Drwho_Node (char *h_name, Drwho_Node *n)
+Drwho_Node::Drwho_Node (const char *h_name, Drwho_Node *n)
: next (n),
inactive_count (0),
active_count (0),
@@ -27,9 +27,10 @@ Drwho_Node::get_login_name (void)
}
char *
-Drwho_Node::set_login_name (char *str)
+Drwho_Node::set_login_name (const char *str)
{
- return this->key_name1 = str;
+ this->key_name1 = str;
+ return str;
}
char *
@@ -39,9 +40,10 @@ Drwho_Node::get_real_name (void)
}
char *
-Drwho_Node::set_real_name (char *str)
+Drwho_Node::set_real_name (const char *str)
{
- return this->key_name2 = str;
+ this->key_name2 = str;
+ return str;
}
char *
@@ -51,9 +53,10 @@ Drwho_Node::get_host_name (void)
}
char *
-Drwho_Node::set_host_name (char *str)
+Drwho_Node::set_host_name (const char *str)
{
- return this->key_name1 = str;
+ this->key_name1 = str;
+ return str;
}
int
diff --git a/apps/drwho/Drwho_Node.h b/apps/drwho/Drwho_Node.h
index c7395bf5e34..9d9960d7c33 100644
--- a/apps/drwho/Drwho_Node.h
+++ b/apps/drwho/Drwho_Node.h
@@ -24,7 +24,7 @@ class Drwho_Node
// = TITLE
// Stores information about a host for a specific friend.
public:
- Drwho_Node (char *host, Drwho_Node *next);
+ Drwho_Node (const char *host, Drwho_Node *next);
Drwho_Node (void);
int get_active_count (void);
@@ -34,11 +34,11 @@ public:
int set_idle_time (int idle_time);
int get_idle_time (void);
char *get_host_name (void);
- char *set_host_name (char *str);
+ char *set_host_name (const char *str);
char *get_login_name (void);
- char *set_login_name (char *);
+ char *set_login_name (const char *);
char *get_real_name (void);
- char *set_real_name (char *);
+ char *set_real_name (const char *);
char *key_name1;
char *key_name2;
diff --git a/apps/drwho/HT_Client.cpp b/apps/drwho/HT_Client.cpp
index ff307195dba..2079fb60394 100644
--- a/apps/drwho/HT_Client.cpp
+++ b/apps/drwho/HT_Client.cpp
@@ -7,7 +7,7 @@
// that we do our own memory allocation here...
Protocol_Record *
-HT_Client::insert (char *key_name, int max_len)
+HT_Client::insert (const char *key_name, int max_len)
{
Protocol_Record **frpp = 0;
@@ -26,7 +26,7 @@ HT_Client::insert (char *key_name, int max_len)
Protocol_Record (ACE::strnew (key_name),
*frpp),
0);
- this->count++;
+ this->count_++;
}
return *frpp;
diff --git a/apps/drwho/HT_Client.h b/apps/drwho/HT_Client.h
index 9e1512a0b80..16828077d00 100644
--- a/apps/drwho/HT_Client.h
+++ b/apps/drwho/HT_Client.h
@@ -24,7 +24,7 @@ class HT_Client : public Hash_Table
// = TITLE
// Provides the client's hash table abstraction.
public:
- virtual Protocol_Record *insert (char *key_name,
+ virtual Protocol_Record *insert (const char *key_name,
int max_len = MAXUSERIDNAMELEN);
};
diff --git a/apps/drwho/HT_Server.h b/apps/drwho/HT_Server.h
index 777331efc33..96b110b14b0 100644
--- a/apps/drwho/HT_Server.h
+++ b/apps/drwho/HT_Server.h
@@ -25,7 +25,7 @@ class HT_Server : public Hash_Table
// Provides the server's hash table abstraction.
public:
- virtual Protocol_Record *insert (char *key_name,
+ virtual Protocol_Record *insert (const char *key_name,
int max_len = MAXUSERIDNAMELEN);
};
diff --git a/apps/drwho/PM_Client.cpp b/apps/drwho/PM_Client.cpp
index ed087344ba2..a46dc0ad760 100644
--- a/apps/drwho/PM_Client.cpp
+++ b/apps/drwho/PM_Client.cpp
@@ -13,14 +13,14 @@ PM_Client::insert_protocol_info (Protocol_Record &protocol_record)
Protocol_Record *frp = this->ss->insert (protocol_record.get_login ());
Drwho_Node *current_node = protocol_record.get_drwho_list ();
Drwho_Node *np = this->get_drwho_node (ACE::strnew (current_node->get_host_name ()),
- frp->drwho_list);
+ frp->drwho_list_);
// Update the active and inactive counts.
if (np->get_active_count () < current_node->get_active_count ())
{
np->set_active_count (current_node->get_active_count ());
- frp->is_active = 1;
+ frp->is_active_ = 1;
}
if (np->get_inactive_count () < current_node->get_inactive_count())
@@ -54,7 +54,7 @@ PM_Client::process (void)
// Goes through the queue of all the logged in friends and prints
// out the associated information.
- for (Protocol_Record *frp = this->Protocol_Manager::get_each_friend ()
+ for (Protocol_Record *frp = this->Protocol_Manager::get_each_friend ();
frp != 0;
frp = this->Protocol_Manager::get_each_friend ())
{
@@ -89,11 +89,11 @@ PM_Client::process (void)
if ((np = np->next) == 0)
break;
else
- ACE_DEBUG ((LM_DEBUG
+ ACE_DEBUG ((LM_DEBUG,
" "));
}
- ACE_DEBUG ((LM_DEBUG
+ ACE_DEBUG ((LM_DEBUG,
"]\n"));
}
@@ -114,10 +114,10 @@ PM_Client::handle_protocol_entries (const char *cp,
Drwho_Node *current_node = protocol_record.get_drwho_list ();
protocol_record.set_login (login_name);
- protocol_record.set_real (real_name);
+ protocol_record.set_real (real_name);
current_node->set_inactive_count (atoi (cp));
- current_node->set_active_count (atoi (cp = strchr (cp, ' ') + 1));
- current_node->set_host_name (cp = strchr (cp, ' ') + 1);
+ current_node->set_active_count (atoi (cp = ACE_OS::strchr (cp, ' ') + 1));
+ current_node->set_host_name (cp = ACE_OS::strchr (cp, ' ') + 1);
this->insert_protocol_info (protocol_record);
diff --git a/apps/drwho/Protocol_Record.cpp b/apps/drwho/Protocol_Record.cpp
index fda6fc8314d..05c0fc11656 100644
--- a/apps/drwho/Protocol_Record.cpp
+++ b/apps/drwho/Protocol_Record.cpp
@@ -23,72 +23,73 @@ Protocol_Record::~Protocol_Record (void)
}
Protocol_Record::Protocol_Record (void)
- : is_active (0),
- drwho_list (0),
- key_name1 (0),
- key_name2 (0),
- next (0)
+ : is_active_ (0),
+ drwho_list_ (0),
+ key_name1_ (0),
+ key_name2_ (0),
+ next_ (0)
{
}
Protocol_Record::Protocol_Record (int)
- : is_active (0),
- drwho_list (&Protocol_Record::drwho_node),
- key_name1 (0),
- key_name2 (0),
- next (0)
+ : is_active_ (0),
+ drwho_list_ (&Protocol_Record::drwho_node),
+ key_name1_ (0),
+ key_name2_ (0),
+ next_ (0)
{
}
-Protocol_Record::Protocol_Record (char *kn1, Protocol_Record *next)
- : is_active (0),
- drwho_list (0),
- key_name2 (0)
+Protocol_Record::Protocol_Record (const char *kn1, Protocol_Record *next)
+ : is_active_ (0),
+ drwho_list_ (0),
+ key_name2_ (0)
{
- this->key_name1 = kn1;
- this->next = next;
+ this->key_name1_ = kn1;
+ this->next_ = next;
}
char *
Protocol_Record::get_login (void)
{
- return this->key_name1;
+ return this->key_name1_;
}
char *
-Protocol_Record::set_login (char *str)
+Protocol_Record::set_login (const char *str)
{
- return this->key_name1 = str;
+ this->key_name1_ = str;
+ return str;
}
char *
Protocol_Record::get_real (void)
{
- return this->key_name2;
+ return this->key_name2_;
}
char *
Protocol_Record::get_host (void)
{
- return this->key_name1;
+ return this->key_name1_;
}
char *
-Protocol_Record::set_host (char *str)
+Protocol_Record::set_host (const char *str)
{
- this->key_name1 = str;
+ this->key_name1_ = str;
return str;
}
char *
-Protocol_Record::set_real (char *str)
+Protocol_Record::set_real (const char *str)
{
- this->key_name2 = str
+ this->key_name2_ = str
return str;
}
Drwho_Node *
Protocol_Record::get_drwho_list (void)
{
- return this->drwho_list;
+ return this->drwho_list_;
}
diff --git a/apps/drwho/Protocol_Record.h b/apps/drwho/Protocol_Record.h
index 4af413cf411..71e9d10c9bd 100644
--- a/apps/drwho/Protocol_Record.h
+++ b/apps/drwho/Protocol_Record.h
@@ -27,23 +27,23 @@ class Protocol_Record
public:
Protocol_Record (void);
Protocol_Record (int use_dummy);
- Protocol_Record (char *key_name1,
+ Protocol_Record (const char *key_name1,
Protocol_Record *next = 0);
~Protocol_Record (void);
char *get_host (void);
- char *set_host (char *str);
+ char *set_host (const char *str);
char *get_login (void);
- char *set_login (char *str);
+ char *set_login (const char *str);
char *get_real (void);
- char *set_real (char *str);
+ char *set_real (const char *str);
Drwho_Node *get_drwho_list (void);
- static Drwho_Node drwho_node;
- char *key_name1;
- char *key_name2;
- Drwho_Node *drwho_list;
- Protocol_Record *next;
- int is_active;
+ static Drwho_Node drwho_node_;
+ char *key_name1_;
+ char *key_name2_;
+ Drwho_Node *drwho_list_;
+ Protocol_Record *next_;
+ int is_active_;
};
#endif /* _PROTOCOL_RECORD_H */