From 3c71fa452f2d9dbd40c124485dd99d7de83443d8 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Wed, 9 Aug 2023 22:24:30 +0530
Subject: [PATCH] rustify a silly function from rigctl

---
 rust/src/lib.rs    |  2 +-
 rust/src/rigctl.rs | 13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 rust/src/rigctl.rs

diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 83d0269..bc40ea0 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -1,4 +1,4 @@
-use libc::{size_t};
+mod rigctl;
 
 #[no_mangle]
 pub extern "C" fn add(left: usize, right: usize) -> usize {
diff --git a/rust/src/rigctl.rs b/rust/src/rigctl.rs
new file mode 100644
index 0000000..8aea534
--- /dev/null
+++ b/rust/src/rigctl.rs
@@ -0,0 +1,13 @@
+use std::os::fd::FromRawFd;
+use std::{fs::File, io::Write};
+use std::slice;
+use libc::{write, c_int, c_char};
+
+#[no_mangle]
+pub extern "C" fn send_resp(fd: c_int, msg: *const c_char) -> () {
+    let mut f: File = unsafe { File::from_raw_fd(fd) };
+    let cstr = unsafe { std::ffi::CStr::from_ptr(msg) };
+    let buf: &[u8] = cstr.to_bytes();
+    let _ = f.write_all(buf);
+    ()
+}
-- 
2.45.2