-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.cpp
More file actions
73 lines (67 loc) · 1.19 KB
/
Copy pathsync.cpp
File metadata and controls
73 lines (67 loc) · 1.19 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
72
73
/**
* RDNSLOGS 7.0
* Performs Reverse DNS lookups on multiple logfiles.
* This program is designed to work with the Analog Logfile analyzer.
*
* Supports compressed files
*
* Antonio C. Silvestri
*
***/
#include <iostream>
#include "sync.h"
#include "globaldata.h"
HANDLE hEvent;
#ifdef MUTEX
HANDLE hsync;
HANDLE hmapsync;
HANDLE hmutex;
#endif
#ifdef CRITSEC
CRITICAL_SECTION sync;
CRITICAL_SECTION mapsync;
CRITICAL_SECTION mutex;
#endif
//********************************************************************
void syncVerboseMessages(const char *fmt, ...) {
if (!verbose)
return;
#ifdef MUTEX
WaitForSingleObject(hsync, INFINITE);
#endif
#ifdef CRITSEC
EnterCriticalSection(&sync);
#endif
va_list ap;
va_start(ap, fmt);
for (const char *p = fmt; *p; p++) {
if (*p != '%') {
cout << *p;
continue;
}
DWORD ival;
const char *sval;
switch (*++p) {
case 'd':
case 'i':
ival = va_arg(ap, int);
cout << ival;
break;
case 's':
sval = va_arg(ap, const char *);
cout << sval;
break;
default:
putchar(*p);
break;
}
}
va_end(ap);
#ifdef MUTEX
ReleaseMutex(hsync);
#endif
#ifdef CRITSEC
LeaveCriticalSection(&sync);
#endif
}