HCE project C++ developers source code library  1.1.1
HCE project developer library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AdminClient.h
Go to the documentation of this file.
1 #ifndef ADMINCLIENT_H
2 #define ADMINCLIENT_H
3 #include <sys/types.h>
4 #include <errno.h>
5 #include <string.h>
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <unistd.h>
9 #include <Socket.h>
10 #include <Thread.h>
11 #include <HttpParser.h>
12 #include <List.h>
13 #include <BaseHandler.h>
14 #include <ErrorNo.h>
15 #include <String.h>
16 #include <new>
17 #define MAX_REQUEST_SIZE 10*1024*1024
18 #define ES_OK ""
19 #define ES_UNKNOWN "Unknown error"
20 #define E_UNKNOWN 1
21 #define ES_WRONGPARAM "Wrong parameters"
22 #define E_WRONGPARAM 2
23 #define ES_BADCOMMAND "Bad command code"
24 #define E_BADCOMMAND 3
25 
26 class AdminClient: public Thread
27 {
28  public:
29  AdminClient(const char *host, int port, List<BaseHandler*> *handlerList);
30  int getLastErr(){return lastErrNo;}
31  ~AdminClient();
32  void lock(){mutex.lock();}
33  void unlock(){mutex.unlock();}
34 
35  private:
36  void* run();
37  char* readRequest(size_t &size);
38  void sendResponse(const char *response);
39  char* urlEncode(const char *url);
40  HttpParser *httpParser;
41  List<BaseHandler*> *handlerList;
42  Socket *listenSock;
43  Socket *clientSock;
44  int lastErrNo;
45  Mutex mutex;
46 };
47 #endif
48