6 #include "ace/Log_Msg.h"
7 #include "ace/OS_NS_string.h"
8 #include "ace/OS_NS_unistd.h"
9 #include "ace/OS_NS_stdlib.h"
10 #include "ace/OS_Memory.h"
11 #include "ace/os_include/os_netdb.h"
13 // This function is pretty much a no-op that just sets up the
14 // appropriate lookup function to use.
17 PMC_Ruser::encode (char *packet
, int &packet_length
)
19 if (Options::get_opt (Options::DEBUGGING
) != 0)
21 "in PMC_Ruser::encode\n"));
23 ACE_NEW_RETURN (this->ss
,
27 SET_PACKET_TYPE (packet
, Options::PROTO_RUSER
);
29 char *buf_ptr
= SKIP_PACKET_TYPE (packet
);
31 *buf_ptr
++ = char (Options::get_opt (Options::PRINT_LOGIN_NAME
));
33 packet_length
= buf_ptr
- packet
;
37 // This method is responsible for transforming the msg from the server
38 // back into a form usable by the client. Note that it reads the
39 // REAL_NAME from the packet (since the server placed it there)...
42 PMC_Ruser::decode (char *packet
, int &packet_length
)
44 if (Options::get_opt (Options::DEBUGGING
) != 0)
47 "in PMC_Ruser::decode, packet_length = %d\n",
49 ACE_OS::write (ACE_STDERR
, packet
, packet_length
);
60 this->increment_total_users (remote_users
);
62 for (cp
= (char *) ACE::strend (cp
);
68 for (cp
= (char *) ACE::strend (cp
);
69 *(cp
= this->handle_protocol_entries (cp
, host_name
)) != '\t'; )
77 PMC_Ruser::insert_protocol_info (Protocol_Record
&protocol_record
)
79 Protocol_Record
*prp
= this->ss
->insert (protocol_record
.get_host (),
81 Drwho_Node
*current_node
= protocol_record
.get_drwho_list ();
82 Drwho_Node
*np
= this->get_drwho_node (ACE::strnnew (current_node
->get_login_name (),
85 int length
= ACE_OS::strlen (prp
->get_host ());
87 np
->set_real_name (ACE::strnew (current_node
->get_real_name ()));
89 if (np
->get_active_count () < current_node
->get_active_count ())
90 np
->set_active_count (current_node
->get_active_count ());
91 if (np
->get_inactive_count () < current_node
->get_inactive_count())
92 np
->set_inactive_count (current_node
->get_inactive_count ());
94 if (length
> this->max_key_length
)
95 this->max_key_length
= length
;
101 PMC_Ruser::handle_protocol_entries (const char *cp
,
102 const char *host_name
,
105 static Protocol_Record
protocol_record (1);
106 Drwho_Node
*current_node
= protocol_record
.get_drwho_list ();
108 protocol_record
.set_host (host_name
);
109 current_node
->set_inactive_count (ACE_OS::atoi (cp
));
110 current_node
->set_active_count (ACE_OS::atoi (cp
= ACE_OS::strchr (cp
, ' ') + 1));
111 current_node
->set_login_name (cp
= ACE_OS::strchr (cp
, ' ') + 1);
112 current_node
->set_real_name (cp
= ACE_OS::strchr (cp
, '\0') + 1);
114 this->insert_protocol_info (protocol_record
);
116 return (char *) ACE::strend (cp
);
120 PMC_Ruser::process ()
122 const char *(Drwho_Node::*get_name
)();
124 if (Options::get_opt (Options::PRINT_LOGIN_NAME
))
125 get_name
= &Drwho_Node::get_login_name
;
127 get_name
= &Drwho_Node::get_real_name
;
129 for (Protocol_Record
*prp
;
130 (prp
= this->Protocol_Manager::get_each_friend ()) != 0;
133 ACE_DEBUG ((LM_DEBUG
,
135 this->max_key_length
,
138 for (Drwho_Node
*np
= prp
->get_drwho_list (); ;)
140 ACE_DEBUG ((LM_DEBUG
,
142 (np
->*get_name
) ()));
144 if (np
->get_inactive_count () != 0)
146 if (np
->get_active_count () != 0)
147 ACE_DEBUG ((LM_DEBUG
,
149 np
->get_active_count ()));
151 else if (np
->get_active_count () > 1)
152 ACE_DEBUG ((LM_DEBUG
,
154 np
->get_active_count ()));
155 else if (np
->get_active_count () == 1)
156 ACE_DEBUG ((LM_DEBUG
,
162 else if (Options::get_opt (Options::PRINT_LOGIN_NAME
))
163 ACE_DEBUG ((LM_DEBUG
,
166 ACE_DEBUG ((LM_DEBUG
,
170 ACE_DEBUG ((LM_DEBUG
,
175 PMC_Ruser::PMC_Ruser ()