// File: coolsuperman[P]ShareCataLogServer/upload.cc
// Function: Upload::ProcessUpload()
bool ProcessUpload(){//对正文进行处理，将文件数据进行存储（处理上传）
      int64_t tlen = 0,blen=0;//已读取多少；当前buffer数据长度；
      char buf[MAX_BUFF];
      while(tlen<content_len){
        int len = read(0,buf+blen,MAX_BUFF-blen);
        blen+=len;//当前buf中数据长度
        int boundry_pos,content_pos;
        if(MatchBoundry(buf,blen,&boundry_pos)==BOUNDRY_FIRST){
            std::cerr<<"first boundry match success!"<<std::endl;
          //1.匹配到firstBoundry，获取头部，从中获取文件名
          //2.若获取文件名成功，则创建文件，打开文件
          //3.将头信息从buf移除，上下数据进行下一步匹配
          if(GetFileName(buf,&content_pos)){
            CreateFile();
            std::cerr<<"OutCreatFile content_pos:"<<content_pos << " blen:" << blen<<std::endl;
            blen-=content_pos;
            memmove(buf,buf+content_pos,blen);
           // std::cerr << "buf:[" << buf << "]\n";
          }else{
            blen-=_f_boundry.size();
            memmove(buf,buf+_f_boundry.size(),blen);
          }
        }
       // std::cerr << "will middle boundary match\n";
        while(1){
          if(MatchBoundry(buf,blen,&boundry_pos)!=BOUNDRY_MIDDLE){
           // std::cerr<<"middle boundry match fail!"<<std::endl;
            break;
          }
          std::cerr<<"middle boundry match success!"<<std::endl;
          //匹配middle_boundry成功
          //1.将boundry之前数据写入文件，将数据从buf中移除,关闭文件
          //2.看boundry头中是否有文件名--雷同first_boundry;
          WriteFile(buf,boundry_pos);//
          CloseFile();
          blen-=boundry_pos;//
          memmove(buf,buf+content_pos,blen);
          if(GetFileName(buf,&content_pos)){
            CreateFile();
            blen-=content_pos;
            memmove(buf,buf+content_pos,blen);
          }else{
            if(content_pos==0)
              break;
            blen-=_m_boundry.size();
            memmove(buf,buf+_m_boundry.size(),blen);
          }
        }
        if(MatchBoundry(buf,blen,&boundry_pos)==BOUNDRY_LAST){
          std::cerr<<"last boundry match success!"<<std::endl;
          //匹配Boundry_LAST成功
          //1.将boundry之前的数据写入文件
          //2.关闭文件
          //3.上传文件处理完毕，退出
          WriteFile(buf,boundry_pos);//
          CloseFile();
          return true;
        }
        if(MatchBoundry(buf,blen,&boundry_pos)==BOUNDRY_BAK){
          //1.将类似boundry位置之前的数据写入文件
          //2.移除之前的数据
          //3.剩下的数据不动，重新继续接收数据，补全后继续匹配
          WriteFile(buf,boundry_pos);//
          blen-=boundry_pos;//
          memmove(buf,buf+content_pos,blen);
        }
        if(MatchBoundry(buf,blen,&boundry_pos)==BOUNDRY_NO){
          WriteFile(buf,blen);//
          blen=0;//
        }
        tlen +=len;
      }
      return false;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1060, %rsp           # imm = 0x1060
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x1038(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x1038(%rbp), %rcx
movq -0x18(%rbp), %rax
cmpq (%rcx), %rax
jge 0x4179
leaq -0x1020(%rbp), %rsi
addq -0x20(%rbp), %rsi
movl $0x1000, %edx           # imm = 0x1000
subq -0x20(%rbp), %rdx
xorl %edi, %edi
callq 0x2320
movq -0x1038(%rbp), %rdi
movl %eax, -0x1024(%rbp)
movslq -0x1024(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
leaq -0x1020(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq -0x1028(%rbp), %rcx
callq 0x49e0
cmpl $0x1, %eax
jne 0x3ebe
movq 0x7262(%rip), %rdi      # 0xaff0
leaq 0x3494(%rip), %rsi      # 0x7229
callq 0x2220
movq %rax, %rdi
movq 0x720c(%rip), %rsi      # 0xafb0
callq 0x2250
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
leaq -0x102c(%rbp), %rdx
callq 0x4bd0
testb $0x1, %al
jne 0x3dcc
jmp 0x3e58
movq -0x1038(%rbp), %rdi
callq 0x4e50
movq 0x7211(%rip), %rdi      # 0xaff0
leaq 0x3460(%rip), %rsi      # 0x7246
callq 0x2220
movq %rax, %rdi
movl -0x102c(%rbp), %esi
callq 0x23b0
movq %rax, %rdi
leaq 0x345d(%rip), %rsi      # 0x7260
callq 0x2220
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x23f0
movq %rax, %rdi
movq 0x7192(%rip), %rsi      # 0xafb0
callq 0x2250
movslq -0x102c(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq -0x1020(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movslq -0x102c(%rbp), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
callq 0x2380
jmp 0x3ebc
movq -0x1038(%rbp), %rdi
addq $0x30, %rdi
callq 0x2170
movq -0x1038(%rbp), %rdi
movq %rax, %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq -0x1020(%rbp), %rax
movq %rax, -0x1040(%rbp)
leaq -0x1020(%rbp), %rax
movq %rax, -0x1048(%rbp)
addq $0x30, %rdi
callq 0x2170
movq -0x1048(%rbp), %rsi
movq -0x1040(%rbp), %rdi
addq %rax, %rsi
movq -0x20(%rbp), %rdx
callq 0x2380
jmp 0x3ebe
jmp 0x3ec0
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq -0x1028(%rbp), %rcx
callq 0x49e0
cmpl $0x2, %eax
je 0x3eea
jmp 0x4039
movq 0x70ff(%rip), %rdi      # 0xaff0
leaq 0x336f(%rip), %rsi      # 0x7267
callq 0x2220
movq %rax, %rdi
movq 0x70a9(%rip), %rsi      # 0xafb0
callq 0x2250
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movl -0x1028(%rbp), %edx
callq 0x4fe0
movq -0x1038(%rbp), %rdi
callq 0x5020
movslq -0x1028(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq -0x1020(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movslq -0x102c(%rbp), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
callq 0x2380
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
leaq -0x102c(%rbp), %rdx
callq 0x4bd0
testb $0x1, %al
jne 0x3f84
jmp 0x3fc5
movq -0x1038(%rbp), %rdi
callq 0x4e50
movslq -0x102c(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq -0x1020(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movslq -0x102c(%rbp), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
callq 0x2380
jmp 0x4034
cmpl $0x0, -0x102c(%rbp)
jne 0x3fd0
jmp 0x4039
movq -0x1038(%rbp), %rdi
addq $0x50, %rdi
callq 0x2170
movq -0x1038(%rbp), %rdi
movq %rax, %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq -0x1020(%rbp), %rax
movq %rax, -0x1050(%rbp)
leaq -0x1020(%rbp), %rax
movq %rax, -0x1058(%rbp)
addq $0x50, %rdi
callq 0x2170
movq -0x1058(%rbp), %rsi
movq -0x1050(%rbp), %rdi
addq %rax, %rsi
movq -0x20(%rbp), %rdx
callq 0x2380
jmp 0x3ec0
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq -0x1028(%rbp), %rcx
callq 0x49e0
cmpl $0x3, %eax
jne 0x40ae
movq 0x6f8b(%rip), %rdi      # 0xaff0
leaq 0x3219(%rip), %rsi      # 0x7285
callq 0x2220
movq %rax, %rdi
movq 0x6f35(%rip), %rsi      # 0xafb0
callq 0x2250
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movl -0x1028(%rbp), %edx
callq 0x4fe0
movq -0x1038(%rbp), %rdi
callq 0x5020
movb $0x1, -0x1(%rbp)
jmp 0x417d
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq -0x1028(%rbp), %rcx
callq 0x49e0
cmpl $0x4, %eax
jne 0x411f
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movl -0x1028(%rbp), %edx
callq 0x4fe0
movslq -0x1028(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
leaq -0x1020(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movslq -0x102c(%rbp), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
callq 0x2380
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
leaq -0x1028(%rbp), %rcx
callq 0x49e0
cmpl $0x0, %eax
jne 0x4165
movq -0x1038(%rbp), %rdi
leaq -0x1020(%rbp), %rsi
movq -0x20(%rbp), %rax
movl %eax, %edx
callq 0x4fe0
movq $0x0, -0x20(%rbp)
movslq -0x1024(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x3d1a
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x1060, %rsp           # imm = 0x1060
popq %rbp
retq
nopl (%rax,%rax)