code format
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Packets extractor
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
PIP - Platform Independent Primitives
|
||||
Packets extractor
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 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 Lesser General Public License for more details.
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pipacketextractor.h"
|
||||
@@ -91,8 +91,8 @@ PIPacketExtractor::PIPacketExtractor(PIIODevice * device_, PIPacketExtractor::Sp
|
||||
|
||||
|
||||
void PIPacketExtractor::construct() {
|
||||
func_header = nullptr;
|
||||
func_footer = nullptr;
|
||||
func_header = nullptr;
|
||||
func_footer = nullptr;
|
||||
func_payload = nullptr;
|
||||
setPayloadSize(0);
|
||||
setTimeout(100);
|
||||
@@ -104,16 +104,16 @@ void PIPacketExtractor::construct() {
|
||||
setDevice(nullptr);
|
||||
setSplitMode(None);
|
||||
missed = footerInd = 0;
|
||||
header_found = false;
|
||||
header_found = false;
|
||||
}
|
||||
|
||||
|
||||
void PIPacketExtractor::propertyChanged(const char *) {
|
||||
mode_ = (SplitMode)(property("splitMode").toInt());
|
||||
dataSize = property("payloadSize").toInt();
|
||||
mode_ = (SplitMode)(property("splitMode").toInt());
|
||||
dataSize = property("payloadSize").toInt();
|
||||
src_header = property("header").toByteArray();
|
||||
src_footer = property("footer").toByteArray();
|
||||
time_ = property("timeout").toDouble();
|
||||
time_ = property("timeout").toDouble();
|
||||
}
|
||||
|
||||
|
||||
@@ -135,8 +135,10 @@ void PIPacketExtractor::setDevice(PIIODevice * device_) {
|
||||
|
||||
|
||||
ssize_t PIPacketExtractor::bytesAvailable() const {
|
||||
if (dev) return dev->bytesAvailable();
|
||||
else return 0;
|
||||
if (dev)
|
||||
return dev->bytesAvailable();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -183,7 +185,7 @@ bool PIPacketExtractor::validatePayload(const uchar * rec, int size) {
|
||||
|
||||
|
||||
bool PIPacketExtractor::threadedRead(const uchar * readed, ssize_t size_) {
|
||||
//piCoutObj << "readed" << size_;
|
||||
// piCoutObj << "readed" << size_;
|
||||
int ss;
|
||||
tmpbuf.append(readed, size_);
|
||||
switch (mode_) {
|
||||
@@ -194,7 +196,7 @@ bool PIPacketExtractor::threadedRead(const uchar * readed, ssize_t size_) {
|
||||
} else {
|
||||
missed += size_;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PIPacketExtractor::Header:
|
||||
if (src_header.isEmpty()) return PIIODevice::threadedRead(readed, size_);
|
||||
while (tmpbuf.size() >= src_header.size()) {
|
||||
@@ -249,14 +251,14 @@ bool PIPacketExtractor::threadedRead(const uchar * readed, ssize_t size_) {
|
||||
if (tmpbuf.size_s() < ss) return PIIODevice::threadedRead(readed, size_);
|
||||
}
|
||||
header_found = true;
|
||||
footerInd = src_header.size_s();
|
||||
footerInd = src_header.size_s();
|
||||
} else {
|
||||
if (tmpbuf.size_s() < footerInd + src_footer.size_s()) return PIIODevice::threadedRead(readed, size_);
|
||||
while (!validateFooter(src_footer.data(), tmpbuf.data(footerInd), src_footer.size_s())) {
|
||||
++footerInd;
|
||||
if (tmpbuf.size_s() < footerInd + src_footer.size_s()) return PIIODevice::threadedRead(readed, size_);
|
||||
}
|
||||
//piCout << "footer found at" << footerInd;
|
||||
// piCout << "footer found at" << footerInd;
|
||||
header_found = false;
|
||||
if (!validatePayload(tmpbuf.data(src_header.size_s()), footerInd - src_header.size_s())) {
|
||||
tmpbuf.pop_front();
|
||||
|
||||
Reference in New Issue
Block a user