From: Matthias Kruk Date: Sun, 2 May 2021 00:56:27 +0000 (+0900) Subject: main: Instantiate and run mwm X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=a072359bdedda144549f06aa5b2bef57e591b7cf;p=mwm 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. --- 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); }