]> git.saurik.com Git - apple/boot.git/blob - i386/testmodule/install/mode.c
boot-132.tar.gz
[apple/boot.git] / i386 / testmodule / install / mode.c
1 /*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
12 * this file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
20 * under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 #import "libsa.h"
25 #import "libsaio.h"
26 #import "install.h"
27
28 void install_enterInstallMode(void)
29 {
30 int answer, count, size;
31 char *LanguageTable, *val;
32 char *LoadableFamilies;
33
34 /* Load language choice table */
35 loadConfigFile("/usr/standalone/i386/Language.table",
36 &LanguageTable, 1);
37
38 /* Get language choices. */
39 if (LanguageTable &&
40 getValueForStringTableKey(
41 LanguageTable, "Languages", &val, &count))
42 {
43 char *string, *languages[16], *language_strings[16];
44 int nlang = 0;
45
46 while (string = (char *)newStringFromList(&val, &count)) {
47 languages[nlang] = string;
48 language_strings[nlang++] = (char *)
49 newStringForStringTableKey(
50 LanguageTable, string);
51 }
52
53 for(answer = -1; answer == -1;) {
54 install_clearScreen();
55 answer = install_choose(language_strings, nlang,
56 1, nlang);
57 }
58 setLanguage(languages[answer - 1]);
59 while (nlang)
60 zfree(language_strings[nlang--]);
61 /* Don't bother freeing the language names. */
62
63 zfree(LanguageTable);
64 } else {
65 printf("Could not load language choice file; "
66 "defaulting to English.\n");
67 setLanguage("English");
68 }
69
70 /* Now save the language in the "Language" key,
71 * which has cleverly been made large for us.
72 */
73 if (getValueForKey("Language", &val, &size)) {
74 char *Language = getLanguage();
75 if ((strlen(Language)+2) < size) {
76 strcpy(val, Language);
77 val += strlen(Language);
78 *val++ = '\"';
79 *val++ = ';';
80 *val++ = '\n';
81 size -= strlen(Language) + 1;
82 while (size--)
83 *val++ = ' ';
84 }
85 }
86
87 /* Now limit the families we look for when considering
88 * drivers during installation.
89 */
90 if (getValueForKey("Installation Driver Families",
91 &val, &size)) {
92 LoadableFamilies = zalloc(size+1);
93 strncpy(LoadableFamilies,val,size);
94 }
95 }