stdglue.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdlib.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /**
  8. * Write callback
  9. * @param _cookie - pointer to cookie (see stdio gnu extension)
  10. * @param data - pointer to data
  11. * @param size - data size
  12. * @warnign your handler must consume everything
  13. */
  14. typedef void (*FuriStdglueWriteCallback)(void* _cookie, const char* data, size_t size);
  15. /** Initialized std library glue code */
  16. void furi_stdglue_init();
  17. /**
  18. * Set global STDOUT callback
  19. * @param callback - callback or NULL to clear
  20. * @return true on success, otherwise fail
  21. * @warning function is thread aware, use this API from the same thread
  22. */
  23. bool furi_stdglue_set_global_stdout_callback(FuriStdglueWriteCallback callback);
  24. /**
  25. * Set STDOUT callback for your thread
  26. * @param callback - callback or NULL to clear
  27. * @return true on success, otherwise fail
  28. * @warning function is thread aware, use this API from the same thread
  29. */
  30. bool furi_stdglue_set_thread_stdout_callback(FuriStdglueWriteCallback callback);
  31. #ifdef __cplusplus
  32. }
  33. #endif