Sync to trunk revision 61757.
[reactos.git] / base / setup / setup / setup.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2003 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 /*
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS GUI/console setup
22 * FILE: subsys/system/setup/setup.c
23 * PURPOSE: Second stage setup
24 * PROGRAMMER: Eric Kohl
25 */
26
27 #include <stdarg.h>
28 #include <windef.h>
29 #include <winbase.h>
30 #include <tchar.h>
31
32 #define NDEBUG
33 #include <debug.h>
34
35 typedef DWORD (WINAPI *PINSTALL_REACTOS)(HINSTANCE hInstance);
36
37 /* FUNCTIONS ****************************************************************/
38
39 LPTSTR lstrchr(LPCTSTR s, TCHAR c)
40 {
41 while (*s)
42 {
43 if (*s == c)
44 return (LPTSTR)s;
45 s++;
46 }
47
48 if (c == (TCHAR)0)
49 return (LPTSTR)s;
50
51 return (LPTSTR)NULL;
52 }
53
54 static VOID
55 RunNewSetup (HINSTANCE hInstance)
56 {
57 HMODULE hDll;
58 PINSTALL_REACTOS InstallReactOS;
59
60 hDll = LoadLibrary (TEXT("syssetup"));
61 if (hDll == NULL)
62 {
63 DPRINT("Failed to load 'syssetup'!\n");
64 return;
65 }
66
67 DPRINT("Loaded 'syssetup'!\n");
68 InstallReactOS = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallReactOS");
69
70 if (InstallReactOS == NULL)
71 {
72 DPRINT("Failed to get address for 'InstallReactOS()'!\n");
73 FreeLibrary (hDll);
74 return;
75 }
76
77 InstallReactOS (hInstance);
78
79 FreeLibrary (hDll);
80 }
81
82 static VOID
83 RunLiveCD (HINSTANCE hInstance)
84 {
85 HMODULE hDll;
86 PINSTALL_REACTOS InstallLiveCD;
87
88 hDll = LoadLibrary (TEXT("syssetup"));
89 if (hDll == NULL)
90 {
91 DPRINT("Failed to load 'syssetup'!\n");
92 return;
93 }
94
95 DPRINT("Loaded 'syssetup'!\n");
96 InstallLiveCD = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallLiveCD");
97
98 if (InstallLiveCD == NULL)
99 {
100 DPRINT("Failed to get address for 'InstallReactOS()'!\n");
101 FreeLibrary (hDll);
102 return;
103 }
104
105 InstallLiveCD (hInstance);
106
107 FreeLibrary (hDll);
108 }
109
110 int WINAPI
111 _tWinMain (HINSTANCE hInstance,
112 HINSTANCE hPrevInstance,
113 LPTSTR lpCmdLine,
114 int nShowCmd)
115 {
116 LPTSTR CmdLine;
117 LPTSTR p;
118
119 CmdLine = GetCommandLine ();
120
121 DPRINT("CmdLine: <%s>\n",CmdLine);
122
123 p = lstrchr (CmdLine, TEXT('-'));
124 if (p == NULL)
125 return 0;
126
127 if (!lstrcmpi (p, TEXT("-newsetup")))
128 {
129 RunNewSetup (hInstance);
130 }
131 else if (!lstrcmpi (p, TEXT("-mini")))
132 {
133 RunLiveCD (hInstance);
134 }
135
136 #if 0
137 /* Add new setup types here */
138 else if (...)
139 {
140
141 }
142 #endif
143
144 return 0;
145 }
146
147 /* EOF */