int main(int argc, char *argv[]) { FILE *log_file = NULL; int read_times = 0; my_time time1; my_time time2; //global options truncate_end = 0; truncate_start = 0; strict_binary_search = 0; // // Parse Args // for(int carg = 1; carg < argc; carg++){ if(NULL == log_file && (log_file = fopen(argv[carg], "r"))) continue; if(0 == read_times && (read_times = get_my_times(argv[carg], &time1, &time2))) continue; if((strlen(argv[carg]) == 2) && (0 == strncmp(argv[carg], "-s",2))){ truncate_start = 1; continue; } if((strlen(argv[carg]) == 2) && (0 == strncmp(argv[carg], "-e",2))){ truncate_end = 1; continue; } if((strlen(argv[carg]) == 2) && (0 == strncmp(argv[carg], "-b",2))){ strict_binary_search = 1; continue; } // If times have been read or it's not a time, and it's not a valid file, exit if(NULL == log_file) fprintf(stderr, "%s couldn't be opened for reading or is a bad time range\n", argv[carg]); else if(read_times) fprintf(stderr, "you put in too many arguments!\n"); else fprintf(stderr, "invalid time argument!\n"); exit(0); } // Open the default log file if "log_file" is still NULL if(log_file == NULL && NULL == (log_file = fopen(LOG_PATH, "r"))){ fprintf(stderr, LOG_PATH " couldn't be opened for reading\n"); exit(0); } search_log(log_file, &time1, &time2); }
int main(int argc, char *argv[]) { char match[1024]; int operation; int action; int fd; int ret; struct talpa_filesystem tfs; if ( argc == 4 ) { strncpy(match,argv[1],sizeof(match)); operation = atoi(argv[2]); action = atoi(argv[3]); } if ( open_log() < 0 ) { fprintf(stderr,"Failed to open syslog!\n"); return 1; } fd = open("/dev/talpa-test",O_RDWR,0); if ( fd < 0 ) { fprintf(stderr,"Failed to open talpa-test device!\n"); return 1; } ret = ioctl(fd,TALPA_TEST_SET_EVAL_CODE, action); if ( ret < 0 ) { fprintf(stderr,"SetAction IOCTL error!\n"); close(fd); return 1; } if (action == EIA_Timeout) { ret = ioctl(fd,TALPA_TEST_SET_ERROR_CODE, ETIME); if ( ret < 0 ) { fprintf(stderr,"SetErrorCode IOCTL error!\n"); close(fd); return 1; } } tfs.operation = operation; strcpy(tfs.dev,"/dev/sda1"); strcpy(tfs.target,"/mnt"); strcpy(tfs.type,"ext2"); ret = ioctl(fd,TALPA_TEST_FILESYSTEMINFO,&tfs); if ( ret < 0 ) { fprintf(stderr,"File IOCTL error!\n"); close(fd); return 1; } if ( !search_log(5, match) ) { fprintf(stderr,"Bad output - not critical! [%d,%d]\n", operation, action); close(fd); return 77; } close_log(); close(fd); return 0; }
unsigned int ceil(T value) { return search_log(value, Search::Ceiling); }
//Floor/Ceiling lookup functions basically just delegate unsigned int floor(T value) { return search_log(value, Search::Floor); }