netstring.h 1.5 KB

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