xref: /aosp_15_r20/external/giflib/qprintf.c (revision 324bb76b8d05e2a05aa88511fff61cf3f9ca5892)
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 #include <stdarg.h>
12 #include <stdbool.h>
13 #include <stdio.h>
14 
15 #include "gif_lib.h"
16 
17 bool GifNoisyPrint = false;
18 
19 /*****************************************************************************
20  Same as fprintf to stderr but with optional print.
21 ******************************************************************************/
GifQprintf(char * Format,...)22 void GifQprintf(char *Format, ...) {
23 	va_list ArgPtr;
24 
25 	va_start(ArgPtr, Format);
26 
27 	if (GifNoisyPrint) {
28 		char Line[128];
29 		(void)vsnprintf(Line, sizeof(Line), Format, ArgPtr);
30 		(void)fputs(Line, stderr);
31 	}
32 
33 	va_end(ArgPtr);
34 }
35 
PrintGifError(int ErrorCode)36 void PrintGifError(int ErrorCode) {
37 	const char *Err = GifErrorString(ErrorCode);
38 
39 	if (Err != NULL) {
40 		fprintf(stderr, "GIF-LIB error: %s.\n", Err);
41 	} else {
42 		fprintf(stderr, "GIF-LIB undefined error %d.\n", ErrorCode);
43 	}
44 }
45 
46 /* end */
47