#include #include #include #include #include #include #include #include "common.h" #include "key_tracker.h" #include "report.h" FILE* report_fp; FILE* evdev_fp; void handler(int _) { gen_report(report_fp); fclose(report_fp); fclose(evdev_fp); exit(0); } int main(int argc, char* argv[]) { evdev_fp = fopen(KEYBOARD_EVDEV, "r"); report_fp = NULL; char* report_path = NULL; struct input_event pressed_key; int perkey_pressed[PERKEY_LEN + 1]; int keys_pressed = 0; struct timeval start_time; struct timeval press_time; gettimeofday(&start_time, NULL); asprintf(&report_path, REPORT_PATH, start_time.tv_sec); report_fp = fopen(report_path, "w"); signal(SIGHUP, handler); signal(SIGQUIT, handler); signal(SIGTERM, handler); do { fread(&pressed_key, sizeof(pressed_key), 1, evdev_fp); if (pressed_key.value == 1) { log_key(pressed_key.code); } } while (1); return 0; }