Go to the documentation of this file.00001 #include <string>
00002 using namespace std;
00003 #ifndef WORKER_H_
00004 #define WORKER_H_
00005
00016 namespace headers {
00017 const string filecopy = "FC";
00018 const string authenticate = "AUTH";
00019 const string ok = "OK";
00020 const string delim = ":";
00021 const string end = "\r\n";
00022 const string close = "CLOSE";
00023 const string extract = "EXTRACT";
00024 }
00025
00054 class Worker {
00055 public:
00056 Worker(void* lp);
00057 ~Worker();
00058 void comm();
00059
00060 private:
00061 int* csock;
00062 string authMessage;
00063 string authReply;
00064 string featureType;
00065 string descriptorType;
00066
00077 struct fileloc{
00078 string path;
00079 string name;
00080 string getFullName()
00081 {
00082 return path+name;
00083 }
00084 void initFromPath(string filePath)
00085 {
00086 int slash = filePath.find_last_of("/");
00087 name = filePath.substr(slash+1);
00088 path = filePath.substr(0,slash+1);
00089 }
00090 }recvFile,sendFile;
00091
00092 int snt;
00093 int rcv;
00094
00095 char *header[4096];
00096 char recordBUFF[4096];
00097
00098 stringstream ss;
00099
00100 int parseARGS(char **args, char *line);
00101 bool auth();
00102 bool intent();
00103 bool receivefile();
00104 bool sendfile();
00105 void message(const char *msg);
00106 bool receiveMessage();
00107 bool sendMessage(string msg);
00108 void killConnection();
00109 string randomFilename(string suffix);
00110
00111 };
00112
00113 #endif