blob: 1fc82252ce88e983032ba439fe8681413f7cbc08 (
plain)
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
74
75
76
77
78
79
80
|
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <winsock2.h>
#include <prsht.h>
#include <newpluginapi.h>
#include <m_options.h>
#include <m_protosvc.h>
#include <m_database.h>
#include <m_langpack.h>
#include "resource.h"
#include "version.h"
#include "get_time.h"
#include "lan.h"
#include "mlan.h"
#define PROTONAME "EM_LAN_PROTO"
struct CMPlugin : public PLUGIN<CMPlugin>
{
CMPlugin() :
PLUGIN<CMPlugin>(PROTONAME)
{
RegisterProtocol(PROTOTYPE_PROTOCOL);
SetUniqueId("Nick");
}
};
//#define VERBOSE
#ifdef VERBOSE
#include <fstream>
extern std::fstream emlanLog;
#define EMLOG(x) emlanLog << "[" << __FUNCTION__ << "] [" << __FILE__ << ":" << __LINE__ << "] " << x << std::endl
#define EMLOGIF(x, y) if (y) EMLOG(x)
inline const char* showErrName(int err)
{
const char* name = "unknown";
switch (err)
{
case 0: name = "NOERROR"; break;
case WSANOTINITIALISED: name = "WSANOTINITIALIZED"; break;
case WSAENETDOWN: name = "WSAENETDOWN"; break;
case WSAEACCES: name = "WSAEACCES"; break;
case WSAEFAULT: name = "WSAEFAULT"; break;
case WSAENOTCONN: name = "WSAENOTCONN"; break;
case WSAEINTR: name = "WSAEINTR"; break;
case WSAEINPROGRESS: name = "WSAEINPROGRESS"; break;
case WSAENETRESET: name = "WSAENETRESET"; break;
case WSAENOTSOCK: name = "WSAENOTSOCK"; break;
case WSAEOPNOTSUPP: name = "WSAEOPNOTSUPP"; break;
case WSAESHUTDOWN: name = "WSAESHUTDOWN"; break;
case WSAEWOULDBLOCK: name = "WSAEWOULDBLOCK"; break;
case WSAEMSGSIZE: name = "WSAEMSGSIZE"; break;
case WSAEINVAL: name = "WSAEINVAL"; break;
case WSAECONNABORTED: name = "WSAECONNABORTED"; break;
case WSAETIMEDOUT: name = "WSAETIMEDOUT"; break;
case WSAECONNRESET: name = "WSAECONNRESET"; break;
case WSAENOBUFS: name = "WSAENOBUFS"; break;
case WSAEHOSTUNREACH: name = "WSAEHOSTUNREACH"; break;
}
return name;
}
#define EMLOGERR() { int err = WSAGetLastError(); const char* name = showErrName(err); EMLOG( "Error: " << err << '(' << name << ')' ); }
#define EMLOGERRIF(y) if (y) EMLOGERR()
#else
#define EMLOG(x)
#define EMLOGIF(x, y)
#define EMLOGERR()
#define EMLOGERRIF()
#endif
|