Coverage Report

Created: 2025-07-23 08:18

/work/include/jasper/jas_debug.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright (c) 2001-2002 Michael David Adams.
3
 * All rights reserved.
4
 */
5
6
/* __START_OF_JASPER_LICENSE__
7
 * 
8
 * JasPer License Version 2.0
9
 * 
10
 * Copyright (c) 2001-2006 Michael David Adams
11
 * Copyright (c) 1999-2000 Image Power, Inc.
12
 * Copyright (c) 1999-2000 The University of British Columbia
13
 * 
14
 * All rights reserved.
15
 * 
16
 * Permission is hereby granted, free of charge, to any person (the
17
 * "User") obtaining a copy of this software and associated documentation
18
 * files (the "Software"), to deal in the Software without restriction,
19
 * including without limitation the rights to use, copy, modify, merge,
20
 * publish, distribute, and/or sell copies of the Software, and to permit
21
 * persons to whom the Software is furnished to do so, subject to the
22
 * following conditions:
23
 * 
24
 * 1.  The above copyright notices and this permission notice (which
25
 * includes the disclaimer below) shall be included in all copies or
26
 * substantial portions of the Software.
27
 * 
28
 * 2.  The name of a copyright holder shall not be used to endorse or
29
 * promote products derived from the Software without specific prior
30
 * written permission.
31
 * 
32
 * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
33
 * LICENSE.  NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
34
 * THIS DISCLAIMER.  THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
35
 * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36
 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
37
 * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  IN NO
38
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
39
 * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
40
 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
41
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
42
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  NO ASSURANCES ARE
43
 * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
44
 * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
45
 * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
46
 * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
47
 * PROPERTY RIGHTS OR OTHERWISE.  AS A CONDITION TO EXERCISING THE RIGHTS
48
 * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
49
 * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY.  THE SOFTWARE
50
 * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
51
 * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
52
 * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
53
 * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
54
 * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
55
 * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
56
 * RISK ACTIVITIES").  THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
57
 * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
58
 * 
59
 * __END_OF_JASPER_LICENSE__
60
 */
61
62
/*!
63
 * @file jas_debug.h
64
 * @brief JasPer Debugging-Related Functionality
65
 */
66
67
#ifndef JAS_DEBUG_H
68
#define JAS_DEBUG_H
69
70
/******************************************************************************\
71
* Includes.
72
\******************************************************************************/
73
74
/* The configuration header file should be included first. */
75
#include <jasper/jas_config.h>
76
77
#include "jasper/jas_init.h"
78
#include "jasper/jas_debug.h"
79
80
#include <stdio.h>
81
#include <stdarg.h>
82
83
#ifdef __cplusplus
84
extern "C" {
85
#endif
86
87
/******************************************************************************\
88
* Macros and functions.
89
\******************************************************************************/
90
91
/* Output debugging information to standard error provided that the debug
92
  level is set sufficiently high. */
93
#if !defined(NDEBUG)
94
#define JAS_DBGLOG(n, x) \
95
  ((jas_get_debug_level() >= (n)) ? (jas_eprintf x) : 0)
96
#else
97
#define JAS_DBGLOG(n, x)
98
#endif
99
100
#if !defined(NDEBUG)
101
#define JAS_LOGDEBUGF(n, ...) \
102
  ((jas_get_debug_level() >= (n)) ? jas_logdebugf((n), __VA_ARGS__) : 0)
103
#else
104
#define JAS_LOGDEBUGF(n, ...)
105
#endif
106
107
/*!
108
@brief
109
Warn about the use of deprecated functionality.
110
*/
111
JAS_EXPORT
112
void jas_deprecated(const char *fmt, ...);
113
114
/*!
115
@brief
116
Get the library debug level.
117
118
@deprecated
119
This function is deprecated.
120
*/
121
JAS_DEPRECATED
122
static inline
123
int jas_getdbglevel(void)
124
0
{
125
0
  jas_deprecated("jas_getdbglevel is deprecated\n");
126
0
  return jas_get_debug_level();
127
0
}
128
129
/*!
130
@brief
131
Set the library debug level.
132
*/
133
JAS_EXPORT
134
int jas_setdbglevel(int dbglevel);
135
136
/*!
137
@brief
138
Print formatted text for the standard error stream (i.e., stderr).
139
*/
140
JAS_EXPORT
141
int jas_eprintf(const char *fmt, ...);
142
143
/*!
144
@brief
145
Generate a generic log message.
146
*/
147
JAS_EXPORT
148
int jas_logprintf(const char *fmt, ...);
149
150
/*!
151
@brief
152
Generate an error log message.
153
*/
154
JAS_EXPORT
155
int jas_logerrorf(const char *fmt, ...);
156
157
/*!
158
@brief
159
Generate a warning log message.
160
*/
161
JAS_EXPORT
162
int jas_logwarnf(const char *fmt, ...);
163
164
/*!
165
@brief
166
Generate an informational log message.
167
*/
168
JAS_EXPORT
169
int jas_loginfof(const char *fmt, ...);
170
171
/*!
172
@brief
173
Generate a debugging log message.
174
*/
175
JAS_EXPORT
176
int jas_logdebugf(int priority, const char *fmt, ...);
177
178
/*!
179
@brief
180
Dump memory.
181
*/
182
int jas_logmemdump(const void *data, size_t len);
183
184
/*!
185
@brief
186
Dump memory to a stream.
187
*/
188
JAS_EXPORT
189
int jas_memdump(FILE *out, const void *data, size_t len);
190
191
/*!
192
@brief
193
Convert to a string literal.
194
*/
195
#define JAS_STRINGIFY(x) #x
196
197
/*!
198
@brief
199
Convert to a string literal after macro expansion.
200
*/
201
#define JAS_STRINGIFYX(x) JAS_STRINGIFY(x)
202
203
#ifdef __cplusplus
204
}
205
#endif
206
207
#endif