ffi.rs 620 B

123456789101112131415161718192021
  1. //! FFI functions to announce Rust support during tor startup, only to be
  2. //! called from C.
  3. //!
  4. use libc::c_char;
  5. use tor_allocate::allocate_and_copy_string;
  6. /// Returns a short string to announce Rust support during startup.
  7. ///
  8. /// # Examples
  9. /// ```c
  10. /// char *rust_str = rust_welcome_string();
  11. /// printf("%s", rust_str);
  12. /// tor_free(rust_str);
  13. /// ```
  14. #[no_mangle]
  15. pub extern "C" fn rust_welcome_string() -> *mut c_char {
  16. let rust_welcome = String::from("Tor is running with Rust integration. Please report \
  17. any bugs you encouter.");
  18. allocate_and_copy_string(&rust_welcome)
  19. }