5 #include "ace/Log_Msg.h"
6 #include "ace/OS_NS_string.h"
7 #include "ace/OS_NS_unistd.h"
8 #include "ace/OS_NS_stdio.h"
9 #include "ace/OS_Memory.h"
11 // This function "encodes" a list of friends by putting the userid's
12 // in a contiguous block. This block can then be transmitted over to
13 // the network to servers on other subnets. Several things are added
14 // to make decoding easier on the other end:
16 // * A count of the number of friends is prepended (assumption: there
17 // are no more than 9999999 friends... ;-))
18 // * The login userids are separated by a single space. */
21 PMC_Flo::encode (char *packet
, int &packet_length
)
23 if (Options::get_opt (Options::DEBUGGING
) != 0)
25 "in PMC_Flo::encode"));
27 ACE_NEW_RETURN (this->ss
,
31 SET_PACKET_TYPE (packet
, Options::PROTO_FLO
);
32 char *buf_ptr
= SKIP_PACKET_TYPE (packet
);
34 ACE_OS::sprintf (buf_ptr
,
36 this->friend_count ());
38 buf_ptr
+= MAXUSERIDNAMELEN
;
40 // Iterate through all the friends, copying them into the packet
43 for (Protocol_Record
*prp
; (prp
= this->get_next_friend ()) != 0; )
44 buf_ptr
= ACE_OS::strecpy (buf_ptr
,
47 packet_length
= buf_ptr
- packet
;
49 if (Options::get_opt (Options::DEBUGGING
) != 0)
52 "packet_length = %d\n",
54 ACE_OS::write (ACE_STDERR
, packet
, packet_length
);
62 // This method is responsible for transforming the msg from the server
63 // back into a form usable by the client.
66 PMC_Flo::decode (char *packet
, int &packet_length
)
68 if (Options::get_opt (Options::DEBUGGING
) != 0)
71 "in PMC_Flo::decode, packet_length = %d\n",
73 ACE_OS::write (ACE_STDERR
, packet
, packet_length
);
85 this->increment_total_users (remote_users
);
87 for (cp
= (char *) ACE::strend (cp
);
91 char *login_name
= cp
;
93 for (cp
= (char *) ACE::strend (cp
);
94 *(cp
= this->handle_protocol_entries (cp
, login_name
)) != '\t';
103 PMC_Flo::insert_protocol_info (Protocol_Record
&protocol_record
)
105 Protocol_Record
*prp
= PM_Client::insert_protocol_info (protocol_record
);
106 int length
= ACE_OS::strlen (prp
->get_real ());
108 if (length
> this->max_key_length
)
109 this->max_key_length
= length
;
117 ACE_DEBUG ((LM_DEBUG
,
118 "remote friends logged on\n"));
119 PM_Client::process ();