buffer.h 2.0 KB
Newer Older
R
Rich Salz 已提交
1 2
/*
 * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
3
 *
R
Rich Salz 已提交
4 5 6 7
 * Licensed under the OpenSSL license (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * 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>
R
Rich Salz 已提交
14 15 16 17
# ifndef HEADER_CRYPTO_H
#  include <openssl/crypto.h>
# endif

18

19 20 21 22
#ifdef  __cplusplus
extern "C" {
#endif

23
# include <stddef.h>
R
Richard Levitte 已提交
24

25 26 27
# if !defined(NO_SYS_TYPES_H)
#  include <sys/types.h>
# endif
28

R
Rich Salz 已提交
29 30 31 32 33 34 35 36 37 38
/*
 * These names are outdated as of OpenSSL 1.1; a future release
 * will move them to be deprecated.
 */
# define BUF_strdup(s) OPENSSL_strdup(s)
# define BUF_strndup(s, size) OPENSSL_strndup(s, size)
# define BUF_memdup(data, size) OPENSSL_memdup(data, size)
# define BUF_strlcpy(dst, src, size)  OPENSSL_strlcpy(dst, src, size)
# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size)
# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen)
F
FdaSilvaYY 已提交
39

40 41 42 43
struct buf_mem_st {
    size_t length;              /* current number of bytes */
    char *data;
    size_t max;                 /* size of buffer */
R
Rich Salz 已提交
44
    unsigned long flags;
45
};
46

R
Rich Salz 已提交
47 48
# define BUF_MEM_FLAG_SECURE  0x01

49
BUF_MEM *BUF_MEM_new(void);
R
Rich Salz 已提交
50
BUF_MEM *BUF_MEM_new_ex(unsigned long flags);
51
void BUF_MEM_free(BUF_MEM *a);
52 53
size_t BUF_MEM_grow(BUF_MEM *str, size_t len);
size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len);
E
Emilia Kasper 已提交
54
void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz);
55 56

/* BEGIN ERROR CODES */
57 58
/*
 * The following lines are auto generated by the script mkerr.pl. Any changes
59 60
 * made after this point may be overwritten when the script is next run.
 */
R
Rich Salz 已提交
61

R
Richard Levitte 已提交
62
void ERR_load_BUF_strings(void);
63

64 65 66
/* Error codes for the BUF functions. */

/* Function codes. */
67 68 69
# define BUF_F_BUF_MEM_GROW                               100
# define BUF_F_BUF_MEM_GROW_CLEAN                         105
# define BUF_F_BUF_MEM_NEW                                101
70 71

/* Reason codes. */
72

R
Rich Salz 已提交
73
# ifdef  __cplusplus
74
}
R
Rich Salz 已提交
75
# endif
76
#endif