// File: /workspace/github_cpp_makefile_star2_O3/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
xorl %eax, %eax
movl 0x8(%rbx), %edi
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 0x592e
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 0x2b8c(%rip), %rcx      # 0x8233
xorl %r8d, %r8d
callq 0x2360
cmpl $0x0, -0x2c(%rbp)
je 0x592e
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 0x2b42(%rip), %rcx      # 0x8233
xorl %r8d, %r8d
callq 0x2360
movl -0x2c(%rbp), %r14d
leaq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x98(%rbp), %rdi
leaq 0x2b43(%rip), %rsi      # 0x825c
leaq 0x2b45(%rip), %rdx      # 0x8265
callq 0x651a
leaq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
leaq -0x78(%rbp), %rdi
leaq 0x29ef(%rip), %rsi      # 0x8127
leaq 0x29f1(%rip), %rdx      # 0x8130
callq 0x651a
leaq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq %r13, %rdi
leaq 0x2a06(%rip), %rsi      # 0x8162
leaq 0x2a05(%rip), %rdx      # 0x8168
callq 0x651a
movq %r12, (%rsp)
movq -0x38(%rbp), %rsi
movl %r14d, %edx
leaq -0x98(%rbp), %rcx
leaq -0x78(%rbp), %r8
movq %r13, %r9
callq 0x5a34
movl %eax, %r14d
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x57ab
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x57c4
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x57e6
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2230
cmpl $0x1, %r14d
je 0x58d8
cmpl $0x2, %r14d
je 0x585b
cmpl $-0x1, %r14d
je 0x5921
leaq -0xc8(%rbp), %r14
movq %r14, -0xd8(%rbp)
movq %r15, %rdi
leaq 0x294a(%rip), %rsi      # 0x8162
leaq 0x2949(%rip), %rdx      # 0x8168
callq 0x651a
movl 0x8(%rbx), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq %r15, %rcx
leaq 0x981(%rip), %r8        # 0x61c0
xorl %r9d, %r9d
callq 0x5cc4
movq -0xd8(%rbp), %rdi
movq %r14, %rax
cmpq %r14, %rdi
jne 0x58cb
jmp 0x5915
movq %r13, %r15
movq %r12, %r13
leaq -0xe8(%rbp), %r14
movq %r14, -0xf8(%rbp)
leaq -0xf8(%rbp), %r12
movq %r12, %rdi
leaq 0x28a7(%rip), %rsi      # 0x8127
leaq 0x28a9(%rip), %rdx      # 0x8130
callq 0x651a
movq %rbx, %rdi
movl 0x8(%rbx), %eax
movl %eax, (%rsp)
movq -0x38(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
movq %r12, %rcx
leaq 0x7ab(%rip), %r8        # 0x6052
xorl %r9d, %r9d
callq 0x5cc4
movq -0xf8(%rbp), %rdi
movq %r14, %rax
cmpq %r14, %rdi
movq %r13, %r12
movq %r15, %r13
leaq -0xd8(%rbp), %r15
je 0x5915
movq (%rax), %rsi
incq %rsi
callq 0x2230
jmp 0x5915
movq -0x38(%rbp), %rdi
leaq 0x2979(%rip), %rsi      # 0x825c
leaq -0x2c(%rbp), %rdx
callq 0x6616
movq %rax, -0x38(%rbp)
cmpl $0x0, 0xc(%rbx)
jns 0x590d
movq 0x10(%rbx), %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x21b0
movl %eax, 0xc(%rbx)
testl %eax, %eax
js 0x5959
movq %rbx, %rdi
callq 0x4a74
cmpl $0x0, -0x2c(%rbp)
jne 0x56cb
jmp 0x592e
movq -0x50(%rbp), %rax
testq %rax, %rax
jne 0x564f
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x5947
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 0x5a0f
movq %rax, %rbx
movq -0xd8(%rbp), %rdi
cmpq %r14, %rdi
je 0x5a12
movq -0xc8(%rbp), %rsi
jmp 0x5a05
jmp 0x5a0f
movq %rax, %rbx
movq -0xf8(%rbp), %rdi
cmpq %r14, %rdi
je 0x5a12
movq -0xe8(%rbp), %rsi
jmp 0x5a05
jmp 0x5a0f
movq %rax, %rbx
jmp 0x59eb
movq %rax, %rbx
jmp 0x59d2
jmp 0x5a0f
movq %rax, %rbx
movq -0xb8(%rbp), %rdi
leaq -0xa8(%rbp), %rax
cmpq %rax, %rdi
je 0x59d2
movq -0xa8(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x59eb
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x98(%rbp), %rdi
leaq -0x88(%rbp), %rax
cmpq %rax, %rdi
je 0x5a12
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x2230
jmp 0x5a12
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x58(%rbp), %rdi
cmpq %rax, %rdi
je 0x5a2b
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x23c0
nop