// File: 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
subq $0x600, %rsp            # imm = 0x600
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x558(%rbp)
leaq -0x440(%rbp), %rdi
callq 0x33e0
movq -0x558(%rbp), %rax
movl (%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 0x6c76
movq -0x560(%rbp), %rax
movl %eax, -0x41c(%rbp)
cmpl $0x0, %eax
jle 0x7236
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 0x44ed(%rip), %rsi      # 0xb1f5
callq 0x33d0
jmp 0x6d0f
jmp 0x6d11
jmp 0x6d13
cmpl $0x0, -0x41c(%rbp)
jne 0x6d46
movb $0x1, -0x1(%rbp)
movl $0x1, -0x468(%rbp)
jmp 0x7238
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x7252
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 0x4465(%rip), %rsi      # 0xb1f5
callq 0x33d0
jmp 0x6d97
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 0x42da(%rip), %rsi      # 0xb0ac
leaq -0x488(%rbp), %rdi
callq 0x88a0
jmp 0x6de0
leaq -0x4b1(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0x34c0
movq -0x5c0(%rbp), %rdx
leaq 0x42e8(%rip), %rsi      # 0xb0e9
leaq -0x4b0(%rbp), %rdi
callq 0x88a0
jmp 0x6e0f
leaq -0x4d9(%rbp), %rdi
movq %rdi, -0x5c8(%rbp)
callq 0x34c0
movq -0x5c8(%rbp), %rdx
leaq 0x4336(%rip), %rsi      # 0xb166
leaq -0x4d8(%rbp), %rdi
callq 0x88a0
jmp 0x6e3e
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 0x6e81
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 0x6fae
leaq -0x440(%rbp), %rdi
callq 0x3210
cmpq $0x0, %rax
jne 0x6fa9
movb $0x1, -0x1(%rbp)
movl $0x1, -0x468(%rbp)
jmp 0x7238
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x6f98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x6f80
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x6f68
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 0x7252
jmp 0x7231
cmpl $0x0, -0x444(%rbp)
jne 0x70c5
leaq 0xb0e(%rip), %rax       # 0x7ad0
movq %rax, -0x458(%rbp)
movq $0x0, -0x450(%rbp)
movq -0x418(%rbp), %rax
movq %rax, -0x5e0(%rbp)
leaq -0x501(%rbp), %rdi
movq %rdi, -0x5d8(%rbp)
callq 0x34c0
movq -0x5d8(%rbp), %rdx
leaq 0x40a9(%rip), %rsi      # 0xb0ac
leaq -0x500(%rbp), %rdi
callq 0x88a0
jmp 0x7011
movq -0x5e0(%rbp), %rsi
movq -0x558(%rbp), %rdi
movq -0x458(%rbp), %rax
movq -0x450(%rbp), %rdx
movl (%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 0x7065
leaq -0x500(%rbp), %rdi
callq 0x31f0
leaq -0x501(%rbp), %rdi
callq 0x3320
jmp 0x722a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x70b4
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 0x7252
cmpl $0x1, -0x444(%rbp)
jne 0x71d9
leaq 0x1137(%rip), %rax      # 0x8210
movq %rax, -0x458(%rbp)
movq $0x0, -0x450(%rbp)
movq -0x418(%rbp), %rax
movq %rax, -0x5f0(%rbp)
leaq -0x539(%rbp), %rdi
movq %rdi, -0x5e8(%rbp)
callq 0x34c0
movq -0x5e8(%rbp), %rdx
leaq 0x3fcf(%rip), %rsi      # 0xb0e9
leaq -0x538(%rbp), %rdi
callq 0x88a0
jmp 0x7128
movq -0x5f0(%rbp), %rsi
movq -0x558(%rbp), %rdi
movq -0x458(%rbp), %rax
movq -0x450(%rbp), %rdx
movl (%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 0x717c
leaq -0x538(%rbp), %rdi
callq 0x31f0
leaq -0x539(%rbp), %rdi
callq 0x3320
jmp 0x7228
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x460(%rbp)
movl %eax, -0x464(%rbp)
jmp 0x71cb
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 0x7252
movq -0x418(%rbp), %rdi
leaq 0x3f7f(%rip), %rsi      # 0xb166
leaq -0x41c(%rbp), %rdx
callq 0x8de0
movq %rax, -0x5f8(%rbp)
jmp 0x71fc
movq -0x558(%rbp), %rdi
movq -0x5f8(%rbp), %rax
movq %rax, -0x418(%rbp)
callq 0x5d30
jmp 0x7218
movb $0x0, -0x1(%rbp)
movl $0x1, -0x468(%rbp)
jmp 0x7238
jmp 0x722a
jmp 0x722c
jmp 0x6d11
jmp 0x6c16
ud2
leaq -0x440(%rbp), %rdi
callq 0x31f0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x600, %rsp            # imm = 0x600
popq %rbp
retq
leaq -0x440(%rbp), %rdi
callq 0x31f0
movq -0x460(%rbp), %rdi
callq 0x34b0
nopw (%rax,%rax)