// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rdi, %rbx
xorl %eax, %eax
leaq -0x1040(%rbp), %r14
movq 0x4061(%rip), %r15      # 0x6ff0
xorl %r13d, %r13d
movq (%rbx), %r12
cmpq %r12, %rax
jge 0x31de
movq %rax, -0x38(%rbp)
leaq -0x1040(,%r13), %rsi
addq %rbp, %rsi
movl $0x1000, %edx           # imm = 0x1000
subq %r13, %rdx
xorl %edi, %edi
callq 0x22c0
cltq
movq %rax, -0x40(%rbp)
addq %rax, %r13
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
leaq -0x30(%rbp), %rcx
callq 0x340c
cmpl $0x1, %eax
jne 0x3070
movq %r15, %rdi
leaq 0x123b(%rip), %rsi      # 0x4225
callq 0x21e0
movq %rax, %rdi
callq 0x2100
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x2c(%rbp), %rdx
callq 0x3504
testb %al, %al
je 0x3053
movq %rbx, %rdi
callq 0x3650
movq %r15, %rdi
leaq 0x1226(%rip), %rsi      # 0x4242
callq 0x21e0
movl -0x2c(%rbp), %esi
movq %rax, %rdi
callq 0x2330
movq %rax, %rdi
leaq 0x1226(%rip), %rsi      # 0x425c
callq 0x21e0
movq %rax, %rdi
movq %r13, %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x2100
jmp 0x30f4
movq 0x38(%rbx), %rax
subq %rax, %r13
leaq (%rax,%rbp), %rsi
addq $-0x1040, %rsi          # imm = 0xEFC0
movq %r14, %rdi
movq %r13, %rdx
callq 0x2310
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
leaq -0x30(%rbp), %rcx
callq 0x340c
cmpl $0x2, %eax
jne 0x310c
movq %r15, %rdi
leaq 0x11ce(%rip), %rsi      # 0x4263
callq 0x21e0
movq %rax, %rdi
callq 0x2100
movl -0x30(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3742
movq %rbx, %rdi
callq 0x375a
movslq -0x30(%rbp), %rax
subq %rax, %r13
movslq -0x2c(%rbp), %rax
leaq (%rax,%rbp), %rsi
addq $-0x1040, %rsi          # imm = 0xEFC0
movq %r14, %rdi
movq %r13, %rdx
callq 0x2310
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x2c(%rbp), %rdx
callq 0x3504
testb %al, %al
je 0x30fd
movq %rbx, %rdi
callq 0x3650
movslq -0x2c(%rbp), %rax
jmp 0x3057
cmpl $0x0, -0x2c(%rbp)
je 0x310c
movq 0x58(%rbx), %rax
jmp 0x3057
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
leaq -0x30(%rbp), %r15
movq %r15, %rcx
callq 0x340c
cmpl $0x3, %eax
je 0x31a5
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
movq %r15, %rcx
callq 0x340c
cmpl $0x4, %eax
jne 0x316b
movl -0x30(%rbp), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3742
movslq -0x30(%rbp), %rax
subq %rax, %r13
movslq -0x2c(%rbp), %rax
leaq (%rax,%rbp), %rsi
addq $-0x1040, %rsi          # imm = 0xEFC0
movq %r14, %rdi
movq %r13, %rdx
callq 0x2310
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
movq %r15, %rcx
callq 0x340c
testl %eax, %eax
jne 0x3191
movq %rbx, %rdi
movq %r14, %rsi
movl %r13d, %edx
callq 0x3742
xorl %r13d, %r13d
movq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
movq 0x3e50(%rip), %r15      # 0x6ff0
jmp 0x2f92
movq 0x3e44(%rip), %rdi      # 0x6ff0
leaq 0x10ce(%rip), %rsi      # 0x4281
callq 0x21e0
movq %rax, %rdi
callq 0x2100
movl -0x30(%rbp), %edx
leaq -0x1040(%rbp), %rsi
movq %rbx, %rdi
callq 0x3742
movq %rbx, %rdi
callq 0x375a
movq -0x38(%rbp), %rax
cmpq %r12, %rax
setl %al
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq