// File: 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
subq $0x610, %rsp            # imm = 0x610
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x558(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x33e0
movq -0x558(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x56c(%rbp)
leaq -0x440(%rbp), %rdi
movq %rdi, -0x578(%rbp)
callq 0x3210
movq -0x578(%rbp), %rdi
leaq -0x410(%rbp,%rax), %rax
movq %rax, -0x568(%rbp)
callq 0x3210
movl -0x56c(%rbp), %edi
movq -0x568(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
subq %rax, %rdx
callq 0x3400
movq %rax, -0x560(%rbp)
jmp 0x72f7
movq -0x560(%rbp), %rax
movl %eax, -0x41c(%rbp)
cmpl $0x0, %eax
jle 0x7906
leaq -0x440(%rbp), %rdi
movq %rdi, -0x588(%rbp)
callq 0x3130
movq -0x588(%rbp), %rdi
movq %rax, -0x590(%rbp)
callq 0x3210
movq -0x590(%rbp), %rsi
movq %rax, %rdx
leaq -0x410(%rbp), %rdi
movq %rdi, -0x580(%rbp)
callq 0x31c0
movq -0x588(%rbp), %rdi
callq 0x3210
movq -0x588(%rbp), %rdi
movq %rax, %rdx
movq -0x580(%rbp), %rax
movl -0x41c(%rbp), %ecx
addl %edx, %ecx
movl %ecx, -0x41c(%rbp)
movq %rax, -0x418(%rbp)
leaq 0x3e6c(%rip), %rsi      # 0xb1f5
callq 0x33d0
jmp 0x7390
jmp 0x7392
jmp 0x7394
cmpl $0x0, -0x41c(%rbp)
jne 0x73c3
movl $0x1, -0x468(%rbp)
jmp 0x7910
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x7925
leaq -0x440(%rbp), %rdi
movq %rdi, -0x598(%rbp)
callq 0x3130
movq -0x598(%rbp), %rdi
movq %rax, -0x5a0(%rbp)
callq 0x3210
movq -0x5a0(%rbp), %rsi
movq %rax, %rdx
leaq -0x410(%rbp), %rdi
callq 0x31c0
movq -0x598(%rbp), %rdi
leaq 0x3de8(%rip), %rsi      # 0xb1f5
callq 0x33d0
jmp 0x7414
movq -0x418(%rbp), %rax
movq %rax, -0x5b8(%rbp)
movl -0x41c(%rbp), %eax
movl %eax, -0x5ac(%rbp)
leaq -0x489(%rbp), %rdi
movq %rdi, -0x5a8(%rbp)
callq 0x34c0
movq -0x5a8(%rbp), %rdx
leaq 0x3dcf(%rip), %rsi      # 0xb21e
leaq -0x488(%rbp), %rdi
callq 0x88a0
jmp 0x745d
leaq -0x4b1(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0x34c0
movq -0x5c0(%rbp), %rdx
leaq 0x3c6b(%rip), %rsi      # 0xb0e9
leaq -0x4b0(%rbp), %rdi
callq 0x88a0
jmp 0x748c
leaq -0x4d9(%rbp), %rdi
movq %rdi, -0x5c8(%rbp)
callq 0x34c0
movq -0x5c8(%rbp), %rdx
leaq 0x3c77(%rip), %rsi      # 0xb124
leaq -0x4d8(%rbp), %rdi
callq 0x88a0
jmp 0x74bb
movl -0x5ac(%rbp), %edx
movq -0x5b8(%rbp), %rsi
movq -0x558(%rbp), %rdi
movq %rsp, %rax
leaq -0x440(%rbp), %rcx
movq %rcx, (%rax)
leaq -0x488(%rbp), %rcx
leaq -0x4b0(%rbp), %r8
leaq -0x4d8(%rbp), %r9
callq 0x7940
movl %eax, -0x5cc(%rbp)
jmp 0x74fe
movl -0x5cc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x444(%rbp)
leaq -0x4d8(%rbp), %rdi
callq 0x31f0
leaq -0x4d9(%rbp), %rdi
callq 0x3320
leaq -0x4b0(%rbp), %rdi
callq 0x31f0
leaq -0x4b1(%rbp), %rdi
callq 0x3320
leaq -0x488(%rbp), %rdi
callq 0x31f0
leaq -0x489(%rbp), %rdi
callq 0x3320
cmpl $-0x2, -0x444(%rbp)
jne 0x7627
leaq -0x440(%rbp), %rdi
callq 0x3210
cmpq $0x0, %rax
jne 0x7622
movl $0x1, -0x468(%rbp)
jmp 0x7910
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x7611
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x75f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x75e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
leaq -0x4d8(%rbp), %rdi
callq 0x31f0
leaq -0x4d9(%rbp), %rdi
callq 0x3320
leaq -0x4b0(%rbp), %rdi
callq 0x31f0
leaq -0x4b1(%rbp), %rdi
callq 0x3320
leaq -0x488(%rbp), %rdi
callq 0x31f0
leaq -0x489(%rbp), %rdi
callq 0x3320
jmp 0x7925
jmp 0x7901
cmpl $0x0, -0x444(%rbp)
jne 0x76db
movq -0x418(%rbp), %rdi
leaq 0x3bdc(%rip), %rsi      # 0xb21e
leaq -0x41c(%rbp), %rdx
callq 0x8de0
movq %rax, -0x5d8(%rbp)
jmp 0x7657
movq -0x558(%rbp), %rax
movq -0x5d8(%rbp), %rcx
movq %rcx, -0x418(%rbp)
cmpl $0x0, 0xc(%rax)
jge 0x76c8
movq -0x558(%rbp), %rdi
addq $0x10, %rdi
callq 0x3130
movq %rax, %rdi
xorl %eax, %eax
movl $0x1, %esi
callq 0x3230
movl %eax, -0x5dc(%rbp)
jmp 0x7699
movl -0x5dc(%rbp), %eax
movq -0x558(%rbp), %rcx
movl %eax, 0xc(%rcx)
cmpl $0x0, %eax
jge 0x76c6
leaq 0x3b73(%rip), %rdi      # 0xb228
callq 0x3260
jmp 0x76bc
movl $0x1, %edi
callq 0x3370
jmp 0x76c8
movq -0x558(%rbp), %rdi
callq 0x5f90
jmp 0x76d6
jmp 0x78fa
cmpl $0x1, -0x444(%rbp)
jne 0x77f3
leaq 0xc31(%rip), %rax       # 0x8320
movq %rax, -0x458(%rbp)
movq $0x0, -0x450(%rbp)
movq -0x418(%rbp), %rax
movq %rax, -0x5f0(%rbp)
leaq -0x501(%rbp), %rdi
movq %rdi, -0x5e8(%rbp)
callq 0x34c0
movq -0x5e8(%rbp), %rdx
leaq 0x39b9(%rip), %rsi      # 0xb0e9
leaq -0x500(%rbp), %rdi
callq 0x88a0
jmp 0x773e
movq -0x5f0(%rbp), %rsi
movq -0x558(%rbp), %rdi
movq -0x458(%rbp), %rax
movq -0x450(%rbp), %rdx
movl 0x8(%rdi), %ecx
movq %rdx, -0x510(%rbp)
movq %rax, -0x518(%rbp)
movq -0x518(%rbp), %r8
movq -0x510(%rbp), %r9
movq %rsp, %rax
movl %ecx, (%rax)
leaq -0x41c(%rbp), %rdx
leaq -0x500(%rbp), %rcx
callq 0x7cd0
jmp 0x7793
leaq -0x500(%rbp), %rdi
callq 0x31f0
leaq -0x501(%rbp), %rdi
callq 0x3320
jmp 0x78f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x77e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
leaq -0x500(%rbp), %rdi
callq 0x31f0
leaq -0x501(%rbp), %rdi
callq 0x3320
jmp 0x7925
leaq 0xcc6(%rip), %rax       # 0x84c0
movq %rax, -0x458(%rbp)
movq $0x0, -0x450(%rbp)
movq -0x418(%rbp), %rax
movq %rax, -0x600(%rbp)
leaq -0x539(%rbp), %rdi
movq %rdi, -0x5f8(%rbp)
callq 0x34c0
movq -0x5f8(%rbp), %rdx
leaq 0x38e9(%rip), %rsi      # 0xb124
leaq -0x538(%rbp), %rdi
callq 0x88a0
jmp 0x7849
movq -0x600(%rbp), %rsi
movq -0x558(%rbp), %rdi
movq -0x458(%rbp), %rax
movq -0x450(%rbp), %rdx
movl 0x8(%rdi), %ecx
movq %rdx, -0x548(%rbp)
movq %rax, -0x550(%rbp)
movq -0x550(%rbp), %r8
movq -0x548(%rbp), %r9
movq %rsp, %rax
movl %ecx, (%rax)
leaq -0x41c(%rbp), %rdx
leaq -0x538(%rbp), %rcx
callq 0x7cd0
jmp 0x789e
leaq -0x538(%rbp), %rdi
callq 0x31f0
leaq -0x539(%rbp), %rdi
callq 0x3320
jmp 0x78f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x78ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
leaq -0x538(%rbp), %rdi
callq 0x31f0
leaq -0x539(%rbp), %rdi
callq 0x3320
jmp 0x7925
jmp 0x78fa
jmp 0x78fc
jmp 0x7392
jmp 0x7296
movl $0x0, -0x468(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x31f0
addq $0x610, %rsp            # imm = 0x610
popq %rbp
retq
leaq -0x440(%rbp), %rdi
callq 0x31f0
movq -0x460(%rbp), %rdi
callq 0x34b0
nopl (%rax)