io.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. *
  3. * Embedded Linux library
  4. *
  5. * Copyright (C) 2011-2014 Intel Corporation. All rights reserved.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #ifndef __ELL_IO_H
  23. #define __ELL_IO_H
  24. #include <stdbool.h>
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. struct l_io;
  29. typedef void (*l_io_debug_cb_t) (const char *str, void *user_data);
  30. typedef bool (*l_io_read_cb_t) (struct l_io *io, void *user_data);
  31. typedef bool (*l_io_write_cb_t) (struct l_io *io, void *user_data);
  32. typedef void (*l_io_disconnect_cb_t) (struct l_io *io, void *user_data);
  33. typedef void (*l_io_destroy_cb_t) (void *user_data);
  34. struct l_io *l_io_new(int fd);
  35. void l_io_destroy(struct l_io *io);
  36. int l_io_get_fd(struct l_io *io);
  37. bool l_io_set_close_on_destroy(struct l_io *io, bool do_close);
  38. bool l_io_set_read_handler(struct l_io *io, l_io_read_cb_t callback,
  39. void *user_data, l_io_destroy_cb_t destroy);
  40. bool l_io_set_write_handler(struct l_io *io, l_io_write_cb_t callback,
  41. void *user_data, l_io_destroy_cb_t destroy);
  42. bool l_io_set_disconnect_handler(struct l_io *io,
  43. l_io_disconnect_cb_t callback,
  44. void *user_data, l_io_destroy_cb_t destroy);
  45. bool l_io_set_debug(struct l_io *io, l_io_debug_cb_t callback,
  46. void *user_data, l_io_destroy_cb_t destroy);
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* __ELL_IO_H */