Implement nickcmp

This commit is contained in:
SoniEx2 2018-03-31 15:39:11 -03:00
parent e4e7b29d09
commit cca18e4fee
1 changed files with 17 additions and 2 deletions

View File

@ -649,9 +649,24 @@ impl<'a> EnsureValidContext<'a> {
}
}
/// Compares two nicks based on the server's case mapping.
pub fn nickcmp(&mut self, nick1: &str, nick2: &str) -> ::std::cmp::Ordering {
// TODO
unimplemented!()
use std::cmp::Ordering;
// this was a mistake but oh well
let ph = self.ph.ph;
// need to put this in a more permanent position than temporaries
let nick1 = CString::new(nick1).unwrap();
let nick2 = CString::new(nick2).unwrap();
let res = unsafe {
((*ph).hexchat_nickcmp)(ph, nick1.as_ptr(), nick2.as_ptr())
};
if res < 0 {
Ordering::Less
} else if res > 0 {
Ordering::Greater
} else {
Ordering::Equal
}
}
pub fn send_modes(&mut self) {