// File: /workspace/github_cpp_makefile_star2_O3/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:
cmpq $0x0, (%rdi)
jle 0x3700
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rdi, %rbx
xorl %r13d, %r13d
leaq -0x1040(%rbp), %r15
leaq -0x30(%rbp), %r12
movq 0x4b90(%rip), %r14      # 0x7ff0
xorl %eax, %eax
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 %r15, %rsi
movl %r13d, %edx
movq %r12, %rcx
callq 0x3a88
cmpl $0x1, %eax
jne 0x358a
movl $0x1c, %edx
movq %r14, %rdi
leaq 0x1dd4(%rip), %rsi      # 0x5286
callq 0x2250
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x2c(%rbp), %rdx
callq 0x3b84
testb %al, %al
je 0x356d
movq %rbx, %rdi
callq 0x3d2a
movl $0x19, %edx
movq %r14, %rdi
leaq 0x1d9b(%rip), %rsi      # 0x52a3
callq 0x2250
movl -0x2c(%rbp), %esi
movq %r14, %rdi
callq 0x2350
movq %rax, %r12
movl $0x6, %edx
movq %rax, %rdi
leaq 0x1d93(%rip), %rsi      # 0x52bd
callq 0x2250
movq %r12, %rdi
movq %r13, %rsi
callq 0x21f0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r12, %rdi
leaq -0x30(%rbp), %r12
callq 0x2030
movq %rax, %rdi
callq 0x2130
jmp 0x3643
movq 0x38(%rbx), %rax
subq %rax, %r13
leaq (%rax,%rbp), %rsi
addq $-0x1040, %rsi          # imm = 0xEFC0
movq %r15, %rdi
movq %r13, %rdx
callq 0x2330
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %r12, %rcx
callq 0x3a88
cmpl $0x2, %eax
jne 0x365b
movl $0x1d, %edx
movq %r14, %rdi
leaq 0x1d11(%rip), %rsi      # 0x52c4
callq 0x2250
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl 0x8(%rbx), %edi
cmpl $-0x1, %edi
je 0x3607
movslq -0x30(%rbp), %rdx
movq %r15, %rsi
callq 0x20c0
movl 0x8(%rbx), %edi
cmpl $-0x1, %edi
je 0x3607
callq 0x23c0
movl $0xffffffff, 0x8(%rbx)  # imm = 0xFFFFFFFF
movslq -0x30(%rbp), %rax
subq %rax, %r13
movslq -0x2c(%rbp), %rax
leaq (%rax,%rbp), %rsi
addq $-0x1040, %rsi          # imm = 0xEFC0
movq %r15, %rdi
movq %r13, %rdx
callq 0x2330
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x2c(%rbp), %rdx
callq 0x3b84
testb %al, %al
je 0x364c
movq %rbx, %rdi
callq 0x3d2a
movslq -0x2c(%rbp), %rax
jmp 0x3571
cmpl $0x0, -0x2c(%rbp)
je 0x365b
movq 0x58(%rbx), %rax
jmp 0x3571
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %r12, %rcx
callq 0x3a88
cmpl $0x3, %eax
je 0x3703
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %r12, %rcx
callq 0x3a88
cmpl $0x4, %eax
jne 0x36c0
movl 0x8(%rbx), %edi
cmpl $-0x1, %edi
je 0x369f
movslq -0x30(%rbp), %rdx
movq %r15, %rsi
callq 0x20c0
movslq -0x30(%rbp), %rax
subq %rax, %r13
movslq -0x2c(%rbp), %rax
leaq (%rax,%rbp), %rsi
addq $-0x1040, %rsi          # imm = 0xEFC0
movq %r15, %rdi
movq %r13, %rdx
callq 0x2330
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
movq %r12, %rcx
callq 0x3a88
testl %eax, %eax
jne 0x36eb
movl 0x8(%rbx), %edi
cmpl $-0x1, %edi
je 0x36e8
movslq %r13d, %rdx
movq %r15, %rsi
callq 0x20c0
xorl %r13d, %r13d
movq -0x38(%rbp), %rax
addq -0x40(%rbp), %rax
cmpq (%rbx), %rax
jl 0x3462
xorl %eax, %eax
jmp 0x376c
xorl %eax, %eax
retq
leaq 0x1bd8(%rip), %rsi      # 0x52e2
movl $0x1b, %edx
movq %r14, %rdi
callq 0x2250
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2200
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl 0x8(%rbx), %edi
cmpl $-0x1, %edi
je 0x376a
movslq -0x30(%rbp), %rdx
leaq -0x1040(%rbp), %rsi
callq 0x20c0
movl 0x8(%rbx), %edi
cmpl $-0x1, %edi
je 0x376a
callq 0x23c0
movl $0xffffffff, 0x8(%rbx)  # imm = 0xFFFFFFFF
movb $0x1, %al
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq