Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / apps / drwho / PM_Server.cpp
blob662735e25ea5ae9aae4b3456076c43c8e948d881
1 #include "Options.h"
2 #include "Rwho_DB_Manager.h"
3 #include "PM_Server.h"
4 #include "ace/ACE.h"
5 #include "ace/OS_NS_string.h"
6 #include "ace/OS_NS_stdio.h"
8 // This is the main method for the server side of things. It reads
9 // the RWHO file on the local machine and inserts HOST_NAME
10 // information for each LOGIN_NAME that is a friend into the
11 // DRWHO_LIST. This function is also responsible for determining
12 // whether a given LOGIN_NAME is currently idle or not.
14 int
15 PM_Server::process ()
17 RWho_DB_Manager ru;
18 Protocol_Record protocol_record (1);
20 while (ru.get_next_user (protocol_record) > 0)
21 this->insert_protocol_info (protocol_record);
23 return 1;
26 // Insert the HOST_NAME into the server's lookup table on behalf of
27 // user LOGIN_NAME. Note that we need to allocate memory for
28 // HOST_NAME...
30 Protocol_Record *
31 PM_Server::insert_protocol_info (Protocol_Record &protocol_record)
33 Protocol_Record *prp = this->ss->insert (protocol_record.get_login ());
35 Drwho_Node *current_node = protocol_record.get_drwho_list ();
37 if (current_node->get_idle_time () < MAX_USER_TIMEOUT)
38 this->increment_total_users ();
40 if (prp)
42 Drwho_Node *np =
43 this->get_drwho_node (ACE::strnew (current_node->get_host_name ()),
44 prp->drwho_list_);
46 if (current_node->get_idle_time () >= MAX_USER_TIMEOUT)
47 np->inactive_count_++;
48 else
49 np->active_count_++;
52 return prp;
55 // Put the inactive and active counts, plus the hostname into the
56 // packet.
58 char *
59 PM_Server::handle_protocol_entries (char *buf_ptr,
60 Drwho_Node *np)
62 for (; np != 0; np = np->next_)
64 ACE_OS::sprintf (buf_ptr,
65 "%d %d %s",
66 np->get_inactive_count (),
67 np->get_active_count (),
68 np->get_host_name ());
69 buf_ptr += ACE_OS::strlen (buf_ptr) + 1;
72 return buf_ptr;
75 PM_Server::PM_Server ()
79 PM_Server::~PM_Server ()