comparison src/events/SDL_quit.c @ 1330:450721ad5436

It's now possible to build SDL without any C runtime at all on Windows, using Visual C++ 2005
author Sam Lantinga <slouken@libsdl.org>
date Mon, 06 Feb 2006 08:28:51 +0000
parents c9b51268668f
children d910939febfa
comparison
equal deleted inserted replaced
1329:bc67bbf87818 1330:450721ad5436
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 22
23 /* General quit handling code for SDL */ 23 /* General quit handling code for SDL */
24 24
25 #if defined (_WIN32_WCE) 25 #include "SDL_config.h"
26 #define NO_SIGNAL_H
27 #endif
28 26
29 #include <stdio.h> 27 #ifdef HAVE_SIGNAL_H
30 #ifndef NO_SIGNAL_H
31 #include <signal.h> 28 #include <signal.h>
32 #endif 29 #endif
33 30
34 #include "SDL_events.h" 31 #include "SDL_events.h"
35 #include "SDL_events_c.h" 32 #include "SDL_events_c.h"
36 33
37 34
38 #ifndef NO_SIGNAL_H 35 #ifdef HAVE_SIGNAL_H
39 static void SDL_HandleSIG(int sig) 36 static void SDL_HandleSIG(int sig)
40 { 37 {
41 /* Reset the signal handler */ 38 /* Reset the signal handler */
42 signal(sig, SDL_HandleSIG); 39 signal(sig, SDL_HandleSIG);
43 40
44 /* Signal a quit interrupt */ 41 /* Signal a quit interrupt */
45 SDL_PrivateQuit(); 42 SDL_PrivateQuit();
46 } 43 }
47 #endif /* NO_SIGNAL_H */ 44 #endif /* HAVE_SIGNAL_H */
48 45
49 /* Public functions */ 46 /* Public functions */
50 int SDL_QuitInit(void) 47 int SDL_QuitInit(void)
51 { 48 {
52 #ifndef NO_SIGNAL_H 49 #ifdef HAVE_SIGNAL_H
53 void (*ohandler)(int); 50 void (*ohandler)(int);
54 51
55 /* Both SIGINT and SIGTERM are translated into quit interrupts */ 52 /* Both SIGINT and SIGTERM are translated into quit interrupts */
56 ohandler = signal(SIGINT, SDL_HandleSIG); 53 ohandler = signal(SIGINT, SDL_HandleSIG);
57 if ( ohandler != SIG_DFL ) 54 if ( ohandler != SIG_DFL )
58 signal(SIGINT, ohandler); 55 signal(SIGINT, ohandler);
59 ohandler = signal(SIGTERM, SDL_HandleSIG); 56 ohandler = signal(SIGTERM, SDL_HandleSIG);
60 if ( ohandler != SIG_DFL ) 57 if ( ohandler != SIG_DFL )
61 signal(SIGTERM, ohandler); 58 signal(SIGTERM, ohandler);
62 #endif /* NO_SIGNAL_H */ 59 #endif /* HAVE_SIGNAL_H */
63 60
64 /* That's it! */ 61 /* That's it! */
65 return(0); 62 return(0);
66 } 63 }
67 void SDL_QuitQuit(void) 64 void SDL_QuitQuit(void)
68 { 65 {
69 #ifndef NO_SIGNAL_H 66 #ifdef HAVE_SIGNAL_H
70 void (*ohandler)(int); 67 void (*ohandler)(int);
71 68
72 ohandler = signal(SIGINT, SIG_DFL); 69 ohandler = signal(SIGINT, SIG_DFL);
73 if ( ohandler != SDL_HandleSIG ) 70 if ( ohandler != SDL_HandleSIG )
74 signal(SIGINT, ohandler); 71 signal(SIGINT, ohandler);
75 ohandler = signal(SIGTERM, SIG_DFL); 72 ohandler = signal(SIGTERM, SIG_DFL);
76 if ( ohandler != SDL_HandleSIG ) 73 if ( ohandler != SDL_HandleSIG )
77 signal(SIGTERM, ohandler); 74 signal(SIGTERM, ohandler);
78 #endif /* NO_SIGNAL_H */ 75 #endif /* HAVE_SIGNAL_H */
79 } 76 }
80 77
81 /* This function returns 1 if it's okay to close the application window */ 78 /* This function returns 1 if it's okay to close the application window */
82 int SDL_PrivateQuit(void) 79 int SDL_PrivateQuit(void)
83 { 80 {