summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/mount.c
blob: 918f5d1a2f88e22a6b3d80cdb9b64d6452c565c3 (plain)
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
 * Guillaume Cottenceau (gc)
 *
 * Copyright 2000 Mandriva
 *
 * This software may be freely redistributed under the terms of the GNU
 * public license.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/*
 * Portions from Erik Troan (ewt@redhat.com)
 *
 * Copyright 1996 Red Hat Software 
 *
 */

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "log.h"
#include "utils.h"
#include "modules.h"

#include "mount.h"



/* WARNING: this won't work if the argument is not /dev/ based */
int ensure_dev_exists(const char * dev)
{
	int major, minor;
	int type = S_IFBLK; /* my default type is block. don't forget to change for chars */
	const char * name;
	struct stat buf;
	char * ptr;
	
	name = &dev[5]; /* we really need that dev be passed as /dev/something.. */

	if (!stat(dev, &buf))
		return 0; /* if the file already exists, we assume it's correct */

	if (ptr_begins_static_str(name, "sd")) {
		/* SCSI disks */
		major = 8;
		minor = (name[2] - 'a') << 4;
		if (name[3] && name[4]) {
			minor += 10 + (name[4] - '0');
			if (name[3] > 1 || name[4] > 5) {
				log_message("I don't know how to create device %s, please post bugreport to me!", dev);
				return -1;
			}
		} else if (name[3])
			minor += (name[3] - '0');
	} else if (ptr_begins_static_str(name, "vd")) {
		/* Virtual disks */
		major = 252;
		minor = (name[2] - 'a') << 4;
		if (name[3] && name[4]) {
			minor += 10 + (name[4] - '0');
			if (name[3] > 1 || name[4] > 5) {
				log_message("I don't know how to create device %s, please post bugreport to me!", dev);
				return -1;
			}
		} else if (name[3])
			minor += (name[3] - '0');
	} else if (ptr_begins_static_str(name, "xvd")) {
		/* Virtual disks */
		major = 202;
		minor = (name[2] - 'a') << 4;
		if (name[4] && name[5]) {
			minor += 10 + (name[5] - '0');
			if (name[4] > 1 || name[5] > 5) {
				log_message("I don't know how to create device %s, please post bugreport to me!", dev);
				return -1;
			}
		} else if (name[4])
			minor += (name[4] - '0');
	} else if (ptr_begins_static_str(name, "hd")) {
		/* IDE disks/cd's */
		if (name[2] == 'a')
			major = 3, minor = 0;
		else if (name[2] == 'b')
			major = 3, minor = 64;
		else if (name[2] == 'c')
			major = 22, minor = 0;
		else if (name[2] == 'd')
			major = 22, minor = 64;
		else if (name[2] == 'e')
			major = 33, minor = 0;
		else if (name[2] == 'f')
			major = 33, minor = 64;
		else if (name[2] == 'g')
			major = 34, minor = 0;
		else if (name[2] == 'h')
			major = 34, minor = 64;
		else if (name[2] == 'i')
			major = 56, minor = 0;
		else if (name[2] == 'j')
			major = 56, minor = 64;
		else if (name[2] == 'k')
			major = 57, minor = 0;
		else if (name[2] == 'l')
			major = 57, minor = 64;
		else if (name[2] == 'm')
			major = 88, minor = 0;
		else if (name[2] == 'n')
			major = 88, minor = 64;
		else if (name[2] == 'o')
			major = 89, minor = 0;
		else if (name[2] == 'p')
			major = 89, minor = 64;
		else if (name[2] == 'q')
			major = 90, minor = 0;
		else if (name[2] == 'r')
			major = 90, minor = 64;
		else if (name[2] == 's')
			major = 91, minor = 0;
		else if (name[2] == 't')
			major = 91, minor = 64;
		else
			return -1;
		
		if (name[3] && name[4])
			minor += 10 + (name[4] - '0');
		else if (name[3])
			minor += (name[3] - '0');
	} else if (ptr_begins_static_str(name , "sr")) {
		/* SCSI cd's */
		major = 11;
		minor = name[2] - '0';
	} else if (ptr_begins_static_str(name, "ida/") ||
		   ptr_begins_static_str(name, "cciss/")) {
		/* Compaq Smart Array "ida/c0d0{p1}" */
		ptr = strchr(name, '/');
		mkdir("/dev/ida", 0755);
		mkdir("/dev/cciss", 0755);
		major = ptr_begins_static_str(name, "ida/") ? 72 : 104 + charstar_to_int(ptr+2);
		ptr = strchr(ptr, 'd');
		minor = 16 * charstar_to_int(ptr+1);
		ptr = strchr(ptr, 'p');
		minor += charstar_to_int(ptr+1);
	} else if (ptr_begins_static_str(name, "rd/")) {
		/* DAC960 "rd/cXdXXpX" */
		mkdir("/dev/rd", 0755);
		major = 48 + charstar_to_int(name+4);
		ptr = strchr(name+4, 'd');
		minor = 8 * charstar_to_int(ptr+1);
		ptr = strchr(ptr, 'p');
		minor += charstar_to_int(ptr+1);
	} else if (ptr_begins_static_str(name, "loop")) {
		major = 7;
		minor = name[4] - '0';
	} else if (ptr_begins_static_str(name, "chloop")) {
		major = 100;
		minor = name[6] - '0';
	} else {
		log_message("I don't know how to create device %s, please post bugreport to me!", dev);
		return -1;
	}

	if (mknod(dev, type | 0600, makedev(major, minor))) {
		log_perror(dev);
		return -1;
	}
	
	return 0;
}


