netstring.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2011 Flowroute LLC (flowroute.com)
  3. *
  4. * This file is part of Kamailio, a free SIP server.
  5. *
  6. * This file is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. *
  12. * This file 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
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #ifndef __NETSTRING_STREAM_H
  23. #define __NETSTRING_STREAM_H
  24. #include <string.h>
  25. int netstring_read_fd(int fd, char **netstring);
  26. int netstring_read(char *buffer, size_t buffer_length,
  27. char **netstring_start, size_t *netstring_length);
  28. size_t netstring_buffer_size(size_t data_length);
  29. size_t netstring_encode_new(char **netstring, char *data, size_t len);
  30. /* Errors that can occur during netstring parsing */
  31. #define NETSTRING_ERROR_TOO_LONG -1
  32. #define NETSTRING_ERROR_NO_COLON -2
  33. #define NETSTRING_ERROR_TOO_SHORT -3
  34. #define NETSTRING_ERROR_NO_COMMA -4
  35. #define NETSTRING_ERROR_LEADING_ZERO -5
  36. #define NETSTRING_ERROR_NO_LENGTH -6
  37. #define NETSTRING_ERROR_BAD_FD -7
  38. #endif