[CMAKE]
[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 #define WIN32_NO_STATUS
27 #include <windows.h>
28 #include <tchar.h>
29 #include <syssetup/syssetup.h>
30 #include <userenv.h>
31 #include <tchar.h>
32
33 #define NDEBUG
34 #include <debug.h>
35
36
37 typedef DWORD (WINAPI *PINSTALL_REACTOS)(HINSTANCE hInstance);
38
39
40 /* FUNCTIONS ****************************************************************/
41
42 LPTSTR lstrchr(LPCTSTR s, 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 static VOID
58 RunNewSetup (HINSTANCE hInstance)
59 {
60 HMODULE hDll;
61 PINSTALL_REACTOS InstallReactOS;
62
63 hDll = LoadLibrary (TEXT("syssetup"));
64 if (hDll == NULL)
65 {
66 DPRINT("Failed to load 'syssetup'!\n");
67 return;
68 }
69
70 DPRINT("Loaded 'syssetup'!\n");
71 InstallReactOS = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallReactOS");
72
73 if (InstallReactOS == NULL)
74 {
75 DPRINT("Failed to get address for 'InstallReactOS()'!\n");
76 FreeLibrary (hDll);
77 return;
78 }
79
80 InstallReactOS (hInstance);
81
82 FreeLibrary (hDll);
83 }
84
85 static VOID
86 RunLiveCD (HINSTANCE hInstance)
87 {
88 HMODULE hDll;
89 PINSTALL_REACTOS InstallLiveCD;
90
91 hDll = LoadLibrary (TEXT("syssetup"));
92 if (hDll == NULL)
93 {
94 DPRINT("Failed to load 'syssetup'!\n");
95 return;
96 }
97
98 DPRINT("Loaded 'syssetup'!\n");
99 InstallLiveCD = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallLiveCD");
100
101 if (InstallLiveCD == NULL)
102 {
103 DPRINT("Failed to get address for 'InstallReactOS()'!\n");
104 FreeLibrary (hDll);
105 return;
106 }
107
108 InstallLiveCD (hInstance);
109
110 FreeLibrary (hDll);
111 }
112
113 int WINAPI
114 _tWinMain (HINSTANCE hInstance,
115 HINSTANCE hPrevInstance,
116 LPTSTR lpCmdLine,
117 int nShowCmd)
118 {
119 LPTSTR CmdLine;
120 LPTSTR p;
121
122 CmdLine = GetCommandLine ();
123
124 DPRINT("CmdLine: <%s>\n",CmdLine);
125
126 p = lstrchr (CmdLine, TEXT('-'));
127 if (p == NULL)
128 return 0;
129
130 if (!lstrcmpi (p, TEXT("-newsetup")))
131 {
132 RunNewSetup (hInstance);
133 }
134 else if (!lstrcmpi (p, TEXT("-mini")))
135 {
136 RunLiveCD (hInstance);
137 }
138
139 #if 0
140 /* Add new setup types here */
141 else if (...)
142 {
143
144 }
145 #endif
146
147 return 0;
148 }
149
150 /* EOF */