// File: /workspace/github_cpp_makefile_star2_O1/billDrett[P]Bulletin-Boards/boardServer.cpp
// Function: BoardServer::readFromC2S()
bool BoardServer::readFromC2S() //diavasma apo pipe client 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(pipeClient2Server, 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 true;
            strncpy(buffer, tmpTag.c_str(), tmpTag.size());
            tmpTag = "";
            state = this->nextState(tmp, nread, "<Chanel>", "<Message>", "<Shutdown>", 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 true;
                break;
            }
            else if(state==createChanel)
            {
                f = &BoardServer::parseAddChanel;
                this->parseCommandPrototype(tmp, nread, "<Chanel>", f, pipeClient2Server);
            }
            else if(state == getMessages)
            {
                f = &BoardServer::parseSendMessage;
                this->parseCommandPrototype(tmp, nread, "<Message>", f, pipeClient2Server);
            }
            else //shutdown
            {
                tmp = getAfterTag(tmp, "<Shutdown>", nread); //dn mporei na einai null afou me thn prohpothesh oti yparxei vrethike edw
                this->shutDown();
                return false;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
movq %rdi, %rbx
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x4f0(%rbp), %r14
movl (%rbx), %edi
movq -0x48(%rbp), %rax
leaq (%rax,%rbp), %rsi
addq $-0x4f0, %rsi           # imm = 0xFB10
movl $0x400, %edx            # imm = 0x400
subq %rax, %rdx
callq 0x2300
movq %rax, %r15
movl %r15d, -0x2c(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %r13
movq %r14, %rdi
movq %r13, %rdx
callq 0x2160
addl %r13d, %r15d
movl %r15d, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movq %r13, %rdx
leaq 0x2f3d(%rip), %rcx      # 0x821f
xorl %r8d, %r8d
callq 0x2360
cmpl $0x0, -0x2c(%rbp)
leaq -0xa0(%rbp), %r13
je 0x54f3
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %r15
movq %r14, %rdi
movq %r15, %rdx
callq 0x2160
leaq -0x50(%rbp), %rdi
xorl %esi, %esi
movq %r15, %rdx
leaq 0x2f01(%rip), %rcx      # 0x821f
xorl %r8d, %r8d
callq 0x2360
movl -0x2c(%rbp), %r15d
movq %r13, -0xb0(%rbp)
leaq -0xb0(%rbp), %rdi
leaq 0x2d97(%rip), %rsi      # 0x80d6
leaq 0x2d98(%rip), %rdx      # 0x80de
callq 0x64f8
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
leaq 0x2db5(%rip), %rsi      # 0x8113
leaq 0x2db7(%rip), %rdx      # 0x811c
callq 0x64f8
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %r12
movq %r12, %rdi
leaq 0x2e0a(%rip), %rsi      # 0x8190
leaq 0x2e0d(%rip), %rdx      # 0x819a
callq 0x64f8
leaq -0x50(%rbp), %rax
movq %rax, (%rsp)
movq %r14, %rsi
movl %r15d, %edx
leaq -0xb0(%rbp), %rcx
leaq -0x70(%rbp), %r8
movq %r12, %r9
callq 0x5a2c
movl %eax, %r15d
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x53d2
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x53eb
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0xb0(%rbp), %rdi
cmpq %r13, %rdi
je 0x5406
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2230
cmpl $0x1, %r15d
je 0x546b
cmpl $0x2, %r15d
jne 0x54dd
leaq -0xc0(%rbp), %r15
movq %r15, -0xd0(%rbp)
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
leaq 0x2cde(%rip), %rsi      # 0x8113
leaq 0x2ce0(%rip), %rdx      # 0x811c
callq 0x64f8
movl (%rbx), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x2c(%rbp), %rdx
movq %r12, %rcx
leaq 0xb10(%rip), %r8        # 0x5f6a
xorl %r9d, %r9d
callq 0x5cb8
movq -0xd0(%rbp), %rdi
jmp 0x54be
leaq -0xe0(%rbp), %r15
movq %r15, -0xf0(%rbp)
leaq -0xf0(%rbp), %r12
movq %r12, %rdi
leaq 0x2c4c(%rip), %rsi      # 0x80d6
leaq 0x2c4d(%rip), %rdx      # 0x80de
callq 0x64f8
movl (%rbx), %eax
movl %eax, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x2c(%rbp), %rdx
movq %r12, %rcx
leaq 0x653(%rip), %r8        # 0x5b02
xorl %r9d, %r9d
callq 0x5cb8
movq -0xf0(%rbp), %rdi
movq %r15, %rax
cmpq %r15, %rdi
je 0x54d1
movq (%rax), %rsi
incq %rsi
callq 0x2230
cmpl $0x0, -0x2c(%rbp)
jne 0x52fb
jmp 0x54f3
cmpl $-0x1, %r15d
jne 0x54f8
cmpq $0x0, -0x48(%rbp)
movb $0x1, %r15b
jne 0x5293
jmp 0x551a
movb $0x1, %r15b
jmp 0x551a
leaq 0x2c91(%rip), %rsi      # 0x8190
leaq -0x4f0(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x65ee
movq %rbx, %rdi
callq 0x4912
xorl %r15d, %r15d
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x5533
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2230
movl %r15d, %eax
addq $0x4d8, %rsp            # imm = 0x4D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x55c5
jmp 0x55c5
jmp 0x55c5
jmp 0x55c5
movq %rax, %rbx
movq -0xd0(%rbp), %rdi
cmpq %r15, %rdi
je 0x55ef
movq -0xc0(%rbp), %rsi
jmp 0x55e7
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
cmpq %r15, %rdi
je 0x55ef
movq -0xe0(%rbp), %rsi
jmp 0x55e7
movq %rax, %rbx
jmp 0x55aa
jmp 0x55c5
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x55aa
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2230
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x55cd
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2230
jmp 0x55cd
movq %rax, %rbx
jmp 0x55ef
movq %rax, %rbx
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x55ef
movq -0xa0(%rbp), %rsi
incq %rsi
callq 0x2230
leaq -0x40(%rbp), %rax
movq -0x50(%rbp), %rdi
cmpq %rax, %rdi
je 0x5608
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2230
movq %rbx, %rdi
callq 0x23c0