summaryrefslogtreecommitdiffabout
path: root/SyslogSocket.h
Unidiff
Diffstat (limited to 'SyslogSocket.h') (more/less context) (ignore whitespace changes)
-rw-r--r--SyslogSocket.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/SyslogSocket.h b/SyslogSocket.h
new file mode 100644
index 0000000..572560f
--- a/dev/null
+++ b/SyslogSocket.h
@@ -0,0 +1,82 @@
1
2 struct CSyslogOutgoingPacket{
3 SOCKADDR_IN m_To;
4 CString m_What;
5};
6typedef CList<CSyslogOutgoingPacket*,CSyslogOutgoingPacket*> CSyslogOutgoingPackets;
7
8 class CSyslogSocket : public CAsyncSocket{
9public:
10 virtual void OnSend(int nErrorCode);
11 static UINT Priority(LPCTSTR str);
12 static UINT Facility(LPCTSTR str);
13 BOOL LogTo(LPCTSTR str);
14 SOCKADDR_IN m_DefaultHost;
15 BOOL LogTo(UINT pri,UINT fac,LPCTSTR str);
16 BOOL LogTo(DWORD sinAddr,LPCTSTR str);
17 BOOL LogTo(DWORD sinAddr,UINT pri,UINT fac,LPCTSTR str);
18 BOOL LogTo(DWORD sinAddr,UINT sinPort,UINT pri,UINT fac,LPCTSTR str);
19 BOOL LogTo(DWORD sinAddr,UINT sinPort,LPCTSTR str);
20 BOOL LogTo(SOCKADDR_IN* sin,LPCTSTR str);
21 BOOL LogTo(SOCKADDR_IN* sin,UINT pri,UINT fac,LPCTSTR str);
22 static CString Escape(LPCTSTR str);
23 virtual void Log(UINT pri,UINT fac,LPCTSTR line,SOCKADDR_IN *sin);
24 UINT m_DefaultPriority;
25 virtual void OnReceive(int nErrorCode);
26 UINT m_MaxLine;
27 void DoSelect();
28 CSyslogOutgoingPackets m_Queue;
29 CSyslogSocket();
30 UINT m_Port;
31 BOOL CreateListen(UINT port=0);
32 static LPCTSTR m_Facilities[24];
33 static LPCTSTR m_Priorities[8];
34 enum{
35 maskPriority = 7,
36 maskFacility = 0x3F8,
37 shiftFacility = 3,
38 priNone = 0xFFFF,
39 facNone = 0xFFFF,
40 totalPriorities=8,
41 totalFacilities=24,
42
43 priEmergency=0,
44 priAlert=1,
45 priCritical=2,
46 priError=3,
47 priWarning=4,
48 priNotice=5,
49 priInfo=6,
50 priDebug=7,
51
52 facKernel=0,
53 facUser=1,
54 facMail=2,
55 facDaemon=3,
56 facAuth=4,
57 facSyslog=5,
58 facLPR=6,
59 facNews=7,
60 facUUCP=8,
61 facCron=9,
62 facAuthPriv=10,
63
64 facReserved0=11,
65 facReserved1=12,
66 facReserved2=13,
67 facReserved3=14,
68 facReserved4=15,
69
70 facLocal0=16,
71 facLocal1=17,
72 facLocal2=18,
73 facLocal3=19,
74 facLocal4=20,
75 facLocal5=21,
76 facLocal6=22,
77 facLocal7=23
78 };
79 static UINT Priority(UINT pri){ return pri&maskPriority; }
80 static UINT Facility(UINT pri){ return (pri&maskFacility)>>shiftFacility; }
81 static UINT MakePriority(UINT pri,UINT fac) { return (pri&maskPriority)|((fac<<shiftFacility)&maskFacility); }
82}; \ No newline at end of file