summaryrefslogtreecommitdiff
path: root/rust/src/sendxmpp.rs
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2016-09-03 02:00:54 +0200
committerYves Fischer <yvesf-git@xapek.org>2016-09-03 12:26:30 +0200
commit53b5c00e625bf700a21be1a3e2070d3b23f1bef4 (patch)
treefaace67aba86121a28382a0c74fe7701e4d398b7 /rust/src/sendxmpp.rs
parent311a02c31e03b23cc66e662cce63e6c19d4bc662 (diff)
downloadauth-xmppmessage-53b5c00e625bf700a21be1a3e2070d3b23f1bef4.tar.gz
auth-xmppmessage-53b5c00e625bf700a21be1a3e2070d3b23f1bef4.zip
first test version
Diffstat (limited to 'rust/src/sendxmpp.rs')
-rw-r--r--rust/src/sendxmpp.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/rust/src/sendxmpp.rs b/rust/src/sendxmpp.rs
new file mode 100644
index 0000000..2db471e
--- /dev/null
+++ b/rust/src/sendxmpp.rs
@@ -0,0 +1,21 @@
+///! Interface for the C implementation oof sending xmpp message
+
+use std::ffi::{CString, NulError};
+use std::os::raw::c_char;
+
+pub fn send_message(jid: &str, password: &str, message: &str, to: &str) -> Result<(), NulError> {
+ extern {
+ pub fn send_message(jid: *const c_char,
+ password: *const c_char,
+ message: *const c_char,
+ to: *const c_char);
+ }
+ let cjid = try!(CString::new(jid));
+ let cpassword = try!(CString::new(password));
+ let cmessage = try!(CString::new(message));
+ let cto = try!(CString::new(to));
+ unsafe {
+ send_message(cjid.as_ptr(), cpassword.as_ptr(), cmessage.as_ptr(), cto.as_ptr());
+ }
+ Ok(())
+} \ No newline at end of file