Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / apps / drwho / PMC_All.cpp
blob75ba7710571c4cbc1d692bee8d4fcc22eae28c64
1 #include "global.h"
2 #include "Options.h"
3 #include "HT_Client.h"
4 #include "PMC_All.h"
5 #include "ace/ACE.h"
6 #include "ace/Log_Msg.h"
7 #include "ace/OS_NS_string.h"
8 #include "ace/OS_NS_unistd.h"
9 #include "ace/OS_Memory.h"
11 // This function is pretty much a no-op that just sets up the
12 // appropriate lookup function to use.
14 int
15 PMC_All::encode (char *packet, int &packet_length)
17 if (Options::get_opt (Options::DEBUGGING) != 0)
18 ACE_DEBUG ((LM_DEBUG,
19 "in PMC_All::encode\n"));
21 ACE_NEW_RETURN (this->ss,
22 HT_Client,
23 -1);
25 SET_PACKET_TYPE (packet, Options::PROTO_ALL);
27 char *buf_ptr = SKIP_PACKET_TYPE (packet);
29 packet_length = buf_ptr - packet;
30 return 1;
33 // This method is responsible for transforming the msg from the server
34 // back into a form usable by the client. Note that it reads the
35 // REAL_NAME from the packet (since the server placed it there)...
37 int
38 PMC_All::decode (char *packet, int &packet_length)
40 if (Options::get_opt (Options::DEBUGGING) != 0)
42 ACE_DEBUG ((LM_DEBUG,
43 "in PMC_All::decode, packet_length = %d\n",
44 packet_length));
46 ACE_OS::write (ACE_STDERR, packet, packet_length);
47 ACE_DEBUG ((LM_DEBUG,
48 "\n"));
50 char *cp = packet;
51 int remote_users = 0;
53 sscanf (cp,
54 "Users %d",
55 &remote_users);
57 this->increment_total_users (remote_users);
59 for (cp = (char *) ACE::strend (cp);
60 *cp != '\n';
61 cp++)
63 // Skip over the LOGIN_NAME.
65 char *login_name = cp;
66 char *real_name = cp = (char *) ACE::strend (cp);
68 for (cp = (char *) ACE::strend (cp);
69 *(cp = this->handle_protocol_entries (cp, login_name, real_name)) != '\t';
71 continue;
74 return 1;
77 Protocol_Record *
78 PMC_All::insert_protocol_info (Protocol_Record &protocol_record)
80 Protocol_Record *prp = PM_Client::insert_protocol_info (protocol_record);
81 int length = ACE_OS::strlen (prp->set_real (ACE::strnew (protocol_record.get_real ())));
83 if (length > this->max_key_length)
84 this->max_key_length = length;
86 return prp;
89 void
90 PMC_All::process ()
92 ACE_DEBUG ((LM_DEBUG,
93 "remote users logged on\n"));
94 PM_Client::process ();
97 PMC_All::PMC_All ()