2 #include "File_Manager.h"
4 #include "ace/Log_Msg.h"
5 #include "ace/Null_Mutex.h"
6 #include "ace/OS_NS_string.h"
8 BS_Client::BS_Client ()
10 this->count_
= FILE_MANAGER::instance ()->open_file (Options::friend_file
);
15 Options::program_name
));
18 ACE_NEW (this->protocol_record_
,
19 Protocol_Record
[this->count_
]);
20 ACE_NEW (this->sorted_record_
,
21 Protocol_Record
*[this->count_
]);
23 for (int i
= 0; i
< this->count_
; i
++)
25 Protocol_Record
*prp
= &this->protocol_record_
[i
];
27 this->sorted_record_
[i
] = prp
;
29 FILE_MANAGER::instance ()->get_login_and_real_name
30 (prp
->key_name1_
, prp
->key_name2_
);
33 ACE_OS::qsort (this->sorted_record_
,
35 sizeof *this->sorted_record_
,
36 (ACE_COMPARE_FUNC
)Binary_Search::name_compare
);
40 // This function is used to merge the KEY_NAME from server HOST_NAME
41 // into the sorted list of userids kept on the client's side. Since
42 // we *know* we are going to find the name we use the traditional
46 BS_Client::insert (const char *key_name
, int)
49 Protocol_Record
*pr
= (Protocol_Record
*)
50 ACE_OS::bsearch ((const void *) key_name
,
51 (const void *) this->sorted_record_
,
54 int (*compar
)(const void *, const void *) ACE_OS::strcmp
);
58 int hi
= this->count_
- 1;
59 Protocol_Record
**sorted_buffer
= this->sorted_record_
;
63 int mid
= (lo
+ hi
) / 2;
64 Protocol_Record
*prp
= sorted_buffer
[mid
];
65 int cmp
= ACE_OS::strcmp (key_name
,
80 BS_Client::get_each_entry ()
82 for (Protocol_Record
*prp
= Binary_Search::get_each_entry ();
84 prp
= Binary_Search::get_each_entry ())
85 if (prp
->get_drwho_list () != 0)