diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2018-03-31 15:39:11 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2018-03-31 15:39:11 -0300 |
commit | cca18e4feeaad04d9db9354ca7a123898cc9abfa (patch) | |
tree | 4c653261afcee3509be884e747b3aa076aa24815 /src | |
parent | e4e7b29d09751195f369851eb0cea5fd6178ab16 (diff) |
Implement nickcmp
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs index 617563a..07c2cf7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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) { |