update for HEAD-2003091401
[reactos.git] / 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
30 #include <syssetup.h>
31
32 #define DEBUG
33
34 typedef DWORD STDCALL (*PINSTALL_REACTOS)(HINSTANCE hInstance);
35
36
37 /* FUNCTIONS ****************************************************************/
38
39
40 LPTSTR lstrchr(LPCTSTR s, TCHAR c)
41 {
42   while (*s)
43     {
44       if (*s == c)
45         return (LPTSTR)s;
46       s++;
47     }
48
49   if (c == (TCHAR)0)
50     return (LPTSTR)s;
51
52   return (LPTSTR)NULL;
53 }
54
55
56 static VOID
57 RunNewSetup (HINSTANCE hInstance)
58 {
59   HMODULE hDll;
60   PINSTALL_REACTOS InstallReactOS;
61
62   hDll = LoadLibrary (TEXT("syssetup"));
63   if (hDll == NULL)
64     {
65 #ifdef DEBUG
66       OutputDebugString (TEXT("Failed to load 'syssetup'!\n"));
67 #endif
68       return;
69     }
70
71 #ifdef DEBUG
72   OutputDebugString (TEXT("Loaded 'syssetup'!\n"));
73 #endif
74
75   InstallReactOS = (PINSTALL_REACTOS)GetProcAddress (hDll, "InstallReactOS");
76   if (InstallReactOS == NULL)
77     {
78 #ifdef DEBUG
79       OutputDebugString (TEXT("Failed to get address for 'InstallReactOS()'!\n"));
80 #endif
81       FreeLibrary (hDll);
82       return;
83     }
84
85   InstallReactOS (hInstance);
86
87   FreeLibrary (hDll);
88 }
89
90
91 int STDCALL
92 WinMain (HINSTANCE hInstance,
93          HINSTANCE hPrevInstance,
94          LPSTR lpCmdLine,
95          int nShowCmd)
96 {
97   LPTSTR CmdLine;
98   LPTSTR p;
99
100   CmdLine = GetCommandLine ();
101
102 #ifdef DEBUG
103   OutputDebugString (TEXT("CmdLine: <"));
104   OutputDebugString (CmdLine);
105   OutputDebugString (TEXT(">\n"));
106 #endif
107
108   p = lstrchr (CmdLine, TEXT('-'));
109   if (p == NULL)
110     return 0;
111
112   if (!lstrcmpi (p, TEXT("-newsetup")))
113     {
114       RunNewSetup (hInstance);
115     }
116
117 #if 0
118   /* Add new setup types here */
119   else if (...)
120     {
121
122     }
123 #endif
124
125   return 0;
126 }
127
128 /* EOF */