trunnel.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* trunnel.h -- Public declarations for trunnel, to be included
  2. * in trunnel header files.
  3. * Copyright 2014, The Tor Project, Inc.
  4. * See license at the end of this file for copying information.
  5. */
  6. #ifndef TRUNNEL_H_INCLUDED_
  7. #define TRUNNEL_H_INCLUDED_
  8. #include <sys/types.h>
  9. /** Macro to declare a variable-length dynamically allocated array. Trunnel
  10. * uses these to store all variable-length arrays. */
  11. #define TRUNNEL_DYNARRAY_HEAD(name, elttype) \
  12. struct name { \
  13. size_t n_; \
  14. size_t allocated_; \
  15. elttype *elts_; \
  16. }
  17. /** Initializer for a dynamic array of a given element type. */
  18. #define TRUNNEL_DYNARRAY_INIT(elttype) { 0, 0, (elttype*)NULL }
  19. /** Typedef used for storing variable-length arrays of char. */
  20. typedef TRUNNEL_DYNARRAY_HEAD(trunnel_string_st, char) trunnel_string_t;
  21. #endif
  22. /*
  23. Copyright 2014 The Tor Project, Inc.
  24. Redistribution and use in source and binary forms, with or without
  25. modification, are permitted provided that the following conditions are
  26. met:
  27. * Redistributions of source code must retain the above copyright
  28. notice, this list of conditions and the following disclaimer.
  29. * Redistributions in binary form must reproduce the above
  30. copyright notice, this list of conditions and the following disclaimer
  31. in the documentation and/or other materials provided with the
  32. distribution.
  33. * Neither the names of the copyright owners nor the names of its
  34. contributors may be used to endorse or promote products derived from
  35. this software without specific prior written permission.
  36. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  37. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  38. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  39. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  40. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  43. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  44. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  45. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  46. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47. */