// File: /workspace/github_cpp_makefile_star2_O2/llefranc[P]42_webserv/srcs/parser/FileParser.cpp
// Function: FileParser::newLocation(ServerInfo&)
void FileParser::newLocation(ServerInfo &srv)
{
	Location n_loc(srv.getPort());
	std::string uri;
	int brack = 0;

	bracketRegulator(brack, _buf);

	// Processing of the first line of location
	if (!_buf.compare(0, 9, "location ")){
		
		// **check validity of the line**	
		if (numberOfWords(_buf.c_str()) != 3)
			throw std::runtime_error(errParseMessage("error line : ", _buf.c_str(), "\n"));
		
		// **get the locaton name without whitespaces**
		(!_buf.compare(_buf.size() - 1, 1, "{")) ? _buf.erase(_buf.size() - 1, 1) : 0;
		uri = *wsTrim(_buf);
		uri.replace(0, 8, "");
	}
	
	// Processing of the location block
	while (brack > 0)
	{
		std::getline(_file, _buf);
		cleanLineFromSpaces(_buf);
		bracketRegulator(brack, _buf);

		if (!_buf.compare(0, 13, "allow_method "))
			n_loc.setLocation(METHO, 13, _buf);
		else if (!_buf.compare(0, 6, "index "))
			n_loc.setLocation(IDX, 6, _buf);
		else if (!_buf.compare(0, 12, "upload_path "))
			n_loc.setLocation(STORE, 12, _buf);
		else if (!_buf.compare(0, 5, "root "))
			n_loc.setLocation(ROOT, 5, _buf);
		else if (!_buf.compare(0, 4, "cgi "))
			n_loc.setLocation(CGI_EXE, 4, _buf);
		else if (!_buf.compare(0, 10, "autoindex "))
			n_loc.setLocation(AUTOIDX, 10, _buf);
		else if (!_buf.compare(0, 9, "redirect "))
			n_loc.setLocation(REDIRECT, 9, _buf);
		else if (!_buf.compare(0, 1, "}")) continue;
		else throw std::runtime_error(errParseMessage("error line : ", _buf.c_str(), ". Wrong input in block location\n"));
	}
	_bracket--;
	addNewLocationToMap(&n_loc, uri);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x110, %rsp            # imm = 0x110
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x59a8
movl (%rax), %esi
leaq -0x120(%rbp), %rdi
callq 0x80b0
leaq -0x28(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x18(%rbp), %rdi
andl $0x0, (%rdi)
leaq 0x208(%rbx), %r14
movq %r14, %rsi
callq 0x92bc
leaq 0xa42b(%rip), %rcx      # 0x111f1
pushq $0x9
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
jne 0x6e71
movq (%r14), %rdi
callq 0x93dc
cmpq $0x3, %rax
jne 0x70cd
movq 0x210(%rbx), %rsi
decq %rsi
leaq 0xa312(%rip), %rcx      # 0x11110
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x4550
testl %eax, %eax
je 0x6e1e
leaq -0x58(%rbp), %rdi
leaq -0x14(%rbp), %rdx
xorl %esi, %esi
callq 0x4ec8
jmp 0x6e3f
movq 0x210(%rbx), %rsi
decq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
callq 0x40f0
leaq -0x58(%rbp), %rdi
movq %rax, %rsi
callq 0x4580
leaq -0x58(%rbp), %rdi
callq 0x47d8
movq %r14, %rdi
callq 0x947b
leaq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x4270
leaq 0xa897(%rip), %rcx      # 0x116fa
leaq -0x38(%rbp), %rdi
pushq $0x8
popq %rdx
xorl %esi, %esi
callq 0x42b0
cmpl $0x0, -0x18(%rbp)
jle 0x7065
movq %rbx, %rdi
movq %r14, %rsi
callq 0x40b0
movq %r14, %rdi
callq 0x924c
leaq -0x18(%rbp), %rdi
movq %r14, %rsi
callq 0x92bc
leaq 0xa2a4(%rip), %rcx      # 0x11145
pushq $0xd
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
je 0x6f7f
leaq 0xa2b2(%rip), %rcx      # 0x1116f
pushq $0x6
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
je 0x6f9f
leaq 0xa27a(%rip), %rcx      # 0x11153
pushq $0xc
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
je 0x6fc0
leaq 0xa26b(%rip), %rcx      # 0x11160
pushq $0x5
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
je 0x6fe1
leaq 0xa255(%rip), %rcx      # 0x11166
pushq $0x4
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
je 0x7002
leaq 0xa23e(%rip), %rcx      # 0x1116b
pushq $0xa
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
je 0x7023
leaq 0xa22d(%rip), %rcx      # 0x11176
pushq $0x9
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
je 0x7044
leaq 0xa1ad(%rip), %rcx      # 0x11112
pushq $0x1
popq %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4550
testl %eax, %eax
je 0x6e71
jmp 0x709f
leaq -0x14(%rbp), %rdx
movl $0xd, (%rdx)
leaq -0x120(%rbp), %rdi
xorl %esi, %esi
movq %r14, %rcx
callq 0x840a
jmp 0x6e71
leaq -0x14(%rbp), %rdx
movl $0x6, (%rdx)
leaq -0x120(%rbp), %rdi
pushq $0x1
popq %rsi
movq %r14, %rcx
callq 0x840a
jmp 0x6e71
leaq -0x14(%rbp), %rdx
movl $0xc, (%rdx)
leaq -0x120(%rbp), %rdi
pushq $0x2
popq %rsi
movq %r14, %rcx
callq 0x840a
jmp 0x6e71
leaq -0x14(%rbp), %rdx
movl $0x5, (%rdx)
leaq -0x120(%rbp), %rdi
pushq $0x3
popq %rsi
movq %r14, %rcx
callq 0x840a
jmp 0x6e71
leaq -0x14(%rbp), %rdx
movl $0x4, (%rdx)
leaq -0x120(%rbp), %rdi
pushq $0x4
popq %rsi
movq %r14, %rcx
callq 0x840a
jmp 0x6e71
leaq -0x14(%rbp), %rdx
movl $0xa, (%rdx)
leaq -0x120(%rbp), %rdi
pushq $0x5
popq %rsi
movq %r14, %rcx
callq 0x840a
jmp 0x6e71
leaq -0x14(%rbp), %rdx
movl $0x9, (%rdx)
leaq -0x120(%rbp), %rdi
pushq $0x6
popq %rsi
movq %r14, %rcx
callq 0x840a
jmp 0x6e71
decl 0x228(%rbx)
leaq -0x120(%rbp), %rsi
leaq -0x38(%rbp), %rdx
movq %rbx, %rdi
callq 0x7150
leaq -0x38(%rbp), %rdi
callq 0x47d8
leaq -0x120(%rbp), %rdi
callq 0x8364
addq $0x110, %rsp            # imm = 0x110
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x4220
movq %rax, %rbx
movq (%r14), %rsi
leaq 0xa060(%rip), %rdi      # 0x11114
leaq 0xa0c5(%rip), %rdx      # 0x11180
callq 0x9320
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4650
jmp 0x70f9
pushq $0x10
popq %rdi
callq 0x4220
movq %rax, %rbx
movq (%r14), %rsi
leaq 0xa032(%rip), %rdi      # 0x11114
leaq 0xa2ba(%rip), %rdx      # 0x113a3
callq 0x9320
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4650
movq 0x11ef0(%rip), %rsi     # 0x18ff0
movq 0x11ec1(%rip), %rdx     # 0x18fc8
movq %rbx, %rdi
callq 0x46b0
jmp 0x7130
jmp 0x7115
jmp 0x7130
movq %rax, %r14
movq %rbx, %rdi
callq 0x4330
jmp 0x7133
jmp 0x7130
jmp 0x7130
jmp 0x7130
jmp 0x7130
jmp 0x7130
jmp 0x7130
jmp 0x7130
movq %rax, %r14
leaq -0x38(%rbp), %rdi
callq 0x47d8
leaq -0x120(%rbp), %rdi
callq 0x8364
movq %r14, %rdi
callq 0x46d0