Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

GGEP.h

Go to the documentation of this file.
00001 //
00002 // GGEP.h
00003 //
00004 // Copyright (c) Shareaza Development Team, 2002-2005.
00005 // This file is part of SHAREAZA (www.shareaza.com)
00006 //
00007 // Shareaza is free software; you can redistribute it
00008 // and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2 of
00010 // the License, or (at your option) any later version.
00011 //
00012 // Shareaza is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with Shareaza; if not, write to the Free Software
00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 //
00021 
00022 #if !defined(AFX_GGEP_H__7081FCAC_A207_412A_BD18_A72F09F89F05__INCLUDED_)
00023 #define AFX_GGEP_H__7081FCAC_A207_412A_BD18_A72F09F89F05__INCLUDED_
00024 
00025 #pragma once
00026 
00027 class CGGEPBlock;
00028 class CGGEPItem;
00029 class CPacket;
00030 
00031 
00032 class CGGEPBlock
00033 {
00034 // Construction
00035 public:
00036         CGGEPBlock();
00037         virtual ~CGGEPBlock();
00038 
00039 // Attributes
00040 public:
00041         CGGEPItem*      m_pFirst;
00042         CGGEPItem*      m_pLast;
00043         BYTE*           m_pInput;
00044         DWORD           m_nInput;
00045 
00046 // Operations
00047 public:
00048         void            Clear();
00049         CGGEPItem*      Add(LPCTSTR pszID);
00050         CGGEPItem*      Find(LPCTSTR pszID, DWORD nMinLength = 0);
00051 public:
00052         BOOL            ReadFromPacket(CPacket* pPacket);
00053         BOOL            ReadFromString(LPCTSTR pszData);
00054         void            Write(CPacket* pPacket);
00055         void            Write(CString& str);
00056         static          CGGEPBlock* FromPacket(CPacket* pPacket);
00057 protected:
00058         BOOL    ReadInternal();
00059         BYTE    ReadByte();
00060 
00061         friend class CGGEPItem;
00062 };
00063 
00064 
00065 class CGGEPItem
00066 {
00067 // Construction
00068 public:
00069         CGGEPItem(LPCTSTR pszID = NULL);
00070         virtual ~CGGEPItem();
00071 
00072 // Attributes
00073 public:
00074         CGGEPItem*      m_pNext;
00075         CString         m_sID;
00076         BYTE*           m_pBuffer;
00077         DWORD           m_nLength;
00078         DWORD           m_nPosition;
00079 
00080 // Operations
00081 public:
00082         BOOL    IsNamed(LPCTSTR pszID);
00083         void    Read(LPVOID pData, int nLength);
00084         BYTE    ReadByte();
00085         void    Write(LPCVOID pData, int nLength);
00086         void    WriteByte(BYTE nValue);
00087         CString ToString();
00088 protected:
00089         BOOL    ReadFrom(CGGEPBlock* pBlock, BYTE nFlags);
00090         void    WriteTo(CPacket* pPacket);
00091         void    WriteTo(CString& str);
00092 protected:
00093         BOOL    Encode(BOOL bIfZeros = FALSE);
00094         BOOL    Decode();
00095         BOOL    Deflate(BOOL bIfSmaller = FALSE);
00096         BOOL    Inflate();
00097 
00098         friend class CGGEPBlock;
00099 };
00100 
00101 //
00102 // Constants
00103 //
00104 
00105 #define GGEP_HDR_LAST           0x80
00106 #define GGEP_HDR_COBS           0x40
00107 #define GGEP_HDR_DEFLATE        0x20
00108 #define GGEP_HDR_IDLEN          0x0F
00109 #define GGEP_LEN_MORE           0x80
00110 #define GGEP_LEN_LAST           0x40
00111 #define GGEP_LEN_MASK           0x3F
00112 
00113 #endif // !defined(AFX_GGEP_H__7081FCAC_A207_412A_BD18_A72F09F89F05__INCLUDED_)

Generated on Thu Dec 15 10:39:42 2005 for Shareaza 2.2.1.0 by  doxygen 1.4.2