edits
[iotcloud.git] / version2 / src / server_malicious_override_do_rej / iotquery.h
1 #ifndef IOTQUERY_H
2 #define IOTQUERY_H
3 #include <iostream>
4 #include "fcgio.h"
5 #include "fcgi_stdio.h"
6
7 #define DEFAULT_SIZE 128
8 #define OFFSET_MAX 0
9 #define OFFSET_OLD 4
10 #define OFFSET_NEW 12
11
12 class IoTQuery {
13 public:
14         IoTQuery(FCGX_Request * request);
15         ~IoTQuery();
16         void processQuery();
17
18 private:
19         void sendResponse(char *data, int length);
20         void getQuery();
21         void getDirectory();
22         bool readData();
23         bool checkDirectory();
24         bool openStatusFile();
25         void updateStatusFile();
26         void decodeQuery();
27         void getSlot();
28         void putSlot();
29         void setSalt();
30         void getSalt();
31         void removeOldestSlot();
32         char * getSlotFileName(long long);
33         char * getSaltFileName();
34
35         FCGX_Request * request;
36         char *data;
37         /* Directory slot files are placed in. */
38         char *directory;
39         /* Full URI from Apache */
40         const char * uri;
41         /* Query portion of URI */
42         const char * query;
43         /* Type of request: GET or PUT */
44         const char * method;
45         /* Root directory for all accounts */
46         const char * iotcloudroot;
47         /* Expected length of data from client */
48         long long length;
49         /* Sequence number for oldest slot */
50         long long oldestentry;
51         /* Sequence number for newest slot */
52         long long newestentry;
53         /* Sequence number from request */
54         long long requestsequencenumber;
55         /* Size of queue */
56         int numqueueentries;
57         /* fd for queuestatus file */
58         int fd;
59         /* Is the request to get a slot? */
60         bool reqGetSlot;
61         /* Is the request to put a slot? */
62         bool reqPutSlot;
63         /* Is the request to set the salt? */
64         bool reqSetSalt;
65         /* Is the request to get the salt? */
66         bool reqGetSalt;
67 };
68 #endif