[CMAKE]
[reactos.git] / reactos / 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
40 lstrchr(
41 LPCTSTR s,
42 TCHAR c)
43 {
44 while (*s)
45 {
46 if (*s == c)
47 return (LPTSTR)s;
48 s++;
49 }
50
51 if (c == (TCHAR)0)
52 return (LPTSTR)s;
53
54 return (LPTSTR)NULL;
55 }
56
57
58 static
59 VOID
60 RunNewSetup(
61 HINSTANCE hInstance)
62 {
63 HMODULE hDll;
64 PINSTALL_REACTOS InstallReactOS;
65
66 hDll = LoadLibrary(TEXT("syssetup"));
67 if (hDll == NULL)
68 {
69 DPRINT("Failed to load 'syssetup'!\n");
70 return;
71 }
72
73 DPRINT("Loaded 'syssetup'!\n");
74 InstallReactOS = (PINSTALL_REACTOS)GetProcAddress(hDll, "InstallReactOS");
75 if (InstallReactOS == NULL)
76 {
77 DPRINT("Failed to get address for 'InstallReactOS()'!\n");
78 FreeLibrary(hDll);
79 return;
80 }
81
82 InstallReactOS(hInstance);
83
84 FreeLibrary(hDll);
85 }
86
87
88 static
89 VOID
90 RunLiveCD(
91 HINSTANCE hInstance)
92 {
93 HMODULE hDll;
94 PINSTALL_REACTOS InstallLiveCD;
95
96 hDll = LoadLibrary(TEXT("syssetup"));
97 if (hDll == NULL)
98 {
99 DPRINT("Failed to load 'syssetup'!\n");
100 return;
101 }
102
103 DPRINT("Loaded 'syssetup'!\n");
104 InstallLiveCD = (PINSTALL_REACTOS)GetProcAddress(hDll, "InstallLiveCD");
105 if (InstallLiveCD == NULL)
106 {
107 DPRINT("Failed to get address for 'InstallReactOS()'!\n");
108 FreeLibrary(hDll);
109 return;
110 }
111
112 InstallLiveCD(hInstance);
113
114 FreeLibrary(hDll);
115 }
116
117
118 int
119 WINAPI
120 _tWinMain(
121 HINSTANCE hInstance,
122 HINSTANCE hPrevInstance,
123 LPTSTR lpCmdLine,
124 int nShowCmd)
125 {
126 LPTSTR CmdLine;
127 LPTSTR p;
128
129 CmdLine = GetCommandLine();
130
131 DPRINT("CmdLine: <%s>\n",CmdLine);
132
133 p = lstrchr(CmdLine, TEXT('-'));
134 if (p == NULL)
135 return 0;
136
137 if (!lstrcmpi(p, TEXT("-newsetup")))
138 {
139 RunNewSetup(hInstance);
140 }
141 else if (!lstrcmpi(p, TEXT("-mini")))
142 {
143 RunLiveCD(hInstance);
144 }
145
146 #if 0
147 /* Add new setup types here */
148 else if (...)
149 {
150
151 }
152 #endif
153
154 return 0;
155 }
156
157 /* EOF */