Various fixex to make HEAD compile.
[reactos.git] / reactos / subsys / system / 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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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 <windows.h>
28 #include <tchar.h>
29 #include <syssetup/syssetup.h>
30 #include <userenv.h>
31
32 #define NTOS_MODE_USER
33 #include <ndk/ntndk.h>
34
35 #define NDEBUG
36 #include <debug.h>
37
38
39 typedef DWORD STDCALL (*PINSTALL_REACTOS)(HINSTANCE hInstance);
40
41
42 /* FUNCTIONS ****************************************************************/
43
44 LPTSTR lstrchr(LPCTSTR s, TCHAR c)
45 {
46 while (*s)
47 {
48 if (*s == c)
49 return (LPTSTR)s;
50 s++;
51 }
52
53 if (c == (TCHAR)0)
54 return (LPTSTR)s;
55
56 return (LPTSTR)NULL;
57 }
58
59
60 static VOID
61 RunNewSetup (HINSTANCE hInstance)
62 {
63 HMODULE hDll;
64 PINSTALL_REACTOS InstallReactOS;
65
66 /* some dlls (loaded by syssetup) need a valid user profile */
67 InitializeProfiles();
68
69 hDll = LoadLibrary (TEXT("syssetup"));
70 if (hDll == NULL)
71 {
72 DPRINT("Failed to load 'syssetup'!\n");
73 return;
74 }
75
76 DPRINT("Loaded 'syssetup'!\n");
77
78 InstallReactOS = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallReactOS");
79 if (InstallReactOS == NULL)
80 {
81 DPRINT("Failed to get address for 'InstallReactOS()'!\n");
82 FreeLibrary (hDll);
83 return;
84 }
85
86 InstallReactOS (hInstance);
87
88 FreeLibrary (hDll);
89 }
90
91
92 int STDCALL
93 WinMain (HINSTANCE hInstance,
94 HINSTANCE hPrevInstance,
95 LPSTR lpCmdLine,
96 int nShowCmd)
97 {
98 LPTSTR CmdLine;
99 LPTSTR p;
100
101 CmdLine = GetCommandLine ();
102
103 DPRINT("CmdLine: <%s>\n",CmdLine);
104
105 p = lstrchr (CmdLine, TEXT('-'));
106 if (p == NULL)
107 return 0;
108
109 if (!lstrcmpi (p, TEXT("-newsetup")))
110 {
111 RunNewSetup (hInstance);
112 }
113
114 #if 0
115 /* Add new setup types here */
116 else if (...)
117 {
118
119 }
120 #endif
121
122 return 0;
123 }
124
125 /* EOF */