1*4724848cSchristos /*
2*4724848cSchristos * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
3*4724848cSchristos *
4*4724848cSchristos * Licensed under the OpenSSL license (the "License"). You may not use
5*4724848cSchristos * this file except in compliance with the License. You can obtain a copy
6*4724848cSchristos * in the file LICENSE in the source distribution or at
7*4724848cSchristos * https://www.openssl.org/source/license.html
8*4724848cSchristos */
9*4724848cSchristos
10*4724848cSchristos #include "../testutil.h"
11*4724848cSchristos #include "output.h"
12*4724848cSchristos #include "tu_local.h"
13*4724848cSchristos
14*4724848cSchristos #include <openssl/crypto.h>
15*4724848cSchristos #include <openssl/bio.h>
16*4724848cSchristos
17*4724848cSchristos BIO *bio_out = NULL;
18*4724848cSchristos BIO *bio_err = NULL;
19*4724848cSchristos
test_open_streams(void)20*4724848cSchristos void test_open_streams(void)
21*4724848cSchristos {
22*4724848cSchristos bio_out = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
23*4724848cSchristos bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
24*4724848cSchristos #ifdef __VMS
25*4724848cSchristos bio_out = BIO_push(BIO_new(BIO_f_linebuffer()), bio_out);
26*4724848cSchristos bio_err = BIO_push(BIO_new(BIO_f_linebuffer()), bio_err);
27*4724848cSchristos #endif
28*4724848cSchristos bio_err = BIO_push(BIO_new(BIO_f_tap()), bio_err);
29*4724848cSchristos
30*4724848cSchristos OPENSSL_assert(bio_out != NULL);
31*4724848cSchristos OPENSSL_assert(bio_err != NULL);
32*4724848cSchristos }
33*4724848cSchristos
test_close_streams(void)34*4724848cSchristos void test_close_streams(void)
35*4724848cSchristos {
36*4724848cSchristos BIO_free_all(bio_out);
37*4724848cSchristos BIO_free_all(bio_err);
38*4724848cSchristos }
39*4724848cSchristos
test_vprintf_stdout(const char * fmt,va_list ap)40*4724848cSchristos int test_vprintf_stdout(const char *fmt, va_list ap)
41*4724848cSchristos {
42*4724848cSchristos return BIO_vprintf(bio_out, fmt, ap);
43*4724848cSchristos }
44*4724848cSchristos
test_vprintf_stderr(const char * fmt,va_list ap)45*4724848cSchristos int test_vprintf_stderr(const char *fmt, va_list ap)
46*4724848cSchristos {
47*4724848cSchristos return BIO_vprintf(bio_err, fmt, ap);
48*4724848cSchristos }
49*4724848cSchristos
test_flush_stdout(void)50*4724848cSchristos int test_flush_stdout(void)
51*4724848cSchristos {
52*4724848cSchristos return BIO_flush(bio_out);
53*4724848cSchristos }
54*4724848cSchristos
test_flush_stderr(void)55*4724848cSchristos int test_flush_stderr(void)
56*4724848cSchristos {
57*4724848cSchristos return BIO_flush(bio_err);
58*4724848cSchristos }
59