]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/protocol/usb_hid/USB_Host_Shield_2.0/parsetools.cpp
1 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved.
3 This software may be distributed and modified under the terms of the GNU
4 General Public License version 2 (GPL2) as published by the Free Software
5 Foundation and appearing in the file GPL2.TXT included in the packaging of
6 this file. Please note that GPL2 Section 2[b] requires that all works based
7 on this software must also be made publicly available under the terms of
14 Web : http://www.circuitsathome.com
15 e-mail : support@circuitsathome.com
19 bool MultiByteValueParser::Parse(uint8_t **pp
, uint16_t *pcntdn
) {
21 Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80);
24 for(; countDown
&& (*pcntdn
); countDown
--, (*pcntdn
)--, (*pp
)++)
25 pBuf
[valueSize
- countDown
] = (**pp
);
30 countDown
= valueSize
;
34 bool PTPListParser::Parse(uint8_t **pp
, uint16_t *pcntdn
, PTP_ARRAY_EL_FUNC pf
, const void *me
) {
37 pBuf
->valueSize
= lenSize
;
38 theParser
.Initialize(pBuf
);
42 if(!theParser
.Parse(pp
, pcntdn
))
46 arLen
= (pBuf
->valueSize
>= 4) ? *((uint32_t*)pBuf
->pValue
) : (uint32_t)(*((uint16_t*)pBuf
->pValue
));
51 pBuf
->valueSize
= valSize
;
52 theParser
.Initialize(pBuf
);
56 for(; arLenCntdn
; arLenCntdn
--) {
57 if(!theParser
.Parse(pp
, pcntdn
))
61 pf(pBuf
, (arLen
- arLenCntdn
), me
);