60
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
// BaseProtocol.h: interface for the CBaseProtocol class.
|
|
18 |
//
|
|
19 |
//////////////////////////////////////////////////////////////////////
|
|
20 |
|
|
21 |
#if !defined(AFX_BASEPROTOCOL_H__EABB80B6_353C_45AE_8976_AE0C0D93AC84__INCLUDED_)
|
|
22 |
#define AFX_BASEPROTOCOL_H__EABB80B6_353C_45AE_8976_AE0C0D93AC84__INCLUDED_
|
|
23 |
|
|
24 |
#if _MSC_VER > 1000
|
|
25 |
#pragma once
|
|
26 |
#endif // _MSC_VER > 1000
|
|
27 |
|
458
|
28 |
#define DECODE_MESSAGE_NOT_FOUND (0) // enough bytes, but message cannot be decoded
|
|
29 |
#define DECODE_MESSAGE_FOUND (1) // enough bytes, and message found
|
|
30 |
#define DECODE_NOT_ENOUGH_BYTES_TO_SEARCH (2) // not enough bytes to do compare
|
|
31 |
|
60
|
32 |
class CBaseProtocol
|
|
33 |
{
|
|
34 |
public:
|
|
35 |
CBaseProtocol();
|
|
36 |
virtual ~CBaseProtocol();
|
|
37 |
|
|
38 |
// used to decode a message into header/message parts
|
458
|
39 |
virtual int DecodeMessage(BYTE* fullMessage, DWORD& fullLength, BYTE& msgId, BYTE*& rawMessage, DWORD& rawLength)=0;
|
60
|
40 |
|
|
41 |
// used to encode a raw message (prefixes any protocol headers)
|
|
42 |
virtual DWORD EncodeMessage(BYTE* rawMessage, DWORD rawLength, BYTE protocolVersion, BYTE msgId, BYTE* fullMessage, DWORD maxFullLength)=0;
|
|
43 |
|
|
44 |
// used to query how many bytes the header is so the caller can allocate enough memory
|
|
45 |
virtual DWORD GetHeaderLength()=0;
|
|
46 |
|
|
47 |
};
|
|
48 |
|
|
49 |
typedef const char* (*PROTOCOLREGISTER)(void);
|
|
50 |
typedef CBaseProtocol* (*PROTOCOLCREATE)(void);
|
|
51 |
|
|
52 |
#define PROTOCOLREGISTER_FNNAME "RegisterProtocol"
|
|
53 |
#define PROTOCOLCREATE_FNNAME "CreateProtocol"
|
|
54 |
|
|
55 |
#define PROTOCOLDLL_BASENAME "TCFProt"
|
|
56 |
|
|
57 |
#endif // !defined(AFX_BASEPROTOCOL_H__EABB80B6_353C_45AE_8976_AE0C0D93AC84__INCLUDED_)
|