]> icculus.org git repositories - taylor/freespace2.git/blob - src/freespace2/unixmain.cpp
command line
[taylor/freespace2.git] / src / freespace2 / unixmain.cpp
1 #include "pstypes.h"
2 #include "osregistry.h"
3
4 int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow);
5 void vm_dump();
6
7 int main(int argc, char **argv)
8 {
9         /* set some sane defaults since we don't have a laucher... */
10         if (os_config_read_string(NULL, NOX("Videocard"), NULL) == NULL)
11                 os_config_write_string(NULL, NOX("Videocard"), NOX("OpenGL (640x480)"));
12         
13         if (os_config_read_string(NULL, NOX("NetworkConnection"), NULL) == NULL)
14                 os_config_write_string(NULL, NOX("NetworkConnection"), NOX("lan"));
15         
16         if (os_config_read_string(NULL, NOX("ConnectionSpeed"), NULL) == NULL)
17                 os_config_write_string(NULL, NOX("ConnectionSpeed"), NOX("Slow"));              
18         
19         char *argptr = NULL;
20         int i;
21         int len = 1;
22         
23         argptr = (char *)malloc(1);
24         *argptr = 0;
25         
26         for (i = 1; i < argc; i++) {
27                 int oldlen = len-1;
28                 
29                 len += strlen(argv[i])+1;
30                 
31                 argptr = (char *)realloc(argptr, len);
32                 if (argptr == NULL) {
33                         fprintf(stderr, "ERROR: out of memory in main!\n");
34                         exit(1);
35                 }
36                 
37                 strcpy(argptr+oldlen, argv[i]);
38                 strcat(argptr, " ");
39         }
40          
41         int retr = WinMain(1, 0, argptr, 0);
42
43         free(argptr);
44                 
45         vm_dump();
46         
47         return retr;    
48 }