5 #include "ace/Log_Msg.h"
6 #include "ace/OS_NS_string.h"
7 #include "ace/OS_NS_pwd.h"
8 #include "ace/OS_NS_unistd.h"
9 #include "ace/OS_NS_stdio.h"
10 #include "ace/OS_Memory.h"
12 // This function packs the located friends userids, plus the machines
13 // they are logged into (along with the inactive and active counts on
14 // each machine) into a buffer that is subsequently transmitted back
15 // to the client across the network. Note that this function encodes
16 // the REAL_NAME of the user in the packet.
19 PMS_All::encode (char *packet
, int &packet_length
)
21 if (Options::get_opt (Options::DEBUGGING
) != 0)
23 "in PMS_All::encode"));
26 char *buf_ptr
= packet
;
28 ACE_OS::sprintf (buf_ptr
,
30 this->get_total_users ());
31 buf_ptr
+= ACE_OS::strlen (buf_ptr
) + 1;
33 // We only send back info on friends that we actually see logged in.
36 (prp
= this->get_next_friend ()) != 0;
39 this->handle_protocol_entries (ACE_OS::strecpy
40 (ACE_OS::strecpy (buf_ptr
,
43 prp
->get_drwho_list ());
46 packet_length
= buf_ptr
- packet
;
48 if (Options::get_opt (Options::DEBUGGING
) != 0)
51 "packet_length = %d\n",
53 ACE_OS::write (ACE_STDERR
, packet
, packet_length
);
60 // This function takes a packet received from the client and calls the
61 // appropriate Protocol_Manager routine to build the local table of
65 PMS_All::decode (char *, int &packet_length
)
67 if (Options::get_opt (Options::DEBUGGING
) != 0)
69 "in PMS_All::decode, packet_length = %d\n",
72 ACE_NEW_RETURN (this->ss
,
78 // We only want the user's real name, not the gecos junk after the
79 // first leading ','. However, if the real-name is not in the
80 // password file, just return the login name instead.
83 PMS_All::insert_protocol_info (Protocol_Record
&protocol_record
)
85 Protocol_Record
*prp
= PM_Server::insert_protocol_info (protocol_record
);
86 passwd
*pwent
= ACE_OS::getpwnam (prp
->get_login ());
87 char *cp
= (char *) ACE_OS::strchr (prp
->set_real
90 ACE::strnew (pwent
->pw_gecos
)),