blob: 38c79d456bf9cdb56d1a9d2807b311902f4842c8 [file] [log] [blame]
bigbiff bigbiff9c754052013-01-09 09:09:08 -05001/*
2 log.c (02.09.09)
3 exFAT file system implementation library.
4
bigbiff bigbiff61cdc022013-08-08 08:35:06 -04005 Free exFAT implementation.
Matt Mower09ef1e42015-12-13 11:29:45 -06006 Copyright (C) 2010-2015 Andrew Nayenko
bigbiff bigbiff9c754052013-01-09 09:09:08 -05007
bigbiff bigbiff61cdc022013-08-08 08:35:06 -04008 This program is free software; you can redistribute it and/or modify
bigbiff bigbiff9c754052013-01-09 09:09:08 -05009 it under the terms of the GNU General Public License as published by
bigbiff bigbiff61cdc022013-08-08 08:35:06 -040010 the Free Software Foundation, either version 2 of the License, or
bigbiff bigbiff9c754052013-01-09 09:09:08 -050011 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
bigbiff bigbiff61cdc022013-08-08 08:35:06 -040018 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bigbiff bigbiff9c754052013-01-09 09:09:08 -050021*/
22
23#include "exfat.h"
24#include <stdarg.h>
25#include <syslog.h>
26#include <unistd.h>
27
28int exfat_errors;
29
30/*
31 * This message means an internal bug in exFAT implementation.
32 */
33void exfat_bug(const char* format, ...)
34{
35 va_list ap, aq;
36
37 va_start(ap, format);
38 va_copy(aq, ap);
39
40 fflush(stdout);
41 fputs("BUG: ", stderr);
42 vfprintf(stderr, format, ap);
43 va_end(ap);
44 fputs(".\n", stderr);
45
46 if (!isatty(STDERR_FILENO))
47 vsyslog(LOG_CRIT, format, aq);
48 va_end(aq);
49
Matt Mower09ef1e42015-12-13 11:29:45 -060050#if defined(__ANDROID__)
51 exit(-1);
52#else
bigbiff bigbiff9c754052013-01-09 09:09:08 -050053 abort();
Matt Mower09ef1e42015-12-13 11:29:45 -060054#endif
bigbiff bigbiff9c754052013-01-09 09:09:08 -050055}
56
57/*
58 * This message means an error in exFAT file system.
59 */
60void exfat_error(const char* format, ...)
61{
62 va_list ap, aq;
63
64 exfat_errors++;
65 va_start(ap, format);
66 va_copy(aq, ap);
67
68 fflush(stdout);
69 fputs("ERROR: ", stderr);
70 vfprintf(stderr, format, ap);
71 va_end(ap);
72 fputs(".\n", stderr);
73
74 if (!isatty(STDERR_FILENO))
75 vsyslog(LOG_ERR, format, aq);
76 va_end(aq);
77}
78
79/*
80 * This message means that there is something unexpected in exFAT file system
81 * that can be a potential problem.
82 */
83void exfat_warn(const char* format, ...)
84{
85 va_list ap, aq;
86
87 va_start(ap, format);
88 va_copy(aq, ap);
89
90 fflush(stdout);
91 fputs("WARN: ", stderr);
92 vfprintf(stderr, format, ap);
93 va_end(ap);
94 fputs(".\n", stderr);
95
96 if (!isatty(STDERR_FILENO))
97 vsyslog(LOG_WARNING, format, aq);
98 va_end(aq);
99}
100
101/*
102 * Just debug message. Disabled by default.
103 */
104void exfat_debug(const char* format, ...)
105{
106 va_list ap;
107
108 fflush(stdout);
109 fputs("DEBUG: ", stderr);
110 va_start(ap, format);
111 vfprintf(stderr, format, ap);
112 va_end(ap);
113 fputs(".\n", stderr);
114}