匿名用户
1级
2018-07-18 回答
#include // for sockaddr_in
#include // for socket
#include // for socket
#include // for printf
#include // for exit
#include // for bzero
#include
#include // for open
#include // for close
#include //for thread
#include //for time
struct info {
char dirname[50];
int mysock;
};
void* search_by_time(void * arg) {
FILE * fp; //文件指针
char strtime[32];
bzero(strtime, 32);
char start_time[16];
char end_time[16];
bzero(start_time, 16);
bzero(end_time, 16);
char dirname[20];
char cmd[200];
char path[20];
char colletc_file[20];
char colletc_file_data[50];
struct info *sinfo = arg;
int socket = sinfo->mysock;
while (1) {
if (socket != -1) {
int len;
while ((len = recv(socket, strtime, 32, 0)) > 0) {
if (strncmp(strtime, “quit”, 4) == 0) {
fclose(fp);
pthread_exit(NULL);
}
strncpy(start_time, strtime, 15);
char *p = strtime;
p += 16;
strncpy(start_time, strtime, 15);
bzero(cmd, 100);
strcpy(cmd, “cd “);
strcat(path, “./”);
strcat(path, sinfo->dirname);
strcat(path, “/”);
system(cmd);
bzero(cmd, 100);
strcpy(cmd, “touch -t “);
strcat(cmd, start_time);
strcat(cmd, ” start”);
system(cmd);
bzero(cmd, 100);
strcpy(cmd, “touch -t “);
printf(“%sn”, end_time);
strcat(cmd, end_time);
strcat(cmd, ” end”);
system(cmd);
bzero(cmd, 100);
strcpy(cmd,
“find ./* -newer start ! -newer end | tr -d “./”” >>a””);
fp = fopen(“”a””
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!