mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 05:17:59 +03:00
intermediate
This commit is contained in:
6
.ccls
6
.ccls
@@ -1,7 +1,9 @@
|
|||||||
clang++
|
clang++
|
||||||
-Iincludes
|
-Iincludes
|
||||||
%cpp
|
-Isrc/Header/
|
||||||
%hpp --include=./includes/webserv.hpp
|
-Isrc/Autoindex/
|
||||||
|
-Isrc/Server/
|
||||||
|
-Isrc/config/
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra
|
||||||
-Werror
|
-Werror
|
||||||
|
|||||||
167
Session.vim
Normal file
167
Session.vim
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
let SessionLoad = 1
|
||||||
|
let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1
|
||||||
|
let v:this_session=expand("<sfile>:p")
|
||||||
|
silent only
|
||||||
|
silent tabonly
|
||||||
|
cd ~/work/2_ecole/webserv
|
||||||
|
if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
|
||||||
|
let s:wipebuf = bufnr('%')
|
||||||
|
endif
|
||||||
|
set shortmess=aoO
|
||||||
|
argglobal
|
||||||
|
%argdel
|
||||||
|
tabnew
|
||||||
|
tabrewind
|
||||||
|
edit src/config/TOMLParser.cpp
|
||||||
|
let s:save_splitbelow = &splitbelow
|
||||||
|
let s:save_splitright = &splitright
|
||||||
|
set splitbelow splitright
|
||||||
|
wincmd _ | wincmd |
|
||||||
|
vsplit
|
||||||
|
1wincmd h
|
||||||
|
wincmd w
|
||||||
|
let &splitbelow = s:save_splitbelow
|
||||||
|
let &splitright = s:save_splitright
|
||||||
|
wincmd t
|
||||||
|
let s:save_winminheight = &winminheight
|
||||||
|
let s:save_winminwidth = &winminwidth
|
||||||
|
set winminheight=0
|
||||||
|
set winheight=1
|
||||||
|
set winminwidth=0
|
||||||
|
set winwidth=1
|
||||||
|
exe 'vert 1resize ' . ((&columns * 94 + 95) / 190)
|
||||||
|
exe 'vert 2resize ' . ((&columns * 95 + 95) / 190)
|
||||||
|
argglobal
|
||||||
|
balt includes/TOMLParser.hpp
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal nofen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 165 - ((11 * winheight(0) + 23) / 46)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 165
|
||||||
|
normal! 09|
|
||||||
|
wincmd w
|
||||||
|
argglobal
|
||||||
|
if bufexists("src/config/TOMLParser.cpp") | buffer src/config/TOMLParser.cpp | else | edit src/config/TOMLParser.cpp | endif
|
||||||
|
if &buftype ==# 'terminal'
|
||||||
|
silent file src/config/TOMLParser.cpp
|
||||||
|
endif
|
||||||
|
balt src/config/parse.cpp
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal nofen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 420 - ((38 * winheight(0) + 23) / 46)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 420
|
||||||
|
normal! 0
|
||||||
|
wincmd w
|
||||||
|
exe 'vert 1resize ' . ((&columns * 94 + 95) / 190)
|
||||||
|
exe 'vert 2resize ' . ((&columns * 95 + 95) / 190)
|
||||||
|
tabnext
|
||||||
|
edit includes/TOMLParser.hpp
|
||||||
|
let s:save_splitbelow = &splitbelow
|
||||||
|
let s:save_splitright = &splitright
|
||||||
|
set splitbelow splitright
|
||||||
|
wincmd _ | wincmd |
|
||||||
|
vsplit
|
||||||
|
1wincmd h
|
||||||
|
wincmd w
|
||||||
|
let &splitbelow = s:save_splitbelow
|
||||||
|
let &splitright = s:save_splitright
|
||||||
|
wincmd t
|
||||||
|
let s:save_winminheight = &winminheight
|
||||||
|
let s:save_winminwidth = &winminwidth
|
||||||
|
set winminheight=0
|
||||||
|
set winheight=1
|
||||||
|
set winminwidth=0
|
||||||
|
set winwidth=1
|
||||||
|
exe 'vert 1resize ' . ((&columns * 94 + 95) / 190)
|
||||||
|
exe 'vert 2resize ' . ((&columns * 95 + 95) / 190)
|
||||||
|
argglobal
|
||||||
|
balt includes/TOMLNode.hpp
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal nofen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 23 - ((20 * winheight(0) + 23) / 46)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 23
|
||||||
|
normal! 063|
|
||||||
|
wincmd w
|
||||||
|
argglobal
|
||||||
|
if bufexists("src/config/TOMLParser.cpp") | buffer src/config/TOMLParser.cpp | else | edit src/config/TOMLParser.cpp | endif
|
||||||
|
if &buftype ==# 'terminal'
|
||||||
|
silent file src/config/TOMLParser.cpp
|
||||||
|
endif
|
||||||
|
balt includes/TOMLParser.hpp
|
||||||
|
setlocal fdm=manual
|
||||||
|
setlocal fde=0
|
||||||
|
setlocal fmr={{{,}}}
|
||||||
|
setlocal fdi=#
|
||||||
|
setlocal fdl=0
|
||||||
|
setlocal fml=1
|
||||||
|
setlocal fdn=20
|
||||||
|
setlocal nofen
|
||||||
|
silent! normal! zE
|
||||||
|
let &fdl = &fdl
|
||||||
|
let s:l = 303 - ((8 * winheight(0) + 23) / 46)
|
||||||
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
|
keepjumps exe s:l
|
||||||
|
normal! zt
|
||||||
|
keepjumps 303
|
||||||
|
normal! 0
|
||||||
|
wincmd w
|
||||||
|
exe 'vert 1resize ' . ((&columns * 94 + 95) / 190)
|
||||||
|
exe 'vert 2resize ' . ((&columns * 95 + 95) / 190)
|
||||||
|
tabnext 1
|
||||||
|
badd +7 Makefile
|
||||||
|
badd +18 src/config/TOMLParser.hpp
|
||||||
|
badd +37 src/config/parse.cpp
|
||||||
|
badd +1 src/config/Tokenizer.hpp
|
||||||
|
badd +0 src/config/TOMLNode.hpp
|
||||||
|
badd +182 src/config/TOMLParser.cpp
|
||||||
|
badd +23 includes/TOMLParser.hpp
|
||||||
|
badd +37 includes/TOMLNode.hpp
|
||||||
|
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
|
||||||
|
silent exe 'bwipe ' . s:wipebuf
|
||||||
|
endif
|
||||||
|
unlet! s:wipebuf
|
||||||
|
set winheight=1 winwidth=20 shortmess=filnxtToOFc
|
||||||
|
let &winminheight = s:save_winminheight
|
||||||
|
let &winminwidth = s:save_winminwidth
|
||||||
|
let s:sx = expand("<sfile>:p:r")."x.vim"
|
||||||
|
if filereadable(s:sx)
|
||||||
|
exe "source " . fnameescape(s:sx)
|
||||||
|
endif
|
||||||
|
let &g:so = s:so_save | let &g:siso = s:siso_save
|
||||||
|
set hlsearch
|
||||||
|
nohlsearch
|
||||||
|
doautoall SessionLoadPost
|
||||||
|
unlet SessionLoad
|
||||||
|
" vim: set ft=vim :
|
||||||
@@ -75,33 +75,44 @@ void Server::newConnection(int fd)
|
|||||||
|
|
||||||
void Server::start(void)
|
void Server::start(void)
|
||||||
{
|
{
|
||||||
Socket serverSocket(AF_INET, SOCK_STREAM, 0, _port, "127.0.0.1");
|
/* Socket serverSocket(AF_INET, SOCK_STREAM, 0, _port, "127.0.0.1"); */
|
||||||
char buff[BUFFSIZE + 1] = {0};
|
/* char buff[BUFFSIZE + 1] = {0}; */
|
||||||
Header header;
|
/* Header header; */
|
||||||
int fd_accept;
|
/* int fd_accept; */
|
||||||
int code;
|
/* int code; */
|
||||||
|
|
||||||
|
/* checkError(serverSocket.init(MAX_CLIENT), "Socket init"); */
|
||||||
|
/* fd_accept = accept(serverSocket.getSocketFd(), */
|
||||||
|
/* serverSocket.getSockaddr(), serverSocket.getSocklen()); */
|
||||||
|
/* checkError(fd_accept, "Initialize client socket"); */
|
||||||
|
/* checkError(recv(fd_accept, buff, BUFFSIZE, 0), "Receive msg from client"); */
|
||||||
|
/* std::cout << TURGUOISE << "Receive Header" << ZERO_C << std::endl; */
|
||||||
|
/* header.setRawData(buff); */
|
||||||
|
/* code = header.parseRequest(); */
|
||||||
|
/* header.printHeaderInfo(); */
|
||||||
|
/* header.sendRespons(fd_accept); */
|
||||||
|
/* std::cout << BLUE << header.getReasonPhrase(code) << ZERO_C << std::endl; */
|
||||||
|
/* close(fd_accept); */
|
||||||
|
/* close(serverSocket.getSocketFd()); */
|
||||||
|
|
||||||
|
Socket server_sock(AF_INET, SOCK_STREAM, 0, _port, "127.0.0.1");
|
||||||
|
char buf[BUFFSIZE + 1] = {0};
|
||||||
|
Header header[MAX_CLIENT];
|
||||||
|
int fd;
|
||||||
|
int n;
|
||||||
|
int nfds;
|
||||||
|
int client_sock;
|
||||||
|
int epollfd;
|
||||||
|
|
||||||
|
#define THREAD_NUM 100
|
||||||
|
|
||||||
|
epollfd = epoll_create1(0);
|
||||||
|
struct epoll_event ev;
|
||||||
|
|
||||||
|
ev.events = EPOLLIN | EPOLLOUT | EPOLLET;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
checkError(serverSocket.init(MAX_CLIENT), "Socket init");
|
|
||||||
fd_accept = accept(serverSocket.getSocketFd(),
|
|
||||||
serverSocket.getSockaddr(), serverSocket.getSocklen());
|
|
||||||
checkError(fd_accept, "Initialize client socket");
|
|
||||||
checkError(recv(fd_accept, buff, BUFFSIZE, 0), "Receive msg from client");
|
|
||||||
std::cout << TURGUOISE << "Receive Header" << ZERO_C << std::endl;
|
|
||||||
header.setRawData(buff);
|
|
||||||
code = header.parseRequest();
|
|
||||||
header.printHeaderInfo();
|
|
||||||
header.sendRespons(fd_accept);
|
|
||||||
std::cout << BLUE << header.getReasonPhrase(code) << ZERO_C << std::endl;
|
|
||||||
close(fd_accept);
|
|
||||||
close(serverSocket.getSocketFd());
|
|
||||||
//-----------------------------------------------попытка добавить epoll------------------
|
|
||||||
// Socket serverSocket(AF_INET, SOCK_STREAM, 0, _port);
|
|
||||||
// char buff[BUFFSIZE + 1] = {0};
|
|
||||||
// Header header[MAX_CLIENT];
|
|
||||||
// int fd;
|
|
||||||
// int n;
|
|
||||||
// int nfds;
|
|
||||||
// int _clientSocket;
|
|
||||||
|
|
||||||
// nfds = 0;
|
// nfds = 0;
|
||||||
// n = 0;
|
// n = 0;
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ namespace config
|
|||||||
if (file.eof())
|
if (file.eof())
|
||||||
{
|
{
|
||||||
std::cout << "Tokens exhausted" << std::endl;
|
std::cout << "Tokens exhausted" << std::endl;
|
||||||
|
throw std::logic_error("Tokens exhausted");
|
||||||
}
|
}
|
||||||
prev_pos = file.tellg();
|
prev_pos = file.tellg();
|
||||||
c = getWithoutWhiteSpace();
|
c = getWithoutWhiteSpace();
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ int main(int argc, char **argv)
|
|||||||
Server server;
|
Server server;
|
||||||
|
|
||||||
server.readConfig();
|
server.readConfig();
|
||||||
// server.setupConfig();
|
server.setupConfig();
|
||||||
// server.start();
|
server.start();
|
||||||
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
Reference in New Issue
Block a user