buffer.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #ifndef HEADER_BUFFER_H
  10. # define HEADER_BUFFER_H
  11. # include <openssl/ossl_typ.h>
  12. # ifndef HEADER_CRYPTO_H
  13. # include <openssl/crypto.h>
  14. # endif
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. # include <stddef.h>
  19. # if !defined(NO_SYS_TYPES_H)
  20. # include <sys/types.h>
  21. # endif
  22. /*
  23. * These names are outdated as of OpenSSL 1.1; a future release
  24. * will move them to be deprecated.
  25. */
  26. # define BUF_strdup(s) OPENSSL_strdup(s)
  27. # define BUF_strndup(s, size) OPENSSL_strndup(s, size)
  28. # define BUF_memdup(data, size) OPENSSL_memdup(data, size)
  29. # define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size)
  30. # define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)
  31. # define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)
  32. struct buf_mem_st {
  33. size_t length; /* current number of bytes */
  34. char *data;
  35. size_t max; /* size of buffer */
  36. unsigned long flags;
  37. };
  38. # define BUF_MEM_FLAG_SECURE 0x01
  39. BUF_MEM *BUF_MEM_new(void);
  40. BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
  41. void BUF_MEM_free(BUF_MEM *a);
  42. size_t BUF_MEM_grow(BUF_MEM *str, size_t len);
  43. size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
  44. void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
  45. /* BEGIN ERROR CODES */
  46. /*
  47. * The following lines are auto generated by the script mkerr.pl. Any changes
  48. * made after this point may be overwritten when the script is next run.
  49. */
  50. int ERR_load_BUF_strings(void);
  51. /* Error codes for the BUF functions. */
  52. /* Function codes. */
  53. # define BUF_F_BUF_MEM_GROW 100
  54. # define BUF_F_BUF_MEM_GROW_CLEAN 105
  55. # define BUF_F_BUF_MEM_NEW 101
  56. /* Reason codes. */
  57. # ifdef __cplusplus
  58. }
  59. # endif
  60. #endif