|
|
|
@ -159,6 +159,7 @@ int handleclient(struct client *p) { |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
// printf("size %d read in %d bytes\n", p->info->size, len);
|
|
|
|
procbar(p->info->size,len); |
|
|
|
p->state = AWAITING_HASH; |
|
|
|
return 1; |
|
|
|
} |
|
|
|
@ -389,14 +390,17 @@ int checkfile(struct client *p) { |
|
|
|
void procbar(double total,double current){ |
|
|
|
char bar[PROCBAR_LEN]; |
|
|
|
memset(bar,'\0',sizeof(bar)); |
|
|
|
// label
|
|
|
|
const char *label= "|/_\\"; |
|
|
|
//
|
|
|
|
int cnt=0; |
|
|
|
int len= strlen(label); |
|
|
|
// 占比
|
|
|
|
double rate = (100*current)/total; |
|
|
|
//循环次数,必须为整数
|
|
|
|
int loop_count = (int) rate; |
|
|
|
//loop print
|
|
|
|
whiel(cnt<=loop_count){ |
|
|
|
while(cnt<=loop_count){ |
|
|
|
printf("[%-100s][%.11f%%][%c]\r",bar,rate,label[cnt%len]); |
|
|
|
// 直接输出不,非缓冲区
|
|
|
|
fflush(stdout); |
|
|
|
|