exit hook

Mon, 17 Mar 2014 14:35:53 +0100

author
Mike Becker <universe@uap-core.de>
date
Mon, 17 Mar 2014 14:35:53 +0100
changeset 4
560e07f7a6a1
parent 3
3693fd2eb0e9
child 5
f7dfef88947d

exit hook

src/main.c file | annotate | diff | comparison | revisions
--- a/src/main.c	Thu Mar 06 15:03:06 2014 +0100
+++ b/src/main.c	Mon Mar 17 14:35:53 2014 +0100
@@ -137,6 +137,14 @@
     return exitcode;
 }
 
+static WINDOW* window;
+
+void leavescr() {
+    mvprintw(getmaxy(window)-1, 0, "Leaving terminal-chess. Press any key...");
+    getch();
+    endwin();
+}
+
 int main(int argc, char **argv) {
     srand(time(NULL));
     
@@ -167,9 +175,9 @@
         return EXIT_SUCCESS;
     }
     
-    initscr();
+    window = initscr();
     cbreak();
-    atexit((void(*)(void)) endwin);
+    atexit(leavescr);
     
     Server server;
     settings.server = &server;
@@ -253,7 +261,6 @@
         }
     }
     
-    getch(); /* TODO: remove */
     return cleanup(&settings, EXIT_SUCCESS);
 }
 

mercurial