/src/giflib-code/qprintf.c
Line  | Count  | Source  | 
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  |  | *****************************************************************************/  | 
8  |  | // SPDX-License-Identifier: MIT  | 
9  |  | // SPDX-FileCopyrightText: Copyright (C) Eric S. Raymond <esr@thyrsus.com>  | 
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  |  | ******************************************************************************/  | 
22  | 0  | void GifQprintf(char *Format, ...) { | 
23  | 0  |   va_list ArgPtr;  | 
24  |  | 
  | 
25  | 0  |   va_start(ArgPtr, Format);  | 
26  |  | 
  | 
27  | 0  |   if (GifNoisyPrint) { | 
28  | 0  |     char Line[128];  | 
29  | 0  |     (void)vsnprintf(Line, sizeof(Line), Format, ArgPtr);  | 
30  | 0  |     (void)fputs(Line, stderr);  | 
31  | 0  |   }  | 
32  |  | 
  | 
33  | 0  |   va_end(ArgPtr);  | 
34  | 0  | }  | 
35  |  |  | 
36  | 0  | void PrintGifError(int ErrorCode) { | 
37  | 0  |   const char *Err = GifErrorString(ErrorCode);  | 
38  |  | 
  | 
39  | 0  |   if (Err != NULL) { | 
40  | 0  |     fprintf(stderr, "GIF-LIB error: %s.\n", Err);  | 
41  | 0  |   } else { | 
42  |  |     fprintf(stderr, "GIF-LIB undefined error %d.\n", ErrorCode);  | 
43  | 0  |   }  | 
44  | 0  | }  | 
45  |  |  | 
46  |  | /* end */  |