1 /* Miscellaneous public API.
2 Copyright (C) 2019 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2019.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18 #include <config.h>
19
20 /* Specification. */
21 #include "misc.h"
22
23 #include "term-styled-ostream.h"
24 #include "noop-styled-ostream.h"
25 #include "fd-ostream.h"
26 #include "exitfail.h"
27
28 extern int xmalloc_exit_failure;
29
30
31 styled_ostream_t
styled_ostream_create(int fd,const char * filename,ttyctl_t tty_control,const char * css_filename)32 styled_ostream_create (int fd, const char *filename, ttyctl_t tty_control,
33 const char *css_filename)
34 {
35 styled_ostream_t stream;
36
37 stream = term_styled_ostream_create (fd, filename, tty_control, css_filename);
38 if (stream == NULL)
39 stream =
40 noop_styled_ostream_create (fd_ostream_create (fd, filename, true), true);
41
42 return stream;
43 }
44
45
46 void
libtextstyle_set_failure_exit_code(int exit_code)47 libtextstyle_set_failure_exit_code (int exit_code)
48 {
49 exit_failure = exit_code;
50 xmalloc_exit_failure = exit_code;
51 }
52