|
|
@ -26,6 +26,8 @@ struct request *createrequest(void); |
|
|
void complete_path(const char *child, char *s); |
|
|
void complete_path(const char *child, char *s); |
|
|
int handleclient(struct client *p); |
|
|
int handleclient(struct client *p); |
|
|
int checkfile(struct client *p); |
|
|
int checkfile(struct client *p); |
|
|
|
|
|
// 百分比进度条
|
|
|
|
|
|
void procbar(double total,double current); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int bindandlisten(unsigned short port); |
|
|
int bindandlisten(unsigned short port); |
|
|
@ -109,6 +111,7 @@ void rcopy_server(unsigned short port, char *dest) { |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
* Based on the state of the client complete task. |
|
|
* Based on the state of the client complete task. |
|
|
|
|
|
✔ ✖ |
|
|
*/ |
|
|
*/ |
|
|
int handleclient(struct client *p) { |
|
|
int handleclient(struct client *p) { |
|
|
|
|
|
|
|
|
@ -211,6 +214,7 @@ int handleclient(struct client *p) { |
|
|
status = ERROR; |
|
|
status = ERROR; |
|
|
} |
|
|
} |
|
|
} while((len == 1) && ++s < p->info->size); |
|
|
} while((len == 1) && ++s < p->info->size); |
|
|
|
|
|
//close file handle
|
|
|
fclose(in); |
|
|
fclose(in); |
|
|
if (len != 1) { |
|
|
if (len != 1) { |
|
|
perror("server: reading file"); |
|
|
perror("server: reading file"); |
|
|
@ -378,3 +382,27 @@ int checkfile(struct client *p) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 进度条 |
|
|
|
|
|
*/ |
|
|
|
|
|
void procbar(double total,double current){ |
|
|
|
|
|
char bar[PROCBAR_LEN]; |
|
|
|
|
|
memset(bar,'\0',sizeof(bar)); |
|
|
|
|
|
//
|
|
|
|
|
|
int cnt=0; |
|
|
|
|
|
int len= strlen(label); |
|
|
|
|
|
// 占比
|
|
|
|
|
|
double rate = (100*current)/total; |
|
|
|
|
|
int loop_count = (int) rate; |
|
|
|
|
|
//loop print
|
|
|
|
|
|
whiel(cnt<=loop_count){ |
|
|
|
|
|
printf("[%-100s][%.11f%%][%c]\r",bar,rate,label[cnt%len]); |
|
|
|
|
|
// 直接输出不,非缓冲区
|
|
|
|
|
|
fflush(stdout); |
|
|
|
|
|
bar[cnt++] = PROC_STYLE; |
|
|
|
|
|
usleep(2000); |
|
|
|
|
|
} |
|
|
|
|
|
// 输出换行,反正被覆盖
|
|
|
|
|
|
printf("\n"); |
|
|
|
|
|
} |