1 /*****************************************************************************
2 
3  qprintf.c - module to emulate a printf with a possible quiet (disable mode.)
4 
5  A global variable GifNoisyPrint controls the printing of this routine
6 
7 SPDX-License-Identifier: MIT
8 
9 *****************************************************************************/
10 
11 
12 #include <stdio.h>
13 #include <stdbool.h>
14 #include <stdarg.h>
15 
16 #include "gif_lib.h"
17 
18 bool GifNoisyPrint = false;
19 
20 /*****************************************************************************
21  Same as fprintf to stderr but with optional print.
22 ******************************************************************************/
23 void
GifQprintf(char * Format,...)24 GifQprintf(char *Format, ...) {
25     va_list ArgPtr;
26 
27     va_start(ArgPtr, Format);
28 
29     if (GifNoisyPrint) {
30 	char Line[128];
31 	(void)vsnprintf(Line, sizeof(Line), Format, ArgPtr);
32 	(void)fputs(Line, stderr);
33     }
34 
35     va_end(ArgPtr);
36 }
37 
38 void
PrintGifError(int ErrorCode)39 PrintGifError(int ErrorCode) {
40     const char *Err = GifErrorString(ErrorCode);
41 
42     if (Err != NULL)
43         fprintf(stderr, "GIF-LIB error: %s.\n", Err);
44     else
45         fprintf(stderr, "GIF-LIB undefined error %d.\n", ErrorCode);
46 }
47 
48 /* end */
49