1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
// $Id$
#include "Options.h"
#include "BS_Client.h"
#include "PMC_Flo.h"
#include "ace/ACE.h"
#include "ace/Log_Msg.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_unistd.h"
#include "ace/OS_Memory.h"
// This function "encodes" a list of friends by putting the userid's
// in a contiguous block. This block can then be transmitted over to
// the network to servers on other subnets. Several things are added
// to make decoding easier on the other end:
//
// * A count of the number of friends is prepended (assumption: there
// are no more than 9999999 friends... ;-))
// * The login userids are separated by a single space. */
int
PMC_Flo::encode (char *packet, int &packet_length)
{
if (Options::get_opt (Options::DEBUG) != 0)
ACE_DEBUG ((LM_DEBUG,
"in PMC_Flo::encode"));
ACE_NEW_RETURN (this->ss,
BS_Client,
-1);
SET_PACKET_TYPE (packet, Options::PROTO_FLO);
char *buf_ptr = SKIP_PACKET_TYPE (packet);
sprintf (buf_ptr,
"%d",
this->friend_count ());
buf_ptr += MAXUSERIDNAMELEN;
// Iterate through all the friends, copying them into the packet
// buffer.
for (Protocol_Record *prp; (prp = this->get_next_friend ()) != 0; )
buf_ptr = ACE_OS::strecpy (buf_ptr,
prp->get_login ());
packet_length = buf_ptr - packet;
if (Options::get_opt (Options::DEBUG) != 0)
{
ACE_DEBUG ((LM_DEBUG,
"packet_length = %d\n",
packet_length));
ACE_OS::write (ACE_STDERR, packet, packet_length);
ACE_DEBUG ((LM_DEBUG,
"\n"));
}
return 1;
}
// This method is responsible for transforming the msg from the server
// back into a form usable by the client.
int
PMC_Flo::decode (char *packet, int &packet_length)
{
if (Options::get_opt (Options::DEBUG) != 0)
{
ACE_DEBUG ((LM_DEBUG,
"in PMC_Flo::decode, packet_length = %d\n",
packet_length));
ACE_OS::write (ACE_STDERR, packet, packet_length);
ACE_DEBUG ((LM_DEBUG,
"\n"));
}
char *cp = packet;
int remote_users = 0;
sscanf (cp,
"Users %d",
&remote_users);
this->increment_total_users (remote_users);
for (cp = (char *) ACE::strend (cp);
*cp != '\n';
cp++)
{
char *login_name = cp;
for (cp = (char *) ACE::strend (cp);
*(cp = this->handle_protocol_entries (cp, login_name)) != '\t';
)
continue;
}
return 1;
}
Protocol_Record *
PMC_Flo::insert_protocol_info (Protocol_Record &protocol_record)
{
Protocol_Record *prp = PM_Client::insert_protocol_info (protocol_record);
int length = ACE_OS::strlen (prp->get_real ());
if (length > this->max_key_length)
this->max_key_length = length;
return prp;
}
void
PMC_Flo::process (void)
{
ACE_DEBUG ((LM_DEBUG,
"remote friends logged on\n"));
PM_Client::process ();
}
PMC_Flo::PMC_Flo (void)
{
}
|