make error tables const and separate header file
[openssl.git] / include / openssl / buffer.h
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
10 #ifndef HEADER_BUFFER_H
11 # define HEADER_BUFFER_H
12
13 # include <openssl/ossl_typ.h>
14 # ifndef HEADER_CRYPTO_H
15 #  include <openssl/crypto.h>
16 # endif
17 # include <openssl/buffererr.h>
18
19
20 #ifdef  __cplusplus
21 extern "C" {
22 #endif
23
24 # include <stddef.h>
25
26 # if !defined(NO_SYS_TYPES_H)
27 #  include <sys/types.h>
28 # endif
29
30 /*
31  * These names are outdated as of OpenSSL 1.1; a future release
32  * will move them to be deprecated.
33  */
34 # define BUF_strdup(s) OPENSSL_strdup(s)
35 # define BUF_strndup(s, size) OPENSSL_strndup(s, size)
36 # define BUF_memdup(data, size) OPENSSL_memdup(data, size)
37 # define BUF_strlcpy(dst, src, size)  OPENSSL_strlcpy(dst, src, size)
38 # define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)
39 # define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)
40
41 struct buf_mem_st {
42     size_t length;              /* current number of bytes */
43     char *data;
44     size_t max;                 /* size of buffer */
45     unsigned long flags;
46 };
47
48 # define BUF_MEM_FLAG_SECURE  0x01
49
50 BUF_MEM *BUF_MEM_new(void);
51 BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
52 void BUF_MEM_free(BUF_MEM *a);
53 size_t BUF_MEM_grow(BUF_MEM *str, size_t len);
54 size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
55 void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
56
57 int ERR_load_BUF_strings(void);
58
59 # ifdef  __cplusplus
60 }
61 # endif
62 #endif