rnd-20040821-2-src
[rocksndiamonds.git] / src / game_em / main.c
1 /* Emerald Mine
2  * 
3  * David Tritscher
4  * 
5  * v0.0 2000-01-06T06:43:39Z
6  *
7  * set everything up and close everything down
8  */
9
10 #include <stdlib.h>
11 #include <unistd.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include <errno.h>
15
16 #include "global.h"
17
18
19 #if defined(TARGET_X11)
20
21 char *progname;
22 char *arg_basedir;
23 char *arg_display;
24 char *arg_geometry;
25 int arg_install;
26 int arg_silence;
27
28 extern void tab_generate();
29 extern void ulaw_generate();
30
31 void em_open_all()
32 {
33   /* pre-calculate some data */
34   tab_generate();
35   ulaw_generate();
36
37   progname = "emerald mine";
38
39   if (open_all() != 0)
40     Error(ERR_EXIT, "em_open_all(): open_all() failed");
41 }
42
43 void em_close_all()
44 {
45   close_all();
46 }
47
48 void em_main()
49 {
50 #if 0
51   em_open_all();
52 #endif
53
54   if (game_start() != 0)
55     Error(ERR_EXIT, "em_main(): game_start() failed");
56
57 #if 0
58   em_close_all();
59 #endif
60 }
61
62 /* massive kludge for buffer overflows
63  * i cant think of an elegant way to handle this situation.
64  * oh wait yes i can. dynamically allocate each string. oh well
65  */
66 void snprintf_overflow(char *description)
67 {
68   fprintf(stderr, "%s: %s\n", progname,
69           "buffer overflow; check EMERALD_BASE environment variable");
70   fprintf(stderr, "%s %s\n", "Fault occured while attempting to", description);
71
72   abort();
73 }
74
75 #else
76
77 int em_main()
78 {
79   /* temporary dummy until X11->SDL conversion finished */
80   return 0;
81 }
82
83 #endif