-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathoutstreams.cpp
More file actions
71 lines (60 loc) · 1.72 KB
/
outstreams.cpp
File metadata and controls
71 lines (60 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "utility.hpp"
#include "outstreams.hpp"
static bool warningOrErrorReported = false;
static bool printMessages = true;
static bool printWarnings = true;
static bool printErrors = true;
static int numWarnings = 0;
static int numErrors = 0;
void printOutstreamStatus()
{
printf( "\n%d warnings and %d errors were reported.\n",
numWarnings,
numErrors );
fflush( stdout );
}
void printMessage( const char* format, ... )
{
if( !printMessages ) { return; }
va_list argptr;
va_start( argptr, format );
vfprintf( stdout, format, argptr );
va_end( argptr );
fflush( stdout );
warningOrErrorReported = true;
}
void printWarning( const char* format, ... )
{
++numWarnings;
if( !printWarnings ) { return; }
fprintf( stderr, "Warning: " );
va_list argptr;
va_start( argptr, format );
vfprintf( stderr, format, argptr );
va_end( argptr );
fflush( stderr );
}
void printError( const char* format, ... )
{
++numErrors;
if( !printErrors ) { return; }
fprintf( stderr, "ERROR: " );
va_list argptr;
va_start( argptr, format );
vfprintf( stderr, format, argptr );
va_end( argptr );
fprintf( stderr,
"Help improve the map analyzer: send map files that cause errors to %s.\n",
adminEmail );
fflush( stderr );
warningOrErrorReported = true;
}
void enableMessages() { printMessages = true; }
void enableWarnings() { printWarnings = true; }
void enableErrors() { printErrors = true; }
void disableMessages(){ printMessages = false; }
void disableWarnings(){ printWarnings = false; }
void disableErrors() { printErrors = false; }