From fc9e4c8ef6b420cd877abb834758655e15367555 Mon Sep 17 00:00:00 2001 From: Sam Moore Date: Wed, 14 Aug 2013 18:13:00 +0800 Subject: [PATCH] Actually make program compile Whoops --- rpi/Makefile | 6 +++--- rpi/log.c | 6 +++--- rpi/main.c | 27 +++++++++++++++++++-------- rpi/options.h | 2 +- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/rpi/Makefile b/rpi/Makefile index 24310f3..a7f9f7b 100644 --- a/rpi/Makefile +++ b/rpi/Makefile @@ -1,11 +1,11 @@ -# Makefile for web2io testing stuff +# Makefile for rpi side server CXX = gcc FLAGS = -std=c99 -Wall -Werror -pedantic -g LIB = -OBJ = network.o log.o webserver.o +OBJ = log.o main.o RM = rm -f -BIN = webserver +BIN = server $(BIN) : $(OBJ) $(CXX) $(FLAGS) -o $(BIN) $(OBJ) diff --git a/rpi/log.c b/rpi/log.c index 15e6618..bd41936 100644 --- a/rpi/log.c +++ b/rpi/log.c @@ -31,7 +31,7 @@ void Log(int level, char * funct, char * fmt, ...) Fatal("Log", "Format string is NULL"); // Don't print the message unless we need to - if (level > options.verbosity) + if (level > g_options.verbosity) return; if (funct == NULL) @@ -59,7 +59,7 @@ void Log(int level, char * funct, char * fmt, ...) } // Print: Program name, PID, severity string, function name first - fprintf(stderr, "%s [%d] : %s : %s - ", options.program, getpid(), severity, funct); + fprintf(stderr, "%s [%d] : %s : %s - ", g_options.program, getpid(), severity, funct); // Then pass additional arguments with the format string to vfprintf for printing va_list va; @@ -93,7 +93,7 @@ void Fatal(char * funct, char * fmt, ...) if (funct == NULL) funct = unspecified_funct; - fprintf(stderr, "%s [%d] : %s : FATAL - ", options.program, getpid(), funct); + fprintf(stderr, "%s [%d] : %s : FATAL - ", g_options.program, getpid(), funct); va_list va; va_start(va, fmt); diff --git a/rpi/main.c b/rpi/main.c index 23ef071..bb3b5ac 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, "ParseArguments", "Called as %s with %d arguments.", opts->program, argc); } /** @@ -59,4 +58,16 @@ void 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) +{ + return 0; +} + diff --git a/rpi/options.h b/rpi/options.h index df78870..66cad6c 100644 --- a/rpi/options.h +++ b/rpi/options.h @@ -13,6 +13,6 @@ typedef struct } Options; -extern Options g_options; +extern Options g_options; // global options structure #endif //_OPTIONS_H -- 2.20.1