BmnRoot
Loading...
Searching...
No Matches
MpdWebScreenshots.h
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- MpdWebScreenshots header file -----
3// ----- Created 11/12/15 by K. Smirnov -----
4// -------------------------------------------------------------------------
5
6#ifndef MPDWEBSCREENSHOTS_H
7#define MPDWEBSCREENSHOTS_H
8
9#include "MpdEventManager.h"
10
11#include "FairTask.h"
12
13#include "TString.h"
14
16#define BUFFER_SIZE 512
17#define MAX_FILE_SIZE 1024*1024
18#define MAX_CONNECTIONS 3
20
22{
24 TString outputDir;
25 int daemon;
26};
27
28
29class MpdWebScreenshots : public FairTask
30{
31 public:
32 // Standard constructor
33 //*@param name Name of task
34 //*@outputDir Output directory
35 //*@param iVerbose Verbosity level
36 MpdWebScreenshots(const char* name, char* output_dir, bool isWebServer = false, Int_t iVerbose = 0);
37
38 // Destructor
39 virtual ~MpdWebScreenshots();
40
41 // Set verbosity level. For this task and all of the subtasks.
42 void SetVerbose(Int_t iVerbose) { fVerbose = iVerbose; }
43 // Executed task
44 virtual void Exec(Option_t* option);
45 virtual InitStatus Init();
46 virtual void SetParContainers();
47 // Action after each event
48 virtual void Finish();
49
50 //Set format of saved files
51 void SetFormatFiles(int i_format_files) { iFormatFiles = i_format_files; }
52 //Set quantity of files
53 void SetMultiFiles(bool is_multi_files) { isMultiFiles = is_multi_files; }
54 //Set Number port
55 void SetPort(int NumberPort) { web_port = NumberPort; }
56
57 private:
58 // Default constructor
60 MpdWebScreenshots(const MpdWebScreenshots&) = delete;
61 MpdWebScreenshots& operator=(const MpdWebScreenshots&) = delete;
62
63 static int daemonize();
64 static int sendString(const char* message, int socket);
65 static void sendHeader(const char* Status_code, char* Content_Type, int TotalSize, int socket);
66 static void sendHTML(char* statusCode, char* contentType, char* content, int size, int socket);
67 static void sendFile(FILE* fp, int connecting_socket);
68 static int scan(char* input, char* output, size_t start, size_t max);
69 static int checkMime(char* extension, char* mime_type);
70 static int getHttpVersion(char* input, char* output);
71 static int GetExtension(char* input, char* output, size_t max);
72 static int handleHttpGET(char* input, TString output_dir, int connecting_socket);
73 static int getRequestType(char* input);
74 static int receive(int connecting_socket, TString output_dir);
75 static int acceptConnection(int currentSocket, TString output_dir);
76 static int start(int webPort, TString output_dir);
77 static int start_server(void* ptr);
78
79 MpdEventManager* fMan;
80
81 // 0 - PNG, 1 -JPG, 2 - both types
82 int iFormatFiles;
83 // 0 - one (the same) file event.png; 1 - multiple files event_nnn.png (event1.png and etc.)
84 bool isMultiFiles;
85
86 TString outputDir;
87 int web_port;
88 int daemon;
89
90 bool isWebStarted;
91 bool isWeb;
92
93 ClassDef(MpdWebScreenshots,1);
94};
95
96#endif
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:31
void SetPort(int NumberPort)
void SetVerbose(Int_t iVerbose)
virtual InitStatus Init()
void SetFormatFiles(int i_format_files)
void SetMultiFiles(bool is_multi_files)
virtual void Exec(Option_t *option)
virtual void SetParContainers()
void scan()