File: xscorch.c

package info (click to toggle)
xscorch 0.2.0-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny
  • size: 4,636 kB
  • ctags: 3,399
  • sloc: ansic: 31,504; sh: 8,826; makefile: 467; perl: 16
file content (101 lines) | stat: -rw-r--r-- 2,622 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* $Header: /fridge/cvs/xscorch/xscorch.c,v 1.11 2004/03/10 21:52:42 jacob Exp $ */
/*

   xscorch - xscorch.c        Copyright(c) 2000-2004 Justin David Smith
                              Copyright(c) 2000-2004 Jacob Luna Lundberg
   justins(at)chaos2.org      http://chaos2.org/
   jacob(at)chaos2.org        http://chaos2.org/~jacob

   Scorched Earth, main function


   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, version 2 of the License ONLY.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/
#define  _POSIX_SOURCE     /* Needed for signal handling */
#define  _GNU_SOURCE       /* Needed for signal handling */

#include <signal.h>
#include <stdio.h>
#include <stdlib.h>

#include <xscorch.h>
#include <sconfig.h>
#include <sinfo.h>
#include <sland.h>
#include <swindow.h>



#if !HAVE_GETTIMEOFDAY
#error "This program requires gettimeofday()"
#endif



void sc_signal_handler(int sig) {
/* sc_sig_handler
   Extensible signal handler for xscorch. */

   switch(sig) {
      case SIGPIPE:
         /* SIGPIPE will most likely be a dead net cnxn.
            We try to ignore it and sort of hope for the best... */
         fprintf(stderr, "xscorch: Got SIGPIPE; there goes the neighborhood...\n");
         break;
      default:
         ;
   }

}



int main(int argc, char **argv) {

   struct sigaction sa;
   sigset_t sigset;
   sc_config *c;
   sc_window *w;

   /* Signal handlers */
   sigemptyset(&sigset);
   sigaddset(&sigset, SIGPIPE);
   sa.sa_handler = sc_signal_handler;
   sa.sa_mask = sigset;
   sa.sa_flags = 0;
   sigaction(SIGPIPE, &sa, NULL);

   /* Tell them what they've won! */
   sc_info();

   /* Create game configuration, X window.
      Parse command line options, and load
      images.                              */
   if(!(c = sc_config_new(&argc, &argv))) return(1);
   if(!(w = sc_window_new(c, argc, argv))) return(1);

   sc_land_generate(c, c->land);

   sc_window_run(w);

   /* Release all data */
   sc_window_free(&w);
   sc_config_free(&c);

   printf("War is the science of destruction.  -- John Abbott\n");

   return(0);

}