15.10.2012 - version 0.2.0 - PIIODevice - base of file, ethernet, serial and packets extractor. PIEthernet now support also TCP (client and server). PIConsole now can align labels in each column individually.

This commit is contained in:
peri4
2012-10-15 23:36:18 +04:00
parent 5558add03e
commit cfc5eed75e
64 changed files with 1879 additions and 867 deletions

24
piprocess.cpp Normal file → Executable file
View File

@@ -1,7 +1,7 @@
/*
PIP - Platform Independent Primitives
Process
Copyright (C) 2011 Ivan Pelipenko peri4ko@gmail.com
Copyright (C) 2012 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
@@ -59,7 +59,7 @@ void PIProcess::run() {
#ifdef WINDOWS
//args.pop_front();
piForeachC (PIString & i, args)
as += i.stdString().length() + 1;
as += i.lengthAscii() + 1;
char * a = new char[as];
memset(a, ' ', as - 1);
as = 0;
@@ -93,28 +93,28 @@ void PIProcess::run() {
/// files for stdin/out/err
t_in = t_out = t_err = false;
if (f_in.path().isEmpty()) {
f_in = PIFile::openTemporary(PIFile::New | PIFile::Read);
f_in = PIFile::openTemporary(PIIODevice::ReadWrite);
t_in = true;
}
f_in.open(PIFile::New | PIFile::Read); f_in.close();
f_in.open(PIIODevice::ReadWrite); f_in.close();
if (f_out.path().isEmpty()) {
f_out = PIFile::openTemporary(PIFile::New | PIFile::Write);
f_out = PIFile::openTemporary(PIIODevice::ReadWrite);
t_out = true;
}
f_out.open(PIFile::New | PIFile::Write); f_out.close();
f_out.open(PIIODevice::WriteOnly); f_out.close();
if (f_err.path().isEmpty()) {
f_err = PIFile::openTemporary(PIFile::New | PIFile::Write);
f_err = PIFile::openTemporary(PIIODevice::ReadWrite);
t_err = true;
}
f_err.open(PIFile::New | PIFile::Write); f_err.close();
f_err.open(PIIODevice::WriteOnly); f_err.close();
str = args.front().stdString();
is_exec = true;
#ifndef WINDOWS
pid = fork();
if (pid == 0) {
#endif
FILE * tf;
FILE * tf = 0;
//cout << "exec" << endl;
//cout << f_out.path() << endl;
if (g_in) tf = freopen(f_in.path().data(), "r", stdin);
@@ -140,10 +140,10 @@ void PIProcess::run() {
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
} else
cout << "[PIProcess] \"CreateProcess\" error, " << errorString() << endl;
piCout << "[PIProcess] \"CreateProcess\" error, " << errorString() << endl;
#else
if (execve(str.c_str(), a, e) < 0)
cout << "[PIProcess] \"execve\" error, " << errorString() << endl;
piCout << "[PIProcess] \"execve\" error, " << errorString() << endl;
} else {
msleep(1);
//cout << "wait" << endl;