// File: /workspace/github_cpp_makefile_star2_O2/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 $0x4e8, %rsp            # imm = 0x4E8
leaq -0x50(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %eax, %eax
leaq -0x100(%rbp), %r13
leaq -0x80(%rbp), %rbx
movq %rdi, -0x40(%rbp)
movl (%rdi), %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, -0x30(%rbp)
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %r15
leaq -0x500(%rbp), %rdi
movq %r15, %rdx
callq 0x2180
addl %r14d, %r15d
movl %r15d, -0x30(%rbp)
leaq -0x60(%rbp), %rdi
leaq 0x2d16(%rip), %rsi      # 0x721b
callq 0x23d0
movb $0x1, %r14b
cmpl $0x0, -0x30(%rbp)
je 0x46b7
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
leaq -0x500(%rbp), %rdi
callq 0x2180
leaq -0x60(%rbp), %rdi
leaq 0x2ce5(%rip), %rsi      # 0x721b
callq 0x23d0
movl -0x30(%rbp), %r15d
leaq -0xa0(%rbp), %rdi
leaq 0x2b85(%rip), %rsi      # 0x70d2
leaq -0x29(%rbp), %rdx
callq 0x529a
movq %r13, %rdi
leaq 0x2baf(%rip), %rsi      # 0x710f
leaq -0x32(%rbp), %rdx
callq 0x529a
movq %r13, %r14
movq %rbx, %rdi
leaq 0x2c16(%rip), %rsi      # 0x718c
leaq -0x31(%rbp), %rdx
callq 0x529a
leaq -0x60(%rbp), %rax
movq %rax, (%rsp)
leaq -0x500(%rbp), %rsi
movl %r15d, %edx
leaq -0xa0(%rbp), %r13
movq %r13, %rcx
movq %r14, %r12
movq %r14, %r8
movq %rbx, %r9
callq 0x4a22
movl %eax, %r15d
movq %rbx, %rdi
callq 0x2130
movq %r12, %rdi
callq 0x2130
movq %r13, %rdi
callq 0x2130
cmpl $0x1, %r15d
je 0x461d
cmpl $0x2, %r15d
jne 0x4671
leaq -0xc0(%rbp), %r15
movq %r15, %rdi
leaq 0x2b2a(%rip), %rsi      # 0x710f
leaq -0x29(%rbp), %rdx
callq 0x529a
leaq -0x80(%rbp), %rbx
movq %r14, %r13
movq -0x40(%rbp), %rdi
movl (%rdi), %eax
movl %eax, (%rsp)
leaq -0x500(%rbp), %rsi
leaq -0x30(%rbp), %rdx
movq %r15, %rcx
leaq 0x865(%rip), %r8        # 0x4e78
xorl %r9d, %r9d
callq 0x4c24
jmp 0x4664
leaq -0xe0(%rbp), %r15
movq %r15, %rdi
leaq 0x2aa4(%rip), %rsi      # 0x70d2
leaq -0x29(%rbp), %rdx
callq 0x529a
movq -0x40(%rbp), %rdi
movl (%rdi), %eax
movl %eax, (%rsp)
leaq -0x500(%rbp), %rsi
leaq -0x30(%rbp), %rdx
movq %r15, %rcx
leaq 0x497(%rip), %r8        # 0x4aec
xorl %r9d, %r9d
callq 0x4c24
leaq -0x80(%rbp), %rbx
movq %r14, %r13
movq %r15, %rdi
callq 0x2130
jmp 0x450a
cmpl $-0x1, %r15d
leaq -0x80(%rbp), %rbx
jne 0x4694
movq %r14, %r13
movq -0x58(%rbp), %rax
testq %rax, %rax
movq -0x40(%rbp), %rdi
movb $0x1, %r14b
jne 0x44bb
jmp 0x46b7
leaq 0x2af1(%rip), %rsi      # 0x718c
leaq -0x500(%rbp), %rdi
leaq -0x30(%rbp), %rdx
callq 0x5421
movq -0x40(%rbp), %rdi
callq 0x3cc6
xorl %r14d, %r14d
leaq -0x60(%rbp), %rdi
callq 0x2130
movl %r14d, %eax
addq $0x4e8, %rsp            # imm = 0x4E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4716
jmp 0x4716
jmp 0x4716
jmp 0x4716
movq %rax, %rbx
leaq -0xc0(%rbp), %rdi
jmp 0x4725
movq %rax, %rbx
leaq -0xe0(%rbp), %rdi
jmp 0x4725
movq %rax, %rbx
jmp 0x4708
jmp 0x4716
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x2130
leaq -0x100(%rbp), %rdi
callq 0x2130
jmp 0x471e
movq %rax, %rbx
jmp 0x472a
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x2130
leaq -0x60(%rbp), %rdi
callq 0x2130
movq %rbx, %rdi
callq 0x2390
nop