X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=rpi%2Fmain.c;h=22fad613a4e16d57e38fa7e2293bfea964dbd3bc;hb=5bd6aced71333d0dc8d142f593073c68811e5435;hp=23ef0711096a64570a23bb16c9cc020f39d9ff6f;hpb=5d2b87e5ad41b31eeb94dca4547d73bc8e30e6c3;p=matches%2FMCTX3420.git diff --git a/rpi/main.c b/rpi/main.c index 23ef071..22fad61 100644 --- a/rpi/main.c +++ b/rpi/main.c @@ -3,12 +3,16 @@ * @purpose Entry point to the program, starts threads, handles cleanup on program exit */ +#define _POSIX_C_SOURCE 200809L // For strsignal to work + // --- Standard headers --- // #include #include #include // for signal handling +#include // string functions // --- Custom headers --- // +#include "log.h" #include "options.h" // --- Variable definitions --- // @@ -25,14 +29,9 @@ Options g_options; // options passed to program through command line arguments */ void ParseArguments(int argc, char ** argv, Options * opts) { - options.program = argv[0]; // program name - options.verbosity = LOGDEBUG; // default log level - if (argc > 1) - options.port = atoi(argv[1]); // Allow us change the port for testing (I keep getting "address in use" errors) - else - options.port = 8080; // Using 8080 instead of 80 for now because to use 80 you have to run the program as root - - Log(LOGDEBUG, "ParseArguments", "Called as %s with %d arguments.", options.program, argc); + opts->program = argv[0]; // program name + opts->verbosity = LOGDEBUG; // default log level + Log(LOGDEBUG, "Called as %s with %d arguments.", opts->program, argc); } /** @@ -44,7 +43,7 @@ void SignalHandler(int sig) { // At the moment just always exit. // Call `exit` so that Cleanup will be called to... clean up. - Log(LOGWARN, "SignalHandler", "Got signal %d (%s). Exiting.", sig, strsignal(sig)); + Log(LOGWARN, "Got signal %d (%s). Exiting.", sig, strsignal(sig)); exit(sig); } @@ -54,9 +53,22 @@ void SignalHandler(int sig) */ void Cleanup() { - Log(LOGDEBUG, "Cleanup", "Begin cleanup."); - Log(LOGDEBUG, "Cleanup", "Finish cleanup."); + Log(LOGDEBUG, "Begin cleanup."); + Log(LOGDEBUG, "Finish cleanup."); + +} +/** + * @funct main + * @purpose Main entry point; start worker threads, setup signal handling, wait for threads to exit, exit + * @param argc - Num args + * @param argv - Args + * @returns 0 on success, error code on failure + */ +int main(int argc, char ** argv) +{ + ParseArguments(argc, argv, &g_options); + return 0; }