summaryrefslogtreecommitdiffstats
path: root/private/ntos/arcinst/arcinst.c
blob: 7e81de0f3aa5de3c296dc8b8c2862d58c0c62cbf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*++

Copyright (c) 1991-1996  Microsoft Corporation
Copyright (c) 1992, 1992  Digital Equipment Corporation

Module Name:

    arcinst.c

Abstract:

    This module contains the code that prepares a ARC compliant platform
    for OS installation. It creates system partitions and formats system
    partitions

--*/


#include "precomp.h"
#pragma hdrstop


PCHAR Banner1 = "  Arc Installation Program Version 4.00";
PCHAR Banner2 = "  Copyright (c) 1991-1996 Microsoft Corporation";

//
// Menu definitions
//

PCHAR   rgszMainMenu[] = {
        "Configure Partitions",
        "Exit"

        };


//
// NOTE! This must be the number of entries in rgszMainMenu. It is used
//       to tell AddMenuItems the number of menu items to add.
//

#define CSZMENUITEMS 2


//
// NOTE! These must be kept in sync with the indices for rgszMainMenu
//       The main menu is created by AddMenuItems which will generated
//       associated data values based upon the index into the array of
//       strings passed in. These #defines must match those values
//       or the switch statement used to handle the menu selection will
//       dispatch to the wrong code.
//

#define CONFIG_SYS_PARTITION 0
#define EXIT 1

#define MENU_START_ROW 4
#define ERROR_ROW_TOP 13
#define ERROR_ROW_BOTTOM 16

//
// Max size for a path or environment variable
//

#define MAX_PATH 256

//
// Max bytes in a line
//

#define CBMAXLINE   120

//
// Define constants to generate a 2 meg stack and a 2 meg heap.
//
#define ARCINST_STACK_PAGES (2*1024*1024 / PAGE_SIZE)
#define ARCINST_HEAP_PAGES  (2*1024*1024 / PAGE_SIZE)

ARC_STATUS  GetTitlesAndPaths ( PCHAR, PCHAR, ULONG, ULONG, PCHAR **,PULONG, PCHAR **, PULONG);
ARC_STATUS  GetSectionElementList ( PCHAR, PCHAR, ULONG, PCHAR **, PULONG );
ARC_STATUS  CopySection( PCHAR, PCHAR, PCHAR, PCHAR );
ARC_STATUS  UpdateOSFiles( PCHAR, PCHAR, PCHAR );

VOID        PrintError( PCHAR, ... );

// Needed for C string functions
int errno;

ARC_STATUS __cdecl
main(
    IN  ULONG   argc,
    IN  PCHAR   argv[],
    IN  PCHAR   envp[]
    )
{
    PCHAR       szSysPartition = NULL;
    PCHAR       szInfPath = NULL;
    PVOID       hdMenuId;
    ULONG       MenuChoice;

    DBG_UNREFERENCED_PARAMETER( argc );
    DBG_UNREFERENCED_PARAMETER( argv );
    DBG_UNREFERENCED_PARAMETER( envp );

    if (AlMemoryInitialize (ARCINST_STACK_PAGES, ARCINST_HEAP_PAGES) != ESUCCESS) {

        PrintError(NULL, "Failed to initialize the heap");
        return( ESUCCESS );
    }

    if (!AlInitializeMenuPackage()) {

        PrintError(NULL, "Could not initialize menu package");
        return( ESUCCESS );

    }

    if (FdiskInitialize() != ESUCCESS) {

        PrintError(NULL, "Failed to initialize the FDISK package");
        return( ESUCCESS );

    }

    if (!AlNewMenu(&hdMenuId)) {

        PrintError(NULL, "Could not create main menu");
        return( ESUCCESS );

    }

    //
    // Initialize the main ArcInst menu.
    //
    // Not that when you add items in this way the associated data becomes
    // the index in the array of strings. Make sure the values used for
    // associated data the predefined values CHANGE_ENV etc.
    //

    if (!AlAddMenuItems(hdMenuId, rgszMainMenu, CSZMENUITEMS)) {

        PrintError(NULL, "Failed to Initialize Main Menu");
        return( ESUCCESS );
    }

    //
    // Loop till Exit or an ESC key is it.
    //
    while (TRUE) {

        //
        // Print Banner
        //
        AlClearScreen();
        AlSetPosition(1, 0);
        AlPrint(Banner1);
        AlPrint("\r\n");
        AlPrint(Banner2);

        if (!AlDisplayMenu(hdMenuId,
                           FALSE,
                           CONFIG_SYS_PARTITION,
                           &MenuChoice,
                           MENU_START_ROW,
                           0)) {

            //
            // User hit ESC key
            //
            return( ESUCCESS );

        }

        switch (MenuChoice) {

        case CONFIG_SYS_PARTITION:

            ConfigureSystemPartitions();
            break;

        case EXIT:

            return(ESUCCESS);
            break;

        }
    }
}

VOID
PrintError(
    IN  PCHAR szFormat,
    ...
    )

/*++

Routine Description:

    This routine prints a error or information message at a specific
    location the screen (ERROR_ROW_TOP) and waits for the user to hit
    any key.

Arguments:

    szFormat - Format string, if NULL then "%s" is used.
    szErrorMessage - Text of string to print

Return Value:

    none

--*/

{
    va_list ArgList;

    va_start(ArgList,szFormat);
    if (szFormat == NULL ) {
        szFormat = "%s";
    }
    vAlStatusMsg(ERROR_ROW_TOP, TRUE, szFormat, ArgList);

    AlWaitKey(NULL);
    AlClearStatusArea(ERROR_ROW_TOP, ERROR_ROW_BOTTOM);
}

VOID
JzShowTime (
    BOOLEAN First
    )
{
    return;
}