void display_information(int sig) { print_log(INFO,"\n-----------------------------SERVER iNFO-----------------------------"); print_log(ERROR,"\nCURRENT LOG LEVELS : ERROR"); print_log(WARNING,",WARNING"); print_log(INFO,",INFO"); print_log(DEBUG,",DEBUG"); print_log(INFO,"\nDocument Root : %s",path_root); print_log(INFO,"\nPort No : %d",port_number); print_log(INFO,"\nResponse Strategy : %s",strategy_name); if(strstr(strategy_name,"Fork")) { print_log(INFO,"\n---------------------------------------------------------------------\n"); return; } if(strcmp(strategy_name,"Thread Pool")==0) { print_log(INFO,"\nThread Pool Size : %d",worker_max); print_log(INFO,"\nWorker Size : %d",buffer_max); } print_log(INFO,"\nTotal Requests handled : %d",show_total_requests()); print_log(INFO,"\nTotal amount of data transferred : %d bytes",show_total_size()); s_stop(&total_uptime); get_time_difference(&total_uptime); print_log(INFO,"\nTotal uptime : %s",show_time_difference(&total_uptime)); print_log(INFO,"\nTotal time spent serving requets : %s",show_total_time_difference(&requests_time)); print_log(INFO,"\nAvg time spent serving requests : %s",show_average_time(&requests_time,show_total_requests())); print_log(INFO,"\n---------------------------------------------------------------------\n"); }
static int listdir(const char *name, int flags) { char tmp[4096]; DIR *d; struct dirent *de; d = opendir(name); if(d == 0) { fprintf(stderr, "opendir failed, %s\n", strerror(errno)); return -1; } if ((flags & LIST_SIZE) != 0) { show_total_size(name, d, flags); } while((de = readdir(d)) != 0){ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) continue; if(de->d_name[0] == '.' && (flags & LIST_ALL) == 0) continue; listfile(name, de->d_name, flags); } if (flags & LIST_RECURSIVE) { rewinddir(d); while ((de = readdir(d)) != 0) { struct stat s; int err; if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) continue; if (de->d_name[0] == '.' && (flags & LIST_ALL) == 0) continue; if (!strcmp(name, "/")) snprintf(tmp, sizeof(tmp), "/%s", de->d_name); else snprintf(tmp, sizeof(tmp), "%s/%s", name, de->d_name); /* * If the name ends in a '/', use stat() so we treat it like a * directory even if it's a symlink. */ if (tmp[strlen(tmp)-1] == '/') err = stat(tmp, &s); else err = lstat(tmp, &s); if (err < 0) { perror(tmp); closedir(d); return -1; } if (S_ISDIR(s.st_mode)) { printf("\n%s:\n", tmp); listdir(tmp, flags); } } } closedir(d); return 0; }