author | Michael Krelin <hacker@klever.net> | 2004-07-05 01:53:09 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2004-07-05 01:53:09 (UTC) |
commit | a1487b3fc0313408525cd5b2f3bc4a462df351f7 (patch) (side-by-side diff) | |
tree | 010aec6c2abd5ada2f909ac6798c93bf22508bf5 /SyslogSocket.h | |
download | klog-a1487b3fc0313408525cd5b2f3bc4a462df351f7.zip klog-a1487b3fc0313408525cd5b2f3bc4a462df351f7.tar.gz klog-a1487b3fc0313408525cd5b2f3bc4a462df351f7.tar.bz2 |
initial commit into svn repository
git-svn-id: http://svn.klever.net/kin/klog/trunk@1 fe716a7a-6dde-0310-88d9-d003556173a8
-rw-r--r-- | SyslogSocket.h | 82 |
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 @@ +
+struct CSyslogOutgoingPacket {
+ SOCKADDR_IN m_To;
+ CString m_What;
+};
+typedef CList<CSyslogOutgoingPacket*,CSyslogOutgoingPacket*> CSyslogOutgoingPackets;
+
+class CSyslogSocket : public CAsyncSocket {
+public:
+ virtual void OnSend(int nErrorCode); + static UINT Priority(LPCTSTR str); + static UINT Facility(LPCTSTR str); + BOOL LogTo(LPCTSTR str); + SOCKADDR_IN m_DefaultHost; + BOOL LogTo(UINT pri,UINT fac,LPCTSTR str); + BOOL LogTo(DWORD sinAddr,LPCTSTR str); + BOOL LogTo(DWORD sinAddr,UINT pri,UINT fac,LPCTSTR str); + BOOL LogTo(DWORD sinAddr,UINT sinPort,UINT pri,UINT fac,LPCTSTR str); + BOOL LogTo(DWORD sinAddr,UINT sinPort,LPCTSTR str); + BOOL LogTo(SOCKADDR_IN* sin,LPCTSTR str); + BOOL LogTo(SOCKADDR_IN* sin,UINT pri,UINT fac,LPCTSTR str); + static CString Escape(LPCTSTR str); + virtual void Log(UINT pri,UINT fac,LPCTSTR line,SOCKADDR_IN *sin); + UINT m_DefaultPriority; + virtual void OnReceive(int nErrorCode); + UINT m_MaxLine; + void DoSelect(); + CSyslogOutgoingPackets m_Queue;
+ CSyslogSocket(); + UINT m_Port; + BOOL CreateListen(UINT port=0); + static LPCTSTR m_Facilities[24];
+ static LPCTSTR m_Priorities[8]; + enum {
+ maskPriority = 7,
+ maskFacility = 0x3F8,
+ shiftFacility = 3,
+ priNone = 0xFFFF,
+ facNone = 0xFFFF,
+ totalPriorities=8,
+ totalFacilities=24,
+
+ priEmergency=0,
+ priAlert=1,
+ priCritical=2,
+ priError=3,
+ priWarning=4,
+ priNotice=5,
+ priInfo=6,
+ priDebug=7,
+
+ facKernel=0,
+ facUser=1,
+ facMail=2,
+ facDaemon=3,
+ facAuth=4,
+ facSyslog=5,
+ facLPR=6,
+ facNews=7,
+ facUUCP=8,
+ facCron=9,
+ facAuthPriv=10,
+
+ facReserved0=11,
+ facReserved1=12,
+ facReserved2=13,
+ facReserved3=14,
+ facReserved4=15,
+
+ facLocal0=16,
+ facLocal1=17,
+ facLocal2=18,
+ facLocal3=19,
+ facLocal4=20,
+ facLocal5=21,
+ facLocal6=22,
+ facLocal7=23
+ };
+ static UINT Priority(UINT pri) { return pri&maskPriority; }
+ static UINT Facility(UINT pri) { return (pri&maskFacility)>>shiftFacility; }
+ static UINT MakePriority(UINT pri,UINT fac) { return (pri&maskPriority)|((fac<<shiftFacility)&maskFacility); }
+};
\ No newline at end of file |