]> git.corax.cc Git - mwm/commitdiff
main: Instantiate and run mwm
authorMatthias Kruk <m@m10k.eu>
Sun, 2 May 2021 00:56:27 +0000 (09:56 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 2 May 2021 00:56:27 +0000 (09:56 +0900)
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
main.c

index 916e762e96f1705b7bb51d8664bb6c0fa9dc0b34..af33710a5afba2913e1e06fadb8a77049fde2bf2 100644 (file)
--- 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 4caf55b4e6a9e1d855f8dfd3ad2fe01921cce71f..3d83b58c4e02575937d9cd2893b216c010c66f84 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,5 +1,7 @@
 #include <stdio.h>
 #include <getopt.h>
+#include <string.h>
+#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);
 }