fbuffer.h 679 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * MessagePack for C FILE* buffer adaptor
  3. *
  4. * Copyright (C) 2013 Vladimir Volodko
  5. *
  6. * Distributed under the Boost Software License, Version 1.0.
  7. * (See accompanying file LICENSE_1_0.txt or copy at
  8. * http://www.boost.org/LICENSE_1_0.txt)
  9. */
  10. #ifndef MSGPACK_FBUFFER_H
  11. #define MSGPACK_FBUFFER_H
  12. #include <stdio.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. /**
  17. * @defgroup msgpack_fbuffer FILE* buffer
  18. * @ingroup msgpack_buffer
  19. * @{
  20. */
  21. static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
  22. {
  23. return (len == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
  24. }
  25. /** @} */
  26. #ifdef __cplusplus
  27. }
  28. #endif
  29. #endif /* msgpack/fbuffer.h */