1 /** \file   gtk3main.c
2  * \brief   Native GTK3 UI startup
3  *
4  * \author  Marco van den Heuvel <blackystardust68@yahoo.com>
5  */
6 
7 /*
8  * This file is part of VICE, the Versatile Commodore Emulator.
9  * See README for copyright notice.
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24  *  02111-1307  USA.
25  *
26  */
27 
28 #include "vice.h"
29 
30 #include <stdio.h>
31 #include <signal.h>
32 
33 #include "log.h"
34 #include "machine.h"
35 #include "main.h"
36 #include "video.h"
37 
38 /* For the ugly hack below */
39 #ifdef WIN32_COMPILE
40 # include "windows.h"
41 #endif
42 
43 
44 /** \brief  Program driver
45  *
46  * \param[in]   argc    argument count
47  * \param[in]   argv    argument vector
48  *
49  * \return  0 on success, any other value on failure
50  *
51  * \note    This should return either EXIT_SUCCESS on success or EXIT_FAILURE
52  *          on failure. Unfortunately, there are a lot of exit(1)/exit(-1)
53  *          calls, so don't expect to get a meaningful exit status.
54  */
main(int argc,char ** argv)55 int main(int argc, char **argv)
56 {
57     /*
58      * Ugly hack to make the VTE-based monitor behave on 32-bit Windows.
59      *
60      * Without this, the monitor outputs all sorts of non-ASCII glyphs resulting
61      * in either weird tokens and a red background or a nice crash.
62      *
63      * The Windows C runtime doesn't actually use this env var, but Gtk/GLib
64      * does. Ofcourse properly fixing the monitor code would be better, but I've
65      * spent all day trying to figure this out, so it'll have to do for now.
66      *
67      * --Compyx
68      */
69 #ifdef WIN32_COMPILE
70     _putenv("LANG=C");
71 #endif
72 
73     return main_program(argc, argv);
74 }
75 
76 
77 /** \brief  Exit handler
78  */
main_exit(void)79 void main_exit(void)
80 {
81     /* Disable SIGINT.  This is done to prevent the user from keeping C-c
82        pressed and thus breaking the cleanup process, which might be
83        dangerous.  */
84     signal(SIGINT, SIG_IGN);
85 
86     log_message(LOG_DEFAULT, "\nExiting...");
87 
88     machine_shutdown();
89 }
90