]> icculus.org git repositories - taylor/freespace2.git/blob - src/freespace2/unixmain.cpp
clean up app entry a bit
[taylor/freespace2.git] / src / freespace2 / unixmain.cpp
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
4  * All source code herein is the property of Volition, Inc. You may not sell
5  * or otherwise commercially exploit the source or things you created based on
6  * the source.
7  */
8
9 #include <sys/stat.h>
10
11 #include "pstypes.h"
12 #include "osregistry.h"
13 #include "osapi.h"
14
15 #undef malloc
16 #undef free
17
18 extern int game_main(const char *szCmdLine);
19
20 void vm_dump();
21
22
23 int main(int argc, char **argv)
24 {
25         char *argptr = NULL;
26         int i;
27         int len = 0;
28         int retr = 0;
29
30         for (i = 1; i < argc; i++) {
31                 len += strlen(argv[i]) + 1;
32         }
33
34         if (len > 0) {
35                 argptr = (char *)malloc(len+5);
36
37                 if (argptr == NULL) {
38                         fprintf(stderr, "ERROR: out of memory in main!\n");
39                         exit(1);
40                 }
41
42                 memset(argptr, 0, len+5);
43
44                 for (i = 1; i < argc; i++) {
45                         strcat(argptr, argv[i]);
46                         strcat(argptr, " ");
47                 }
48         }
49
50         try {
51                 retr = game_main(argptr);
52         } catch(...) {
53                 mprintf(("ERROR!! Exception caught in main()"));
54                 fprintf(stderr, "ERROR!! Exception caught in main()");
55         }
56
57         if (argptr) {
58                 free(argptr);
59         }
60                 
61         vm_dump();
62         
63         return retr;    
64 }