[TeamTalk 19]: [556] TeamTalk/Agents/PrimitiveComm: Fixed gcc/linux compilation issues.
tk@edam.speech.cs.cmu.edu
tk at edam.speech.cs.cmu.edu
Mon Dec 11 03:01:47 EST 2006
An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20061211/d1e0a00f/attachment.html
-------------- next part --------------
Modified: TeamTalk/Agents/PrimitiveComm/geometry.h
===================================================================
--- TeamTalk/Agents/PrimitiveComm/geometry.h 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/geometry.h 2006-12-11 08:01:47 UTC (rev 556)
@@ -10,18 +10,18 @@
namespace geometry {
template<typename T> struct Point {
- T x, y;
- Point<T>() : x(0), y(0) {};
- Point<T>(T X, T Y) : x(X), y(Y) {};
+ T x, y;
+ Point<T>() : x(0), y(0) {};
+ Point<T>(T X, T Y) : x(X), y(Y) {};
template<typename L> static Point<T> Polar(L length, double angle) {
return Point<T>((T)(cos(angle)*length), (T)(sin(angle)*length));
}
- Point<T> rotate(double rads) {
- double r = sqrt(x*x + y*y);
- double theta = atan2(y, x);
- x = (T) (r*cos(theta+rads));
- y = (T) (r*sin(theta+rads));
- return *this;
+ Point<T> rotate(double rads) {
+ double r = sqrt(x*x + y*y);
+ double theta = atan2(y, x);
+ x = (T) (r*cos(theta+rads));
+ y = (T) (r*sin(theta+rads));
+ return *this;
}
double length() const {return sqrt(x*x+y*y);};
double angle() const {return atan2(y, x);};
@@ -41,6 +41,7 @@
y += rhs.y;
return *this;
}
+ bool operator!() {return x != 0 || y != 0;}
};
template<typename T> struct Polygon : public vector< Point<T> > {
@@ -49,53 +50,54 @@
Polygon<T>(const Polygon<T>& p) : vector< Point<T> >(p) {};
};
-template<typename T> struct Quadrilateral : public Polygon<T> {
- Quadrilateral<T>() : Polygon<T>(4) {};
- Quadrilateral<T>(const Quadrilateral<T>& q) : Polygon<T>(q) {};
+template<typename T> struct Quadrilateral : public Polygon<T>
+{
+ Quadrilateral<T>() : Polygon<T>(4) {};
+ Quadrilateral<T>(const Quadrilateral<T>& q) : Polygon<T>(q) {};
Quadrilateral<T>(Point<T> lower_left, Point<T> upper_right) : Polygon<T>(4) {
- // axis-aligned quadrilateral
- at(0) = Point<T>(lower_left.x, lower_left.y);
- at(1) = Point<T>(lower_left.x, upper_right.y);
- at(2) = Point<T>(upper_right.x, upper_right.y);
- at(3) = Point<T>(upper_right.x, lower_left.y);
+ // axis-aligned quadrilateral
+ push_back(Point<T>(lower_left.x, lower_left.y));
+ push_back(Point<T>(lower_left.x, upper_right.y));
+ push_back(Point<T>(upper_right.x, upper_right.y));
+ push_back(Point<T>(upper_right.x, lower_left.y));
};
- Quadrilateral<T>(T x1, T x2, T y1, T y2) : Polygon(4) {
- at(0) = Point<T>(MIN(x1, x2), MIN(y1, y2));
- at(1) = Point<T>(MIN(x1, x2), MAX(y1, y2));
- at(2) = Point<T>(MAX(x1, x2), MAX(y1, y2));
- at(3) = Point<T>(MAX(x1, x2), MIN(y1, y2));
+ Quadrilateral<T>(T x1, T x2, T y1, T y2) : Polygon<T>(4) {
+ push_back(Point<T>(MIN(x1, x2), MIN(y1, y2)));
+ push_back(Point<T>(MIN(x1, x2), MAX(y1, y2)));
+ push_back(Point<T>(MAX(x1, x2), MAX(y1, y2)));
+ push_back(Point<T>(MAX(x1, x2), MIN(y1, y2)));
};
- Quadrilateral<T>(Point<T> p1, Point<T> p2, Point<T> p3, Point<T> p4): Polygon(4) {
- at(0) = p1; at(1) = p2; at(2) = p3; at(3) = p4;
+ Quadrilateral<T>(Point<T> p1, Point<T> p2, Point<T> p3, Point<T> p4): Polygon<T>(4) {
+ push_back(p1); push_back(p2); push_back(p3); push_back(p4);
};
operator Polygon<T>() const {return *this;}
- Point<T> ll() const {
- Point<T> retval = at(0);
- for(int i=1; i<4; i++) {
- if(at(i).x < retval.x || at(i).y < retval.y) retval = at(i);
- }
- return retval;
+ Point<T> ll() const {
+ Point<T> retval = this->at(0);
+ for(int i=1; i<4; i++) {
+ if(this->at(i).x < retval.x || this->at(i).y < retval.y) retval = this->at(i);
+ }
+ return retval;
};
- Point<T> ul() const {
- Point<T> retval = at(0);
- for(int i=1; i<4; i++) {
- if(at(i).x > retval.x || at(i).y < retval.y) retval = at(i);
- }
- return retval;
+ Point<T> ul() const {
+ Point<T> retval = this->at(0);
+ for(int i=1; i<4; i++) {
+ if(this->at(i).x > retval.x || this->at(i).y < retval.y) retval = this->at(i);
+ }
+ return retval;
};
- Point<T> ur() const {
- Point<T> retval = at(0);
- for(int i=1; i<4; i++) {
- if(at(i).x > retval.x || at(i).y > retval.y) retval = at(i);
- }
- return retval;
+ Point<T> ur() const {
+ Point<T> retval = this->at(0);
+ for(int i=1; i<4; i++) {
+ if(this->at(i).x > retval.x || this->at(i).y > retval.y) retval = this->at(i);
+ }
+ return retval;
};
- Point<T> lr() const {
- Point<T> retval = at(0);
- for(int i=1; i<4; i++) {
- if(at(i).x < retval.x || at(i).y > retval.y) retval = at(i);
- }
- return retval;
+ Point<T> lr() const {
+ Point<T> retval = this->at(0);
+ for(int i=1; i<4; i++) {
+ if(this->at(i).x < retval.x || this->at(i).y > retval.y) retval = this->at(i);
+ }
+ return retval;
};
};
Modified: TeamTalk/Agents/PrimitiveComm/robot_class.cpp
===================================================================
--- TeamTalk/Agents/PrimitiveComm/robot_class.cpp 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/robot_class.cpp 2006-12-11 08:01:47 UTC (rev 556)
@@ -22,7 +22,7 @@
if((in >> s).fail()) return in;
if(s == "safe" || s == "SAFE") robotClass = Robot::SAFE;
else if(s == "dangerous" || s == "DANGEROUS") robotClass = Robot::DANGEROUS;
- else in.setf(ios::failbit);
+ else in.setstate(ios_base::failbit);
return in;
}
@@ -39,4 +39,4 @@
out << (int)robotClass;
}
return out;
-}
\ No newline at end of file
+}
Modified: TeamTalk/Agents/PrimitiveComm/robot_class.h
===================================================================
--- TeamTalk/Agents/PrimitiveComm/robot_class.h 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/robot_class.h 2006-12-11 08:01:47 UTC (rev 556)
@@ -25,4 +25,4 @@
istream& operator>>(istream& in, TeamTalk::Robot::RobotClass& robotClass);
ostream& operator<<(ostream& out, const TeamTalk::Robot::RobotClass& robotClass);
-#endif
\ No newline at end of file
+#endif
Modified: TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp
===================================================================
--- TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/robot_packet2.cpp 2006-12-11 08:01:47 UTC (rev 556)
@@ -1,6 +1,6 @@
#include "robot_packet2.h"
#include "utils.h"
-#include "win_netutils.h"
+#include "netutils.h"
//these are for Msg::stamp
#include <sys/types.h>
@@ -536,17 +536,17 @@
//normal instantiation
MsgMap::MsgMap(short invoice, int sequence, int width, int height, const string& imageData, MsgMap::Encoding encoding, string sender)
-: Msg(sender), invoice_(invoice), sequence_(sequence), width_(width), height_(height), imageData_(imageData.begin(), imageData.end()), encoding_(encoding) {}
+ : Msg(sender), invoice_(invoice), width_(width), height_(height), sequence_(sequence), encoding_(encoding), imageData_(imageData.begin(), imageData.end()) {}
//instatiation from a Boeing packet
MsgMap::MsgMap(string sender, double tstamp, short invoice, int sequence, int width, int height, const string& imageData, MsgMap::Encoding encoding)
-: Msg(sender, tstamp), invoice_(invoice), sequence_(sequence), width_(width), height_(height), imageData_(imageData.begin(), imageData.end()), encoding_(encoding) {}
+ : Msg(sender, tstamp), invoice_(invoice), width_(width), height_(height), sequence_(sequence), encoding_(encoding), imageData_(imageData) {}
int MsgMap::getWidth() const {return width_;}
int MsgMap::getHeight() const {return height_;}
short MsgMap::getInvoice() const {return invoice_;}
int MsgMap::getSequence() const {return sequence_;}
-basic_string<unsigned char> MsgMap::getImageData() const {return imageData_;}
+string MsgMap::getImageData() const {return imageData_;}
size_t MsgMap::getImageDataSize() const {return imageData_.size();}
MsgMap::Encoding MsgMap::getEncoding() const {return encoding_;}
@@ -581,7 +581,7 @@
break;
default: throw MalformedPacketException("MsgMap::renderBoeingPacket()", "");
}
- Boeing::MsgMap::MsgMapFactory(e, packet, imageData_.c_str(), (int)imageData_.size(), invoice_, sequence_, width_, height_);
+ Boeing::MsgMap::MsgMapFactory(e, packet, (const unsigned char*)imageData_.c_str(), (int)imageData_.size(), invoice_, sequence_, width_, height_);
string spacket(reinterpret_cast<char*>(packet), packet->getSize());
free(packet);
return spacket;
@@ -591,4 +591,5 @@
ostream& operator<<(ostream& out, const Msg* m) {
return out << m->render();
-}
\ No newline at end of file
+}
+
Modified: TeamTalk/Agents/PrimitiveComm/robot_packet2.h
===================================================================
--- TeamTalk/Agents/PrimitiveComm/robot_packet2.h 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/robot_packet2.h 2006-12-11 08:01:47 UTC (rev 556)
@@ -271,7 +271,7 @@
short invoice_;
int width_, height_, sequence_;
Encoding encoding_;
- basic_string<unsigned char> imageData_;
+ string imageData_;
public:
//normal instantiation
MsgMap(short invoice, int sequence, int width, int height, const string& imageData, Encoding encoding, string sender=string());
@@ -281,7 +281,7 @@
int getHeight() const;
short getInvoice() const;
int getSequence() const;
- basic_string<unsigned char> getImageData() const;
+ string getImageData() const;
size_t getImageDataSize() const;
Encoding getEncoding() const;
string render() const;
Modified: TeamTalk/Agents/PrimitiveComm/stdint.h
===================================================================
--- TeamTalk/Agents/PrimitiveComm/stdint.h 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/stdint.h 2006-12-11 08:01:47 UTC (rev 556)
@@ -30,7 +30,7 @@
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned uint32_t;
-typedef long long int64_t;
+typedef long long int64_t;
typedef unsigned long long uint64_t;
/* 7.18.1.2 Minimum-width integer types */
Modified: TeamTalk/Agents/PrimitiveComm/udpsocket.cc
===================================================================
--- TeamTalk/Agents/PrimitiveComm/udpsocket.cc 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/udpsocket.cc 2006-12-11 08:01:47 UTC (rev 556)
@@ -18,7 +18,6 @@
#include <stdio.h>
#include <stdlib.h>
-//#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
@@ -26,9 +25,13 @@
#include <assert.h>
+#ifndef WIN32
+#include <unistd.h>
+#include <sys/time.h>
+#endif
+
//#include <netdb.h>
-//#include <sys/time.h>
#include <sys/types.h>
//#include <sys/socket.h>
#include <sys/stat.h>
@@ -97,8 +100,8 @@
return timebuffer.time + (float)timebuffer.millitm/1000;
#else
struct timeval curr;
- gettimeofday(&curr, NULL);
- return (curr.tv_sec + curr.tv_usec / 1000000.0);
+ gettimeofday(&curr, NULL);
+ return (curr.tv_sec + curr.tv_usec / 1000000.0);
#endif
}
@@ -176,7 +179,7 @@
#ifdef WIN32
closesocket(fd);
#else
- close(fd);
+ close(fd);
#endif
return status = NotConnected;
}
Modified: TeamTalk/Agents/PrimitiveComm/utils.cpp
===================================================================
--- TeamTalk/Agents/PrimitiveComm/utils.cpp 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/utils.cpp 2006-12-11 08:01:47 UTC (rev 556)
@@ -1,5 +1,9 @@
#ifdef WIN32
#include <direct.h>
+#else
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
#endif
#include "utils.h"
@@ -7,70 +11,70 @@
//parses an english number from zero to nine hundred ninety nine
int GetNumber999(const string& x)
{
- istringstream issX(x);
- int retval = 0;
- for(string token; issX >> token;) {
- if(token == "ZERO") {
- // do nothing
- } else if(token == "ONE" || token == "A") {
- retval += 1;
- } else if(token == "TWO") {
- retval += 2;
- } else if(token == "THREE") {
- retval += 3;
- } else if(token == "FOUR") {
- retval += 4;
- } else if(token == "FIVE") {
- retval += 5;
- } else if(token == "SIX") {
- retval += 6;
- } else if(token == "SEVEN") {
- retval += 7;
- } else if(token == "EIGHT") {
- retval += 8;
- } else if(token == "NINE") {
- retval += 9;
- } else if(token == "TEN") {
- retval += 10;
- } else if(token == "ELEVEN") {
- retval += 11;
- } else if(token == "TWELVE") {
- retval += 12;
- } else if(token == "THIRTEEN") {
- retval += 13;
- } else if(token == "FOURTEEN") {
- retval += 14;
- } else if(token == "FIFTEEN") {
- retval += 15;
- } else if(token == "SIXTEEN") {
- retval += 16;
- } else if(token == "SEVENTEEN") {
- retval += 17;
- } else if(token == "EIGHTEEN") {
- retval += 18;
- } else if(token == "NINETEEN") {
- retval += 19;
- } else if(token == "TWENTY") {
- retval += 20;
- } else if(token == "THIRTY") {
- retval += 30;
- } else if(token == "FORTY") {
- retval += 40;
- } else if(token == "FIFTY") {
- retval += 50;
- } else if(token == "SIXTY") {
- retval += 60;
- } else if(token == "SEVENTY") {
- retval += 70;
- } else if(token == "EIGHTY") {
- retval += 80;
- } else if(token == "NINETY") {
- retval += 90;
- } else if(token == "HUNDRED") {
- retval *= 100;
- }
- }
- return retval;
+ istringstream issX(x);
+ int retval = 0;
+ for(string token; issX >> token;) {
+ if(token == "ZERO") {
+ // do nothing
+ } else if(token == "ONE" || token == "A") {
+ retval += 1;
+ } else if(token == "TWO") {
+ retval += 2;
+ } else if(token == "THREE") {
+ retval += 3;
+ } else if(token == "FOUR") {
+ retval += 4;
+ } else if(token == "FIVE") {
+ retval += 5;
+ } else if(token == "SIX") {
+ retval += 6;
+ } else if(token == "SEVEN") {
+ retval += 7;
+ } else if(token == "EIGHT") {
+ retval += 8;
+ } else if(token == "NINE") {
+ retval += 9;
+ } else if(token == "TEN") {
+ retval += 10;
+ } else if(token == "ELEVEN") {
+ retval += 11;
+ } else if(token == "TWELVE") {
+ retval += 12;
+ } else if(token == "THIRTEEN") {
+ retval += 13;
+ } else if(token == "FOURTEEN") {
+ retval += 14;
+ } else if(token == "FIFTEEN") {
+ retval += 15;
+ } else if(token == "SIXTEEN") {
+ retval += 16;
+ } else if(token == "SEVENTEEN") {
+ retval += 17;
+ } else if(token == "EIGHTEEN") {
+ retval += 18;
+ } else if(token == "NINETEEN") {
+ retval += 19;
+ } else if(token == "TWENTY") {
+ retval += 20;
+ } else if(token == "THIRTY") {
+ retval += 30;
+ } else if(token == "FORTY") {
+ retval += 40;
+ } else if(token == "FIFTY") {
+ retval += 50;
+ } else if(token == "SIXTY") {
+ retval += 60;
+ } else if(token == "SEVENTY") {
+ retval += 70;
+ } else if(token == "EIGHTY") {
+ retval += 80;
+ } else if(token == "NINETY") {
+ retval += 90;
+ } else if(token == "HUNDRED") {
+ retval *= 100;
+ }
+ }
+ return retval;
}
DebugStream::Level DebugStream::threashold_ = DebugStream::F;
@@ -82,27 +86,27 @@
DebugStream fatal = DebugStream(DebugStream::F);
string& tolower(string& x) {
- for(string::iterator i=x.begin(); i!=x.end(); i++) *i = tolower(*i);
- return x;
+ for(string::iterator i=x.begin(); i!=x.end(); i++) *i = tolower(*i);
+ return x;
}
string tolower(const string& x) {
- string retval(x);
- return tolower(retval);
+ string retval(x);
+ return tolower(retval);
}
string& toupper(string& x) {
- for(string::iterator i=x.begin(); i!=x.end(); i++) *i = toupper(*i);
- return x;
+ for(string::iterator i=x.begin(); i!=x.end(); i++) *i = toupper(*i);
+ return x;
}
string toupper(const string& x) {
- string retval(x);
- return toupper(retval);
+ string retval(x);
+ return toupper(retval);
}
istream& ignoreToEndOfLine(istream& x) {
- return x.ignore(numeric_limits<int>::max(), '\n');
+ return x.ignore(numeric_limits<int>::max(), '\n');
}
istream& istreamLookFor(istream& in, char c) {
@@ -121,20 +125,21 @@
void substitute(string& temp, const string& var, const string& val)
{
- for(string::size_type j = temp.find(var); j != string::npos; j = temp.find(var)) {
- temp.replace(j, var.size(), val);
- }
+ for(string::size_type j = temp.find(var); j != string::npos; j = temp.find(var)) {
+ temp.replace(j, var.size(), val);
+ }
}
void substitute(string& temp, const map<string, string>& subs)
{
- for(map<string, string>::const_iterator i = subs.begin(); i != subs.end(); i++) {
- substitute(temp, i->first, i->second);
- }
+ for(map<string, string>::const_iterator i = subs.begin(); i != subs.end(); i++) {
+ substitute(temp, i->first, i->second);
+ }
}
#ifndef WIN32
-int spawn(string working_dir, string cmd, vector<string> args) {
+int spawn(bool wait, const string& working_dir, const string& cmd, vector<string> args)
+{
char** argv = new char*[args.size()+2];
argv[0] = new char[cmd.size()+1];
strcpy(argv[0], cmd.c_str());
@@ -144,10 +149,10 @@
strcpy(argv[i+1], args[i].c_str());
}
argv[i+1] = NULL;
- cerr << "spawn: working dir: " << working_dir << " cmd: " << cmd;
+ debug << "spawn: working dir: " << working_dir << " cmd: " << cmd;
for(vector<string>::const_iterator i=args.begin(); i!=args.end(); i++)
- cerr << ' ' << *i;
- cerr << endl;
+ debug << ' ' << *i;
+ debug << endl;
int pid;
if(!(pid = fork())) {
if(chdir(working_dir.c_str()) < 0) {
@@ -159,10 +164,15 @@
exit(1);
} else if(pid < 0) {
perror("fork");
- exit(1);
+ return -1;
}
+ if(wait) waitpid(pid, NULL, 0);
return pid;
}
+int spawn(bool wait, const string& title, const string& working_dir, const string& cmd, vector<string> args)
+{
+ return spawn(wait, working_dir, cmd, args);
+}
#else
PROCESS_INFORMATION spawn(const string& title, const string& wdir,
const string& cmd,
@@ -179,57 +189,66 @@
PROCESS_INFORMATION spawn(const string& title, const string& wdir,
const string& exe, string args)
{
- //CreateProcess wants a writable char* for some stupid reason
- ostringstream cmdline;
- cmdline << exe << ' ' << args;
- char* temppath = new char[cmdline.str().length()+1];
- cmdline.str().copy(temppath, cmdline.str().length());
- temppath[cmdline.str().length()] = '\0';
+ //CreateProcess wants a writable char* for some stupid reason
+ ostringstream cmdline;
+ cmdline << exe << ' ' << args;
+ char* temppath = new char[cmdline.str().length()+1];
+ cmdline.str().copy(temppath, cmdline.str().length());
+ temppath[cmdline.str().length()] = '\0';
debug << "fixin' to spawn: " << temppath << endl;
-
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- ZeroMemory(&si, sizeof(si));
- si.cb = sizeof(si);
- si.lpTitle = (LPSTR) title.c_str();
- ZeroMemory(&pi, sizeof(pi));
- if (!CreateProcess(NULL,
- temppath,
- NULL,
- NULL,
- FALSE,
- CREATE_NEW_CONSOLE,
- NULL,
- wdir.c_str(),
- &si,
- &pi)) {
- switch(errno) {
- case E2BIG: error << "Argument list exceeds 1024 bytes"; break;
- case EINVAL: error << "mode argument is invalid"; break;
- case ENOENT: error << "File or path is not found"; break;
- case ENOEXEC: error << "Specified file is not executable or has invalid executable-file format"; break;
- case ENOMEM: error << "Not enough memory is available to execute new process"; break;
- default: error << "Some unknown spawn error";
- }
- error << endl;
- }
- delete temppath;
- return pi;
+
+ STARTUPINFO si;
+ PROCESS_INFORMATION pi;
+ ZeroMemory(&si, sizeof(si));
+ si.cb = sizeof(si);
+ si.lpTitle = (LPSTR) title.c_str();
+ ZeroMemory(&pi, sizeof(pi));
+ if (!CreateProcess(NULL,
+ temppath,
+ NULL,
+ NULL,
+ FALSE,
+ CREATE_NEW_CONSOLE,
+ NULL,
+ wdir.c_str(),
+ &si,
+ &pi)) {
+ switch(errno) {
+ case E2BIG: error << "Argument list exceeds 1024 bytes"; break;
+ case EINVAL: error << "mode argument is invalid"; break;
+ case ENOENT: error << "File or path is not found"; break;
+ case ENOEXEC: error << "Specified file is not executable or has invalid executable-file format"; break;
+ case ENOMEM: error << "Not enough memory is available to execute new process"; break;
+ default: error << "Some unknown spawn error";
+ }
+ error << endl;
+ }
+ delete temppath;
+ return pi;
}
#endif
bool testLastConfig(const string& source, const string& target)
{
- //return true if target is newer than source
- struct _stat source_stat, target_stat;
- if(_stat(source.c_str(), &source_stat)) {
- error << "problem stating source: " << source << endl;
- return false;
- }
- if(_stat(target.c_str(), &target_stat)) {
- error << "problem stating target: " << target << endl;
- return false;
- }
- return target_stat.st_mtime > source_stat.st_mtime;
-}
+ //return true if target is newer than source
+#ifdef WIN32
+ struct _stat source_stat, target_stat;
+ if(_stat(source.c_str(), &source_stat)) {
+#else
+ struct stat source_stat, target_stat;
+ if(stat(source.c_str(), &source_stat)) {
+#endif
+ error << "problem stating source: " << source << endl;
+ return false;
+ }
+#ifdef WIN32
+ if(_stat(target.c_str(), &target_stat)) {
+#else
+ if(stat(target.c_str(), &target_stat)) {
+#endif
+ error << "problem stating target: " << target << endl;
+ return false;
+ }
+ return target_stat.st_mtime > source_stat.st_mtime;
+ }
Modified: TeamTalk/Agents/PrimitiveComm/utils.h
===================================================================
--- TeamTalk/Agents/PrimitiveComm/utils.h 2006-12-11 03:46:02 UTC (rev 555)
+++ TeamTalk/Agents/PrimitiveComm/utils.h 2006-12-11 08:01:47 UTC (rev 556)
@@ -25,6 +25,7 @@
#include <vector>
#include <set>
#include <map>
+#include <cmath>
#include <sys/stat.h>
#include <errno.h>
@@ -49,8 +50,8 @@
enum Level {D, I, W, E, F};
protected:
static set<string> types_;
+ Level level_;
string type_;
- Level level_;
public:
static Level threashold_;
DebugStream(Level level=D, const string s=string()) : level_(level), type_(s) {};
@@ -121,14 +122,14 @@
// ** Process *********************************************************
#ifndef WIN32
-int spawn(const string& wdir, const string& cmd,
+int spawn(bool wait, const string& wdir, const string& cmd,
vector<string> args=vector<string>());
-int spawn(const string& wdir, const string& cmd, const string& exe,
- string args=string());
+int spawn(bool wait, const string& title, const string& wdir,
+ const string& cmd, string args=string());
#else
-PROCESS_INFORMATION spawn(string wd, string cmd,
+PROCESS_INFORMATION spawn(bool wait, const string& wd, const string& cmd,
vector<string> args=vector<string>());
-PROCESS_INFORMATION spawn(const string& title, const string& wdir,
+PROCESS_INFORMATION spawn(bool wait, const string& title, const string& wdir,
const string& exe, string args=string());
#endif
More information about the TeamTalk-developers
mailing list