// File: /workspace/github_cpp_makefile_star2_O1/billDrett[P]Bulletin-Boards/boardServer.cpp
// Function: BoardServer::readFromBp2S()
void BoardServer::readFromBp2S() //diavasma apo pipe boardPost to server
{
    char buffer[BUFFERSIZE];
    char* tmp;
    int nread;
    string tmpTag;
    int state;
    void (BoardServer::*f)(char* buffer, int nread, int state, string& previousRead);

    while((nread = read(pipeBoardPost2Server, buffer + tmpTag.size(), BUFFERSIZE - tmpTag.size())) > 0) //an exw lavei meros ena tag entolis tote ksanadiavazw gia na parw to ypoleipo
    {
        strncpy(buffer, tmpTag.c_str(), tmpTag.size());
        nread += tmpTag.size();
        tmp = buffer;
        tmpTag = "";
        while(1) //se ena read mporei na exw panw apo mia entoli gia auto mpainei se loop while 1 pou termatizetai otan dn yparxoun alloi xaraktires gia epeksergasia 'h parw meros tag
        {
            if(nread == 0)return;

            strncpy(buffer, tmpTag.c_str(), tmpTag.size());
            tmpTag = "";
            state = this->nextState(tmp, nread, "<Chanels>", "<Message>", "<File>", tmpTag) -1; //ta states ksekinan apo 0 oxi apo 1

            if(state == -2) //exei kopei entoli sthn mesh ara na ksanadiavasw
            {
                if(tmpTag.size() == 0) return;
                break;
            }
            else if(state==chanelist)
            {
                tmp = getAfterTag(tmp, "<Chanels>", nread);
                if(pipeServer2BoardPost < 0) //an dn to exw anoiskei hdh to anoigw
                {
                    if((pipeServer2BoardPost = open(Server2BoardPost.c_str(), O_WRONLY)) < 0)
                    {
                        perror("fifo S2BP not found");
                        exit(1);
                    }
                }
                this->sendChanelsList();

            }
            else if(state == message)
            {
                f = &BoardServer::parseGetMessage;
                this->parseCommandPrototype(tmp, nread, "<Message>", f, pipeBoardPost2Server);
            }
            else //file
            {
                f = &BoardServer::parseGetFiles;
                this->parseCommandPrototype(tmp, nread, "<File>", f, pipeBoardPost2Server);
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4e8, %rsp            # imm = 0x4E8
movq %rdi, %rbx
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x58(%rbp), %r12
leaq -0xb8(%rbp), %r13
movl 0x8(%rbx), %edi
movq -0x50(%rbp), %rax
leaq (%rax,%rbp), %rsi
addq $-0x500, %rsi           # imm = 0xFB00
movl $0x400, %edx            # imm = 0x400
subq %rax, %rdx
callq 0x2300
movq %rax, %r14
movl %r14d, -0x2c(%rbp)
testl %r14d, %r14d
jle 0x5926
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %r15
leaq -0x500(%rbp), %rdi
movq %r15, %rdx
callq 0x2160
addl %r15d, %r14d
movl %r14d, -0x2c(%rbp)
movq %r12, %rdi
xorl %esi, %esi
movq %r15, %rdx
leaq 0x2b7e(%rip), %rcx      # 0x821f
xorl %r8d, %r8d
callq 0x2360
cmpl $0x0, -0x2c(%rbp)
je 0x5926
leaq -0x500(%rbp), %r15
movq %r15, -0x38(%rbp)
leaq -0xd8(%rbp), %r15
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %r14
leaq -0x500(%rbp), %rdi
movq %r14, %rdx
callq 0x2160
movq %r12, %rdi
xorl %esi, %esi
movq %r14, %rdx
leaq 0x2b34(%rip), %rcx      # 0x821f
xorl %r8d, %r8d
callq 0x2360
movl -0x2c(%rbp), %r14d
leaq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rdi
leaq 0x2b35(%rip), %rsi      # 0x8248
leaq 0x2b37(%rip), %rdx      # 0x8251
callq 0x64f8
leaq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
leaq 0x29e1(%rip), %rsi      # 0x8113
leaq 0x29e3(%rip), %rdx      # 0x811c
callq 0x64f8
leaq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq %r13, %rdi
leaq 0x29f8(%rip), %rsi      # 0x814e
leaq 0x29f7(%rip), %rdx      # 0x8154
callq 0x64f8
movq %r12, (%rsp)
movq -0x38(%rbp), %rsi
movl %r14d, %edx
leaq -0x98(%rbp), %rcx
leaq -0x78(%rbp), %r8
movq %r13, %r9
callq 0x5a2c
movl %eax, %r14d
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x57a5
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x57be
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x57e0
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2230
cmpl $0x1, %r14d
je 0x58d2
cmpl $0x2, %r14d
je 0x5855
cmpl $-0x1, %r14d
je 0x591b
leaq -0xc8(%rbp), %r14
movq %r14, -0xd8(%rbp)
movq %r15, %rdi
leaq 0x293c(%rip), %rsi      # 0x814e
leaq 0x293b(%rip), %rdx      # 0x8154
callq 0x64f8
movl 0x8(%rbx), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq %r15, %rcx
leaq 0x971(%rip), %r8        # 0x61aa
xorl %r9d, %r9d
callq 0x5cb8
movq -0xd8(%rbp), %rdi
movq %r14, %rax
cmpq %r14, %rdi
jne 0x58c5
jmp 0x590f
movq %r13, %r15
movq %r12, %r13
leaq -0xe8(%rbp), %r14
movq %r14, -0xf8(%rbp)
leaq -0xf8(%rbp), %r12
movq %r12, %rdi
leaq 0x2899(%rip), %rsi      # 0x8113
leaq 0x289b(%rip), %rdx      # 0x811c
callq 0x64f8
movq %rbx, %rdi
movl 0x8(%rbx), %eax
movl %eax, (%rsp)
movq -0x38(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq %r12, %rcx
leaq 0x79b(%rip), %r8        # 0x603c
xorl %r9d, %r9d
callq 0x5cb8
movq -0xf8(%rbp), %rdi
movq %r14, %rax
cmpq %r14, %rdi
movq %r13, %r12
movq %r15, %r13
leaq -0xd8(%rbp), %r15
je 0x590f
movq (%rax), %rsi
incq %rsi
callq 0x2230
jmp 0x590f
movq -0x38(%rbp), %rdi
leaq 0x296b(%rip), %rsi      # 0x8248
leaq -0x2c(%rbp), %rdx
callq 0x65ee
movq %rax, -0x38(%rbp)
cmpl $0x0, 0xc(%rbx)
jns 0x5907
movq 0x10(%rbx), %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x21b0
movl %eax, 0xc(%rbx)
testl %eax, %eax
js 0x5951
movq %rbx, %rdi
callq 0x4a6c
cmpl $0x0, -0x2c(%rbp)
jne 0x56c5
jmp 0x5926
cmpq $0x0, -0x50(%rbp)
jne 0x5645
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x593f
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2230
addq $0x4e8, %rsp            # imm = 0x4E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2490
jmp 0x5a07
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0x5a0a
movq -0xc8(%rbp), %rsi
jmp 0x59fd
jmp 0x5a07
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0x5a0a
movq -0xe8(%rbp), %rsi
jmp 0x59fd
jmp 0x5a07
movq %rax, %rbx
jmp 0x59e3
movq %rax, %rbx
jmp 0x59ca
jmp 0x5a07
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x59ca
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x59e3
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x5a0a
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2230
jmp 0x5a0a
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x58(%rbp), %rdi
cmpq %rax, %rdi
je 0x5a23
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x23c0
nop