-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCGI.hpp
58 lines (40 loc) · 1.13 KB
/
CGI.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <iostream>
#include <string>
// #include "Request.hpp"
#include "Response.hpp"
#include <vector>
#include <cstring>
#include "HelperFuncs.hpp"
#include <memory>
#include <sys/wait.h>
#define FORK_ERROR -1
#define PIPE_ERROR -1
#define READ 0
#define WRITE 1
#define CHILD 0
class Request;
class CGI {
public:
CGI(std::shared_ptr<Request> client_request);
~CGI();
int ExecuteScript(std::string path);
int read_fd = -1;
int write_fd = -1;
pid_t pid = -1;
private:
void GetMethodParse();
void PostMethodParse();
void DeleteMethodParse();
void ParseEnviromentArray();
void ParseHeader(const std::string &header, const std::string &enviroment_name);
void GiveScriptDataSTDIN();
char **AllocateArgumentVector();
char **AllocateEnviroment();
void DeletePointerArray(char **arr, size_t index);
char **m_envp;
char **m_argv;
std::vector<std::string> m_enviroment_var;
std::string m_path;
std::shared_ptr<Request> m_client_request;
};