summaryrefslogtreecommitdiffstats
path: root/labb5/lib/StanfordCPPLib/private/main.h
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-11-17 15:42:27 +0100
committerGustav Sörnäs <gustav@sornas.net>2020-11-17 15:42:27 +0100
commitfb80ac50825c7ca1fa063d3493175b7b27adbdb1 (patch)
tree4d84895d45ca2c177ddefe11164575bf6762b3ca /labb5/lib/StanfordCPPLib/private/main.h
parent4065799f7080260f507a5e3ea8c2d8375e735166 (diff)
downloadtddd86-fb80ac50825c7ca1fa063d3493175b7b27adbdb1.tar.gz
add given code
Diffstat (limited to 'labb5/lib/StanfordCPPLib/private/main.h')
-rwxr-xr-xlabb5/lib/StanfordCPPLib/private/main.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/labb5/lib/StanfordCPPLib/private/main.h b/labb5/lib/StanfordCPPLib/private/main.h
new file mode 100755
index 0000000..4339915
--- /dev/null
+++ b/labb5/lib/StanfordCPPLib/private/main.h
@@ -0,0 +1,62 @@
+/*
+ * File: main.h
+ * ------------
+ * This file renames the <code>main</code> method in the client's
+ * program to <code>Main</code>, thereby allowing a custom
+ * <code>main</code> method in the libraries to take control
+ * before passing control back to the client program. The main macro
+ * also defines a function getMainFlags that returns an int whose bits
+ * indicate which of the various interfaces have been loaded by this
+ * definition of main.
+ *
+ * Note: This file can be loaded more than once and must therefore
+ * check to see what has already been defined.
+ */
+
+#ifdef main
+# undef main
+# undef CONSOLE_FLAG
+# undef GRAPHICS_FLAG
+#else
+# define MAIN_USES_CONSOLE (1<<0)
+# define MAIN_USES_GRAPHICS (1<<1)
+#endif
+
+#ifdef _console_h
+# define CONSOLE_FLAG MAIN_USES_CONSOLE
+#else
+# define CONSOLE_FLAG 0
+#endif
+
+#ifdef _gwindow_h
+# define GRAPHICS_FLAG MAIN_USES_GRAPHICS
+#else
+# define GRAPHICS_FLAG 0
+#endif
+
+void __StanfordCPPLib_terminate_handler();
+void __StanfordCPPLib_set_terminate();
+
+#if CONSOLE_FLAG | GRAPHICS_FLAG
+
+#define main main(int argc, char **argv) { \
+ extern int _mainFlags; \
+ _mainFlags = GRAPHICS_FLAG + CONSOLE_FLAG; \
+ return startupMain(argc, argv); \
+ } \
+ int Main
+
+extern int startupMain(int argc, char **argv);
+
+#else
+
+#define main main(int argc, char **argv) { \
+ extern int _mainFlags; \
+ _mainFlags = GRAPHICS_FLAG + CONSOLE_FLAG; \
+ return mainWrapper(argc, argv); } \
+ } \
+ int Main
+
+extern int mainWrapper(int argc, char **argv);
+
+#endif