str.h 756 B

123456789101112131415161718192021222324252627282930
  1. /* str.h -- strings to be used in the CoAP library
  2. *
  3. * Copyright (C) 2010,2011 Olaf Bergmann <bergmann@tzi.org>
  4. *
  5. * This file is part of the CoAP library libcoap. Please see
  6. * README for terms of use.
  7. */
  8. #ifndef _COAP_STR_H_
  9. #define _COAP_STR_H_
  10. #include "c_string.h"
  11. typedef struct {
  12. size_t length; /* length of string */
  13. unsigned char *s; /* string data */
  14. } str;
  15. #define COAP_SET_STR(st,l,v) { (st)->length = (l), (st)->s = (v); }
  16. /**
  17. * Returns a new string object with at least size bytes storage
  18. * allocated. The string must be released using coap_delete_string();
  19. */
  20. str *coap_new_string(size_t size);
  21. /** Deletes the given string and releases any memory allocated. */
  22. void coap_delete_string(str *);
  23. #endif /* _COAP_STR_H_ */