ffi.rs 716 B

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