summaryrefslogtreecommitdiffstats
path: root/loader/lang.c
diff options
context:
space:
mode:
authorMatt Wilson <msw@redhat.com>1999-09-13 05:28:46 +0000
committerMatt Wilson <msw@redhat.com>1999-09-13 05:28:46 +0000
commit19c59d8a6e69dff0bb1405258f22c767280edb13 (patch)
treeb280bf6ac3f10e472af1a2afa78dc076611b4a79 /loader/lang.c
parente853aed1366acd9465cb540acc99cd1f4d87b527 (diff)
downloadanaconda-19c59d8a6e69dff0bb1405258f22c767280edb13.tar.gz
anaconda-19c59d8a6e69dff0bb1405258f22c767280edb13.tar.xz
anaconda-19c59d8a6e69dff0bb1405258f22c767280edb13.zip
more i18nr0-7-2
Diffstat (limited to 'loader/lang.c')
-rw-r--r--loader/lang.c297
1 files changed, 291 insertions, 6 deletions
diff --git a/loader/lang.c b/loader/lang.c
index 272f2bfd6..15d725025 100644
--- a/loader/lang.c
+++ b/loader/lang.c
@@ -11,11 +11,17 @@
#include <unistd.h>
#include <zlib.h>
#include <rpm/rpmio.h>
+#include <linux/keyboard.h>
+#include <linux/kd.h>
#include "isys/cpio.h"
#include "loader.h"
#include "lang.h"
#include "log.h"
+#include "windows.h"
+
+#define errorWindow(String) \
+ newtWinMessage(_("Error"), _("OK"), String, strerror (errno));
struct aString {
unsigned int hash;
@@ -72,12 +78,15 @@ static const struct langInfo languages[] = {
{ "German", "de", "lat0-sun16", "iso15", "de_DE" },
{ "Hungarian", "hu", "lat2-sun16", "iso02", "hu_HU" },
{ "Icelandic", "is", "lat0-sun16", "iso15", "is_IS" },
+ { "Indonesian", "id", "lat0-sun16", "iso01", "id_ID" },
{ "Italian", "it", "lat0-sun16", "iso15", "it_IT" },
{ "Norwegian", "no", "lat0-sun16", "iso15", "no_NO" },
+ { "Polish", "pl", "lat2-sun16", "iso02", "pl_PL" },
{ "Romanian", "ro", "lat2-sun16", "iso02", "ro_RO" },
{ "Slovak", "sk", "lat2-sun16", "iso02", "sk_SK" },
+ { "Spanish", "es", "lat0-sun16", "iso01", "es_MX" },
{ "Russian", "ru", "Cyr_a8x16", "koi2alt", "ru_SU" },
- { "Ukrainian", "uk", "RUSCII_8x16", "koi2alt", "uk_UA" },
+ { "Ukrainian", "uk", "RUSCII_8x16", "koi2alt", "uk_UA" },
};
/* FONT LIST ENDS */
const int numLanguages = sizeof(languages) / sizeof(struct langInfo);
@@ -107,7 +116,7 @@ void loadLanguage (char * file, int flags) {
stream = fdOpen(file, O_RDONLY, 0644);
if (fdFileno(stream) < 0) {
- newtWinMessage("Error", "Ok", "Cannot open %s: %s. Installation will "
+ newtWinMessage("Error", "OK", "Cannot open %s: %s. Installation will "
"proceed in English.", file, strerror(errno));
return ;
}
@@ -118,14 +127,14 @@ void loadLanguage (char * file, int flags) {
fdClose(stream);
if (rc || access("/tmp/translation", R_OK)) {
- newtWinMessage("Error", "Ok", "Cannot get translation file %s.\n",
+ newtWinMessage("Error", "OK", "Cannot get translation file %s.\n",
filename);
return;
}
fd = open("/tmp/translation", O_RDONLY);
if (fd < 0) {
- newtWinMessage("Error", "Ok", "Failed to open /tmp/translation: %s\n",
+ newtWinMessage("Error", "OK", "Failed to open /tmp/translation: %s\n",
strerror(errno));
return;
}
@@ -161,10 +170,12 @@ static int loadFont(char * fontFile, int flags) {
FD_t stream;
int rc;
+#if 0
if (!FL_TESTING(flags)) {
+#endif
stream = fdOpen("/etc/fonts.cgz", O_RDONLY, 0644);
if (fdFileno(stream) < 0) {
- newtWinMessage("Error", "Ok",
+ newtWinMessage("Error", "OK",
"Cannot open fonts: %s", strerror(errno));
return LOADER_ERROR;
}
@@ -196,7 +207,9 @@ static int loadFont(char * fontFile, int flags) {
logMessage("PIO_UNISCRNMAP failed: %s", strerror(errno));
fprintf(stderr, "\033(K");
+#if 0
}
+#endif
return 0;
}
@@ -231,7 +244,7 @@ int chooseLanguage(int flags) {
newtWinMenu(_("Choose a Language"), _("What language should be used "
"during the installation process?"), 40, 5, 5, 8,
- langs, &choice, _("Ok"), NULL);
+ langs, &choice, _("OK"), NULL);
if (choice == english) {
/* stick with the default (English) */
@@ -251,5 +264,277 @@ int chooseLanguage(int flags) {
return 0;
}
+struct defaultKeyboardByLang {
+ char * lang, * keyboard;
+} defaultKeyboards[] = {
+ { "de", "de-latin1" },
+ { "fi", "fi-latin1" },
+ { "se", "se-latin1" },
+ { "no", "no-latin1" },
+ { "cs", "cz-lat2" },
+ { "tr", "trq" },
+ { NULL, NULL } };
+
+#ifdef __sparc__
+struct defaultKeyboardByLang
+defaultSunKeyboards[] = {
+ { "fi", "sunt5-fi-latin1" },
+ { "cs", "sunt5-cz-us" },
+ { NULL, NULL } };
+#endif
+
+/* the file pointer must be at the beginning of the section already! */
+static int loadKeymap(gzFile stream) {
+ int console;
+ int kmap, key;
+ struct kbentry entry;
+ int keymaps[MAX_NR_KEYMAPS];
+ int count = 0;
+ int magic;
+ short keymap[NR_KEYS];
+
+ if (gzread(stream, &magic, sizeof(magic)) != sizeof(magic)) {
+ logMessage("failed to read kmap magic: %s", strerror(errno));
+ return LOADER_ERROR;
+ }
+
+ if (magic != KMAP_MAGIC) {
+ logMessage("bad magic for keymap!");
+ return LOADER_ERROR;
+ }
+
+ if (gzread(stream, keymaps, sizeof(keymaps)) != sizeof(keymaps)) {
+ logMessage("failed to read keymap header: %s", strerror(errno));
+ return LOADER_ERROR;
+ }
+
+
+ console = open("/dev/console", O_RDWR);
+ if (console < 0) {
+ logMessage("failed to open /dev/console: %s", strerror(errno));
+ return LOADER_ERROR;
+ }
+
+ for (kmap = 0; kmap < MAX_NR_KEYMAPS; kmap++) {
+ if (!keymaps[kmap]) continue;
+
+ if (gzread(stream, keymap, sizeof(keymap)) != sizeof(keymap)) {
+ logMessage("failed to read keymap data: %s", strerror(errno));
+ close(console);
+ return LOADER_ERROR;
+ }
+
+ count++;
+ for (key = 0; key < NR_KEYS; key++) {
+ entry.kb_index = key;
+ entry.kb_table = kmap;
+ entry.kb_value = keymap[key];
+ if (KTYP(entry.kb_value) != KT_SPEC) {
+ if (ioctl(console, KDSKBENT, &entry)) {
+ close(console);
+ logMessage("keymap ioctl failed: %s", strerror(errno));
+ }
+ }
+ }
+ }
+
+ logMessage("loaded %d keymap tables", count);
+
+ close(console);
+
+ return 0;
+}
+int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) {
+ int num = -1;
+ int rc;
+ gzFile f;
+ struct kmapHeader hdr;
+ struct kmapInfo * infoTable;
+ char ** argv;
+ int argc;
+ char ** kbds;
+ char buf[16384]; /* I hope this is big enough */
+ int i;
+ char * defkbd = keymap ? *keymap : NULL;
+ struct defaultKeyboardByLang * kbdEntry;
+
+#ifdef __sparc__
+#define KBDTYPE_SUN 0
+#define KBDTYPE_PC 1
+ int kbdtype = -1;
+ int j;
+#endif
+
+ /*if (testing) return 0;*/
+
+#ifdef __sparc__
+ if (kickstart) {
+ kbdtype = KBDTYPE_SUN;
+ if (!ksGetCommand(KS_CMD_KBDTYPE, NULL, &argc, &argv)) {
+ if (argc < 2) {
+ logMessage("no argument passed to keyboard "
+ "kickstart command");
+ } else {
+ if (!strcasecmp (argv[1], "sun"))
+ kbdtype = KBDTYPE_SUN;
+ else if (!strcasecmp (argv[1], "pc"))
+ kbdtype = KBDTYPE_PC;
+ }
+ }
+ } else {
+ char twelve = 12;
+ int fd;
+
+ if (ioctl (0, TIOCLINUX, &twelve) < 0)
+ kbdtype = KBDTYPE_SUN; /* probably serial console, but one should not call us in such a case */
+ else {
+ fd = open("/dev/kbd", O_RDWR);
+ if (fd < 0)
+ kbdtype = KBDTYPE_PC; /* if PC keyboard, then there is no driver for /dev/kbd */
+ else {
+ close(fd);
+ kbdtype = KBDTYPE_SUN;
+ }
+ }
+ }
+#endif
+
+ if (!defkbd && getenv("LANG")) {
+ kbdEntry = defaultKeyboards;
+#ifdef __sparc__
+ if (kbdtype == KBDTYPE_SUN)
+ kbdEntry = defaultSunKeyboards;
+#endif
+ while (kbdEntry->lang &&
+ strcmp(kbdEntry->lang, getenv("LANG")))
+ kbdEntry++;
+ if (kbdEntry->keyboard) defkbd = kbdEntry->keyboard;
+ }
+ if (!defkbd)
+#ifdef __sparc__
+ if (kbdtype == KBDTYPE_SUN)
+ defkbd = "sunkeymap";
+ else
+#endif
+ defkbd = "us";
+ f = gzopen("/etc/keymaps.gz", "r");
+ if (!f) {
+ errorWindow("cannot open /etc/keymaps.gz: %s");
+ return LOADER_ERROR;
+ }
+
+ if (gzread(f, &hdr, sizeof(hdr)) != sizeof(hdr)) {
+ errorWindow("failed to read keymaps header: %s");
+ gzclose(f);
+ return LOADER_ERROR;
+ }
+
+ logMessage("%d keymaps are available", hdr.numEntries);
+
+ i = hdr.numEntries * sizeof(*infoTable);
+ infoTable = alloca(i);
+ if (gzread(f, infoTable, i) != i) {
+ errorWindow("failed to read keymap information: %s");
+ gzclose(f);
+ return LOADER_ERROR;
+ }
+
+#if 0
+ if (kickstart) {
+ if (!ksGetCommand(KS_CMD_KEYBOARD, NULL, &argc, &argv)) {
+ if (argc < 2) {
+ logMessage("no argument passed to keyboard "
+ "kickstart command");
+ } else {
+ for (i = 0; i < hdr.numEntries; i++)
+ if (!strcmp(infoTable[i].name, argv[1])) break;
+#ifdef __sparc__
+ if (i < hdr.numEntries) {
+ if (kbdtype == KBDTYPE_SUN && strncmp (argv[1], "sun", 3))
+ i = hdr.numEntries;
+ else if (kbdtype == KBDTYPE_PC && !strncmp (argv[1], "sun", 3))
+ i = hdr.numEntries;
+ }
+#endif
+ if (i < hdr.numEntries)
+ num = i;
+ else
+ newtWinMessage("Kickstart Error", "OK", "Bad keymap "
+ "name %s passed to kickstart command.",
+ argv[1]);
+ }
+ }
+ }
+#endif
+
+ if (num == -1 ) {
+#ifdef __sparc__
+ kbds = alloca(sizeof(*kbds) * (hdr.numEntries + 1));
+ for (j = 0, i = 0; j < hdr.numEntries; j++) {
+ if (kbdtype == KBDTYPE_SUN && strncmp (infoTable[j].name, "sun", 3))
+ continue;
+ else if (kbdtype == KBDTYPE_PC && !strncmp (infoTable[j].name, "sun", 3))
+ continue;
+ kbds[i] = infoTable[j].name;
+ if (!strcmp(infoTable[j].name, defkbd))
+ num = i;
+ i++;
+ }
+#else
+ kbds = alloca(sizeof(*kbds) * (hdr.numEntries + 1));
+ for (i = 0; i < hdr.numEntries; i++) {
+ kbds[i] = infoTable[i].name;
+ if (!strcmp(infoTable[i].name, defkbd))
+ num = i;
+ }
+#endif
+
+ kbds[i] = NULL;
+
+ rc = newtWinMenu(_("Keyboard Type"),
+ _("What type of keyboard do you have?"),
+ 40, 5, 5, 8, kbds, &num, _("OK"), _("Back"), NULL);
+ if (rc == 2) return LOADER_BACK;
+ }
+
+ rc = 0;
+
+#ifdef __sparc__
+ for (j = 0, i = 0; i < hdr.numEntries; i++) {
+ if (kbdtype == KBDTYPE_SUN && strncmp (infoTable[i].name, "sun", 3))
+ continue;
+ if (kbdtype == KBDTYPE_PC && !strncmp (infoTable[i].name, "sun", 3))
+ continue;
+ if (j == num) {
+ num = i;
+ break;
+ }
+ j++;
+ }
+#endif
+
+ logMessage("using keymap %s", infoTable[num].name);
+
+ for (i = 0; i < num; i++) {
+ if (gzread(f, buf, infoTable[i].size) != infoTable[i].size) {
+ logMessage("error reading %d bytes from file: %s",
+ infoTable[i].size, strerror(errno));
+ gzclose(f);
+ rc = LOADER_ERROR;
+ }
+ }
+
+ if (!rc) rc = loadKeymap(f);
+
+ gzclose(f);
+
+ if (keymap) *keymap = strdup(infoTable[num].name);
+
+#ifdef __sparc__
+ if (kbdtypep) *kbdtypep = (kbdtype == KBDTYPE_SUN) ? "sun" : "pci";
+#endif
+
+ return rc;
+}