18.03.2013 - Bug fixes, add in/out speed diagnostic to PIProtocol, fixed PIConsole tab switch segfault, PIObject EVENT / EVENT_HANDLER mechanism update - new EVENT macros that use EVENT_HANDLER with raiseEvent implementation.

This allow compile check event for CONNECT and use EVENT as CONNECT target, also raise event now is simple execute EVENT function.
This commit is contained in:
peri4
2013-03-18 12:07:44 +04:00
parent cfc5eed75e
commit 66c53a27fc
72 changed files with 4407 additions and 960 deletions

24
pifile.cpp Executable file → Normal file
View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
File
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
Copyright (C) 2013 Ivan Pelipenko peri4ko@gmail.com
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
@@ -33,21 +33,20 @@ bool PIFile::openDevice() {
bool PIFile::closeDevice() {
if (!opened_) return true;
return (fclose(fd) != 0);
return (fclose(fd) == 0);
}
PIString PIFile::readLine() {
PIString str;
if (!opened_) return str;
char cc;
int cp = 0;
int cc, cp = 0;
while (!isEnd() && cp < 4095) {
cc = char(fgetc(fd));
if (cc == '\n') break;
str.push_back(cc);
cc = fgetc(fd);
if (char(cc) == '\n' || cc == EOF) break;
str.push_back(char(cc));
}
//cout << "readline: " << buff << endl;
//cout << "readline: " << str << endl;
return str;
}
@@ -66,17 +65,20 @@ llong PIFile::readAll(void * data) {
PIByteArray PIFile::readAll(bool forceRead) {
llong cp = pos(), s = size();
PIByteArray a;
if (s < 0) {
if (!forceRead) return a;
llong cp = pos();
if (forceRead) {
seekToBegin();
while (!isEnd())
a.push_back(readChar());
seek(cp);
return a;
}
llong s = size();
if (s < 0) return a;
a.resize(s);
s = readAll(a.data());
seek(cp);
if (s >= 0) a.resize(s);
return a;
}