summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bio/bio_meth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bio/bio_meth.c')
-rw-r--r--src/lib/libcrypto/bio/bio_meth.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/lib/libcrypto/bio/bio_meth.c b/src/lib/libcrypto/bio/bio_meth.c
new file mode 100644
index 0000000000..83e5254304
--- /dev/null
+++ b/src/lib/libcrypto/bio/bio_meth.c
@@ -0,0 +1,82 @@
1/* $OpenBSD: bio_meth.c,v 1.1 2018/02/17 13:57:14 tb Exp $ */
2/*
3 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <stdlib.h>
19
20#include <openssl/bio.h>
21
22BIO_METHOD *
23BIO_meth_new(int type, const char *name)
24{
25 BIO_METHOD *biom;
26
27 if ((biom = calloc(1, sizeof(*biom))) == NULL)
28 return NULL;
29
30 biom->type = type;
31 biom->name = name;
32
33 return biom;
34}
35
36void
37BIO_meth_free(BIO_METHOD *biom)
38{
39 free(biom);
40}
41
42int
43BIO_meth_set_write(BIO_METHOD *biom, int (*write)(BIO *, const char *, int))
44{
45 biom->bwrite = write;
46 return 1;
47}
48
49int
50BIO_meth_set_read(BIO_METHOD *biom, int (*read)(BIO *, char *, int))
51{
52 biom->bread = read;
53 return 1;
54}
55
56int
57BIO_meth_set_puts(BIO_METHOD *biom, int (*puts)(BIO *, const char *))
58{
59 biom->bputs = puts;
60 return 1;
61}
62
63int
64BIO_meth_set_ctrl(BIO_METHOD *biom, long (*ctrl)(BIO *, int, long, void *))
65{
66 biom->ctrl = ctrl;
67 return 1;
68}
69
70int
71BIO_meth_set_create(BIO_METHOD *biom, int (*create)(BIO *))
72{
73 biom->create = create;
74 return 1;
75}
76
77int
78BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy)(BIO *))
79{
80 biom->destroy = destroy;
81 return 1;
82}