summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ/src/tlv.h
blob: 45503f22f385692c8dfabd39ebf8d4ce1fce1108 (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
// ---------------------------------------------------------------------------80
//                ICQ plugin for Miranda Instant Messenger
//                ________________________________________
//
// Copyright © 2000-2001 Richard Hughes, Roland Rabien, Tristan Van de Vreede
// Copyright © 2001-2002 Jon Keating, Richard Hughes
// Copyright © 2002-2004 Martin Öberg, Sam Kothari, Robert Rainwater
// Copyright © 2004-2008 Joe Kucera
// Copyright © 2012-2017 Miranda NG Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
// -----------------------------------------------------------------------------

#ifndef __TLV_H
#define __TLV_H

/*---------* Structures *--------------*/

struct oscar_tlv
{
  WORD wType;
  WORD wLen;
  BYTE *pData;
};


struct oscar_tlv_chain
{
  oscar_tlv tlv;
  oscar_tlv_chain *next;

  WORD getChainLength();

  oscar_tlv* getTLV(WORD wType, WORD wIndex);
  oscar_tlv* putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bReplace);
  oscar_tlv_chain* removeTLV(oscar_tlv *tlv);
  WORD getLength(WORD wType, WORD wIndex);

  DWORD getDWord(WORD wType, WORD wIndex);
  WORD getWord(WORD wType, WORD wIndex);
  BYTE getByte(WORD wType, WORD wIndex);
  int getNumber(WORD wType, WORD wIndex);
  double getDouble(WORD wType, WORD wIndex);
  char* getString(WORD wType, WORD wIndex);
};


struct oscar_tlv_record_list
{
  oscar_tlv_chain *item;
  oscar_tlv_record_list *next;

  oscar_tlv_chain* getRecordByTLV(WORD wType, int nValue);
};

/*---------* Functions *---------------*/

oscar_tlv_chain* readIntoTLVChain(BYTE **buf, size_t wLen, int maxTlvs);
void disposeChain(oscar_tlv_chain** chain);

oscar_tlv_record_list* readIntoTLVRecordList(BYTE **buf, size_t wLen, int nCount);
void disposeRecordList(oscar_tlv_record_list** list);


#endif /* __TLV_H */