From a072359bdedda144549f06aa5b2bef57e591b7cf Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Sun, 2 May 2021 09:56:27 +0900 Subject: [PATCH] main: Instantiate and run mwm The main() function currently does nothing but parse teh commandline. This commit changes the main() function so that it creates an mwm instance and subsequently initializes and executes it. --- Makefile | 2 +- main.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 916e762..af33710 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ OUTPUT = mwm -OBJECTS = main.o +OBJECTS = main.o array.o monitor.o mwm.o ifeq ($(PREFIX), ) PREFIX = /usr/local diff --git a/main.c b/main.c index 4caf55b..3d83b58 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,7 @@ #include #include +#include +#include "mwm.h" #define SHORTOPTS "h" @@ -20,10 +22,13 @@ static void print_usage(const char *argv0) int main(int argc, char *argv[]) { + struct mwm *mwm; int opt; + int err; do { - opt = getopt_long(argc, argv, SHORTOPTS, cmd_opts, NULL); + opt = getopt_long(argc, argv, SHORTOPTS, + cmd_opts, NULL); switch(opt) { case 'h': @@ -36,5 +41,27 @@ int main(int argc, char *argv[]) } } while(opt >= 0); - return(0); + err = mwm_new(&mwm); + + if(err < 0) { + fprintf(stderr, "mwm_new: %s\n", strerror(-err)); + return(1); + } + + err = mwm_init(mwm); + + if(err < 0) { + fprintf(stderr, "mwm_init: %s\n", strerror(-err)); + } else { + err = mwm_run(mwm); + + if(err < 0) { + fprintf(stderr, "mwm_run: %s\n", + strerror(-err)); + } + } + + mwm_free(&mwm); + + return(err); } -- 2.47.3