+ modif html page for script tests + script output not added to response in case of http error
66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
|
|
#ifndef CGI_UTILS_HPP
|
|
# define CGI_UTILS_HPP
|
|
|
|
# include <iostream>
|
|
# include <string>
|
|
# include <sstream>
|
|
# include <vector>
|
|
# include <stdlib.h> // getenv
|
|
# include <algorithm> // transform
|
|
|
|
# define CR "\r"
|
|
# define LF "\n"
|
|
# define CRLF CR LF
|
|
# define CRLF_SIZE 2
|
|
# define NPOS std::string::npos
|
|
|
|
# define HTML_BODY_TOP "<!DOCTYPE html>"\
|
|
"<html>"\
|
|
" <head>"\
|
|
" <meta charset=\"UTF-8\">"\
|
|
" <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">"\
|
|
" <title>CGI</title>"\
|
|
" <link href=\"./cgi_style.css\" type=\"text/css\" rel=\"stylesheet\">"\
|
|
" </head>"\
|
|
" <body>"\
|
|
" <h1>cgi</h1><br>"
|
|
# define HTML_BODY_BOTTOM " </body>"\
|
|
"</html>"
|
|
|
|
std::string
|
|
str_tolower(std::string str);
|
|
|
|
std::string
|
|
trim(std::string str, char del);
|
|
|
|
std::vector<std::string>
|
|
split(const std::string & input, std::string delim, char ctrim = '\0');
|
|
|
|
std::string
|
|
itos(int n);
|
|
|
|
std::string
|
|
parse_env(const std::string & env);
|
|
|
|
std::string
|
|
parse_body();
|
|
|
|
std::string
|
|
print_env(char **env, std::string tag = "p");
|
|
|
|
std::string
|
|
get_form_infos();
|
|
|
|
std::string
|
|
get_value(std::string key);
|
|
|
|
std::string
|
|
print_form(std::string form, std::string key = "p", std::string val = "p");
|
|
|
|
void
|
|
fill_response_basic(char **env, std::string & body, std::string & header);
|
|
|
|
#endif
|
|
|