/* mounts, creating the device if needed+possible */
int my_mount(char *dev, char *location, char *fs, int force_rw)
{
	unsigned long flags = MS_MGC_VAL | (force_rw ? 0 : MS_RDONLY);
	char * opts = NULL;
	struct stat buf;
	int rc;

	if (strcmp(fs, "nfs")) {
	    rc = ensure_dev_exists(dev);
	    if (rc != 0) {
		    log_message("could not create required device file");
		    return -1;
	    }
	}

	log_message("mounting %s on %s as type %s", dev, location, fs);

	if (stat(location, &buf)) {
		if (mkdir(location, 0755)) {
			log_perror("could not create location dir");
			return -1;
		}
	} else if (!S_ISDIR(buf.st_mode)) {
		log_message("not a dir %s, will unlink and mkdir", location);
		if (unlink(location)) {
			log_perror("could not unlink");
			return -1;
		}
		if (mkdir(location, 0755)) {
			log_perror("could not create location dir");
			return -1;
		}
	}

	if (!strcmp(fs, "supermount")) {
		my_insmod("supermount", ANY_DRIVER_TYPE, NULL, 1);
		my_insmod("isofs", ANY_DRIVER_TYPE, NULL, 1);
		opts = alloca(500);
                sprintf(opts, "dev=%s,fs=iso9660,tray_lock=always", dev);
                dev = "none";
	}

#ifndef DISABLE_MEDIAS
	if (!strcmp(fs, "vfat")) {
		my_insmod("nls_cp437", ANY_DRIVER_TYPE, NULL, 1);
		my_insmod("nls_iso8859_1", ANY_DRIVER_TYPE, NULL, 1);
		my_insmod("vfat", ANY_DRIVER_TYPE, NULL, 1);
		opts = "check=relaxed";
	}

	if (!strcmp(fs, "ntfs")) {
		my_insmod("ntfs", ANY_DRIVER_TYPE, NULL, 1);
	}

	if (!strcmp(fs, "reiserfs"))
		my_insmod("reiserfs", ANY_DRIVER_TYPE, NULL, 1);

	if (!strcmp(fs, "reiser4"))
		my_insmod("reiser4", ANY_DRIVER_TYPE, NULL, 1);

	if (!strcmp(fs, "jfs"))
		my_insmod("jfs", ANY_DRIVER_TYPE, NULL, 1);

	if (!strcmp(fs, "xfs"))
		my_insmod("xfs", ANY_DRIVER_TYPE, NULL, 1);

	if (!strcmp(fs, "ext4"))
		my_insmod("ext4", ANY_DRIVER_TYPE, NULL, 1);

	if (!strcmp(fs, "btrfs"))
		my_insmod("btrfs", ANY_DRIVER_TYPE, NULL, 1);

#endif
	if (!strcmp(fs, "iso9660"))
		my_insmod("isofs", ANY_DRIVER_TYPE, NULL, 1);

#ifndef DISABLE_NETWORK
	if (!strcmp(fs, "nfs")) {
		my_insmod("nfs", ANY_DRIVER_TYPE, NULL, 1);
		log_message("preparing nfsmount for %s", dev);
		rc = nfsmount_prepare(dev, &opts);
		if (rc != 0)
			return rc;
	}
#endif

	rc = mount(dev, location, fs, flags, opts);
	if (rc != 0) {
		log_perror("mount failed");
		rmdir(location);
	}

	return rc;
}
'iso-8859-2', 'hr', 'hr' ], 'hu' => [ 'Hungarian', 'iso-8859-2', 'hu', 'hu' ], #'hy_AM.ARMSCII-8'=> [ 'Armenian|ARMSCII-8','armscii-8','hy','hy' ], 'hy_AM.UTF-8'=> [ 'Armenian', 'utf_hy', 'hy', 'hy' ], #- 'in' was the old code for indonesian language; by putting LANGUAGE=id:in_ID #- we catch the few catalog files still using the wrong code 'id' => [ 'Indonesian', 'iso-8859-1', 'id', 'id:in_ID' ], 'is' => [ 'Icelandic', 'iso-8859-1', 'is', 'is' ], 'it_CH' => [ 'Italian|Switzerland', 'iso-8859-15', 'it', 'it_IT:it' ], 'it_IT' => [ 'Italian|Italy','iso-8859-15','it', 'it_IT:it' ], #-'iu' => [ 'Inuktitut', 'unicodeIU', 'iu', 'iu' ], 'ja' => [ 'Japanese', 'jisx0208', 'ja', 'ja_JP.ujis:ja' ], 'ja_JP.UTF-8'=> [ 'Japanese (UTF-8)', 'utf_ja', 'ja', 'ja_JP.ujis:ja' ], 'ka_GE.UTF-8'=> [ 'Georgian', 'utf_ka', 'ka', 'ka' ], #-'kl' => [ 'Greenlandic (inuit)', 'iso-8859-1', 'kl', 'kl' ], 'ko' => [ 'Korean', 'ksc5601', 'ko', 'ko' ], 'ko_KR.UTF-8'=> [ 'Korean (UTF-8)', 'utf_ko', 'ko', 'ko' ], #-'kw' => [ 'Cornish gaelic', 'iso-8859-14','kw', 'kw:en_GB:en' ], #-'lo' => [ 'Laotian', 'mulelao-1', 'lo', 'lo' ], 'lt' => [ 'Lithuanian', 'iso-8859-13','lt', 'lt' ], 'lv' => [ 'Latvian', 'iso-8859-13','lv', 'lv' ], 'mi' => [ 'Maori', 'iso-8859-13','mi', 'mi' ], 'mk' => [ 'Macedonian (Cyrillic)','iso-8859-5', 'mk', 'mk' ], 'mk_MK.UTF-8'=> [ 'Macedonian (Cyrillic) (UTF-8)','utf_1251', 'mk', 'mk' ], 'ms' => [ 'Malay', 'iso-8859-1', 'ms', 'ms' ], # 'mt' => [ 'Maltese|ISO-8859-3', 'iso-8859-3', 'mt', 'mt' ], 'mt_MT.UTF-8'=> [ 'Maltese', 'utf_3', 'mt', 'mt' ], 'nl_BE' => [ 'Dutch|Belgium', 'iso-8859-15', 'nl', 'nl_BE:nl' ], 'nl_NL' => [ 'Dutch|Netherlands','iso-8859-15', 'nl', 'nl_NL:nl' ], # 'nb' is the new locale name in glibc 2.2 'no' => [ 'Norwegian|Bokmaal', 'iso-8859-1', 'no', 'no:nb:nn:no@nynorsk:no_NY' ], # no_NY is used by KDE (but not standard); 'nn' is the new locale in glibc 2.2 'nn' => [ 'Norwegian|Nynorsk', 'iso-8859-1', 'no', 'nn:no@nynorsk:no_NY:no:nb' ], #-'oc' => [ 'Occitan', 'iso-8859-1', 'oc', 'oc:fr_FR' ], #-'pd' => [ 'Plauttdietsch', 'iso-8859-1', 'pd', 'pd' ], #-'ph' => [ 'Pilipino', 'iso-8859-1', 'ph', 'ph:tl' ], 'pl' => [ 'Polish', 'iso-8859-2', 'pl', 'pl' ], #-'pp' => [ 'Papiamento', 'iso-8859-1', 'pp', 'pp' ], 'pt_BR' => [ 'Portuguese|Brazil', 'iso-8859-1', 'pt_BR', 'pt_BR:pt_PT:pt' ], 'pt_PT' => [ 'Portuguese|Portugal','iso-8859-15','pt', 'pt_PT:pt:pt_BR' ], 'ro' => [ 'Romanian', 'iso-8859-2', 'ro', 'ro' ], 'ru_RU.KOI8-R' => [ 'Russian|KOI8-R', 'koi8-r', 'ru', 'ru_RU:ru' ], 'ru_RU.CP1251' => [ 'Russian|CP1251', 'cp1251', 'ru', 'ru_RU:ru' ], 'ru_RU.UTF-8' => [ 'Russian|UTF-8', 'utf_1251', 'ru', 'ru_RU:ru' ], 'sk' => [ 'Slovak', 'iso-8859-2', 'sk', 'sk' ], 'sl' => [ 'Slovenian', 'iso-8859-2', 'sl', 'sl' ], 'sp' => [ 'Serbian|Cyrillic (ISO-8859-5)','iso-8859-5', 'sp', 'sp:sr' ], 'sp_YU.CP1251'=> [ 'Serbian|Cyrillic (CP1251)','cp1251', 'sp', 'sp:sr' ], 'sp_YU.UTF-8'=> [ 'Serbian|Cyrillic (UTF-8)','utf_1251', 'sp', 'sp:sr' ], 'sr' => [ 'Serbian|Latin (ISO-8859-2)','iso-8859-2','sr', 'sr' ], 'sr_YU.UTF-8'=> [ 'Serbian|Latin (UTF-8)', 'utf_2', 'sr', 'sr' ], 'sv' => [ 'Swedish', 'iso-8859-1', 'sv', 'sv' ], # there is no tamil font curently; so set DrakX encoding to utf_1 'ta_IN.UTF-8'=> [ 'Tamil', 'utf_1', 'ta', 'ta' ], 'tg_TJ.UTF-8'=> [ 'Tajik', 'utf_koi', 'tg', 'tg' ], 'th' => [ 'Thai|TIS-620', 'tis620', 'th', 'th' ], 'th_TH.UTF-8'=> [ 'Thai (UTF-8)', 'utf_th', 'th', 'th' ], 'tr' => [ 'Turkish', 'iso-8859-9', 'tr', 'tr' ], #-'tt_RU.UTF-8'=> [ 'Tatar', 'koi8-k', 'tt', 'tt' ], #-'ur' => [ 'Urdu', 'cp1256', 'ur', 'ur' ], 'uk_UA' => [ 'Ukrainian|KOI8-U', 'koi8-u', 'uk', 'uk_UA:uk' ], 'uk_UA.CP1251'=> [ 'Ukrainian|CP1251', 'cp1251', 'uk', 'uk_UA:uk' ], 'uk_UA.UTF-8'=> [ 'Ukrainian|UTF-8', 'utf_1251', 'uk', 'uk_UA:uk' ], 'uz' => [ 'Uzbek', 'iso-8859-1', 'uz', 'uz' ], 'vi_VN.TCVN' => [ 'Vietnamese|TCVN', 'tcvn', 'vi', 'vi' ], 'vi_VN.VISCII' => [ 'Vietnamese|VISCII','viscii', 'vi', 'vi' ], 'vi_VN.UTF-8' => [ 'Vietnamese|UTF-8', 'utf_vi', 'vi', 'vi' ], 'wa' => [ 'Walon', 'iso-8859-15', 'wa', 'wa:fr_BE:fr' ], #-'yi' => [ 'Yiddish', 'cp1255', 'yi', 'yi' ], # NOTE: 'zh' must be in the LANGUAGE list, it is not used for translations # themselves but is needed for our selection of locales-xx packages # and the language dependent packages resolution #'zh_HK.Big5' => [ 'Chinese|Traditional|Hong Kong|Big5', 'Big5', 'zh_TW.Big5', 'zh_TW.Big5:zh_TW:zh_HK:zh' ], #'zh_HK.UTF-8' => [ 'Chinese|Traditional|Hong Kong|UTF-8','utf_tw','zh_HK', 'zh_HK:zh_TW.Big5:zh_TW:zh' ], 'zh_TW.Big5' => [ 'Chinese|Traditional|Big5', 'Big5', 'zh_TW.Big5', 'zh_TW.Big5:zh_TW:zh_HK:zh' ], 'zh_TW.UTF-8' => [ 'Chinese|Traditional|UTF-8','utf_tw','zh_TW.Big5','zh_TW.Big5:zh_TW.big5:zh_TW:zh_HK:zh' ], 'zh_CN.GB2312' => [ 'Chinese|Simplified|GB2312', 'gb2312', 'zh_CN.GB2312', 'zh_CN.GB2312:zh_CN:zh' ], 'zh_CN.UTF-8' => [ 'Chinese|Simplified|UTF-8','utf_cn','zh_CN', 'zh_CN.GB2312:zh_CN:zh' ], # does this one works? #'zh_CN.GB18030' => [ 'Chinese|Simplified|GB18030','gb2312','zh_CN', 'zh_CN.GB2312:zh_CN:zh' ], ); @languages = map { $_->[0] } group_by2(@languages); my %xim = ( # 'zh_TW.Big5' => { # ENC => 'big5', # XIM => 'xcin', # XIM_PROGRAM => 'xcin', # XMODIFIERS => '"@im=xcin"', # CONSOLE_NOT_LOCALIZED => 'yes', # }, 'zh_TW.Big5' => { ENC => 'big5', XIM => 'Chinput', XIM_PROGRAM => 'chinput', XMODIFIERS => '"@im=Chinput"', CONSOLE_NOT_LOCALIZED => 'yes', }, 'zh_TW.UTF-8' => { ENC => 'utf8', XIM => 'Chinput', XIM_PROGRAM => 'chinput', XMODIFIERS => '"@im=Chinput"', CONSOLE_NOT_LOCALIZED => 'yes', }, 'zh_CN.GB2312' => { ENC => 'gb', XIM => 'Chinput', XIM_PROGRAM => 'chinput', XMODIFIERS => '"@im=Chinput"', CONSOLE_NOT_LOCALIZED => 'yes', 'zh_CN.UTF-8' => { ENC => 'utf8', XIM => 'Chinput', XIM_PROGRAM => 'chinput', XMODIFIERS => '"@im=Chinput"', CONSOLE_NOT_LOCALIZED => 'yes', }, }, 'ko' => { ENC => 'kr', XIM => 'Ami', # NOTE: there are several possible versions of ami, for the different # desktops (kde, gnome, etc). So XIM_PROGRAM isn't defined; it will # be the xinitrc script, XIM section, that will choose the right one # XIM_PROGRAM => 'ami', XMODIFIERS => '"@im=Ami"', CONSOLE_NOT_LOCALIZED => 'yes', }, 'ko_KR.UTF-8' => { ENC => 'utf8', XIM => 'Ami', # NOTE: there are several possible versions of ami, for the different # desktops (kde, gnome, etc). So XIM_PROGRAM isn't defined; it will # be the xinitrc script, XIM section, that will choose the right one # XIM_PROGRAM => 'ami', XMODIFIERS => '"@im=Ami"', CONSOLE_NOT_LOCALIZED => 'yes', }, 'ja' => { ENC => 'eucj', XIM => 'kinput2', XIM_PROGRAM => 'kinput2', XMODIFIERS => '"@im=kinput2"', }, 'ja_JP.UTF-8' => { ENC => 'utf8', XIM => 'kinput2', XIM_PROGRAM => 'kinput2', XMODIFIERS => '"@im=kinput2"', }, # XFree86 has an internal XIM for Thai that enables syntax checking etc. # 'Passthroug' is no check at all, 'BasicCheck' accepts bad sequences # and convert them to right ones, 'Strict' refuses bad sequences 'th' => { XIM_PROGRAM => '/bin/true', # it's an internal module XMODIFIERS => '"@im=BasicCheck"', }, # xvnkb is not an XIM input method; but an input method of another # kind, only XIM_PROGRAM needs to be defined 'vi' => { XIM_PROGRAM => 'xvnkb', }, 'vi_VN.TCVN' => { XIM_PROGRAM => 'xvnkb', }, 'vi_VN.VISCII' => { XIM_PROGRAM => 'xvnkb', }, ## xvnkb don't work in utf-8 # 'vi_VN.UTF-8' => { # XIM_PROGRAM => 'xvnkb', # }, # right to left languages only work properly on console 'ar' => { X11_NOT_LOCALIZED => "yes", }, 'fa' => { X11_NOT_LOCALIZED => "yes", }, # KDE has some "mirrored" translations # 'he' => { # X11_NOT_LOCALIZED => "yes", # }, 'ur' => { X11_NOT_LOCALIZED => "yes", }, 'yi' => { X11_NOT_LOCALIZED => "yes", }, ); sub std2 { "-*-*-medium-r-normal-*-$_[1]-*-*-*-*-*-$_[0]" } sub std_ { std2($_[0], 10), std2($_[0], 10) } sub std { std2($_[0], $_[1] || 10), std2($_[0], 8) } #- [0]: console font name; [1]: unicode map for console font #- [2]: acm file for console font; #- [3]: iocharset param for mount; [4]: codepage parameter for mount #- [5]: X11 fontset (for DrakX) my %charsets = ( "armscii-8" => [ "arm8", "armscii8.uni", "trivial.trans", undef, undef, std_("armscii-8") ], "utf_hy" => [ "arm8", "armscii8.uni", "trivial.trans", "utf8", undef, std_("armscii-8") ], #- chinese needs special console driver for text mode "Big5" => [ undef, undef, undef, "big5", "950", "-*-*-*-*-*-*-*-*-*-*-*-*-big5-0" ], "utf_tw" => [ undef, undef, undef, "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-big5-0" ], "gb2312" => [ undef, undef, undef, "gb2312", "936", "-*-*-*-*-*-*-*-*-*-*-*-*-gb2312.1980-0" ], "utf_cn" => [ undef, undef, undef, "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-gb2312.1980-0" ], "utf_ka" => [ "t_geors", "geors.uni", "geors_to_geops.trans", "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-georgian-academy" ], "C" => [ "lat0-sun16", undef, "iso15", "iso8859-1", "850", sub { std("iso8859-1", @_) } ], "iso-8859-1" => [ "lat0-sun16", undef, "iso15", "iso8859-1", "850", sub { std("iso8859-15", @_) } ], "utf_1" => [ "lat0-sun16", undef, "iso15", "utf8", undef, sub { std("iso8859-15", @_) } ], "iso-8859-2" => [ "lat2-sun16", undef, "iso02", "iso8859-2", "852", sub { std("iso8859-2", @_) } ], "utf_2" => [ "lat2-sun16", undef, "iso02", "utf8", undef, sub { std("iso8859-2", @_) } ], "iso-8859-3" => [ "iso03.f16", undef, "iso03", "iso8859-3", undef, std_("iso8859-3") ], "utf_3" => [ "iso03.f16", undef, "iso03", "utf8", undef, std_("iso8859-3") ], # "iso-8859-4" => [ "lat4u-16", undef, "iso04", # "iso8859-4", "775", std_("iso8859-4") ], "iso-8859-5" => [ "iso05.f16", "iso05", "trivial.trans", "iso8859-5", "855", sub { std("microsoft-cp1251", @_) } ], #-#- arabic needs special console driver for text mode [acon] #-#- (and gtk support isn't done yet) "iso-8859-6" => [ "iso06.f16", "iso06", "trivial.trans", "iso8859-6", "864", std_("iso8859-6") ], "iso-8859-7" => [ "iso07.f16", "iso07", "trivial.trans", "iso8859-7", "869", std_("iso8859-7") ], "utf_el" => [ "iso07.f16", "iso07", "trivial.trans", "utf8", "869", std_("iso8859-7") ], #-#- hebrew needs special console driver for text mode [acon] #-#- (and gtk support isn't done yet) "iso-8859-8" => [ "iso08.f16", "iso08", "trivial.trans", # std_("iso8859-8") ], "iso8859-8", "862", std_("microsoft-cp1255") ], "iso-8859-9" => [ "iso09.f16", "iso09", "trivial.trans", "iso8859-9", "857", sub { std("iso8859-9", @_) } ], "iso-8859-13" => [ "tlat7", "iso13", "trivial.trans", "iso8859-13", "775", std_("iso8859-13") ], "utf_13" => [ "tlat7", "iso13", "trivial.trans", "utf8", "775", std_("iso8859-13") ], "iso-8859-14" => [ "tlat8", "iso14", "trivial.trans", "iso8859-14", "850", std_("iso8859-14") ], "utf_14" => [ "tlat8", "iso14", "trivial.trans", "utf8", undef, std_("iso8859-14") ], "iso-8859-15" => [ "lat0-sun16", undef, "iso15", "iso8859-15", "850", sub { std("iso8859-15", @_) } ], "utf_15" => [ "lat0-sun16", undef, "iso15", "utf8", undef, sub { std("iso8859-15", @_) } ], "utf_az" => [ "tiso09e", "iso09", "trivial.trans", "utf8", undef, std2("iso8859-9e",10) ], #- japanese needs special console driver for text mode [kon2] "jisx0208" => [ undef, undef, "trivial.trans", "euc-jp", "932", "-*-*-*-*-*-*-*-*-*-*-*-*-jisx*.*-0" ], "utf_ja" => [ undef, undef, "trivial.trans", "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-jisx*.*-0" ], "koi8-r" => [ "UniCyr_8x16", undef, "koi8-r", "koi8-r", "866", sub { std("microsoft-cp1251", @_) } ], "koi8-u" => [ "UniCyr_8x16", undef, "koi8-u", "koi8-u", "866", sub { std("microsoft-cp1251", @_) } ], "utf_koi" => [ "koi8-k", "iso01", "trivial.trans", "utf8", undef, std("koi8-k") ], "cp1251" => [ "UniCyr_8x16", undef, "cp1251", "cp1251", "866", sub { std("microsoft-cp1251", @_) } ], "utf_1251" => [ "UniCyr_8x16", undef, "cp1251", "utf8", undef, sub { std("microsoft-cp1251", @_) } ], #- Yiddish needs special console driver for text mode [acon] #- (and gtk support isn't done yet) # "cp1255" => [ "iso08.f16", "iso08", "trivial.trans", # "cp1255", "862", std_("microsoft-cp1255") ], "utf_he" => [ "iso08.f16", "iso08", "trivial.trans", "utf8", "862", std_("microsoft-cp1255") ], #- Urdu needs special console driver for text mode [acon] #- (and gtk support isn't done yet) # "cp1256" => [ undef, undef, "trivial.trans", # undef, "864", std_("microsoft-cp1255") ], #- korean needs special console driver for text mode "ksc5601" => [ undef, undef, undef, "euc-kr", "949", "-*-*-*-*-*-*-*-*-*-*-*-*-ksc5601.1987-*" ], "utf_ko" => [ undef, undef, undef, "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-ksc5601.1987-*" ], #- I have no console font for Thai... "tis620" => [ undef, undef, "trivial.trans", "tis-620", "874", std2("tis620.2533-1",12) ], "utf_th" => [ undef, undef, "trivial.trans", "utf8", "874", std2("tis620.2533-1",12) ], "tcvn" => [ "tcvn8x16", "tcvn", "trivial.trans", undef, undef, std2("tcvn-5712", 13), std2("tcvn-5712", 10) ], "viscii" => [ "viscii10-8x16", "viscii.uni", "viscii1.0_to_viscii1.1.trans", #- "-*-*-*-*-*-*-*-*-*-*-*-*-viscii1.1-1" ], undef, undef, std2("tcvn-5712", 13), std2("tcvn-5712", 10) ], "utf_vi" => [ "tcvn8x16", "tcvn", "trivial.trans", "utf8", undef, std2("tcvn-5712", 13), std2("tcvn-5712", 10) ], #- Farsi (iranian) needs special console driver for text mode [acon] #- (and gtk support isn't done yet) # "isiri-3342" => [ undef, undef, "trivial.trans", # undef, undef, "-*-*-*-*-*-*-*-*-*-*-*-*-isiri-3342" ], # "tscii-0" => [ "tamil", undef, "trivial.trans", # undef, undef, "-*-*-*-*-*-*-*-*-*-*-*-*-tscii-0" ], "unicode" => [ undef, undef, "trivial.trans", "utf8", undef, "-*-*-*-*-*-*-*-*-*-*-*-*-iso10646-1" ], ); my %bigfonts = ( Big5 => 'taipei16.pcf.gz', gb2312 => 'gb16fs.pcf.gz', jisx0208 => 'k14.pcf.gz', ksc5601 => 'baekmuk_gulim_h_14.pcf.gz', unicode => 'cu12.pcf.gz', ); #- for special cases not handled magically my %charset2kde_charset = ( gb2312 => 'gb2312.1980-0', jisx0208 => 'jisx0208.1983-0', ksc5601 => 'ksc5601.1987-0', Big5 => 'big5-0', cp1251 => 'microsoft-cp1251', utf8 => 'iso10646-1', tis620 => 'tis620-0', ); #- for special cases not handled magically my %lang2country = ( ar => 'eg', be => 'by', bs => 'bh', cs => 'cz', da => 'dk', el => 'gr', et => 'ee', ko => 'kr', mi => 'nz', ms => 'my', nn => 'no', sl => 'si', sp => 'sr', sv => 'se', ); #-###################################################################################### #- Functions #-###################################################################################### sub list { my ($exclude_non_necessary_utf8) = @_; if ($exclude_non_necessary_utf8) { my %LANGs_non_utf8 = map { lang2LANG($_) => 1 } grep { !/UTF-8/ } @languages; grep { !/UTF-8/ || !$LANGs_non_utf8{lang2LANG($_)} } @languages; } else { @languages; } } sub lang2text { exists $languages{$_[0]} && $languages{$_[0]}[0] } sub lang2charset { exists $languages{$_[0]} && $languages{$_[0]}[1] } sub lang2LANG { exists $languages{$_[0]} && $languages{$_[0]}[2] }