Debian Codegraph @

src/logger.c

raw symbols SCIP
1 /*
2 * This file is part of libdvdread.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17 */
18
19 #include "config.h"
20 #include <stdio.h>
21 #include <stdarg.h>
22
23 #include "dvdread/dvd_reader.h"
24 #include "logger.h"
25
26 #ifdef _WIN32
27 #define TTY_DEVICE "CON"
28 #else
29 #define TTY_DEVICE "/dev/tty"
30 #endif
31
32 void DVDReadLog( void *priv, const dvd_logger_cb *logcb,
33 dvd_logger_level_t level, const char *fmt, ... )
34 {
35 va_list list;
36 va_start(list, fmt);
37 if(logcb && logcb->pf_log)
38 logcb->pf_log(priv, level, fmt, list);
39 else
40 {
41 static FILE *tty_stream = NULL;
42 if (!tty_stream)
43 tty_stream = fopen(TTY_DEVICE, "w");
44
45 FILE *stream = (level == DVD_LOGGER_LEVEL_ERROR) ? stderr : tty_stream;
46
47 /* no controlling terminal so fall back to stderr */
48 if (!stream)
49 stream = stderr;
50
51 fprintf(stream, "libdvdread: ");
52 vfprintf(stream, fmt, list);
53 fprintf(stream, "\n");
54 }
55 va_end(list);
56 }