Reformat source code in the single style
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Alexey Gladkov
7 years ago
0 | BasedOnStyle: LLVM | |
1 | IndentWidth: 8 | |
2 | ColumnLimit: 0 | |
3 | UseTab: ForIndentation | |
4 | BreakBeforeBraces: Linux | |
5 | AllowShortIfStatementsOnASingleLine: false | |
6 | IndentCaseLabels: true | |
7 | AlignConsecutiveAssignments: true | |
8 | Cpp11BracedListStyle: false | |
9 | SortIncludes: false |
22 | 22 | int handle_codepage(int); |
23 | 23 | void handle_fontfile(void); |
24 | 24 | |
25 | #define PACKED __attribute__ ((packed)) | |
25 | #define PACKED __attribute__((packed)) | |
26 | 26 | /* Use this (instead of the above) to compile under MSDOS */ |
27 | 27 | /*#define PACKED */ |
28 | 28 | |
30 | 30 | unsigned char id0 PACKED; |
31 | 31 | unsigned char id[7] PACKED; |
32 | 32 | unsigned char res[8] PACKED; |
33 | unsigned short pnum PACKED; /* number of pointers */ | |
34 | unsigned char ptyp PACKED; /* type of pointers */ | |
33 | unsigned short pnum PACKED; /* number of pointers */ | |
34 | unsigned char ptyp PACKED; /* type of pointers */ | |
35 | 35 | unsigned long fih_offset PACKED; /* FontInfoHeader offset */ |
36 | 36 | } FontFileHeader; |
37 | 37 | |
38 | 38 | int drfont = 0; |
39 | 39 | |
40 | #define N 4 | |
41 | struct { | |
42 | unsigned char num_fonts PACKED; /* N = 4 fonts per code page*/ | |
40 | #define N 4 | |
41 | struct { | |
42 | unsigned char num_fonts PACKED; /* N = 4 fonts per code page*/ | |
43 | 43 | unsigned char font_height[N] PACKED; |
44 | 44 | unsigned long dfd_offset[N] PACKED; /* DisplayFontData offset */ |
45 | 45 | } DRDOS_ExtendedFontFileHeader; |
85 | 85 | |
86 | 86 | unsigned short codepage; |
87 | 87 | |
88 | int main (int argc, char *argv[]) { | |
88 | int main(int argc, char *argv[]) | |
89 | { | |
89 | 90 | if (argc < 2) |
90 | 91 | usage(); |
91 | 92 | |
94 | 95 | if (argc == 2) |
95 | 96 | optl = 1; |
96 | 97 | else |
97 | while(1) { | |
98 | switch(getopt(argc, argv, "alLc")) { | |
99 | case 'a': | |
100 | opta = 1; | |
101 | continue; | |
102 | case 'c': | |
103 | optc = 1; | |
104 | continue; | |
105 | case 'L': | |
106 | optL = 1; | |
107 | continue; | |
108 | case 'l': | |
109 | optl = 1; | |
110 | continue; | |
111 | case '?': | |
112 | default: | |
98 | while (1) { | |
99 | switch (getopt(argc, argv, "alLc")) { | |
100 | case 'a': | |
101 | opta = 1; | |
102 | continue; | |
103 | case 'c': | |
104 | optc = 1; | |
105 | continue; | |
106 | case 'L': | |
107 | optL = 1; | |
108 | continue; | |
109 | case 'l': | |
110 | optl = 1; | |
111 | continue; | |
112 | case '?': | |
113 | default: | |
114 | usage(); | |
115 | case -1: | |
116 | break; | |
117 | } | |
118 | break; | |
119 | } | |
120 | ||
121 | if (optind < argc) { | |
122 | if ((in = fopen(argv[optind], "r")) == NULL) { | |
123 | printf("\nUnable to open file %s.\n", argv[optind]); | |
124 | exit(0); | |
125 | } | |
126 | optind++; | |
127 | } else | |
113 | 128 | usage(); |
114 | case -1: | |
115 | break; | |
116 | } | |
117 | break; | |
118 | } | |
119 | ||
120 | if (optind < argc) { | |
121 | if ((in = fopen(argv[optind], "r")) == NULL) { | |
122 | printf("\nUnable to open file %s.\n", argv[optind]); | |
123 | exit(0); | |
124 | } | |
125 | optind++; | |
126 | } else | |
127 | usage(); | |
128 | ||
129 | ||
129 | 130 | if (optind != argc) { |
130 | if (optind != argc-1 || opta) | |
131 | usage(); | |
132 | codepage = atoi(argv[optind]); | |
133 | optx = 1; | |
131 | if (optind != argc - 1 || opta) | |
132 | usage(); | |
133 | codepage = atoi(argv[optind]); | |
134 | optx = 1; | |
134 | 135 | } |
135 | 136 | |
136 | 137 | if (optc) |
137 | handle_codepage(0); | |
138 | handle_codepage(0); | |
138 | 139 | else |
139 | handle_fontfile(); | |
140 | handle_fontfile(); | |
140 | 141 | |
141 | 142 | if (optx) { |
142 | printf("no page %d found\n", codepage); | |
143 | exit(1); | |
143 | printf("no page %d found\n", codepage); | |
144 | exit(1); | |
144 | 145 | } |
145 | 146 | |
146 | 147 | fclose(in); |
147 | 148 | return (0); |
148 | 149 | } |
149 | 150 | |
150 | void | |
151 | handle_fontfile(){ | |
151 | void handle_fontfile() | |
152 | { | |
152 | 153 | int i, j; |
153 | 154 | |
154 | 155 | j = fread(&FontFileHeader, 1, sizeof(FontFileHeader), in); |
155 | 156 | if (j != sizeof(FontFileHeader)) { |
156 | printf("error reading FontFileHeader - got %d chars\n", j); | |
157 | exit (1); | |
157 | printf("error reading FontFileHeader - got %d chars\n", j); | |
158 | exit(1); | |
158 | 159 | } |
159 | 160 | if (optL) |
160 | printf("FontFileHeader: id=0x%x \"%7.7s\" res=%8.8s " | |
161 | "num=%d typ=%d fih_offset=%ld\n\n", | |
162 | FontFileHeader.id0, FontFileHeader.id, FontFileHeader.res, | |
163 | FontFileHeader.pnum, FontFileHeader.ptyp, | |
164 | FontFileHeader.fih_offset); | |
161 | printf("FontFileHeader: id=0x%x \"%7.7s\" res=%8.8s " | |
162 | "num=%d typ=%d fih_offset=%ld\n\n", | |
163 | FontFileHeader.id0, FontFileHeader.id, FontFileHeader.res, | |
164 | FontFileHeader.pnum, FontFileHeader.ptyp, | |
165 | FontFileHeader.fih_offset); | |
165 | 166 | |
166 | 167 | if (!strcmp(FontFileHeader.id, "DRFONT ")) { |
167 | drfont = 1; | |
168 | j = fread(&DRDOS_ExtendedFontFileHeader, 1, | |
169 | sizeof(DRDOS_ExtendedFontFileHeader), in); | |
170 | if (j != sizeof(DRDOS_ExtendedFontFileHeader)) { | |
171 | printf("error reading ExtendedFontFileHeader - " | |
172 | "got %d chars\n", j); | |
173 | exit (1); | |
174 | } | |
175 | if (DRDOS_ExtendedFontFileHeader.num_fonts != N) { | |
176 | printf("found %d instead of 4 fonts in drfont\n", | |
177 | DRDOS_ExtendedFontFileHeader.num_fonts); | |
178 | exit (1); | |
179 | } | |
180 | if (optL) { | |
181 | printf("ExtendedFontFileHeader:\n"); | |
182 | for (j=0; j<N; j++) { | |
183 | printf("font%d: height %d dfd_offset %d\n", j, | |
184 | DRDOS_ExtendedFontFileHeader.font_height[j], | |
185 | DRDOS_ExtendedFontFileHeader.dfd_offset[j]); | |
186 | } | |
187 | printf("\n"); | |
188 | } | |
168 | drfont = 1; | |
169 | j = fread(&DRDOS_ExtendedFontFileHeader, 1, | |
170 | sizeof(DRDOS_ExtendedFontFileHeader), in); | |
171 | if (j != sizeof(DRDOS_ExtendedFontFileHeader)) { | |
172 | printf("error reading ExtendedFontFileHeader - " | |
173 | "got %d chars\n", | |
174 | j); | |
175 | exit(1); | |
176 | } | |
177 | if (DRDOS_ExtendedFontFileHeader.num_fonts != N) { | |
178 | printf("found %d instead of 4 fonts in drfont\n", | |
179 | DRDOS_ExtendedFontFileHeader.num_fonts); | |
180 | exit(1); | |
181 | } | |
182 | if (optL) { | |
183 | printf("ExtendedFontFileHeader:\n"); | |
184 | for (j = 0; j < N; j++) { | |
185 | printf("font%d: height %d dfd_offset %d\n", j, | |
186 | DRDOS_ExtendedFontFileHeader.font_height[j], | |
187 | DRDOS_ExtendedFontFileHeader.dfd_offset[j]); | |
188 | } | |
189 | printf("\n"); | |
190 | } | |
189 | 191 | } |
190 | 192 | |
191 | 193 | j = fread(&FontInfoHeader, 1, sizeof(FontInfoHeader), in); |
192 | 194 | if (j != sizeof(FontInfoHeader)) { |
193 | printf("error reading FontInfoHeader - got %d chars\n", j); | |
194 | exit (1); | |
195 | printf("error reading FontInfoHeader - got %d chars\n", j); | |
196 | exit(1); | |
195 | 197 | } |
196 | 198 | if (optL) |
197 | printf("FontInfoHeader: num_codepages=%d\n\n", | |
198 | FontInfoHeader.num_codepages); | |
199 | printf("FontInfoHeader: num_codepages=%d\n\n", | |
200 | FontInfoHeader.num_codepages); | |
199 | 201 | |
200 | 202 | #if 1 |
201 | 203 | if (drfont) { |
202 | printf("this program cannot handle DRDOS font files\n"); | |
203 | exit(1); | |
204 | printf("this program cannot handle DRDOS font files\n"); | |
205 | exit(1); | |
204 | 206 | } |
205 | 207 | #endif |
206 | 208 | |
207 | 209 | for (i = FontInfoHeader.num_codepages; i; i--) |
208 | if (handle_codepage(i-1)) | |
209 | break; | |
210 | if (handle_codepage(i - 1)) | |
211 | break; | |
210 | 212 | } |
211 | 213 | |
212 | int | |
213 | handle_codepage(int more_to_come) { | |
214 | int j; | |
214 | int handle_codepage(int more_to_come) | |
215 | { | |
216 | int j; | |
215 | 217 | char outfile[20]; |
216 | 218 | unsigned char *fonts; |
217 | 219 | long inpos, nexthdr; |
218 | 220 | |
219 | 221 | j = fread(&CPEntryHeader, 1, sizeof(CPEntryHeader), in); |
220 | 222 | if (j != sizeof(CPEntryHeader)) { |
221 | printf("error reading CPEntryHeader - got %d chars\n", j); | |
222 | exit(1); | |
223 | printf("error reading CPEntryHeader - got %d chars\n", j); | |
224 | exit(1); | |
223 | 225 | } |
224 | 226 | if (optL) { |
225 | int t = CPEntryHeader.device_type; | |
226 | printf("CPEntryHeader: size=%d dev=%d [%s] name=%8.8s " | |
227 | "codepage=%d\n\t\tres=%6.6s nxt=%ld off_font=%ld\n\n", | |
228 | CPEntryHeader.size, | |
229 | t, (t==1) ? "screen" : (t==2) ? "printer" : "?", | |
230 | CPEntryHeader.device_name, | |
231 | CPEntryHeader.codepage, | |
232 | CPEntryHeader.res, | |
233 | CPEntryHeader.off_nexthdr, CPEntryHeader.off_font); | |
227 | int t = CPEntryHeader.device_type; | |
228 | printf("CPEntryHeader: size=%d dev=%d [%s] name=%8.8s " | |
229 | "codepage=%d\n\t\tres=%6.6s nxt=%ld off_font=%ld\n\n", | |
230 | CPEntryHeader.size, | |
231 | t, (t == 1) ? "screen" : (t == 2) ? "printer" : "?", | |
232 | CPEntryHeader.device_name, | |
233 | CPEntryHeader.codepage, | |
234 | CPEntryHeader.res, | |
235 | CPEntryHeader.off_nexthdr, CPEntryHeader.off_font); | |
234 | 236 | } else if (optl) { |
235 | printf("\nCodepage = %d\n", CPEntryHeader.codepage); | |
236 | printf("Device = %.8s\n", CPEntryHeader.device_name); | |
237 | printf("\nCodepage = %d\n", CPEntryHeader.codepage); | |
238 | printf("Device = %.8s\n", CPEntryHeader.device_name); | |
237 | 239 | } |
238 | 240 | #if 0 |
239 | 241 | if (CPEntryHeader.size != sizeof(CPEntryHeader)) { |
246 | 248 | } |
247 | 249 | #endif |
248 | 250 | if (!opta && (!optx || CPEntryHeader.codepage != codepage) && !optc) |
249 | goto next; | |
251 | goto next; | |
250 | 252 | |
251 | 253 | inpos = ftell(in); |
252 | 254 | if (inpos != CPEntryHeader.off_font && !optc) { |
253 | if (optL) | |
254 | printf("pos=%ld font at %ld\n", inpos, CPEntryHeader.off_font); | |
255 | fseek(in, CPEntryHeader.off_font, SEEK_SET); | |
255 | if (optL) | |
256 | printf("pos=%ld font at %ld\n", inpos, CPEntryHeader.off_font); | |
257 | fseek(in, CPEntryHeader.off_font, SEEK_SET); | |
256 | 258 | } |
257 | 259 | |
258 | 260 | j = fread(&CPInfoHeader, 1, sizeof(CPInfoHeader), in); |
259 | 261 | if (j != sizeof(CPInfoHeader)) { |
260 | printf("error reading CPInfoHeader - got %d chars\n", j); | |
261 | exit(1); | |
262 | printf("error reading CPInfoHeader - got %d chars\n", j); | |
263 | exit(1); | |
262 | 264 | } |
263 | 265 | if (optl) { |
264 | printf("Number of Fonts = %d\n", CPInfoHeader.num_fonts); | |
265 | printf("Size of Bitmap = %d\n", CPInfoHeader.size); | |
266 | printf("Number of Fonts = %d\n", CPInfoHeader.num_fonts); | |
267 | printf("Size of Bitmap = %d\n", CPInfoHeader.size); | |
266 | 268 | } |
267 | 269 | if (CPInfoHeader.num_fonts == 0) |
268 | goto next; | |
270 | goto next; | |
269 | 271 | if (optc) |
270 | return 0; | |
272 | return 0; | |
271 | 273 | |
272 | 274 | sprintf(outfile, "%d.cp", CPEntryHeader.codepage); |
273 | 275 | if ((out = fopen(outfile, "w")) == NULL) { |
274 | printf("\nUnable to open file %s.\n", outfile); | |
275 | exit(1); | |
276 | } else printf("\nWriting %s\n", outfile); | |
277 | ||
278 | fonts = (unsigned char *) malloc(CPInfoHeader.size); | |
279 | ||
276 | printf("\nUnable to open file %s.\n", outfile); | |
277 | exit(1); | |
278 | } else | |
279 | printf("\nWriting %s\n", outfile); | |
280 | ||
281 | fonts = (unsigned char *)malloc(CPInfoHeader.size); | |
282 | ||
280 | 283 | fread(fonts, CPInfoHeader.size, 1, in); |
281 | 284 | fwrite(&CPEntryHeader, sizeof(CPEntryHeader), 1, out); |
282 | 285 | fwrite(&CPInfoHeader, sizeof(CPInfoHeader), 1, out); |
283 | 286 | j = fwrite(fonts, 1, CPInfoHeader.size, out); |
284 | 287 | if (j != CPInfoHeader.size) { |
285 | printf("error writing %s - wrote %d chars\n", outfile, j); | |
286 | exit(1); | |
288 | printf("error writing %s - wrote %d chars\n", outfile, j); | |
289 | exit(1); | |
287 | 290 | } |
288 | 291 | fclose(out); |
289 | 292 | free(fonts); |
290 | if (optx) exit(0); | |
291 | next: | |
293 | if (optx) | |
294 | exit(0); | |
295 | next: | |
292 | 296 | /* |
293 | 297 | * It seems that if entry headers and fonts are interspersed, |
294 | 298 | * then nexthdr will point past the font, regardless of |
298 | 302 | */ |
299 | 303 | nexthdr = CPEntryHeader.off_nexthdr; |
300 | 304 | if (nexthdr == 0 || nexthdr == -1) { |
301 | if (more_to_come) { | |
302 | printf("more codepages expected, but nexthdr=%ld\n", | |
303 | nexthdr); | |
304 | exit(1); | |
305 | } else | |
306 | return 1; | |
305 | if (more_to_come) { | |
306 | printf("more codepages expected, but nexthdr=%ld\n", | |
307 | nexthdr); | |
308 | exit(1); | |
309 | } else | |
310 | return 1; | |
307 | 311 | } |
308 | 312 | |
309 | 313 | inpos = ftell(in); |
310 | 314 | if (inpos != CPEntryHeader.off_nexthdr) { |
311 | if (optL) | |
312 | printf("pos=%ld nexthdr at %ld\n", inpos, nexthdr); | |
313 | if (opta && !more_to_come) { | |
314 | printf("no more code pages, but nexthdr != 0\n"); | |
315 | return 1; | |
316 | } | |
317 | ||
318 | fseek(in, CPEntryHeader.off_nexthdr, SEEK_SET); | |
315 | if (optL) | |
316 | printf("pos=%ld nexthdr at %ld\n", inpos, nexthdr); | |
317 | if (opta && !more_to_come) { | |
318 | printf("no more code pages, but nexthdr != 0\n"); | |
319 | return 1; | |
320 | } | |
321 | ||
322 | fseek(in, CPEntryHeader.off_nexthdr, SEEK_SET); | |
319 | 323 | } |
320 | 324 | |
321 | 325 | return 0; |
6 | 6 | #include <linux/kd.h> |
7 | 7 | #include <linux/keyboard.h> |
8 | 8 | |
9 | int | |
10 | main(void) | |
9 | int main(void) | |
11 | 10 | { |
12 | 11 | struct kbentry ke; |
13 | 12 |
5 | 5 | #include <unistd.h> |
6 | 6 | #include <sys/stat.h> |
7 | 7 | |
8 | void | |
9 | dosplit (int from, int to, char *fontbuf, int size, char *fontfile) { | |
10 | int itemsize = size/256; | |
8 | void dosplit(int from, int to, char *fontbuf, int size, char *fontfile) | |
9 | { | |
10 | int itemsize = size / 256; | |
11 | 11 | int i, fd; |
12 | 12 | char *p, *q, s; |
13 | 13 | char filename[4096]; |
14 | 14 | |
15 | 15 | if (from < 0 || from > 255 || to < 0 || to > 255) { |
16 | 16 | fprintf(stderr, "splitfont: bad argument %s,%s\n", |
17 | from, to); | |
17 | from, to); | |
18 | 18 | exit(1); |
19 | 19 | } |
20 | if(strlen(fontfile) >= sizeof(filename)-4) { | |
20 | if (strlen(fontfile) >= sizeof(filename) - 4) { | |
21 | 21 | fprintf(stderr, "splitfont: ridiculously long name\n"); |
22 | 22 | exit(1); |
23 | 23 | } |
24 | 24 | while (from <= to) { |
25 | 25 | sprintf(filename, "%s.%02x", fontfile, from); |
26 | if ((fd = open(filename, O_WRONLY|O_CREAT, 0666)) < 0) { | |
26 | if ((fd = open(filename, O_WRONLY | O_CREAT, 0666)) < 0) { | |
27 | 27 | perror("splitfont"); |
28 | 28 | fprintf(stderr, "cannot open %s for writing\n", filename); |
29 | 29 | } |
30 | p = &fontbuf[from*itemsize]; | |
30 | p = &fontbuf[from * itemsize]; | |
31 | 31 | if (write(fd, p, itemsize) != itemsize) { |
32 | 32 | perror("splitfont"); |
33 | 33 | fprintf(stderr, "error writing %s\n", filename); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | int main(int argc, char **argv) { | |
40 | int main(int argc, char **argv) | |
41 | { | |
41 | 42 | struct stat statbuf; |
42 | 43 | char fontbuf[4096]; |
43 | 44 | int fd; |
73 | 74 | } |
74 | 75 | |
75 | 76 | p = argv[2]; |
76 | while(1) { | |
77 | to = from = strtoul(p,&q,0); | |
78 | if(*q == '-') { | |
79 | p = q+1; | |
80 | to = strtoul(p,&q,0); | |
77 | while (1) { | |
78 | to = from = strtoul(p, &q, 0); | |
79 | if (*q == '-') { | |
80 | p = q + 1; | |
81 | to = strtoul(p, &q, 0); | |
81 | 82 | } |
82 | if(*q && *q != ',') { | |
83 | if (*q && *q != ',') { | |
83 | 84 | fprintf(stderr, "splitfont: garbage in %s\n", p); |
84 | 85 | exit(1); |
85 | 86 | } |
86 | 87 | dosplit(from, to, fontbuf, statbuf.st_size, argv[1]); |
87 | 88 | if (!*q) |
88 | 89 | break; |
89 | p = q+1; | |
90 | p = q + 1; | |
90 | 91 | } |
91 | 92 | return 0; |
92 | 93 | } |
7 | 7 | #include <termios.h> |
8 | 8 | #include <sys/ioctl.h> |
9 | 9 | |
10 | int | |
11 | main(int argc, char **argv) { | |
12 | int fd; | |
13 | char *s; | |
10 | int main(int argc, char **argv) | |
11 | { | |
12 | int fd; | |
13 | char *s; | |
14 | 14 | |
15 | if(argc != 3) { | |
16 | fprintf(stderr, "call: sti tty text\n"); | |
17 | exit(1); | |
18 | } | |
19 | fd = open(argv[1], O_RDONLY); | |
20 | if(fd < 0) { | |
21 | perror(argv[1]); | |
22 | fprintf(stderr, "sti: could not open tty\n"); | |
23 | exit(1); | |
24 | } | |
25 | s = argv[2]; | |
26 | while(*s) { | |
27 | if(ioctl(fd, TIOCSTI, s)) { | |
28 | perror("TIOCSTI"); | |
29 | fprintf(stderr, "sti: TIOCSTI ioctl failed\n"); | |
30 | exit(1); | |
31 | } | |
32 | s++; | |
33 | } | |
34 | return 0; | |
15 | if (argc != 3) { | |
16 | fprintf(stderr, "call: sti tty text\n"); | |
17 | exit(1); | |
18 | } | |
19 | fd = open(argv[1], O_RDONLY); | |
20 | if (fd < 0) { | |
21 | perror(argv[1]); | |
22 | fprintf(stderr, "sti: could not open tty\n"); | |
23 | exit(1); | |
24 | } | |
25 | s = argv[2]; | |
26 | while (*s) { | |
27 | if (ioctl(fd, TIOCSTI, s)) { | |
28 | perror("TIOCSTI"); | |
29 | fprintf(stderr, "sti: TIOCSTI ioctl failed\n"); | |
30 | exit(1); | |
31 | } | |
32 | s++; | |
33 | } | |
34 | return 0; | |
35 | 35 | } |
9 | 9 | #include <fcntl.h> |
10 | 10 | #include <time.h> |
11 | 11 | |
12 | void | |
13 | fatal(char *s) { | |
14 | perror(s); | |
15 | exit(1); | |
12 | void fatal(char *s) | |
13 | { | |
14 | perror(s); | |
15 | exit(1); | |
16 | 16 | } |
17 | 17 | |
18 | int | |
19 | number_of_columns() { | |
20 | int fda; | |
21 | unsigned char rc[2]; /* unsigned: Ranty@soon.com */ | |
18 | int number_of_columns() | |
19 | { | |
20 | int fda; | |
21 | unsigned char rc[2]; /* unsigned: Ranty@soon.com */ | |
22 | 22 | |
23 | if((fda = open("/dev/vcsa", O_RDONLY)) < 0 | |
24 | && (fda = open("/dev/vcsa0", O_RDONLY)) < 0) | |
25 | fatal("/dev/vcsa"); | |
26 | if(read(fda, rc, 2) != 2) | |
27 | fatal("/dev/vcsa"); | |
28 | close(fda); | |
29 | return rc[1]; | |
23 | if ((fda = open("/dev/vcsa", O_RDONLY)) < 0 && (fda = open("/dev/vcsa0", O_RDONLY)) < 0) | |
24 | fatal("/dev/vcsa"); | |
25 | if (read(fda, rc, 2) != 2) | |
26 | fatal("/dev/vcsa"); | |
27 | close(fda); | |
28 | return rc[1]; | |
30 | 29 | } |
31 | 30 | |
32 | int | |
33 | main(){ | |
34 | int fd; | |
35 | int cols = number_of_columns(); | |
36 | time_t tid; | |
37 | struct tm *t; | |
38 | char tijd[10]; | |
31 | int main() | |
32 | { | |
33 | int fd; | |
34 | int cols = number_of_columns(); | |
35 | time_t tid; | |
36 | struct tm *t; | |
37 | char tijd[10]; | |
39 | 38 | |
40 | if((fd = open("/dev/vcs", O_WRONLY)) < 0 | |
41 | && (fd = open("/dev/vcs0", O_WRONLY)) < 0) | |
42 | fatal("/dev/vcs"); | |
39 | if ((fd = open("/dev/vcs", O_WRONLY)) < 0 && (fd = open("/dev/vcs0", O_WRONLY)) < 0) | |
40 | fatal("/dev/vcs"); | |
43 | 41 | |
44 | while(1) { | |
45 | lseek(fd, cols-10, 0); | |
46 | tid = time(0); | |
47 | t = localtime(&tid); | |
48 | sprintf(tijd, " %02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec); | |
49 | write(fd, tijd, 9); | |
50 | usleep(500000L); /* or sleep(1); */ | |
51 | } | |
42 | while (1) { | |
43 | lseek(fd, cols - 10, 0); | |
44 | tid = time(0); | |
45 | t = localtime(&tid); | |
46 | sprintf(tijd, " %02d:%02d:%02d", t->tm_hour, t->tm_min, t->tm_sec); | |
47 | write(fd, tijd, 9); | |
48 | usleep(500000L); /* or sleep(1); */ | |
49 | } | |
52 | 50 | } |
14 | 14 | #include "version.h" |
15 | 15 | #include "kbd_error.h" |
16 | 16 | |
17 | int | |
18 | main(int argc, char *argv[]) { | |
19 | int fd, num; | |
17 | int main(int argc, char *argv[]) | |
18 | { | |
19 | int fd, num; | |
20 | 20 | |
21 | set_progname(argv[0]); | |
21 | set_progname(argv[0]); | |
22 | 22 | |
23 | setlocale(LC_ALL, ""); | |
24 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
25 | textdomain(PACKAGE_NAME); | |
23 | setlocale(LC_ALL, ""); | |
24 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
25 | textdomain(PACKAGE_NAME); | |
26 | 26 | |
27 | if (argc == 2 && !strcmp(argv[1], "-V")) | |
28 | print_version_and_exit(); | |
27 | if (argc == 2 && !strcmp(argv[1], "-V")) | |
28 | print_version_and_exit(); | |
29 | 29 | |
30 | if (argc != 2) { | |
31 | fprintf(stderr, _("usage: chvt N\n")); | |
32 | return EXIT_FAILURE; | |
33 | } | |
30 | if (argc != 2) { | |
31 | fprintf(stderr, _("usage: chvt N\n")); | |
32 | return EXIT_FAILURE; | |
33 | } | |
34 | 34 | |
35 | if ((fd = getfd(NULL)) < 0) | |
36 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); | |
35 | if ((fd = getfd(NULL)) < 0) | |
36 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); | |
37 | 37 | |
38 | num = atoi(argv[1]); | |
38 | num = atoi(argv[1]); | |
39 | 39 | |
40 | if (ioctl(fd,VT_ACTIVATE,num)) { | |
41 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_ACTIVATE"); | |
42 | } | |
40 | if (ioctl(fd, VT_ACTIVATE, num)) { | |
41 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_ACTIVATE"); | |
42 | } | |
43 | 43 | |
44 | if (ioctl(fd,VT_WAITACTIVE,num)) { | |
45 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_WAITACTIVE"); | |
46 | } | |
44 | if (ioctl(fd, VT_WAITACTIVE, num)) { | |
45 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_WAITACTIVE"); | |
46 | } | |
47 | 47 | |
48 | return EXIT_SUCCESS; | |
48 | return EXIT_SUCCESS; | |
49 | 49 | } |
13 | 13 | #include "getfd.h" |
14 | 14 | #include "nls.h" |
15 | 15 | |
16 | int | |
17 | main(int argc, char *argv[]) { | |
16 | int main(int argc, char *argv[]) | |
17 | { | |
18 | 18 | int fd; |
19 | 19 | char *console = NULL; |
20 | 20 | |
28 | 28 | if ((fd = getfd(console)) < 0) |
29 | 29 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
30 | 30 | |
31 | return loadunimap (fd, NULL, NULL); | |
31 | return loadunimap(fd, NULL, NULL); | |
32 | 32 | } |
19 | 19 | * Changes in use: 1.1.74: you have to be root for PIO_FONT. |
20 | 20 | */ |
21 | 21 | #ifndef GIO_FONT |
22 | #define GIO_FONT 0x4B60 | |
23 | #define PIO_FONT 0x4B61 | |
22 | #define GIO_FONT 0x4B60 | |
23 | #define PIO_FONT 0x4B61 | |
24 | 24 | #endif |
25 | 25 | |
26 | 26 | /* |
45 | 45 | * The old GIO_FONT will fail if the fontsize is 512. |
46 | 46 | */ |
47 | 47 | #ifndef GIO_FONTX |
48 | #define GIO_FONTX 0x4B6B | |
49 | #define PIO_FONTX 0x4B6C | |
48 | #define GIO_FONTX 0x4B6B | |
49 | #define PIO_FONTX 0x4B6C | |
50 | 50 | struct consolefontdesc { |
51 | 51 | unsigned short charcount; |
52 | 52 | unsigned short charheight; |
72 | 72 | * In other words, this ioctl is totally useless today. |
73 | 73 | */ |
74 | 74 | #ifndef PIO_FONTRESET |
75 | #define PIO_FONTRESET 0x4B6D /* reset to default font */ | |
75 | #define PIO_FONTRESET 0x4B6D /* reset to default font */ | |
76 | 76 | #endif |
77 | 77 | |
78 | 78 | /* |
85 | 85 | #ifndef KDFONTOP |
86 | 86 | #define KDFONTOP 0x4B72 |
87 | 87 | struct console_font_op { |
88 | unsigned int op; /* KD_FONT_OP_* */ | |
89 | unsigned int flags; /* KD_FONT_FLAG_* */ | |
90 | unsigned int width, height; | |
91 | unsigned int charcount; | |
92 | unsigned char *data; /* font data with height fixed to 32 */ | |
88 | unsigned int op; /* KD_FONT_OP_* */ | |
89 | unsigned int flags; /* KD_FONT_FLAG_* */ | |
90 | unsigned int width, height; | |
91 | unsigned int charcount; | |
92 | unsigned char *data; /* font data with height fixed to 32 */ | |
93 | 93 | }; |
94 | 94 | |
95 | #define KD_FONT_OP_SET 0 /* Set font */ | |
96 | #define KD_FONT_OP_GET 1 /* Get font */ | |
97 | #define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, | |
98 | data points to name / NULL */ | |
99 | #define KD_FONT_OP_COPY 3 /* Copy from another console */ | |
95 | #define KD_FONT_OP_SET 0 /* Set font */ | |
96 | #define KD_FONT_OP_GET 1 /* Get font */ | |
97 | #define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, \ | |
98 | data points to name / NULL */ | |
99 | #define KD_FONT_OP_COPY 3 /* Copy from another console */ | |
100 | 100 | |
101 | #define KD_FONT_FLAG_OLD 0x80000000 /* Invoked via old interface */ | |
102 | #define KD_FONT_FLAG_DONT_RECALC 1 /* Don't call adjust_height() */ | |
103 | /* (Used internally for PIO_FONT support) */ | |
104 | #endif /* KDFONTOP */ | |
101 | #define KD_FONT_FLAG_OLD 0x80000000 /* Invoked via old interface */ | |
102 | #define KD_FONT_FLAG_DONT_RECALC 1 /* Don't call adjust_height() */ | |
103 | /* (Used internally for PIO_FONT support) */ | |
104 | #endif /* KDFONTOP */ | |
105 | 105 | |
106 | 106 | #ifndef KDKBDREP |
107 | 107 | /* usually defined in <linux/kd.h> */ |
108 | 108 | /* set keyboard delay/repeat rate; |
109 | 109 | * actually used values are returned */ |
110 | #define KDKBDREP 0x4B52 | |
110 | #define KDKBDREP 0x4B52 | |
111 | 111 | #endif |
16 | 16 | #include "version.h" |
17 | 17 | #include "kbd_error.h" |
18 | 18 | |
19 | int | |
20 | main(int argc, char *argv[]) { | |
19 | int main(int argc, char *argv[]) | |
20 | { | |
21 | 21 | int fd, num, i; |
22 | 22 | |
23 | if (argc < 1) /* unlikely */ | |
23 | if (argc < 1) /* unlikely */ | |
24 | 24 | return EXIT_FAILURE; |
25 | 25 | set_progname(argv[0]); |
26 | 26 | |
43 | 43 | |
44 | 44 | if (argc == 1) { |
45 | 45 | /* deallocate all unused consoles */ |
46 | if (ioctl(fd,VT_DISALLOCATE,0)) { | |
46 | if (ioctl(fd, VT_DISALLOCATE, 0)) { | |
47 | 47 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_DISALLOCATE"); |
48 | 48 | } |
49 | } else for (i = 1; i < argc; i++) { | |
50 | num = atoi(argv[i]); | |
51 | if (num == 0) { | |
52 | kbd_error(EXIT_FAILURE, 0, _("0: illegal VT number\n")); | |
53 | } else if (num == 1) { | |
54 | kbd_error(EXIT_FAILURE, 0, _("VT 1 is the console and cannot be deallocated\n")); | |
55 | } else if (ioctl(fd,VT_DISALLOCATE,num)) { | |
56 | kbd_error(EXIT_FAILURE, errno, _("could not deallocate console %d: " | |
57 | "ioctl VT_DISALLOCATE"), num); | |
49 | } else | |
50 | for (i = 1; i < argc; i++) { | |
51 | num = atoi(argv[i]); | |
52 | if (num == 0) { | |
53 | kbd_error(EXIT_FAILURE, 0, _("0: illegal VT number\n")); | |
54 | } else if (num == 1) { | |
55 | kbd_error(EXIT_FAILURE, 0, _("VT 1 is the console and cannot be deallocated\n")); | |
56 | } else if (ioctl(fd, VT_DISALLOCATE, num)) { | |
57 | kbd_error(EXIT_FAILURE, errno, _("could not deallocate console %d: " | |
58 | "ioctl VT_DISALLOCATE"), | |
59 | num); | |
60 | } | |
58 | 61 | } |
59 | } | |
60 | 62 | exit(EXIT_SUCCESS); |
61 | 63 | } |
23 | 23 | |
24 | 24 | static int fd; |
25 | 25 | |
26 | static void __attribute__ ((noreturn)) | |
27 | usage(void) { | |
26 | static void __attribute__((noreturn)) | |
27 | usage(void) | |
28 | { | |
28 | 29 | fprintf(stderr, _("dumpkeys version %s"), PACKAGE_VERSION); |
29 | 30 | fprintf(stderr, _("\ |
30 | 31 | \n\ |
55 | 56 | exit(1); |
56 | 57 | } |
57 | 58 | |
58 | int | |
59 | main (int argc, char *argv[]) { | |
60 | const char *short_opts = "hilvsnf1tkdS:c:V"; | |
59 | int main(int argc, char *argv[]) | |
60 | { | |
61 | const char *short_opts = "hilvsnf1tkdS:c:V"; | |
61 | 62 | const struct option long_opts[] = { |
62 | { "help", no_argument, NULL, 'h' }, | |
63 | { "short-info", no_argument, NULL, 'i' }, | |
64 | { "long-info", no_argument, NULL, 'l' }, | |
65 | { "numeric", no_argument, NULL, 'n' }, | |
66 | { "full-table", no_argument, NULL, 'f' }, | |
67 | { "separate-lines",no_argument, NULL, '1' }, | |
68 | { "shape", required_argument, NULL, 'S' }, | |
69 | { "funcs-only", no_argument, NULL, 't' }, | |
70 | { "keys-only", no_argument, NULL, 'k' }, | |
71 | { "compose-only",no_argument, NULL, 'd' }, | |
72 | { "charset", required_argument, NULL, 'c' }, | |
73 | { "verbose", no_argument, NULL, 'v' }, | |
74 | { "version", no_argument, NULL, 'V' }, | |
75 | { NULL, 0, NULL, 0 } | |
63 | { "help", no_argument, NULL, 'h' }, | |
64 | { "short-info", no_argument, NULL, 'i' }, | |
65 | { "long-info", no_argument, NULL, 'l' }, | |
66 | { "numeric", no_argument, NULL, 'n' }, | |
67 | { "full-table", no_argument, NULL, 'f' }, | |
68 | { "separate-lines", no_argument, NULL, '1' }, | |
69 | { "shape", required_argument, NULL, 'S' }, | |
70 | { "funcs-only", no_argument, NULL, 't' }, | |
71 | { "keys-only", no_argument, NULL, 'k' }, | |
72 | { "compose-only", no_argument, NULL, 'd' }, | |
73 | { "charset", required_argument, NULL, 'c' }, | |
74 | { "verbose", no_argument, NULL, 'v' }, | |
75 | { "version", no_argument, NULL, 'V' }, | |
76 | { NULL, 0, NULL, 0 } | |
76 | 77 | }; |
77 | 78 | int c, rc; |
78 | 79 | int kbd_mode; |
79 | 80 | |
80 | char long_info = 0; | |
81 | char short_info = 0; | |
82 | char numeric = 0; | |
81 | char long_info = 0; | |
82 | char short_info = 0; | |
83 | char numeric = 0; | |
83 | 84 | lk_table_shape table = LK_SHAPE_DEFAULT; |
84 | char funcs_only = 0; | |
85 | char keys_only = 0; | |
86 | char diac_only = 0; | |
85 | char funcs_only = 0; | |
86 | char keys_only = 0; | |
87 | char diac_only = 0; | |
87 | 88 | |
88 | 89 | struct lk_ctx *ctx; |
89 | 90 | |
99 | 100 | } |
100 | 101 | |
101 | 102 | while ((c = getopt_long(argc, argv, |
102 | short_opts, long_opts, NULL)) != -1) { | |
103 | short_opts, long_opts, NULL)) != -1) { | |
103 | 104 | switch (c) { |
104 | 105 | case 'i': |
105 | 106 | short_info = 1; |
135 | 136 | case 'c': |
136 | 137 | if ((lk_set_charset(ctx, optarg)) != 0) { |
137 | 138 | fprintf(stderr, _("unknown charset %s - ignoring charset request\n"), |
138 | optarg); | |
139 | optarg); | |
139 | 140 | usage(); |
140 | 141 | } |
141 | 142 | printf("charset \"%s\"\n", optarg); |
157 | 158 | /* check whether the keyboard is in Unicode mode */ |
158 | 159 | if (ioctl(fd, KDGKBMODE, &kbd_mode)) { |
159 | 160 | fprintf(stderr, _("%s: error reading keyboard mode: %m\n"), |
160 | progname); | |
161 | progname); | |
161 | 162 | exit(EXIT_FAILURE); |
162 | 163 | } |
163 | 164 | |
173 | 174 | |
174 | 175 | if (long_info) { |
175 | 176 | printf(_("Symbols recognized by %s:\n(numeric value, symbol)\n\n"), |
176 | progname); | |
177 | progname); | |
177 | 178 | lk_dump_symbols(ctx, stdout); |
178 | 179 | } |
179 | 180 | exit(EXIT_SUCCESS); |
182 | 183 | #ifdef KDGKBDIACR |
183 | 184 | if (!diac_only) { |
184 | 185 | #endif |
185 | if (!funcs_only) { | |
186 | lk_dump_keymap(ctx, stdout, table, numeric); | |
187 | } | |
186 | if (!funcs_only) { | |
187 | lk_dump_keymap(ctx, stdout, table, numeric); | |
188 | } | |
188 | 189 | #ifdef KDGKBDIACR |
189 | 190 | } |
190 | 191 | |
192 | 193 | lk_dump_diacs(ctx, stdout); |
193 | 194 | #endif |
194 | 195 | |
195 | fail: lk_free(ctx); | |
196 | fail: | |
197 | lk_free(ctx); | |
196 | 198 | close(fd); |
197 | 199 | |
198 | 200 | if (rc < 0) |
14 | 14 | #include "version.h" |
15 | 15 | #include "kbd_error.h" |
16 | 16 | |
17 | static void __attribute__ ((noreturn)) | |
17 | static void __attribute__((noreturn)) | |
18 | 18 | usage(void) |
19 | 19 | { |
20 | 20 | fprintf(stderr, _("%s version %s\n" |
21 | "\n" | |
22 | "Usage: %s [options]\n" | |
23 | "\n" | |
24 | "Valid options are:\n" | |
25 | "\n" | |
26 | " -h --help display this help text\n" | |
27 | " -V --version display program version\n" | |
28 | " -n --next-available display number of next unallocated VT\n"), | |
29 | progname, PACKAGE_VERSION, progname); | |
21 | "\n" | |
22 | "Usage: %s [options]\n" | |
23 | "\n" | |
24 | "Valid options are:\n" | |
25 | "\n" | |
26 | " -h --help display this help text\n" | |
27 | " -V --version display program version\n" | |
28 | " -n --next-available display number of next unallocated VT\n"), | |
29 | progname, PACKAGE_VERSION, progname); | |
30 | 30 | exit(EXIT_FAILURE); |
31 | 31 | } |
32 | 32 | |
33 | int | |
34 | main(int argc, char **argv){ | |
33 | int main(int argc, char **argv) | |
34 | { | |
35 | 35 | struct vt_stat vtstat; |
36 | 36 | int fd, vtno = -1, c, show_vt = 0; |
37 | 37 | struct serial_struct sr; |
38 | 38 | const struct option long_opts[] = { |
39 | { "help", no_argument, NULL, 'h' }, | |
40 | { "version", no_argument, NULL, 'V' }, | |
41 | { "next-available", no_argument, NULL, 'n' }, | |
42 | { NULL, 0, NULL, 0 } }; | |
39 | { "help", no_argument, NULL, 'h' }, | |
40 | { "version", no_argument, NULL, 'V' }, | |
41 | { "next-available", no_argument, NULL, 'n' }, | |
42 | { NULL, 0, NULL, 0 } | |
43 | }; | |
43 | 44 | |
44 | 45 | setlocale(LC_ALL, ""); |
45 | 46 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); |
46 | 47 | textdomain(PACKAGE_NAME); |
47 | 48 | |
48 | 49 | set_progname(argv[0]); |
49 | while (( c = getopt_long (argc, argv, "Vhn", long_opts, NULL)) != EOF) { | |
50 | switch (c) { | |
51 | case 'h': | |
52 | usage(); | |
53 | exit (0); | |
54 | case 'n': | |
55 | show_vt = 1; | |
56 | break; | |
57 | case 'V': | |
58 | print_version_and_exit(); | |
59 | break; | |
60 | case '?': | |
61 | usage(); | |
62 | exit(1); | |
63 | } | |
50 | while ((c = getopt_long(argc, argv, "Vhn", long_opts, NULL)) != EOF) { | |
51 | switch (c) { | |
52 | case 'h': | |
53 | usage(); | |
54 | exit(0); | |
55 | case 'n': | |
56 | show_vt = 1; | |
57 | break; | |
58 | case 'V': | |
59 | print_version_and_exit(); | |
60 | break; | |
61 | case '?': | |
62 | usage(); | |
63 | exit(1); | |
64 | } | |
64 | 65 | } |
65 | ||
66 | ||
66 | 67 | if ((fd = getfd(NULL)) < 0) |
67 | 68 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
68 | 69 | |
69 | 70 | if (show_vt) { |
70 | if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || vtno == -1) { | |
71 | kbd_error(2, errno, _("Couldn't read VTNO: ")); | |
72 | } | |
73 | printf ("%d\n", vtno); | |
74 | return EXIT_SUCCESS; | |
71 | if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || vtno == -1) { | |
72 | kbd_error(2, errno, _("Couldn't read VTNO: ")); | |
73 | } | |
74 | printf("%d\n", vtno); | |
75 | return EXIT_SUCCESS; | |
75 | 76 | } |
76 | ||
77 | ||
77 | 78 | if (ioctl(fd, TIOCGSERIAL, &sr) == 0) { |
78 | printf ("serial\n"); | |
79 | return EXIT_SUCCESS; | |
79 | printf("serial\n"); | |
80 | return EXIT_SUCCESS; | |
80 | 81 | } |
81 | ||
82 | ||
82 | 83 | if (ioctl(fd, VT_GETSTATE, &vtstat)) { |
83 | kbd_error(EXIT_FAILURE, errno, "fgconsole: VT_GETSTATE"); | |
84 | kbd_error(EXIT_FAILURE, errno, "fgconsole: VT_GETSTATE"); | |
84 | 85 | } |
85 | 86 | printf("%d\n", vtstat.v_active); |
86 | 87 | return EXIT_SUCCESS; |
28 | 28 | */ |
29 | 29 | |
30 | 30 | static int |
31 | is_a_console(int fd) { | |
31 | is_a_console(int fd) | |
32 | { | |
32 | 33 | char arg; |
33 | 34 | |
34 | 35 | arg = 0; |
35 | return (isatty (fd) | |
36 | && ioctl(fd, KDGKBTYPE, &arg) == 0 | |
37 | && ((arg == KB_101) || (arg == KB_84))); | |
36 | return (isatty(fd) && ioctl(fd, KDGKBTYPE, &arg) == 0 && ((arg == KB_101) || (arg == KB_84))); | |
38 | 37 | } |
39 | 38 | |
40 | 39 | static int |
41 | open_a_console(const char *fnam) { | |
40 | open_a_console(const char *fnam) | |
41 | { | |
42 | 42 | int fd; |
43 | 43 | |
44 | 44 | /* |
55 | 55 | return fd; |
56 | 56 | } |
57 | 57 | |
58 | int | |
59 | getfd(const char *fnam) { | |
58 | int getfd(const char *fnam) | |
59 | { | |
60 | 60 | int fd, i; |
61 | 61 | |
62 | 62 | if (fnam) { |
82 | 82 | return fd; |
83 | 83 | |
84 | 84 | fprintf(stderr, |
85 | _("Couldn't get a file descriptor referring to the console\n")); | |
85 | _("Couldn't get a file descriptor referring to the console\n")); | |
86 | 86 | |
87 | 87 | /* total failure */ |
88 | 88 | exit(1); |
15 | 15 | #include "version.h" |
16 | 16 | #include "kbd_error.h" |
17 | 17 | |
18 | static void __attribute__ ((noreturn)) | |
19 | usage(void) { | |
20 | fprintf(stderr, _("usage: getkeycodes\n")); | |
21 | exit(EXIT_FAILURE); | |
18 | static void __attribute__((noreturn)) | |
19 | usage(void) | |
20 | { | |
21 | fprintf(stderr, _("usage: getkeycodes\n")); | |
22 | exit(EXIT_FAILURE); | |
22 | 23 | } |
23 | 24 | |
24 | int | |
25 | main(int argc, char **argv) { | |
25 | int main(int argc, char **argv) | |
26 | { | |
26 | 27 | int fd; |
27 | 28 | unsigned int sc, sc0; |
28 | 29 | struct kbkeycode a; |
44 | 45 | |
45 | 46 | /* Old kernels don't support changing scancodes below SC_LIM. */ |
46 | 47 | a.scancode = 0; |
47 | a.keycode = 0; | |
48 | a.keycode = 0; | |
48 | 49 | if (ioctl(fd, KDGETKEYCODE, &a)) { |
49 | 50 | sc0 = 89; |
50 | 51 | } else |
51 | for (sc0 = 1; sc0 <= 88; sc0++) { | |
52 | a.scancode = sc0; | |
53 | a.keycode = 0; | |
54 | if (ioctl(fd, KDGETKEYCODE, &a) || a.keycode != sc0) | |
55 | break; | |
56 | } | |
52 | for (sc0 = 1; sc0 <= 88; sc0++) { | |
53 | a.scancode = sc0; | |
54 | a.keycode = 0; | |
55 | if (ioctl(fd, KDGETKEYCODE, &a) || a.keycode != sc0) | |
56 | break; | |
57 | } | |
57 | 58 | |
58 | 59 | printf(_("Plain scancodes xx (hex) versus keycodes (dec)\n")); |
59 | 60 | |
60 | 61 | if (sc0 == 89) { |
61 | 62 | printf(_("0 is an error; " |
62 | "for 1-88 (0x01-0x58) scancode equals keycode\n")); | |
63 | "for 1-88 (0x01-0x58) scancode equals keycode\n")); | |
63 | 64 | } else if (sc0 > 1) { |
64 | 65 | printf(_("for 1-%d (0x01-0x%02x) scancode equals keycode\n"), |
65 | 66 | sc0 - 1, sc0 - 1); |
72 | 73 | if (sc < 128) |
73 | 74 | printf("\n 0x%02x: ", sc); |
74 | 75 | else |
75 | printf("\ne0 %02x: ", sc-128); | |
76 | printf("\ne0 %02x: ", sc - 128); | |
76 | 77 | } |
77 | 78 | |
78 | 79 | if (sc < sc0) { |
81 | 82 | } |
82 | 83 | |
83 | 84 | a.scancode = sc; |
84 | a.keycode = 0; | |
85 | a.keycode = 0; | |
85 | 86 | if (ioctl(fd, KDGETKEYCODE, &a) == 0) { |
86 | 87 | printf(" %3d", a.keycode); |
87 | 88 | continue; |
91 | 92 | continue; |
92 | 93 | } |
93 | 94 | kbd_error(EXIT_FAILURE, errno, _("failed to get keycode for scancode 0x%x: " |
94 | "ioctl KDGETKEYCODE"), sc); | |
95 | "ioctl KDGETKEYCODE"), | |
96 | sc); | |
95 | 97 | exit(1); |
96 | 98 | } |
97 | 99 | printf("\n"); |
19 | 19 | #endif |
20 | 20 | |
21 | 21 | static int |
22 | ud_compar(const void *u1, const void *u2){ | |
23 | unsigned short fp1 = ((struct unipair *) u1)->fontpos; | |
24 | unsigned short fp2 = ((struct unipair *) u2)->fontpos; | |
25 | return (int) fp1 - (int) fp2; | |
22 | ud_compar(const void *u1, const void *u2) | |
23 | { | |
24 | unsigned short fp1 = ((struct unipair *)u1)->fontpos; | |
25 | unsigned short fp2 = ((struct unipair *)u2)->fontpos; | |
26 | return (int)fp1 - (int)fp2; | |
26 | 27 | } |
27 | 28 | |
28 | static void __attribute__ ((noreturn)) | |
29 | usage(void) { | |
29 | static void __attribute__((noreturn)) | |
30 | usage(void) | |
31 | { | |
30 | 32 | fprintf(stderr, _("Usage:\n\t%s [-s] [-C console]\n"), progname); |
31 | 33 | exit(EXIT_FAILURE); |
32 | 34 | } |
33 | 35 | |
34 | int | |
35 | main(int argc, char **argv){ | |
36 | int main(int argc, char **argv) | |
37 | { | |
36 | 38 | int sortflag = 0; |
37 | char mb[]={0,0,0,0,0,0,0,0}; | |
39 | char mb[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | |
38 | 40 | unsigned mb_length; |
39 | 41 | int fd, c, i; |
40 | 42 | char *console = NULL; |
52 | 54 | |
53 | 55 | while ((c = getopt(argc, argv, "sC:")) != EOF) { |
54 | 56 | switch (c) { |
55 | case 's': | |
56 | sortflag = 1; | |
57 | break; | |
58 | case 'C': | |
59 | console = optarg; | |
60 | break; | |
61 | default: | |
62 | usage(); | |
57 | case 's': | |
58 | sortflag = 1; | |
59 | break; | |
60 | case 'C': | |
61 | console = optarg; | |
62 | break; | |
63 | default: | |
64 | usage(); | |
63 | 65 | } |
64 | 66 | } |
65 | 67 | |
76 | 78 | printf("# sorted kernel unimap - count=%d\n", ud.entry_ct); |
77 | 79 | /* sort and merge entries */ |
78 | 80 | qsort(ud.entries, ud.entry_ct, sizeof(ud.entries[0]), |
79 | ud_compar); | |
80 | for(i=0; i<ud.entry_ct; i++) { | |
81 | ud_compar); | |
82 | for (i = 0; i < ud.entry_ct; i++) { | |
81 | 83 | int fp = ud.entries[i].fontpos; |
82 | 84 | printf("0x%03x\tU+%04x", fp, ud.entries[i].unicode); |
83 | while (i+1 < ud.entry_ct && | |
84 | ud.entries[i+1].fontpos == fp) | |
85 | while (i + 1 < ud.entry_ct && | |
86 | ud.entries[i + 1].fontpos == fp) | |
85 | 87 | printf(" U+%04x", ud.entries[++i].unicode); |
86 | 88 | printf("\n"); |
87 | 89 | } |
88 | 90 | } else { |
89 | 91 | printf("# kernel unimap - count=%d\n", ud.entry_ct); |
90 | for(i=0; i<ud.entry_ct; i++) { | |
91 | mb_length = wctomb (mb, ud.entries[i].unicode); | |
92 | mb[ (mb_length > 6) ? 0 : mb_length ] = 0 ; | |
92 | for (i = 0; i < ud.entry_ct; i++) { | |
93 | mb_length = wctomb(mb, ud.entries[i].unicode); | |
94 | mb[(mb_length > 6) ? 0 : mb_length] = 0; | |
93 | 95 | if (mb_length == 1 && !isprint(mb[0])) { |
94 | 96 | mb[2] = 0; |
95 | 97 | mb[1] = mb[0] + 0100; |
1 | 1 | #define _KBD_H |
2 | 2 | |
3 | 3 | #ifndef __GNUC__ |
4 | # define __attribute__(x) /*NOTHING*/ | |
4 | #define __attribute__(x) /*NOTHING*/ | |
5 | 5 | #endif |
6 | 6 | |
7 | 7 | #endif /* _KBD_H */ |
11 | 11 | extern const char *progname; |
12 | 12 | |
13 | 13 | void |
14 | __attribute__ ((format (printf, 2, 3))) | |
15 | kbd_warning(const int errnum, const char *fmt, ...) | |
14 | __attribute__((format(printf, 2, 3))) | |
15 | kbd_warning(const int errnum, const char *fmt, ...) | |
16 | 16 | { |
17 | 17 | va_list ap; |
18 | 18 | |
29 | 29 | } |
30 | 30 | |
31 | 31 | void |
32 | __attribute__ ((noreturn)) | |
33 | __attribute__ ((format (printf, 3, 4))) | |
34 | kbd_error(const int exitnum, const int errnum, const char *fmt, ...) | |
32 | __attribute__((noreturn)) | |
33 | __attribute__((format(printf, 3, 4))) | |
34 | kbd_error(const int exitnum, const int errnum, const char *fmt, ...) | |
35 | 35 | { |
36 | 36 | va_list ap; |
37 | 37 | va_start(ap, fmt); |
17 | 17 | #include "version.h" |
18 | 18 | #include "kbd_error.h" |
19 | 19 | |
20 | static void __attribute__ ((noreturn)) | |
21 | usage(void){ | |
22 | fprintf(stderr, _("usage: kbd_mode [-a|-u|-k|-s] [-C device]\n")); | |
23 | exit(EXIT_FAILURE); | |
20 | static void __attribute__((noreturn)) | |
21 | usage(void) | |
22 | { | |
23 | fprintf(stderr, _("usage: kbd_mode [-a|-u|-k|-s] [-C device]\n")); | |
24 | exit(EXIT_FAILURE); | |
24 | 25 | } |
25 | 26 | |
26 | int | |
27 | main(int argc, char *argv[]){ | |
28 | int fd, mode, c, n = 0; | |
29 | char *console = NULL; | |
27 | int main(int argc, char *argv[]) | |
28 | { | |
29 | int fd, mode, c, n = 0; | |
30 | char *console = NULL; | |
30 | 31 | |
31 | 32 | set_progname(argv[0]); |
32 | 33 | |
35 | 36 | textdomain(PACKAGE_NAME); |
36 | 37 | |
37 | 38 | if (argc == 2 && !strcmp(argv[1], "-V")) |
38 | print_version_and_exit(); | |
39 | print_version_and_exit(); | |
39 | 40 | |
40 | 41 | while ((c = getopt(argc, argv, "auskC:")) != EOF) { |
41 | 42 | switch (c) { |
42 | case 'a': | |
43 | if (n > 0) | |
44 | usage (); | |
45 | mode = K_XLATE; | |
46 | n++; | |
47 | break; | |
48 | case 'u': | |
49 | if (n > 0) | |
50 | usage (); | |
51 | mode = K_UNICODE; | |
52 | n++; | |
53 | break; | |
54 | case 's': | |
55 | if (n > 0) | |
56 | usage (); | |
57 | mode = K_RAW; | |
58 | n++; | |
59 | break; | |
60 | case 'k': | |
61 | if (n > 0) | |
62 | usage (); | |
63 | mode = K_MEDIUMRAW; | |
64 | n++; | |
65 | break; | |
66 | case 'C': | |
67 | if (!optarg || !optarg[0]) | |
68 | usage (); | |
69 | console = optarg; | |
70 | break; | |
71 | default: | |
72 | usage(); | |
43 | case 'a': | |
44 | if (n > 0) | |
45 | usage(); | |
46 | mode = K_XLATE; | |
47 | n++; | |
48 | break; | |
49 | case 'u': | |
50 | if (n > 0) | |
51 | usage(); | |
52 | mode = K_UNICODE; | |
53 | n++; | |
54 | break; | |
55 | case 's': | |
56 | if (n > 0) | |
57 | usage(); | |
58 | mode = K_RAW; | |
59 | n++; | |
60 | break; | |
61 | case 'k': | |
62 | if (n > 0) | |
63 | usage(); | |
64 | mode = K_MEDIUMRAW; | |
65 | n++; | |
66 | break; | |
67 | case 'C': | |
68 | if (!optarg || !optarg[0]) | |
69 | usage(); | |
70 | console = optarg; | |
71 | break; | |
72 | default: | |
73 | usage(); | |
73 | 74 | } |
74 | 75 | } |
75 | 76 | |
77 | 78 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
78 | 79 | |
79 | 80 | if (n == 0) { |
80 | /* report mode */ | |
81 | if (ioctl(fd, KDGKBMODE, &mode)) { | |
82 | kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMODE"); | |
83 | } | |
84 | switch(mode) { | |
85 | case K_RAW: | |
86 | printf(_("The keyboard is in raw (scancode) mode\n")); | |
87 | break; | |
88 | case K_MEDIUMRAW: | |
89 | printf(_("The keyboard is in mediumraw (keycode) mode\n")); | |
90 | break; | |
91 | case K_XLATE: | |
92 | printf(_("The keyboard is in the default (ASCII) mode\n")); | |
93 | break; | |
94 | case K_UNICODE: | |
95 | printf(_("The keyboard is in Unicode (UTF-8) mode\n")); | |
96 | break; | |
97 | default: | |
98 | printf(_("The keyboard is in some unknown mode\n")); | |
99 | } | |
100 | return EXIT_SUCCESS; | |
81 | /* report mode */ | |
82 | if (ioctl(fd, KDGKBMODE, &mode)) { | |
83 | kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMODE"); | |
84 | } | |
85 | switch (mode) { | |
86 | case K_RAW: | |
87 | printf(_("The keyboard is in raw (scancode) mode\n")); | |
88 | break; | |
89 | case K_MEDIUMRAW: | |
90 | printf(_("The keyboard is in mediumraw (keycode) mode\n")); | |
91 | break; | |
92 | case K_XLATE: | |
93 | printf(_("The keyboard is in the default (ASCII) mode\n")); | |
94 | break; | |
95 | case K_UNICODE: | |
96 | printf(_("The keyboard is in Unicode (UTF-8) mode\n")); | |
97 | break; | |
98 | default: | |
99 | printf(_("The keyboard is in some unknown mode\n")); | |
100 | } | |
101 | return EXIT_SUCCESS; | |
101 | 102 | } |
102 | 103 | |
103 | 104 | if (ioctl(fd, KDSKBMODE, mode)) { |
13 | 13 | static const char *action = NULL; |
14 | 14 | static const char *value = NULL; |
15 | 15 | |
16 | static void __attribute__ ((noreturn)) | |
17 | usage(int code) { | |
16 | static void __attribute__((noreturn)) | |
17 | usage(int code) | |
18 | { | |
18 | 19 | fprintf(stderr, |
19 | _("Usage: %1$s [-C DEVICE] getmode [text|graphics]\n" | |
20 | " or: %1$s [-C DEVICE] gkbmode [raw|xlate|mediumraw|unicode]\n" | |
20 | _("Usage: %1$s [-C DEVICE] getmode [text|graphics]\n" | |
21 | " or: %1$s [-C DEVICE] gkbmode [raw|xlate|mediumraw|unicode]\n" | |
21 | 22 | " or: %1$s [-C DEVICE] gkbmeta [metabit|escprefix]\n" |
22 | 23 | " or: %1$s [-C DEVICE] gkbled [scrolllock|numlock|capslock]\n" |
23 | 24 | "Other options:\n" |
24 | 25 | " -h print this usage message\n" |
25 | 26 | " -V print version number\n"), |
26 | progname); | |
27 | progname); | |
27 | 28 | exit(code); |
28 | 29 | } |
29 | 30 | |
30 | 31 | static int |
31 | answer(const char *ans) { | |
32 | answer(const char *ans) | |
33 | { | |
32 | 34 | if (value) |
33 | 35 | return strcasecmp(value, ans) ? EXIT_FAILURE : EXIT_SUCCESS; |
34 | 36 | |
36 | 38 | return EXIT_SUCCESS; |
37 | 39 | } |
38 | 40 | |
39 | int | |
40 | main(int argc, char **argv) { | |
41 | int main(int argc, char **argv) | |
42 | { | |
41 | 43 | int fd, mode, c; |
42 | 44 | int rc = EXIT_FAILURE; |
43 | 45 | char flags; |
82 | 84 | kbd_error(EXIT_FAILURE, errno, "ioctl KDGETMODE"); |
83 | 85 | |
84 | 86 | switch (mode) { |
85 | case KD_TEXT: rc = answer("text"); break; | |
86 | case KD_GRAPHICS: rc = answer("graphics"); break; | |
87 | case KD_TEXT: | |
88 | rc = answer("text"); | |
89 | break; | |
90 | case KD_GRAPHICS: | |
91 | rc = answer("graphics"); | |
92 | break; | |
87 | 93 | } |
88 | 94 | |
89 | 95 | } else if (!strcasecmp("GKBMODE", action)) { |
91 | 97 | kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMODE"); |
92 | 98 | |
93 | 99 | switch (mode) { |
94 | case K_RAW: rc = answer("raw"); break; | |
95 | case K_XLATE: rc = answer("xlate"); break; | |
96 | case K_MEDIUMRAW: rc = answer("mediumraw"); break; | |
97 | case K_UNICODE: rc = answer("unicode"); break; | |
100 | case K_RAW: | |
101 | rc = answer("raw"); | |
102 | break; | |
103 | case K_XLATE: | |
104 | rc = answer("xlate"); | |
105 | break; | |
106 | case K_MEDIUMRAW: | |
107 | rc = answer("mediumraw"); | |
108 | break; | |
109 | case K_UNICODE: | |
110 | rc = answer("unicode"); | |
111 | break; | |
98 | 112 | } |
99 | 113 | |
100 | 114 | } else if (!strcasecmp("GKBMETA", action)) { |
102 | 116 | kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMETA"); |
103 | 117 | |
104 | 118 | switch (mode) { |
105 | case K_METABIT: rc = answer("metabit"); break; | |
106 | case K_ESCPREFIX: rc = answer("escprefix"); break; | |
119 | case K_METABIT: | |
120 | rc = answer("metabit"); | |
121 | break; | |
122 | case K_ESCPREFIX: | |
123 | rc = answer("escprefix"); | |
124 | break; | |
107 | 125 | } |
108 | 126 | |
109 | 127 | } else if (!strcasecmp("GKBLED", action)) { |
114 | 132 | |
115 | 133 | if (value) { |
116 | 134 | if (((mode & LED_SCR) && !strcasecmp(value, "scrolllock")) || |
117 | ((mode & LED_NUM) && !strcasecmp(value, "numlock")) || | |
135 | ((mode & LED_NUM) && !strcasecmp(value, "numlock")) || | |
118 | 136 | ((mode & LED_CAP) && !strcasecmp(value, "capslock"))) |
119 | 137 | rc = EXIT_SUCCESS; |
120 | 138 | } else { |
121 | 139 | printf("scrolllock:%s ", (mode & LED_SCR) ? "on" : "off"); |
122 | printf("numlock:%s ", (mode & LED_NUM) ? "on" : "off"); | |
123 | printf("capslock:%s\n", (mode & LED_CAP) ? "on" : "off"); | |
140 | printf("numlock:%s ", (mode & LED_NUM) ? "on" : "off"); | |
141 | printf("capslock:%s\n", (mode & LED_CAP) ? "on" : "off"); | |
124 | 142 | rc = EXIT_SUCCESS; |
125 | 143 | } |
126 | 144 |
87 | 87 | |
88 | 88 | /* Equal to kernel version, but field names vary. */ |
89 | 89 | struct my_kbd_repeat { |
90 | int delay; /* in msec; <= 0: don't change */ | |
91 | int period; /* in msec; <= 0: don't change */ | |
92 | /* earlier this field was misnamed "rate" */ | |
90 | int delay; /* in msec; <= 0: don't change */ | |
91 | int period; /* in msec; <= 0: don't change */ | |
92 | /* earlier this field was misnamed "rate" */ | |
93 | 93 | }; |
94 | 94 | |
95 | 95 | #include <signal.h> |
99 | 99 | #include "kbd_error.h" |
100 | 100 | |
101 | 101 | static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150, |
102 | 133, 120, 109, 100, 92, 86, 80, 75, 67, | |
103 | 60, 55, 50, 46, 43, 40, 37, 33, 30, 27, | |
104 | 25, 23, 21, 20 }; | |
105 | #define RATE_COUNT (sizeof( valid_rates ) / sizeof( int )) | |
102 | 133, 120, 109, 100, 92, 86, 80, 75, 67, | |
103 | 60, 55, 50, 46, 43, 40, 37, 33, 30, 27, | |
104 | 25, 23, 21, 20 }; | |
105 | #define RATE_COUNT (sizeof(valid_rates) / sizeof(int)) | |
106 | 106 | |
107 | 107 | static int valid_delays[] = { 250, 500, 750, 1000 }; |
108 | #define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int )) | |
108 | #define DELAY_COUNT (sizeof(valid_delays) / sizeof(int)) | |
109 | 109 | |
110 | 110 | static int |
111 | KDKBDREP_ioctl_ok(double rate, int delay, int silent) { | |
111 | KDKBDREP_ioctl_ok(double rate, int delay, int silent) | |
112 | { | |
112 | 113 | /* |
113 | 114 | * This ioctl is defined in <linux/kd.h> but is not |
114 | 115 | * implemented anywhere - must be in some m68k patches. |
118 | 119 | |
119 | 120 | /* don't change, just test */ |
120 | 121 | kbdrep_s.period = -1; |
121 | kbdrep_s.delay = -1; | |
122 | if (ioctl( 0, KDKBDREP, &kbdrep_s )) { | |
122 | kbdrep_s.delay = -1; | |
123 | if (ioctl(0, KDKBDREP, &kbdrep_s)) { | |
123 | 124 | if (errno == EINVAL || errno == ENOTTY) |
124 | 125 | return 0; |
125 | 126 | kbd_error(EXIT_FAILURE, errno, "ioctl KDKBDREP"); |
131 | 132 | #endif |
132 | 133 | |
133 | 134 | /* do the change */ |
134 | if (rate == 0) /* switch repeat off */ | |
135 | if (rate == 0) /* switch repeat off */ | |
135 | 136 | kbdrep_s.period = 0; |
136 | 137 | else |
137 | kbdrep_s.period = 1000.0 / rate; /* convert cps to msec */ | |
138 | kbdrep_s.period = 1000.0 / rate; /* convert cps to msec */ | |
138 | 139 | if (kbdrep_s.period < 1) |
139 | 140 | kbdrep_s.period = 1; |
140 | kbdrep_s.delay = delay; | |
141 | kbdrep_s.delay = delay; | |
141 | 142 | if (kbdrep_s.delay < 1) |
142 | 143 | kbdrep_s.delay = 1; |
143 | ||
144 | ||
144 | 145 | if (ioctl(0, KDKBDREP, &kbdrep_s)) { |
145 | 146 | kbd_error(EXIT_FAILURE, errno, "ioctl KDKBDREP"); |
146 | 147 | } |
149 | 150 | if (kbdrep_s.period == 0) |
150 | 151 | rate = 0; |
151 | 152 | else |
152 | rate = 1000.0 / (double) kbdrep_s.period; | |
153 | rate = 1000.0 / (double)kbdrep_s.period; | |
153 | 154 | |
154 | 155 | if (!silent) |
155 | printf( _("Typematic Rate set to %.1f cps (delay = %d ms)\n"), | |
156 | rate, kbdrep_s.delay ); | |
156 | printf(_("Typematic Rate set to %.1f cps (delay = %d ms)\n"), | |
157 | rate, kbdrep_s.delay); | |
157 | 158 | |
158 | 159 | kbdrep_s.period = -1; |
159 | kbdrep_s.delay = -1; | |
160 | if (ioctl( 0, KDKBDREP, &kbdrep_s )) { | |
160 | kbdrep_s.delay = -1; | |
161 | if (ioctl(0, KDKBDREP, &kbdrep_s)) { | |
161 | 162 | if (errno == EINVAL) |
162 | 163 | return 0; |
163 | 164 | kbd_error(EXIT_FAILURE, errno, "ioctl KDKBDREP"); |
167 | 168 | if (kbdrep_s.period == 0) |
168 | 169 | rate = 0; |
169 | 170 | else |
170 | rate = 1000.0 / (double) kbdrep_s.period; | |
171 | rate = 1000.0 / (double)kbdrep_s.period; | |
171 | 172 | |
172 | 173 | if (!silent) |
173 | printf( _("Typematic Rate set to %.1f cps (delay = %d ms)\n"), | |
174 | rate, kbdrep_s.delay ); | |
175 | ||
176 | return 1; /* success! */ | |
174 | printf(_("Typematic Rate set to %.1f cps (delay = %d ms)\n"), | |
175 | rate, kbdrep_s.delay); | |
176 | ||
177 | return 1; /* success! */ | |
177 | 178 | } |
178 | 179 | |
179 | 180 | #ifndef KIOCSRATE |
180 | #define arg_state __attribute__ ((unused)) | |
181 | #define arg_state __attribute__((unused)) | |
181 | 182 | #else |
182 | 183 | #define arg_state |
183 | 184 | #endif |
184 | 185 | |
185 | 186 | static int |
186 | KIOCSRATE_ioctl_ok(arg_state double rate, arg_state int delay, arg_state int silent) { | |
187 | KIOCSRATE_ioctl_ok(arg_state double rate, arg_state int delay, arg_state int silent) | |
188 | { | |
187 | 189 | #ifdef KIOCSRATE |
188 | 190 | struct kbd_rate kbdrate_s; |
189 | 191 | int fd; |
193 | 195 | kbd_error(EXIT_FAILURE, errno, "open /dev/kbd"); |
194 | 196 | } |
195 | 197 | |
196 | kbdrate_s.rate = (int) (rate + 0.5); /* round up */ | |
197 | kbdrate_s.delay = delay * HZ / 1000; /* convert ms to Hz */ | |
198 | kbdrate_s.rate = (int)(rate + 0.5); /* round up */ | |
199 | kbdrate_s.delay = delay * HZ / 1000; /* convert ms to Hz */ | |
198 | 200 | if (kbdrate_s.rate > 50) |
199 | 201 | kbdrate_s.rate = 50; |
200 | 202 | |
201 | if (ioctl( fd, KIOCSRATE, &kbdrate_s )) { | |
203 | if (ioctl(fd, KIOCSRATE, &kbdrate_s)) { | |
202 | 204 | kbd_error(EXIT_FAILURE, errno, "ioctl KIOCSRATE"); |
203 | 205 | } |
204 | close( fd ); | |
206 | close(fd); | |
205 | 207 | |
206 | 208 | if (!silent) |
207 | printf( "Typematic Rate set to %d cps (delay = %d ms)\n", | |
208 | kbdrate_s.rate, kbdrate_s.delay * 1000 / HZ ); | |
209 | printf("Typematic Rate set to %d cps (delay = %d ms)\n", | |
210 | kbdrate_s.rate, kbdrate_s.delay * 1000 / HZ); | |
209 | 211 | |
210 | 212 | return 1; |
211 | #else /* no KIOCSRATE */ | |
213 | #else /* no KIOCSRATE */ | |
212 | 214 | return 0; |
213 | 215 | #endif /* KIOCSRATE */ |
214 | 216 | } |
215 | 217 | |
216 | 218 | static void |
217 | sigalrmhandler(int sig __attribute__ ((unused))) { | |
219 | sigalrmhandler(int sig __attribute__((unused))) | |
220 | { | |
218 | 221 | kbd_warning(0, "Failed waiting for kbd controller!\n"); |
219 | raise( SIGINT ); | |
222 | raise(SIGINT); | |
220 | 223 | } |
221 | 224 | |
222 | int | |
223 | main( int argc, char **argv ) { | |
225 | int main(int argc, char **argv) | |
226 | { | |
224 | 227 | #ifdef __sparc__ |
225 | double rate = 5.0; /* Default rate */ | |
226 | int delay = 200; /* Default delay */ | |
228 | double rate = 5.0; /* Default rate */ | |
229 | int delay = 200; /* Default delay */ | |
227 | 230 | #else |
228 | double rate = 10.9; /* Default rate */ | |
229 | int delay = 250; /* Default delay */ | |
230 | #endif | |
231 | int value = 0x7f; /* Maximum delay with slowest rate */ | |
232 | /* DO NOT CHANGE this value */ | |
233 | int silent = 0; | |
234 | int fd; | |
235 | char data; | |
236 | int c; | |
231 | double rate = 10.9; /* Default rate */ | |
232 | int delay = 250; /* Default delay */ | |
233 | #endif | |
234 | int value = 0x7f; /* Maximum delay with slowest rate */ | |
235 | /* DO NOT CHANGE this value */ | |
236 | int silent = 0; | |
237 | int fd; | |
238 | char data; | |
239 | int c; | |
237 | 240 | unsigned int i; |
238 | 241 | extern char *optarg; |
239 | 242 | |
247 | 250 | (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) |
248 | 251 | print_version_and_exit(); |
249 | 252 | |
250 | while ( (c = getopt( argc, argv, "r:d:s" )) != EOF ) { | |
253 | while ((c = getopt(argc, argv, "r:d:s")) != EOF) { | |
251 | 254 | switch (c) { |
252 | case 'r': | |
253 | rate = atof( optarg ); | |
254 | break; | |
255 | case 'd': | |
256 | delay = atoi( optarg ); | |
257 | break; | |
258 | case 's': | |
259 | silent = 1; | |
260 | break; | |
261 | default: | |
262 | fprintf(stderr, | |
263 | _("Usage: kbdrate [-V | --version] [-s] [-r rate] [-d delay]\n")); | |
264 | exit(EXIT_FAILURE); | |
265 | } | |
266 | } | |
267 | ||
268 | if(KDKBDREP_ioctl_ok(rate, delay, silent)) /* m68k? */ | |
255 | case 'r': | |
256 | rate = atof(optarg); | |
257 | break; | |
258 | case 'd': | |
259 | delay = atoi(optarg); | |
260 | break; | |
261 | case 's': | |
262 | silent = 1; | |
263 | break; | |
264 | default: | |
265 | fprintf(stderr, | |
266 | _("Usage: kbdrate [-V | --version] [-s] [-r rate] [-d delay]\n")); | |
267 | exit(EXIT_FAILURE); | |
268 | } | |
269 | } | |
270 | ||
271 | if (KDKBDREP_ioctl_ok(rate, delay, silent)) /* m68k? */ | |
269 | 272 | return 0; |
270 | 273 | |
271 | if(KIOCSRATE_ioctl_ok(rate, delay, silent)) /* sparc? */ | |
274 | if (KIOCSRATE_ioctl_ok(rate, delay, silent)) /* sparc? */ | |
272 | 275 | return 0; |
273 | ||
274 | 276 | |
275 | 277 | /* The ioport way */ |
276 | 278 | |
281 | 283 | break; |
282 | 284 | } |
283 | 285 | |
284 | ||
285 | 286 | for (i = 0; i < DELAY_COUNT; i++) |
286 | 287 | if (delay <= valid_delays[i]) { |
287 | 288 | value &= 0x1f; |
289 | 290 | break; |
290 | 291 | } |
291 | 292 | |
292 | if ( (fd = open( "/dev/port", O_RDWR )) < 0) { | |
293 | if ((fd = open("/dev/port", O_RDWR)) < 0) { | |
293 | 294 | kbd_error(EXIT_FAILURE, errno, _("Cannot open /dev/port")); |
294 | 295 | } |
295 | 296 | |
296 | signal( SIGALRM, sigalrmhandler ); | |
297 | alarm( 3 ); | |
297 | signal(SIGALRM, sigalrmhandler); | |
298 | alarm(3); | |
298 | 299 | |
299 | 300 | do { |
300 | lseek( fd, 0x64, 0 ); | |
301 | if (read( fd, &data, 1 ) == -1) { | |
301 | lseek(fd, 0x64, 0); | |
302 | if (read(fd, &data, 1) == -1) { | |
302 | 303 | kbd_error(EXIT_FAILURE, errno, "read"); |
303 | 304 | } |
304 | } while ((data & 2) == 2 ); /* wait */ | |
305 | ||
306 | lseek( fd, 0x60, 0 ); | |
307 | data = 0xf3; /* set typematic rate */ | |
308 | if (write( fd, &data, 1 ) == -1) { | |
305 | } while ((data & 2) == 2); /* wait */ | |
306 | ||
307 | lseek(fd, 0x60, 0); | |
308 | data = 0xf3; /* set typematic rate */ | |
309 | if (write(fd, &data, 1) == -1) { | |
309 | 310 | kbd_error(EXIT_FAILURE, errno, "write"); |
310 | 311 | } |
311 | 312 | |
312 | 313 | do { |
313 | lseek( fd, 0x64, 0 ); | |
314 | if (read( fd, &data, 1 ) == -1) { | |
314 | lseek(fd, 0x64, 0); | |
315 | if (read(fd, &data, 1) == -1) { | |
315 | 316 | kbd_error(EXIT_FAILURE, errno, "read"); |
316 | 317 | } |
317 | } while ((data & 2) == 2 ); /* wait */ | |
318 | ||
319 | alarm( 0 ); | |
320 | ||
321 | lseek( fd, 0x60, 0 ); | |
322 | sleep( 1 ); | |
323 | if (write( fd, &value, 1 ) == -1) { | |
318 | } while ((data & 2) == 2); /* wait */ | |
319 | ||
320 | alarm(0); | |
321 | ||
322 | lseek(fd, 0x60, 0); | |
323 | sleep(1); | |
324 | if (write(fd, &value, 1) == -1) { | |
324 | 325 | kbd_error(EXIT_FAILURE, errno, "write"); |
325 | 326 | } |
326 | 327 | |
327 | close( fd ); | |
328 | close(fd); | |
328 | 329 | |
329 | 330 | if (!silent) |
330 | printf( _("Typematic Rate set to %.1f cps (delay = %d ms)\n"), | |
331 | valid_rates[value & 0x1f] / 10.0, | |
332 | valid_delays[ (value & 0x60) >> 5 ] ); | |
331 | printf(_("Typematic Rate set to %.1f cps (delay = %d ms)\n"), | |
332 | valid_rates[value & 0x1f] / 10.0, | |
333 | valid_delays[(value & 0x60) >> 5]); | |
333 | 334 | |
334 | 335 | return EXIT_SUCCESS; |
335 | 336 | } |
7 | 7 | |
8 | 8 | #include <stdio.h> |
9 | 9 | #include <errno.h> |
10 | #include <stdlib.h> /* free() */ | |
10 | #include <stdlib.h> /* free() */ | |
11 | 11 | #include <sys/ioctl.h> |
12 | 12 | #include <linux/kd.h> |
13 | 13 | #include "kdfontop.h" |
18 | 18 | #include "compat/linux-kd.h" |
19 | 19 | #endif |
20 | 20 | |
21 | int | |
22 | restorefont(int fd) { | |
21 | int restorefont(int fd) | |
22 | { | |
23 | 23 | if (ioctl(fd, PIO_FONTRESET, 0)) { |
24 | 24 | perror("PIO_FONTRESET"); |
25 | 25 | return -1; |
27 | 27 | return 0; |
28 | 28 | } |
29 | 29 | |
30 | int | |
31 | font_charheight(unsigned char *buf, int count, int width) { | |
30 | int font_charheight(unsigned char *buf, int count, int width) | |
31 | { | |
32 | 32 | int h, i, x; |
33 | int bytewidth = (width+7)/8; | |
33 | int bytewidth = (width + 7) / 8; | |
34 | 34 | |
35 | 35 | for (h = 32; h > 0; h--) |
36 | 36 | for (i = 0; i < count; i++) |
37 | 37 | for (x = 0; x < bytewidth; x++) |
38 | if (buf[(32*i+h-1)*bytewidth+x]) | |
38 | if (buf[(32 * i + h - 1) * bytewidth + x]) | |
39 | 39 | goto nonzero; |
40 | nonzero: | |
40 | nonzero: | |
41 | 41 | return h; |
42 | 42 | } |
43 | 43 | |
46 | 46 | * May be called with width==NULL and height==NULL. |
47 | 47 | * Must not exit - we may have cleanup to do. |
48 | 48 | */ |
49 | int | |
50 | getfont(int fd, unsigned char *buf, int *count, int *width, int *height) { | |
49 | int getfont(int fd, unsigned char *buf, int *count, int *width, int *height) | |
50 | { | |
51 | 51 | struct consolefontdesc cfd; |
52 | 52 | struct console_font_op cfo; |
53 | 53 | int i; |
54 | 54 | |
55 | 55 | /* First attempt: KDFONTOP */ |
56 | cfo.op = KD_FONT_OP_GET; | |
56 | cfo.op = KD_FONT_OP_GET; | |
57 | 57 | cfo.flags = 0; |
58 | 58 | cfo.width = cfo.height = 32; |
59 | cfo.charcount = *count; | |
60 | cfo.data = buf; | |
61 | i = ioctl(fd, KDFONTOP, &cfo); | |
59 | cfo.charcount = *count; | |
60 | cfo.data = buf; | |
61 | i = ioctl(fd, KDFONTOP, &cfo); | |
62 | 62 | if (i == 0) { |
63 | 63 | *count = cfo.charcount; |
64 | 64 | if (height) |
73 | 73 | } |
74 | 74 | |
75 | 75 | /* The other methods do not support width != 8 */ |
76 | if (width) *width = 8; | |
76 | if (width) | |
77 | *width = 8; | |
77 | 78 | /* Second attempt: GIO_FONTX */ |
78 | cfd.charcount = *count; | |
79 | cfd.charcount = *count; | |
79 | 80 | cfd.charheight = 0; |
80 | cfd.chardata = (char *)buf; | |
81 | i = ioctl(fd, GIO_FONTX, &cfd); | |
81 | cfd.chardata = (char *)buf; | |
82 | i = ioctl(fd, GIO_FONTX, &cfd); | |
82 | 83 | if (i == 0) { |
83 | 84 | *count = cfd.charcount; |
84 | 85 | if (height) |
96 | 97 | return -1; |
97 | 98 | } |
98 | 99 | if (!buf) { |
99 | fprintf(stderr, _("bug: getfont using GIO_FONT needs buf.\n")); | |
100 | return -1; | |
100 | fprintf(stderr, _("bug: getfont using GIO_FONT needs buf.\n")); | |
101 | return -1; | |
101 | 102 | } |
102 | 103 | i = ioctl(fd, GIO_FONT, buf); |
103 | 104 | if (i) { |
106 | 107 | } |
107 | 108 | *count = 256; |
108 | 109 | if (height) |
109 | *height = 0; /* undefined, at most 32 */ | |
110 | *height = 0; /* undefined, at most 32 */ | |
110 | 111 | return 0; |
111 | 112 | } |
112 | 113 | |
113 | int | |
114 | getfontsize(int fd) { | |
114 | int getfontsize(int fd) | |
115 | { | |
115 | 116 | int count; |
116 | 117 | int i; |
117 | 118 | |
118 | 119 | count = 0; |
119 | i = getfont(fd, NULL, &count, NULL, NULL); | |
120 | i = getfont(fd, NULL, &count, NULL, NULL); | |
120 | 121 | return (i == 0) ? count : 256; |
121 | 122 | } |
122 | 123 | |
123 | int | |
124 | putfont(int fd, unsigned char *buf, int count, int width, int height) { | |
124 | int putfont(int fd, unsigned char *buf, int count, int width, int height) | |
125 | { | |
125 | 126 | struct consolefontdesc cfd; |
126 | 127 | struct console_font_op cfo; |
127 | 128 | int i; |
132 | 133 | height = font_charheight(buf, count, width); |
133 | 134 | |
134 | 135 | /* First attempt: KDFONTOP */ |
135 | cfo.op = KD_FONT_OP_SET; | |
136 | cfo.flags = 0; | |
137 | cfo.width = width; | |
138 | cfo.height = height; | |
136 | cfo.op = KD_FONT_OP_SET; | |
137 | cfo.flags = 0; | |
138 | cfo.width = width; | |
139 | cfo.height = height; | |
139 | 140 | cfo.charcount = count; |
140 | cfo.data = buf; | |
141 | i = ioctl(fd, KDFONTOP, &cfo); | |
141 | cfo.data = buf; | |
142 | i = ioctl(fd, KDFONTOP, &cfo); | |
142 | 143 | if (i == 0) |
143 | 144 | return 0; |
144 | 145 | if (width != 8 || (errno != ENOSYS && errno != EINVAL)) { |
149 | 150 | /* Variation on first attempt: in case count is not 256 or 512 |
150 | 151 | round up and try again. */ |
151 | 152 | if (errno == EINVAL && width == 8 && count != 256 && count < 512) { |
152 | int ct = ((count > 256) ? 512 : 256); | |
153 | int ct = ((count > 256) ? 512 : 256); | |
153 | 154 | unsigned char *mybuf = malloc(32 * ct); |
154 | 155 | |
155 | 156 | if (!mybuf) { |
158 | 159 | } |
159 | 160 | memset(mybuf, 0, 32 * ct); |
160 | 161 | memcpy(mybuf, buf, 32 * count); |
161 | cfo.data = mybuf; | |
162 | cfo.data = mybuf; | |
162 | 163 | cfo.charcount = ct; |
163 | i = ioctl(fd, KDFONTOP, &cfo); | |
164 | i = ioctl(fd, KDFONTOP, &cfo); | |
164 | 165 | free(mybuf); |
165 | 166 | if (i == 0) |
166 | 167 | return 0; |
167 | 168 | } |
168 | 169 | |
169 | 170 | /* Second attempt: PIO_FONTX */ |
170 | cfd.charcount = count; | |
171 | cfd.charcount = count; | |
171 | 172 | cfd.charheight = height; |
172 | cfd.chardata = (char *)buf; | |
173 | i = ioctl(fd, PIO_FONTX, &cfd); | |
173 | cfd.chardata = (char *)buf; | |
174 | i = ioctl(fd, PIO_FONTX, &cfd); | |
174 | 175 | if (i == 0) |
175 | 176 | return 0; |
176 | 177 | if (errno != ENOSYS && errno != EINVAL) { |
35 | 35 | * translation tables, and this ioctl would get/set the fourth |
36 | 36 | * table, while the other three tables are built-in and constant.) |
37 | 37 | */ |
38 | int | |
39 | getscrnmap(int fd, char *map) { | |
40 | if (ioctl(fd,GIO_SCRNMAP,map)) { | |
38 | int getscrnmap(int fd, char *map) | |
39 | { | |
40 | if (ioctl(fd, GIO_SCRNMAP, map)) { | |
41 | 41 | perror("GIO_SCRNMAP"); |
42 | 42 | return -1; |
43 | 43 | } |
44 | 44 | return 0; |
45 | 45 | } |
46 | 46 | |
47 | int | |
48 | loadscrnmap(int fd, char *map) { | |
49 | if (ioctl(fd,PIO_SCRNMAP,map)) { | |
47 | int loadscrnmap(int fd, char *map) | |
48 | { | |
49 | if (ioctl(fd, PIO_SCRNMAP, map)) { | |
50 | 50 | perror("PIO_SCRNMAP"); |
51 | 51 | return -1; |
52 | 52 | } |
76 | 76 | * In the new scheme, the old PIO_SCRNMAP fills the kernel umap |
77 | 77 | * table with such direct-to-font values. |
78 | 78 | */ |
79 | ||
80 | int | |
81 | getuniscrnmap(int fd, unsigned short *map) { | |
82 | if (ioctl(fd,GIO_UNISCRNMAP,map)) { | |
79 | ||
80 | int getuniscrnmap(int fd, unsigned short *map) | |
81 | { | |
82 | if (ioctl(fd, GIO_UNISCRNMAP, map)) { | |
83 | 83 | perror("GIO_UNISCRNMAP"); |
84 | 84 | return -1; |
85 | 85 | } |
86 | 86 | return 0; |
87 | 87 | } |
88 | 88 | |
89 | int | |
90 | loaduniscrnmap(int fd, unsigned short *map) { | |
91 | if (ioctl(fd,PIO_UNISCRNMAP,map)) { | |
89 | int loaduniscrnmap(int fd, unsigned short *map) | |
90 | { | |
91 | if (ioctl(fd, PIO_UNISCRNMAP, map)) { | |
92 | 92 | perror("PIO_UNISCRNMAP"); |
93 | 93 | return -1; |
94 | 94 | } |
132 | 132 | * Linux 2.6.1 makes GIO_UNIMAP, PIO_UNIMAP, PIO_UNIMAPCLR per-vt |
133 | 133 | * so that fd no longer is random. |
134 | 134 | */ |
135 | int | |
136 | getunimap(int fd, struct unimapdesc *ud0) { | |
135 | int getunimap(int fd, struct unimapdesc *ud0) | |
136 | { | |
137 | 137 | struct unimapdesc ud; |
138 | 138 | int ct; |
139 | 139 | |
140 | 140 | ud.entry_ct = 0; |
141 | ud.entries = 0; | |
141 | ud.entries = 0; | |
142 | 142 | if (ioctl(fd, GIO_UNIMAP, &ud)) { |
143 | if(errno != ENOMEM || ud.entry_ct == 0) { | |
143 | if (errno != ENOMEM || ud.entry_ct == 0) { | |
144 | 144 | perror("GIO_UNIMAP(0)"); |
145 | 145 | return -1; |
146 | 146 | } |
147 | ct = ud.entry_ct; | |
147 | ct = ud.entry_ct; | |
148 | 148 | ud.entries = (struct unipair *) |
149 | malloc(ct * sizeof(struct unipair)); | |
149 | malloc(ct * sizeof(struct unipair)); | |
150 | 150 | if (ud.entries == NULL) { |
151 | 151 | fprintf(stderr, _("%s: out of memory\n"), progname); |
152 | 152 | return -1; |
157 | 157 | } |
158 | 158 | if (ct != ud.entry_ct) |
159 | 159 | fprintf(stderr, |
160 | _("strange... ct changed from %d to %d\n"), | |
161 | ct, ud.entry_ct); | |
160 | _("strange... ct changed from %d to %d\n"), | |
161 | ct, ud.entry_ct); | |
162 | 162 | /* someone could change the unimap between our |
163 | 163 | first and second ioctl, so the above errors |
164 | 164 | are not impossible */ |
167 | 167 | return 0; |
168 | 168 | } |
169 | 169 | |
170 | int | |
171 | loadunimap(int fd, struct unimapinit *ui, struct unimapdesc *ud) { | |
170 | int loadunimap(int fd, struct unimapinit *ui, struct unimapdesc *ud) | |
171 | { | |
172 | 172 | struct unimapinit advice; |
173 | 173 | |
174 | 174 | if (ui) |
175 | 175 | advice = *ui; |
176 | 176 | else { |
177 | advice.advised_hashsize = 0; | |
178 | advice.advised_hashstep = 0; | |
177 | advice.advised_hashsize = 0; | |
178 | advice.advised_hashstep = 0; | |
179 | 179 | advice.advised_hashlevel = 0; |
180 | 180 | } |
181 | again: | |
181 | again: | |
182 | 182 | if (ioctl(fd, PIO_UNIMAPCLR, &advice)) { |
183 | 183 | #ifdef ENOIOCTLCMD |
184 | 184 | if (errno == ENOIOCTLCMD) { |
185 | 185 | fprintf(stderr, |
186 | _("It seems this kernel is older than 1.1.92\n" | |
187 | "No Unicode mapping table loaded.\n")); | |
186 | _("It seems this kernel is older than 1.1.92\n" | |
187 | "No Unicode mapping table loaded.\n")); | |
188 | 188 | } else |
189 | 189 | #endif |
190 | perror("PIO_UNIMAPCLR"); | |
190 | perror("PIO_UNIMAPCLR"); | |
191 | 191 | return -1; |
192 | 192 | } |
193 | 193 | if (ud == NULL) |
7 | 7 | |
8 | 8 | #include <keymap/array.h> |
9 | 9 | |
10 | int | |
11 | lk_array_init(struct lk_array *a, size_t memb, size_t size) | |
10 | int lk_array_init(struct lk_array *a, size_t memb, size_t size) | |
12 | 11 | { |
13 | 12 | if (!a) |
14 | 13 | return -EINVAL; |
25 | 24 | return 0; |
26 | 25 | } |
27 | 26 | |
28 | int | |
29 | lk_array_free(struct lk_array *a) | |
27 | int lk_array_free(struct lk_array *a) | |
30 | 28 | { |
31 | 29 | if (!a) |
32 | 30 | return -EINVAL; |
35 | 33 | return 0; |
36 | 34 | } |
37 | 35 | |
38 | int | |
39 | lk_array_empty(struct lk_array *a) | |
36 | int lk_array_empty(struct lk_array *a) | |
40 | 37 | { |
41 | 38 | if (!a) |
42 | 39 | return -EINVAL; |
47 | 44 | return 0; |
48 | 45 | } |
49 | 46 | |
50 | int | |
51 | lk_array_exists(struct lk_array *a, unsigned int i) | |
47 | int lk_array_exists(struct lk_array *a, unsigned int i) | |
52 | 48 | { |
53 | 49 | char *s; |
54 | 50 | size_t k; |
57 | 53 | return 0; |
58 | 54 | } |
59 | 55 | |
60 | s = (char *) (a->array + (a->memb * i)); | |
56 | s = (char *)(a->array + (a->memb * i)); | |
61 | 57 | |
62 | 58 | for (k = 0; k < a->memb; k++) { |
63 | 59 | if (s[k] != 0) |
106 | 102 | return 0; |
107 | 103 | } |
108 | 104 | |
109 | int | |
110 | lk_array_set(struct lk_array *a, unsigned int i, const void *e) | |
105 | int lk_array_set(struct lk_array *a, unsigned int i, const void *e) | |
111 | 106 | { |
112 | 107 | int ret = array_resize(a, i); |
113 | 108 | |
120 | 115 | return 0; |
121 | 116 | } |
122 | 117 | |
123 | int | |
124 | lk_array_unset(struct lk_array *a, unsigned int i) | |
118 | int lk_array_unset(struct lk_array *a, unsigned int i) | |
125 | 119 | { |
126 | 120 | if (!a || i >= a->total) |
127 | 121 | return -EINVAL; |
134 | 128 | return 0; |
135 | 129 | } |
136 | 130 | |
137 | int | |
138 | lk_array_append(struct lk_array *a, const void *e) | |
131 | int lk_array_append(struct lk_array *a, const void *e) | |
139 | 132 | { |
140 | 133 | int ret = array_resize(a, a->count); |
141 | 134 |
9 | 9 | #include "nls.h" |
10 | 10 | #include "contextP.h" |
11 | 11 | |
12 | void __attribute__ ((format (printf, 6, 7))) | |
12 | void __attribute__((format(printf, 6, 7))) | |
13 | 13 | lk_log(struct lk_ctx *ctx, int priority, |
14 | 14 | const char *file, int line, const char *fn, |
15 | 15 | const char *fmt, ...) |
23 | 23 | } |
24 | 24 | |
25 | 25 | #ifndef DEBUG |
26 | # define log_unused __attribute__ ((unused)) | |
26 | #define log_unused __attribute__((unused)) | |
27 | 27 | #else |
28 | # define log_unused | |
28 | #define log_unused | |
29 | 29 | #endif |
30 | 30 | |
31 | static void __attribute__ ((format(printf, 6, 0))) | |
31 | static void __attribute__((format(printf, 6, 0))) | |
32 | 32 | log_file(void *data, |
33 | int priority log_unused, | |
33 | int priority log_unused, | |
34 | 34 | const char *file log_unused, |
35 | const int line log_unused, | |
36 | const char *fn log_unused, | |
35 | const int line log_unused, | |
36 | const char *fn log_unused, | |
37 | 37 | const char *format, va_list args) |
38 | 38 | { |
39 | 39 | FILE *fp = data; |
42 | 42 | const char *priname; |
43 | 43 | |
44 | 44 | switch (priority) { |
45 | case LOG_EMERG: priname = "EMERGENCY"; break; | |
46 | case LOG_ALERT: priname = "ALERT"; break; | |
47 | case LOG_CRIT: priname = "CRITICAL"; break; | |
48 | case LOG_ERR: priname = "ERROR"; break; | |
49 | case LOG_WARNING: priname = "WARNING"; break; | |
50 | case LOG_NOTICE: priname = "NOTICE"; break; | |
51 | case LOG_INFO: priname = "INFO"; break; | |
52 | case LOG_DEBUG: priname = "DEBUG"; break; | |
45 | case LOG_EMERG: | |
46 | priname = "EMERGENCY"; | |
47 | break; | |
48 | case LOG_ALERT: | |
49 | priname = "ALERT"; | |
50 | break; | |
51 | case LOG_CRIT: | |
52 | priname = "CRITICAL"; | |
53 | break; | |
54 | case LOG_ERR: | |
55 | priname = "ERROR"; | |
56 | break; | |
57 | case LOG_WARNING: | |
58 | priname = "WARNING"; | |
59 | break; | |
60 | case LOG_NOTICE: | |
61 | priname = "NOTICE"; | |
62 | break; | |
63 | case LOG_INFO: | |
64 | priname = "INFO"; | |
65 | break; | |
66 | case LOG_DEBUG: | |
67 | priname = "DEBUG"; | |
68 | break; | |
53 | 69 | default: |
54 | 70 | snprintf(buf, sizeof(buf), "L:%d", priority); |
55 | 71 | priname = buf; |
62 | 78 | |
63 | 79 | #undef log_unused |
64 | 80 | |
65 | int | |
66 | lk_set_log_fn(struct lk_ctx *ctx, | |
67 | void (*log_fn)(void *data, int priority, | |
68 | const char *file, int line, const char *fn, | |
69 | const char *format, va_list args), | |
70 | const void *data) | |
81 | int lk_set_log_fn(struct lk_ctx *ctx, | |
82 | void (*log_fn)(void *data, int priority, | |
83 | const char *file, int line, const char *fn, | |
84 | const char *format, va_list args), | |
85 | const void *data) | |
71 | 86 | { |
72 | 87 | if (!ctx) |
73 | 88 | return -1; |
78 | 93 | return 0; |
79 | 94 | } |
80 | 95 | |
81 | int | |
82 | lk_get_log_priority(struct lk_ctx *ctx) | |
96 | int lk_get_log_priority(struct lk_ctx *ctx) | |
83 | 97 | { |
84 | 98 | if (!ctx) |
85 | 99 | return -1; |
87 | 101 | return ctx->log_priority; |
88 | 102 | } |
89 | 103 | |
90 | int | |
91 | lk_set_log_priority(struct lk_ctx *ctx, int priority) | |
104 | int lk_set_log_priority(struct lk_ctx *ctx, int priority) | |
92 | 105 | { |
93 | 106 | if (!ctx) |
94 | 107 | return -1; |
106 | 119 | return ctx->flags; |
107 | 120 | } |
108 | 121 | |
109 | int | |
110 | lk_set_parser_flags(struct lk_ctx *ctx, lk_flags flags) | |
122 | int lk_set_parser_flags(struct lk_ctx *ctx, lk_flags flags) | |
111 | 123 | { |
112 | 124 | if (!ctx) |
113 | 125 | return -1; |
153 | 165 | lk_set_log_fn(ctx, log_file, stderr); |
154 | 166 | lk_set_log_priority(ctx, LOG_ERR); |
155 | 167 | |
156 | if (init_array(ctx, &ctx->keymap, sizeof(void*)) < 0 || | |
157 | init_array(ctx, &ctx->func_table, sizeof(void*)) < 0 || | |
158 | init_array(ctx, &ctx->accent_table, sizeof(void*)) < 0 || | |
159 | init_array(ctx, &ctx->key_constant, sizeof(char)) < 0 || | |
160 | init_array(ctx, &ctx->key_line, sizeof(int)) < 0) { | |
168 | if (init_array(ctx, &ctx->keymap, sizeof(void *)) < 0 || | |
169 | init_array(ctx, &ctx->func_table, sizeof(void *)) < 0 || | |
170 | init_array(ctx, &ctx->accent_table, sizeof(void *)) < 0 || | |
171 | init_array(ctx, &ctx->key_constant, sizeof(char)) < 0 || | |
172 | init_array(ctx, &ctx->key_line, sizeof(int)) < 0) { | |
161 | 173 | lk_free(ctx); |
162 | 174 | return NULL; |
163 | 175 | } |
165 | 177 | return ctx; |
166 | 178 | } |
167 | 179 | |
168 | ||
169 | int | |
170 | lk_free(struct lk_ctx *ctx) | |
171 | { | |
172 | unsigned int i;//, j; | |
180 | int lk_free(struct lk_ctx *ctx) | |
181 | { | |
182 | unsigned int i; //, j; | |
173 | 183 | |
174 | 184 | if (!ctx) |
175 | 185 | return -1; |
18 | 18 | #include "contextP.h" |
19 | 19 | #include "ksyms.h" |
20 | 20 | |
21 | int | |
22 | lk_diacr_exists(struct lk_ctx *ctx, unsigned int index) | |
21 | int lk_diacr_exists(struct lk_ctx *ctx, unsigned int index) | |
23 | 22 | { |
24 | 23 | return (lk_array_get_ptr(ctx->accent_table, index) != NULL); |
25 | 24 | } |
26 | 25 | |
27 | int | |
28 | lk_get_diacr(struct lk_ctx *ctx, unsigned int index, struct lk_kbdiacr *dcr) | |
26 | int lk_get_diacr(struct lk_ctx *ctx, unsigned int index, struct lk_kbdiacr *dcr) | |
29 | 27 | { |
30 | 28 | struct lk_kbdiacr *ptr; |
31 | 29 | |
42 | 40 | return 0; |
43 | 41 | } |
44 | 42 | |
45 | int | |
46 | lk_append_diacr(struct lk_ctx *ctx, struct lk_kbdiacr *dcr) | |
43 | int lk_append_diacr(struct lk_ctx *ctx, struct lk_kbdiacr *dcr) | |
47 | 44 | { |
48 | 45 | struct lk_kbdiacr *ptr; |
49 | 46 | |
62 | 59 | return 0; |
63 | 60 | } |
64 | 61 | |
65 | int | |
66 | lk_add_diacr(struct lk_ctx *ctx, unsigned int index, struct lk_kbdiacr *dcr) | |
62 | int lk_add_diacr(struct lk_ctx *ctx, unsigned int index, struct lk_kbdiacr *dcr) | |
67 | 63 | { |
68 | 64 | struct lk_kbdiacr *ptr; |
69 | 65 | |
82 | 78 | return 0; |
83 | 79 | } |
84 | 80 | |
85 | int | |
86 | lk_del_diacr(struct lk_ctx *ctx, unsigned int index) | |
81 | int lk_del_diacr(struct lk_ctx *ctx, unsigned int index) | |
87 | 82 | { |
88 | 83 | int rc; |
89 | 84 | rc = lk_array_unset(ctx->accent_table, index); |
94 | 89 | return 0; |
95 | 90 | } |
96 | 91 | |
97 | int | |
98 | lk_append_compose(struct lk_ctx *ctx, struct lk_kbdiacr *dcr) | |
92 | int lk_append_compose(struct lk_ctx *ctx, struct lk_kbdiacr *dcr) | |
99 | 93 | { |
100 | 94 | struct lk_kbdiacr dcr0; |
101 | 95 | int direction = TO_8BIT; |
105 | 99 | direction = TO_UNICODE; |
106 | 100 | #endif |
107 | 101 | |
108 | dcr0.diacr = convert_code(ctx, dcr->diacr, direction); | |
109 | dcr0.base = convert_code(ctx, dcr->base, direction); | |
102 | dcr0.diacr = convert_code(ctx, dcr->diacr, direction); | |
103 | dcr0.base = convert_code(ctx, dcr->base, direction); | |
110 | 104 | dcr0.result = convert_code(ctx, dcr->result, direction); |
111 | 105 | |
112 | 106 | return lk_append_diacr(ctx, &dcr0); |
29 | 29 | { |
30 | 30 | fprintf(fd, "'"); |
31 | 31 | fprintf(fd, (c == '\'' || c == '\\') ? "\\%c" |
32 | : isgraph(c) ? "%c" | |
33 | : "\\%03o", c); | |
32 | : isgraph(c) ? "%c" | |
33 | : "\\%03o", | |
34 | c); | |
34 | 35 | fprintf(fd, comma ? "', " : "'"); |
35 | 36 | } |
36 | 37 | |
40 | 41 | { |
41 | 42 | fprintf(fd, "'"); |
42 | 43 | fprintf(fd, (c == '\'' || c == '\\') ? "\\%c" |
43 | : (isgraph(c) || c == ' ' || c >= 0200) ? "%c" | |
44 | : "\\%03o", c); | |
44 | : (isgraph(c) || c == ' ' || c >= 0200) ? "%c" | |
45 | : "\\%03o", | |
46 | c); | |
45 | 47 | fprintf(fd, comma ? "', " : "'"); |
46 | 48 | } |
47 | 49 | |
48 | int | |
49 | lk_dump_bkeymap(struct lk_ctx *ctx, FILE *fd) | |
50 | int lk_dump_bkeymap(struct lk_ctx *ctx, FILE *fd) | |
50 | 51 | { |
51 | 52 | unsigned int i, j; |
52 | 53 | char magic[] = "bkeymap"; |
80 | 81 | |
81 | 82 | return 0; |
82 | 83 | |
83 | fail: ERR(ctx, _("Error writing map to file")); | |
84 | fail: | |
85 | ERR(ctx, _("Error writing map to file")); | |
84 | 86 | return -1; |
85 | 87 | } |
86 | 88 | |
105 | 107 | return buf; |
106 | 108 | } |
107 | 109 | |
108 | int | |
109 | lk_dump_ctable(struct lk_ctx *ctx, FILE *fd) | |
110 | int lk_dump_ctable(struct lk_ctx *ctx, FILE *fd) | |
110 | 111 | { |
111 | 112 | int j; |
112 | 113 | unsigned int i, imax; |
120 | 121 | return -1; |
121 | 122 | |
122 | 123 | fprintf(fd, |
123 | /* not to be translated... */ | |
124 | "/* Do not edit this file! It was automatically generated by */\n"); | |
124 | /* not to be translated... */ | |
125 | "/* Do not edit this file! It was automatically generated by */\n"); | |
125 | 126 | fprintf(fd, "/* loadkeys --mktable defkeymap.map > defkeymap.c */\n\n"); |
126 | 127 | fprintf(fd, "#include <linux/keyboard.h>\n"); |
127 | 128 | fprintf(fd, "#include <linux/kd.h>\n\n"); |
152 | 153 | } |
153 | 154 | if (imax < MAX_NR_KEYMAPS - 1) |
154 | 155 | fprintf(fd, "\t0"); |
155 | fprintf(fd, "\n};\n\nunsigned int keymap_count = %u;\n\n", (unsigned int) ctx->keymap->count); | |
156 | ||
157 | /* uglified just for xgettext - it complains about nonterminated strings */ | |
156 | fprintf(fd, "\n};\n\nunsigned int keymap_count = %u;\n\n", (unsigned int)ctx->keymap->count); | |
157 | ||
158 | /* uglified just for xgettext - it complains about nonterminated strings */ | |
158 | 159 | fprintf(fd, |
159 | "/*\n" | |
160 | " * Philosophy: most people do not define more strings, but they who do\n" | |
161 | " * often want quite a lot of string space. So, we statically allocate\n" | |
162 | " * the default and allocate dynamically in chunks of 512 bytes.\n" | |
163 | " */\n" "\n"); | |
160 | "/*\n" | |
161 | " * Philosophy: most people do not define more strings, but they who do\n" | |
162 | " * often want quite a lot of string space. So, we statically allocate\n" | |
163 | " * the default and allocate dynamically in chunks of 512 bytes.\n" | |
164 | " */\n" | |
165 | "\n"); | |
164 | 166 | for (maxfunc = MAX_NR_FUNC; maxfunc; maxfunc--) |
165 | 167 | if (lk_array_get_ptr(ctx->func_table, maxfunc - 1)) |
166 | 168 | break; |
185 | 187 | fprintf(fd, "};\n\n"); |
186 | 188 | |
187 | 189 | fprintf(fd, |
188 | "char *funcbufptr = func_buf;\n" | |
189 | "int funcbufsize = sizeof(func_buf);\n" | |
190 | "int funcbufleft = 0; /* space left */\n" "\n"); | |
190 | "char *funcbufptr = func_buf;\n" | |
191 | "int funcbufsize = sizeof(func_buf);\n" | |
192 | "int funcbufleft = 0; /* space left */\n" | |
193 | "\n"); | |
191 | 194 | |
192 | 195 | fprintf(fd, "char *func_table[MAX_NR_FUNC] = {\n"); |
193 | 196 | for (i = 0; i < maxfunc; i++) { |
233 | 236 | fprintf(fd, "};\n\n"); |
234 | 237 | } |
235 | 238 | fprintf(fd, "unsigned int accent_table_size = %u;\n", |
236 | (unsigned int) ctx->accent_table->count); | |
239 | (unsigned int)ctx->accent_table->count); | |
237 | 240 | return 0; |
238 | 241 | } |
239 | 242 | |
240 | 243 | /* void dump_funcs(void) */ |
241 | void | |
242 | lk_dump_funcs(struct lk_ctx *ctx, FILE *fd) | |
244 | void lk_dump_funcs(struct lk_ctx *ctx, FILE *fd) | |
243 | 245 | { |
244 | 246 | unsigned int i; |
245 | 247 | |
266 | 268 | } |
267 | 269 | |
268 | 270 | /* void dump_diacs(void) */ |
269 | void | |
270 | lk_dump_diacs(struct lk_ctx *ctx, FILE *fd) | |
271 | void lk_dump_diacs(struct lk_ctx *ctx, FILE *fd) | |
271 | 272 | { |
272 | 273 | unsigned int i; |
273 | 274 | struct lk_kbdiacr *ptr; |
292 | 293 | } |
293 | 294 | } else |
294 | 295 | #endif |
295 | if (ptr->result > 0xff) { | |
296 | if (ptr->result > 0xff) { | |
296 | 297 | // impossible case? |
297 | 298 | fprintf(fd, " to 0x%x\n", ptr->result); |
298 | 299 | } else { |
308 | 309 | } |
309 | 310 | } |
310 | 311 | |
311 | void | |
312 | lk_dump_keymaps(struct lk_ctx *ctx, FILE *fd) | |
312 | void lk_dump_keymaps(struct lk_ctx *ctx, FILE *fd) | |
313 | 313 | { |
314 | 314 | unsigned int i; |
315 | 315 | int n, m, s; |
326 | 326 | continue; |
327 | 327 | n--, m--; |
328 | 328 | (n == m) |
329 | ? fprintf(fd, "%c%d" , (s ? ',' : ' '), n) | |
330 | : fprintf(fd, "%c%d-%d", (s ? ',' : ' '), n, m); | |
329 | ? fprintf(fd, "%c%d", (s ? ',' : ' '), n) | |
330 | : fprintf(fd, "%c%d-%d", (s ? ',' : ' '), n, m); | |
331 | 331 | n = m = 0; |
332 | s = 1; | |
332 | s = 1; | |
333 | 333 | } else { |
334 | 334 | if (!n) |
335 | n = i+1; | |
336 | m = i+1; | |
335 | n = i + 1; | |
336 | m = i + 1; | |
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | if (m) { |
341 | 341 | n--, m--; |
342 | 342 | (n == m) |
343 | ? fprintf(fd, "%c%d" , (s ? ',' : ' '), n) | |
344 | : fprintf(fd, "%c%d-%d", (s ? ',' : ' '), n, m); | |
343 | ? fprintf(fd, "%c%d", (s ? ',' : ' '), n) | |
344 | : fprintf(fd, "%c%d-%d", (s ? ',' : ' '), n, m); | |
345 | 345 | } |
346 | 346 | |
347 | 347 | fprintf(fd, "\n"); |
351 | 351 | print_mod(FILE *fd, int x) |
352 | 352 | { |
353 | 353 | if (x) { |
354 | modifier_t *mod = (modifier_t *) modifiers; | |
354 | modifier_t *mod = (modifier_t *)modifiers; | |
355 | 355 | while (mod->name) { |
356 | 356 | if (x & (1 << mod->bit)) |
357 | 357 | fprintf(fd, "%s\t", mod->name); |
389 | 389 | (p = codetoksym(ctx, code))) |
390 | 390 | fprintf(fd, "%-*s", 16 - plus, p); |
391 | 391 | else if (!numeric && t < syms_size && v < get_sym_size(ctx, t) && |
392 | (p = get_sym(ctx, t, v))[0]) | |
392 | (p = get_sym(ctx, t, v))[0]) | |
393 | 393 | fprintf(fd, "%-*s", 16 - plus, p); |
394 | 394 | else if (!numeric && t == KT_META && v < 128 && v < get_sym_size(ctx, KT_LATIN) && |
395 | (p = get_sym(ctx, KT_LATIN, v))[0]) | |
395 | (p = get_sym(ctx, KT_LATIN, v))[0]) | |
396 | 396 | fprintf(fd, "Meta_%-11s", p); |
397 | 397 | else |
398 | 398 | fprintf(fd, "0x%04x %s", code, plus ? "" : " "); |
401 | 401 | static void |
402 | 402 | print_bind(struct lk_ctx *ctx, FILE *fd, int bufj, int i, int j, char numeric) |
403 | 403 | { |
404 | if(j) | |
404 | if (j) | |
405 | 405 | fprintf(fd, "\t"); |
406 | 406 | print_mod(fd, j); |
407 | 407 | fprintf(fd, "keycode %3d =", i); |
409 | 409 | fprintf(fd, "\n"); |
410 | 410 | } |
411 | 411 | |
412 | void | |
413 | lk_dump_keys(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) | |
412 | void lk_dump_keys(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) | |
414 | 413 | { |
415 | 414 | unsigned int i, j; |
416 | 415 | int buf[MAX_NR_KEYMAPS]; |
446 | 445 | |
447 | 446 | if ((type == KT_LATIN || type == KT_LETTER) && KVAL(buf0) < 128) { |
448 | 447 | buf1 = lk_map_exists(ctx, ja) |
449 | ? lk_get_key(ctx, ja, i) | |
450 | : -1; | |
448 | ? lk_get_key(ctx, ja, i) | |
449 | : -1; | |
451 | 450 | |
452 | 451 | if (buf1 != K(KT_META, KVAL(buf0))) |
453 | 452 | goto not_alt_is_meta; |
498 | 497 | continue; |
499 | 498 | } |
500 | 499 | |
501 | typ = KTYP(buf[0]); | |
502 | val = KVAL(buf[0]); | |
503 | islatin = (typ == KT_LATIN || typ == KT_LETTER); | |
500 | typ = KTYP(buf[0]); | |
501 | val = KVAL(buf[0]); | |
502 | islatin = (typ == KT_LATIN || typ == KT_LETTER); | |
504 | 503 | isletter = (islatin && |
505 | ((val >= 'A' && val <= 'Z') || | |
506 | (val >= 'a' && val <= 'z'))); | |
504 | ((val >= 'A' && val <= 'Z') || | |
505 | (val >= 'a' && val <= 'z'))); | |
507 | 506 | |
508 | 507 | isasexpected = 0; |
509 | 508 | if (isletter) { |
513 | 512 | defs[2] = defs[0]; |
514 | 513 | defs[3] = defs[1]; |
515 | 514 | |
516 | for (j = 4; j < 8; j++) | |
515 | for (j = 4; j < 8; j++) | |
517 | 516 | defs[j] = K(KT_LATIN, val & ~96); |
518 | 517 | |
519 | for (j = 8; j < 16; j++) | |
520 | defs[j] = K(KT_META, KVAL(defs[j-8])); | |
518 | for (j = 8; j < 16; j++) | |
519 | defs[j] = K(KT_META, KVAL(defs[j - 8])); | |
521 | 520 | |
522 | 521 | for (j = 0; j < keymapnr; j++) { |
523 | 522 | if ((j >= 16 && buf[j] != K_HOLE) || (j < 16 && buf[j] != defs[j])) |
526 | 525 | |
527 | 526 | isasexpected = 1; |
528 | 527 | } |
529 | unexpected: | |
528 | unexpected: | |
530 | 529 | |
531 | 530 | /* wipe out predictable meta bindings */ |
532 | for (j = 0; j < keymapnr; j++) | |
531 | for (j = 0; j < keymapnr; j++) | |
533 | 532 | zapped[j] = 0; |
534 | 533 | |
535 | 534 | if (alt_is_meta) { |
536 | for(j = 0; j < keymapnr; j++) { | |
535 | for (j = 0; j < keymapnr; j++) { | |
537 | 536 | unsigned int ja, ktyp; |
538 | 537 | ja = (j | M_ALT); |
539 | 538 | |
540 | if (j != ja && lk_map_exists(ctx, ja) | |
541 | && ((ktyp=KTYP(buf[j])) == KT_LATIN || ktyp == KT_LETTER) | |
542 | && KVAL(buf[j]) < 128) { | |
539 | if (j != ja && lk_map_exists(ctx, ja) && ((ktyp = KTYP(buf[j])) == KT_LATIN || ktyp == KT_LETTER) && KVAL(buf[j]) < 128) { | |
543 | 540 | if (buf[ja] != K(KT_META, KVAL(buf[j]))) |
544 | 541 | fprintf(stderr, _("impossible: not meta?\n")); |
545 | buf[ja] = K_HOLE; | |
542 | buf[ja] = K_HOLE; | |
546 | 543 | zapped[ja] = 1; |
547 | 544 | } |
548 | 545 | } |
572 | 569 | count++; |
573 | 570 | } |
574 | 571 | |
575 | if (bad <= count && bad < keymapnr-1) { | |
572 | if (bad <= count && bad < keymapnr - 1) { | |
576 | 573 | if (buf[0] != K_HOLE) { |
577 | 574 | print_keysym(ctx, fd, buf[0], numeric); |
578 | 575 | } |
586 | 583 | } else { |
587 | 584 | for (j = 0; |
588 | 585 | j < keymapnr && buf[j] != K_HOLE && |
589 | (table != LK_SHAPE_UNTIL_HOLE || lk_map_exists(ctx, j)); | |
586 | (table != LK_SHAPE_UNTIL_HOLE || lk_map_exists(ctx, j)); | |
590 | 587 | j++) { |
591 | 588 | //print_bind(ctx, fd, buf[j], i, j, numeric); |
592 | 589 | print_keysym(ctx, fd, buf[j], numeric); |
603 | 600 | } |
604 | 601 | } |
605 | 602 | |
606 | void | |
607 | lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) | |
603 | void lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) | |
608 | 604 | { |
609 | 605 | lk_dump_keymaps(ctx, fd); |
610 | 606 | lk_dump_keys(ctx, fd, table, numeric); |
10 | 10 | #include "nls.h" |
11 | 11 | #include "keymap/findfile.h" |
12 | 12 | |
13 | void | |
14 | lk_fpclose(lkfile_t *fp) | |
13 | void lk_fpclose(lkfile_t *fp) | |
15 | 14 | { |
16 | 15 | if (!fp || !fp->fd) |
17 | 16 | return; |
22 | 21 | fp->fd = NULL; |
23 | 22 | } |
24 | 23 | |
25 | #define SIZE(a) (sizeof(a)/sizeof(a[0])) | |
24 | #define SIZE(a) (sizeof(a) / sizeof(a[0])) | |
26 | 25 | |
27 | 26 | static struct decompressor { |
28 | 27 | const char *ext; /* starts with `.', has no other dots */ |
44 | 43 | |
45 | 44 | sprintf(pipe_cmd, "%s %s", dc->cmd, fp->pathname); |
46 | 45 | |
47 | fp->fd = popen(pipe_cmd, "r"); | |
46 | fp->fd = popen(pipe_cmd, "r"); | |
48 | 47 | fp->pipe = 1; |
49 | 48 | |
50 | 49 | free(pipe_cmd); |
74 | 73 | return pipe_open(dc, fp); |
75 | 74 | } |
76 | 75 | } |
77 | fp->fd = fopen(fp->pathname, "r"); | |
76 | fp->fd = fopen(fp->pathname, "r"); | |
78 | 77 | fp->pipe = 0; |
79 | 78 | |
80 | 79 | if (fp->fd == NULL) |
105 | 104 | |
106 | 105 | sprintf(fp->pathname, "%s%s", fnam, suffixes[i]); |
107 | 106 | |
108 | if(stat(fp->pathname, &st) == 0 | |
109 | && S_ISREG(st.st_mode) | |
110 | && (fp->fd = fopen(fp->pathname, "r")) != NULL) | |
107 | if (stat(fp->pathname, &st) == 0 && S_ISREG(st.st_mode) && (fp->fd = fopen(fp->pathname, "r")) != NULL) | |
111 | 108 | return 0; |
112 | 109 | |
113 | 110 | for (dc = &decompressors[0]; dc->cmd; dc++) { |
116 | 113 | |
117 | 114 | sprintf(fp->pathname, "%s%s%s", fnam, suffixes[i], dc->ext); |
118 | 115 | |
119 | if (stat(fp->pathname, &st) == 0 | |
120 | && S_ISREG(st.st_mode) | |
121 | && access(fp->pathname, R_OK) == 0) | |
116 | if (stat(fp->pathname, &st) == 0 && S_ISREG(st.st_mode) && access(fp->pathname, R_OK) == 0) | |
122 | 117 | return pipe_open(dc, fp); |
123 | 118 | } |
124 | 119 | } |
137 | 132 | int i, rc = -1, secondpass = 0; |
138 | 133 | size_t dir_len; |
139 | 134 | |
140 | fp->fd = NULL; | |
135 | fp->fd = NULL; | |
141 | 136 | fp->pipe = 0; |
142 | 137 | |
143 | 138 | if ((d = opendir(dir)) == NULL) |
153 | 148 | } |
154 | 149 | } |
155 | 150 | |
156 | /* Scan the directory twice: first for files, then | |
151 | /* Scan the directory twice: first for files, then | |
157 | 152 | for subdirectories, so that we do never search |
158 | 153 | a subdirectory when the directory itself already |
159 | 154 | contains the file we are looking for. */ |
160 | 155 | StartScan: |
161 | 156 | while ((de = readdir(d)) != NULL) { |
162 | struct stat st; | |
163 | int okdir; | |
164 | size_t d_len; | |
165 | ||
166 | d_len = strlen(de->d_name); | |
167 | if (d_len < 3) { | |
168 | if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) | |
169 | continue; | |
170 | } | |
171 | ||
172 | if (dir_len + d_len + 2 > sizeof(fp->pathname)) | |
173 | continue; | |
174 | ||
175 | okdir = (ff && strcmp(de->d_name, fdir) == 0); | |
176 | ||
177 | if ((secondpass && recdepth) || okdir) { | |
178 | char *a; | |
179 | ||
180 | if ((a = malloc(dir_len + d_len + 2)) == NULL) | |
181 | goto EndScan; | |
182 | ||
183 | sprintf(a, "%s/%s", dir, de->d_name); | |
184 | ||
185 | if (stat(a, &st) == 0 && S_ISDIR(st.st_mode)) { | |
186 | if (okdir) | |
187 | rc = findfile_in_dir(ff+1, a, 0, suf, fp); | |
188 | ||
189 | if (rc && recdepth) | |
190 | rc = findfile_in_dir(fnam, a, recdepth-1, suf, fp); | |
191 | ||
192 | if (!rc) { | |
193 | free(a); | |
157 | struct stat st; | |
158 | int okdir; | |
159 | size_t d_len; | |
160 | ||
161 | d_len = strlen(de->d_name); | |
162 | if (d_len < 3) { | |
163 | if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) | |
164 | continue; | |
165 | } | |
166 | ||
167 | if (dir_len + d_len + 2 > sizeof(fp->pathname)) | |
168 | continue; | |
169 | ||
170 | okdir = (ff && strcmp(de->d_name, fdir) == 0); | |
171 | ||
172 | if ((secondpass && recdepth) || okdir) { | |
173 | char *a; | |
174 | ||
175 | if ((a = malloc(dir_len + d_len + 2)) == NULL) | |
176 | goto EndScan; | |
177 | ||
178 | sprintf(a, "%s/%s", dir, de->d_name); | |
179 | ||
180 | if (stat(a, &st) == 0 && S_ISDIR(st.st_mode)) { | |
181 | if (okdir) | |
182 | rc = findfile_in_dir(ff + 1, a, 0, suf, fp); | |
183 | ||
184 | if (rc && recdepth) | |
185 | rc = findfile_in_dir(fnam, a, recdepth - 1, suf, fp); | |
186 | ||
187 | if (!rc) { | |
188 | free(a); | |
189 | goto EndScan; | |
190 | } | |
191 | } | |
192 | free(a); | |
193 | } | |
194 | ||
195 | if (secondpass) | |
196 | continue; | |
197 | ||
198 | /* Should we be in a subdirectory? */ | |
199 | if (ff) | |
200 | continue; | |
201 | ||
202 | /* Does d_name start right? */ | |
203 | p = &de->d_name[0]; | |
204 | q = fnam; | |
205 | while (*p && *p == *q) | |
206 | p++, q++; | |
207 | if (*q) | |
208 | continue; | |
209 | ||
210 | sprintf(fp->pathname, "%s/%s", dir, de->d_name); | |
211 | if (stat(fp->pathname, &st) != 0 || !S_ISREG(st.st_mode)) | |
212 | continue; | |
213 | ||
214 | /* Does tail consist of a known suffix and possibly | |
215 | a compression suffix? */ | |
216 | for (i = 0; suf[i]; i++) { | |
217 | size_t l; | |
218 | ||
219 | if (!strcmp(p, suf[i])) { | |
220 | rc = maybe_pipe_open(fp); | |
194 | 221 | goto EndScan; |
195 | 222 | } |
196 | } | |
197 | free(a); | |
198 | } | |
199 | ||
200 | if (secondpass) | |
201 | continue; | |
202 | ||
203 | /* Should we be in a subdirectory? */ | |
204 | if (ff) | |
205 | continue; | |
206 | ||
207 | /* Does d_name start right? */ | |
208 | p = &de->d_name[0]; | |
209 | q = fnam; | |
210 | while (*p && *p == *q) p++,q++; | |
211 | if (*q) | |
212 | continue; | |
213 | ||
214 | sprintf(fp->pathname, "%s/%s", dir, de->d_name); | |
215 | if (stat(fp->pathname, &st) != 0 || !S_ISREG(st.st_mode)) | |
216 | continue; | |
217 | ||
218 | /* Does tail consist of a known suffix and possibly | |
219 | a compression suffix? */ | |
220 | for(i = 0; suf[i]; i++) { | |
221 | size_t l; | |
222 | ||
223 | if (!strcmp(p, suf[i])) { | |
224 | rc = maybe_pipe_open(fp); | |
225 | goto EndScan; | |
226 | } | |
227 | ||
228 | l = strlen(suf[i]); | |
229 | if (!strncmp(p, suf[i], l)) { | |
230 | for (dc = &decompressors[0]; dc->cmd; dc++) | |
231 | if (strcmp(p+l, dc->ext) == 0) { | |
232 | rc = pipe_open(dc, fp); | |
233 | goto EndScan; | |
234 | } | |
235 | } | |
236 | } | |
223 | ||
224 | l = strlen(suf[i]); | |
225 | if (!strncmp(p, suf[i], l)) { | |
226 | for (dc = &decompressors[0]; dc->cmd; dc++) | |
227 | if (strcmp(p + l, dc->ext) == 0) { | |
228 | rc = pipe_open(dc, fp); | |
229 | goto EndScan; | |
230 | } | |
231 | } | |
232 | } | |
237 | 233 | } |
238 | 234 | |
239 | 235 | if (recdepth > 0 && !secondpass) { |
249 | 245 | return rc; |
250 | 246 | } |
251 | 247 | |
252 | int | |
253 | lk_findfile(const char *fnam, const char *const *dirpath, const char *const *suffixes, lkfile_t *fp) | |
248 | int lk_findfile(const char *fnam, const char *const *dirpath, const char *const *suffixes, lkfile_t *fp) | |
254 | 249 | { |
255 | 250 | char *dir; |
256 | 251 | int dl, recdepth, rc, i; |
257 | 252 | |
258 | fp->fd = NULL; | |
253 | fp->fd = NULL; | |
259 | 254 | fp->pipe = 0; |
260 | 255 | |
261 | 256 | /* Try explicitly given name first */ |
273 | 268 | /* Search a list of directories and directory hierarchies */ |
274 | 269 | for (i = 0; dirpath[i]; i++) { |
275 | 270 | recdepth = 0; |
276 | dl = strlen(dirpath[i]); | |
271 | dl = strlen(dirpath[i]); | |
277 | 272 | |
278 | 273 | /* trailing stars denote recursion */ |
279 | while (dl && dirpath[i][dl-1] == '*') | |
274 | while (dl && dirpath[i][dl - 1] == '*') | |
280 | 275 | dl--, recdepth++; |
281 | 276 | |
282 | 277 | /* delete trailing slashes */ |
283 | while (dl && dirpath[i][dl-1] == '/') | |
278 | while (dl && dirpath[i][dl - 1] == '/') | |
284 | 279 | dl--; |
285 | 280 | |
286 | 281 | if (dl) |
17 | 17 | |
18 | 18 | #include "contextP.h" |
19 | 19 | |
20 | int | |
21 | lk_func_exists(struct lk_ctx *ctx, unsigned int index) | |
20 | int lk_func_exists(struct lk_ctx *ctx, unsigned int index) | |
22 | 21 | { |
23 | 22 | return (lk_array_get_ptr(ctx->func_table, index) != NULL); |
24 | 23 | } |
25 | 24 | |
26 | int | |
27 | lk_get_func(struct lk_ctx *ctx, struct kbsentry *kbs) | |
25 | int lk_get_func(struct lk_ctx *ctx, struct kbsentry *kbs) | |
28 | 26 | { |
29 | 27 | char *s; |
30 | 28 | |
40 | 38 | return 0; |
41 | 39 | } |
42 | 40 | |
43 | int | |
44 | lk_add_func(struct lk_ctx *ctx, struct kbsentry *kbs) | |
41 | int lk_add_func(struct lk_ctx *ctx, struct kbsentry *kbs) | |
45 | 42 | { |
46 | 43 | char *s; |
47 | 44 | |
60 | 57 | return 0; |
61 | 58 | } |
62 | 59 | |
63 | int | |
64 | lk_del_func(struct lk_ctx *ctx, unsigned int index) | |
60 | int lk_del_func(struct lk_ctx *ctx, unsigned int index) | |
65 | 61 | { |
66 | 62 | if (lk_array_unset(ctx->func_table, index) < 0) { |
67 | 63 | ERR(ctx, _("Unable to remove item from the list of functions")); |
70 | 66 | |
71 | 67 | return 0; |
72 | 68 | } |
73 |
16 | 16 | #include "nls.h" |
17 | 17 | #include "contextP.h" |
18 | 18 | |
19 | int | |
20 | lk_kernel_keys(struct lk_ctx *ctx, int fd) | |
19 | int lk_kernel_keys(struct lk_ctx *ctx, int fd) | |
21 | 20 | { |
22 | 21 | int i, t; |
23 | 22 | struct kbentry ke; |
28 | 27 | ke.kb_index = i; |
29 | 28 | ke.kb_value = 0; |
30 | 29 | |
31 | if (ioctl(fd, KDGKBENT, (unsigned long) &ke)) { | |
30 | if (ioctl(fd, KDGKBENT, (unsigned long)&ke)) { | |
32 | 31 | ERR(ctx, _("KDGKBENT: %s: error at index %d in table %d"), |
33 | strerror(errno), i, t); | |
32 | strerror(errno), i, t); | |
34 | 33 | return -1; |
35 | 34 | } |
36 | 35 | |
48 | 47 | return 0; |
49 | 48 | } |
50 | 49 | |
51 | int | |
52 | lk_kernel_funcs(struct lk_ctx *ctx, int fd) | |
50 | int lk_kernel_funcs(struct lk_ctx *ctx, int fd) | |
53 | 51 | { |
54 | 52 | int i; |
55 | 53 | struct kbsentry kbs; |
57 | 55 | for (i = 0; i < MAX_NR_FUNC; i++) { |
58 | 56 | kbs.kb_func = i; |
59 | 57 | |
60 | if (ioctl(fd, KDGKBSENT, (unsigned long) &kbs)) { | |
58 | if (ioctl(fd, KDGKBSENT, (unsigned long)&kbs)) { | |
61 | 59 | ERR(ctx, _("KDGKBSENT: %s: Unable to get function key string"), |
62 | strerror(errno)); | |
60 | strerror(errno)); | |
63 | 61 | return -1; |
64 | 62 | } |
65 | 63 | |
66 | if (!strlen((char *) kbs.kb_string)) | |
64 | if (!strlen((char *)kbs.kb_string)) | |
67 | 65 | continue; |
68 | 66 | |
69 | 67 | if (lk_add_func(ctx, &kbs) < 0) |
73 | 71 | return 0; |
74 | 72 | } |
75 | 73 | |
76 | int | |
77 | lk_kernel_diacrs(struct lk_ctx *ctx, int fd) | |
74 | int lk_kernel_diacrs(struct lk_ctx *ctx, int fd) | |
78 | 75 | { |
79 | 76 | #ifdef KDGKBDIACRUC |
80 | 77 | int request = KDGKBDIACRUC; |
88 | 85 | unsigned int i; |
89 | 86 | struct lk_kbdiacr dcr; |
90 | 87 | |
91 | if (ioctl(fd, request, (unsigned long) &kd)) { | |
88 | if (ioctl(fd, request, (unsigned long)&kd)) { | |
92 | 89 | ERR(ctx, _("KDGKBDIACR(UC): %s: Unable to get accent table"), |
93 | strerror(errno)); | |
90 | strerror(errno)); | |
94 | 91 | return -1; |
95 | 92 | } |
96 | 93 | |
97 | 94 | for (i = 0; i < kd.kb_cnt; i++) { |
98 | dcr.diacr = (ar+i)->diacr; | |
99 | dcr.base = (ar+i)->base; | |
100 | dcr.result = (ar+i)->result; | |
95 | dcr.diacr = (ar + i)->diacr; | |
96 | dcr.base = (ar + i)->base; | |
97 | dcr.result = (ar + i)->result; | |
101 | 98 | |
102 | 99 | if (lk_add_diacr(ctx, i, &dcr) < 0) |
103 | 100 | return -1; |
106 | 103 | return 0; |
107 | 104 | } |
108 | 105 | |
109 | int | |
110 | lk_kernel_keymap(struct lk_ctx *ctx, int fd) | |
106 | int lk_kernel_keymap(struct lk_ctx *ctx, int fd) | |
111 | 107 | { |
112 | if (lk_kernel_keys(ctx, fd) < 0 || | |
113 | lk_kernel_funcs(ctx, fd) < 0 || | |
108 | if (lk_kernel_keys(ctx, fd) < 0 || | |
109 | lk_kernel_funcs(ctx, fd) < 0 || | |
114 | 110 | lk_kernel_diacrs(ctx, fd) < 0) |
115 | 111 | return -1; |
116 | 112 | return 0; |
18 | 18 | |
19 | 19 | int lk_array_append(struct lk_array *a, const void *e); |
20 | 20 | |
21 | int lk_array_set(struct lk_array *a, unsigned int i, const void *e); | |
21 | int lk_array_set(struct lk_array *a, unsigned int i, const void *e); | |
22 | 22 | void *lk_array_get(struct lk_array *a, unsigned int i); |
23 | 23 | void *lk_array_get_ptr(struct lk_array *a, unsigned int i); |
24 | 24 |
62 | 62 | * @return 0 on success, -1 on error. |
63 | 63 | */ |
64 | 64 | int lk_set_log_fn(struct lk_ctx *ctx, |
65 | void (*log_fn)(void *data, int priority, | |
66 | const char *file, int line, const char *fn, | |
67 | const char *format, va_list args), | |
68 | const void *data); | |
65 | void (*log_fn)(void *data, int priority, | |
66 | const char *file, int line, const char *fn, | |
67 | const char *format, va_list args), | |
68 | const void *data); | |
69 | 69 | |
70 | 70 | #endif /* LK_COMMON_H */ |
22 | 22 | * @brief General information about the keymap. |
23 | 23 | */ |
24 | 24 | struct kmapinfo { |
25 | lk_flags flags; /**< Parser flags that are set outside the library */ | |
26 | lk_keywords keywords; /**< Keywords used in keymap files */ | |
27 | size_t keymaps; /**< Number of keymaps in actual use */ | |
28 | size_t keymaps_alloced; /**< Number of keymaps dynamically allocated */ | |
29 | size_t functions; /**< Number of function keys */ | |
30 | size_t composes; /**< Number of compose definitions in actual use */ | |
25 | lk_flags flags; /**< Parser flags that are set outside the library */ | |
26 | lk_keywords keywords; /**< Keywords used in keymap files */ | |
27 | size_t keymaps; /**< Number of keymaps in actual use */ | |
28 | size_t keymaps_alloced; /**< Number of keymaps dynamically allocated */ | |
29 | size_t functions; /**< Number of function keys */ | |
30 | size_t composes; /**< Number of compose definitions in actual use */ | |
31 | 31 | |
32 | size_t keymaps_total; | |
33 | size_t functions_total; | |
34 | size_t composes_total; | |
32 | size_t keymaps_total; | |
33 | size_t functions_total; | |
34 | size_t composes_total; | |
35 | 35 | }; |
36 | 36 | |
37 | 37 | /** |
7 | 7 | #include <keymap/context.h> |
8 | 8 | #include <keymap/findfile.h> |
9 | 9 | |
10 | int lk_add_map(struct lk_ctx *ctx, unsigned int k_table); | |
10 | int lk_add_map(struct lk_ctx *ctx, unsigned int k_table); | |
11 | 11 | int lk_map_exists(struct lk_ctx *ctx, unsigned int k_table); |
12 | 12 | |
13 | 13 | int lk_get_keys_total(struct lk_ctx *ctx, unsigned int k_table); |
15 | 15 | int lk_add_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index, int keycode); |
16 | 16 | int lk_del_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index); |
17 | 17 | int lk_get_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index); |
18 | int lk_key_exists(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index); | |
18 | int lk_key_exists(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index); | |
19 | 19 | |
20 | 20 | /* Functions for key string manipulations */ |
21 | 21 | int lk_get_func(struct lk_ctx *ctx, struct kbsentry *kbs); |
17 | 17 | const char *file, int line, const char *fn, |
18 | 18 | const char *fmt, ...); |
19 | 19 | |
20 | #define lk_log_cond(ctx, level, arg...) \ | |
21 | do { \ | |
22 | if (ctx->log_priority >= level) \ | |
23 | lk_log(ctx, level, __FILE__, __LINE__, __func__, ## arg);\ | |
20 | #define lk_log_cond(ctx, level, arg...) \ | |
21 | do { \ | |
22 | if (ctx->log_priority >= level) \ | |
23 | lk_log(ctx, level, __FILE__, __LINE__, __func__, ##arg); \ | |
24 | 24 | } while (0) |
25 | 25 | |
26 | 26 | /** |
28 | 28 | * @param ctx is a keymap library context. |
29 | 29 | * @param arg is output message. |
30 | 30 | */ |
31 | #define DBG(ctx, arg...) lk_log_cond(ctx, LOG_DEBUG, ## arg) | |
31 | #define DBG(ctx, arg...) lk_log_cond(ctx, LOG_DEBUG, ##arg) | |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Wrapper to output informational messages |
35 | 35 | * @param ctx is a keymap library context. |
36 | 36 | * @param arg is output message. |
37 | 37 | */ |
38 | #define INFO(ctx, arg...) lk_log_cond(ctx, LOG_INFO, ## arg) | |
38 | #define INFO(ctx, arg...) lk_log_cond(ctx, LOG_INFO, ##arg) | |
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Wrapper to output warning conditions |
42 | 42 | * @param ctx is a keymap library context. |
43 | 43 | * @param arg is output message. |
44 | 44 | */ |
45 | #define WARN(ctx, arg...) lk_log_cond(ctx, LOG_WARNING, ## arg) | |
45 | #define WARN(ctx, arg...) lk_log_cond(ctx, LOG_WARNING, ##arg) | |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Wrapper to output error conditions |
49 | 49 | * @param ctx is a keymap library context. |
50 | 50 | * @param arg is output message. |
51 | 51 | */ |
52 | #define ERR(ctx, arg...) lk_log_cond(ctx, LOG_ERR, ## arg) | |
52 | #define ERR(ctx, arg...) lk_log_cond(ctx, LOG_ERR, ##arg) | |
53 | 53 | |
54 | 54 | #endif /* LK_LOGGING_H */ |
11 | 11 | #include "ksyms.h" |
12 | 12 | #include "modifiers.h" |
13 | 13 | |
14 | int | |
15 | lk_map_exists(struct lk_ctx *ctx, unsigned int k_table) | |
14 | int lk_map_exists(struct lk_ctx *ctx, unsigned int k_table) | |
16 | 15 | { |
17 | 16 | return (lk_array_get_ptr(ctx->keymap, k_table) != NULL); |
18 | 17 | } |
19 | 18 | |
20 | int | |
21 | lk_get_keys_total(struct lk_ctx *ctx, unsigned int k_table) | |
19 | int lk_get_keys_total(struct lk_ctx *ctx, unsigned int k_table) | |
22 | 20 | { |
23 | 21 | struct lk_array *map; |
24 | 22 | map = lk_array_get_ptr(ctx->keymap, k_table); |
28 | 26 | return map->total; |
29 | 27 | } |
30 | 28 | |
31 | int | |
32 | lk_key_exists(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index) | |
29 | int lk_key_exists(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index) | |
33 | 30 | { |
34 | 31 | struct lk_array *map; |
35 | 32 | unsigned int *key; |
47 | 44 | return (*key > 0); |
48 | 45 | } |
49 | 46 | |
50 | int | |
51 | lk_add_map(struct lk_ctx *ctx, unsigned int k_table) | |
47 | int lk_add_map(struct lk_ctx *ctx, unsigned int k_table) | |
52 | 48 | { |
53 | 49 | struct lk_array *keys; |
54 | 50 | |
73 | 69 | return 0; |
74 | 70 | } |
75 | 71 | |
76 | int | |
77 | lk_get_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index) | |
72 | int lk_get_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index) | |
78 | 73 | { |
79 | 74 | struct lk_array *map; |
80 | 75 | unsigned int *key; |
90 | 85 | return K_HOLE; |
91 | 86 | } |
92 | 87 | |
93 | return (*key)-1; | |
94 | } | |
95 | ||
96 | int | |
97 | lk_del_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index) | |
88 | return (*key) - 1; | |
89 | } | |
90 | ||
91 | int lk_del_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index) | |
98 | 92 | { |
99 | 93 | struct lk_array *map; |
100 | 94 | |
109 | 103 | |
110 | 104 | if (lk_array_unset(map, k_index) < 0) { |
111 | 105 | ERR(ctx, _("unable to unset key %d for table %d"), |
112 | k_index, k_table); | |
113 | return -1; | |
114 | } | |
115 | ||
116 | return 0; | |
117 | } | |
118 | ||
119 | int | |
120 | lk_add_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index, int keycode) | |
106 | k_index, k_table); | |
107 | return -1; | |
108 | } | |
109 | ||
110 | return 0; | |
111 | } | |
112 | ||
113 | int lk_add_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index, int keycode) | |
121 | 114 | { |
122 | 115 | struct lk_array *map; |
123 | 116 | unsigned int code = keycode + 1; |
149 | 142 | |
150 | 143 | if (lk_array_set(map, k_index, &code) < 0) { |
151 | 144 | ERR(ctx, _("unable to set key %d for table %d"), |
152 | k_index, k_table); | |
145 | k_index, k_table); | |
153 | 146 | return -1; |
154 | 147 | } |
155 | 148 | |
156 | 149 | if (ctx->keywords & LK_KEYWORD_ALTISMETA) { |
157 | 150 | unsigned int alttable = k_table | M_ALT; |
158 | int type = KTYP(keycode); | |
159 | int val = KVAL(keycode); | |
151 | int type = KTYP(keycode); | |
152 | int val = KVAL(keycode); | |
160 | 153 | |
161 | 154 | if (alttable != k_table && lk_map_exists(ctx, alttable) && |
162 | 155 | !lk_key_exists(ctx, alttable, k_index) && |
187 | 180 | defs[2] = defs[0]; |
188 | 181 | defs[3] = defs[1]; |
189 | 182 | |
190 | for (j = 4; j < 8; j++) | |
183 | for (j = 4; j < 8; j++) | |
191 | 184 | defs[j] = K(KT_LATIN, val & ~96); |
192 | 185 | |
193 | for (j = 8; j < 16; j++) | |
186 | for (j = 8; j < 16; j++) | |
194 | 187 | defs[j] = K(KT_META, KVAL(defs[j - 8])); |
195 | 188 | |
196 | 189 | for (j = 0; j < ctx->keymap->total; j++) { |
221 | 214 | return 0; |
222 | 215 | } |
223 | 216 | |
224 | int | |
225 | lk_add_constants(struct lk_ctx *ctx) | |
217 | int lk_add_constants(struct lk_ctx *ctx) | |
226 | 218 | { |
227 | 219 | unsigned int i, r0 = 0; |
228 | 220 |
30 | 30 | |
31 | 31 | #include "syms.ktyp.h" |
32 | 32 | |
33 | #define E(x) { x, sizeof(x) / sizeof(x[0]) } | |
34 | ||
35 | const syms_entry | |
36 | syms[] = { | |
37 | E(iso646_syms), /* KT_LATIN */ | |
38 | E(fn_syms), /* KT_FN */ | |
39 | E(spec_syms), /* KT_SPEC */ | |
40 | E(pad_syms), /* KT_PAD */ | |
41 | E(dead_syms), /* KT_DEAD */ | |
42 | E(cons_syms), /* KT_CONS */ | |
43 | E(cur_syms), /* KT_CUR */ | |
44 | E(shift_syms), /* KT_SHIFT */ | |
45 | { 0, 0 }, /* KT_META */ | |
46 | E(ascii_syms), /* KT_ASCII */ | |
47 | E(lock_syms), /* KT_LOCK */ | |
48 | { 0, 0 }, /* KT_LETTER */ | |
49 | E(sticky_syms), /* KT_SLOCK */ | |
50 | { 0, 0 }, /* */ | |
51 | E(brl_syms) /* KT_BRL */ | |
33 | #define E(x) \ | |
34 | { \ | |
35 | x, sizeof(x) / sizeof(x[0]) \ | |
36 | } | |
37 | ||
38 | const syms_entry syms[] = { | |
39 | E(iso646_syms), /* KT_LATIN */ | |
40 | E(fn_syms), /* KT_FN */ | |
41 | E(spec_syms), /* KT_SPEC */ | |
42 | E(pad_syms), /* KT_PAD */ | |
43 | E(dead_syms), /* KT_DEAD */ | |
44 | E(cons_syms), /* KT_CONS */ | |
45 | E(cur_syms), /* KT_CUR */ | |
46 | E(shift_syms), /* KT_SHIFT */ | |
47 | { 0, 0 }, /* KT_META */ | |
48 | E(ascii_syms), /* KT_ASCII */ | |
49 | E(lock_syms), /* KT_LOCK */ | |
50 | { 0, 0 }, /* KT_LETTER */ | |
51 | E(sticky_syms), /* KT_SLOCK */ | |
52 | { 0, 0 }, /* */ | |
53 | E(brl_syms) /* KT_BRL */ | |
52 | 54 | }; |
53 | 55 | |
54 | 56 | #undef E |
55 | 57 | |
56 | 58 | const unsigned int syms_size = sizeof(syms) / sizeof(syms_entry); |
57 | const unsigned int syn_size = sizeof(synonyms) / sizeof(synonyms[0]); | |
59 | const unsigned int syn_size = sizeof(synonyms) / sizeof(synonyms[0]); | |
58 | 60 | |
59 | 61 | const struct cs { |
60 | 62 | const char *charset; |
61 | 63 | const sym *charnames; |
62 | 64 | const int start; |
63 | 65 | } charsets[] = { |
64 | { "iso-8859-1", latin1_syms, 160 }, | |
65 | { "iso-8859-2", latin2_syms, 160 }, | |
66 | { "iso-8859-3", latin3_syms, 160 }, | |
67 | { "iso-8859-4", latin4_syms, 160 }, | |
68 | { "iso-8859-5", iso8859_5_syms, 160 }, | |
69 | { "iso-8859-7", iso8859_7_syms, 160 }, | |
70 | { "iso-8859-8", iso8859_8_syms, 160 }, | |
71 | { "iso-8859-9", iso8859_9_syms, 160 }, | |
72 | { "iso-8859-10", latin6_syms, 160 }, | |
73 | { "iso-8859-15", iso8859_15_syms, 160 }, | |
74 | { "mazovia", mazovia_syms, 128 }, | |
75 | { "cp-1250", cp1250_syms, 128 }, | |
76 | { "koi8-r", koi8_syms, 128 }, | |
77 | { "koi8-u", koi8_syms, 128 }, | |
78 | { "tis-620", tis_620_syms, 160 }, /* thai */ | |
79 | { "iso-10646-18", iso10646_18_syms, 159 }, /* ethiopic */ | |
80 | { "iso-ir-197", iso_ir_197_syms, 160 }, /* sami */ | |
81 | { "iso-ir-209", iso_ir_209_syms, 160 }, /* sami */ | |
66 | { "iso-8859-1", latin1_syms, 160 }, | |
67 | { "iso-8859-2", latin2_syms, 160 }, | |
68 | { "iso-8859-3", latin3_syms, 160 }, | |
69 | { "iso-8859-4", latin4_syms, 160 }, | |
70 | { "iso-8859-5", iso8859_5_syms, 160 }, | |
71 | { "iso-8859-7", iso8859_7_syms, 160 }, | |
72 | { "iso-8859-8", iso8859_8_syms, 160 }, | |
73 | { "iso-8859-9", iso8859_9_syms, 160 }, | |
74 | { "iso-8859-10", latin6_syms, 160 }, | |
75 | { "iso-8859-15", iso8859_15_syms, 160 }, | |
76 | { "mazovia", mazovia_syms, 128 }, | |
77 | { "cp-1250", cp1250_syms, 128 }, | |
78 | { "koi8-r", koi8_syms, 128 }, | |
79 | { "koi8-u", koi8_syms, 128 }, | |
80 | { "tis-620", tis_620_syms, 160 }, /* thai */ | |
81 | { "iso-10646-18", iso10646_18_syms, 159 }, /* ethiopic */ | |
82 | { "iso-ir-197", iso_ir_197_syms, 160 }, /* sami */ | |
83 | { "iso-ir-209", iso_ir_209_syms, 160 }, /* sami */ | |
82 | 84 | }; |
83 | 85 | |
84 | 86 | static const unsigned int charsets_size = sizeof(charsets) / sizeof(charsets[0]); |
85 | 87 | |
86 | 88 | /* Functions for both dumpkeys and loadkeys. */ |
87 | 89 | |
88 | void | |
89 | lk_list_charsets(FILE *f) { | |
90 | int lth,ct; | |
90 | void lk_list_charsets(FILE *f) | |
91 | { | |
92 | int lth, ct; | |
91 | 93 | unsigned int i, j; |
92 | 94 | char *mm[] = { "iso-8859-", "koi8-" }; |
93 | 95 | |
94 | for (j=0; j<sizeof(mm)/sizeof(mm[0]); j++) { | |
95 | if(j) | |
96 | for (j = 0; j < sizeof(mm) / sizeof(mm[0]); j++) { | |
97 | if (j) | |
96 | 98 | fprintf(f, ","); |
97 | 99 | fprintf(f, "%s{", mm[j]); |
98 | ct = 0; | |
100 | ct = 0; | |
99 | 101 | lth = strlen(mm[j]); |
100 | for(i=1; i < charsets_size; i++) { | |
101 | if(!strncmp(charsets[i].charset, mm[j], lth)) { | |
102 | if(ct++) | |
102 | for (i = 1; i < charsets_size; i++) { | |
103 | if (!strncmp(charsets[i].charset, mm[j], lth)) { | |
104 | if (ct++) | |
103 | 105 | fprintf(f, ","); |
104 | fprintf(f, "%s", charsets[i].charset+lth); | |
106 | fprintf(f, "%s", charsets[i].charset + lth); | |
105 | 107 | } |
106 | 108 | } |
107 | 109 | fprintf(f, "}"); |
108 | 110 | } |
109 | for(i=0; i < charsets_size; i++) { | |
110 | for (j=0; j<sizeof(mm)/sizeof(mm[0]); j++) { | |
111 | for (i = 0; i < charsets_size; i++) { | |
112 | for (j = 0; j < sizeof(mm) / sizeof(mm[0]); j++) { | |
111 | 113 | lth = strlen(mm[j]); |
112 | if(!strncmp(charsets[i].charset, mm[j], lth)) | |
114 | if (!strncmp(charsets[i].charset, mm[j], lth)) | |
113 | 115 | goto nxti; |
114 | 116 | } |
115 | 117 | fprintf(f, ",%s", charsets[i].charset); |
127 | 129 | return charsets[ctx->charset].charset; |
128 | 130 | } |
129 | 131 | |
130 | int | |
131 | lk_set_charset(struct lk_ctx *ctx, const char *charset) { | |
132 | int lk_set_charset(struct lk_ctx *ctx, const char *charset) | |
133 | { | |
132 | 134 | unsigned int i; |
133 | 135 | |
134 | 136 | for (i = 0; i < charsets_size; i++) { |
173 | 175 | } |
174 | 176 | |
175 | 177 | const char * |
176 | codetoksym(struct lk_ctx *ctx, int code) { | |
178 | codetoksym(struct lk_ctx *ctx, int code) | |
179 | { | |
177 | 180 | unsigned int i; |
178 | 181 | int j; |
179 | 182 | sym *p; |
181 | 184 | if (code < 0) |
182 | 185 | return NULL; |
183 | 186 | |
184 | if (code < 0x1000) { /* "traditional" keysym */ | |
187 | if (code < 0x1000) { /* "traditional" keysym */ | |
185 | 188 | if (code < 0x80) |
186 | 189 | return get_sym(ctx, KT_LATIN, code); |
187 | 190 | |
195 | 198 | return get_sym(ctx, KTYP(code), KVAL(code)); |
196 | 199 | |
197 | 200 | i = ctx->charset; |
198 | p = (sym *) charsets[i].charnames; | |
201 | p = (sym *)charsets[i].charnames; | |
199 | 202 | if (p && (KVAL(code) >= charsets[i].start)) { |
200 | 203 | p += KVAL(code) - charsets[i].start; |
201 | 204 | if (p->name[0]) |
203 | 206 | } |
204 | 207 | } |
205 | 208 | |
206 | else { /* Unicode keysym */ | |
209 | else { /* Unicode keysym */ | |
207 | 210 | code ^= 0xf000; |
208 | 211 | |
209 | 212 | if (code < 0x80) |
210 | 213 | return get_sym(ctx, KT_LATIN, code); |
211 | 214 | |
212 | 215 | for (i = 0; i < charsets_size; i++) { |
213 | p = (sym *) charsets[i].charnames; | |
216 | p = (sym *)charsets[i].charnames; | |
214 | 217 | if (p) { |
215 | 218 | for (j = charsets[i].start; j < 256; j++, p++) { |
216 | 219 | if (p->uni == code && p->name[0]) |
238 | 241 | /* Functions for loadkeys. */ |
239 | 242 | |
240 | 243 | static int |
241 | kt_latin(struct lk_ctx *ctx, const char *s, int direction) { | |
244 | kt_latin(struct lk_ctx *ctx, const char *s, int direction) | |
245 | { | |
242 | 246 | unsigned int i, max; |
243 | 247 | |
244 | sym *p = (sym *) charsets[ctx->charset].charnames; | |
248 | sym *p = (sym *)charsets[ctx->charset].charnames; | |
245 | 249 | |
246 | 250 | max = (direction == TO_UNICODE ? 128 : 256); // TODO(dmage): is 256 valid for ethiopic charset? |
247 | 251 | |
260 | 264 | return -1; |
261 | 265 | } |
262 | 266 | |
263 | int | |
264 | ksymtocode(struct lk_ctx *ctx, const char *s, int direction) { | |
267 | int ksymtocode(struct lk_ctx *ctx, const char *s, int direction) | |
268 | { | |
265 | 269 | unsigned int i, j; |
266 | 270 | int n; |
267 | 271 | int keycode; |
269 | 273 | |
270 | 274 | if (direction == TO_AUTO) |
271 | 275 | direction = (ctx->flags & LK_FLAG_PREFER_UNICODE) |
272 | ? TO_UNICODE : TO_8BIT; | |
276 | ? TO_UNICODE | |
277 | : TO_8BIT; | |
273 | 278 | |
274 | 279 | if (!strncmp(s, "Meta_", 5)) { |
275 | keycode = ksymtocode(ctx, s+5, TO_8BIT); | |
280 | keycode = ksymtocode(ctx, s + 5, TO_8BIT); | |
276 | 281 | if (KTYP(keycode) == KT_LATIN) |
277 | 282 | return K(KT_META, KVAL(keycode)); |
278 | 283 | |
279 | 284 | /* Avoid error messages for Meta_acute with UTF-8 */ |
280 | else if(direction == TO_UNICODE) | |
281 | return (0); | |
285 | else if (direction == TO_UNICODE) | |
286 | return (0); | |
282 | 287 | |
283 | 288 | /* fall through to error printf */ |
284 | 289 | } |
300 | 305 | |
301 | 306 | if (direction == TO_UNICODE) { |
302 | 307 | i = ctx->charset; |
303 | p = (sym *) charsets[i].charnames; | |
308 | p = (sym *)charsets[i].charnames; | |
304 | 309 | if (p) { |
305 | 310 | for (j = charsets[i].start; j < 256; j++, p++) { |
306 | 311 | if (!strcmp(s, p->name)) |
313 | 318 | if (i == ctx->charset) { |
314 | 319 | continue; |
315 | 320 | } |
316 | p = (sym *) charsets[i].charnames; | |
321 | p = (sym *)charsets[i].charnames; | |
317 | 322 | if (p) { |
318 | 323 | for (j = charsets[i].start; j < 256; j++, p++) { |
319 | 324 | if (!strcmp(s, p->name)) |
364 | 369 | return CODE_FOR_UNKNOWN_KSYM; |
365 | 370 | } |
366 | 371 | |
367 | int | |
368 | lk_ksym_to_unicode(struct lk_ctx *ctx, const char *s) | |
372 | int lk_ksym_to_unicode(struct lk_ctx *ctx, const char *s) | |
369 | 373 | { |
370 | 374 | return ksymtocode(ctx, s, TO_UNICODE); |
371 | 375 | } |
372 | 376 | |
373 | int | |
374 | convert_code(struct lk_ctx *ctx, int code, int direction) | |
377 | int convert_code(struct lk_ctx *ctx, int code, int direction) | |
375 | 378 | { |
376 | 379 | const char *ksym; |
377 | int unicode_forced = (direction == TO_UNICODE); | |
380 | int unicode_forced = (direction == TO_UNICODE); | |
378 | 381 | int input_is_unicode = (code >= 0x1000); |
379 | 382 | int result; |
380 | 383 | |
381 | 384 | if (direction == TO_AUTO) |
382 | 385 | direction = (ctx->flags & LK_FLAG_PREFER_UNICODE) |
383 | ? TO_UNICODE : TO_8BIT; | |
386 | ? TO_UNICODE | |
387 | : TO_8BIT; | |
384 | 388 | |
385 | 389 | if (KTYP(code) == KT_META) |
386 | 390 | return code; |
391 | 395 | /* so is Unicode "Basic Latin" */ |
392 | 396 | return code ^ 0xf000; |
393 | 397 | else if ((input_is_unicode && direction == TO_UNICODE) || |
394 | (!input_is_unicode && direction == TO_8BIT)) | |
398 | (!input_is_unicode && direction == TO_8BIT)) | |
395 | 399 | /* no conversion necessary */ |
396 | 400 | result = code; |
397 | 401 | else { |
416 | 420 | return result; |
417 | 421 | } |
418 | 422 | |
419 | int | |
420 | add_capslock(struct lk_ctx *ctx, int code) | |
423 | int add_capslock(struct lk_ctx *ctx, int code) | |
421 | 424 | { |
422 | 425 | if (KTYP(code) == KT_LATIN && (!(ctx->flags & LK_FLAG_PREFER_UNICODE) || code < 0x80)) |
423 | 426 | return K(KT_LETTER, KVAL(code)); |
8 | 8 | } sym; |
9 | 9 | |
10 | 10 | typedef struct { |
11 | const char * const *table; | |
11 | const char *const *table; | |
12 | 12 | const unsigned int size; |
13 | 13 | } syms_entry; |
14 | 14 | |
25 | 25 | #define CODE_FOR_UNKNOWN_KSYM (-1) |
26 | 26 | |
27 | 27 | /* Directions for converting keysyms */ |
28 | #define TO_AUTO (-1) /* use LK_FLAG_PREFER_UNICODE */ | |
28 | #define TO_AUTO (-1) /* use LK_FLAG_PREFER_UNICODE */ | |
29 | 29 | #define TO_8BIT 0 |
30 | 30 | #define TO_UNICODE 1 |
31 | 31 |
25 | 25 | /* temporarily switch to K_UNICODE while defining keys */ |
26 | 26 | if (ioctl(fd, KDSKBMODE, K_UNICODE)) { |
27 | 27 | ERR(ctx, _("KDSKBMODE: %s: could not switch to Unicode mode"), |
28 | strerror(errno)); | |
28 | strerror(errno)); | |
29 | 29 | goto fail; |
30 | 30 | } |
31 | 31 | } |
55 | 55 | ct++; |
56 | 56 | |
57 | 57 | INFO(ctx, _("keycode %d, table %d = %d%s"), |
58 | j, i, lk_get_key(ctx,i, j), fail ? _(" FAILED") : ""); | |
58 | j, i, lk_get_key(ctx, i, j), fail ? _(" FAILED") : ""); | |
59 | 59 | |
60 | 60 | if (fail) |
61 | 61 | WARN(ctx, _("failed to bind key %d to value %d"), |
73 | 73 | if (ioctl(fd, KDSKBENT, (unsigned long)&ke)) { |
74 | 74 | if (errno != EINVAL) { |
75 | 75 | ERR(ctx, _("KDSKBENT: %s: could not deallocate keymap %d"), |
76 | strerror(errno), i); | |
76 | strerror(errno), i); | |
77 | 77 | goto fail; |
78 | 78 | } |
79 | 79 | /* probably an old kernel */ |
85 | 85 | |
86 | 86 | if (ioctl(fd, KDSKBENT, (unsigned long)&ke)) { |
87 | 87 | if (errno == EINVAL && i >= 16) |
88 | break; /* old kernel */ | |
88 | break; /* old kernel */ | |
89 | 89 | |
90 | 90 | ERR(ctx, _("KDSKBENT: %s: cannot deallocate or clear keymap"), |
91 | strerror(errno)); | |
91 | strerror(errno)); | |
92 | 92 | goto fail; |
93 | 93 | } |
94 | 94 | } |
98 | 98 | |
99 | 99 | if ((ctx->flags & LK_FLAG_UNICODE_MODE) && ioctl(fd, KDSKBMODE, kbd_mode)) { |
100 | 100 | ERR(ctx, _("KDSKBMODE: %s: could not return to original keyboard mode"), |
101 | strerror(errno)); | |
101 | strerror(errno)); | |
102 | 102 | goto fail; |
103 | 103 | } |
104 | 104 | |
105 | 105 | return ct; |
106 | 106 | |
107 | fail: return -1; | |
108 | } | |
109 | ||
107 | fail: | |
108 | return -1; | |
109 | } | |
110 | 110 | |
111 | 111 | static char * |
112 | 112 | ostr(struct lk_ctx *ctx, char *s) |
113 | 113 | { |
114 | int lth = strlen(s); | |
114 | int lth = strlen(s); | |
115 | 115 | char *ns0 = malloc(4 * lth + 1); |
116 | char *ns = ns0; | |
116 | char *ns = ns0; | |
117 | 117 | |
118 | 118 | if (ns == NULL) { |
119 | 119 | ERR(ctx, _("out of memory")); |
122 | 122 | |
123 | 123 | while (*s) { |
124 | 124 | switch (*s) { |
125 | case '\n': | |
126 | *ns++ = '\\'; | |
127 | *ns++ = 'n'; | |
128 | break; | |
129 | case '\033': | |
130 | *ns++ = '\\'; | |
131 | *ns++ = '0'; | |
132 | *ns++ = '3'; | |
133 | *ns++ = '3'; | |
134 | break; | |
135 | default: | |
136 | *ns++ = *s; | |
125 | case '\n': | |
126 | *ns++ = '\\'; | |
127 | *ns++ = 'n'; | |
128 | break; | |
129 | case '\033': | |
130 | *ns++ = '\\'; | |
131 | *ns++ = '0'; | |
132 | *ns++ = '3'; | |
133 | *ns++ = '3'; | |
134 | break; | |
135 | default: | |
136 | *ns++ = *s; | |
137 | 137 | } |
138 | 138 | s++; |
139 | 139 | } |
160 | 160 | if (s == NULL) |
161 | 161 | return -1; |
162 | 162 | ERR(ctx, _("failed to bind string '%s' to function %s"), |
163 | s, get_sym(ctx, KT_FN, kbs.kb_func)); | |
163 | s, get_sym(ctx, KT_FN, kbs.kb_func)); | |
164 | 164 | free(s); |
165 | 165 | } else { |
166 | 166 | ct++; |
170 | 170 | |
171 | 171 | if (ioctl(fd, KDSKBSENT, (unsigned long)&kbs)) { |
172 | 172 | ERR(ctx, _("failed to clear string %s"), |
173 | get_sym(ctx, KT_FN, kbs.kb_func)); | |
173 | get_sym(ctx, KT_FN, kbs.kb_func)); | |
174 | 174 | } else { |
175 | 175 | ct++; |
176 | 176 | } |
238 | 238 | return count; |
239 | 239 | } |
240 | 240 | |
241 | int | |
242 | lk_load_keymap(struct lk_ctx *ctx, int fd, int kbd_mode) | |
241 | int lk_load_keymap(struct lk_ctx *ctx, int fd, int kbd_mode) | |
243 | 242 | { |
244 | 243 | int keyct, funcct, diacct; |
245 | 244 | |
259 | 258 | return -1; |
260 | 259 | |
261 | 260 | INFO(ctx, P_("Loaded %d compose definition", |
262 | "Loaded %d compose definitions", diacct), diacct); | |
261 | "Loaded %d compose definitions", diacct), | |
262 | diacct); | |
263 | 263 | |
264 | 264 | } else { |
265 | 265 | INFO(ctx, _("(No change in compose definitions)")); |
1 | 1 | #include "modifiers.h" |
2 | 2 | |
3 | 3 | const modifier_t modifiers[] = { |
4 | { "shift", KG_SHIFT }, | |
5 | { "altgr", KG_ALTGR }, | |
6 | { "control", KG_CTRL }, | |
7 | { "alt", KG_ALT }, | |
8 | { "shiftl", KG_SHIFTL }, | |
9 | { "shiftr", KG_SHIFTR }, | |
10 | { "ctrll", KG_CTRLL }, | |
11 | { "ctrlr", KG_CTRLR }, | |
12 | { "capsshift", KG_CAPSSHIFT }, | |
13 | { 0, 0 } | |
4 | { "shift", KG_SHIFT }, | |
5 | { "altgr", KG_ALTGR }, | |
6 | { "control", KG_CTRL }, | |
7 | { "alt", KG_ALT }, | |
8 | { "shiftl", KG_SHIFTL }, | |
9 | { "shiftr", KG_SHIFTR }, | |
10 | { "ctrll", KG_CTRLL }, | |
11 | { "ctrlr", KG_CTRLR }, | |
12 | { "capsshift", KG_CAPSSHIFT }, | |
13 | { 0, 0 } | |
14 | 14 | }; |
0 | 0 | #ifndef _MODIFIERS_H |
1 | 1 | #define _MODIFIERS_H |
2 | 2 | |
3 | #include <linux/keyboard.h> | |
3 | #include <linux/keyboard.h> | |
4 | 4 | |
5 | #define M_PLAIN 0 | |
6 | #define M_SHIFT (1 << KG_SHIFT) | |
7 | #define M_CTRL (1 << KG_CTRL) | |
8 | #define M_ALT (1 << KG_ALT) | |
9 | #define M_ALTGR (1 << KG_ALTGR) | |
5 | #define M_PLAIN 0 | |
6 | #define M_SHIFT (1 << KG_SHIFT) | |
7 | #define M_CTRL (1 << KG_CTRL) | |
8 | #define M_ALT (1 << KG_ALT) | |
9 | #define M_ALTGR (1 << KG_ALTGR) | |
10 | 10 | #define M_SHIFTL (1 << KG_SHIFTL) |
11 | 11 | #define M_SHIFTR (1 << KG_SHIFTR) |
12 | #define M_CTRLL (1 << KG_CTRLL) | |
13 | #define M_CTRLR (1 << KG_CTRLR) | |
12 | #define M_CTRLL (1 << KG_CTRLL) | |
13 | #define M_CTRLR (1 << KG_CTRLR) | |
14 | 14 | #define M_CAPSSHIFT (1 << KG_CAPSSHIFT) |
15 | 15 | |
16 | 16 | typedef struct { |
17 | 17 | #include "ksyms.h" |
18 | 18 | #include "modifiers.h" |
19 | 19 | |
20 | ||
21 | 20 | static char |
22 | 21 | valid_type(int fd, int t) |
23 | 22 | { |
27 | 26 | ke.kb_table = 0; |
28 | 27 | ke.kb_value = K(t, 0); |
29 | 28 | |
30 | return (ioctl(fd, KDSKBENT, (unsigned long) &ke) == 0); | |
29 | return (ioctl(fd, KDSKBENT, (unsigned long)&ke) == 0); | |
31 | 30 | } |
32 | 31 | |
33 | 32 | static unsigned char |
39 | 38 | ke.kb_index = 0; |
40 | 39 | ke.kb_table = 0; |
41 | 40 | ke.kb_value = K_HOLE; |
42 | ke0 = ke; | |
41 | ke0 = ke; | |
43 | 42 | |
44 | ioctl(fd, KDGKBENT, (unsigned long) &ke0); | |
43 | ioctl(fd, KDGKBENT, (unsigned long)&ke0); | |
45 | 44 | |
46 | 45 | for (i = 0; i < 256; i++) { |
47 | 46 | ke.kb_value = K(t, i); |
48 | if (ioctl(fd, KDSKBENT, (unsigned long) &ke)) | |
47 | if (ioctl(fd, KDSKBENT, (unsigned long)&ke)) | |
49 | 48 | break; |
50 | 49 | } |
51 | 50 | ke.kb_value = K_HOLE; |
52 | ioctl(fd, KDSKBENT, (unsigned long) &ke0); | |
51 | ioctl(fd, KDSKBENT, (unsigned long)&ke0); | |
53 | 52 | |
54 | 53 | return i - 1; |
55 | 54 | } |
56 | 55 | |
57 | int | |
58 | lk_get_kmapinfo(struct lk_ctx *ctx, struct kmapinfo *res) | |
56 | int lk_get_kmapinfo(struct lk_ctx *ctx, struct kmapinfo *res) | |
59 | 57 | { |
60 | 58 | int i; |
61 | 59 | |
85 | 83 | |
86 | 84 | #define NR_TYPES 15 |
87 | 85 | |
88 | void | |
89 | lk_dump_summary(struct lk_ctx *ctx, FILE *fd, int console) | |
86 | void lk_dump_summary(struct lk_ctx *ctx, FILE *fd, int console) | |
90 | 87 | { |
91 | 88 | int i; |
92 | 89 | struct kmapinfo info; |
95 | 92 | return; |
96 | 93 | |
97 | 94 | fprintf(fd, _("keycode range supported by kernel: 1 - %d\n"), |
98 | NR_KEYS - 1); | |
95 | NR_KEYS - 1); | |
99 | 96 | fprintf(fd, _("max number of actions bindable to a key: %d\n"), |
100 | MAX_NR_KEYMAPS); | |
97 | MAX_NR_KEYMAPS); | |
101 | 98 | fprintf(fd, _("number of keymaps in actual use: %u\n"), |
102 | (unsigned int) info.keymaps); | |
99 | (unsigned int)info.keymaps); | |
103 | 100 | |
104 | 101 | fprintf(fd, _("of which %u dynamically allocated\n"), |
105 | (unsigned int) info.keymaps_alloced); | |
102 | (unsigned int)info.keymaps_alloced); | |
106 | 103 | |
107 | 104 | fprintf(fd, _("ranges of action codes supported by kernel:\n")); |
108 | 105 | |
109 | 106 | for (i = 0; i < NR_TYPES && valid_type(console, i); i++) |
110 | 107 | fprintf(fd, " 0x%04x - 0x%04x\n", |
111 | K(i, 0), K(i, maximum_val(console, i))); | |
108 | K(i, 0), K(i, maximum_val(console, i))); | |
112 | 109 | |
113 | 110 | fprintf(fd, _("number of function keys supported by kernel: %d\n"), |
114 | MAX_NR_FUNC); | |
111 | MAX_NR_FUNC); | |
115 | 112 | fprintf(fd, _("max nr of compose definitions: %d\n"), |
116 | MAX_DIACR); | |
113 | MAX_DIACR); | |
117 | 114 | fprintf(fd, _("nr of compose definitions in actual use: %u\n"), |
118 | (unsigned int) info.composes); | |
115 | (unsigned int)info.composes); | |
119 | 116 | } |
120 | 117 | |
121 | void | |
122 | lk_dump_symbols(struct lk_ctx *ctx, FILE *fd) | |
118 | void lk_dump_symbols(struct lk_ctx *ctx, FILE *fd) | |
123 | 119 | { |
124 | 120 | unsigned int t, v; |
125 | 121 | modifier_t *mod; |
126 | 122 | const char *p; |
127 | 123 | |
128 | 124 | for (t = 0; t < syms_size; t++) { |
129 | if (get_sym_size(ctx, t)) { | |
130 | for (v = 0; v < get_sym_size(ctx, t); v++) { | |
131 | if ((p = get_sym(ctx, t, v))[0]) | |
132 | fprintf(fd, "0x%04x\t%s\n", K(t, v), p); | |
125 | if (get_sym_size(ctx, t)) { | |
126 | for (v = 0; v < get_sym_size(ctx, t); v++) { | |
127 | if ((p = get_sym(ctx, t, v))[0]) | |
128 | fprintf(fd, "0x%04x\t%s\n", K(t, v), p); | |
129 | } | |
130 | } else if (t == KT_META) { | |
131 | for (v = 0; v < get_sym_size(ctx, KT_LATIN) && v < 128; v++) { | |
132 | if ((p = get_sym(ctx, KT_LATIN, v))[0]) | |
133 | fprintf(fd, "0x%04x\tMeta_%s\n", K(t, v), p); | |
134 | } | |
133 | 135 | } |
134 | } else if (t == KT_META) { | |
135 | for (v = 0; v < get_sym_size(ctx, KT_LATIN) && v < 128; v++) { | |
136 | if ((p = get_sym(ctx, KT_LATIN, v))[0]) | |
137 | fprintf(fd, "0x%04x\tMeta_%s\n", K(t, v), p); | |
138 | } | |
139 | } | |
140 | 136 | } |
141 | 137 | |
142 | 138 | fprintf(fd, _("\nThe following synonyms are recognized:\n\n")); |
143 | 139 | |
144 | 140 | for (t = 0; t < syn_size; t++) { |
145 | 141 | fprintf(fd, _("%-15s for %s\n"), |
146 | synonyms[t].synonym, synonyms[t].official_name); | |
142 | synonyms[t].synonym, synonyms[t].official_name); | |
147 | 143 | } |
148 | 144 | |
149 | 145 | fprintf(fd, _("\nRecognized modifier names and their column numbers:\n")); |
150 | 146 | |
151 | mod = (modifier_t *) modifiers; | |
147 | mod = (modifier_t *)modifiers; | |
152 | 148 | while (mod->name) { |
153 | 149 | fprintf(fd, "%s\t\t%3d\n", mod->name, 1 << mod->bit); |
154 | 150 | mod++; |
5 | 5 | * |
6 | 6 | * { "iso-10646-18", iso_10646_18_syms, 159 }, |
7 | 7 | */ |
8 | static sym | |
9 | const iso10646_18_syms[] = { /* 0x1200 - 0x137F */ | |
8 | static sym const iso10646_18_syms[] = { | |
9 | /* 0x1200 - 0x137F */ | |
10 | 10 | { 0x1200, "ethiopic_syllable_ha" }, |
11 | 11 | { 0x1201, "ethiopic_syllable_hu" }, |
12 | 12 | { 0x1202, "ethiopic_syllable_hi" }, |
0 | 0 | /* |
1 | 1 | * Keysyms whose KTYP is KT_LATIN or KT_LETTER and whose KVAL is 0..127. |
2 | 2 | */ |
3 | static const char * | |
4 | const iso646_syms[] = { | |
5 | "nul", /* 0x00, 0000 */ | |
3 | static const char *const iso646_syms[] = { | |
4 | "nul", /* 0x00, 0000 */ | |
6 | 5 | "Control_a", |
7 | 6 | "Control_b", |
8 | 7 | "Control_c", |
18 | 17 | "Control_m", |
19 | 18 | "Control_n", |
20 | 19 | "Control_o", |
21 | "Control_p", /* 0x10, 0020 */ | |
20 | "Control_p", /* 0x10, 0020 */ | |
22 | 21 | "Control_q", |
23 | 22 | "Control_r", |
24 | 23 | "Control_s", |
34 | 33 | "Control_bracketright", |
35 | 34 | "Control_asciicircum", |
36 | 35 | "Control_underscore", |
37 | "space", /* 0x20, 0040 */ | |
36 | "space", /* 0x20, 0040 */ | |
38 | 37 | "exclam", |
39 | 38 | "quotedbl", |
40 | 39 | "numbersign", |
50 | 49 | "minus", |
51 | 50 | "period", |
52 | 51 | "slash", |
53 | "zero", /* 0x30, 0060 */ | |
52 | "zero", /* 0x30, 0060 */ | |
54 | 53 | "one", |
55 | 54 | "two", |
56 | 55 | "three", |
66 | 65 | "equal", |
67 | 66 | "greater", |
68 | 67 | "question", |
69 | "at", /* 0x40, 0100 */ | |
68 | "at", /* 0x40, 0100 */ | |
70 | 69 | "A", |
71 | 70 | "B", |
72 | 71 | "C", |
82 | 81 | "M", |
83 | 82 | "N", |
84 | 83 | "O", |
85 | "P", /* 0x50, 0120 */ | |
84 | "P", /* 0x50, 0120 */ | |
86 | 85 | "Q", |
87 | 86 | "R", |
88 | 87 | "S", |
98 | 97 | "bracketright", |
99 | 98 | "asciicircum", |
100 | 99 | "underscore", |
101 | "grave", /* 0x60, 0140 */ | |
100 | "grave", /* 0x60, 0140 */ | |
102 | 101 | "a", |
103 | 102 | "b", |
104 | 103 | "c", |
114 | 113 | "m", |
115 | 114 | "n", |
116 | 115 | "o", |
117 | "p", /* 0x70, 0160 */ | |
116 | "p", /* 0x70, 0160 */ | |
118 | 117 | "q", |
119 | 118 | "r", |
120 | 119 | "s", |
130 | 129 | "braceright", |
131 | 130 | "asciitilde", |
132 | 131 | "Delete", |
133 | "", /* 0x80, 0200 */ | |
134 | "", | |
135 | "", | |
136 | "", | |
137 | "", | |
138 | "", | |
139 | "", | |
140 | "", | |
141 | "", | |
142 | "", | |
143 | "", | |
144 | "", | |
145 | "", | |
146 | "", | |
147 | "", | |
148 | "", | |
149 | "", /* 0x90, 0220 */ | |
150 | "", | |
151 | "", | |
152 | "", | |
153 | "", | |
154 | "", | |
155 | "", | |
156 | "", | |
157 | "", | |
158 | "", | |
159 | "", | |
160 | "", | |
161 | "", | |
162 | "", | |
163 | "", | |
164 | "", | |
165 | "nobreakspace", /* 0xa0, 0240 */ | |
132 | "", /* 0x80, 0200 */ | |
133 | "", | |
134 | "", | |
135 | "", | |
136 | "", | |
137 | "", | |
138 | "", | |
139 | "", | |
140 | "", | |
141 | "", | |
142 | "", | |
143 | "", | |
144 | "", | |
145 | "", | |
146 | "", | |
147 | "", | |
148 | "", /* 0x90, 0220 */ | |
149 | "", | |
150 | "", | |
151 | "", | |
152 | "", | |
153 | "", | |
154 | "", | |
155 | "", | |
156 | "", | |
157 | "", | |
158 | "", | |
159 | "", | |
160 | "", | |
161 | "", | |
162 | "", | |
163 | "", | |
164 | "nobreakspace", /* 0xa0, 0240 */ | |
166 | 165 | "exclamdown", |
167 | 166 | "cent", |
168 | 167 | "sterling", |
178 | 177 | "hyphen", |
179 | 178 | "registered", |
180 | 179 | "macron", |
181 | "degree", /* 0xb0, 0260 */ | |
180 | "degree", /* 0xb0, 0260 */ | |
182 | 181 | "plusminus", |
183 | 182 | "twosuperior", |
184 | 183 | "threesuperior", |
194 | 193 | "onehalf", |
195 | 194 | "threequarters", |
196 | 195 | "questiondown", |
197 | "Agrave", /* 0xc0, 0300 */ | |
196 | "Agrave", /* 0xc0, 0300 */ | |
198 | 197 | "Aacute", |
199 | 198 | "Acircumflex", |
200 | 199 | "Atilde", |
210 | 209 | "Iacute", |
211 | 210 | "Icircumflex", |
212 | 211 | "Idiaeresis", |
213 | "ETH", /* 0xd0, 0320 */ | |
212 | "ETH", /* 0xd0, 0320 */ | |
214 | 213 | "Ntilde", |
215 | 214 | "Ograve", |
216 | 215 | "Oacute", |
226 | 225 | "Yacute", |
227 | 226 | "THORN", |
228 | 227 | "ssharp", |
229 | "agrave", /* 0xe0, 0340 */ | |
228 | "agrave", /* 0xe0, 0340 */ | |
230 | 229 | "aacute", |
231 | 230 | "acircumflex", |
232 | 231 | "atilde", |
242 | 241 | "iacute", |
243 | 242 | "icircumflex", |
244 | 243 | "idiaeresis", |
245 | "eth", /* 0xf0, 0360 */ | |
244 | "eth", /* 0xf0, 0360 */ | |
246 | 245 | "ntilde", |
247 | 246 | "ograve", |
248 | 247 | "oacute", |
257 | 256 | "udiaeresis", |
258 | 257 | "yacute", |
259 | 258 | "thorn", |
260 | "ydiaeresis", /* 0xff, 0377 */ | |
261 | }; | |
262 | ||
263 | ||
259 | "ydiaeresis", /* 0xff, 0377 */ | |
260 | }; | |
264 | 261 | |
265 | 262 | /* |
266 | 263 | * Keysyms whose KTYP is KT_FN. |
267 | 264 | */ |
268 | static const char * | |
269 | const fn_syms[] = { | |
270 | "F1", "F2", "F3", "F4", "F5", | |
271 | "F6", "F7", "F8", "F9", "F10", | |
272 | "F11", "F12", "F13", "F14", "F15", | |
273 | "F16", "F17", "F18", "F19", "F20", | |
274 | "Find", /* also called: "Home" */ | |
265 | static const char *const fn_syms[] = { | |
266 | "F1", "F2", "F3", "F4", "F5", | |
267 | "F6", "F7", "F8", "F9", "F10", | |
268 | "F11", "F12", "F13", "F14", "F15", | |
269 | "F16", "F17", "F18", "F19", "F20", | |
270 | "Find", /* also called: "Home" */ | |
275 | 271 | "Insert", |
276 | 272 | "Remove", |
277 | "Select", /* also called: "End" */ | |
278 | "Prior", /* also called: "PageUp" */ | |
279 | "Next", /* also called: "PageDown" */ | |
273 | "Select", /* also called: "End" */ | |
274 | "Prior", /* also called: "PageUp" */ | |
275 | "Next", /* also called: "PageDown" */ | |
280 | 276 | "Macro", |
281 | 277 | "Help", |
282 | 278 | "Do", |
283 | 279 | "Pause", |
284 | "F21", "F22", "F23", "F24", "F25", | |
285 | "F26", "F27", "F28", "F29", "F30", | |
286 | "F31", "F32", "F33", "F34", "F35", | |
287 | "F36", "F37", "F38", "F39", "F40", | |
288 | "F41", "F42", "F43", "F44", "F45", | |
289 | "F46", "F47", "F48", "F49", "F50", | |
290 | "F51", "F52", "F53", "F54", "F55", | |
291 | "F56", "F57", "F58", "F59", "F60", | |
292 | "F61", "F62", "F63", "F64", "F65", | |
293 | "F66", "F67", "F68", "F69", "F70", | |
294 | "F71", "F72", "F73", "F74", "F75", | |
295 | "F76", "F77", "F78", "F79", "F80", | |
296 | "F81", "F82", "F83", "F84", "F85", | |
297 | "F86", "F87", "F88", "F89", "F90", | |
298 | "F91", "F92", "F93", "F94", "F95", | |
299 | "F96", "F97", "F98", "F99", "F100", | |
300 | "F101", "F102", "F103", "F104", "F105", | |
301 | "F106", "F107", "F108", "F109", "F110", | |
302 | "F111", "F112", "F113", "F114", "F115", | |
303 | "F116", "F117", "F118", "F119", "F120", | |
304 | "F121", "F122", "F123", "F124", "F125", | |
305 | "F126", "F127", "F128", "F129", "F130", | |
306 | "F131", "F132", "F133", "F134", "F135", | |
307 | "F136", "F137", "F138", "F139", "F140", | |
308 | "F141", "F142", "F143", "F144", "F145", | |
309 | "F146", "F147", "F148", "F149", "F150", | |
310 | "F151", "F152", "F153", "F154", "F155", | |
311 | "F156", "F157", "F158", "F159", "F160", | |
312 | "F161", "F162", "F163", "F164", "F165", | |
313 | "F166", "F167", "F168", "F169", "F170", | |
314 | "F171", "F172", "F173", "F174", "F175", | |
315 | "F176", "F177", "F178", "F179", "F180", | |
316 | "F181", "F182", "F183", "F184", "F185", | |
317 | "F186", "F187", "F188", "F189", "F190", | |
318 | "F191", "F192", "F193", "F194", "F195", | |
319 | "F196", "F197", "F198", "F199", "F200", | |
320 | "F201", "F202", "F203", "F204", "F205", | |
321 | "F206", "F207", "F208", "F209", "F210", | |
322 | "F211", "F212", "F213", "F214", "F215", | |
323 | "F216", "F217", "F218", "F219", "F220", | |
324 | "F221", "F222", "F223", "F224", "F225", | |
325 | "F226", "F227", "F228", "F229", "F230", | |
326 | "F231", "F232", "F233", "F234", "F235", | |
327 | "F236", "F237", "F238", "F239", "F240", | |
328 | "F241", "F242", "F243", "F244", "F245", | |
329 | "F246" /* there are 10 keys named Insert etc., total 256 */ | |
280 | "F21", "F22", "F23", "F24", "F25", | |
281 | "F26", "F27", "F28", "F29", "F30", | |
282 | "F31", "F32", "F33", "F34", "F35", | |
283 | "F36", "F37", "F38", "F39", "F40", | |
284 | "F41", "F42", "F43", "F44", "F45", | |
285 | "F46", "F47", "F48", "F49", "F50", | |
286 | "F51", "F52", "F53", "F54", "F55", | |
287 | "F56", "F57", "F58", "F59", "F60", | |
288 | "F61", "F62", "F63", "F64", "F65", | |
289 | "F66", "F67", "F68", "F69", "F70", | |
290 | "F71", "F72", "F73", "F74", "F75", | |
291 | "F76", "F77", "F78", "F79", "F80", | |
292 | "F81", "F82", "F83", "F84", "F85", | |
293 | "F86", "F87", "F88", "F89", "F90", | |
294 | "F91", "F92", "F93", "F94", "F95", | |
295 | "F96", "F97", "F98", "F99", "F100", | |
296 | "F101", "F102", "F103", "F104", "F105", | |
297 | "F106", "F107", "F108", "F109", "F110", | |
298 | "F111", "F112", "F113", "F114", "F115", | |
299 | "F116", "F117", "F118", "F119", "F120", | |
300 | "F121", "F122", "F123", "F124", "F125", | |
301 | "F126", "F127", "F128", "F129", "F130", | |
302 | "F131", "F132", "F133", "F134", "F135", | |
303 | "F136", "F137", "F138", "F139", "F140", | |
304 | "F141", "F142", "F143", "F144", "F145", | |
305 | "F146", "F147", "F148", "F149", "F150", | |
306 | "F151", "F152", "F153", "F154", "F155", | |
307 | "F156", "F157", "F158", "F159", "F160", | |
308 | "F161", "F162", "F163", "F164", "F165", | |
309 | "F166", "F167", "F168", "F169", "F170", | |
310 | "F171", "F172", "F173", "F174", "F175", | |
311 | "F176", "F177", "F178", "F179", "F180", | |
312 | "F181", "F182", "F183", "F184", "F185", | |
313 | "F186", "F187", "F188", "F189", "F190", | |
314 | "F191", "F192", "F193", "F194", "F195", | |
315 | "F196", "F197", "F198", "F199", "F200", | |
316 | "F201", "F202", "F203", "F204", "F205", | |
317 | "F206", "F207", "F208", "F209", "F210", | |
318 | "F211", "F212", "F213", "F214", "F215", | |
319 | "F216", "F217", "F218", "F219", "F220", | |
320 | "F221", "F222", "F223", "F224", "F225", | |
321 | "F226", "F227", "F228", "F229", "F230", | |
322 | "F231", "F232", "F233", "F234", "F235", | |
323 | "F236", "F237", "F238", "F239", "F240", | |
324 | "F241", "F242", "F243", "F244", "F245", | |
325 | "F246" /* there are 10 keys named Insert etc., total 256 */ | |
330 | 326 | }; |
331 | 327 | |
332 | 328 | /* |
333 | 329 | * Keysyms whose KTYP is KT_SPEC. |
334 | 330 | */ |
335 | static const char * | |
336 | const spec_syms[] = { | |
331 | static const char *const spec_syms[] = { | |
337 | 332 | "VoidSymbol", |
338 | 333 | "Return", |
339 | 334 | "Show_Registers", |
359 | 354 | /* |
360 | 355 | * Keysyms whose KTYP is KT_PAD. |
361 | 356 | */ |
362 | static const char * | |
363 | const pad_syms[] = { | |
357 | static const char *const pad_syms[] = { | |
364 | 358 | "KP_0", |
365 | 359 | "KP_1", |
366 | 360 | "KP_2", |
384 | 378 | /* |
385 | 379 | * Keysyms whose KTYP is KT_DEAD. |
386 | 380 | */ |
387 | static const char * | |
388 | const dead_syms[] = { | |
381 | static const char *const dead_syms[] = { | |
389 | 382 | "dead_grave", |
390 | 383 | "dead_acute", |
391 | 384 | "dead_circumflex", |
397 | 390 | /* |
398 | 391 | * Keysyms whose KTYP is KT_CONS. |
399 | 392 | */ |
400 | static const char * | |
401 | const cons_syms[] = { | |
393 | static const char *const cons_syms[] = { | |
402 | 394 | "Console_1", |
403 | 395 | "Console_2", |
404 | 396 | "Console_3", |
467 | 459 | /* |
468 | 460 | * Keysyms whose KTYP is KT_CUR. |
469 | 461 | */ |
470 | static const char * | |
471 | const cur_syms[] = { | |
462 | static const char *const cur_syms[] = { | |
472 | 463 | "Down", |
473 | 464 | "Left", |
474 | 465 | "Right", |
478 | 469 | /* |
479 | 470 | * Keysyms whose KTYP is KT_SHIFT. |
480 | 471 | */ |
481 | static const char * | |
482 | const shift_syms[] = { | |
472 | static const char *const shift_syms[] = { | |
483 | 473 | "Shift", |
484 | 474 | "AltGr", |
485 | 475 | "Control", |
494 | 484 | /* |
495 | 485 | * Keysyms whose KTYP is KT_ASCII. |
496 | 486 | */ |
497 | static const char * | |
498 | const ascii_syms[] = { | |
487 | static const char *const ascii_syms[] = { | |
499 | 488 | "Ascii_0", |
500 | 489 | "Ascii_1", |
501 | 490 | "Ascii_2", |
527 | 516 | /* |
528 | 517 | * Keysyms whose KTYP is KT_LOCK. |
529 | 518 | */ |
530 | static const char * | |
531 | const lock_syms[] = { | |
519 | static const char *const lock_syms[] = { | |
532 | 520 | "Shift_Lock", |
533 | 521 | "AltGr_Lock", |
534 | 522 | "Control_Lock", |
543 | 531 | /* |
544 | 532 | * Keysyms whose KTYP is KT_SLOCK. |
545 | 533 | */ |
546 | static const char * | |
547 | const sticky_syms[] = { | |
534 | static const char *const sticky_syms[] = { | |
548 | 535 | "SShift", |
549 | 536 | "SAltGr", |
550 | 537 | "SControl", |
559 | 546 | /* |
560 | 547 | * Keysyms whose KTYP is KT_BRL. |
561 | 548 | */ |
562 | static const char * | |
563 | const brl_syms[] = { | |
549 | static const char *const brl_syms[] = { | |
564 | 550 | "Brl_blank", |
565 | 551 | "Brl_dot1", |
566 | 552 | "Brl_dot2", |
0 | static sym | |
1 | const mazovia_syms[] = { | |
0 | static sym const mazovia_syms[] = { | |
2 | 1 | /* as specified by Wlodek Bzyl <matwb@univ.gda.pl> */ |
3 | 2 | { 0x0080, "" }, |
4 | 3 | { 0x0081, "" }, |
5 | 5 | * { "iso-ir-197", iso_ir_197_syms, nn }, |
6 | 6 | */ |
7 | 7 | |
8 | static sym | |
9 | const iso_ir_197_syms[] = { | |
8 | static sym const iso_ir_197_syms[] = { | |
10 | 9 | { 0x00a0, "nobreakspace" }, |
11 | 10 | { 0x010c, "Ccaron" }, |
12 | 11 | { 0x010d, "ccaron" }, |
117 | 116 | * 0xBB 0x021F # LATIN SMALL LETTER H WITH CARON |
118 | 117 | */ |
119 | 118 | |
120 | static sym | |
121 | const iso_ir_209_syms[] = { | |
119 | static sym const iso_ir_209_syms[] = { | |
122 | 120 | { 0x00a0, "nobreakspace" }, |
123 | 121 | { 0x010c, "Ccaron" }, |
124 | 122 | { 0x010d, "ccaron" }, |
217 | 215 | { 0x00ff, "ydiaeresis" }, |
218 | 216 | }; |
219 | 217 | |
220 | static sym | |
221 | const latin6_syms[] = { | |
218 | static sym const latin6_syms[] = { | |
222 | 219 | { 0x00a0, "nobreakspace" }, |
223 | 220 | { 0x0104, "Aogonek" }, |
224 | 221 | { 0x0112, "Emacron" }, |
0 | struct syn | |
1 | const synonyms[] = { | |
2 | { "Control_h", "BackSpace" }, | |
3 | { "Control_i", "Tab" }, | |
4 | { "Control_j", "Linefeed" }, | |
5 | { "Home", "Find" }, | |
6 | /* Unfortunately Delete already denotes ASCII 0177 */ | |
7 | /* { "Delete", "Remove" }, */ | |
8 | { "End", "Select" }, | |
9 | { "PageUp", "Prior" }, | |
10 | { "PageDown", "Next" }, | |
11 | { "multiplication", "multiply" }, | |
12 | { "pound", "sterling" }, | |
13 | { "pilcrow", "paragraph" }, | |
14 | { "Oslash", "Ooblique" }, | |
15 | { "Shift_L", "ShiftL" }, | |
16 | { "Shift_R", "ShiftR" }, | |
17 | { "Control_L", "CtrlL" }, | |
18 | { "Control_R", "CtrlR" }, | |
19 | { "AltL", "Alt" }, | |
20 | { "AltR", "AltGr" }, | |
21 | { "Alt_L", "Alt" }, | |
22 | { "Alt_R", "AltGr" }, | |
23 | { "AltGr_L", "Alt" }, | |
24 | { "AltGr_R", "AltGr" }, | |
25 | { "AltLLock", "Alt_Lock" }, | |
26 | { "AltRLock", "AltGr_Lock" }, | |
27 | { "SCtrl", "SControl" }, | |
28 | { "Spawn_Console", "KeyboardSignal" }, | |
29 | { "Uncaps_Shift", "CapsShift" }, | |
30 | /* the names of the Greek letters are spelled differently | |
0 | struct syn const synonyms[] = { | |
1 | { "Control_h", "BackSpace" }, | |
2 | { "Control_i", "Tab" }, | |
3 | { "Control_j", "Linefeed" }, | |
4 | { "Home", "Find" }, | |
5 | /* Unfortunately Delete already denotes ASCII 0177 */ | |
6 | /* { "Delete", "Remove" }, */ | |
7 | { "End", "Select" }, | |
8 | { "PageUp", "Prior" }, | |
9 | { "PageDown", "Next" }, | |
10 | { "multiplication", "multiply" }, | |
11 | { "pound", "sterling" }, | |
12 | { "pilcrow", "paragraph" }, | |
13 | { "Oslash", "Ooblique" }, | |
14 | { "Shift_L", "ShiftL" }, | |
15 | { "Shift_R", "ShiftR" }, | |
16 | { "Control_L", "CtrlL" }, | |
17 | { "Control_R", "CtrlR" }, | |
18 | { "AltL", "Alt" }, | |
19 | { "AltR", "AltGr" }, | |
20 | { "Alt_L", "Alt" }, | |
21 | { "Alt_R", "AltGr" }, | |
22 | { "AltGr_L", "Alt" }, | |
23 | { "AltGr_R", "AltGr" }, | |
24 | { "AltLLock", "Alt_Lock" }, | |
25 | { "AltRLock", "AltGr_Lock" }, | |
26 | { "SCtrl", "SControl" }, | |
27 | { "Spawn_Console", "KeyboardSignal" }, | |
28 | { "Uncaps_Shift", "CapsShift" }, | |
29 | /* the names of the Greek letters are spelled differently | |
31 | 30 | in the iso-8859-7 and the Unicode standards */ |
32 | { "lambda", "lamda" }, | |
33 | { "Lambda", "Lamda" }, | |
34 | { "xi", "ksi" }, | |
35 | { "Xi", "Ksi" }, | |
36 | { "chi", "khi" }, | |
37 | { "Chi", "Khi" }, | |
38 | /* diacriticals */ | |
39 | { "tilde", "asciitilde" }, | |
40 | { "circumflex", "asciicircum" }, | |
41 | /* as dead_ogonek, dead_caron, dead_breve and dead_doubleacute do not exist | |
42 | * (yet), I put also compose lines for use with respectively dead_cedilla, | |
43 | * dead_circumflex, dead_tilde and dead_tilde */ | |
44 | { "dead_ogonek", "dead_cedilla" }, | |
45 | { "dead_caron", "dead_circumflex" }, | |
46 | { "dead_breve", "dead_tilde" }, | |
47 | { "dead_doubleacute", "dead_tilde" }, | |
48 | /* turkish */ | |
49 | { "Idotabove", "Iabovedot" }, | |
50 | { "dotlessi", "idotless" }, | |
51 | /* cyrillic */ | |
52 | { "no-break_space", "nobreakspace" }, | |
53 | { "paragraph_sign", "section" }, | |
54 | { "soft_hyphen", "hyphen" }, | |
31 | { "lambda", "lamda" }, | |
32 | { "Lambda", "Lamda" }, | |
33 | { "xi", "ksi" }, | |
34 | { "Xi", "Ksi" }, | |
35 | { "chi", "khi" }, | |
36 | { "Chi", "Khi" }, | |
37 | /* diacriticals */ | |
38 | { "tilde", "asciitilde" }, | |
39 | { "circumflex", "asciicircum" }, | |
40 | /* as dead_ogonek, dead_caron, dead_breve and dead_doubleacute do not exist | |
41 | * (yet), I put also compose lines for use with respectively dead_cedilla, | |
42 | * dead_circumflex, dead_tilde and dead_tilde | |
43 | */ | |
44 | { "dead_ogonek", "dead_cedilla" }, | |
45 | { "dead_caron", "dead_circumflex" }, | |
46 | { "dead_breve", "dead_tilde" }, | |
47 | { "dead_doubleacute", "dead_tilde" }, | |
48 | /* turkish */ | |
49 | { "Idotabove", "Iabovedot" }, | |
50 | { "dotlessi", "idotless" }, | |
51 | /* cyrillic */ | |
52 | { "no-break_space", "nobreakspace" }, | |
53 | { "paragraph_sign", "section" }, | |
54 | { "soft_hyphen", "hyphen" }, | |
55 | 55 | { "bielorussian_cyrillic_capital_letter_i", "ukrainian_cyrillic_capital_letter_i" }, |
56 | 56 | { "cyrillic_capital_letter_kha", "cyrillic_capital_letter_ha" }, |
57 | 57 | { "cyrillic_capital_letter_ge", "cyrillic_capital_letter_ghe" }, |
72 | 72 | { "cyrillic_small_letter_short_ii", "cyrillic_small_letter_short_i" }, |
73 | 73 | { "ukrainian_cyrillic_small_letter_ghe_with_upturn", "cyrillic_small_letter_ghe_with_upturn" }, |
74 | 74 | { "ukrainian_cyrillic_capital_letter_ghe_with_upturn", "cyrillic_capital_letter_ghe_with_upturn" }, |
75 | /* iso-8859-7 */ | |
76 | { "rightanglequote", "guillemotright" } | |
75 | /* iso-8859-7 */ | |
76 | { "rightanglequote", "guillemotright" } | |
77 | 77 | }; |
1 | 1 | * Theppitak Karoonboonyanan <thep@linux.thai.net> |
2 | 2 | */ |
3 | 3 | |
4 | static sym | |
5 | const tis_620_syms[] = { | |
6 | { 0x00a0, "nobreakspace" }, | |
7 | { 0x0e01, "thai_kokai" }, | |
8 | { 0x0e02, "thai_khokhai" }, | |
9 | { 0x0e03, "thai_khokhuat" }, | |
10 | { 0x0e04, "thai_khokhwai" }, | |
11 | { 0x0e05, "thai_khokhon" }, | |
12 | { 0x0e06, "thai_khorakhang" }, | |
13 | { 0x0e07, "thai_ngongu" }, | |
14 | { 0x0e08, "thai_chochan" }, | |
15 | { 0x0e09, "thai_choching" }, | |
16 | { 0x0e0a, "thai_chochang" }, | |
17 | { 0x0e0b, "thai_soso" }, | |
18 | { 0x0e0c, "thai_chochoe" }, | |
19 | { 0x0e0d, "thai_yoying" }, | |
20 | { 0x0e0e, "thai_dochada" }, | |
21 | { 0x0e0f, "thai_topatak" }, | |
22 | { 0x0e10, "thai_thothan" }, | |
23 | { 0x0e11, "thai_thonangmontho" }, | |
24 | { 0x0e12, "thai_thophuthao" }, | |
25 | { 0x0e13, "thai_nonen" }, | |
26 | { 0x0e14, "thai_dodek" }, | |
27 | { 0x0e15, "thai_totao" }, | |
28 | { 0x0e16, "thai_thothung" }, | |
29 | { 0x0e17, "thai_thothahan" }, | |
30 | { 0x0e18, "thai_thothong" }, | |
31 | { 0x0e19, "thai_nonu" }, | |
32 | { 0x0e1a, "thai_bobaimai" }, | |
33 | { 0x0e1b, "thai_popla" }, | |
34 | { 0x0e1c, "thai_phophung" }, | |
35 | { 0x0e1d, "thai_fofa" }, | |
36 | { 0x0e1e, "thai_phophan" }, | |
37 | { 0x0e1f, "thai_fofan" }, | |
38 | { 0x0e20, "thai_phosamphao" }, | |
39 | { 0x0e21, "thai_moma" }, | |
40 | { 0x0e22, "thai_yoyak" }, | |
41 | { 0x0e23, "thai_rorua" }, | |
42 | { 0x0e24, "thai_ru" }, | |
43 | { 0x0e25, "thai_loling" }, | |
44 | { 0x0e26, "thai_lu" }, | |
45 | { 0x0e27, "thai_wowaen" }, | |
46 | { 0x0e28, "thai_sosala" }, | |
47 | { 0x0e29, "thai_sorusi" }, | |
48 | { 0x0e2a, "thai_sosua" }, | |
49 | { 0x0e2b, "thai_hohip" }, | |
50 | { 0x0e2c, "thai_lochula" }, | |
51 | { 0x0e2d, "thai_oang" }, | |
52 | { 0x0e2e, "thai_honokhuk" }, | |
53 | { 0x0e2f, "thai_paiyannoi" }, | |
54 | { 0x0e30, "thai_saraa" }, | |
55 | { 0x0e31, "thai_maihanakat" }, | |
56 | { 0x0e32, "thai_saraaa" }, | |
57 | { 0x0e33, "thai_saraam" }, | |
58 | { 0x0e34, "thai_sarai" }, | |
59 | { 0x0e35, "thai_saraii" }, | |
60 | { 0x0e36, "thai_saraue" }, | |
61 | { 0x0e37, "thai_sarauee" }, | |
62 | { 0x0e38, "thai_sarau" }, | |
63 | { 0x0e39, "thai_sarauu" }, | |
64 | { 0x0e3a, "thai_phinthu" }, | |
65 | { 0x0e3b, "" }, | |
66 | { 0x0e3c, "" }, | |
67 | { 0x0e3d, "" }, | |
68 | { 0x0e3e, "" }, | |
69 | { 0x0e3f, "thai_baht" }, | |
70 | { 0x0e40, "thai_sarae" }, | |
71 | { 0x0e41, "thai_saraae" }, | |
72 | { 0x0e42, "thai_sarao" }, | |
73 | { 0x0e43, "thai_saraaimaimuan" }, | |
74 | { 0x0e44, "thai_saraaimaimalai" }, | |
75 | { 0x0e45, "thai_lakkhangyao" }, | |
76 | { 0x0e46, "thai_maiyamok" }, | |
77 | { 0x0e47, "thai_maitaikhu" }, | |
78 | { 0x0e48, "thai_maiek" }, | |
79 | { 0x0e49, "thai_maitho" }, | |
80 | { 0x0e4a, "thai_maitri" }, | |
81 | { 0x0e4b, "thai_maichattawa" }, | |
82 | { 0x0e4c, "thai_thanthakhat" }, | |
83 | { 0x0e4d, "thai_nikhahit" }, | |
84 | { 0x0e4e, "thai_yamakkan" }, | |
85 | { 0x0e4f, "thai_fongman" }, | |
86 | { 0x0e50, "thai_leksun" }, | |
87 | { 0x0e51, "thai_leknung" }, | |
88 | { 0x0e52, "thai_leksong" }, | |
89 | { 0x0e53, "thai_leksam" }, | |
90 | { 0x0e54, "thai_leksi" }, | |
91 | { 0x0e55, "thai_lekha" }, | |
92 | { 0x0e56, "thai_lekhok" }, | |
93 | { 0x0e57, "thai_lekchet" }, | |
94 | { 0x0e58, "thai_lekpaet" }, | |
95 | { 0x0e59, "thai_lekkao" }, | |
96 | { 0x0e5a, "thai_angkhankhu" }, | |
97 | { 0x0e5b, "thai_khomut" }, | |
98 | { 0x0e5c, "" }, | |
99 | { 0x0e5d, "" }, | |
100 | { 0x0e5e, "" }, | |
101 | { 0x0e5f, "" }, | |
4 | static sym const tis_620_syms[] = { | |
5 | { 0x00a0, "nobreakspace" }, | |
6 | { 0x0e01, "thai_kokai" }, | |
7 | { 0x0e02, "thai_khokhai" }, | |
8 | { 0x0e03, "thai_khokhuat" }, | |
9 | { 0x0e04, "thai_khokhwai" }, | |
10 | { 0x0e05, "thai_khokhon" }, | |
11 | { 0x0e06, "thai_khorakhang" }, | |
12 | { 0x0e07, "thai_ngongu" }, | |
13 | { 0x0e08, "thai_chochan" }, | |
14 | { 0x0e09, "thai_choching" }, | |
15 | { 0x0e0a, "thai_chochang" }, | |
16 | { 0x0e0b, "thai_soso" }, | |
17 | { 0x0e0c, "thai_chochoe" }, | |
18 | { 0x0e0d, "thai_yoying" }, | |
19 | { 0x0e0e, "thai_dochada" }, | |
20 | { 0x0e0f, "thai_topatak" }, | |
21 | { 0x0e10, "thai_thothan" }, | |
22 | { 0x0e11, "thai_thonangmontho" }, | |
23 | { 0x0e12, "thai_thophuthao" }, | |
24 | { 0x0e13, "thai_nonen" }, | |
25 | { 0x0e14, "thai_dodek" }, | |
26 | { 0x0e15, "thai_totao" }, | |
27 | { 0x0e16, "thai_thothung" }, | |
28 | { 0x0e17, "thai_thothahan" }, | |
29 | { 0x0e18, "thai_thothong" }, | |
30 | { 0x0e19, "thai_nonu" }, | |
31 | { 0x0e1a, "thai_bobaimai" }, | |
32 | { 0x0e1b, "thai_popla" }, | |
33 | { 0x0e1c, "thai_phophung" }, | |
34 | { 0x0e1d, "thai_fofa" }, | |
35 | { 0x0e1e, "thai_phophan" }, | |
36 | { 0x0e1f, "thai_fofan" }, | |
37 | { 0x0e20, "thai_phosamphao" }, | |
38 | { 0x0e21, "thai_moma" }, | |
39 | { 0x0e22, "thai_yoyak" }, | |
40 | { 0x0e23, "thai_rorua" }, | |
41 | { 0x0e24, "thai_ru" }, | |
42 | { 0x0e25, "thai_loling" }, | |
43 | { 0x0e26, "thai_lu" }, | |
44 | { 0x0e27, "thai_wowaen" }, | |
45 | { 0x0e28, "thai_sosala" }, | |
46 | { 0x0e29, "thai_sorusi" }, | |
47 | { 0x0e2a, "thai_sosua" }, | |
48 | { 0x0e2b, "thai_hohip" }, | |
49 | { 0x0e2c, "thai_lochula" }, | |
50 | { 0x0e2d, "thai_oang" }, | |
51 | { 0x0e2e, "thai_honokhuk" }, | |
52 | { 0x0e2f, "thai_paiyannoi" }, | |
53 | { 0x0e30, "thai_saraa" }, | |
54 | { 0x0e31, "thai_maihanakat" }, | |
55 | { 0x0e32, "thai_saraaa" }, | |
56 | { 0x0e33, "thai_saraam" }, | |
57 | { 0x0e34, "thai_sarai" }, | |
58 | { 0x0e35, "thai_saraii" }, | |
59 | { 0x0e36, "thai_saraue" }, | |
60 | { 0x0e37, "thai_sarauee" }, | |
61 | { 0x0e38, "thai_sarau" }, | |
62 | { 0x0e39, "thai_sarauu" }, | |
63 | { 0x0e3a, "thai_phinthu" }, | |
64 | { 0x0e3b, "" }, | |
65 | { 0x0e3c, "" }, | |
66 | { 0x0e3d, "" }, | |
67 | { 0x0e3e, "" }, | |
68 | { 0x0e3f, "thai_baht" }, | |
69 | { 0x0e40, "thai_sarae" }, | |
70 | { 0x0e41, "thai_saraae" }, | |
71 | { 0x0e42, "thai_sarao" }, | |
72 | { 0x0e43, "thai_saraaimaimuan" }, | |
73 | { 0x0e44, "thai_saraaimaimalai" }, | |
74 | { 0x0e45, "thai_lakkhangyao" }, | |
75 | { 0x0e46, "thai_maiyamok" }, | |
76 | { 0x0e47, "thai_maitaikhu" }, | |
77 | { 0x0e48, "thai_maiek" }, | |
78 | { 0x0e49, "thai_maitho" }, | |
79 | { 0x0e4a, "thai_maitri" }, | |
80 | { 0x0e4b, "thai_maichattawa" }, | |
81 | { 0x0e4c, "thai_thanthakhat" }, | |
82 | { 0x0e4d, "thai_nikhahit" }, | |
83 | { 0x0e4e, "thai_yamakkan" }, | |
84 | { 0x0e4f, "thai_fongman" }, | |
85 | { 0x0e50, "thai_leksun" }, | |
86 | { 0x0e51, "thai_leknung" }, | |
87 | { 0x0e52, "thai_leksong" }, | |
88 | { 0x0e53, "thai_leksam" }, | |
89 | { 0x0e54, "thai_leksi" }, | |
90 | { 0x0e55, "thai_lekha" }, | |
91 | { 0x0e56, "thai_lekhok" }, | |
92 | { 0x0e57, "thai_lekchet" }, | |
93 | { 0x0e58, "thai_lekpaet" }, | |
94 | { 0x0e59, "thai_lekkao" }, | |
95 | { 0x0e5a, "thai_angkhankhu" }, | |
96 | { 0x0e5b, "thai_khomut" }, | |
97 | { 0x0e5c, "" }, | |
98 | { 0x0e5d, "" }, | |
99 | { 0x0e5e, "" }, | |
100 | { 0x0e5f, "" }, | |
102 | 101 | }; |
24 | 24 | |
25 | 25 | #include "keymap.h" |
26 | 26 | |
27 | static const char *progname = NULL; | |
27 | static const char *progname = NULL; | |
28 | 28 | static const char *const dirpath1[] = { "", DATADIR "/" KEYMAPDIR "/**", KERNDIR "/", 0 }; |
29 | 29 | static const char *const suffixes[] = { "", ".kmap", ".map", 0 }; |
30 | 30 | |
31 | static void __attribute__ ((noreturn)) | |
31 | static void __attribute__((noreturn)) | |
32 | 32 | usage(void) |
33 | 33 | { |
34 | 34 | fprintf(stderr, _("loadkeys version %s\n" |
35 | "\n" | |
36 | "Usage: %s [option...] [mapfile...]\n" | |
37 | "\n" | |
38 | "Valid options are:\n" | |
39 | "\n" | |
40 | " -a --ascii force conversion to ASCII\n" | |
41 | " -b --bkeymap output a binary keymap to stdout\n" | |
42 | " -c --clearcompose clear kernel compose table\n" | |
43 | " -C --console=file\n" | |
44 | " the console device to be used\n" | |
45 | " -d --default load \"%s\"\n" | |
46 | " -h --help display this help text\n" | |
47 | " -m --mktable output a \"defkeymap.c\" to stdout\n" | |
48 | " -p --parse search and parse keymap without action\n" | |
49 | " -q --quiet suppress all normal output\n" | |
50 | " -s --clearstrings clear kernel string table\n" | |
51 | " -u --unicode force conversion to Unicode\n" | |
52 | " -v --verbose report the changes\n" | |
53 | " -V --version print version number\n"), | |
54 | PACKAGE_VERSION, progname, DEFMAP); | |
35 | "\n" | |
36 | "Usage: %s [option...] [mapfile...]\n" | |
37 | "\n" | |
38 | "Valid options are:\n" | |
39 | "\n" | |
40 | " -a --ascii force conversion to ASCII\n" | |
41 | " -b --bkeymap output a binary keymap to stdout\n" | |
42 | " -c --clearcompose clear kernel compose table\n" | |
43 | " -C --console=file\n" | |
44 | " the console device to be used\n" | |
45 | " -d --default load \"%s\"\n" | |
46 | " -h --help display this help text\n" | |
47 | " -m --mktable output a \"defkeymap.c\" to stdout\n" | |
48 | " -p --parse search and parse keymap without action\n" | |
49 | " -q --quiet suppress all normal output\n" | |
50 | " -s --clearstrings clear kernel string table\n" | |
51 | " -u --unicode force conversion to Unicode\n" | |
52 | " -v --verbose report the changes\n" | |
53 | " -V --version print version number\n"), | |
54 | PACKAGE_VERSION, progname, DEFMAP); | |
55 | 55 | exit(EXIT_FAILURE); |
56 | 56 | } |
57 | 57 | |
63 | 63 | return (p && p + 1 ? p + 1 : name); |
64 | 64 | } |
65 | 65 | |
66 | int | |
67 | main(int argc, char *argv[]) | |
66 | int main(int argc, char *argv[]) | |
68 | 67 | { |
69 | const char *const short_opts = "abcC:dhmpsuqvV"; | |
68 | const char *const short_opts = "abcC:dhmpsuqvV"; | |
70 | 69 | const struct option const long_opts[] = { |
71 | { "console", required_argument, NULL, 'C'}, | |
72 | { "ascii", no_argument, NULL, 'a' }, | |
73 | { "bkeymap", no_argument, NULL, 'b' }, | |
74 | { "clearcompose", no_argument, NULL, 'c' }, | |
75 | { "default", no_argument, NULL, 'd' }, | |
76 | { "help", no_argument, NULL, 'h' }, | |
77 | { "mktable", no_argument, NULL, 'm' }, | |
78 | { "parse", no_argument, NULL, 'p' }, | |
79 | { "clearstrings", no_argument, NULL, 's' }, | |
80 | { "unicode", no_argument, NULL, 'u' }, | |
81 | { "quiet", no_argument, NULL, 'q' }, | |
82 | { "verbose", no_argument, NULL, 'v' }, | |
83 | { "version", no_argument, NULL, 'V' }, | |
70 | { "console", required_argument, NULL, 'C' }, | |
71 | { "ascii", no_argument, NULL, 'a' }, | |
72 | { "bkeymap", no_argument, NULL, 'b' }, | |
73 | { "clearcompose", no_argument, NULL, 'c' }, | |
74 | { "default", no_argument, NULL, 'd' }, | |
75 | { "help", no_argument, NULL, 'h' }, | |
76 | { "mktable", no_argument, NULL, 'm' }, | |
77 | { "parse", no_argument, NULL, 'p' }, | |
78 | { "clearstrings", no_argument, NULL, 's' }, | |
79 | { "unicode", no_argument, NULL, 'u' }, | |
80 | { "quiet", no_argument, NULL, 'q' }, | |
81 | { "verbose", no_argument, NULL, 'v' }, | |
82 | { "version", no_argument, NULL, 'V' }, | |
84 | 83 | { NULL, 0, NULL, 0 } |
85 | 84 | }; |
86 | 85 | |
121 | 120 | |
122 | 121 | while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { |
123 | 122 | switch (c) { |
124 | case 'a': | |
125 | options |= OPT_A; | |
126 | break; | |
127 | case 'b': | |
128 | options |= OPT_B; | |
129 | break; | |
130 | case 'c': | |
131 | flags |= LK_FLAG_CLEAR_COMPOSE; | |
132 | break; | |
133 | case 'C': | |
134 | console = optarg; | |
135 | break; | |
136 | case 'd': | |
137 | options |= OPT_D; | |
138 | break; | |
139 | case 'm': | |
140 | options |= OPT_M; | |
141 | break; | |
142 | case 'p': | |
143 | options |= OPT_P; | |
144 | break; | |
145 | case 's': | |
146 | flags |= LK_FLAG_CLEAR_STRINGS; | |
147 | break; | |
148 | case 'u': | |
149 | options |= OPT_U; | |
150 | flags |= LK_FLAG_UNICODE_MODE; | |
151 | flags |= LK_FLAG_PREFER_UNICODE; | |
152 | break; | |
153 | case 'q': | |
154 | lk_set_log_priority(ctx, LOG_ERR); | |
155 | break; | |
156 | case 'v': | |
157 | lk_set_log_priority(ctx, LOG_INFO); | |
158 | break; | |
159 | case 'V': | |
160 | fprintf(stdout, _("%s from %s\n"), progname, PACKAGE_STRING); | |
161 | exit(0); | |
162 | case 'h': | |
163 | case '?': | |
164 | usage(); | |
123 | case 'a': | |
124 | options |= OPT_A; | |
125 | break; | |
126 | case 'b': | |
127 | options |= OPT_B; | |
128 | break; | |
129 | case 'c': | |
130 | flags |= LK_FLAG_CLEAR_COMPOSE; | |
131 | break; | |
132 | case 'C': | |
133 | console = optarg; | |
134 | break; | |
135 | case 'd': | |
136 | options |= OPT_D; | |
137 | break; | |
138 | case 'm': | |
139 | options |= OPT_M; | |
140 | break; | |
141 | case 'p': | |
142 | options |= OPT_P; | |
143 | break; | |
144 | case 's': | |
145 | flags |= LK_FLAG_CLEAR_STRINGS; | |
146 | break; | |
147 | case 'u': | |
148 | options |= OPT_U; | |
149 | flags |= LK_FLAG_UNICODE_MODE; | |
150 | flags |= LK_FLAG_PREFER_UNICODE; | |
151 | break; | |
152 | case 'q': | |
153 | lk_set_log_priority(ctx, LOG_ERR); | |
154 | break; | |
155 | case 'v': | |
156 | lk_set_log_priority(ctx, LOG_INFO); | |
157 | break; | |
158 | case 'V': | |
159 | fprintf(stdout, _("%s from %s\n"), progname, PACKAGE_STRING); | |
160 | exit(0); | |
161 | case 'h': | |
162 | case '?': | |
163 | usage(); | |
165 | 164 | } |
166 | 165 | } |
167 | 166 | |
168 | 167 | if ((options & OPT_U) && (options & OPT_A)) { |
169 | 168 | fprintf(stderr, |
170 | _("%s: Options --unicode and --ascii are mutually exclusive\n"), | |
171 | progname); | |
169 | _("%s: Options --unicode and --ascii are mutually exclusive\n"), | |
170 | progname); | |
172 | 171 | exit(EXIT_FAILURE); |
173 | 172 | } |
174 | 173 | |
181 | 180 | if (ioctl(fd, KDGKBMODE, &kbd_mode) || |
182 | 181 | ioctl(fd, KDGETMODE, &kd_mode)) { |
183 | 182 | fprintf(stderr, _("%s: error reading keyboard mode: %m\n"), |
184 | progname); | |
183 | progname); | |
185 | 184 | exit(EXIT_FAILURE); |
186 | 185 | } |
187 | 186 | |
188 | 187 | if (kbd_mode == K_UNICODE) { |
189 | 188 | if (options & OPT_A) { |
190 | 189 | fprintf(stderr, |
191 | _("%s: warning: loading non-Unicode keymap on Unicode console\n" | |
192 | " (perhaps you want to do `kbd_mode -a'?)\n"), | |
193 | progname); | |
190 | _("%s: warning: loading non-Unicode keymap on Unicode console\n" | |
191 | " (perhaps you want to do `kbd_mode -a'?)\n"), | |
192 | progname); | |
194 | 193 | } else { |
195 | 194 | flags |= LK_FLAG_PREFER_UNICODE; |
196 | 195 | } |
200 | 199 | |
201 | 200 | } else if (options & OPT_U && kd_mode != KD_GRAPHICS) { |
202 | 201 | fprintf(stderr, |
203 | _("%s: warning: loading Unicode keymap on non-Unicode console\n" | |
204 | " (perhaps you want to do `kbd_mode -u'?)\n"), | |
205 | progname); | |
202 | _("%s: warning: loading Unicode keymap on non-Unicode console\n" | |
203 | " (perhaps you want to do `kbd_mode -u'?)\n"), | |
204 | progname); | |
206 | 205 | } |
207 | 206 | } |
208 | 207 | |
211 | 210 | dirpath = dirpath1; |
212 | 211 | if ((ev = getenv("LOADKEYS_KEYMAP_PATH")) != NULL) { |
213 | 212 | dirpath2[0] = ev; |
214 | dirpath = dirpath2; | |
213 | dirpath = dirpath2; | |
215 | 214 | } |
216 | 215 | |
217 | 216 | if (options & OPT_D) { |
224 | 223 | |
225 | 224 | if ((rc = lk_parse_keymap(ctx, &f)) == -1) |
226 | 225 | goto fail; |
227 | ||
228 | 226 | |
229 | 227 | } else if (optind == argc) { |
230 | 228 | f.fd = stdin; |
258 | 256 | } |
259 | 257 | } |
260 | 258 | |
261 | fail: lk_free(ctx); | |
259 | fail: | |
260 | lk_free(ctx); | |
262 | 261 | lk_fpclose(&f); |
263 | 262 | close(fd); |
264 | 263 |
28 | 28 | extern char *progname; |
29 | 29 | extern int force; |
30 | 30 | |
31 | static const char *const unidirpath[] = { "", DATADIR "/" UNIMAPDIR "/", 0 }; | |
31 | static const char *const unidirpath[] = { "", DATADIR "/" UNIMAPDIR "/", 0 }; | |
32 | 32 | static const char *const unisuffixes[] = { "", ".uni", ".sfm", 0 }; |
33 | 33 | |
34 | 34 | #ifdef MAIN |
35 | 35 | #include "version.h" |
36 | 36 | int verbose = 0; |
37 | int force = 0; | |
38 | int debug = 0; | |
39 | ||
40 | static void __attribute__ ((noreturn)) | |
41 | usage(void) { | |
42 | fprintf(stderr, | |
43 | _("Usage:\n\t%s [-C console] [-o map.orig]\n"), progname); | |
44 | exit(1); | |
45 | } | |
46 | ||
47 | int | |
48 | main(int argc, char *argv[]) { | |
37 | int force = 0; | |
38 | int debug = 0; | |
39 | ||
40 | static void __attribute__((noreturn)) | |
41 | usage(void) | |
42 | { | |
43 | fprintf(stderr, | |
44 | _("Usage:\n\t%s [-C console] [-o map.orig]\n"), progname); | |
45 | exit(1); | |
46 | } | |
47 | ||
48 | int main(int argc, char *argv[]) | |
49 | { | |
49 | 50 | int fd, c; |
50 | 51 | char *console = NULL; |
51 | 52 | char *outfnam = NULL; |
52 | char *infnam = "def.uni"; | |
53 | char *infnam = "def.uni"; | |
53 | 54 | |
54 | 55 | set_progname(argv[0]); |
55 | 56 | |
63 | 64 | |
64 | 65 | while ((c = getopt(argc, argv, "C:o:")) != EOF) { |
65 | 66 | switch (c) { |
66 | case 'C': | |
67 | console = optarg; | |
68 | break; | |
69 | case 'o': | |
70 | outfnam = optarg; | |
71 | break; | |
72 | default: | |
73 | usage(); | |
74 | } | |
75 | } | |
76 | ||
77 | if (argc > optind+1 || (argc == optind && !outfnam)) | |
67 | case 'C': | |
68 | console = optarg; | |
69 | break; | |
70 | case 'o': | |
71 | outfnam = optarg; | |
72 | break; | |
73 | default: | |
74 | usage(); | |
75 | } | |
76 | } | |
77 | ||
78 | if (argc > optind + 1 || (argc == optind && !outfnam)) | |
78 | 79 | usage(); |
79 | 80 | |
80 | 81 | if ((fd = getfd(console)) < 0) |
86 | 87 | exit(0); |
87 | 88 | } |
88 | 89 | |
89 | if (argc == optind+1) | |
90 | if (argc == optind + 1) | |
90 | 91 | infnam = argv[optind]; |
91 | 92 | loadunicodemap(fd, infnam); |
92 | 93 | exit(0); |
96 | 97 | /* |
97 | 98 | * Skip spaces and read U+1234 or return -1 for error. |
98 | 99 | * Return first non-read position in *p0 (unchanged on error). |
99 | */ | |
100 | */ | |
100 | 101 | static int |
101 | getunicode(char **p0) { | |
102 | getunicode(char **p0) | |
103 | { | |
102 | 104 | char *p = *p0; |
103 | 105 | |
104 | 106 | while (*p == ' ' || *p == '\t') |
124 | 126 | if (*p != 'U' || p[1] != '+' || !isxdigit(p[2]) || !isxdigit(p[3]) || |
125 | 127 | !isxdigit(p[4]) || !isxdigit(p[5]) || isxdigit(p[6])) |
126 | 128 | return -1; |
127 | *p0 = p+6; | |
128 | return strtol(p+2,0,16); | |
129 | *p0 = p + 6; | |
130 | return strtol(p + 2, 0, 16); | |
129 | 131 | } |
130 | 132 | |
131 | 133 | static struct unimapdesc descr; |
132 | 134 | |
133 | 135 | static struct unipair *list = 0; |
134 | static int listsz = 0; | |
135 | static int listct = 0; | |
136 | static int listsz = 0; | |
137 | static int listct = 0; | |
136 | 138 | |
137 | 139 | static void |
138 | addpair(int fp, int un) { | |
139 | if (listct == listsz) { | |
140 | listsz += 4096; | |
141 | list = xrealloc((char *)list, listsz); | |
142 | } | |
143 | list[listct].fontpos = fp; | |
144 | list[listct].unicode = un; | |
145 | listct++; | |
140 | addpair(int fp, int un) | |
141 | { | |
142 | if (listct == listsz) { | |
143 | listsz += 4096; | |
144 | list = xrealloc((char *)list, listsz); | |
145 | } | |
146 | list[listct].fontpos = fp; | |
147 | list[listct].unicode = un; | |
148 | listct++; | |
146 | 149 | } |
147 | 150 | |
148 | 151 | /* |
158 | 161 | */ |
159 | 162 | |
160 | 163 | static void |
161 | parseline(char *buffer, char *tblname) { | |
164 | parseline(char *buffer, char *tblname) | |
165 | { | |
162 | 166 | int fontlen = 512; |
163 | 167 | int i; |
164 | 168 | int fp0, fp1, un0, un1; |
169 | 173 | while (*p == ' ' || *p == '\t') |
170 | 174 | p++; |
171 | 175 | if (!*p || *p == '#') |
172 | return; /* skip comment or blank line */ | |
176 | return; /* skip comment or blank line */ | |
173 | 177 | |
174 | 178 | fp0 = strtol(p, &p1, 0); |
175 | 179 | if (p1 == p) { |
191 | 195 | } else |
192 | 196 | fp1 = 0; |
193 | 197 | |
194 | if ( fp0 < 0 || fp0 >= fontlen ) { | |
198 | if (fp0 < 0 || fp0 >= fontlen) { | |
195 | 199 | fprintf(stderr, |
196 | _("%s: Glyph number (0x%x) larger than font length\n"), | |
197 | tblname, fp0); | |
200 | _("%s: Glyph number (0x%x) larger than font length\n"), | |
201 | tblname, fp0); | |
198 | 202 | exit(EX_DATAERR); |
199 | 203 | } |
200 | if ( fp1 && (fp1 < fp0 || fp1 >= fontlen) ) { | |
204 | if (fp1 && (fp1 < fp0 || fp1 >= fontlen)) { | |
201 | 205 | fprintf(stderr, |
202 | _("%s: Bad end of range (0x%x)\n"), | |
203 | tblname, fp1); | |
206 | _("%s: Bad end of range (0x%x)\n"), | |
207 | tblname, fp1); | |
204 | 208 | exit(EX_DATAERR); |
205 | 209 | } |
206 | 210 | |
211 | 215 | p++; |
212 | 216 | if (!strncmp(p, "idem", 4)) { |
213 | 217 | p += 4; |
214 | for (i=fp0; i<=fp1; i++) | |
215 | addpair(i,i); | |
218 | for (i = fp0; i <= fp1; i++) | |
219 | addpair(i, i); | |
216 | 220 | goto lookattail; |
217 | 221 | } |
218 | 222 | |
220 | 224 | while (*p == ' ' || *p == '\t') |
221 | 225 | p++; |
222 | 226 | if (*p != '-') { |
223 | for (i=fp0; i<=fp1; i++) | |
224 | addpair(i,un0); | |
227 | for (i = fp0; i <= fp1; i++) | |
228 | addpair(i, un0); | |
225 | 229 | goto lookattail; |
226 | 230 | } |
227 | 231 | |
229 | 233 | un1 = getunicode(&p); |
230 | 234 | if (un0 < 0 || un1 < 0) { |
231 | 235 | fprintf(stderr, |
232 | _("%s: Bad Unicode range corresponding to " | |
233 | "font position range 0x%x-0x%x\n"), | |
234 | tblname, fp0, fp1); | |
236 | _("%s: Bad Unicode range corresponding to " | |
237 | "font position range 0x%x-0x%x\n"), | |
238 | tblname, fp0, fp1); | |
235 | 239 | exit(EX_DATAERR); |
236 | 240 | } |
237 | 241 | if (un1 - un0 != fp1 - fp0) { |
238 | 242 | fprintf(stderr, |
239 | _("%s: Unicode range U+%x-U+%x not of the same" | |
240 | " length as font position range 0x%x-0x%x\n"), | |
241 | tblname, un0, un1, fp0, fp1); | |
243 | _("%s: Unicode range U+%x-U+%x not of the same" | |
244 | " length as font position range 0x%x-0x%x\n"), | |
245 | tblname, un0, un1, fp0, fp1); | |
242 | 246 | exit(EX_DATAERR); |
243 | 247 | } |
244 | for(i=fp0; i<=fp1; i++) | |
245 | addpair(i,un0-fp0+i); | |
248 | for (i = fp0; i <= fp1; i++) | |
249 | addpair(i, un0 - fp0 + i); | |
246 | 250 | |
247 | 251 | } else { |
248 | 252 | /* no range; expect a list of unicode values |
249 | 253 | for a single font position */ |
250 | 254 | |
251 | while ( (un0 = getunicode(&p)) >= 0 ) | |
255 | while ((un0 = getunicode(&p)) >= 0) | |
252 | 256 | addpair(fp0, un0); |
253 | 257 | } |
254 | lookattail: | |
258 | lookattail: | |
255 | 259 | while (*p == ' ' || *p == '\t') |
256 | 260 | p++; |
257 | 261 | if (*p && *p != '#') |
258 | 262 | fprintf(stderr, _("%s: trailing junk (%s) ignored\n"), |
259 | tblname, p); | |
260 | } | |
261 | ||
262 | void | |
263 | loadunicodemap(int fd, char *tblname) { | |
263 | tblname, p); | |
264 | } | |
265 | ||
266 | void loadunicodemap(int fd, char *tblname) | |
267 | { | |
264 | 268 | char buffer[65536]; |
265 | 269 | char *p; |
266 | 270 | lkfile_t fp; |
273 | 277 | if (verbose) |
274 | 278 | printf(_("Loading unicode map from file %s\n"), fp.pathname); |
275 | 279 | |
276 | while ( fgets(buffer, sizeof(buffer), fp.fd) != NULL ) { | |
277 | if ( (p = strchr(buffer, '\n')) != NULL ) | |
280 | while (fgets(buffer, sizeof(buffer), fp.fd) != NULL) { | |
281 | if ((p = strchr(buffer, '\n')) != NULL) | |
278 | 282 | *p = '\0'; |
279 | 283 | else |
280 | 284 | fprintf(stderr, _("%s: %s: Warning: line too long\n"), |
281 | progname, tblname); | |
285 | progname, tblname); | |
282 | 286 | |
283 | 287 | parseline(buffer, tblname); |
284 | 288 | } |
287 | 291 | |
288 | 292 | if (listct == 0 && !force) { |
289 | 293 | fprintf(stderr, |
290 | _("%s: not loading empty unimap\n" | |
291 | "(if you insist: use option -f to override)\n"), | |
292 | progname); | |
294 | _("%s: not loading empty unimap\n" | |
295 | "(if you insist: use option -f to override)\n"), | |
296 | progname); | |
293 | 297 | } else { |
294 | 298 | descr.entry_ct = listct; |
295 | descr.entries = list; | |
296 | if (loadunimap (fd, NULL, &descr)) | |
299 | descr.entries = list; | |
300 | if (loadunimap(fd, NULL, &descr)) | |
297 | 301 | exit(1); |
298 | 302 | listct = 0; |
299 | 303 | } |
300 | 304 | } |
301 | 305 | |
302 | 306 | static struct unimapdesc |
303 | getunicodemap(int fd) { | |
304 | struct unimapdesc unimap_descr; | |
305 | ||
306 | if (getunimap(fd, &unimap_descr)) | |
307 | exit(1); | |
307 | getunicodemap(int fd) | |
308 | { | |
309 | struct unimapdesc unimap_descr; | |
310 | ||
311 | if (getunimap(fd, &unimap_descr)) | |
312 | exit(1); | |
308 | 313 | |
309 | 314 | #ifdef MAIN |
310 | fprintf(stderr, "# %d %s\n", unimap_descr.entry_ct, | |
311 | (unimap_descr.entry_ct == 1) ? _("entry") : _("entries")); | |
315 | fprintf(stderr, "# %d %s\n", unimap_descr.entry_ct, | |
316 | (unimap_descr.entry_ct == 1) ? _("entry") : _("entries")); | |
312 | 317 | #endif |
313 | 318 | |
314 | return unimap_descr; | |
315 | } | |
316 | ||
317 | void | |
318 | saveunicodemap(int fd, char *oufil) { | |
319 | FILE *fpo; | |
320 | struct unimapdesc unimap_descr; | |
321 | struct unipair *unilist; | |
322 | int i; | |
323 | ||
324 | if ((fpo = fopen(oufil, "w")) == NULL) { | |
325 | perror(oufil); | |
326 | exit(1); | |
327 | } | |
328 | ||
329 | unimap_descr = getunicodemap(fd); | |
330 | unilist = unimap_descr.entries; | |
331 | ||
332 | for(i=0; i<unimap_descr.entry_ct; i++) | |
333 | fprintf(fpo, "0x%02x\tU+%04x\n", unilist[i].fontpos, unilist[i].unicode); | |
334 | fclose(fpo); | |
335 | ||
336 | if (verbose) | |
337 | printf(_("Saved unicode map on `%s'\n"), oufil); | |
338 | } | |
339 | ||
340 | void | |
341 | appendunicodemap(int fd, FILE *fp, int fontsize, int utf8) { | |
319 | return unimap_descr; | |
320 | } | |
321 | ||
322 | void saveunicodemap(int fd, char *oufil) | |
323 | { | |
324 | FILE *fpo; | |
325 | struct unimapdesc unimap_descr; | |
326 | struct unipair *unilist; | |
327 | int i; | |
328 | ||
329 | if ((fpo = fopen(oufil, "w")) == NULL) { | |
330 | perror(oufil); | |
331 | exit(1); | |
332 | } | |
333 | ||
334 | unimap_descr = getunicodemap(fd); | |
335 | unilist = unimap_descr.entries; | |
336 | ||
337 | for (i = 0; i < unimap_descr.entry_ct; i++) | |
338 | fprintf(fpo, "0x%02x\tU+%04x\n", unilist[i].fontpos, unilist[i].unicode); | |
339 | fclose(fpo); | |
340 | ||
341 | if (verbose) | |
342 | printf(_("Saved unicode map on `%s'\n"), oufil); | |
343 | } | |
344 | ||
345 | void appendunicodemap(int fd, FILE *fp, int fontsize, int utf8) | |
346 | { | |
342 | 347 | struct unimapdesc unimap_descr; |
343 | 348 | struct unipair *unilist; |
344 | 349 | int i, j; |
345 | 350 | |
346 | 351 | unimap_descr = getunicodemap(fd); |
347 | unilist = unimap_descr.entries; | |
348 | ||
349 | ||
350 | for(i=0; i<fontsize; i++) { | |
352 | unilist = unimap_descr.entries; | |
353 | ||
354 | for (i = 0; i < fontsize; i++) { | |
351 | 355 | #if 0 |
352 | 356 | /* More than one mapping is not a sequence! */ |
353 | 357 | int no = 0; |
356 | 360 | no++; |
357 | 361 | if (no > 1) |
358 | 362 | appendseparator(fp, 1, utf8); |
359 | #endif | |
360 | if (debug) printf ("\nchar %03x: ", i); | |
361 | for(j=0; j<unimap_descr.entry_ct; j++) | |
363 | #endif | |
364 | if (debug) | |
365 | printf("\nchar %03x: ", i); | |
366 | for (j = 0; j < unimap_descr.entry_ct; j++) | |
362 | 367 | if (unilist[j].fontpos == i) { |
363 | 368 | if (debug) |
364 | printf ("%04x ", unilist[j].unicode); | |
369 | printf("%04x ", unilist[j].unicode); | |
365 | 370 | appendunicode(fp, unilist[j].unicode, utf8); |
366 | 371 | } |
367 | 372 | appendseparator(fp, 0, utf8); |
368 | 373 | } |
369 | 374 | |
370 | ||
371 | if (debug) printf ("\n"); | |
375 | if (debug) | |
376 | printf("\n"); | |
372 | 377 | if (verbose) |
373 | 378 | printf(_("Appended Unicode map\n")); |
374 | 379 | } |
2 | 2 | #ifndef _LOADUNIMAP_H |
3 | 3 | #define _LOADUNIMAP_H |
4 | 4 | |
5 | void saveunicodemap(int fd, char *oufil); /* save humanly readable */ | |
5 | void saveunicodemap(int fd, char *oufil); /* save humanly readable */ | |
6 | 6 | void loadunicodemap(int fd, char *ufil); |
7 | 7 | void appendunicodemap(int fd, FILE *fp, int ct, int utf8); |
8 | 8 | |
9 | #endif /* _LOADUNIMAP_H */ | |
9 | #endif /* _LOADUNIMAP_H */ |
22 | 22 | void saveoldmap(int fd, char *omfil); |
23 | 23 | void loadnewmap(int fd, char *mfil); |
24 | 24 | |
25 | static int ctoi (char *); | |
25 | static int ctoi(char *); | |
26 | 26 | |
27 | 27 | /* search for the map file in these directories (with trailing /) */ |
28 | static const char *const mapdirpath[] = { "", DATADIR "/" TRANSDIR "/", 0 }; | |
28 | static const char *const mapdirpath[] = { "", DATADIR "/" TRANSDIR "/", 0 }; | |
29 | 29 | static const char *const mapsuffixes[] = { "", ".trans", "_to_uni.trans", ".acm", 0 }; |
30 | 30 | |
31 | 31 | #ifdef MAIN |
33 | 33 | #include "version.h" |
34 | 34 | |
35 | 35 | int verbose = 0; |
36 | int debug = 0; | |
37 | ||
38 | int | |
39 | main(int argc, char *argv[]) { | |
36 | int debug = 0; | |
37 | ||
38 | int main(int argc, char *argv[]) | |
39 | { | |
40 | 40 | int fd; |
41 | 41 | |
42 | 42 | set_progname(argv[0]); |
46 | 46 | textdomain(PACKAGE_NAME); |
47 | 47 | |
48 | 48 | if (argc == 2 && !strcmp(argv[1], "-V")) |
49 | print_version_and_exit(); | |
49 | print_version_and_exit(); | |
50 | 50 | |
51 | 51 | if (argc > 1 && !strcmp(argv[1], "-v")) { |
52 | 52 | verbose = 1; |
58 | 58 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
59 | 59 | |
60 | 60 | if (argc >= 3 && !strcmp(argv[1], "-o")) { |
61 | saveoldmap(fd, argv[2]); | |
62 | argc -= 2; | |
63 | argv += 2; | |
64 | if (argc == 1) | |
65 | exit(EXIT_SUCCESS); | |
66 | } | |
67 | ||
61 | saveoldmap(fd, argv[2]); | |
62 | argc -= 2; | |
63 | argv += 2; | |
64 | if (argc == 1) | |
65 | exit(EXIT_SUCCESS); | |
66 | } | |
67 | ||
68 | 68 | if (argc != 2) { |
69 | 69 | fprintf(stderr, _("usage: %s [-V] [-v] [-o map.orig] map-file\n"), |
70 | progname); | |
70 | progname); | |
71 | 71 | exit(EXIT_FAILURE); |
72 | 72 | } |
73 | 73 | loadnewmap(fd, argv[1]); |
89 | 89 | * Set lineno to line number of first error. |
90 | 90 | */ |
91 | 91 | static int |
92 | parsemap(FILE *fp, char *buf, unsigned short *ubuf, int *u, int *lineno) { | |
92 | parsemap(FILE *fp, char *buf, unsigned short *ubuf, int *u, int *lineno) | |
93 | { | |
93 | 94 | char buffer[256]; |
94 | 95 | int in, on, ln, ret = 0; |
95 | 96 | char *p, *q; |
96 | 97 | |
97 | 98 | ln = 0; |
98 | while (fgets(buffer,sizeof(buffer)-1,fp)) { | |
99 | while (fgets(buffer, sizeof(buffer) - 1, fp)) { | |
99 | 100 | ln++; |
100 | 101 | if (!*u && strstr(buffer, "U+")) |
101 | 102 | *u = 1; |
102 | p = strtok(buffer," \t\n"); | |
103 | p = strtok(buffer, " \t\n"); | |
103 | 104 | if (p && *p != '#') { |
104 | q = strtok(NULL," \t\n#"); | |
105 | q = strtok(NULL, " \t\n#"); | |
105 | 106 | if (q) { |
106 | 107 | in = ctoi(p); |
107 | 108 | on = ctoi(q); |
115 | 116 | } else { |
116 | 117 | if (!ret) |
117 | 118 | *lineno = ln; |
118 | ret = -1; | |
119 | ret = -1; | |
119 | 120 | } |
120 | 121 | } |
121 | 122 | } |
124 | 125 | } |
125 | 126 | |
126 | 127 | static int |
127 | readnewmapfromfile(char *mfil, char *buf, unsigned short *ubuf) { | |
128 | readnewmapfromfile(char *mfil, char *buf, unsigned short *ubuf) | |
129 | { | |
128 | 130 | struct stat stbuf; |
129 | int u = 0; | |
131 | int u = 0; | |
130 | 132 | int lineno = 0; |
131 | 133 | lkfile_t fp; |
132 | 134 | |
133 | 135 | if (lk_findfile(mfil, mapdirpath, mapsuffixes, &fp)) { |
134 | fprintf(stderr, _("mapscrn: cannot open map file _%s_\n"), | |
135 | mfil); | |
136 | fprintf(stderr, _("mapscrn: cannot open map file _%s_\n"), | |
137 | mfil); | |
136 | 138 | exit(1); |
137 | 139 | } |
138 | 140 | if (stat(fp.pathname, &stbuf)) { |
143 | 145 | if (stbuf.st_size == E_TABSZ) { |
144 | 146 | if (verbose) |
145 | 147 | printf(_("Loading binary direct-to-font screen map " |
146 | "from file %s\n"), | |
148 | "from file %s\n"), | |
147 | 149 | fp.pathname); |
148 | if (fread(buf,E_TABSZ,1,fp.fd) != 1) { | |
150 | if (fread(buf, E_TABSZ, 1, fp.fd) != 1) { | |
149 | 151 | fprintf(stderr, |
150 | _("Error reading map from file `%s'\n"), | |
151 | fp.pathname); | |
152 | exit(1); | |
153 | } | |
154 | } else if (stbuf.st_size == 2*E_TABSZ) { | |
152 | _("Error reading map from file `%s'\n"), | |
153 | fp.pathname); | |
154 | exit(1); | |
155 | } | |
156 | } else if (stbuf.st_size == 2 * E_TABSZ) { | |
155 | 157 | if (verbose) |
156 | 158 | printf(_("Loading binary unicode screen map " |
157 | "from file %s\n"), | |
159 | "from file %s\n"), | |
158 | 160 | fp.pathname); |
159 | if (fread(ubuf,2*E_TABSZ,1,fp.fd) != 1) { | |
161 | if (fread(ubuf, 2 * E_TABSZ, 1, fp.fd) != 1) { | |
160 | 162 | fprintf(stderr, |
161 | _("Error reading map from file `%s'\n"), | |
162 | fp.pathname); | |
163 | _("Error reading map from file `%s'\n"), | |
164 | fp.pathname); | |
163 | 165 | exit(1); |
164 | 166 | } |
165 | 167 | u = 1; |
166 | } else { | |
168 | } else { | |
167 | 169 | if (verbose) |
168 | 170 | printf(_("Loading symbolic screen map from file %s\n"), |
169 | 171 | fp.pathname); |
170 | if (parsemap(fp.fd,buf,ubuf,&u,&lineno)) { | |
172 | if (parsemap(fp.fd, buf, ubuf, &u, &lineno)) { | |
171 | 173 | fprintf(stderr, |
172 | _("Error parsing symbolic map " | |
173 | "from `%s', line %d\n"), | |
174 | fp.pathname, lineno); | |
174 | _("Error parsing symbolic map " | |
175 | "from `%s', line %d\n"), | |
176 | fp.pathname, lineno); | |
175 | 177 | exit(1); |
176 | 178 | } |
177 | 179 | } |
179 | 181 | return u; |
180 | 182 | } |
181 | 183 | |
182 | void | |
183 | loadnewmap(int fd, char *mfil) { | |
184 | void loadnewmap(int fd, char *mfil) | |
185 | { | |
184 | 186 | unsigned short ubuf[E_TABSZ]; |
185 | 187 | char buf[E_TABSZ]; |
186 | 188 | int i, u; |
187 | 189 | |
188 | 190 | /* default: trivial straight-to-font */ |
189 | for (i=0; i<E_TABSZ; i++) { | |
190 | buf[i] = i; | |
191 | for (i = 0; i < E_TABSZ; i++) { | |
192 | buf[i] = i; | |
191 | 193 | ubuf[i] = (0xf000 + i); |
192 | 194 | } |
193 | 195 | |
202 | 204 | exit(1); |
203 | 205 | } else { |
204 | 206 | /* no */ |
205 | if (loadscrnmap(fd,buf)) | |
207 | if (loadscrnmap(fd, buf)) | |
206 | 208 | exit(1); |
207 | 209 | } |
208 | 210 | } |
211 | 213 | * Read decimal, octal, hexadecimal, Unicode (U+xxxx) or character |
212 | 214 | * ('x', x a single byte or a utf8 sequence). |
213 | 215 | */ |
214 | int | |
215 | ctoi(char *s) { | |
216 | int ctoi(char *s) | |
217 | { | |
216 | 218 | int i; |
217 | 219 | |
218 | if ((strncmp(s,"0x",2) == 0) && | |
219 | (strspn(s+2,"0123456789abcdefABCDEF") == strlen(s+2))) | |
220 | (void)sscanf(s+2,"%x",&i); | |
220 | if ((strncmp(s, "0x", 2) == 0) && | |
221 | (strspn(s + 2, "0123456789abcdefABCDEF") == strlen(s + 2))) | |
222 | (void)sscanf(s + 2, "%x", &i); | |
221 | 223 | |
222 | 224 | else if ((*s == '0') && |
223 | (strspn(s,"01234567") == strlen(s))) | |
224 | (void)sscanf(s,"%o",&i); | |
225 | ||
226 | else if (strspn(s,"0123456789") == strlen(s)) | |
227 | (void)sscanf(s,"%d",&i); | |
228 | ||
229 | else if ((strncmp(s,"U+",2) == 0) && strlen(s) == 6 && | |
230 | (strspn(s+2,"0123456789abcdefABCDEF") == 4)) | |
231 | (void)sscanf(s+2,"%x",&i); | |
225 | (strspn(s, "01234567") == strlen(s))) | |
226 | (void)sscanf(s, "%o", &i); | |
227 | ||
228 | else if (strspn(s, "0123456789") == strlen(s)) | |
229 | (void)sscanf(s, "%d", &i); | |
230 | ||
231 | else if ((strncmp(s, "U+", 2) == 0) && strlen(s) == 6 && | |
232 | (strspn(s + 2, "0123456789abcdefABCDEF") == 4)) | |
233 | (void)sscanf(s + 2, "%x", &i); | |
232 | 234 | |
233 | 235 | else if ((strlen(s) == 3) && (s[0] == '\'') && (s[2] == '\'')) |
234 | i=s[1]; | |
236 | i = s[1]; | |
235 | 237 | |
236 | 238 | else if (s[0] == '\'') { |
237 | 239 | int err; |
238 | char *s1 = s+1; | |
240 | char *s1 = s + 1; | |
239 | 241 | |
240 | 242 | i = from_utf8(&s1, 0, &err); |
241 | 243 | if (err || s1[0] != '\'' || s1[1] != 0) |
242 | 244 | return -1; |
243 | 245 | } |
244 | 246 | |
245 | else return -1; | |
247 | else | |
248 | return -1; | |
246 | 249 | |
247 | 250 | return i; |
248 | 251 | } |
249 | 252 | |
250 | void | |
251 | saveoldmap(int fd, char *omfil) { | |
253 | void saveoldmap(int fd, char *omfil) | |
254 | { | |
252 | 255 | FILE *fp; |
253 | 256 | char buf[E_TABSZ]; |
254 | 257 | unsigned short ubuf[E_TABSZ]; |
259 | 262 | exit(1); |
260 | 263 | } |
261 | 264 | havemap = haveumap = 1; |
262 | if (getscrnmap(fd,buf)) | |
265 | if (getscrnmap(fd, buf)) | |
263 | 266 | havemap = 0; |
264 | if (getuniscrnmap(fd,ubuf)) | |
267 | if (getuniscrnmap(fd, ubuf)) | |
265 | 268 | haveumap = 0; |
266 | 269 | if (havemap && haveumap) { |
267 | 270 | for (i = 0; i < E_TABSZ; i++) { |
272 | 275 | } |
273 | 276 | } |
274 | 277 | if (havemap) { |
275 | if (fwrite(buf,sizeof(buf),1,fp) != 1) { | |
278 | if (fwrite(buf, sizeof(buf), 1, fp) != 1) { | |
276 | 279 | fprintf(stderr, _("Error writing map to file\n")); |
277 | 280 | exit(1); |
278 | 281 | } |
279 | 282 | } else if (haveumap) { |
280 | if (fwrite(ubuf,sizeof(ubuf),1,fp) != 1) { | |
283 | if (fwrite(ubuf, sizeof(ubuf), 1, fp) != 1) { | |
281 | 284 | fprintf(stderr, _("Error writing map to file\n")); |
282 | 285 | exit(1); |
283 | 286 | } |
2 | 2 | #endif |
3 | 3 | |
4 | 4 | #ifdef HAVE_LOCALE_H |
5 | # include <locale.h> | |
5 | #include <locale.h> | |
6 | 6 | #endif |
7 | 7 | |
8 | 8 | #ifdef ENABLE_NLS |
9 | # include <libintl.h> | |
10 | # define _(Text) gettext (Text) | |
11 | # ifdef gettext_noop | |
12 | # define N_(String) gettext_noop (String) | |
13 | # else | |
14 | # define N_(String) (String) | |
15 | # endif | |
16 | # define P_(singular, plural, number) ngettext(singular, plural, number) | |
9 | #include <libintl.h> | |
10 | #define _(Text) gettext(Text) | |
11 | #ifdef gettext_noop | |
12 | #define N_(String) gettext_noop(String) | |
17 | 13 | #else |
18 | # undef bindtextdomain | |
19 | # define bindtextdomain(Domain, Directory) /* empty */ | |
20 | # undef textdomain | |
21 | # define textdomain(Domain) /* empty */ | |
22 | # define _(Text) (Text) | |
23 | # define N_(Text) (Text) | |
24 | # define P_(singular, plural, number) (number == 1 ? singular : plural) | |
14 | #define N_(String) (String) | |
25 | 15 | #endif |
16 | #define P_(singular, plural, number) ngettext(singular, plural, number) | |
17 | #else | |
18 | #undef bindtextdomain | |
19 | #define bindtextdomain(Domain, Directory) /* empty */ | |
20 | #undef textdomain | |
21 | #define textdomain(Domain) /* empty */ | |
22 | #define _(Text) (Text) | |
23 | #define N_(Text) (Text) | |
24 | #define P_(singular, plural, number) (number == 1 ? singular : plural) | |
25 | #endif |
28 | 28 | #define FALSE (0) |
29 | 29 | |
30 | 30 | #ifdef ESIX_5_3_2_D |
31 | #define VTBASE "/dev/vt%02d" | |
31 | #define VTBASE "/dev/vt%02d" | |
32 | 32 | #endif |
33 | 33 | |
34 | 34 | // Where your VTs are hidden |
42 | 42 | #endif |
43 | 43 | |
44 | 44 | static void |
45 | __attribute__ ((noreturn)) | |
46 | print_help(int ret) | |
45 | __attribute__((noreturn)) | |
46 | print_help(int ret) | |
47 | 47 | { |
48 | 48 | printf(_("Usage: %s [OPTIONS] -- command\n" |
49 | "\n" | |
50 | "This utility help you to start a program on a new virtual terminal (VT).\n" | |
51 | "\n" | |
52 | "Options:\n" | |
53 | " -c, --console=NUM use the given VT number;\n" | |
54 | " -e, --exec execute the command, without forking;\n" | |
55 | " -f, --force force opening a VT without checking;\n" | |
56 | " -l, --login make the command a login shell;\n" | |
57 | " -u, --user figure out the owner of the current VT;\n" | |
58 | " -s, --switch switch to the new VT;\n" | |
59 | " -w, --wait wait for command to complete;\n" | |
60 | " -v, --verbose print a message for each action;\n" | |
61 | " -V, --version print program version and exit;\n" | |
62 | " -h, --help output a brief help message.\n" | |
63 | "\n"), progname); | |
49 | "\n" | |
50 | "This utility help you to start a program on a new virtual terminal (VT).\n" | |
51 | "\n" | |
52 | "Options:\n" | |
53 | " -c, --console=NUM use the given VT number;\n" | |
54 | " -e, --exec execute the command, without forking;\n" | |
55 | " -f, --force force opening a VT without checking;\n" | |
56 | " -l, --login make the command a login shell;\n" | |
57 | " -u, --user figure out the owner of the current VT;\n" | |
58 | " -s, --switch switch to the new VT;\n" | |
59 | " -w, --wait wait for command to complete;\n" | |
60 | " -v, --verbose print a message for each action;\n" | |
61 | " -V, --version print program version and exit;\n" | |
62 | " -h, --help output a brief help message.\n" | |
63 | "\n"), | |
64 | progname); | |
64 | 65 | exit(ret); |
65 | 66 | } |
66 | 67 | |
138 | 139 | |
139 | 140 | kbd_error(EXIT_FAILURE, 0, _("Couldn't find owner of current tty!")); |
140 | 141 | |
141 | got_a_process: | |
142 | got_a_process: | |
142 | 143 | closedir(dp); |
143 | 144 | |
144 | 145 | return pwnam->pw_name; |
160 | 161 | return fd; |
161 | 162 | } |
162 | 163 | |
163 | int | |
164 | main(int argc, char *argv[]) | |
164 | int main(int argc, char *argv[]) | |
165 | 165 | { |
166 | 166 | int opt, pid, i; |
167 | 167 | struct vt_stat vtstat; |
168 | int vtno = -1; | |
169 | int fd = -1; | |
170 | int consfd = -1; | |
171 | int force = 0; | |
172 | char optc = FALSE; | |
173 | char show = FALSE; | |
174 | char login = FALSE; | |
175 | char verbose = FALSE; | |
168 | int vtno = -1; | |
169 | int fd = -1; | |
170 | int consfd = -1; | |
171 | int force = 0; | |
172 | char optc = FALSE; | |
173 | char show = FALSE; | |
174 | char login = FALSE; | |
175 | char verbose = FALSE; | |
176 | 176 | char direct_exec = FALSE; |
177 | char do_wait = FALSE; | |
178 | char as_user = FALSE; | |
177 | char do_wait = FALSE; | |
178 | char as_user = FALSE; | |
179 | 179 | char vtname[sizeof(VTNAME) + 2]; /* allow 999 possible VTs */ |
180 | 180 | char *cmd = NULL, *def_cmd = NULL, *username = NULL; |
181 | 181 | |
182 | 182 | struct option long_options[] = { |
183 | { "help", no_argument, 0, 'h' }, | |
184 | { "version", no_argument, 0, 'V' }, | |
185 | { "verbose", no_argument, 0, 'v' }, | |
186 | { "exec", no_argument, 0, 'e' }, | |
187 | { "force", no_argument, 0, 'f' }, | |
188 | { "login", no_argument, 0, 'l' }, | |
189 | { "user", no_argument, 0, 'u' }, | |
190 | { "switch", no_argument, 0, 's' }, | |
191 | { "wait", no_argument, 0, 'w' }, | |
192 | { "console", required_argument, 0, 'c' }, | |
183 | { "help", no_argument, 0, 'h' }, | |
184 | { "version", no_argument, 0, 'V' }, | |
185 | { "verbose", no_argument, 0, 'v' }, | |
186 | { "exec", no_argument, 0, 'e' }, | |
187 | { "force", no_argument, 0, 'f' }, | |
188 | { "login", no_argument, 0, 'l' }, | |
189 | { "user", no_argument, 0, 'u' }, | |
190 | { "switch", no_argument, 0, 's' }, | |
191 | { "wait", no_argument, 0, 'w' }, | |
192 | { "console", required_argument, 0, 'c' }, | |
193 | 193 | { 0, 0, 0, 0 } |
194 | 194 | }; |
195 | 195 | |
202 | 202 | while ((opt = getopt_long(argc, argv, "c:lsfuewhvV", long_options, NULL)) != -1) { |
203 | 203 | switch (opt) { |
204 | 204 | case 'c': |
205 | optc = 1; /* vtno was specified by the user */ | |
205 | optc = 1; /* vtno was specified by the user */ | |
206 | 206 | vtno = (int)atol(optarg); |
207 | 207 | |
208 | 208 | if (vtno <= 0 || vtno > 63) |
266 | 266 | } else if (!force) { |
267 | 267 | if (vtno >= 16) |
268 | 268 | kbd_error(7, 0, _("Cannot check whether vt %d is free; use `%s -f' to force."), |
269 | vtno, progname); | |
269 | vtno, progname); | |
270 | 270 | |
271 | 271 | if (vtstat.v_state & (1 << vtno)) |
272 | 272 | kbd_error(7, 0, _("vt %d is in use; command aborted; use `%s -f' to force."), |
273 | vtno, progname); | |
273 | vtno, progname); | |
274 | 274 | } |
275 | 275 | |
276 | 276 | if (as_user) |
302 | 302 | if (direct_exec || ((pid = fork()) == 0)) { |
303 | 303 | /* leave current vt */ |
304 | 304 | if (!direct_exec) { |
305 | #ifdef ESIX_5_3_2_D | |
305 | #ifdef ESIX_5_3_2_D | |
306 | 306 | #ifdef HAVE_SETPGRP |
307 | 307 | if (setpgrp() < 0) |
308 | 308 | #else |
309 | 309 | if (1) |
310 | #endif /* HAVE_SETPGRP */ | |
310 | #endif /* HAVE_SETPGRP */ | |
311 | 311 | #else |
312 | 312 | if (setsid() < 0) |
313 | #endif /* ESIX_5_3_2_D */ | |
313 | #endif /* ESIX_5_3_2_D */ | |
314 | 314 | kbd_error(5, errno, _("Unable to set new session")); |
315 | 315 | } |
316 | 316 | |
337 | 337 | } |
338 | 338 | kbd_error(5, errsv, _("Unable to open %s"), vtname); |
339 | 339 | } |
340 | got_vtno: | |
340 | got_vtno: | |
341 | 341 | if (verbose) |
342 | 342 | kbd_warning(0, _("Using VT %s"), vtname); |
343 | 343 | |
390 | 390 | wait(NULL); |
391 | 391 | waitpid(pid, &retval, 0); |
392 | 392 | |
393 | if (show) { /* Switch back... */ | |
393 | if (show) { /* Switch back... */ | |
394 | 394 | if (ioctl(consfd, VT_ACTIVATE, vtstat.v_active)) |
395 | 395 | kbd_error(8, errno, "ioctl(VT_ACTIVATE)"); |
396 | 396 | |
404 | 404 | |
405 | 405 | /* if all our stuff went right, we want to return the exit code of the command we ran |
406 | 406 | super vital for scripting loops etc */ |
407 | return(retval); | |
407 | return (retval); | |
408 | 408 | } |
409 | 409 | |
410 | 410 | return EXIT_SUCCESS; |
2 | 2 | #include "config.h" |
3 | 3 | |
4 | 4 | #include <stdio.h> |
5 | #include <stdlib.h> /* exit */ | |
5 | #include <stdlib.h> /* exit */ | |
6 | 6 | #include "kbd.h" |
7 | 7 | #include "psf.h" |
8 | 8 | |
9 | static void __attribute__ ((noreturn)) | |
10 | usage(void) { | |
9 | static void __attribute__((noreturn)) | |
10 | usage(void) | |
11 | { | |
11 | 12 | fprintf(stderr, "call: outpsfheader psftype fontsize charsize hastable\n"); |
12 | 13 | exit(1); |
13 | 14 | } |
14 | 15 | |
15 | int | |
16 | main(int argc, char **argv){ | |
16 | int main(int argc, char **argv) | |
17 | { | |
17 | 18 | int psftype, fontsize, charsize, hastable; |
18 | 19 | |
19 | 20 | if (argc != 5) |
20 | 21 | usage(); |
21 | psftype = atoi(argv[1]); | |
22 | psftype = atoi(argv[1]); | |
22 | 23 | fontsize = atoi(argv[2]); |
23 | 24 | charsize = atoi(argv[3]); |
24 | 25 | hastable = atoi(argv[4]); |
30 | 31 | usage(); |
31 | 32 | h1.magic[0] = PSF1_MAGIC0; |
32 | 33 | h1.magic[1] = PSF1_MAGIC1; |
33 | h1.mode = (fontsize == 256) ? 0 : PSF1_MODE512; | |
34 | h1.mode = (fontsize == 256) ? 0 : PSF1_MODE512; | |
34 | 35 | if (hastable) |
35 | 36 | h1.mode |= PSF1_MODEHASTAB; |
36 | 37 | h1.charsize = charsize; |
41 | 42 | } else if (psftype == 2) { |
42 | 43 | struct psf2_header h2; |
43 | 44 | |
44 | h2.magic[0] = PSF2_MAGIC0; | |
45 | h2.magic[1] = PSF2_MAGIC1; | |
46 | h2.magic[2] = PSF2_MAGIC2; | |
47 | h2.magic[3] = PSF2_MAGIC3; | |
48 | h2.version = 0; | |
45 | h2.magic[0] = PSF2_MAGIC0; | |
46 | h2.magic[1] = PSF2_MAGIC1; | |
47 | h2.magic[2] = PSF2_MAGIC2; | |
48 | h2.magic[3] = PSF2_MAGIC3; | |
49 | h2.version = 0; | |
49 | 50 | h2.headersize = sizeof(h2); |
50 | h2.flags = (hastable ? PSF2_HAS_UNICODE_TABLE : 0); | |
51 | h2.length = fontsize; | |
52 | h2.charsize = charsize; | |
53 | h2.width = 8; | |
54 | h2.height = charsize; | |
51 | h2.flags = (hastable ? PSF2_HAS_UNICODE_TABLE : 0); | |
52 | h2.length = fontsize; | |
53 | h2.charsize = charsize; | |
54 | h2.width = 8; | |
55 | h2.height = charsize; | |
55 | 56 | if (fwrite(&h2, sizeof(h2), 1, stdout) != 1) { |
56 | 57 | fprintf(stderr, "write error\n"); |
57 | 58 | exit(1); |
17 | 17 | * Default keymap, and where the kernel copy of it lives. |
18 | 18 | */ |
19 | 19 | #ifdef __sparc__ |
20 | # define DEFMAP "sunkeymap.map" | |
21 | # define KERNDIR "/usr/src/linux/drivers/sbus/char" | |
20 | #define DEFMAP "sunkeymap.map" | |
21 | #define KERNDIR "/usr/src/linux/drivers/sbus/char" | |
22 | 22 | #else |
23 | # define DEFMAP "defkeymap.map" | |
24 | # define KERNDIR "/usr/src/linux/drivers/tty/vt" | |
23 | #define DEFMAP "defkeymap.map" | |
24 | #define KERNDIR "/usr/src/linux/drivers/tty/vt" | |
25 | 25 | #endif |
26 | 26 | |
27 | 27 | extern int verbose; |
34 | 34 | #ifndef _PSF_H |
35 | 35 | #define _PSF_H |
36 | 36 | |
37 | #define PSF1_MAGIC0 0x36 | |
38 | #define PSF1_MAGIC1 0x04 | |
37 | 39 | |
38 | #define PSF1_MAGIC0 0x36 | |
39 | #define PSF1_MAGIC1 0x04 | |
40 | ||
41 | #define PSF1_MODE512 0x01 | |
40 | #define PSF1_MODE512 0x01 | |
42 | 41 | #define PSF1_MODEHASTAB 0x02 |
43 | 42 | #define PSF1_MODEHASSEQ 0x04 |
44 | #define PSF1_MAXMODE 0x05 | |
43 | #define PSF1_MAXMODE 0x05 | |
45 | 44 | |
46 | #define PSF1_SEPARATOR 0xFFFF | |
47 | #define PSF1_STARTSEQ 0xFFFE | |
45 | #define PSF1_SEPARATOR 0xFFFF | |
46 | #define PSF1_STARTSEQ 0xFFFE | |
48 | 47 | |
49 | 48 | struct psf1_header { |
50 | unsigned char magic[2]; /* Magic number */ | |
51 | unsigned char mode; /* PSF font mode */ | |
52 | unsigned char charsize; /* Character size */ | |
49 | unsigned char magic[2]; /* Magic number */ | |
50 | unsigned char mode; /* PSF font mode */ | |
51 | unsigned char charsize; /* Character size */ | |
53 | 52 | }; |
54 | 53 | |
55 | 54 | /* |
64 | 63 | * The integers here are little endian 4-byte integers. |
65 | 64 | */ |
66 | 65 | |
67 | #define PSF2_MAGIC0 0x72 | |
68 | #define PSF2_MAGIC1 0xb5 | |
69 | #define PSF2_MAGIC2 0x4a | |
70 | #define PSF2_MAGIC3 0x86 | |
66 | #define PSF2_MAGIC0 0x72 | |
67 | #define PSF2_MAGIC1 0xb5 | |
68 | #define PSF2_MAGIC2 0x4a | |
69 | #define PSF2_MAGIC3 0x86 | |
71 | 70 | |
72 | 71 | struct psf2_header { |
73 | 72 | unsigned char magic[4]; |
74 | 73 | unsigned int version; |
75 | unsigned int headersize; /* offset of bitmaps in file */ | |
74 | unsigned int headersize; /* offset of bitmaps in file */ | |
76 | 75 | unsigned int flags; |
77 | unsigned int length; /* number of glyphs */ | |
78 | unsigned int charsize; /* number of bytes for each character */ | |
76 | unsigned int length; /* number of glyphs */ | |
77 | unsigned int charsize; /* number of bytes for each character */ | |
79 | 78 | unsigned int height, width; /* max dimensions of glyphs */ |
80 | /* charsize = height * ((width + 7) / 8) */ | |
79 | /* charsize = height * ((width + 7) / 8) */ | |
81 | 80 | }; |
82 | 81 | |
83 | 82 | /* bits used in flags */ |
84 | 83 | #define PSF2_HAS_UNICODE_TABLE 0x01 |
85 | 84 | |
86 | 85 | /* max version recognized so far */ |
87 | #define PSF2_MAXVERSION 0 | |
86 | #define PSF2_MAXVERSION 0 | |
88 | 87 | |
89 | 88 | /* UTF8 separators */ |
90 | #define PSF2_SEPARATOR 0xFF | |
91 | #define PSF2_STARTSEQ 0xFE | |
89 | #define PSF2_SEPARATOR 0xFF | |
90 | #define PSF2_STARTSEQ 0xFE | |
92 | 91 | |
92 | #define PSF1_MAGIC_OK(x) ((x)[0] == PSF1_MAGIC0 && (x)[1] == PSF1_MAGIC1) | |
93 | #define PSF2_MAGIC_OK(x) ((x)[0] == PSF2_MAGIC0 && (x)[1] == PSF2_MAGIC1 && (x)[2] == PSF2_MAGIC2 && (x)[3] == PSF2_MAGIC3) | |
93 | 94 | |
94 | #define PSF1_MAGIC_OK(x) ((x)[0]==PSF1_MAGIC0 && (x)[1]==PSF1_MAGIC1) | |
95 | #define PSF2_MAGIC_OK(x) ((x)[0]==PSF2_MAGIC0 && (x)[1]==PSF2_MAGIC1 \ | |
96 | && (x)[2]==PSF2_MAGIC2 && (x)[3]==PSF2_MAGIC3) | |
97 | ||
98 | ||
99 | #endif /* _PSF_H */ | |
95 | #endif /* _PSF_H */ |
16 | 16 | extern char *progname; |
17 | 17 | |
18 | 18 | static void |
19 | addpair(struct unicode_list *up, unsigned int uc) { | |
19 | addpair(struct unicode_list *up, unsigned int uc) | |
20 | { | |
20 | 21 | struct unicode_list *ul; |
21 | 22 | struct unicode_seq *us; |
22 | 23 | |
23 | ul = xmalloc(sizeof(struct unicode_list)); | |
24 | us = xmalloc(sizeof(struct unicode_seq)); | |
25 | us->uc = uc; | |
26 | us->prev = us; | |
27 | us->next = NULL; | |
28 | ul->seq = us; | |
29 | ul->prev = up->prev; | |
24 | ul = xmalloc(sizeof(struct unicode_list)); | |
25 | us = xmalloc(sizeof(struct unicode_seq)); | |
26 | us->uc = uc; | |
27 | us->prev = us; | |
28 | us->next = NULL; | |
29 | ul->seq = us; | |
30 | ul->prev = up->prev; | |
30 | 31 | ul->prev->next = ul; |
31 | ul->next = NULL; | |
32 | up->prev = ul; | |
32 | ul->next = NULL; | |
33 | up->prev = ul; | |
33 | 34 | } |
34 | 35 | |
35 | 36 | static void |
36 | addseq(struct unicode_list *up, unsigned int uc) { | |
37 | addseq(struct unicode_list *up, unsigned int uc) | |
38 | { | |
37 | 39 | struct unicode_seq *us; |
38 | 40 | struct unicode_seq *usl; |
39 | 41 | struct unicode_list *ul = up->prev; |
40 | 42 | |
41 | 43 | usl = ul->seq; |
42 | while (usl->next) usl = usl->next; | |
43 | us = xmalloc(sizeof(struct unicode_seq)); | |
44 | us->uc = uc; | |
45 | us->prev = usl; | |
46 | us->next = NULL; | |
47 | usl->next = us; | |
44 | while (usl->next) | |
45 | usl = usl->next; | |
46 | us = xmalloc(sizeof(struct unicode_seq)); | |
47 | us->uc = uc; | |
48 | us->prev = usl; | |
49 | us->next = NULL; | |
50 | usl->next = us; | |
48 | 51 | //ul->seq->prev = us; |
49 | 52 | } |
50 | 53 | |
51 | 54 | static unsigned int |
52 | assemble_int(unsigned char *ip) { | |
53 | return (ip[0] + (ip[1]<<8) + (ip[2]<<16) + (ip[3]<<24)); | |
55 | assemble_int(unsigned char *ip) | |
56 | { | |
57 | return (ip[0] + (ip[1] << 8) + (ip[2] << 16) + (ip[3] << 24)); | |
54 | 58 | } |
55 | 59 | |
56 | 60 | static void |
57 | store_int_le(unsigned char *ip, int num) { | |
61 | store_int_le(unsigned char *ip, int num) | |
62 | { | |
58 | 63 | ip[0] = (num & 0xff); |
59 | 64 | ip[1] = ((num >> 8) & 0xff); |
60 | 65 | ip[2] = ((num >> 16) & 0xff); |
62 | 67 | } |
63 | 68 | |
64 | 69 | static unsigned int |
65 | assemble_ucs2(char **inptr, int cnt) { | |
70 | assemble_ucs2(char **inptr, int cnt) | |
71 | { | |
66 | 72 | unsigned int u1, u2; |
67 | 73 | |
68 | 74 | if (cnt < 2) { |
71 | 77 | exit(EX_DATAERR); |
72 | 78 | } |
73 | 79 | |
74 | u1 = (unsigned char) *(*inptr)++; | |
75 | u2 = (unsigned char) *(*inptr)++; | |
80 | u1 = (unsigned char)*(*inptr)++; | |
81 | u2 = (unsigned char)*(*inptr)++; | |
76 | 82 | return (u1 | (u2 << 8)); |
77 | 83 | } |
78 | 84 | |
79 | 85 | /* called with cnt > 0 and **inptr not 0xff or 0xfe */ |
80 | 86 | static unsigned int |
81 | assemble_utf8(char **inptr, int cnt) { | |
87 | assemble_utf8(char **inptr, int cnt) | |
88 | { | |
82 | 89 | int err; |
83 | 90 | unsigned long uc; |
84 | 91 | char *u; |
86 | 93 | uc = from_utf8(inptr, cnt, &err); |
87 | 94 | if (err) { |
88 | 95 | switch (err) { |
89 | case UTF8_SHORT: | |
90 | u = _("%s: short utf8 unicode table\n"); | |
91 | break; | |
92 | case UTF8_BAD: | |
93 | u = _("%s: bad utf8\n"); | |
94 | break; | |
95 | default: | |
96 | u = _("%s: unknown utf8 error\n"); | |
96 | case UTF8_SHORT: | |
97 | u = _("%s: short utf8 unicode table\n"); | |
98 | break; | |
99 | case UTF8_BAD: | |
100 | u = _("%s: bad utf8\n"); | |
101 | break; | |
102 | default: | |
103 | u = _("%s: unknown utf8 error\n"); | |
97 | 104 | } |
98 | 105 | fprintf(stderr, u, progname); |
99 | 106 | exit(EX_DATAERR); |
102 | 109 | } |
103 | 110 | |
104 | 111 | static void |
105 | clear_uni_entry(struct unicode_list *up) { | |
112 | clear_uni_entry(struct unicode_list *up) | |
113 | { | |
106 | 114 | up->next = NULL; |
107 | up->seq = NULL; | |
115 | up->seq = NULL; | |
108 | 116 | up->prev = up; |
109 | } | |
117 | } | |
110 | 118 | |
111 | 119 | /* |
112 | 120 | * Read description of a single font position. |
113 | 121 | */ |
114 | 122 | static void |
115 | get_uni_entry(char **inptr, char **endptr, struct unicode_list *up, int utf8) { | |
123 | get_uni_entry(char **inptr, char **endptr, struct unicode_list *up, int utf8) | |
124 | { | |
116 | 125 | unsigned char uc; |
117 | 126 | unicode unichar; |
118 | 127 | int inseq = 0; |
119 | 128 | |
120 | 129 | up->next = NULL; |
121 | up->seq = NULL; | |
130 | up->seq = NULL; | |
122 | 131 | up->prev = up; |
123 | 132 | |
124 | while(1) { | |
133 | while (1) { | |
125 | 134 | if (*endptr == *inptr) { |
126 | 135 | char *u = _("%s: short unicode table\n"); |
127 | 136 | fprintf(stderr, u, progname); |
176 | 185 | */ |
177 | 186 | extern char *progname; |
178 | 187 | |
179 | int | |
180 | readpsffont(FILE *fontf, char **allbufp, int *allszp, | |
181 | char **fontbufp, int *fontszp, | |
182 | int *fontwidthp, int *fontlenp, int fontpos0, | |
183 | struct unicode_list **uclistheadsp) { | |
184 | char *inputbuf = NULL; | |
188 | int readpsffont(FILE *fontf, char **allbufp, int *allszp, | |
189 | char **fontbufp, int *fontszp, | |
190 | int *fontwidthp, int *fontlenp, int fontpos0, | |
191 | struct unicode_list **uclistheadsp) | |
192 | { | |
193 | char *inputbuf = NULL; | |
185 | 194 | size_t inputbuflth = 0; |
186 | 195 | size_t inputlth, fontlen, fontwidth, charsize, hastable, ftoffset, utf8; |
187 | 196 | size_t i, k, n; |
192 | 201 | * just read the entire file. |
193 | 202 | */ |
194 | 203 | if (fontf) { |
195 | inputbuflth = MAXFONTSIZE/4; /* random */ | |
196 | inputbuf = xmalloc(inputbuflth); | |
197 | n = 0; | |
198 | ||
199 | while(1) { | |
204 | inputbuflth = MAXFONTSIZE / 4; /* random */ | |
205 | inputbuf = xmalloc(inputbuflth); | |
206 | n = 0; | |
207 | ||
208 | while (1) { | |
200 | 209 | if (n >= inputbuflth) { |
201 | 210 | inputbuflth *= 2; |
202 | 211 | inputbuf = xrealloc(inputbuf, inputbuflth); |
203 | 212 | } |
204 | n += fread(inputbuf+n, 1, inputbuflth-n, fontf); | |
213 | n += fread(inputbuf + n, 1, inputbuflth - n, fontf); | |
205 | 214 | if (ferror(fontf)) { |
206 | 215 | char *u = _("%s: Error reading input font"); |
207 | 216 | fprintf(stderr, u, progname); |
214 | 223 | *allbufp = inputbuf; |
215 | 224 | if (allszp) |
216 | 225 | *allszp = n; |
217 | inputlth = n; | |
226 | inputlth = n; | |
218 | 227 | } else { |
219 | 228 | if (!allbufp || !allszp) { |
220 | 229 | char *u = _("%s: Bad call of readpsffont\n"); |
221 | 230 | fprintf(stderr, u, progname); |
222 | 231 | exit(EX_SOFTWARE); |
223 | 232 | } |
224 | inputbuf = *allbufp; | |
233 | inputbuf = *allbufp; | |
225 | 234 | inputbuflth = inputlth = n = *allszp; |
226 | 235 | } |
227 | 236 | |
229 | 238 | PSF1_MAGIC_OK((unsigned char *)inputbuf)) { |
230 | 239 | struct psf1_header *psfhdr; |
231 | 240 | |
232 | psfhdr = (struct psf1_header *) &inputbuf[0]; | |
241 | psfhdr = (struct psf1_header *)&inputbuf[0]; | |
233 | 242 | |
234 | 243 | if (psfhdr->mode > PSF1_MAXMODE) { |
235 | 244 | char *u = _("%s: Unsupported psf file mode (%d)\n"); |
236 | 245 | fprintf(stderr, u, progname, psfhdr->mode); |
237 | 246 | exit(EX_DATAERR); |
238 | 247 | } |
239 | fontlen = ((psfhdr->mode & PSF1_MODE512) ? 512 : 256); | |
240 | charsize = psfhdr->charsize; | |
241 | hastable = (psfhdr->mode & (PSF1_MODEHASTAB|PSF1_MODEHASSEQ)); | |
242 | ftoffset = sizeof(struct psf1_header); | |
248 | fontlen = ((psfhdr->mode & PSF1_MODE512) ? 512 : 256); | |
249 | charsize = psfhdr->charsize; | |
250 | hastable = (psfhdr->mode & (PSF1_MODEHASTAB | PSF1_MODEHASSEQ)); | |
251 | ftoffset = sizeof(struct psf1_header); | |
243 | 252 | fontwidth = 8; |
244 | utf8 = 0; | |
253 | utf8 = 0; | |
245 | 254 | } else if (inputlth >= sizeof(struct psf2_header) && |
246 | PSF2_MAGIC_OK((unsigned char *)inputbuf)) { | |
255 | PSF2_MAGIC_OK((unsigned char *)inputbuf)) { | |
247 | 256 | struct psf2_header psfhdr; |
248 | 257 | int flags; |
249 | 258 | |
254 | 263 | fprintf(stderr, u, progname, psfhdr.version); |
255 | 264 | exit(EX_DATAERR); |
256 | 265 | } |
257 | fontlen = assemble_int((unsigned char *) &psfhdr.length); | |
258 | charsize = assemble_int((unsigned char *) &psfhdr.charsize); | |
259 | flags = assemble_int((unsigned char *) &psfhdr.flags); | |
260 | hastable = (flags & PSF2_HAS_UNICODE_TABLE); | |
261 | ftoffset = assemble_int((unsigned char *) &psfhdr.headersize); | |
262 | fontwidth = assemble_int((unsigned char *) &psfhdr.width); | |
263 | utf8 = 1; | |
266 | fontlen = assemble_int((unsigned char *)&psfhdr.length); | |
267 | charsize = assemble_int((unsigned char *)&psfhdr.charsize); | |
268 | flags = assemble_int((unsigned char *)&psfhdr.flags); | |
269 | hastable = (flags & PSF2_HAS_UNICODE_TABLE); | |
270 | ftoffset = assemble_int((unsigned char *)&psfhdr.headersize); | |
271 | fontwidth = assemble_int((unsigned char *)&psfhdr.width); | |
272 | utf8 = 1; | |
264 | 273 | } else |
265 | return -1; /* not psf */ | |
274 | return -1; /* not psf */ | |
266 | 275 | |
267 | 276 | /* tests required - we divide by these */ |
268 | 277 | if (fontlen == 0) { |
292 | 301 | *fontwidthp = fontwidth; |
293 | 302 | |
294 | 303 | if (!uclistheadsp) |
295 | return 0; /* got font, don't need unicode_list */ | |
304 | return 0; /* got font, don't need unicode_list */ | |
296 | 305 | |
297 | 306 | *uclistheadsp = xrealloc(*uclistheadsp, |
298 | (fontpos0+fontlen)*sizeof(struct unicode_list)); | |
307 | (fontpos0 + fontlen) * sizeof(struct unicode_list)); | |
299 | 308 | |
300 | 309 | if (hastable) { |
301 | 310 | char *inptr, *endptr; |
302 | 311 | |
303 | inptr = inputbuf + ftoffset + fontlen * charsize; | |
312 | inptr = inputbuf + ftoffset + fontlen * charsize; | |
304 | 313 | endptr = inputbuf + inputlth; |
305 | 314 | |
306 | for (i=0; i<fontlen; i++) { | |
315 | for (i = 0; i < fontlen; i++) { | |
307 | 316 | k = fontpos0 + i; |
308 | 317 | get_uni_entry(&inptr, &endptr, |
309 | &(*uclistheadsp)[k], utf8); | |
318 | &(*uclistheadsp)[k], utf8); | |
310 | 319 | } |
311 | 320 | if (inptr != endptr) { |
312 | 321 | char *u = _("%s: Input file: trailing garbage\n"); |
314 | 323 | exit(EX_DATAERR); |
315 | 324 | } |
316 | 325 | } else { |
317 | for (i=0; i<fontlen; i++) { | |
326 | for (i = 0; i < fontlen; i++) { | |
318 | 327 | k = fontpos0 + i; |
319 | 328 | clear_uni_entry(&(*uclistheadsp)[k]); |
320 | 329 | } |
321 | 330 | } |
322 | 331 | |
323 | return 0; /* got psf font */ | |
332 | return 0; /* got psf font */ | |
324 | 333 | } |
325 | 334 | |
326 | 335 | static int |
327 | has_sequences(struct unicode_list *uclistheads, int fontlen) { | |
336 | has_sequences(struct unicode_list *uclistheads, int fontlen) | |
337 | { | |
328 | 338 | struct unicode_list *ul; |
329 | 339 | struct unicode_seq *us; |
330 | 340 | int i; |
331 | 341 | |
332 | for (i=0; i<fontlen; i++) { | |
342 | for (i = 0; i < fontlen; i++) { | |
333 | 343 | ul = uclistheads[i].next; |
334 | while(ul) { | |
344 | while (ul) { | |
335 | 345 | us = ul->seq; |
336 | 346 | if (us && us->next) |
337 | 347 | return 1; |
341 | 351 | return 0; |
342 | 352 | } |
343 | 353 | |
344 | void | |
345 | appendunicode(FILE *fp, unsigned int uc, int utf8) { | |
354 | void appendunicode(FILE *fp, unsigned int uc, int utf8) | |
355 | { | |
346 | 356 | int n = 6; |
347 | 357 | unsigned char out[6]; |
348 | 358 | |
364 | 374 | } |
365 | 375 | out[--n] = ((uc + ~mask + ~mask) & 0xff); |
366 | 376 | } |
367 | if (fwrite(out+n, 6-n, 1, fp) != 1) { | |
377 | if (fwrite(out + n, 6 - n, 1, fp) != 1) { | |
368 | 378 | perror("appendunimap"); |
369 | 379 | exit(1); |
370 | 380 | } |
371 | 381 | if (debug) { |
372 | printf ("("); | |
382 | printf("("); | |
373 | 383 | if (!utf8) |
374 | printf ("U+"); | |
375 | while (n < 6) printf ("%02x ", out[n++]); | |
376 | printf (")"); | |
377 | } | |
378 | } | |
379 | ||
380 | void | |
381 | appendseparator(FILE *fp, int seq, int utf8) { | |
384 | printf("U+"); | |
385 | while (n < 6) | |
386 | printf("%02x ", out[n++]); | |
387 | printf(")"); | |
388 | } | |
389 | } | |
390 | ||
391 | void appendseparator(FILE *fp, int seq, int utf8) | |
392 | { | |
382 | 393 | int n; |
383 | 394 | |
384 | 395 | if (utf8) { |
385 | 396 | unsigned char u = (seq ? PSF2_STARTSEQ : PSF2_SEPARATOR); |
386 | n = fwrite(&u, sizeof(u), 1, fp); | |
397 | n = fwrite(&u, sizeof(u), 1, fp); | |
387 | 398 | } else { |
388 | 399 | unsigned short u = (seq ? PSF1_STARTSEQ : PSF1_SEPARATOR); |
389 | n = fwrite(&u, sizeof(u), 1, fp); | |
400 | n = fwrite(&u, sizeof(u), 1, fp); | |
390 | 401 | } |
391 | 402 | if (n != 1) { |
392 | 403 | perror("appendseparator"); |
394 | 405 | } |
395 | 406 | } |
396 | 407 | |
397 | void | |
398 | writepsffontheader(FILE *ofil, int width, int height, int fontlen, | |
399 | int *psftype, int flags) { | |
408 | void writepsffontheader(FILE *ofil, int width, int height, int fontlen, | |
409 | int *psftype, int flags) | |
410 | { | |
400 | 411 | int bytewidth, charsize, ret; |
401 | 412 | |
402 | bytewidth = (width+7)/8; | |
403 | charsize = bytewidth * height; | |
413 | bytewidth = (width + 7) / 8; | |
414 | charsize = bytewidth * height; | |
404 | 415 | |
405 | 416 | if ((fontlen != 256 && fontlen != 512) || width != 8) |
406 | 417 | *psftype = 2; |
415 | 426 | h.magic[1] = PSF2_MAGIC1; |
416 | 427 | h.magic[2] = PSF2_MAGIC2; |
417 | 428 | h.magic[3] = PSF2_MAGIC3; |
418 | store_int_le((unsigned char *) &h.version, 0); | |
419 | store_int_le((unsigned char *) &h.headersize, sizeof(h)); | |
420 | store_int_le((unsigned char *) &h.flags, flags2); | |
421 | store_int_le((unsigned char *) &h.length, fontlen); | |
422 | store_int_le((unsigned char *) &h.charsize, charsize); | |
423 | store_int_le((unsigned char *) &h.width, width); | |
424 | store_int_le((unsigned char *) &h.height, height); | |
429 | store_int_le((unsigned char *)&h.version, 0); | |
430 | store_int_le((unsigned char *)&h.headersize, sizeof(h)); | |
431 | store_int_le((unsigned char *)&h.flags, flags2); | |
432 | store_int_le((unsigned char *)&h.length, fontlen); | |
433 | store_int_le((unsigned char *)&h.charsize, charsize); | |
434 | store_int_le((unsigned char *)&h.width, width); | |
435 | store_int_le((unsigned char *)&h.height, height); | |
425 | 436 | ret = fwrite(&h, sizeof(h), 1, ofil); |
426 | 437 | } else { |
427 | 438 | struct psf1_header h; |
428 | 439 | |
429 | 440 | h.magic[0] = PSF1_MAGIC0; |
430 | 441 | h.magic[1] = PSF1_MAGIC1; |
431 | h.mode = 0; | |
442 | h.mode = 0; | |
432 | 443 | if (fontlen == 512) |
433 | 444 | h.mode |= PSF1_MODE512; |
434 | 445 | if (flags & WPSFH_HASSEQ) |
436 | 447 | else if (flags & WPSFH_HASTAB) |
437 | 448 | h.mode |= PSF1_MODEHASTAB; |
438 | 449 | h.charsize = charsize; |
439 | ret = fwrite(&h, sizeof(h), 1, ofil); | |
450 | ret = fwrite(&h, sizeof(h), 1, ofil); | |
440 | 451 | } |
441 | 452 | |
442 | 453 | if (ret != 1) { |
445 | 456 | } |
446 | 457 | } |
447 | 458 | |
448 | ||
449 | int | |
450 | writepsffont(FILE *ofil, char *fontbuf, int width, int height, size_t fontlen, | |
451 | int psftype, struct unicode_list *uclistheads) { | |
459 | int writepsffont(FILE *ofil, char *fontbuf, int width, int height, size_t fontlen, | |
460 | int psftype, struct unicode_list *uclistheads) | |
461 | { | |
452 | 462 | int bytewidth, charsize, flags, utf8; |
453 | 463 | size_t i; |
454 | 464 | |
455 | bytewidth = (width+7)/8; | |
456 | charsize = bytewidth * height; | |
457 | flags = 0; | |
465 | bytewidth = (width + 7) / 8; | |
466 | charsize = bytewidth * height; | |
467 | flags = 0; | |
458 | 468 | |
459 | 469 | if (uclistheads) { |
460 | 470 | flags |= WPSFH_HASTAB; |
471 | 481 | } |
472 | 482 | |
473 | 483 | /* unimaps: -1 => do nothing: caller will append map */ |
474 | if (uclistheads != NULL && uclistheads != (struct unicode_list*)-1) { | |
484 | if (uclistheads != NULL && uclistheads != (struct unicode_list *)-1) { | |
475 | 485 | struct unicode_list *ul; |
476 | 486 | struct unicode_seq *us; |
477 | 487 | |
478 | for (i=0; i<fontlen; i++) { | |
488 | for (i = 0; i < fontlen; i++) { | |
479 | 489 | ul = uclistheads[i].next; |
480 | while(ul) { | |
490 | while (ul) { | |
481 | 491 | us = ul->seq; |
482 | 492 | if (us && us->next) |
483 | 493 | appendseparator(ofil, 1, utf8); |
484 | while(us) { | |
494 | while (us) { | |
485 | 495 | appendunicode(ofil, us->uc, utf8); |
486 | 496 | us = us->next; |
487 | 497 | } |
492 | 502 | } |
493 | 503 | return utf8; |
494 | 504 | } |
495 |
20 | 20 | }; |
21 | 21 | |
22 | 22 | extern int readpsffont(FILE *fontf, char **allbufp, int *allszp, |
23 | char **fontbufp, int *fontszp, | |
24 | int *fontwidthp, int *fontlenp, int fontpos0, | |
25 | struct unicode_list **uclistheadsp); | |
23 | char **fontbufp, int *fontszp, | |
24 | int *fontwidthp, int *fontlenp, int fontpos0, | |
25 | struct unicode_list **uclistheadsp); | |
26 | 26 | |
27 | 27 | extern int writepsffont(FILE *ofil, char *fontbuf, |
28 | int width, int height, size_t fontlen, int psftype, | |
29 | struct unicode_list *uclistheads); | |
28 | int width, int height, size_t fontlen, int psftype, | |
29 | struct unicode_list *uclistheads); | |
30 | 30 | |
31 | #define WPSFH_HASTAB 1 | |
32 | #define WPSFH_HASSEQ 2 | |
33 | extern void writepsffontheader(FILE *ofil, | |
34 | int width, int height, int fontlen, | |
35 | int *psftype, int flags); | |
31 | #define WPSFH_HASTAB 1 | |
32 | #define WPSFH_HASSEQ 2 | |
33 | extern void writepsffontheader(FILE *ofil, | |
34 | int width, int height, int fontlen, | |
35 | int *psftype, int flags); | |
36 | 36 | |
37 | 37 | extern void appendunicode(FILE *fp, unsigned int uc, int utf8); |
38 | 38 | extern void appendseparator(FILE *fp, int seq, int utf8); |
39 | 39 | |
40 | #endif /* _PSFFONTOP_H */ | |
40 | #endif /* _PSFFONTOP_H */ |
53 | 53 | struct unicode_list *uclistheads; |
54 | 54 | |
55 | 55 | static void |
56 | addpair(int fontpos, unsigned int uc) { | |
56 | addpair(int fontpos, unsigned int uc) | |
57 | { | |
57 | 58 | struct unicode_list *ul; |
58 | 59 | struct unicode_seq *us; |
59 | 60 | |
60 | ul = xmalloc(sizeof(struct unicode_list)); | |
61 | us = xmalloc(sizeof(struct unicode_seq)); | |
62 | us->uc = uc; | |
63 | us->prev = us; | |
64 | us->next = NULL; | |
65 | ul->seq = us; | |
66 | ul->prev = uclistheads[fontpos].prev; | |
67 | ul->prev->next = ul; | |
68 | ul->next = NULL; | |
61 | ul = xmalloc(sizeof(struct unicode_list)); | |
62 | us = xmalloc(sizeof(struct unicode_seq)); | |
63 | us->uc = uc; | |
64 | us->prev = us; | |
65 | us->next = NULL; | |
66 | ul->seq = us; | |
67 | ul->prev = uclistheads[fontpos].prev; | |
68 | ul->prev->next = ul; | |
69 | ul->next = NULL; | |
69 | 70 | uclistheads[fontpos].prev = ul; |
70 | 71 | } |
71 | 72 | |
72 | 73 | static void |
73 | addseq(int fontpos, unsigned int uc) { | |
74 | addseq(int fontpos, unsigned int uc) | |
75 | { | |
74 | 76 | struct unicode_list *ul; |
75 | 77 | struct unicode_seq *us; |
76 | 78 | |
77 | ul = uclistheads[fontpos].prev; | |
78 | us = xmalloc(sizeof(struct unicode_seq)); | |
79 | us->uc = uc; | |
80 | us->prev = ul->seq->prev; | |
79 | ul = uclistheads[fontpos].prev; | |
80 | us = xmalloc(sizeof(struct unicode_seq)); | |
81 | us->uc = uc; | |
82 | us->prev = ul->seq->prev; | |
81 | 83 | us->prev->next = us; |
82 | us->next = NULL; | |
83 | ul->seq->prev = us; | |
84 | us->next = NULL; | |
85 | ul->seq->prev = us; | |
84 | 86 | } |
85 | 87 | |
86 | 88 | static int |
87 | getunicode(char **p0) { | |
89 | getunicode(char **p0) | |
90 | { | |
88 | 91 | char *p = *p0; |
89 | 92 | |
90 | 93 | while (*p == ' ' || *p == '\t') |
93 | 96 | !isxdigit(p[2]) || !isxdigit(p[3]) || !isxdigit(p[4]) || |
94 | 97 | !isxdigit(p[5]) || isxdigit(p[6])) |
95 | 98 | return -1; |
96 | *p0 = p+6; | |
97 | return strtol(p+2,0,16); | |
99 | *p0 = p + 6; | |
100 | return strtol(p + 2, 0, 16); | |
98 | 101 | } |
99 | 102 | |
100 | 103 | static void |
101 | parse_itab_line(char *buf, int fontlen){ | |
104 | parse_itab_line(char *buf, int fontlen) | |
105 | { | |
102 | 106 | char *p, *p1; |
103 | 107 | int i; |
104 | 108 | long fp0, fp1, un0, un1; |
156 | 160 | p++; |
157 | 161 | if (!strncmp(p, "idem", 4)) { |
158 | 162 | for (i = fp0; i <= fp1; i++) |
159 | addpair(i,i); | |
163 | addpair(i, i); | |
160 | 164 | p += 4; |
161 | 165 | } else { |
162 | 166 | un0 = getunicode(&p); |
164 | 168 | p++; |
165 | 169 | if (*p != '-') { |
166 | 170 | char *u = _("%s: Corresponding to a range of " |
167 | "font positions, there should be " | |
168 | "a Unicode range\n"); | |
171 | "font positions, there should be " | |
172 | "a Unicode range\n"); | |
169 | 173 | fprintf(stderr, u, progname); |
170 | 174 | exit(EX_DATAERR); |
171 | 175 | } |
173 | 177 | un1 = getunicode(&p); |
174 | 178 | if (un0 < 0 || un1 < 0) { |
175 | 179 | char *u = _("%s: Bad Unicode range " |
176 | "corresponding to font position " | |
177 | "range 0x%x-0x%x\n"); | |
180 | "corresponding to font position " | |
181 | "range 0x%x-0x%x\n"); | |
178 | 182 | fprintf(stderr, u, progname, fp0, fp1); |
179 | 183 | exit(EX_DATAERR); |
180 | 184 | } |
181 | 185 | if (un1 - un0 != fp1 - fp0) { |
182 | 186 | char *u = _("%s: Unicode range U+%x-U+%x not " |
183 | "of the same length as font " | |
184 | "position range 0x%x-0x%x\n"); | |
187 | "of the same length as font " | |
188 | "position range 0x%x-0x%x\n"); | |
185 | 189 | fprintf(stderr, u, progname, |
186 | un0, un1, fp0, fp1); | |
190 | un0, un1, fp0, fp1); | |
187 | 191 | exit(EX_DATAERR); |
188 | 192 | } |
189 | 193 | for (i = fp0; i <= fp1; i++) |
190 | addpair(i, un0-fp0+i); | |
194 | addpair(i, un0 - fp0 + i); | |
191 | 195 | } /* not idem */ |
192 | 196 | } else { /* no range */ |
193 | 197 | while ((un0 = getunicode(&p)) >= 0) { |
207 | 211 | } |
208 | 212 | |
209 | 213 | static void |
210 | read_itable(FILE *itab, int fontlen, struct unicode_list **uclistheadsp) { | |
214 | read_itable(FILE *itab, int fontlen, struct unicode_list **uclistheadsp) | |
215 | { | |
211 | 216 | char buf[65536]; |
212 | 217 | int i; |
213 | 218 | |
214 | 219 | if (uclistheadsp) { |
215 | 220 | *uclistheadsp = xrealloc(*uclistheadsp, |
216 | fontlen*sizeof(struct unicode_list)); | |
217 | for (i=0; i<fontlen; i++) { | |
221 | fontlen * sizeof(struct unicode_list)); | |
222 | for (i = 0; i < fontlen; i++) { | |
218 | 223 | struct unicode_list *up = &((*uclistheadsp)[i]); |
219 | up->next = NULL; | |
220 | up->seq = NULL; | |
221 | up->prev = up; | |
224 | up->next = NULL; | |
225 | up->seq = NULL; | |
226 | up->prev = up; | |
222 | 227 | } |
223 | 228 | while (fgets(buf, sizeof(buf), itab) != NULL) |
224 | 229 | parse_itab_line(buf, fontlen); |
227 | 232 | |
228 | 233 | int debug = 0; |
229 | 234 | |
230 | int | |
231 | main(int argc, char **argv) { | |
235 | int main(int argc, char **argv) | |
236 | { | |
232 | 237 | char *ifname, *ofname, *itname, *otname; |
233 | 238 | FILE *ifil, *ofil, *itab, *otab; |
234 | 239 | int psftype, fontlen, charsize, hastable, notable; |
248 | 253 | |
249 | 254 | ifil = ofil = itab = otab = NULL; |
250 | 255 | ifname = ofname = itname = otname = NULL; |
251 | fontbuf = NULL; | |
252 | notable = 0; | |
256 | fontbuf = NULL; | |
257 | notable = 0; | |
253 | 258 | |
254 | 259 | if (!strcmp(progname, "psfaddtable")) { |
255 | 260 | /* Do not send binary data to stdout without explicit "-" */ |
276 | 281 | fprintf(stderr, u, progname); |
277 | 282 | exit(EX_USAGE); |
278 | 283 | } |
279 | ifname = argv[1]; | |
280 | ofname = argv[2]; | |
284 | ifname = argv[1]; | |
285 | ofname = argv[2]; | |
281 | 286 | notable = 1; |
282 | 287 | } else { |
283 | for (i = 1; i < argc; i ++) { | |
284 | if ((!strcmp(argv[i], "-i") || !strcmp(argv[i], "-if")) | |
285 | && i < argc-1) | |
288 | for (i = 1; i < argc; i++) { | |
289 | if ((!strcmp(argv[i], "-i") || !strcmp(argv[i], "-if")) && i < argc - 1) | |
286 | 290 | ifname = argv[++i]; |
287 | else if((!strcmp(argv[i],"-o")||!strcmp(argv[i],"-of")) | |
288 | && i < argc-1) | |
291 | else if ((!strcmp(argv[i], "-o") || !strcmp(argv[i], "-of")) && i < argc - 1) | |
289 | 292 | ofname = argv[++i]; |
290 | else if(!strcmp(argv[i], "-it") && i < argc-1) | |
293 | else if (!strcmp(argv[i], "-it") && i < argc - 1) | |
291 | 294 | itname = argv[++i]; |
292 | else if(!strcmp(argv[i], "-ot") && i < argc-1) | |
295 | else if (!strcmp(argv[i], "-ot") && i < argc - 1) | |
293 | 296 | otname = argv[++i]; |
294 | else if(!strcmp(argv[i], "-nt")) | |
297 | else if (!strcmp(argv[i], "-nt")) | |
295 | 298 | notable = 1; |
296 | 299 | else |
297 | 300 | break; |
298 | 301 | } |
299 | 302 | if (i < argc || argc <= 1) { |
300 | 303 | char *u = _("Usage:\n\t%s [-i infont] [-o outfont] " |
301 | "[-it intable] [-ot outtable] [-nt]\n"); | |
304 | "[-it intable] [-ot outtable] [-nt]\n"); | |
302 | 305 | fprintf(stderr, u, progname); |
303 | 306 | exit(EX_USAGE); |
304 | 307 | } |
355 | 358 | } |
356 | 359 | |
357 | 360 | if (readpsffont(ifil, &inbuf, &inbuflth, &fontbuf, &fontbuflth, |
358 | &width, &fontlen, 0, | |
359 | itab ? NULL : &uclistheads) == -1) { | |
361 | &width, &fontlen, 0, | |
362 | itab ? NULL : &uclistheads) == -1) { | |
360 | 363 | char *u = _("%s: Bad magic number on %s\n"); |
361 | 364 | fprintf(stderr, u, progname, ifname); |
362 | 365 | exit(EX_DATAERR); |
363 | 366 | } |
364 | 367 | fclose(ifil); |
365 | 368 | |
366 | charsize = fontbuflth/fontlen; | |
367 | bytewidth = (width + 7)/8; | |
369 | charsize = fontbuflth / fontlen; | |
370 | bytewidth = (width + 7) / 8; | |
368 | 371 | if (!bytewidth) |
369 | 372 | bytewidth = 1; |
370 | height = charsize / bytewidth; | |
373 | height = charsize / bytewidth; | |
371 | 374 | |
372 | 375 | hastable = (uclistheads != NULL); |
373 | 376 | |
397 | 400 | exit(EX_DATAERR); |
398 | 401 | } |
399 | 402 | fprintf(otab, |
400 | "#\n# Character table extracted from font %s\n#\n", | |
401 | ifname); | |
402 | for (i=0; i<fontlen; i++) { | |
403 | "#\n# Character table extracted from font %s\n#\n", | |
404 | ifname); | |
405 | for (i = 0; i < fontlen; i++) { | |
403 | 406 | fprintf(otab, "0x%03x\t", i); |
404 | 407 | sep = ""; |
405 | ul = uclistheads[i].next; | |
408 | ul = uclistheads[i].next; | |
406 | 409 | while (ul) { |
407 | 410 | us = ul->seq; |
408 | while(us) { | |
411 | while (us) { | |
409 | 412 | fprintf(otab, "%sU+%04x", sep, us->uc); |
410 | us = us->next; | |
413 | us = us->next; | |
411 | 414 | sep = ", "; |
412 | 415 | } |
413 | ul = ul->next; | |
416 | ul = ul->next; | |
414 | 417 | sep = " "; |
415 | 418 | } |
416 | 419 | fprintf(otab, "\n"); |
420 | 423 | |
421 | 424 | if (ofil) { |
422 | 425 | writepsffont(ofil, fontbuf, width, height, fontlen, psftype, |
423 | notable ? NULL : uclistheads); | |
426 | notable ? NULL : uclistheads); | |
424 | 427 | fclose(ofil); |
425 | 428 | } |
426 | 429 |
86 | 86 | #include "version.h" |
87 | 87 | #include "kbd_error.h" |
88 | 88 | |
89 | #define MODE_RESTORETEXTMODE 0 | |
90 | #define MODE_VGALINES 1 | |
89 | #define MODE_RESTORETEXTMODE 0 | |
90 | #define MODE_VGALINES 1 | |
91 | 91 | |
92 | 92 | static void usage(void); |
93 | 93 | |
100 | 100 | static void vga_set_cursor(int, int); |
101 | 101 | static void vga_set_verticaldisplayend_lowbyte(int); |
102 | 102 | |
103 | const char *const dirpath[] = { "", DATADIR "/" VIDEOMODEDIR "/", 0}; | |
103 | const char *const dirpath[] = { "", DATADIR "/" VIDEOMODEDIR "/", 0 }; | |
104 | 104 | const char *const suffixes[] = { "", 0 }; |
105 | 105 | |
106 | int | |
107 | main(int argc, char **argv) { | |
108 | int rr, cc, fd, i, mode; | |
109 | struct vt_sizes vtsizes; | |
110 | struct vt_stat vtstat; | |
111 | struct winsize winsize; | |
112 | char *p; | |
113 | char tty[12], cmd[80], infile[1024]; | |
114 | char *defaultfont; | |
115 | lkfile_t fp; | |
116 | ||
117 | set_progname(argv[0]); | |
118 | ||
119 | setlocale(LC_ALL, ""); | |
120 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
121 | textdomain(PACKAGE_NAME); | |
122 | ||
123 | if (argc < 2) | |
124 | usage(); | |
125 | ||
126 | if (argc == 2 && !strcmp(argv[1], "-V")) | |
127 | print_version_and_exit(); | |
128 | ||
129 | rr = 0; /* make gcc happy */ | |
130 | cc = atoi(argv[1]); | |
131 | mode = MODE_RESTORETEXTMODE; | |
132 | if (argc == 3 && strcmp(argv[1], "-lines") == 0) { | |
133 | mode = MODE_VGALINES; | |
134 | rr = atoi(argv[2]); | |
135 | } | |
136 | else | |
137 | if (argc == 2 && (p = strchr(argv[1], 'x')) != 0) | |
138 | rr = atoi(p+1); | |
139 | else if(argc == 3) | |
140 | rr = atoi(argv[2]); | |
141 | else | |
142 | usage(); | |
143 | ||
144 | if (mode == MODE_RESTORETEXTMODE) { | |
145 | /* prepare for: restoretextmode -r 80x25 */ | |
146 | sprintf(infile, "%dx%d", cc, rr); | |
147 | if (lk_findfile(infile, dirpath, suffixes, &fp)) { | |
148 | kbd_error(EXIT_FAILURE, 0, _("resizecons: cannot find videomode file %s\n"), infile); | |
149 | } | |
150 | lk_fpclose(&fp); | |
151 | } | |
152 | ||
153 | if ((fd = getfd(NULL)) < 0) | |
154 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); | |
155 | ||
156 | if(ioctl(fd, TIOCGWINSZ, &winsize)) { | |
157 | kbd_error(EXIT_FAILURE, errno, "ioctl TIOCGWINSZ"); | |
158 | } | |
159 | ||
160 | if (mode == MODE_VGALINES) { | |
161 | /* Get the number of columns. */ | |
162 | cc = winsize.ws_col; | |
163 | if (rr != 25 && rr != 28 && rr != 30 && rr != 34 && rr != 36 && | |
164 | rr != 40 && rr != 44 && rr != 50 && rr != 60) { | |
165 | kbd_error(EXIT_FAILURE, 0, _("Invalid number of lines\n")); | |
166 | } | |
167 | } | |
168 | ||
169 | if(ioctl(fd, VT_GETSTATE, &vtstat)) { | |
170 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_GETSTATE"); | |
171 | } | |
172 | ||
173 | vtsizes.v_rows = rr; | |
174 | vtsizes.v_cols = cc; | |
175 | vtsizes.v_scrollsize = 0; | |
176 | ||
177 | vga_init_io(); /* maybe only if (mode == MODE_VGALINES) */ | |
178 | ||
179 | if(ioctl(fd, VT_RESIZE, &vtsizes)) { | |
180 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_RESIZE"); | |
181 | } | |
182 | ||
183 | if (mode == MODE_VGALINES) { | |
184 | /* Program the VGA registers. */ | |
185 | int scanlines_old; | |
186 | int scanlines_new; | |
187 | int fontheight; | |
188 | if (winsize.ws_row == 25 || winsize.ws_row == 28 || | |
189 | winsize.ws_row == 36 || winsize.ws_row == 44 || | |
190 | winsize.ws_row == 50) | |
191 | scanlines_old = 400; | |
192 | else | |
193 | scanlines_old = 480; | |
194 | if (rr == 25 || rr == 28 || rr == 36 || rr == 44 || rr == 50) | |
195 | scanlines_new = 400; | |
196 | else | |
197 | scanlines_new = 480; | |
198 | /* Switch to 400 or 480 scanline vertical timing if required. */ | |
199 | if (scanlines_old != 400 && scanlines_new == 400) | |
200 | vga_400_scanlines(); | |
201 | if (scanlines_old != 480 && scanlines_new == 480) | |
202 | vga_480_scanlines(); | |
203 | switch (rr) { | |
204 | case 25 : fontheight = 16; break; | |
205 | case 28 : fontheight = 14; break; | |
206 | case 30 : fontheight = 16; break; | |
207 | case 34 : fontheight = 14; break; | |
208 | case 36 : fontheight = 12; break; | |
209 | case 40 : fontheight = 12; break; | |
210 | case 44 : fontheight = 9; break; | |
211 | case 50 : fontheight = 8; break; | |
212 | case 60 : fontheight = 8; break; | |
213 | default : fontheight = 8; break; | |
214 | } | |
215 | /* Set the VGA character height. */ | |
216 | vga_set_fontheight(fontheight); | |
217 | /* Set the line offsets within a character cell of the cursor. */ | |
218 | if (fontheight >= 10) | |
219 | vga_set_cursor(fontheight - 3, fontheight - 2); | |
106 | int main(int argc, char **argv) | |
107 | { | |
108 | int rr, cc, fd, i, mode; | |
109 | struct vt_sizes vtsizes; | |
110 | struct vt_stat vtstat; | |
111 | struct winsize winsize; | |
112 | char *p; | |
113 | char tty[12], cmd[80], infile[1024]; | |
114 | char *defaultfont; | |
115 | lkfile_t fp; | |
116 | ||
117 | set_progname(argv[0]); | |
118 | ||
119 | setlocale(LC_ALL, ""); | |
120 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
121 | textdomain(PACKAGE_NAME); | |
122 | ||
123 | if (argc < 2) | |
124 | usage(); | |
125 | ||
126 | if (argc == 2 && !strcmp(argv[1], "-V")) | |
127 | print_version_and_exit(); | |
128 | ||
129 | rr = 0; /* make gcc happy */ | |
130 | cc = atoi(argv[1]); | |
131 | mode = MODE_RESTORETEXTMODE; | |
132 | if (argc == 3 && strcmp(argv[1], "-lines") == 0) { | |
133 | mode = MODE_VGALINES; | |
134 | rr = atoi(argv[2]); | |
135 | } else if (argc == 2 && (p = strchr(argv[1], 'x')) != 0) | |
136 | rr = atoi(p + 1); | |
137 | else if (argc == 3) | |
138 | rr = atoi(argv[2]); | |
220 | 139 | else |
221 | vga_set_cursor(fontheight - 2, fontheight - 1); | |
222 | /* | |
140 | usage(); | |
141 | ||
142 | if (mode == MODE_RESTORETEXTMODE) { | |
143 | /* prepare for: restoretextmode -r 80x25 */ | |
144 | sprintf(infile, "%dx%d", cc, rr); | |
145 | if (lk_findfile(infile, dirpath, suffixes, &fp)) { | |
146 | kbd_error(EXIT_FAILURE, 0, _("resizecons: cannot find videomode file %s\n"), infile); | |
147 | } | |
148 | lk_fpclose(&fp); | |
149 | } | |
150 | ||
151 | if ((fd = getfd(NULL)) < 0) | |
152 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); | |
153 | ||
154 | if (ioctl(fd, TIOCGWINSZ, &winsize)) { | |
155 | kbd_error(EXIT_FAILURE, errno, "ioctl TIOCGWINSZ"); | |
156 | } | |
157 | ||
158 | if (mode == MODE_VGALINES) { | |
159 | /* Get the number of columns. */ | |
160 | cc = winsize.ws_col; | |
161 | if (rr != 25 && rr != 28 && rr != 30 && rr != 34 && rr != 36 && | |
162 | rr != 40 && rr != 44 && rr != 50 && rr != 60) { | |
163 | kbd_error(EXIT_FAILURE, 0, _("Invalid number of lines\n")); | |
164 | } | |
165 | } | |
166 | ||
167 | if (ioctl(fd, VT_GETSTATE, &vtstat)) { | |
168 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_GETSTATE"); | |
169 | } | |
170 | ||
171 | vtsizes.v_rows = rr; | |
172 | vtsizes.v_cols = cc; | |
173 | vtsizes.v_scrollsize = 0; | |
174 | ||
175 | vga_init_io(); /* maybe only if (mode == MODE_VGALINES) */ | |
176 | ||
177 | if (ioctl(fd, VT_RESIZE, &vtsizes)) { | |
178 | kbd_error(EXIT_FAILURE, errno, "ioctl VT_RESIZE"); | |
179 | } | |
180 | ||
181 | if (mode == MODE_VGALINES) { | |
182 | /* Program the VGA registers. */ | |
183 | int scanlines_old; | |
184 | int scanlines_new; | |
185 | int fontheight; | |
186 | if (winsize.ws_row == 25 || winsize.ws_row == 28 || | |
187 | winsize.ws_row == 36 || winsize.ws_row == 44 || | |
188 | winsize.ws_row == 50) | |
189 | scanlines_old = 400; | |
190 | else | |
191 | scanlines_old = 480; | |
192 | if (rr == 25 || rr == 28 || rr == 36 || rr == 44 || rr == 50) | |
193 | scanlines_new = 400; | |
194 | else | |
195 | scanlines_new = 480; | |
196 | /* Switch to 400 or 480 scanline vertical timing if required. */ | |
197 | if (scanlines_old != 400 && scanlines_new == 400) | |
198 | vga_400_scanlines(); | |
199 | if (scanlines_old != 480 && scanlines_new == 480) | |
200 | vga_480_scanlines(); | |
201 | switch (rr) { | |
202 | case 25: | |
203 | fontheight = 16; | |
204 | break; | |
205 | case 28: | |
206 | fontheight = 14; | |
207 | break; | |
208 | case 30: | |
209 | fontheight = 16; | |
210 | break; | |
211 | case 34: | |
212 | fontheight = 14; | |
213 | break; | |
214 | case 36: | |
215 | fontheight = 12; | |
216 | break; | |
217 | case 40: | |
218 | fontheight = 12; | |
219 | break; | |
220 | case 44: | |
221 | fontheight = 9; | |
222 | break; | |
223 | case 50: | |
224 | fontheight = 8; | |
225 | break; | |
226 | case 60: | |
227 | fontheight = 8; | |
228 | break; | |
229 | default: | |
230 | fontheight = 8; | |
231 | break; | |
232 | } | |
233 | /* Set the VGA character height. */ | |
234 | vga_set_fontheight(fontheight); | |
235 | /* Set the line offsets within a character cell of the cursor. */ | |
236 | if (fontheight >= 10) | |
237 | vga_set_cursor(fontheight - 3, fontheight - 2); | |
238 | else | |
239 | vga_set_cursor(fontheight - 2, fontheight - 1); | |
240 | /* | |
223 | 241 | * If there are a few unused scanlines at the bottom of the |
224 | 242 | * screen, make sure they are not displayed (otherwise |
225 | 243 | * there is a annoying changing partial line at the bottom). |
226 | 244 | */ |
227 | vga_set_verticaldisplayend_lowbyte((fontheight * rr - 1) & 0xff); | |
228 | printf(_("Old mode: %dx%d New mode: %dx%d\n"), winsize.ws_col, | |
229 | winsize.ws_row, cc, rr); | |
230 | printf(_("Old #scanlines: %d New #scanlines: %d Character height: %d\n"), | |
231 | scanlines_old, scanlines_new, fontheight); | |
232 | } | |
233 | ||
234 | if (mode == MODE_RESTORETEXTMODE) { | |
235 | /* do: restoretextmode -r 25x80 */ | |
236 | sprintf(cmd, "restoretextmode -r %s\n", fp.pathname); | |
237 | errno = 0; | |
238 | if(system(cmd)) { | |
239 | if(errno) | |
240 | perror("restoretextmode"); | |
241 | fprintf(stderr, _("resizecons: the command `%s' failed\n"), cmd); | |
242 | exit(EXIT_FAILURE); | |
243 | } | |
244 | } | |
245 | ||
246 | /* | |
245 | vga_set_verticaldisplayend_lowbyte((fontheight * rr - 1) & 0xff); | |
246 | printf(_("Old mode: %dx%d New mode: %dx%d\n"), winsize.ws_col, | |
247 | winsize.ws_row, cc, rr); | |
248 | printf(_("Old #scanlines: %d New #scanlines: %d Character height: %d\n"), | |
249 | scanlines_old, scanlines_new, fontheight); | |
250 | } | |
251 | ||
252 | if (mode == MODE_RESTORETEXTMODE) { | |
253 | /* do: restoretextmode -r 25x80 */ | |
254 | sprintf(cmd, "restoretextmode -r %s\n", fp.pathname); | |
255 | errno = 0; | |
256 | if (system(cmd)) { | |
257 | if (errno) | |
258 | perror("restoretextmode"); | |
259 | fprintf(stderr, _("resizecons: the command `%s' failed\n"), cmd); | |
260 | exit(EXIT_FAILURE); | |
261 | } | |
262 | } | |
263 | ||
264 | /* | |
247 | 265 | * for i in /dev/tty[0-9] /dev/tty[0-9][0-9] |
248 | 266 | * do |
249 | 267 | * stty rows $rr cols $cc < $i |
250 | 268 | * done |
251 | 269 | * kill -SIGWINCH `cat /tmp/selection.pid` |
252 | 270 | */ |
253 | winsize.ws_row = rr; | |
254 | winsize.ws_col = cc; | |
255 | for (i=0; i<16; i++) | |
256 | if (vtstat.v_state & (1<<i)) { | |
257 | sprintf(tty, "/dev/tty%d", i); | |
258 | fd = open(tty, O_RDONLY); | |
259 | if (fd < 0 && errno == ENOENT) { | |
260 | sprintf(tty, "/dev/vc/%d", i); | |
261 | fd = open(tty, O_RDONLY); | |
262 | } | |
263 | if (fd >= 0) { | |
264 | if(ioctl(fd, TIOCSWINSZ, &winsize)) | |
265 | kbd_warning(errno, "ioctl TIOCSWINSZ"); | |
266 | close(fd); | |
267 | } | |
268 | } | |
271 | winsize.ws_row = rr; | |
272 | winsize.ws_col = cc; | |
273 | for (i = 0; i < 16; i++) | |
274 | if (vtstat.v_state & (1 << i)) { | |
275 | sprintf(tty, "/dev/tty%d", i); | |
276 | fd = open(tty, O_RDONLY); | |
277 | if (fd < 0 && errno == ENOENT) { | |
278 | sprintf(tty, "/dev/vc/%d", i); | |
279 | fd = open(tty, O_RDONLY); | |
280 | } | |
281 | if (fd >= 0) { | |
282 | if (ioctl(fd, TIOCSWINSZ, &winsize)) | |
283 | kbd_warning(errno, "ioctl TIOCSWINSZ"); | |
284 | close(fd); | |
285 | } | |
286 | } | |
269 | 287 | |
270 | 288 | #if 0 |
271 | 289 | /* Try to tell selection about the change */ |
284 | 302 | } |
285 | 303 | #endif |
286 | 304 | |
287 | /* do: setfont default8x16 */ | |
288 | /* (other people might wish other fonts - this should be settable) */ | |
289 | ||
290 | /* We read the VGA font height register to be sure. */ | |
291 | /* There isn't much consistency in this. */ | |
292 | switch (vga_get_fontheight()) { | |
293 | case 8 : | |
294 | case 9 : defaultfont = "default8x9"; break; | |
295 | case 10 : defaultfont = "lat1-10"; break; | |
296 | case 11 : | |
297 | case 12 : defaultfont = "lat1-12"; break; | |
298 | case 13 : | |
299 | case 14 : defaultfont = "iso01.14"; break; | |
300 | case 15 : | |
301 | case 16 : | |
302 | default : defaultfont = "default8x16"; break; | |
303 | } | |
304 | ||
305 | sprintf(cmd, "setfont %s", defaultfont); | |
306 | errno = 0; | |
307 | if(system(cmd)) { | |
308 | if(errno) | |
309 | perror("setfont"); | |
310 | fprintf(stderr, "resizecons: the command `%s' failed\n", cmd); | |
305 | /* do: setfont default8x16 */ | |
306 | /* (other people might wish other fonts - this should be settable) */ | |
307 | ||
308 | /* We read the VGA font height register to be sure. */ | |
309 | /* There isn't much consistency in this. */ | |
310 | switch (vga_get_fontheight()) { | |
311 | case 8: | |
312 | case 9: | |
313 | defaultfont = "default8x9"; | |
314 | break; | |
315 | case 10: | |
316 | defaultfont = "lat1-10"; | |
317 | break; | |
318 | case 11: | |
319 | case 12: | |
320 | defaultfont = "lat1-12"; | |
321 | break; | |
322 | case 13: | |
323 | case 14: | |
324 | defaultfont = "iso01.14"; | |
325 | break; | |
326 | case 15: | |
327 | case 16: | |
328 | default: | |
329 | defaultfont = "default8x16"; | |
330 | break; | |
331 | } | |
332 | ||
333 | sprintf(cmd, "setfont %s", defaultfont); | |
334 | errno = 0; | |
335 | if (system(cmd)) { | |
336 | if (errno) | |
337 | perror("setfont"); | |
338 | fprintf(stderr, "resizecons: the command `%s' failed\n", cmd); | |
339 | exit(EXIT_FAILURE); | |
340 | } | |
341 | ||
342 | fprintf(stderr, _("resizecons: don't forget to change TERM " | |
343 | "(maybe to con%dx%d or linux-%dx%d)\n"), | |
344 | cc, rr, cc, rr); | |
345 | if (getenv("LINES") || getenv("COLUMNS")) | |
346 | fprintf(stderr, | |
347 | "Also the variables LINES and COLUMNS may need adjusting.\n"); | |
348 | ||
349 | return EXIT_SUCCESS; | |
350 | } | |
351 | ||
352 | static void __attribute__((noreturn)) | |
353 | usage() | |
354 | { | |
355 | fprintf(stderr, | |
356 | _("resizecons:\n" | |
357 | "call is: resizecons COLSxROWS or: resizecons COLS ROWS\n" | |
358 | "or: resizecons -lines ROWS, with ROWS one of 25, 28, 30, 34," | |
359 | " 36, 40, 44, 50, 60\n")); | |
311 | 360 | exit(EXIT_FAILURE); |
312 | } | |
313 | ||
314 | fprintf(stderr, _("resizecons: don't forget to change TERM " | |
315 | "(maybe to con%dx%d or linux-%dx%d)\n"), | |
316 | cc, rr, cc, rr); | |
317 | if (getenv("LINES") || getenv("COLUMNS")) | |
318 | fprintf(stderr, | |
319 | "Also the variables LINES and COLUMNS may need adjusting.\n"); | |
320 | ||
321 | return EXIT_SUCCESS; | |
322 | } | |
323 | ||
324 | static void __attribute__ ((noreturn)) | |
325 | usage() { | |
326 | fprintf(stderr, | |
327 | _("resizecons:\n" | |
328 | "call is: resizecons COLSxROWS or: resizecons COLS ROWS\n" | |
329 | "or: resizecons -lines ROWS, with ROWS one of 25, 28, 30, 34," | |
330 | " 36, 40, 44, 50, 60\n")); | |
331 | exit(EXIT_FAILURE); | |
332 | 361 | } |
333 | 362 | |
334 | 363 | /* |
339 | 368 | /* Port I/O macros. Note that these are not compatible with the ones */ |
340 | 369 | /* defined in the kernel header files. */ |
341 | 370 | |
342 | static inline void my_outb( int port, int value ) | |
343 | { | |
344 | __asm__ volatile ("outb %0,%1" | |
345 | : : "a" ((unsigned char)value), "d" ((unsigned short)port)); | |
346 | } | |
347 | ||
348 | static inline int my_inb( int port ) | |
371 | static inline void my_outb(int port, int value) | |
372 | { | |
373 | __asm__ volatile("outb %0,%1" | |
374 | : | |
375 | : "a"((unsigned char)value), "d"((unsigned short)port)); | |
376 | } | |
377 | ||
378 | static inline int my_inb(int port) | |
349 | 379 | { |
350 | 380 | unsigned char value; |
351 | __asm__ volatile ("inb %1,%0" | |
352 | : "=a" (value) | |
353 | : "d" ((unsigned short)port)); | |
381 | __asm__ volatile("inb %1,%0" | |
382 | : "=a"(value) | |
383 | : "d"((unsigned short)port)); | |
354 | 384 | return value; |
355 | 385 | } |
356 | 386 | |
357 | ||
358 | 387 | /* VGA textmode register tweaking functions. */ |
359 | 388 | |
360 | 389 | static int crtcport; |
361 | 390 | |
362 | static void vga_init_io() { | |
391 | static void vga_init_io() | |
392 | { | |
363 | 393 | if (iopl(3) < 0) { |
364 | 394 | fprintf(stderr, |
365 | _("resizecons: cannot get I/O permissions.\n")); | |
395 | _("resizecons: cannot get I/O permissions.\n")); | |
366 | 396 | exit(EXIT_FAILURE); |
367 | 397 | } |
368 | 398 | crtcport = 0x3d4; |
370 | 400 | crtcport = 0x3b4; |
371 | 401 | } |
372 | 402 | |
373 | static void vga_set_fontheight( int h ) { | |
403 | static void vga_set_fontheight(int h) | |
404 | { | |
374 | 405 | my_outb(crtcport, 0x09); |
375 | 406 | my_outb(crtcport + 1, (my_inb(crtcport + 1) & 0xe0) | (h - 1)); |
376 | 407 | } |
377 | 408 | |
378 | static int vga_get_fontheight() { | |
409 | static int vga_get_fontheight() | |
410 | { | |
379 | 411 | my_outb(crtcport, 0x09); |
380 | 412 | return (my_inb(crtcport + 1) & 0x1f) + 1; |
381 | 413 | } |
382 | 414 | |
383 | static void vga_set_cursor( int top, int bottom ) { | |
415 | static void vga_set_cursor(int top, int bottom) | |
416 | { | |
384 | 417 | my_outb(crtcport, 0x0a); |
385 | 418 | my_outb(crtcport + 1, (my_inb(crtcport + 1) & 0xc0) | top); |
386 | 419 | my_outb(crtcport, 0x0b); |
387 | 420 | my_outb(crtcport + 1, (my_inb(crtcport + 1) & 0xe0) | bottom); |
388 | 421 | } |
389 | 422 | |
390 | static void vga_set_verticaldisplayend_lowbyte( int byte ) { | |
423 | static void vga_set_verticaldisplayend_lowbyte(int byte) | |
424 | { | |
391 | 425 | /* CRTC register 0x12 */ |
392 | 426 | /* vertical display end */ |
393 | 427 | my_outb(crtcport, 0x12); |
394 | 428 | my_outb(crtcport + 1, byte); |
395 | 429 | } |
396 | 430 | |
397 | static void vga_480_scanlines() { | |
431 | static void vga_480_scanlines() | |
432 | { | |
398 | 433 | /* CRTC register 0x11 */ |
399 | 434 | /* vertical sync end (also unlocks CR0-7) */ |
400 | 435 | my_outb(crtcport, 0x11); |
435 | 470 | my_outb(0x3c2, (my_inb(0x3cc) & 0x0d) | 0xe2); |
436 | 471 | } |
437 | 472 | |
438 | static void vga_400_scanlines() { | |
473 | static void vga_400_scanlines() | |
474 | { | |
439 | 475 | /* CRTC register 0x11 */ |
440 | 476 | /* vertical sync end (also unlocks CR0-7) */ |
441 | 477 | my_outb(crtcport, 0x11); |
28 | 28 | #include "version.h" |
29 | 29 | #include "kbd_error.h" |
30 | 30 | |
31 | int | |
32 | main(int argc, char **argv) { | |
33 | int cons = 0; | |
34 | char infile[20]; | |
35 | unsigned char header[4]; | |
36 | unsigned int rows, cols; | |
37 | int fd; | |
38 | unsigned int i, j; | |
39 | char *inbuf, *outbuf, *p, *q; | |
31 | int main(int argc, char **argv) | |
32 | { | |
33 | int cons = 0; | |
34 | char infile[20]; | |
35 | unsigned char header[4]; | |
36 | unsigned int rows, cols; | |
37 | int fd; | |
38 | unsigned int i, j; | |
39 | char *inbuf, *outbuf, *p, *q; | |
40 | 40 | |
41 | set_progname(argv[0]); | |
41 | set_progname(argv[0]); | |
42 | 42 | |
43 | setlocale(LC_ALL, ""); | |
44 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
45 | textdomain(PACKAGE_NAME); | |
43 | setlocale(LC_ALL, ""); | |
44 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
45 | textdomain(PACKAGE_NAME); | |
46 | 46 | |
47 | if (argc == 2 && !strcmp(argv[1], "-V")) | |
48 | print_version_and_exit(); | |
47 | if (argc == 2 && !strcmp(argv[1], "-V")) | |
48 | print_version_and_exit(); | |
49 | 49 | |
50 | if (argc > 2) { | |
51 | fprintf(stderr, _("usage: screendump [n]\n")); | |
52 | exit(EXIT_FAILURE); | |
53 | } | |
50 | if (argc > 2) { | |
51 | fprintf(stderr, _("usage: screendump [n]\n")); | |
52 | exit(EXIT_FAILURE); | |
53 | } | |
54 | 54 | |
55 | cons = (argc == 2) ? atoi(argv[1]) : 0; | |
55 | cons = (argc == 2) ? atoi(argv[1]) : 0; | |
56 | 56 | |
57 | sprintf(infile, "/dev/vcsa%d", cons); | |
58 | fd = open(infile, O_RDONLY); | |
59 | if (fd < 0 && cons == 0 && errno == ENOENT) { | |
60 | sprintf(infile, "/dev/vcsa"); | |
61 | fd = open(infile, O_RDONLY); | |
62 | } | |
63 | if (fd < 0 && errno == ENOENT) { | |
64 | sprintf(infile, "/dev/vcs/a%d", cons); | |
65 | fd = open(infile, O_RDONLY); | |
66 | } | |
67 | if (fd < 0 && cons == 0 && errno == ENOENT) { | |
68 | sprintf(infile, "/dev/vcs/a"); | |
69 | fd = open(infile, O_RDONLY); | |
70 | } | |
71 | if (fd < 0 || read(fd, header, 4) != 4) | |
72 | goto try_ioctl; | |
73 | rows = header[0]; | |
74 | cols = header[1]; | |
75 | if (rows * cols == 0) | |
76 | goto try_ioctl; | |
77 | inbuf = xmalloc(rows*cols*2); | |
78 | outbuf = xmalloc(rows*(cols+1)); | |
57 | sprintf(infile, "/dev/vcsa%d", cons); | |
58 | fd = open(infile, O_RDONLY); | |
59 | if (fd < 0 && cons == 0 && errno == ENOENT) { | |
60 | sprintf(infile, "/dev/vcsa"); | |
61 | fd = open(infile, O_RDONLY); | |
62 | } | |
63 | if (fd < 0 && errno == ENOENT) { | |
64 | sprintf(infile, "/dev/vcs/a%d", cons); | |
65 | fd = open(infile, O_RDONLY); | |
66 | } | |
67 | if (fd < 0 && cons == 0 && errno == ENOENT) { | |
68 | sprintf(infile, "/dev/vcs/a"); | |
69 | fd = open(infile, O_RDONLY); | |
70 | } | |
71 | if (fd < 0 || read(fd, header, 4) != 4) | |
72 | goto try_ioctl; | |
73 | rows = header[0]; | |
74 | cols = header[1]; | |
75 | if (rows * cols == 0) | |
76 | goto try_ioctl; | |
77 | inbuf = xmalloc(rows * cols * 2); | |
78 | outbuf = xmalloc(rows * (cols + 1)); | |
79 | 79 | |
80 | if (read(fd, inbuf, rows*cols*2) != (ssize_t) (rows*cols*2)) { | |
81 | kbd_error(EXIT_FAILURE, errno, _("Error reading %s"), infile); | |
82 | } | |
83 | p = inbuf; | |
84 | q = outbuf; | |
85 | for(i=0; i<rows; i++) { | |
86 | for(j=0; j<cols; j++) { | |
87 | *q++ = *p; | |
88 | p += 2; | |
89 | } | |
90 | while(j-- > 0 && q[-1] == ' ') | |
91 | q--; | |
92 | *q++ = '\n'; | |
93 | } | |
94 | goto done; | |
80 | if (read(fd, inbuf, rows * cols * 2) != (ssize_t)(rows * cols * 2)) { | |
81 | kbd_error(EXIT_FAILURE, errno, _("Error reading %s"), infile); | |
82 | } | |
83 | p = inbuf; | |
84 | q = outbuf; | |
85 | for (i = 0; i < rows; i++) { | |
86 | for (j = 0; j < cols; j++) { | |
87 | *q++ = *p; | |
88 | p += 2; | |
89 | } | |
90 | while (j-- > 0 && q[-1] == ' ') | |
91 | q--; | |
92 | *q++ = '\n'; | |
93 | } | |
94 | goto done; | |
95 | 95 | |
96 | try_ioctl: | |
97 | { | |
96 | try_ioctl : { | |
98 | 97 | struct winsize win; |
99 | 98 | char consnam[20], devfsconsnam[20]; |
100 | 99 | unsigned char *screenbuf; |
102 | 101 | sprintf(consnam, "/dev/tty%d", cons); |
103 | 102 | fd = open(consnam, O_RDONLY); |
104 | 103 | if (fd < 0 && errno == ENOENT) { |
105 | sprintf(devfsconsnam, "/dev/vc/%d", cons); | |
106 | fd = open(devfsconsnam, O_RDONLY); | |
107 | if (fd < 0) | |
108 | errno = ENOENT; | |
104 | sprintf(devfsconsnam, "/dev/vc/%d", cons); | |
105 | fd = open(devfsconsnam, O_RDONLY); | |
106 | if (fd < 0) | |
107 | errno = ENOENT; | |
109 | 108 | } |
110 | 109 | if (fd < 0) { |
111 | perror(consnam); | |
112 | fd = 0; | |
110 | perror(consnam); | |
111 | fd = 0; | |
113 | 112 | } |
114 | 113 | |
115 | 114 | if (ioctl(fd, TIOCGWINSZ, &win)) { |
116 | kbd_error(EXIT_FAILURE, errno, "ioctl TIOCGWINSZ"); | |
115 | kbd_error(EXIT_FAILURE, errno, "ioctl TIOCGWINSZ"); | |
117 | 116 | } |
118 | 117 | |
119 | screenbuf = xmalloc(2 + win.ws_row * win.ws_col); | |
118 | screenbuf = xmalloc(2 + win.ws_row * win.ws_col); | |
120 | 119 | screenbuf[0] = 0; |
121 | screenbuf[1] = (unsigned char) cons; | |
120 | screenbuf[1] = (unsigned char)cons; | |
122 | 121 | |
123 | if (ioctl(fd,TIOCLINUX,screenbuf) && | |
124 | (!fd || ioctl(0,TIOCLINUX,screenbuf))) { | |
122 | if (ioctl(fd, TIOCLINUX, screenbuf) && | |
123 | (!fd || ioctl(0, TIOCLINUX, screenbuf))) { | |
125 | 124 | #if 0 |
126 | 125 | perror("TIOCLINUX"); |
127 | 126 | fprintf(stderr,_("couldn't read %s, and cannot ioctl dump\n"), |
128 | 127 | infile); |
129 | 128 | #else |
130 | /* we tried this just to be sure, but TIOCLINUX | |
129 | /* we tried this just to be sure, but TIOCLINUX | |
131 | 130 | function 0 has been disabled since 1.1.92 |
132 | 131 | Do not mention `ioctl dump' in error msg */ |
133 | kbd_warning(0, _("couldn't read %s\n"), infile); | |
132 | kbd_warning(0, _("couldn't read %s\n"), infile); | |
134 | 133 | #endif |
135 | return EXIT_FAILURE; | |
134 | return EXIT_FAILURE; | |
136 | 135 | } |
137 | 136 | |
138 | rows = screenbuf[0]; | |
139 | cols = screenbuf[1]; | |
137 | rows = screenbuf[0]; | |
138 | cols = screenbuf[1]; | |
140 | 139 | if (rows != win.ws_row || cols != win.ws_col) { |
141 | kbd_error(EXIT_FAILURE, 0, | |
142 | _("Strange ... screen is both %dx%d and %dx%d ??\n"), | |
143 | win.ws_col, win.ws_row, cols, rows); | |
140 | kbd_error(EXIT_FAILURE, 0, | |
141 | _("Strange ... screen is both %dx%d and %dx%d ??\n"), | |
142 | win.ws_col, win.ws_row, cols, rows); | |
144 | 143 | } |
145 | 144 | |
146 | outbuf = xmalloc(rows*(cols+1)); | |
147 | p = ((char *)screenbuf) + 2; | |
148 | q = outbuf; | |
149 | for (i=0; i<rows; i++) { | |
150 | for (j=0; j<cols; j++) | |
151 | *q++ = *p++; | |
152 | while (j-- > 0 && (q[-1] == ' ')) | |
153 | q--; | |
154 | *q++ = '\n'; | |
155 | } | |
156 | } | |
145 | outbuf = xmalloc(rows * (cols + 1)); | |
146 | p = ((char *)screenbuf) + 2; | |
147 | q = outbuf; | |
148 | for (i = 0; i < rows; i++) { | |
149 | for (j = 0; j < cols; j++) | |
150 | *q++ = *p++; | |
151 | while (j-- > 0 && (q[-1] == ' ')) | |
152 | q--; | |
153 | *q++ = '\n'; | |
154 | } | |
155 | } | |
157 | 156 | done: |
158 | if (write(1, outbuf, q-outbuf) != q-outbuf) { | |
159 | kbd_error(EXIT_FAILURE, 0, _("Error writing screendump\n")); | |
160 | } | |
157 | if (write(1, outbuf, q - outbuf) != q - outbuf) { | |
158 | kbd_error(EXIT_FAILURE, 0, _("Error writing screendump\n")); | |
159 | } | |
161 | 160 | |
162 | return EXIT_SUCCESS; | |
161 | return EXIT_SUCCESS; | |
163 | 162 | } |
38 | 38 | static void saveoldfont(int fd, char *ofil); |
39 | 39 | static void saveoldfontplusunicodemap(int fd, char *Ofil); |
40 | 40 | static void loadnewfont(int fd, char *ifil, |
41 | int iunit, int hwunit, int no_m, int no_u); | |
41 | int iunit, int hwunit, int no_m, int no_u); | |
42 | 42 | static void loadnewfonts(int fd, char **ifiles, int ifilct, |
43 | int iunit, int hwunit, int no_m, int no_u); | |
43 | int iunit, int hwunit, int no_m, int no_u); | |
44 | 44 | extern void saveoldmap(int fd, char *omfil); |
45 | 45 | extern void loadnewmap(int fd, char *mfil); |
46 | 46 | extern void activatemap(int fd); |
47 | 47 | extern void disactivatemap(int fd); |
48 | 48 | |
49 | 49 | int verbose = 0; |
50 | int force = 0; | |
51 | int debug = 0; | |
50 | int force = 0; | |
51 | int debug = 0; | |
52 | 52 | |
53 | 53 | /* search for the font in these directories (with trailing /) */ |
54 | const char *const fontdirpath[] = { "", DATADIR "/" FONTDIR "/", 0 }; | |
54 | const char *const fontdirpath[] = { "", DATADIR "/" FONTDIR "/", 0 }; | |
55 | 55 | const char *const fontsuffixes[] = { "", ".psfu", ".psf", ".cp", ".fnt", 0 }; |
56 | 56 | /* hide partial fonts a bit - loading a single one is a bad idea */ |
57 | const char *const partfontdirpath[] = { "", DATADIR "/" FONTDIR "/" PARTIALDIR "/", 0 }; | |
57 | const char *const partfontdirpath[] = { "", DATADIR "/" FONTDIR "/" PARTIALDIR "/", 0 }; | |
58 | 58 | const char *const partfontsuffixes[] = { "", 0 }; |
59 | 59 | |
60 | 60 | static inline int |
61 | findfont(char *fnam, lkfile_t *fp) { | |
62 | return lk_findfile(fnam, fontdirpath, fontsuffixes, fp); | |
61 | findfont(char *fnam, lkfile_t *fp) | |
62 | { | |
63 | return lk_findfile(fnam, fontdirpath, fontsuffixes, fp); | |
63 | 64 | } |
64 | 65 | |
65 | 66 | static inline int |
66 | findpartialfont(char *fnam, lkfile_t *fp) { | |
67 | return lk_findfile(fnam, partfontdirpath, partfontsuffixes, fp); | |
68 | } | |
69 | ||
70 | static void __attribute__ ((noreturn)) | |
67 | findpartialfont(char *fnam, lkfile_t *fp) | |
68 | { | |
69 | return lk_findfile(fnam, partfontdirpath, partfontsuffixes, fp); | |
70 | } | |
71 | ||
72 | static void __attribute__((noreturn)) | |
71 | 73 | usage(void) |
72 | 74 | { |
73 | fprintf(stderr, _( | |
74 | "Usage: setfont [write-options] [-<N>] [newfont..] [-m consolemap] [-u unicodemap]\n" | |
75 | " write-options (take place before file loading):\n" | |
76 | " -o <filename> Write current font to <filename>\n" | |
77 | " -O <filename> Write current font and unicode map to <filename>\n" | |
78 | " -om <filename> Write current consolemap to <filename>\n" | |
79 | " -ou <filename> Write current unicodemap to <filename>\n" | |
80 | "If no newfont and no -[o|O|om|ou|m|u] option is given,\n" | |
81 | "a default font is loaded:\n" | |
82 | " setfont Load font \"default[.gz]\"\n" | |
83 | " setfont -<N> Load font \"default8x<N>[.gz]\"\n" | |
84 | "The -<N> option selects a font from a codepage that contains three fonts:\n" | |
85 | " setfont -{8|14|16} codepage.cp[.gz] Load 8x<N> font from codepage.cp\n" | |
86 | "Explicitly (with -m or -u) or implicitly (in the fontfile) given mappings\n" | |
87 | "will be loaded and, in the case of consolemaps, activated.\n" | |
88 | " -h<N> (no space) Override font height.\n" | |
89 | " -m <fn> Load console screen map.\n" | |
90 | " -u <fn> Load font unicode map.\n" | |
91 | " -m none Suppress loading and activation of a screen map.\n" | |
92 | " -u none Suppress loading of a unicode map.\n" | |
93 | " -v Be verbose.\n" | |
94 | " -C <cons> Indicate console device to be used.\n" | |
95 | " -V Print version and exit.\n" | |
96 | "Files are loaded from the current directory or %s/*/.\n" | |
97 | ), DATADIR); | |
75 | fprintf(stderr, _( | |
76 | "Usage: setfont [write-options] [-<N>] [newfont..] [-m consolemap] [-u unicodemap]\n" | |
77 | " write-options (take place before file loading):\n" | |
78 | " -o <filename> Write current font to <filename>\n" | |
79 | " -O <filename> Write current font and unicode map to <filename>\n" | |
80 | " -om <filename> Write current consolemap to <filename>\n" | |
81 | " -ou <filename> Write current unicodemap to <filename>\n" | |
82 | "If no newfont and no -[o|O|om|ou|m|u] option is given,\n" | |
83 | "a default font is loaded:\n" | |
84 | " setfont Load font \"default[.gz]\"\n" | |
85 | " setfont -<N> Load font \"default8x<N>[.gz]\"\n" | |
86 | "The -<N> option selects a font from a codepage that contains three fonts:\n" | |
87 | " setfont -{8|14|16} codepage.cp[.gz] Load 8x<N> font from codepage.cp\n" | |
88 | "Explicitly (with -m or -u) or implicitly (in the fontfile) given mappings\n" | |
89 | "will be loaded and, in the case of consolemaps, activated.\n" | |
90 | " -h<N> (no space) Override font height.\n" | |
91 | " -m <fn> Load console screen map.\n" | |
92 | " -u <fn> Load font unicode map.\n" | |
93 | " -m none Suppress loading and activation of a screen map.\n" | |
94 | " -u none Suppress loading of a unicode map.\n" | |
95 | " -v Be verbose.\n" | |
96 | " -C <cons> Indicate console device to be used.\n" | |
97 | " -V Print version and exit.\n" | |
98 | "Files are loaded from the current directory or %s/*/.\n"), | |
99 | DATADIR); | |
98 | 100 | exit(EX_USAGE); |
99 | 101 | } |
100 | 102 | |
101 | 103 | #define MAXIFILES 256 |
102 | 104 | |
103 | int | |
104 | main(int argc, char *argv[]) { | |
105 | int main(int argc, char *argv[]) | |
106 | { | |
105 | 107 | char *ifiles[MAXIFILES]; |
106 | 108 | char *mfil, *ufil, *Ofil, *ofil, *omfil, *oufil, *console; |
107 | int ifilct = 0, fd, i, iunit, hwunit, no_m, no_u; | |
109 | int ifilct = 0, fd, i, iunit, hwunit, no_m, no_u; | |
108 | 110 | int restore = 0; |
109 | 111 | |
110 | 112 | set_progname(argv[0]); |
116 | 118 | ifiles[0] = mfil = ufil = Ofil = ofil = omfil = oufil = NULL; |
117 | 119 | iunit = hwunit = 0; |
118 | 120 | no_m = no_u = 0; |
119 | console = NULL; | |
121 | console = NULL; | |
120 | 122 | |
121 | 123 | /* |
122 | 124 | * No getopt() here because of the -om etc options. |
123 | 125 | */ |
124 | 126 | for (i = 1; i < argc; i++) { |
125 | if (!strcmp(argv[i], "-V")) { | |
126 | print_version_and_exit(); | |
127 | } else if (!strcmp(argv[i], "-v")) { | |
128 | verbose++; | |
129 | } else if (!strcmp(argv[i], "-R")) { | |
130 | restore = 1; | |
131 | } else if (!strcmp(argv[i], "-C")) { | |
132 | if (++i == argc || console) | |
133 | usage(); | |
134 | console = argv[i]; | |
135 | } else if (!strcmp(argv[i], "-O")) { | |
136 | if (++i == argc || Ofil) | |
137 | usage(); | |
138 | Ofil = argv[i]; | |
139 | } else if (!strcmp(argv[i], "-o")) { | |
140 | if (++i == argc || ofil) | |
141 | usage(); | |
142 | ofil = argv[i]; | |
143 | } else if (!strcmp(argv[i], "-om")) { | |
144 | if (++i == argc || omfil) | |
145 | usage(); | |
146 | omfil = argv[i]; | |
147 | } else if (!strcmp(argv[i], "-ou")) { | |
148 | if (++i == argc || oufil) | |
149 | usage(); | |
150 | oufil = argv[i]; | |
151 | } else if (!strcmp(argv[i], "-m")) { | |
152 | if (++i == argc || mfil) | |
153 | usage(); | |
154 | if (!strcmp(argv[i], "none")) | |
155 | no_m = 1; | |
156 | else | |
157 | mfil = argv[i]; | |
158 | } else if (!strcmp(argv[i], "-u")) { | |
159 | if (++i == argc || ufil) | |
160 | usage(); | |
161 | if (!strcmp(argv[i], "none")) | |
162 | no_u = 1; | |
163 | else | |
164 | ufil = argv[i]; | |
165 | } else if (!strcmp(argv[i], "-f")) { | |
166 | force = 1; | |
167 | } else if (!strncmp(argv[i], "-h", 2)) { | |
168 | hwunit = atoi(argv[i]+2); | |
169 | if (hwunit <= 0 || hwunit > 32) | |
170 | usage(); | |
171 | } else if (argv[i][0] == '-') { | |
172 | iunit = atoi(argv[i]+1); | |
173 | if(iunit <= 0 || iunit > 32) | |
174 | usage(); | |
175 | } else { | |
176 | if (ifilct == MAXIFILES) { | |
177 | fprintf(stderr, _("setfont: too many input files\n")); | |
178 | exit(EX_USAGE); | |
179 | } | |
180 | ifiles[ifilct++] = argv[i]; | |
181 | } | |
127 | if (!strcmp(argv[i], "-V")) { | |
128 | print_version_and_exit(); | |
129 | } else if (!strcmp(argv[i], "-v")) { | |
130 | verbose++; | |
131 | } else if (!strcmp(argv[i], "-R")) { | |
132 | restore = 1; | |
133 | } else if (!strcmp(argv[i], "-C")) { | |
134 | if (++i == argc || console) | |
135 | usage(); | |
136 | console = argv[i]; | |
137 | } else if (!strcmp(argv[i], "-O")) { | |
138 | if (++i == argc || Ofil) | |
139 | usage(); | |
140 | Ofil = argv[i]; | |
141 | } else if (!strcmp(argv[i], "-o")) { | |
142 | if (++i == argc || ofil) | |
143 | usage(); | |
144 | ofil = argv[i]; | |
145 | } else if (!strcmp(argv[i], "-om")) { | |
146 | if (++i == argc || omfil) | |
147 | usage(); | |
148 | omfil = argv[i]; | |
149 | } else if (!strcmp(argv[i], "-ou")) { | |
150 | if (++i == argc || oufil) | |
151 | usage(); | |
152 | oufil = argv[i]; | |
153 | } else if (!strcmp(argv[i], "-m")) { | |
154 | if (++i == argc || mfil) | |
155 | usage(); | |
156 | if (!strcmp(argv[i], "none")) | |
157 | no_m = 1; | |
158 | else | |
159 | mfil = argv[i]; | |
160 | } else if (!strcmp(argv[i], "-u")) { | |
161 | if (++i == argc || ufil) | |
162 | usage(); | |
163 | if (!strcmp(argv[i], "none")) | |
164 | no_u = 1; | |
165 | else | |
166 | ufil = argv[i]; | |
167 | } else if (!strcmp(argv[i], "-f")) { | |
168 | force = 1; | |
169 | } else if (!strncmp(argv[i], "-h", 2)) { | |
170 | hwunit = atoi(argv[i] + 2); | |
171 | if (hwunit <= 0 || hwunit > 32) | |
172 | usage(); | |
173 | } else if (argv[i][0] == '-') { | |
174 | iunit = atoi(argv[i] + 1); | |
175 | if (iunit <= 0 || iunit > 32) | |
176 | usage(); | |
177 | } else { | |
178 | if (ifilct == MAXIFILES) { | |
179 | fprintf(stderr, _("setfont: too many input files\n")); | |
180 | exit(EX_USAGE); | |
181 | } | |
182 | ifiles[ifilct++] = argv[i]; | |
183 | } | |
182 | 184 | } |
183 | 185 | |
184 | 186 | if (ifilct && restore) { |
185 | fprintf(stderr, _("setfont: cannot both restore from character ROM" | |
186 | " and from file. Font unchanged.\n")); | |
187 | exit(EX_USAGE); | |
187 | fprintf(stderr, _("setfont: cannot both restore from character ROM" | |
188 | " and from file. Font unchanged.\n")); | |
189 | exit(EX_USAGE); | |
188 | 190 | } |
189 | 191 | |
190 | 192 | if ((fd = getfd(console)) < 0) |
191 | 193 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
192 | 194 | |
193 | 195 | int kd_mode = -1; |
194 | if (!ioctl(fd, KDGETMODE, &kd_mode) && (kd_mode == KD_GRAPHICS)) | |
195 | { | |
196 | /* | |
197 | * PIO_FONT will fail on a console which is in foreground and in KD_GRAPHICS mode. | |
198 | * 2005-03-03, jw@suse.de. | |
199 | */ | |
200 | if (verbose) | |
201 | printf("setfont: graphics console %s skipped\n", console?console:""); | |
202 | close(fd); | |
203 | return 0; | |
204 | } | |
196 | if (!ioctl(fd, KDGETMODE, &kd_mode) && (kd_mode == KD_GRAPHICS)) { | |
197 | /* | |
198 | * PIO_FONT will fail on a console which is in foreground and in KD_GRAPHICS mode. | |
199 | * 2005-03-03, jw@suse.de. | |
200 | */ | |
201 | if (verbose) | |
202 | printf("setfont: graphics console %s skipped\n", console ? console : ""); | |
203 | close(fd); | |
204 | return 0; | |
205 | } | |
205 | 206 | |
206 | 207 | if (!ifilct && !mfil && !ufil && |
207 | 208 | !Ofil && !ofil && !omfil && !oufil && !restore) |
208 | /* reset to some default */ | |
209 | ifiles[ifilct++] = ""; | |
209 | /* reset to some default */ | |
210 | ifiles[ifilct++] = ""; | |
210 | 211 | |
211 | 212 | if (Ofil) |
212 | saveoldfontplusunicodemap(fd, Ofil); | |
213 | saveoldfontplusunicodemap(fd, Ofil); | |
213 | 214 | |
214 | 215 | if (ofil) |
215 | saveoldfont(fd, ofil); | |
216 | saveoldfont(fd, ofil); | |
216 | 217 | |
217 | 218 | if (omfil) |
218 | saveoldmap(fd, omfil); | |
219 | saveoldmap(fd, omfil); | |
219 | 220 | |
220 | 221 | if (oufil) |
221 | saveunicodemap(fd, oufil); | |
222 | saveunicodemap(fd, oufil); | |
222 | 223 | |
223 | 224 | if (mfil) { |
224 | loadnewmap(fd, mfil); | |
225 | activatemap(fd); | |
226 | no_m = 1; | |
225 | loadnewmap(fd, mfil); | |
226 | activatemap(fd); | |
227 | no_m = 1; | |
227 | 228 | } |
228 | 229 | |
229 | 230 | if (ufil) |
230 | no_u = 1; | |
231 | no_u = 1; | |
231 | 232 | |
232 | 233 | if (restore) |
233 | restorefont(fd); | |
234 | restorefont(fd); | |
234 | 235 | |
235 | 236 | if (ifilct) |
236 | loadnewfonts(fd, ifiles, ifilct, iunit, hwunit, no_m, no_u); | |
237 | loadnewfonts(fd, ifiles, ifilct, iunit, hwunit, no_m, no_u); | |
237 | 238 | |
238 | 239 | if (ufil) |
239 | loadunicodemap(fd, ufil); | |
240 | loadunicodemap(fd, ufil); | |
240 | 241 | |
241 | 242 | return 0; |
242 | 243 | } |
248 | 249 | |
249 | 250 | static void |
250 | 251 | do_loadfont(int fd, char *inbuf, int width, int height, int hwunit, |
251 | int fontsize, char *filename) { | |
252 | int fontsize, char *filename) | |
253 | { | |
252 | 254 | unsigned char *buf; |
253 | 255 | int i, buflen; |
254 | int bytewidth = (width+7)/8; | |
255 | int charsize = height * bytewidth; | |
256 | int kcharsize = 32 * bytewidth; | |
256 | int bytewidth = (width + 7) / 8; | |
257 | int charsize = height * bytewidth; | |
258 | int kcharsize = 32 * bytewidth; | |
257 | 259 | int bad_video_erase_char = 0; |
258 | 260 | |
259 | 261 | if (height < 1 || height > 32) { |
269 | 271 | hwunit = height; |
270 | 272 | |
271 | 273 | buflen = kcharsize * ((fontsize < 128) ? 128 : fontsize); |
272 | buf = xmalloc(buflen); | |
273 | memset(buf,0,buflen); | |
274 | buf = xmalloc(buflen); | |
275 | memset(buf, 0, buflen); | |
274 | 276 | |
275 | 277 | for (i = 0; i < fontsize; i++) |
276 | memcpy(buf+(i*kcharsize), inbuf+(i*charsize), charsize); | |
278 | memcpy(buf + (i * kcharsize), inbuf + (i * charsize), charsize); | |
277 | 279 | |
278 | 280 | /* |
279 | 281 | * Due to a kernel bug, font position 32 is used |
282 | 284 | */ |
283 | 285 | if (erase_mode) { |
284 | 286 | for (i = 0; i < kcharsize; i++) |
285 | if (buf[32*kcharsize+i]) | |
287 | if (buf[32 * kcharsize + i]) | |
286 | 288 | bad_video_erase_char = 1; |
287 | 289 | if (bad_video_erase_char) { |
288 | 290 | fprintf(stderr, |
289 | _("%s: font position 32 is nonblank\n"), | |
290 | progname); | |
291 | switch(erase_mode) { | |
292 | case 3: | |
293 | exit(EX_DATAERR); | |
294 | case 2: | |
295 | for (i = 0; i < kcharsize; i++) | |
296 | buf[32*kcharsize+i] = 0; | |
297 | fprintf(stderr, _("%s: wiped it\n"), progname); | |
298 | break; | |
299 | case 1: | |
300 | fprintf(stderr, | |
301 | _("%s: background will look funny\n"), | |
302 | progname); | |
291 | _("%s: font position 32 is nonblank\n"), | |
292 | progname); | |
293 | switch (erase_mode) { | |
294 | case 3: | |
295 | exit(EX_DATAERR); | |
296 | case 2: | |
297 | for (i = 0; i < kcharsize; i++) | |
298 | buf[32 * kcharsize + i] = 0; | |
299 | fprintf(stderr, _("%s: wiped it\n"), progname); | |
300 | break; | |
301 | case 1: | |
302 | fprintf(stderr, | |
303 | _("%s: background will look funny\n"), | |
304 | progname); | |
303 | 305 | } |
304 | 306 | fflush(stderr); |
305 | 307 | sleep(2); |
326 | 328 | } |
327 | 329 | |
328 | 330 | static void |
329 | do_loadtable(int fd, struct unicode_list *uclistheads, int fontsize) { | |
331 | do_loadtable(int fd, struct unicode_list *uclistheads, int fontsize) | |
332 | { | |
330 | 333 | struct unimapdesc ud; |
331 | 334 | struct unipair *up; |
332 | 335 | int i, ct = 0, maxct; |
336 | 339 | maxct = 0; |
337 | 340 | for (i = 0; i < fontsize; i++) { |
338 | 341 | ul = uclistheads[i].next; |
339 | while(ul) { | |
342 | while (ul) { | |
340 | 343 | us = ul->seq; |
341 | if (us && ! us->next) | |
344 | if (us && !us->next) | |
342 | 345 | maxct++; |
343 | 346 | ul = ul->next; |
344 | 347 | } |
346 | 349 | up = xmalloc(maxct * sizeof(struct unipair)); |
347 | 350 | for (i = 0; i < fontsize; i++) { |
348 | 351 | ul = uclistheads[i].next; |
349 | if (debug) printf ("char %03x:", i); | |
350 | while(ul) { | |
352 | if (debug) | |
353 | printf("char %03x:", i); | |
354 | while (ul) { | |
351 | 355 | us = ul->seq; |
352 | if (us && ! us->next) { | |
356 | if (us && !us->next) { | |
353 | 357 | up[ct].unicode = us->uc; |
354 | 358 | up[ct].fontpos = i; |
355 | 359 | ct++; |
356 | if (debug) printf (" %04x", us->uc); | |
360 | if (debug) | |
361 | printf(" %04x", us->uc); | |
362 | } else if (debug) { | |
363 | printf(" seq: <"); | |
364 | while (us) { | |
365 | printf(" %04x", us->uc); | |
366 | us = us->next; | |
367 | } | |
368 | printf(" >"); | |
357 | 369 | } |
358 | else | |
359 | if (debug) { | |
360 | printf (" seq: <"); | |
361 | while (us) { | |
362 | printf (" %04x", us->uc); | |
363 | us = us->next; | |
364 | } | |
365 | printf (" >"); | |
366 | } | |
367 | 370 | ul = ul->next; |
368 | if (debug) printf (","); | |
369 | } | |
370 | if (debug) printf ("\n"); | |
371 | if (debug) | |
372 | printf(","); | |
373 | } | |
374 | if (debug) | |
375 | printf("\n"); | |
371 | 376 | } |
372 | 377 | if (ct != maxct) { |
373 | 378 | char *u = _("%s: bug in do_loadtable\n"); |
376 | 381 | } |
377 | 382 | |
378 | 383 | if (verbose) |
379 | printf(_("Loading Unicode mapping table...\n")); | |
384 | printf(_("Loading Unicode mapping table...\n")); | |
380 | 385 | |
381 | 386 | ud.entry_ct = ct; |
382 | ud.entries = up; | |
387 | ud.entries = up; | |
383 | 388 | if (loadunimap(fd, NULL, &ud)) |
384 | 389 | exit(EX_OSERR); |
385 | 390 | } |
386 | 391 | |
387 | 392 | static void |
388 | 393 | loadnewfonts(int fd, char **ifiles, int ifilct, |
389 | int iunit, int hwunit, int no_m, int no_u) | |
394 | int iunit, int hwunit, int no_m, int no_u) | |
390 | 395 | { |
391 | 396 | char *ifil, *inbuf, *fontbuf, *bigfontbuf; |
392 | 397 | int inputlth, fontbuflth, fontsize, height, width, bytewidth; |
402 | 407 | |
403 | 408 | /* several fonts that must be merged */ |
404 | 409 | /* We just concatenate the bitmaps - only allow psf fonts */ |
405 | bigfontbuf = NULL; | |
410 | bigfontbuf = NULL; | |
406 | 411 | bigfontbuflth = 0; |
407 | bigfontsize = 0; | |
408 | uclistheads = NULL; | |
409 | bigheight = 0; | |
410 | bigwidth = 0; | |
411 | ||
412 | for (i=0; i<ifilct; i++) { | |
412 | bigfontsize = 0; | |
413 | uclistheads = NULL; | |
414 | bigheight = 0; | |
415 | bigwidth = 0; | |
416 | ||
417 | for (i = 0; i < ifilct; i++) { | |
413 | 418 | ifil = ifiles[i]; |
414 | 419 | if (findfont(ifil, &fp) && findpartialfont(ifil, &fp)) { |
415 | 420 | fprintf(stderr, _("Cannot open font file %s\n"), ifil); |
418 | 423 | |
419 | 424 | inbuf = fontbuf = NULL; |
420 | 425 | inputlth = fontbuflth = 0; |
421 | fontsize = 0; | |
422 | ||
423 | if(readpsffont(fp.fd, &inbuf, &inputlth, &fontbuf, &fontbuflth, | |
424 | &width, &fontsize, bigfontsize, | |
425 | no_u ? NULL : &uclistheads)) { | |
426 | fontsize = 0; | |
427 | ||
428 | if (readpsffont(fp.fd, &inbuf, &inputlth, &fontbuf, &fontbuflth, | |
429 | &width, &fontsize, bigfontsize, | |
430 | no_u ? NULL : &uclistheads)) { | |
426 | 431 | fprintf(stderr, _("When loading several fonts, all " |
427 | "must be psf fonts - %s isn't\n"), | |
428 | fp.pathname); | |
432 | "must be psf fonts - %s isn't\n"), | |
433 | fp.pathname); | |
429 | 434 | lk_fpclose(&fp); |
430 | 435 | exit(EX_DATAERR); |
431 | 436 | } |
432 | lk_fpclose(&fp); // avoid zombies, jw@suse.de (#88501) | |
433 | bytewidth = (width+7) / 8; | |
434 | height = fontbuflth / (bytewidth * fontsize); | |
437 | lk_fpclose(&fp); // avoid zombies, jw@suse.de (#88501) | |
438 | bytewidth = (width + 7) / 8; | |
439 | height = fontbuflth / (bytewidth * fontsize); | |
435 | 440 | if (verbose) |
436 | 441 | printf(_("Read %d-char %dx%d font from file %s\n"), |
437 | 442 | fontsize, width, height, fp.pathname); |
440 | 445 | bigheight = height; |
441 | 446 | else if (bigheight != height) { |
442 | 447 | fprintf(stderr, _("When loading several fonts, all " |
443 | "must have the same height\n")); | |
448 | "must have the same height\n")); | |
444 | 449 | exit(EX_DATAERR); |
445 | 450 | } |
446 | 451 | if (bigwidth == 0) |
447 | 452 | bigwidth = width; |
448 | 453 | else if (bigwidth != width) { |
449 | 454 | fprintf(stderr, _("When loading several fonts, all " |
450 | "must have the same width\n")); | |
455 | "must have the same width\n")); | |
451 | 456 | exit(EX_DATAERR); |
452 | 457 | } |
453 | 458 | |
454 | 459 | bigfontsize += fontsize; |
455 | 460 | bigfontbuflth += fontbuflth; |
456 | 461 | bigfontbuf = xrealloc(bigfontbuf, bigfontbuflth); |
457 | memcpy(bigfontbuf+bigfontbuflth-fontbuflth, | |
462 | memcpy(bigfontbuf + bigfontbuflth - fontbuflth, | |
458 | 463 | fontbuf, fontbuflth); |
459 | 464 | } |
460 | 465 | do_loadfont(fd, bigfontbuf, bigwidth, bigheight, hwunit, |
461 | bigfontsize, NULL); | |
466 | bigfontsize, NULL); | |
462 | 467 | free(bigfontbuf); |
463 | 468 | |
464 | 469 | if (uclistheads && !no_u) |
478 | 483 | if (!*ifil) { |
479 | 484 | /* try to find some default file */ |
480 | 485 | |
481 | def = 1; /* maybe also load default unimap */ | |
486 | def = 1; /* maybe also load default unimap */ | |
482 | 487 | |
483 | 488 | if (iunit < 0 || iunit > 32) |
484 | 489 | iunit = 0; |
510 | 515 | |
511 | 516 | inbuf = fontbuf = NULL; |
512 | 517 | inputlth = fontbuflth = fontsize = 0; |
513 | width = 8; | |
514 | uclistheads = NULL; | |
515 | if(readpsffont(fp.fd, &inbuf, &inputlth, &fontbuf, &fontbuflth, | |
516 | &width, &fontsize, 0, | |
517 | no_u ? NULL : &uclistheads) == 0) { | |
518 | width = 8; | |
519 | uclistheads = NULL; | |
520 | if (readpsffont(fp.fd, &inbuf, &inputlth, &fontbuf, &fontbuflth, | |
521 | &width, &fontsize, 0, | |
522 | no_u ? NULL : &uclistheads) == 0) { | |
518 | 523 | lk_fpclose(&fp); |
519 | 524 | /* we've got a psf font */ |
520 | bytewidth = (width+7) / 8; | |
521 | height = fontbuflth / (bytewidth * fontsize); | |
525 | bytewidth = (width + 7) / 8; | |
526 | height = fontbuflth / (bytewidth * fontsize); | |
522 | 527 | |
523 | 528 | do_loadfont(fd, fontbuf, width, height, hwunit, |
524 | fontsize, fp.pathname); | |
529 | fontsize, fp.pathname); | |
525 | 530 | if (uclistheads && !no_u) |
526 | 531 | do_loadtable(fd, uclistheads, fontsize); |
527 | 532 | #if 1 |
530 | 535 | #endif |
531 | 536 | return; |
532 | 537 | } |
533 | lk_fpclose(&fp); // avoid zombies, jw@suse.de (#88501) | |
538 | lk_fpclose(&fp); // avoid zombies, jw@suse.de (#88501) | |
534 | 539 | |
535 | 540 | /* instructions to combine fonts? */ |
536 | { char *combineheader = "# combine partial fonts\n"; | |
537 | int chlth = strlen(combineheader); | |
538 | char *p, *q; | |
539 | if (inputlth >= chlth && !strncmp(inbuf, combineheader, chlth)) { | |
540 | char *ifiles[MAXIFILES]; | |
541 | int ifilct = 0; | |
542 | q = inbuf + chlth; | |
543 | while(q < inbuf + inputlth) { | |
544 | p = q; | |
545 | while (q < inbuf+inputlth && *q != '\n') | |
546 | q++; | |
547 | if (q == inbuf+inputlth) { | |
548 | fprintf(stderr, | |
549 | _("No final newline in combine file\n")); | |
550 | exit(EX_DATAERR); | |
551 | } | |
552 | *q++ = 0; | |
553 | if (ifilct == MAXIFILES) { | |
554 | fprintf(stderr, | |
555 | _("Too many files to combine\n")); | |
556 | exit(EX_DATAERR); | |
557 | } | |
558 | ifiles[ifilct++] = p; | |
559 | } | |
560 | /* recursive call */ | |
561 | loadnewfonts(fd, ifiles, ifilct, iunit, hwunit, no_m, no_u); | |
562 | return; | |
563 | } | |
541 | { | |
542 | char *combineheader = "# combine partial fonts\n"; | |
543 | int chlth = strlen(combineheader); | |
544 | char *p, *q; | |
545 | if (inputlth >= chlth && !strncmp(inbuf, combineheader, chlth)) { | |
546 | char *ifiles[MAXIFILES]; | |
547 | int ifilct = 0; | |
548 | q = inbuf + chlth; | |
549 | while (q < inbuf + inputlth) { | |
550 | p = q; | |
551 | while (q < inbuf + inputlth && *q != '\n') | |
552 | q++; | |
553 | if (q == inbuf + inputlth) { | |
554 | fprintf(stderr, | |
555 | _("No final newline in combine file\n")); | |
556 | exit(EX_DATAERR); | |
557 | } | |
558 | *q++ = 0; | |
559 | if (ifilct == MAXIFILES) { | |
560 | fprintf(stderr, | |
561 | _("Too many files to combine\n")); | |
562 | exit(EX_DATAERR); | |
563 | } | |
564 | ifiles[ifilct++] = p; | |
565 | } | |
566 | /* recursive call */ | |
567 | loadnewfonts(fd, ifiles, ifilct, iunit, hwunit, no_m, no_u); | |
568 | return; | |
569 | } | |
564 | 570 | } |
565 | 571 | |
566 | 572 | /* file with three code pages? */ |
567 | 573 | if (inputlth == 9780) { |
568 | offset = position_codepage(iunit); | |
569 | height = iunit; | |
574 | offset = position_codepage(iunit); | |
575 | height = iunit; | |
570 | 576 | fontsize = 256; |
571 | width = 8; | |
577 | width = 8; | |
572 | 578 | } else if (inputlth == 32768) { |
573 | 579 | /* restorefont -w writes a SVGA font to file |
574 | 580 | restorefont -r restores it |
577 | 583 | and it always is, there is no default font that is saved, |
578 | 584 | so probably the second half is always garbage. */ |
579 | 585 | fprintf(stderr, _("Hmm - a font from restorefont? " |
580 | "Using the first half.\n")); | |
581 | inputlth = 16384; /* ignore rest */ | |
586 | "Using the first half.\n")); | |
587 | inputlth = 16384; /* ignore rest */ | |
582 | 588 | fontsize = 512; |
583 | offset = 0; | |
584 | width = 8; | |
585 | height = 32; | |
589 | offset = 0; | |
590 | width = 8; | |
591 | height = 32; | |
586 | 592 | if (!hwunit) |
587 | 593 | hwunit = 16; |
588 | 594 | } else { |
597 | 603 | exit(EX_DATAERR); |
598 | 604 | } |
599 | 605 | fontsize = 256; |
600 | width = 8; | |
601 | height = inputlth/256; | |
602 | } | |
603 | do_loadfont(fd, inbuf+offset, width, height, hwunit, fontsize, | |
604 | fp.pathname); | |
606 | width = 8; | |
607 | height = inputlth / 256; | |
608 | } | |
609 | do_loadfont(fd, inbuf + offset, width, height, hwunit, fontsize, | |
610 | fp.pathname); | |
605 | 611 | } |
606 | 612 | |
607 | 613 | static int |
608 | position_codepage(int iunit) { | |
609 | int offset; | |
614 | position_codepage(int iunit) | |
615 | { | |
616 | int offset; | |
610 | 617 | |
611 | 618 | /* code page: first 40 bytes, then 8x16 font, |
612 | 619 | then 6 bytes, then 8x14 font, |
613 | 620 | then 6 bytes, then 8x8 font */ |
614 | 621 | |
615 | 622 | if (!iunit) { |
616 | fprintf(stderr, | |
617 | _("This file contains 3 fonts: 8x8, 8x14 and 8x16." | |
618 | " Please indicate\n" | |
619 | "using an option -8 or -14 or -16 " | |
620 | "which one you want loaded.\n")); | |
621 | exit(EX_USAGE); | |
623 | fprintf(stderr, | |
624 | _("This file contains 3 fonts: 8x8, 8x14 and 8x16." | |
625 | " Please indicate\n" | |
626 | "using an option -8 or -14 or -16 " | |
627 | "which one you want loaded.\n")); | |
628 | exit(EX_USAGE); | |
622 | 629 | } |
623 | 630 | switch (iunit) { |
624 | case 8: | |
625 | offset = 7732; break; | |
626 | case 14: | |
627 | offset = 4142; break; | |
628 | case 16: | |
629 | offset = 40; break; | |
630 | default: | |
631 | fprintf(stderr, _("You asked for font size %d, " | |
632 | "but only 8, 14, 16 are possible here.\n"), | |
633 | iunit); | |
634 | exit(EX_USAGE); | |
631 | case 8: | |
632 | offset = 7732; | |
633 | break; | |
634 | case 14: | |
635 | offset = 4142; | |
636 | break; | |
637 | case 16: | |
638 | offset = 40; | |
639 | break; | |
640 | default: | |
641 | fprintf(stderr, _("You asked for font size %d, " | |
642 | "but only 8, 14, 16 are possible here.\n"), | |
643 | iunit); | |
644 | exit(EX_USAGE); | |
635 | 645 | } |
636 | 646 | return offset; |
637 | 647 | } |
638 | 648 | |
639 | 649 | static void |
640 | 650 | do_saveoldfont(int fd, char *ofil, FILE *fpo, int unimap_follows, |
641 | int *count, int *utf8) { | |
651 | int *count, int *utf8) | |
652 | { | |
642 | 653 | |
643 | 654 | /* this is the max font size the kernel is willing to handle */ |
644 | #define MAXFONTSIZE 65536 | |
655 | #define MAXFONTSIZE 65536 | |
645 | 656 | unsigned char buf[MAXFONTSIZE]; |
646 | 657 | |
647 | 658 | int i, ct, width, height, bytewidth, charsize, kcharsize; |
648 | 659 | |
649 | ct = sizeof(buf)/(32*32/8); /* max size 32x32, 8 bits/byte */ | |
660 | ct = sizeof(buf) / (32 * 32 / 8); /* max size 32x32, 8 bits/byte */ | |
650 | 661 | if (getfont(fd, buf, &ct, &width, &height)) |
651 | 662 | exit(EX_OSERR); |
652 | 663 | |
653 | 664 | /* save as efficiently as possible */ |
654 | 665 | bytewidth = (width + 7) / 8; |
655 | height = font_charheight(buf, ct, width); | |
656 | charsize = height * bytewidth; | |
666 | height = font_charheight(buf, ct, width); | |
667 | charsize = height * bytewidth; | |
657 | 668 | kcharsize = 32 * bytewidth; |
658 | 669 | |
659 | /* Do we need a psf header? */ | |
660 | /* Yes if ct==512 - otherwise we cannot distinguish | |
670 | /* Do we need a psf header? */ | |
671 | /* Yes if ct==512 - otherwise we cannot distinguish | |
661 | 672 | a 512-char 8x8 and a 256-char 8x16 font. */ |
662 | #define ALWAYS_PSF_HEADER 1 | |
673 | #define ALWAYS_PSF_HEADER 1 | |
663 | 674 | |
664 | 675 | if (ct != 256 || width != 8 || unimap_follows || ALWAYS_PSF_HEADER) { |
665 | 676 | int psftype = 1; |
666 | int flags = 0; | |
677 | int flags = 0; | |
667 | 678 | |
668 | 679 | if (unimap_follows) |
669 | 680 | flags |= WPSFH_HASTAB; |
670 | writepsffontheader (fpo, width, height, ct, &psftype, flags); | |
681 | writepsffontheader(fpo, width, height, ct, &psftype, flags); | |
671 | 682 | if (utf8) |
672 | 683 | *utf8 = (psftype == 2); |
673 | 684 | } |
676 | 687 | fprintf(stderr, _("Found nothing to save\n")); |
677 | 688 | } else { |
678 | 689 | for (i = 0; i < ct; i++) { |
679 | if (fwrite(buf+(i*kcharsize), charsize, 1, fpo) != 1) { | |
690 | if (fwrite(buf + (i * kcharsize), charsize, 1, fpo) != 1) { | |
680 | 691 | fprintf(stderr, _("Cannot write font file")); |
681 | 692 | exit(EX_IOERR); |
682 | 693 | } |
692 | 703 | } |
693 | 704 | |
694 | 705 | static void |
695 | saveoldfont(int fd, char *ofil) { | |
696 | FILE *fpo; | |
697 | ||
698 | if((fpo = fopen(ofil, "w")) == NULL) { | |
699 | perror(ofil); | |
700 | exit(EX_CANTCREAT); | |
701 | } | |
702 | do_saveoldfont(fd, ofil, fpo, 0, NULL, NULL); | |
703 | fclose(fpo); | |
706 | saveoldfont(int fd, char *ofil) | |
707 | { | |
708 | FILE *fpo; | |
709 | ||
710 | if ((fpo = fopen(ofil, "w")) == NULL) { | |
711 | perror(ofil); | |
712 | exit(EX_CANTCREAT); | |
713 | } | |
714 | do_saveoldfont(fd, ofil, fpo, 0, NULL, NULL); | |
715 | fclose(fpo); | |
704 | 716 | } |
705 | 717 | |
706 | 718 | static void |
707 | saveoldfontplusunicodemap(int fd, char *Ofil) { | |
708 | FILE *fpo; | |
709 | int ct; | |
710 | int utf8 = 0; | |
711 | ||
712 | if((fpo = fopen(Ofil, "w")) == NULL) { | |
713 | perror(Ofil); | |
714 | exit(EX_CANTCREAT); | |
715 | } | |
716 | ct = 0; | |
717 | do_saveoldfont(fd, Ofil, fpo, 1, &ct, &utf8); | |
718 | appendunicodemap(fd, fpo, ct, utf8); | |
719 | fclose(fpo); | |
719 | saveoldfontplusunicodemap(int fd, char *Ofil) | |
720 | { | |
721 | FILE *fpo; | |
722 | int ct; | |
723 | int utf8 = 0; | |
724 | ||
725 | if ((fpo = fopen(Ofil, "w")) == NULL) { | |
726 | perror(Ofil); | |
727 | exit(EX_CANTCREAT); | |
728 | } | |
729 | ct = 0; | |
730 | do_saveoldfont(fd, Ofil, fpo, 1, &ct, &utf8); | |
731 | appendunicodemap(fd, fpo, ct, utf8); | |
732 | fclose(fpo); | |
720 | 733 | } |
721 | 734 | |
722 | 735 | /* Only on the current console? On all allocated consoles? */ |
726 | 739 | /* For the moment: only the current console, only the G0 set */ |
727 | 740 | |
728 | 741 | static void |
729 | send_escseq(int fd, char *seq, int n) { | |
730 | if (write(fd, seq, n) != n) /* maybe fd is read-only */ | |
742 | send_escseq(int fd, char *seq, int n) | |
743 | { | |
744 | if (write(fd, seq, n) != n) /* maybe fd is read-only */ | |
731 | 745 | printf("%s", seq); |
732 | 746 | } |
733 | 747 | |
734 | void | |
735 | activatemap(int fd) { | |
748 | void activatemap(int fd) | |
749 | { | |
736 | 750 | send_escseq(fd, "\033(K", 3); |
737 | 751 | } |
738 | 752 | |
739 | void | |
740 | disactivatemap(int fd) { | |
753 | void disactivatemap(int fd) | |
754 | { | |
741 | 755 | send_escseq(fd, "\033(B", 3); |
742 | 756 | } |
17 | 17 | #include "version.h" |
18 | 18 | #include "kbd_error.h" |
19 | 19 | |
20 | static void __attribute__ ((noreturn)) | |
21 | usage(char *s) { | |
20 | static void __attribute__((noreturn)) | |
21 | usage(char *s) | |
22 | { | |
22 | 23 | fprintf(stderr, "setkeycode: %s\n", s); |
23 | 24 | fprintf(stderr, _( |
24 | "usage: setkeycode scancode keycode ...\n" | |
25 | " (where scancode is either xx or e0xx, given in hexadecimal,\n" | |
26 | " and keycode is given in decimal)\n")); | |
25 | "usage: setkeycode scancode keycode ...\n" | |
26 | " (where scancode is either xx or e0xx, given in hexadecimal,\n" | |
27 | " and keycode is given in decimal)\n")); | |
27 | 28 | exit(EXIT_FAILURE); |
28 | 29 | } |
29 | 30 | |
30 | int | |
31 | main(int argc, char **argv) { | |
31 | int main(int argc, char **argv) | |
32 | { | |
32 | 33 | char *ep; |
33 | 34 | int fd; |
34 | 35 | struct kbkeycode a; |
49 | 50 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
50 | 51 | |
51 | 52 | while (argc > 2) { |
52 | a.keycode = atoi(argv[2]); | |
53 | a.keycode = atoi(argv[2]); | |
53 | 54 | a.scancode = strtol(argv[1], &ep, 16); |
54 | 55 | if (*ep) |
55 | 56 | usage(_("error reading scancode")); |
56 | 57 | if (a.scancode >= 0xe000) { |
57 | 58 | a.scancode -= 0xe000; |
58 | a.scancode += 128; /* some kernels needed +256 */ | |
59 | a.scancode += 128; /* some kernels needed +256 */ | |
59 | 60 | } |
60 | 61 | #if 0 |
61 | 62 | /* Test is OK up to 2.5.31--later kernels have more keycodes */ |
67 | 68 | (a.scancode > 255 || a.keycode > 239) |
68 | 69 | but we can leave testing to the kernel. */ |
69 | 70 | #endif |
70 | if (ioctl(fd,KDSETKEYCODE,&a)) { | |
71 | if (ioctl(fd, KDSETKEYCODE, &a)) { | |
71 | 72 | kbd_error(EXIT_FAILURE, errno, |
72 | _("failed to set scancode %x to keycode %d: ioctl KDSETKEYCODE"), | |
73 | a.scancode, a.keycode); | |
73 | _("failed to set scancode %x to keycode %d: ioctl KDSETKEYCODE"), | |
74 | a.scancode, a.keycode); | |
74 | 75 | } |
75 | 76 | argc -= 2; |
76 | 77 | argv += 2; |
17 | 17 | #include "version.h" |
18 | 18 | #include "kbd_error.h" |
19 | 19 | |
20 | static void __attribute__ ((noreturn)) | |
20 | static void __attribute__((noreturn)) | |
21 | 21 | usage(void) |
22 | 22 | { |
23 | fprintf(stderr, _( | |
24 | "Usage:\n" | |
25 | " setleds [-v] [-L] [-D] [-F] [[+|-][ num | caps | scroll %s]]\n" | |
26 | "Thus,\n" | |
27 | " setleds +caps -num\n" | |
28 | "will set CapsLock, clear NumLock and leave ScrollLock unchanged.\n" | |
29 | "The settings before and after the change (if any) are reported\n" | |
30 | "when the -v option is given or when no change is requested.\n" | |
31 | "Normally, setleds influences the vt flag settings\n" | |
32 | "(and these are usually reflected in the leds).\n" | |
33 | "With -L, setleds only sets the leds, and leaves the flags alone.\n" | |
34 | "With -D, setleds sets both the flags and the default flags, so\n" | |
35 | "that a subsequent reset will not change the flags.\n" | |
36 | ), | |
23 | fprintf(stderr, _( | |
24 | "Usage:\n" | |
25 | " setleds [-v] [-L] [-D] [-F] [[+|-][ num | caps | scroll %s]]\n" | |
26 | "Thus,\n" | |
27 | " setleds +caps -num\n" | |
28 | "will set CapsLock, clear NumLock and leave ScrollLock unchanged.\n" | |
29 | "The settings before and after the change (if any) are reported\n" | |
30 | "when the -v option is given or when no change is requested.\n" | |
31 | "Normally, setleds influences the vt flag settings\n" | |
32 | "(and these are usually reflected in the leds).\n" | |
33 | "With -L, setleds only sets the leds, and leaves the flags alone.\n" | |
34 | "With -D, setleds sets both the flags and the default flags, so\n" | |
35 | "that a subsequent reset will not change the flags.\n"), | |
37 | 36 | #ifdef __sparc__ |
38 | "| compose " | |
39 | #else | |
40 | "" | |
41 | #endif | |
42 | ); | |
43 | exit(EXIT_FAILURE); | |
37 | "| compose " | |
38 | #else | |
39 | "" | |
40 | #endif | |
41 | ); | |
42 | exit(EXIT_FAILURE); | |
44 | 43 | } |
45 | 44 | |
46 | 45 | #define onoff(a) ((a) ? _("on ") : _("off")) |
47 | 46 | |
48 | 47 | /* report the bits, in the order seen on the (my) keyboard */ |
49 | #define LED_NLOCK 1 | |
48 | #define LED_NLOCK 1 | |
50 | 49 | #define LED_CMPOSE 2 |
51 | 50 | #define LED_SCRLCK 4 |
52 | #define LED_CLOCK 8 | |
53 | ||
54 | static void | |
55 | sunreport(int leds) { | |
51 | #define LED_CLOCK 8 | |
52 | ||
53 | static void | |
54 | sunreport(int leds) | |
55 | { | |
56 | 56 | printf("NumLock %s Compose %s ScrollLock %s CapsLock %s\n", |
57 | 57 | onoff(leds & LED_NLOCK), |
58 | 58 | onoff(leds & LED_CMPOSE), |
61 | 61 | } |
62 | 62 | |
63 | 63 | static void |
64 | report(int leds) { | |
65 | printf("NumLock %s CapsLock %s ScrollLock %s\n", | |
64 | report(int leds) | |
65 | { | |
66 | printf("NumLock %s CapsLock %s ScrollLock %s\n", | |
66 | 67 | onoff(leds & LED_NUM), |
67 | 68 | onoff(leds & LED_CAP), |
68 | 69 | onoff(leds & LED_SCR)); |
69 | 70 | } |
70 | 71 | |
71 | 72 | struct led { |
72 | char *name; | |
73 | int bit; | |
74 | int sunbit; | |
73 | char *name; | |
74 | int bit; | |
75 | int sunbit; | |
75 | 76 | } leds[] = { |
76 | { "scroll", LED_SCR, LED_SCRLCK }, | |
77 | { "num", LED_NUM, LED_NLOCK }, | |
78 | { "caps", LED_CAP, LED_CLOCK }, | |
77 | { "scroll", LED_SCR, LED_SCRLCK }, | |
78 | { "num", LED_NUM, LED_NLOCK }, | |
79 | { "caps", LED_CAP, LED_CLOCK }, | |
79 | 80 | #ifdef __sparc__ |
80 | { "compose", 0, LED_CMPOSE } | |
81 | { "compose", 0, LED_CMPOSE } | |
81 | 82 | #endif |
82 | 83 | }; |
83 | 84 | |
84 | 85 | static void |
85 | getleds(char *cur_leds) { | |
86 | if (ioctl(0, KDGETLED, cur_leds)) { | |
87 | kbd_error(EXIT_FAILURE, errno, _("Error reading current led setting. " | |
88 | "Maybe stdin is not a VT?: " | |
89 | "ioctl KDGETLED")); | |
90 | } | |
86 | getleds(char *cur_leds) | |
87 | { | |
88 | if (ioctl(0, KDGETLED, cur_leds)) { | |
89 | kbd_error(EXIT_FAILURE, errno, _("Error reading current led setting. " | |
90 | "Maybe stdin is not a VT?: " | |
91 | "ioctl KDGETLED")); | |
92 | } | |
91 | 93 | } |
92 | 94 | |
93 | 95 | static int |
94 | setleds(char cur_leds) { | |
95 | if (ioctl(0, KDSETLED, cur_leds)) { | |
96 | kbd_warning(errno, "ioctl KDSETLED"); | |
97 | return -1; | |
98 | } | |
99 | return 0; | |
100 | } | |
101 | ||
102 | static void | |
103 | getflags(char *flags) { | |
104 | if (ioctl(0, KDGKBLED, flags)) { | |
105 | kbd_error(EXIT_FAILURE, errno, _("Error reading current flags setting. " | |
106 | "Maybe you are not on the console?: " | |
107 | "ioctl KDGKBLED")); | |
108 | } | |
96 | setleds(char cur_leds) | |
97 | { | |
98 | if (ioctl(0, KDSETLED, cur_leds)) { | |
99 | kbd_warning(errno, "ioctl KDSETLED"); | |
100 | return -1; | |
101 | } | |
102 | return 0; | |
103 | } | |
104 | ||
105 | static void | |
106 | getflags(char *flags) | |
107 | { | |
108 | if (ioctl(0, KDGKBLED, flags)) { | |
109 | kbd_error(EXIT_FAILURE, errno, _("Error reading current flags setting. " | |
110 | "Maybe you are not on the console?: " | |
111 | "ioctl KDGKBLED")); | |
112 | } | |
109 | 113 | } |
110 | 114 | |
111 | 115 | static int sunkbdfd = -1; |
112 | 116 | |
113 | 117 | #ifndef KIOCGLED |
114 | #define arg_state __attribute__ ((unused)) | |
118 | #define arg_state __attribute__((unused)) | |
115 | 119 | #else |
116 | 120 | #define arg_state |
117 | 121 | #endif |
118 | 122 | |
119 | 123 | static void |
120 | sungetleds(arg_state char *cur_leds) { | |
124 | sungetleds(arg_state char *cur_leds) | |
125 | { | |
121 | 126 | #ifdef KIOCGLED |
122 | if (ioctl(sunkbdfd, KIOCGLED, cur_leds)) { | |
123 | kbd_error(EXIT_FAILURE, errno, _("Error reading current led setting from /dev/kbd: " | |
124 | "ioctl KIOCGLED")); | |
125 | } | |
126 | #else | |
127 | kbd_error(EXIT_FAILURE, 0, _("KIOCGLED unavailable?\n")); | |
127 | if (ioctl(sunkbdfd, KIOCGLED, cur_leds)) { | |
128 | kbd_error(EXIT_FAILURE, errno, _("Error reading current led setting from /dev/kbd: " | |
129 | "ioctl KIOCGLED")); | |
130 | } | |
131 | #else | |
132 | kbd_error(EXIT_FAILURE, 0, _("KIOCGLED unavailable?\n")); | |
128 | 133 | #endif |
129 | 134 | } |
130 | 135 | |
131 | 136 | #ifndef KIOCSLED |
132 | #define arg_state __attribute__ ((unused)) | |
137 | #define arg_state __attribute__((unused)) | |
133 | 138 | #else |
134 | 139 | #define arg_state |
135 | 140 | #endif |
136 | 141 | |
137 | 142 | static void |
138 | sunsetleds(arg_state char *cur_leds) { | |
143 | sunsetleds(arg_state char *cur_leds) | |
144 | { | |
139 | 145 | #ifdef KIOCSLED |
140 | if (ioctl(sunkbdfd, KIOCSLED, cur_leds)) { | |
141 | kbd_error(EXIT_FAILURE, errno, _("Error reading current led setting from /dev/kbd: " | |
142 | "ioctl KIOCSLED")); | |
143 | } | |
144 | #else | |
145 | kbd_error(EXIT_FAILURE, 0, _("KIOCSLED unavailable?\n")); | |
146 | #endif | |
147 | } | |
148 | ||
149 | int | |
150 | main(int argc, char **argv) { | |
151 | int optL = 0, optD = 0, optF = 0, verbose = 0; | |
152 | char oleds, nleds, oflags, nflags, odefflags, ndefflags; | |
153 | char nval, ndef, sign; | |
154 | char osunleds = 0, nsunleds, nsunval, nsundef; | |
155 | char *ap; | |
156 | struct led *lp; | |
157 | ||
158 | set_progname(argv[0]); | |
159 | ||
160 | setlocale(LC_ALL, ""); | |
161 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
162 | textdomain(PACKAGE_NAME); | |
163 | ||
164 | if (argc == 2 && (!strcmp("-V", argv[1]) || !strcmp("--version", argv[1]))) | |
165 | print_version_and_exit(); | |
146 | if (ioctl(sunkbdfd, KIOCSLED, cur_leds)) { | |
147 | kbd_error(EXIT_FAILURE, errno, _("Error reading current led setting from /dev/kbd: " | |
148 | "ioctl KIOCSLED")); | |
149 | } | |
150 | #else | |
151 | kbd_error(EXIT_FAILURE, 0, _("KIOCSLED unavailable?\n")); | |
152 | #endif | |
153 | } | |
154 | ||
155 | int main(int argc, char **argv) | |
156 | { | |
157 | int optL = 0, optD = 0, optF = 0, verbose = 0; | |
158 | char oleds, nleds, oflags, nflags, odefflags, ndefflags; | |
159 | char nval, ndef, sign; | |
160 | char osunleds = 0, nsunleds, nsunval, nsundef; | |
161 | char *ap; | |
162 | struct led *lp; | |
163 | ||
164 | set_progname(argv[0]); | |
165 | ||
166 | setlocale(LC_ALL, ""); | |
167 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
168 | textdomain(PACKAGE_NAME); | |
169 | ||
170 | if (argc == 2 && (!strcmp("-V", argv[1]) || !strcmp("--version", argv[1]))) | |
171 | print_version_and_exit(); | |
166 | 172 | |
167 | 173 | #ifdef __sparc__ |
168 | if ((sunkbdfd = open("/dev/kbd", O_RDONLY)) < 0) { | |
169 | kbd_error(EXIT_FAILURE, errno, "open /dev/kbd"); | |
170 | /* exit(1); */ | |
171 | } | |
172 | #endif | |
173 | ||
174 | getflags(&oflags); | |
175 | getleds(&oleds); | |
176 | if (sunkbdfd >= 0) | |
177 | sungetleds(&osunleds); | |
178 | ||
179 | while (argc > 1) { | |
180 | if (!strcmp("-L", argv[1])) | |
181 | optL = 1; | |
182 | else if (!strcmp("-D", argv[1])) | |
183 | optD = 1; | |
184 | else if (!strcmp("-F", argv[1])) | |
185 | optF = 1; | |
186 | else if (!strcmp("-v", argv[1])) | |
187 | verbose = 1; | |
188 | else | |
189 | break; | |
190 | argc--; | |
191 | argv++; | |
192 | } | |
193 | ||
194 | odefflags = ndefflags = ((oflags >> 4) & 7); | |
195 | oflags = nflags = (oflags & 7); | |
196 | ||
197 | if (argc <= 1) { | |
174 | if ((sunkbdfd = open("/dev/kbd", O_RDONLY)) < 0) { | |
175 | kbd_error(EXIT_FAILURE, errno, "open /dev/kbd"); | |
176 | /* exit(1); */ | |
177 | } | |
178 | #endif | |
179 | ||
180 | getflags(&oflags); | |
181 | getleds(&oleds); | |
182 | if (sunkbdfd >= 0) | |
183 | sungetleds(&osunleds); | |
184 | ||
185 | while (argc > 1) { | |
186 | if (!strcmp("-L", argv[1])) | |
187 | optL = 1; | |
188 | else if (!strcmp("-D", argv[1])) | |
189 | optD = 1; | |
190 | else if (!strcmp("-F", argv[1])) | |
191 | optF = 1; | |
192 | else if (!strcmp("-v", argv[1])) | |
193 | verbose = 1; | |
194 | else | |
195 | break; | |
196 | argc--; | |
197 | argv++; | |
198 | } | |
199 | ||
200 | odefflags = ndefflags = ((oflags >> 4) & 7); | |
201 | oflags = nflags = (oflags & 7); | |
202 | ||
203 | if (argc <= 1) { | |
204 | if (optL) { | |
205 | nleds = 0xff; | |
206 | if (setleds(nleds)) { | |
207 | kbd_error(EXIT_FAILURE, 0, _("Error resetting ledmode\n")); | |
208 | } | |
209 | } | |
210 | ||
211 | /* If nothing to do, report, even if not verbose */ | |
212 | if (!optD && !optL && !optF) | |
213 | optD = optL = optF = 1; | |
214 | if (optD) { | |
215 | printf(_("Current default flags: ")); | |
216 | report(odefflags); | |
217 | } | |
218 | if (optF) { | |
219 | printf(_("Current flags: ")); | |
220 | report(oflags & 07); | |
221 | } | |
222 | if (optL) { | |
223 | printf(_("Current leds: ")); | |
224 | if (sunkbdfd >= 0) | |
225 | sunreport(osunleds); | |
226 | else | |
227 | report(oleds); | |
228 | } | |
229 | exit(EXIT_SUCCESS); | |
230 | } | |
231 | ||
232 | if (!optL) | |
233 | optF = 1; | |
234 | nval = 0; | |
235 | ndef = 0; | |
236 | nsunval = 0; | |
237 | nsundef = 0; | |
238 | ||
239 | while (--argc) { | |
240 | ap = *++argv; | |
241 | sign = 1; /* by default: set */ | |
242 | if (*ap == '+') | |
243 | ap++; | |
244 | else if (*ap == '-') { | |
245 | sign = 0; | |
246 | ap++; | |
247 | } | |
248 | for (lp = leds; (unsigned)(lp - leds) < sizeof(leds) / sizeof(leds[0]); lp++) { | |
249 | if (!strcmp(ap, lp->name)) { | |
250 | if (sign) { | |
251 | nval |= lp->bit; | |
252 | nsunval |= lp->sunbit; | |
253 | } | |
254 | ndef |= lp->bit; | |
255 | nsundef |= lp->sunbit; | |
256 | goto nxtarg; | |
257 | } | |
258 | } | |
259 | fprintf(stderr, _("unrecognized argument: _%s_\n\n"), ap); | |
260 | usage(); | |
261 | ||
262 | nxtarg:; | |
263 | } | |
264 | ||
265 | if (optD) { | |
266 | ndefflags = (odefflags & ~ndef) | nval; | |
267 | if (verbose) { | |
268 | printf(_("Old default flags: ")); | |
269 | report(odefflags); | |
270 | printf(_("New default flags: ")); | |
271 | report(ndefflags); | |
272 | } | |
273 | } | |
274 | if (optF) { | |
275 | nflags = ((oflags & ~ndef) | nval); | |
276 | if (verbose) { | |
277 | printf(_("Old flags: ")); | |
278 | report(oflags & 07); | |
279 | printf(_("New flags: ")); | |
280 | report(nflags & 07); | |
281 | } | |
282 | } | |
283 | if (optD || optF) { | |
284 | if (ioctl(0, KDSKBLED, (ndefflags << 4) | nflags)) { | |
285 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSKBLED"); | |
286 | } | |
287 | } | |
198 | 288 | if (optL) { |
199 | nleds = 0xff; | |
200 | if (setleds(nleds)) { | |
201 | kbd_error(EXIT_FAILURE, 0, _("Error resetting ledmode\n")); | |
202 | } | |
203 | } | |
204 | ||
205 | /* If nothing to do, report, even if not verbose */ | |
206 | if (!optD && !optL && !optF) | |
207 | optD = optL = optF = 1; | |
208 | if (optD) { | |
209 | printf(_("Current default flags: ")); | |
210 | report(odefflags); | |
211 | } | |
212 | if (optF) { | |
213 | printf(_("Current flags: ")); | |
214 | report(oflags & 07); | |
215 | } | |
216 | if (optL) { | |
217 | printf(_("Current leds: ")); | |
218 | if (sunkbdfd >= 0) | |
219 | sunreport(osunleds); | |
220 | else | |
221 | report(oleds); | |
289 | if (sunkbdfd >= 0) { | |
290 | nsunleds = (osunleds & ~nsundef) | nsunval; | |
291 | if (verbose) { | |
292 | printf(_("Old leds: ")); | |
293 | sunreport(osunleds); | |
294 | printf(_("New leds: ")); | |
295 | sunreport(nsunleds); | |
296 | } | |
297 | sunsetleds(&nsunleds); | |
298 | } else { | |
299 | nleds = (oleds & ~ndef) | nval; | |
300 | if (verbose) { | |
301 | printf(_("Old leds: ")); | |
302 | report(oleds); | |
303 | printf(_("New leds: ")); | |
304 | report(nleds); | |
305 | } | |
306 | if (setleds(nleds)) | |
307 | exit(EXIT_FAILURE); | |
308 | } | |
222 | 309 | } |
223 | 310 | exit(EXIT_SUCCESS); |
224 | } | |
225 | ||
226 | if (!optL) | |
227 | optF = 1; | |
228 | nval = 0; | |
229 | ndef = 0; | |
230 | nsunval = 0; | |
231 | nsundef = 0; | |
232 | ||
233 | while(--argc) { | |
234 | ap = *++argv; | |
235 | sign = 1; /* by default: set */ | |
236 | if(*ap == '+') | |
237 | ap++; | |
238 | else if(*ap == '-') { | |
239 | sign = 0; | |
240 | ap++; | |
241 | } | |
242 | for (lp = leds; (unsigned) (lp-leds) < sizeof(leds)/sizeof(leds[0]); lp++) { | |
243 | if(!strcmp(ap, lp->name)) { | |
244 | if(sign) { | |
245 | nval |= lp->bit; | |
246 | nsunval |= lp->sunbit; | |
247 | } | |
248 | ndef |= lp->bit; | |
249 | nsundef |= lp->sunbit; | |
250 | goto nxtarg; | |
251 | } | |
252 | } | |
253 | fprintf(stderr, _("unrecognized argument: _%s_\n\n"), ap); | |
254 | usage(); | |
255 | ||
256 | nxtarg: ; | |
257 | } | |
258 | ||
259 | if (optD) { | |
260 | ndefflags = (odefflags & ~ndef) | nval; | |
261 | if (verbose) { | |
262 | printf(_("Old default flags: ")); | |
263 | report(odefflags); | |
264 | printf(_("New default flags: ")); | |
265 | report(ndefflags); | |
266 | } | |
267 | } | |
268 | if (optF) { | |
269 | nflags = ((oflags & ~ndef) | nval); | |
270 | if (verbose) { | |
271 | printf(_("Old flags: ")); | |
272 | report(oflags & 07); | |
273 | printf(_("New flags: ")); | |
274 | report(nflags & 07); | |
275 | } | |
276 | } | |
277 | if (optD || optF) { | |
278 | if (ioctl(0, KDSKBLED, (ndefflags << 4) | nflags)) { | |
279 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSKBLED"); | |
280 | } | |
281 | } | |
282 | if (optL) { | |
283 | if (sunkbdfd >= 0) { | |
284 | nsunleds = (osunleds & ~nsundef) | nsunval; | |
285 | if (verbose) { | |
286 | printf(_("Old leds: ")); | |
287 | sunreport(osunleds); | |
288 | printf(_("New leds: ")); | |
289 | sunreport(nsunleds); | |
290 | } | |
291 | sunsetleds(&nsunleds); | |
292 | } else { | |
293 | nleds = (oleds & ~ndef) | nval; | |
294 | if (verbose) { | |
295 | printf(_("Old leds: ")); | |
296 | report(oleds); | |
297 | printf(_("New leds: ")); | |
298 | report(nleds); | |
299 | } | |
300 | if (setleds(nleds)) | |
301 | exit(EXIT_FAILURE); | |
302 | } | |
303 | } | |
304 | exit(EXIT_SUCCESS); | |
305 | } | |
311 | } |
16 | 16 | #include "nls.h" |
17 | 17 | #include "kbd_error.h" |
18 | 18 | |
19 | int | |
20 | main(int argc, char **argv){ | |
19 | int main(int argc, char **argv) | |
20 | { | |
21 | 21 | int fd, cons; |
22 | struct { char fn, subarg; } arg; | |
22 | struct { | |
23 | char fn, subarg; | |
24 | } arg; | |
23 | 25 | |
24 | 26 | setlocale(LC_ALL, ""); |
25 | 27 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); |
28 | 30 | if (argc == 2) |
29 | 31 | cons = atoi(argv[1]); |
30 | 32 | else |
31 | cons = 0; /* current console */ | |
33 | cons = 0; /* current console */ | |
32 | 34 | |
33 | 35 | if ((fd = getfd(NULL)) < 0) |
34 | 36 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
35 | 37 | |
36 | arg.fn = 11; /* redirect kernel messages */ | |
37 | arg.subarg = cons; /* to specified console */ | |
38 | arg.fn = 11; /* redirect kernel messages */ | |
39 | arg.subarg = cons; /* to specified console */ | |
38 | 40 | if (ioctl(fd, TIOCLINUX, &arg)) { |
39 | 41 | kbd_error(EXIT_FAILURE, errno, "TIOCLINUX"); |
40 | 42 | } |
16 | 16 | #include "version.h" |
17 | 17 | #include "kbd_error.h" |
18 | 18 | |
19 | static void __attribute__ ((noreturn)) | |
19 | static void __attribute__((noreturn)) | |
20 | 20 | usage(void) |
21 | 21 | { |
22 | fprintf(stderr, _( | |
23 | "Usage:\n" | |
24 | " setmetamode [ metabit | meta | bit | escprefix | esc | prefix ]\n" | |
25 | "Each vt has his own copy of this bit. Use\n" | |
26 | " setmetamode [arg] < /dev/ttyn\n" | |
27 | "to change the settings of another vt.\n" | |
28 | "The setting before and after the change are reported.\n" | |
29 | )); | |
30 | exit(EXIT_FAILURE); | |
22 | fprintf(stderr, _( | |
23 | "Usage:\n" | |
24 | " setmetamode [ metabit | meta | bit | escprefix | esc | prefix ]\n" | |
25 | "Each vt has his own copy of this bit. Use\n" | |
26 | " setmetamode [arg] < /dev/ttyn\n" | |
27 | "to change the settings of another vt.\n" | |
28 | "The setting before and after the change are reported.\n")); | |
29 | exit(EXIT_FAILURE); | |
31 | 30 | } |
32 | 31 | |
33 | 32 | static void |
34 | report(int meta) { | |
35 | char *s; | |
33 | report(int meta) | |
34 | { | |
35 | char *s; | |
36 | 36 | |
37 | switch(meta) { | |
38 | case K_METABIT: | |
39 | s = _("Meta key sets high order bit\n"); | |
40 | break; | |
41 | case K_ESCPREFIX: | |
42 | s = _("Meta key gives Esc prefix\n"); | |
43 | break; | |
44 | default: | |
45 | s = _("Strange mode for Meta key?\n"); | |
46 | } | |
47 | printf("%s", s); | |
37 | switch (meta) { | |
38 | case K_METABIT: | |
39 | s = _("Meta key sets high order bit\n"); | |
40 | break; | |
41 | case K_ESCPREFIX: | |
42 | s = _("Meta key gives Esc prefix\n"); | |
43 | break; | |
44 | default: | |
45 | s = _("Strange mode for Meta key?\n"); | |
46 | } | |
47 | printf("%s", s); | |
48 | 48 | } |
49 | 49 | |
50 | 50 | struct meta { |
51 | char *name; | |
52 | int val; | |
51 | char *name; | |
52 | int val; | |
53 | 53 | } metas[] = { |
54 | { "metabit", K_METABIT }, | |
55 | { "meta", K_METABIT }, | |
56 | { "bit", K_METABIT }, | |
57 | { "escprefix", K_ESCPREFIX }, | |
58 | { "esc", K_ESCPREFIX }, | |
59 | { "prefix", K_ESCPREFIX } | |
54 | { "metabit", K_METABIT }, | |
55 | { "meta", K_METABIT }, | |
56 | { "bit", K_METABIT }, | |
57 | { "escprefix", K_ESCPREFIX }, | |
58 | { "esc", K_ESCPREFIX }, | |
59 | { "prefix", K_ESCPREFIX } | |
60 | 60 | }; |
61 | 61 | |
62 | #define SIZE(a) (sizeof(a)/sizeof(a[0])) | |
62 | #define SIZE(a) (sizeof(a) / sizeof(a[0])) | |
63 | 63 | |
64 | int | |
65 | main(int argc, char **argv) { | |
66 | char ometa, nmeta; | |
67 | struct meta *mp; | |
64 | int main(int argc, char **argv) | |
65 | { | |
66 | char ometa, nmeta; | |
67 | struct meta *mp; | |
68 | 68 | |
69 | set_progname(argv[0]); | |
69 | set_progname(argv[0]); | |
70 | 70 | |
71 | setlocale(LC_ALL, ""); | |
72 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
73 | textdomain(PACKAGE_NAME); | |
71 | setlocale(LC_ALL, ""); | |
72 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); | |
73 | textdomain(PACKAGE_NAME); | |
74 | 74 | |
75 | if (argc == 2 && !strcmp(argv[1], "-V")) | |
76 | print_version_and_exit(); | |
75 | if (argc == 2 && !strcmp(argv[1], "-V")) | |
76 | print_version_and_exit(); | |
77 | 77 | |
78 | if (ioctl(0, KDGKBMETA, &ometa)) { | |
79 | kbd_error(EXIT_FAILURE, errno, _("Error reading current setting. Maybe stdin is not a VT?: " | |
80 | "ioctl KDGKBMETA")); | |
81 | } | |
78 | if (ioctl(0, KDGKBMETA, &ometa)) { | |
79 | kbd_error(EXIT_FAILURE, errno, _("Error reading current setting. Maybe stdin is not a VT?: " | |
80 | "ioctl KDGKBMETA")); | |
81 | } | |
82 | 82 | |
83 | if (argc <= 1) { | |
83 | if (argc <= 1) { | |
84 | report(ometa); | |
85 | exit(EXIT_SUCCESS); | |
86 | } | |
87 | ||
88 | nmeta = 0; /* make gcc happy */ | |
89 | for (mp = metas; (unsigned)(mp - metas) < SIZE(metas); mp++) { | |
90 | if (!strcmp(argv[1], mp->name)) { | |
91 | nmeta = mp->val; | |
92 | goto fnd; | |
93 | } | |
94 | } | |
95 | fprintf(stderr, _("unrecognized argument: _%s_\n\n"), argv[1]); | |
96 | usage(); | |
97 | ||
98 | fnd: | |
99 | printf(_("old state: ")); | |
84 | 100 | report(ometa); |
85 | exit(EXIT_SUCCESS); | |
86 | } | |
101 | if (ioctl(0, KDSKBMETA, nmeta)) { | |
102 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSKBMETA"); | |
103 | } | |
104 | printf(_("new state: ")); | |
105 | report(nmeta); | |
87 | 106 | |
88 | nmeta = 0; /* make gcc happy */ | |
89 | for (mp = metas; (unsigned) (mp-metas) < SIZE(metas); mp++) { | |
90 | if(!strcmp(argv[1], mp->name)) { | |
91 | nmeta = mp->val; | |
92 | goto fnd; | |
93 | } | |
94 | } | |
95 | fprintf(stderr, _("unrecognized argument: _%s_\n\n"), argv[1]); | |
96 | usage(); | |
97 | ||
98 | fnd: | |
99 | printf(_("old state: ")); | |
100 | report(ometa); | |
101 | if (ioctl(0, KDSKBMETA, nmeta)) { | |
102 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSKBMETA"); | |
103 | } | |
104 | printf(_("new state: ")); | |
105 | report(nmeta); | |
106 | ||
107 | return EXIT_SUCCESS; | |
107 | return EXIT_SUCCESS; | |
108 | 108 | } |
8 | 8 | #include "version.h" |
9 | 9 | #include "kbd_error.h" |
10 | 10 | |
11 | int | |
12 | main(int argc, char **argv){ | |
11 | int main(int argc, char **argv) | |
12 | { | |
13 | 13 | int fd, indx, red, green, blue; |
14 | 14 | unsigned char cmap[48]; |
15 | 15 | |
37 | 37 | if (ioctl(fd, GIO_CMAP, cmap)) |
38 | 38 | kbd_error(EXIT_FAILURE, errno, "ioctl GIO_CMAP"); |
39 | 39 | |
40 | cmap[3*indx] = red; | |
41 | cmap[3*indx+1] = green; | |
42 | cmap[3*indx+2] = blue; | |
40 | cmap[3 * indx] = red; | |
41 | cmap[3 * indx + 1] = green; | |
42 | cmap[3 * indx + 2] = blue; | |
43 | 43 | |
44 | 44 | if (ioctl(fd, PIO_CMAP, cmap)) |
45 | 45 | kbd_error(EXIT_FAILURE, errno, "ioctl PIO_CMAP"); |
13 | 13 | #include "nls.h" |
14 | 14 | #include "kbd_error.h" |
15 | 15 | |
16 | int | |
17 | main(int argc, char *argv[]) { | |
16 | int main(int argc, char *argv[]) | |
17 | { | |
18 | 18 | int fd; |
19 | struct { char ten, onoff; } arg; | |
19 | struct { | |
20 | char ten, onoff; | |
21 | } arg; | |
20 | 22 | |
21 | 23 | setlocale(LC_ALL, ""); |
22 | 24 | bindtextdomain(PACKAGE_NAME, LOCALEDIR); |
28 | 30 | } |
29 | 31 | if ((fd = getfd(NULL)) < 0) |
30 | 32 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
31 | arg.ten = 10; | |
33 | arg.ten = 10; | |
32 | 34 | arg.onoff = 0; |
33 | 35 | if (!strcmp(argv[1], "on")) |
34 | 36 | arg.onoff = 1; |
36 | 36 | 0xff, 0xff, 0xff, |
37 | 37 | }; |
38 | 38 | |
39 | static void __attribute__ ((noreturn)) | |
39 | static void __attribute__((noreturn)) | |
40 | 40 | usage(int code) |
41 | 41 | { |
42 | 42 | fprintf(stderr, |
43 | _("Usage: %s [-h] [-V]\n" | |
44 | " %s vga|FILE|-\n" | |
45 | "\n" | |
46 | "If you use the FILE parameter, FILE should be exactly 3 lines of\n" | |
47 | "comma-separated decimal values for RED, GREEN, and BLUE.\n" | |
48 | "\n" | |
49 | "To seed a valid FILE:\n" | |
50 | " cat /sys/module/vt/parameters/default_{red,grn,blu} > FILE\n" | |
51 | "\n" | |
52 | "and then edit the values in FILE.\n" | |
53 | "\n" | |
54 | "Other options:\n" | |
55 | " -h print this usage message\n" | |
56 | " -V print version number\n" | |
57 | "\n"), | |
58 | progname, progname); | |
43 | _("Usage: %s [-h] [-V]\n" | |
44 | " %s vga|FILE|-\n" | |
45 | "\n" | |
46 | "If you use the FILE parameter, FILE should be exactly 3 lines of\n" | |
47 | "comma-separated decimal values for RED, GREEN, and BLUE.\n" | |
48 | "\n" | |
49 | "To seed a valid FILE:\n" | |
50 | " cat /sys/module/vt/parameters/default_{red,grn,blu} > FILE\n" | |
51 | "\n" | |
52 | "and then edit the values in FILE.\n" | |
53 | "\n" | |
54 | "Other options:\n" | |
55 | " -h print this usage message\n" | |
56 | " -V print version number\n" | |
57 | "\n"), | |
58 | progname, progname); | |
59 | 59 | exit(code); |
60 | 60 | } |
61 | 61 | |
72 | 72 | kbd_error(EXIT_FAILURE, errno, "fscanf"); |
73 | 73 | |
74 | 74 | kbd_error(EXIT_FAILURE, 0, _("Error: %s: Invalid value in field %u in line %u."), |
75 | filename, rows + 1, cols + 1); | |
75 | filename, rows + 1, cols + 1); | |
76 | 76 | } |
77 | 77 | |
78 | cmap[rows + cols * 3] = (unsigned char) val; | |
78 | cmap[rows + cols * 3] = (unsigned char)val; | |
79 | 79 | |
80 | 80 | if (cols < 15 && fgetc(fd) != ',') |
81 | 81 | kbd_error(EXIT_FAILURE, 0, _("Error: %s: Insufficient number of fields in line %u."), |
82 | filename, rows + 1); | |
82 | filename, rows + 1); | |
83 | 83 | } |
84 | 84 | |
85 | 85 | if ((c = fgetc(fd)) == EOF) |
86 | 86 | kbd_error(EXIT_FAILURE, 0, _("Error: %s: Line %u has ended unexpectedly.\n"), |
87 | filename, rows + 1); | |
87 | filename, rows + 1); | |
88 | 88 | |
89 | 89 | if (c != '\n') |
90 | 90 | kbd_error(EXIT_FAILURE, 0, _("Error: %s: Line %u is too long.\n"), |
91 | filename, rows + 1); | |
91 | filename, rows + 1); | |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | int | |
96 | main(int argc, char **argv) { | |
95 | int main(int argc, char **argv) | |
96 | { | |
97 | 97 | int c, fd; |
98 | 98 | const char *file; |
99 | 99 | unsigned char *colormap = cmap; |
26 | 26 | |
27 | 27 | unsigned short obuf[E_TABSZ], nbuf[E_TABSZ]; |
28 | 28 | struct unimapdesc ounimap, nunimap; |
29 | int fd = 0; | |
30 | int have_obuf = 0; | |
29 | int fd = 0; | |
30 | int have_obuf = 0; | |
31 | 31 | int have_ounimap = 0; |
32 | 32 | |
33 | static void __attribute__ ((noreturn)) | |
34 | leave(int n) { | |
35 | if (have_obuf && loaduniscrnmap(fd,obuf)) { | |
33 | static void __attribute__((noreturn)) | |
34 | leave(int n) | |
35 | { | |
36 | if (have_obuf && loaduniscrnmap(fd, obuf)) { | |
36 | 37 | kbd_warning(0, _("failed to restore original translation table\n")); |
37 | 38 | n = EXIT_FAILURE; |
38 | 39 | } |
39 | if (have_ounimap && loadunimap(fd,NULL,&ounimap)) { | |
40 | if (have_ounimap && loadunimap(fd, NULL, &ounimap)) { | |
40 | 41 | kbd_warning(0, _("failed to restore original unimap\n")); |
41 | 42 | n = EXIT_FAILURE; |
42 | 43 | } |
44 | 45 | } |
45 | 46 | |
46 | 47 | static void |
47 | settrivialscreenmap(void) { | |
48 | settrivialscreenmap(void) | |
49 | { | |
48 | 50 | int i; |
49 | 51 | |
50 | if (getuniscrnmap(fd,obuf)) | |
52 | if (getuniscrnmap(fd, obuf)) | |
51 | 53 | exit(1); |
52 | 54 | have_obuf = 1; |
53 | 55 | |
54 | for(i=0; i<E_TABSZ; i++) | |
56 | for (i = 0; i < E_TABSZ; i++) | |
55 | 57 | nbuf[i] = i; |
56 | 58 | |
57 | if (loaduniscrnmap(fd,nbuf)) { | |
59 | if (loaduniscrnmap(fd, nbuf)) { | |
58 | 60 | kbd_error(EXIT_FAILURE, 0, _("cannot change translation table\n")); |
59 | 61 | } |
60 | 62 | } |
61 | 63 | |
62 | 64 | static void |
63 | getoldunicodemap(void) { | |
65 | getoldunicodemap(void) | |
66 | { | |
64 | 67 | struct unimapdesc descr; |
65 | 68 | |
66 | 69 | if (getunimap(fd, &descr)) |
67 | 70 | leave(EXIT_FAILURE); |
68 | ounimap = descr; | |
71 | ounimap = descr; | |
69 | 72 | have_ounimap = 1; |
70 | 73 | } |
71 | 74 | |
72 | #define BASE 041 /* ' '+1 */ | |
75 | #define BASE 041 /* ' '+1 */ | |
73 | 76 | |
74 | 77 | static void |
75 | setnewunicodemap(int *list, int cnt) { | |
78 | setnewunicodemap(int *list, int cnt) | |
79 | { | |
76 | 80 | int i; |
77 | 81 | |
78 | 82 | if (!nunimap.entry_ct) { |
79 | 83 | nunimap.entry_ct = 512; |
80 | nunimap.entries = (struct unipair *) xmalloc(nunimap.entry_ct * sizeof(struct unipair)); | |
81 | } | |
82 | for (i=0; i<512; i++) { | |
84 | nunimap.entries = (struct unipair *)xmalloc(nunimap.entry_ct * sizeof(struct unipair)); | |
85 | } | |
86 | for (i = 0; i < 512; i++) { | |
83 | 87 | nunimap.entries[i].fontpos = i; |
84 | 88 | nunimap.entries[i].unicode = 0; |
85 | 89 | } |
86 | for (i=0; i<cnt; i++) | |
87 | nunimap.entries[list[i]].unicode = BASE+i; | |
90 | for (i = 0; i < cnt; i++) | |
91 | nunimap.entries[list[i]].unicode = BASE + i; | |
88 | 92 | |
89 | 93 | if (loadunimap(fd, NULL, &nunimap)) |
90 | 94 | leave(EXIT_FAILURE); |
91 | 95 | } |
92 | 96 | |
93 | static void __attribute__ ((noreturn)) | |
94 | usage(void) { | |
97 | static void __attribute__((noreturn)) | |
98 | usage(void) | |
99 | { | |
95 | 100 | fprintf(stderr, |
96 | _("usage: showconsolefont -V|--version\n" | |
97 | " showconsolefont [-C tty] [-v] [-i]\n" | |
98 | "(probably after loading a font with `setfont font')\n" | |
99 | "\n" | |
100 | "Valid options are:\n" | |
101 | " -V --version Print version number and exit.\n" | |
102 | " -C tty Device to read the font from. Default: current tty.\n" | |
103 | " -v Be more verbose.\n" | |
104 | " -i Don't print out the font table, just show\n" | |
105 | " ROWSxCOLSxCOUNT and exit.\n")); | |
101 | _("usage: showconsolefont -V|--version\n" | |
102 | " showconsolefont [-C tty] [-v] [-i]\n" | |
103 | "(probably after loading a font with `setfont font')\n" | |
104 | "\n" | |
105 | "Valid options are:\n" | |
106 | " -V --version Print version number and exit.\n" | |
107 | " -C tty Device to read the font from. Default: current tty.\n" | |
108 | " -v Be more verbose.\n" | |
109 | " -i Don't print out the font table, just show\n" | |
110 | " ROWSxCOLSxCOUNT and exit.\n")); | |
106 | 111 | exit(EXIT_FAILURE); |
107 | 112 | } |
108 | 113 | |
109 | int | |
110 | main (int argc, char **argv) { | |
114 | int main(int argc, char **argv) | |
115 | { | |
111 | 116 | int c, n, cols, rows, nr, i, j, k; |
112 | 117 | int mode; |
113 | 118 | char *space, *sep, *console = NULL; |
125 | 130 | |
126 | 131 | while ((c = getopt(argc, argv, "ivC:")) != EOF) { |
127 | 132 | switch (c) { |
128 | case 'i': | |
129 | info = 1; | |
130 | break; | |
131 | case 'v': | |
132 | verbose = 1; | |
133 | break; | |
134 | case 'C': | |
135 | console = optarg; | |
136 | break; | |
137 | default: | |
138 | usage(); | |
133 | case 'i': | |
134 | info = 1; | |
135 | break; | |
136 | case 'v': | |
137 | verbose = 1; | |
138 | break; | |
139 | case 'C': | |
140 | console = optarg; | |
141 | break; | |
142 | default: | |
143 | usage(); | |
139 | 144 | } |
140 | 145 | } |
141 | 146 | |
150 | 155 | leave(EXIT_FAILURE); |
151 | 156 | } |
152 | 157 | if (mode == K_UNICODE) |
153 | space = "\xef\x80\xa0"; /* U+F020 (direct-to-font space) */ | |
158 | space = "\xef\x80\xa0"; /* U+F020 (direct-to-font space) */ | |
154 | 159 | else |
155 | 160 | space = " "; |
156 | 161 | |
157 | if (info) { | |
158 | nr = rows = cols = 0; | |
159 | n = getfont(fd, NULL, &nr, &rows, &cols); | |
160 | if (n != 0) | |
161 | leave(EXIT_FAILURE); | |
162 | ||
163 | if (verbose) { | |
164 | printf(_("Character count: %d\n"), nr); | |
165 | printf(_("Font width : %d\n"), rows); | |
166 | printf(_("Font height : %d\n"), cols); | |
167 | } | |
168 | else | |
169 | printf("%dx%dx%d\n", rows, cols, nr); | |
170 | leave(EXIT_SUCCESS); | |
171 | } | |
162 | if (info) { | |
163 | nr = rows = cols = 0; | |
164 | n = getfont(fd, NULL, &nr, &rows, &cols); | |
165 | if (n != 0) | |
166 | leave(EXIT_FAILURE); | |
167 | ||
168 | if (verbose) { | |
169 | printf(_("Character count: %d\n"), nr); | |
170 | printf(_("Font width : %d\n"), rows); | |
171 | printf(_("Font height : %d\n"), cols); | |
172 | } else | |
173 | printf("%dx%dx%d\n", rows, cols, nr); | |
174 | leave(EXIT_SUCCESS); | |
175 | } | |
172 | 176 | |
173 | 177 | settrivialscreenmap(); |
174 | 178 | getoldunicodemap(); |
177 | 181 | if (verbose) |
178 | 182 | printf(_("Showing %d-char font\n\n"), n); |
179 | 183 | cols = ((n > 256) ? 32 : 16); |
180 | nr = 64/cols; | |
181 | rows = (n+cols-1)/cols; | |
182 | sep = ((cols == 16) ? "%1$s%1$s" : "%1$s"); | |
183 | ||
184 | for (i=0; i<rows; i++) { | |
184 | nr = 64 / cols; | |
185 | rows = (n + cols - 1) / cols; | |
186 | sep = ((cols == 16) ? "%1$s%1$s" : "%1$s"); | |
187 | ||
188 | for (i = 0; i < rows; i++) { | |
185 | 189 | if (i % nr == 0) { |
186 | 190 | lth = 0; |
187 | for (k=i; k<i+nr; k++) | |
188 | for (j=0; j < cols; j++) | |
189 | list[lth++] = k+j*rows; | |
191 | for (k = i; k < i + nr; k++) | |
192 | for (j = 0; j < cols; j++) | |
193 | list[lth++] = k + j * rows; | |
190 | 194 | setnewunicodemap(list, lth); |
191 | 195 | } |
192 | 196 | printf("%1$s%1$s%1$s%1$s", space); |
193 | for(j=0; j < cols && i+j*rows < n; j++) { | |
194 | putchar(BASE + (i%nr)*cols+j); | |
197 | for (j = 0; j < cols && i + j * rows < n; j++) { | |
198 | putchar(BASE + (i % nr) * cols + j); | |
195 | 199 | printf(sep, space); |
196 | if (j%8 == 7) | |
200 | if (j % 8 == 7) | |
197 | 201 | printf(sep, space); |
198 | 202 | } |
199 | 203 | putchar('\n'); |
200 | if (i%8 == 7) | |
204 | if (i % 8 == 7) | |
201 | 205 | putchar('\n'); |
202 | 206 | fflush(stdout); |
203 | 207 | } |
15 | 15 | #include "nls.h" |
16 | 16 | #include "version.h" |
17 | 17 | |
18 | int tmp; /* for debugging */ | |
18 | int tmp; /* for debugging */ | |
19 | 19 | |
20 | 20 | int fd; |
21 | 21 | int oldkbmode; |
26 | 26 | * thus making the console unusable when it was called under X. |
27 | 27 | */ |
28 | 28 | static void |
29 | get_mode(void) { | |
30 | char *m; | |
29 | get_mode(void) | |
30 | { | |
31 | char *m; | |
31 | 32 | |
32 | 33 | if (ioctl(fd, KDGKBMODE, &oldkbmode)) { |
33 | 34 | kbd_error(EXIT_FAILURE, errno, "ioctl KDGKBMODE"); |
34 | 35 | } |
35 | switch(oldkbmode) { | |
36 | case K_RAW: | |
37 | m = "RAW"; break; | |
38 | case K_XLATE: | |
39 | m = "XLATE"; break; | |
40 | case K_MEDIUMRAW: | |
41 | m = "MEDIUMRAW"; break; | |
42 | case K_UNICODE: | |
43 | m = "UNICODE"; break; | |
44 | default: | |
45 | m = _("?UNKNOWN?"); break; | |
36 | switch (oldkbmode) { | |
37 | case K_RAW: | |
38 | m = "RAW"; | |
39 | break; | |
40 | case K_XLATE: | |
41 | m = "XLATE"; | |
42 | break; | |
43 | case K_MEDIUMRAW: | |
44 | m = "MEDIUMRAW"; | |
45 | break; | |
46 | case K_UNICODE: | |
47 | m = "UNICODE"; | |
48 | break; | |
49 | default: | |
50 | m = _("?UNKNOWN?"); | |
51 | break; | |
46 | 52 | } |
47 | 53 | printf(_("kb mode was %s\n"), m); |
48 | 54 | if (oldkbmode != K_XLATE) { |
49 | printf(_("[ if you are trying this under X, it might not work\n" | |
50 | "since the X server is also reading /dev/console ]\n")); | |
55 | printf(_("[ if you are trying this under X, it might not work\n" | |
56 | "since the X server is also reading /dev/console ]\n")); | |
51 | 57 | } |
52 | 58 | printf("\n"); |
53 | 59 | } |
54 | 60 | |
55 | 61 | static void |
56 | clean_up(void) { | |
62 | clean_up(void) | |
63 | { | |
57 | 64 | if (ioctl(fd, KDSKBMODE, oldkbmode)) { |
58 | 65 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSKBMODE"); |
59 | 66 | } |
62 | 69 | close(fd); |
63 | 70 | } |
64 | 71 | |
65 | static void __attribute__ ((noreturn)) | |
66 | die(int x) { | |
72 | static void __attribute__((noreturn)) | |
73 | die(int x) | |
74 | { | |
67 | 75 | printf(_("caught signal %d, cleaning up...\n"), x); |
68 | 76 | clean_up(); |
69 | 77 | exit(EXIT_FAILURE); |
70 | 78 | } |
71 | 79 | |
72 | static void __attribute__ ((noreturn)) | |
73 | watch_dog(int x __attribute__ ((unused))) { | |
80 | static void __attribute__((noreturn)) | |
81 | watch_dog(int x __attribute__((unused))) | |
82 | { | |
74 | 83 | clean_up(); |
75 | 84 | exit(EXIT_SUCCESS); |
76 | 85 | } |
77 | 86 | |
78 | static void __attribute__ ((noreturn)) | |
79 | usage(void) { | |
87 | static void __attribute__((noreturn)) | |
88 | usage(void) | |
89 | { | |
80 | 90 | fprintf(stderr, _( |
81 | "showkey version %s\n\n" | |
82 | "usage: showkey [options...]\n" | |
83 | "\n" | |
84 | "valid options are:\n" | |
85 | "\n" | |
86 | " -h --help display this help text\n" | |
87 | " -a --ascii display the decimal/octal/hex values of the keys\n" | |
88 | " -s --scancodes display only the raw scan-codes\n" | |
89 | " -k --keycodes display only the interpreted keycodes (default)\n" | |
90 | " -V --version print version number\n" | |
91 | ), PACKAGE_VERSION); | |
91 | "showkey version %s\n\n" | |
92 | "usage: showkey [options...]\n" | |
93 | "\n" | |
94 | "valid options are:\n" | |
95 | "\n" | |
96 | " -h --help display this help text\n" | |
97 | " -a --ascii display the decimal/octal/hex values of the keys\n" | |
98 | " -s --scancodes display only the raw scan-codes\n" | |
99 | " -k --keycodes display only the interpreted keycodes (default)\n" | |
100 | " -V --version print version number\n"), | |
101 | PACKAGE_VERSION); | |
92 | 102 | exit(EXIT_FAILURE); |
93 | 103 | } |
94 | 104 | |
95 | int | |
96 | main (int argc, char *argv[]) { | |
97 | const char *short_opts = "haskV"; | |
105 | int main(int argc, char *argv[]) | |
106 | { | |
107 | const char *short_opts = "haskV"; | |
98 | 108 | const struct option long_opts[] = { |
99 | { "help", no_argument, NULL, 'h' }, | |
100 | { "ascii", no_argument, NULL, 'a' }, | |
101 | { "scancodes", no_argument, NULL, 's' }, | |
102 | { "keycodes", no_argument, NULL, 'k' }, | |
103 | { "version", no_argument, NULL, 'V' }, | |
109 | { "help", no_argument, NULL, 'h' }, | |
110 | { "ascii", no_argument, NULL, 'a' }, | |
111 | { "scancodes", no_argument, NULL, 's' }, | |
112 | { "keycodes", no_argument, NULL, 'k' }, | |
113 | { "version", no_argument, NULL, 'V' }, | |
104 | 114 | { NULL, 0, NULL, 0 } |
105 | 115 | }; |
106 | 116 | int c; |
107 | 117 | int show_keycodes = 1; |
108 | int print_ascii = 0; | |
118 | int print_ascii = 0; | |
109 | 119 | |
110 | 120 | struct termios new; |
111 | unsigned char buf[18]; /* divisible by 3 */ | |
121 | unsigned char buf[18]; /* divisible by 3 */ | |
112 | 122 | int i, n; |
113 | 123 | |
114 | 124 | set_progname(argv[0]); |
118 | 128 | textdomain(PACKAGE_NAME); |
119 | 129 | |
120 | 130 | while ((c = getopt_long(argc, argv, |
121 | short_opts, long_opts, NULL)) != -1) { | |
131 | short_opts, long_opts, NULL)) != -1) { | |
122 | 132 | switch (c) { |
123 | case 's': | |
124 | show_keycodes = 0; | |
125 | break; | |
126 | case 'k': | |
127 | show_keycodes = 1; | |
128 | break; | |
129 | case 'a': | |
130 | print_ascii = 1; | |
131 | break; | |
132 | case 'V': | |
133 | print_version_and_exit(); | |
134 | case 'h': | |
135 | case '?': | |
136 | usage(); | |
133 | case 's': | |
134 | show_keycodes = 0; | |
135 | break; | |
136 | case 'k': | |
137 | show_keycodes = 1; | |
138 | break; | |
139 | case 'a': | |
140 | print_ascii = 1; | |
141 | break; | |
142 | case 'V': | |
143 | print_version_and_exit(); | |
144 | case 'h': | |
145 | case '?': | |
146 | usage(); | |
137 | 147 | } |
138 | 148 | } |
139 | 149 | |
142 | 152 | |
143 | 153 | if (print_ascii) { |
144 | 154 | /* no mode and signal and timer stuff - just read stdin */ |
145 | fd = 0; | |
155 | fd = 0; | |
146 | 156 | |
147 | 157 | if (tcgetattr(fd, &old) == -1) |
148 | 158 | kbd_warning(errno, "tcgetattr"); |
149 | 159 | if (tcgetattr(fd, &new) == -1) |
150 | 160 | kbd_warning(errno, "tcgetattr"); |
151 | 161 | |
152 | new.c_lflag &= ~ (ICANON | ISIG); | |
162 | new.c_lflag &= ~(ICANON | ISIG); | |
153 | 163 | new.c_lflag |= (ECHO | ECHOCTL); |
154 | new.c_iflag = 0; | |
155 | new.c_cc[VMIN] = 1; | |
164 | new.c_iflag = 0; | |
165 | new.c_cc[VMIN] = 1; | |
156 | 166 | new.c_cc[VTIME] = 0; |
157 | 167 | |
158 | 168 | if (tcsetattr(fd, TCSAFLUSH, &new) == -1) |
214 | 224 | if (tcgetattr(fd, &new) == -1) |
215 | 225 | kbd_warning(errno, "tcgetattr"); |
216 | 226 | |
217 | new.c_lflag &= ~ (ICANON | ECHO | ISIG); | |
218 | new.c_iflag = 0; | |
219 | new.c_cc[VMIN] = sizeof(buf); | |
220 | new.c_cc[VTIME] = 1; /* 0.1 sec intercharacter timeout */ | |
227 | new.c_lflag &= ~(ICANON | ECHO | ISIG); | |
228 | new.c_iflag = 0; | |
229 | new.c_cc[VMIN] = sizeof(buf); | |
230 | new.c_cc[VTIME] = 1; /* 0.1 sec intercharacter timeout */ | |
221 | 231 | |
222 | 232 | if (tcsetattr(fd, TCSAFLUSH, &new) == -1) |
223 | 233 | kbd_warning(errno, "tcsetattr"); |
251 | 261 | |
252 | 262 | s = (buf[i] & 0x80) ? _("release") : _("press"); |
253 | 263 | |
254 | if (i+2 < n && (buf[i] & 0x7f) == 0 | |
255 | && (buf[i+1] & 0x80) != 0 | |
256 | && (buf[i+2] & 0x80) != 0) { | |
257 | kc = ((buf[i+1] & 0x7f) << 7) | | |
258 | (buf[i+2] & 0x7f); | |
264 | if (i + 2 < n && (buf[i] & 0x7f) == 0 && (buf[i + 1] & 0x80) != 0 && (buf[i + 2] & 0x80) != 0) { | |
265 | kc = ((buf[i + 1] & 0x7f) << 7) | | |
266 | (buf[i + 2] & 0x7f); | |
259 | 267 | i += 3; |
260 | 268 | } else { |
261 | 269 | kc = (buf[i] & 0x7f); |
15 | 15 | #include <errno.h> |
16 | 16 | #include <linux/kd.h> |
17 | 17 | #include <stdio.h> |
18 | #include <stdlib.h> /* system */ | |
19 | #include <fcntl.h> /* open */ | |
20 | #include <sys/ioctl.h> /* ioctl */ | |
21 | #include <unistd.h> /* sleep */ | |
18 | #include <stdlib.h> /* system */ | |
19 | #include <fcntl.h> /* open */ | |
20 | #include <sys/ioctl.h> /* ioctl */ | |
21 | #include <unistd.h> /* sleep */ | |
22 | 22 | |
23 | 23 | #include "version.h" |
24 | 24 | #include "kbd.h" |
25 | 25 | #include "kbd_error.h" |
26 | 26 | |
27 | 27 | static void |
28 | sighup(int n __attribute__ ((unused))) { | |
29 | if (system("openvt -s -l bash") == -1) { | |
30 | kbd_error(EXIT_FAILURE, errno, "system"); | |
31 | } | |
32 | signal(SIGHUP, sighup); | |
28 | sighup(int n __attribute__((unused))) | |
29 | { | |
30 | if (system("openvt -s -l bash") == -1) { | |
31 | kbd_error(EXIT_FAILURE, errno, "system"); | |
32 | } | |
33 | signal(SIGHUP, sighup); | |
33 | 34 | } |
34 | 35 | |
35 | int | |
36 | main(int argc __attribute__ ((unused)), char *argv[]) { | |
37 | int fd; | |
36 | int main(int argc __attribute__((unused)), char *argv[]) | |
37 | { | |
38 | int fd; | |
38 | 39 | |
39 | set_progname(argv[0]); | |
40 | set_progname(argv[0]); | |
40 | 41 | |
41 | fd = open("/dev/tty0", 0); | |
42 | if (fd < 0 && errno == ENOENT) | |
43 | fd = open("/dev/vc/0", 0); | |
44 | if (fd < 0) | |
45 | fd = 0; | |
46 | signal(SIGHUP, sighup); | |
47 | if (ioctl(fd, KDSIGACCEPT, (long) SIGHUP)) { | |
48 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSIGACCEPT"); | |
49 | } | |
50 | while(1) | |
51 | sleep(3600); | |
52 | return EXIT_SUCCESS; | |
42 | fd = open("/dev/tty0", 0); | |
43 | if (fd < 0 && errno == ENOENT) | |
44 | fd = open("/dev/vc/0", 0); | |
45 | if (fd < 0) | |
46 | fd = 0; | |
47 | signal(SIGHUP, sighup); | |
48 | if (ioctl(fd, KDSIGACCEPT, (long)SIGHUP)) { | |
49 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSIGACCEPT"); | |
50 | } | |
51 | while (1) | |
52 | sleep(3600); | |
53 | return EXIT_SUCCESS; | |
53 | 54 | } |
19 | 19 | #include "kbd_error.h" |
20 | 20 | |
21 | 21 | static void |
22 | sighup(int n __attribute__ ((unused))) { | |
23 | if (system("openvt -s -l -- login -h spawn") == -1) { | |
24 | kbd_error(EXIT_FAILURE, errno, "system"); | |
25 | } | |
26 | signal(SIGHUP, sighup); | |
22 | sighup(int n __attribute__((unused))) | |
23 | { | |
24 | if (system("openvt -s -l -- login -h spawn") == -1) { | |
25 | kbd_error(EXIT_FAILURE, errno, "system"); | |
26 | } | |
27 | signal(SIGHUP, sighup); | |
27 | 28 | } |
28 | 29 | |
29 | int | |
30 | main(int argc __attribute__ ((unused)), char *argv[]) { | |
31 | int fd; | |
30 | int main(int argc __attribute__((unused)), char *argv[]) | |
31 | { | |
32 | int fd; | |
32 | 33 | |
33 | set_progname(argv[0]); | |
34 | set_progname(argv[0]); | |
34 | 35 | |
35 | fd = open("/dev/tty0", 0); | |
36 | if (fd < 0 && errno == ENOENT) | |
37 | fd = open("/dev/vc/0", 0); | |
38 | if (fd < 0) | |
39 | fd = 0; | |
40 | signal(SIGHUP, sighup); | |
41 | if (ioctl(fd, KDSIGACCEPT, (long) SIGHUP)) | |
42 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSIGACCEPT"); | |
43 | while(1) | |
44 | sleep(3600); | |
45 | return EXIT_SUCCESS; | |
36 | fd = open("/dev/tty0", 0); | |
37 | if (fd < 0 && errno == ENOENT) | |
38 | fd = open("/dev/vc/0", 0); | |
39 | if (fd < 0) | |
40 | fd = 0; | |
41 | signal(SIGHUP, sighup); | |
42 | if (ioctl(fd, KDSIGACCEPT, (long)SIGHUP)) | |
43 | kbd_error(EXIT_FAILURE, errno, "ioctl KDSIGACCEPT"); | |
44 | while (1) | |
45 | sleep(3600); | |
46 | return EXIT_SUCCESS; | |
46 | 47 | } |
15 | 15 | #include "version.h" |
16 | 16 | #include "kbd_error.h" |
17 | 17 | |
18 | int | |
19 | main(int argc, char *argv[]) { | |
18 | int main(int argc, char *argv[]) | |
19 | { | |
20 | 20 | int fd, num; |
21 | 21 | |
22 | 22 | set_progname(argv[0]); |
36 | 36 | kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); |
37 | 37 | |
38 | 38 | num = atoi(argv[1]); |
39 | if (ioctl(fd,KDSETMODE,KD_TEXT)) { | |
39 | if (ioctl(fd, KDSETMODE, KD_TEXT)) { | |
40 | 40 | kbd_error(EXIT_FAILURE, errno, "totextmode: KDSETMODE"); |
41 | 41 | } |
42 | 42 | return EXIT_SUCCESS; |
12 | 12 | * cnt is either 0 or gives the number of available bytes |
13 | 13 | */ |
14 | 14 | unsigned long |
15 | from_utf8(char **inptr, int cnt, int *err) { | |
15 | from_utf8(char **inptr, int cnt, int *err) | |
16 | { | |
16 | 17 | unsigned char *in; |
17 | 18 | unsigned int uc, uc2; |
18 | 19 | int need, bit, bad = 0; |
19 | 20 | |
20 | in = (unsigned char *)(* inptr); | |
21 | uc = *in++; | |
21 | in = (unsigned char *)(*inptr); | |
22 | uc = *in++; | |
22 | 23 | need = 0; |
23 | bit = 0x80; | |
24 | while(uc & bit) { | |
24 | bit = 0x80; | |
25 | while (uc & bit) { | |
25 | 26 | need++; |
26 | 27 | bit >>= 1; |
27 | 28 | } |
28 | uc &= (bit-1); | |
29 | uc &= (bit - 1); | |
29 | 30 | if (cnt && cnt < need) { |
30 | 31 | *err = UTF8_SHORT; |
31 | 32 | return 0; |
32 | 33 | } |
33 | 34 | if (need == 1) |
34 | 35 | bad = 1; |
35 | else if (need) while(--need) { | |
36 | uc2 = *in++; | |
37 | if ((uc2 & 0xc0) != 0x80) { | |
38 | bad = 1; | |
39 | break; | |
36 | else if (need) | |
37 | while (--need) { | |
38 | uc2 = *in++; | |
39 | if ((uc2 & 0xc0) != 0x80) { | |
40 | bad = 1; | |
41 | break; | |
42 | } | |
43 | uc = ((uc << 6) | (uc2 & 0x3f)); | |
40 | 44 | } |
41 | uc = ((uc << 6) | (uc2 & 0x3f)); | |
42 | } | |
43 | 45 | if (bad) { |
44 | 46 | *err = UTF8_BAD; |
45 | 47 | return 0; |
46 | 48 | } |
47 | 49 | *inptr = (char *)in; |
48 | *err = 0; | |
50 | *err = 0; | |
49 | 51 | return uc; |
50 | 52 | } |
2 | 2 | |
3 | 3 | extern unsigned long from_utf8(char **inptr, int cnt, int *err); |
4 | 4 | |
5 | #define UTF8_BAD (-1) | |
6 | #define UTF8_SHORT (-2) | |
5 | #define UTF8_BAD (-1) | |
6 | #define UTF8_SHORT (-2) | |
7 | 7 | |
8 | 8 | #endif /* _UTF8_H */ |
7 | 7 | char *progname; |
8 | 8 | |
9 | 9 | static inline void |
10 | set_progname(char *name) { | |
10 | set_progname(char *name) | |
11 | { | |
11 | 12 | char *p; |
12 | 13 | |
13 | p = strrchr(name, '/'); | |
14 | progname = (p ? p+1 : name); | |
14 | p = strrchr(name, '/'); | |
15 | progname = (p ? p + 1 : name); | |
15 | 16 | } |
16 | 17 | |
17 | static inline void __attribute__ ((noreturn)) | |
18 | print_version_and_exit(void) { | |
18 | static inline void __attribute__((noreturn)) | |
19 | print_version_and_exit(void) | |
20 | { | |
19 | 21 | printf(_("%s from %s\n"), progname, PACKAGE_STRING); |
20 | 22 | exit(0); |
21 | 23 | } |
33 | 33 | #include "nls.h" |
34 | 34 | |
35 | 35 | /* Delay after fatal PAM errors, in seconds. */ |
36 | #define LONG_DELAY 10 | |
36 | #define LONG_DELAY 10 | |
37 | 37 | /* Delay after other PAM errors, in seconds. */ |
38 | #define SHORT_DELAY 1 | |
38 | #define SHORT_DELAY 1 | |
39 | 39 | |
40 | 40 | static int |
41 | do_account_password_management (pam_handle_t *pamh) | |
41 | do_account_password_management(pam_handle_t *pamh) | |
42 | 42 | { |
43 | 43 | int rc; |
44 | 44 | |
45 | 45 | /* Whether the authenticated user is allowed to log in? */ |
46 | rc = pam_acct_mgmt (pamh, 0); | |
46 | rc = pam_acct_mgmt(pamh, 0); | |
47 | 47 | |
48 | 48 | /* Do we need to prompt the user for a new password? */ |
49 | 49 | if (rc == PAM_NEW_AUTHTOK_REQD) |
50 | rc = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK); | |
50 | rc = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK); | |
51 | 51 | |
52 | 52 | /* Extend the lifetime of the existing credentials. */ |
53 | 53 | if (rc == PAM_SUCCESS) |
54 | rc = pam_setcred (pamh, PAM_REFRESH_CRED); | |
54 | rc = pam_setcred(pamh, PAM_REFRESH_CRED); | |
55 | 55 | |
56 | 56 | return rc; |
57 | 57 | } |
58 | 58 | |
59 | int | |
60 | get_password (pam_handle_t * pamh, const char *username, const char *tty) | |
59 | int get_password(pam_handle_t *pamh, const char *username, const char *tty) | |
61 | 60 | { |
62 | uid_t uid = getuid (); | |
61 | uid_t uid = getuid(); | |
63 | 62 | |
64 | for (;;) | |
65 | { | |
66 | int rc; | |
63 | for (;;) { | |
64 | int rc; | |
67 | 65 | const char *msg; |
68 | 66 | |
69 | if (!pamh) | |
70 | { | |
71 | pamh = init_pam (username, tty, 1); | |
72 | if (!pamh) | |
73 | { | |
67 | if (!pamh) { | |
68 | pamh = init_pam(username, tty, 1); | |
69 | if (!pamh) { | |
74 | 70 | /* Log the fact of failure. */ |
75 | syslog (LOG_WARNING, | |
76 | "Authentication problems on %s for %s by (uid=%u)", | |
77 | tty, username, uid); | |
78 | puts (_("Please try again later.\n\n\n")); | |
79 | fflush (stdout); | |
80 | sleep (LONG_DELAY); | |
71 | syslog(LOG_WARNING, | |
72 | "Authentication problems on %s for %s by (uid=%u)", | |
73 | tty, username, uid); | |
74 | puts(_("Please try again later.\n\n\n")); | |
75 | fflush(stdout); | |
76 | sleep(LONG_DELAY); | |
81 | 77 | continue; |
82 | 78 | } |
83 | 79 | } |
84 | 80 | |
85 | if (o_lock_all) | |
86 | { | |
87 | printf (_("The entire console display is now completely locked by %s.\n"), | |
88 | username); | |
89 | } else | |
90 | { | |
91 | printf (_("The %s is now locked by %s.\n"), tty, | |
92 | username); | |
81 | if (o_lock_all) { | |
82 | printf(_("The entire console display is now completely locked by %s.\n"), | |
83 | username); | |
84 | } else { | |
85 | printf(_("The %s is now locked by %s.\n"), tty, | |
86 | username); | |
93 | 87 | if (is_vt) |
94 | puts (_("Use Alt-function keys to switch to other virtual consoles.")); | |
88 | puts(_("Use Alt-function keys to switch to other virtual consoles.")); | |
95 | 89 | } |
96 | fflush (stdout); | |
90 | fflush(stdout); | |
97 | 91 | |
98 | 92 | /* |
99 | 93 | * No need to request a delay on failure via pam_fail_delay(3): |
100 | 94 | * authentication module should do it for us. |
101 | 95 | */ |
102 | rc = pam_authenticate (pamh, 0); | |
96 | rc = pam_authenticate(pamh, 0); | |
103 | 97 | |
104 | switch (rc) | |
105 | { | |
98 | switch (rc) { | |
106 | 99 | case PAM_SUCCESS: |
107 | rc = do_account_password_management (pamh); | |
100 | rc = do_account_password_management(pamh); | |
108 | 101 | |
109 | if (rc != PAM_SUCCESS) | |
110 | { | |
102 | if (rc != PAM_SUCCESS) { | |
111 | 103 | /* |
112 | 104 | * The user was authenticated but |
113 | 105 | * either account or password management |
114 | 106 | * returned an error. |
115 | 107 | */ |
116 | printf ("%s.\n\n\n", | |
117 | pam_strerror (pamh, rc)); | |
118 | fflush (stdout); | |
119 | pam_end (pamh, rc); | |
108 | printf("%s.\n\n\n", | |
109 | pam_strerror(pamh, rc)); | |
110 | fflush(stdout); | |
111 | pam_end(pamh, rc); | |
120 | 112 | pamh = 0; |
121 | sleep (SHORT_DELAY); | |
113 | sleep(SHORT_DELAY); | |
122 | 114 | break; |
123 | 115 | } |
124 | 116 | |
125 | pam_end (pamh, rc); | |
117 | pam_end(pamh, rc); | |
126 | 118 | /* Log the fact of console unlocking. */ |
127 | syslog (LOG_NOTICE, | |
128 | "Unlocked %s on %s for %s by (uid=%u)", | |
129 | locked_name (), tty, username, uid); | |
119 | syslog(LOG_NOTICE, | |
120 | "Unlocked %s on %s for %s by (uid=%u)", | |
121 | locked_name(), tty, username, uid); | |
130 | 122 | return EXIT_SUCCESS; |
131 | 123 | |
132 | 124 | case PAM_MAXTRIES: |
133 | 125 | case PAM_ABORT: |
134 | msg = pam_strerror (pamh, rc); | |
126 | msg = pam_strerror(pamh, rc); | |
135 | 127 | /* Log the fact of failure. */ |
136 | syslog (LOG_WARNING, "%s", msg); | |
137 | printf ("%s.\n\n\n", msg); | |
138 | fflush (stdout); | |
128 | syslog(LOG_WARNING, "%s", msg); | |
129 | printf("%s.\n\n\n", msg); | |
130 | fflush(stdout); | |
139 | 131 | msg = 0; |
140 | pam_end (pamh, rc); | |
132 | pam_end(pamh, rc); | |
141 | 133 | pamh = 0; |
142 | sleep (LONG_DELAY); | |
134 | sleep(LONG_DELAY); | |
143 | 135 | break; |
144 | 136 | |
145 | 137 | default: |
146 | printf ("%s.\n\n\n", pam_strerror (pamh, rc)); | |
147 | fflush (stdout); | |
138 | printf("%s.\n\n\n", pam_strerror(pamh, rc)); | |
139 | fflush(stdout); | |
148 | 140 | /* |
149 | 141 | * EOF encountered on read? |
150 | 142 | * If not on VT, check stdin. |
151 | 143 | */ |
152 | if (is_vt || isatty (STDIN_FILENO)) | |
153 | { | |
144 | if (is_vt || isatty(STDIN_FILENO)) { | |
154 | 145 | /* Ignore error. */ |
155 | sleep (SHORT_DELAY); | |
146 | sleep(SHORT_DELAY); | |
156 | 147 | break; |
157 | 148 | } |
158 | 149 | |
159 | 150 | /* Cancel locking. */ |
160 | pam_end (pamh, rc); | |
161 | syslog (LOG_NOTICE, | |
162 | "Cancelled lock of %s on %s for %s by (uid=%u)", | |
163 | locked_name (), tty, username, uid); | |
151 | pam_end(pamh, rc); | |
152 | syslog(LOG_NOTICE, | |
153 | "Cancelled lock of %s on %s for %s by (uid=%u)", | |
154 | locked_name(), tty, username, uid); | |
164 | 155 | return EXIT_FAILURE; |
165 | 156 | } |
166 | 157 | } |
37 | 37 | }; |
38 | 38 | |
39 | 39 | pam_handle_t * |
40 | init_pam (const char *username, const char *tty, int log) | |
40 | init_pam(const char *username, const char *tty, int log) | |
41 | 41 | { |
42 | 42 | pam_handle_t *pamh = 0; |
43 | int rc = pam_start ("vlock", username, &conv, &pamh); | |
43 | int rc = pam_start("vlock", username, &conv, &pamh); | |
44 | 44 | |
45 | if (rc != PAM_SUCCESS) | |
46 | { | |
45 | if (rc != PAM_SUCCESS) { | |
47 | 46 | /* pam_strerror is not available atm. */ |
48 | 47 | if (log) |
49 | syslog (LOG_WARNING, "pam_start failed: %m"); | |
48 | syslog(LOG_WARNING, "pam_start failed: %m"); | |
50 | 49 | else |
51 | 50 | kbd_warning(errno, "pam_start"); |
52 | 51 | return 0; |
53 | 52 | } |
54 | 53 | |
55 | rc = pam_set_item (pamh, PAM_TTY, tty); | |
56 | if (rc != PAM_SUCCESS) | |
57 | { | |
54 | rc = pam_set_item(pamh, PAM_TTY, tty); | |
55 | if (rc != PAM_SUCCESS) { | |
58 | 56 | if (log) |
59 | syslog (LOG_WARNING, "pam_set_item: %s", | |
60 | pam_strerror (pamh, rc)); | |
57 | syslog(LOG_WARNING, "pam_set_item: %s", | |
58 | pam_strerror(pamh, rc)); | |
61 | 59 | else |
62 | 60 | kbd_warning(0, "pam_set_item: %s", |
63 | pam_strerror (pamh, rc)); | |
64 | pam_end (pamh, rc); | |
61 | pam_strerror(pamh, rc)); | |
62 | pam_end(pamh, rc); | |
65 | 63 | return 0; |
66 | 64 | } |
67 | 65 |
21 | 21 | |
22 | 22 | #include <security/pam_appl.h> |
23 | 23 | |
24 | pam_handle_t *init_pam (const char *username, const char *tty, int log); | |
25 | int get_password (pam_handle_t * pamh, const char *username, | |
26 | const char *tty); | |
24 | pam_handle_t *init_pam(const char *username, const char *tty, int log); | |
25 | int get_password(pam_handle_t *pamh, const char *username, | |
26 | const char *tty); |
35 | 35 | * current VT or all of them. |
36 | 36 | * 0 means current, 1 means all. |
37 | 37 | */ |
38 | int o_lock_all; | |
38 | int o_lock_all; | |
39 | 39 | |
40 | 40 | const char * |
41 | locked_name (void) | |
41 | locked_name(void) | |
42 | 42 | { |
43 | 43 | return o_lock_all ? "console" : (is_vt ? "VC" : "tty"); |
44 | 44 | } |
45 | 45 | |
46 | static void __attribute__ ((__noreturn__)) | |
46 | static void __attribute__((__noreturn__)) | |
47 | 47 | show_usage(void) |
48 | 48 | { |
49 | 49 | fprintf(stderr, |
50 | _("Try `%s --help' for more information.\n"), | |
51 | program_invocation_short_name); | |
50 | _("Try `%s --help' for more information.\n"), | |
51 | program_invocation_short_name); | |
52 | 52 | exit(1); |
53 | 53 | } |
54 | 54 | |
55 | static void __attribute__ ((__noreturn__)) | |
55 | static void __attribute__((__noreturn__)) | |
56 | 56 | show_help(void) |
57 | 57 | { |
58 | 58 | printf(_("%s: locks virtual consoles, saving your current session.\n" |
59 | "Usage: %s [options]\n" | |
60 | " Where [options] are any of:\n" | |
61 | "-c or --current: lock only this virtual console, allowing user to\n" | |
62 | " switch to other virtual consoles.\n" | |
63 | "-a or --all: lock all virtual consoles by preventing other users\n" | |
64 | " from switching virtual consoles.\n" | |
65 | "-v or --version: Print the version number of vlock and exit.\n" | |
66 | "-h or --help: Print this help message and exit.\n"), | |
59 | "Usage: %s [options]\n" | |
60 | " Where [options] are any of:\n" | |
61 | "-c or --current: lock only this virtual console, allowing user to\n" | |
62 | " switch to other virtual consoles.\n" | |
63 | "-a or --all: lock all virtual consoles by preventing other users\n" | |
64 | " from switching virtual consoles.\n" | |
65 | "-v or --version: Print the version number of vlock and exit.\n" | |
66 | "-h or --help: Print this help message and exit.\n"), | |
67 | 67 | progname, progname); |
68 | 68 | exit(0); |
69 | 69 | } |
70 | 70 | |
71 | void | |
72 | parse (int ac, char *const av[]) | |
71 | void parse(int ac, char *const av[]) | |
73 | 72 | { |
74 | 73 | static struct option long_options[] = { |
75 | {"current", 0, 0, 'c'}, | |
76 | {"all", 0, 0, 'a'}, | |
77 | {"version", 0, 0, 'v'}, | |
78 | {"help", 0, 0, 'h'}, | |
79 | {0, 0, 0, 0}, | |
74 | { "current", 0, 0, 'c' }, | |
75 | { "all", 0, 0, 'a' }, | |
76 | { "version", 0, 0, 'v' }, | |
77 | { "help", 0, 0, 'h' }, | |
78 | { 0, 0, 0, 0 }, | |
80 | 79 | }; |
81 | int c; | |
80 | int c; | |
82 | 81 | |
83 | while ((c = getopt_long(ac, av, "acvh", long_options, 0)) != -1) | |
84 | { | |
85 | switch (c) | |
86 | { | |
82 | while ((c = getopt_long(ac, av, "acvh", long_options, 0)) != -1) { | |
83 | switch (c) { | |
87 | 84 | case 'c': |
88 | 85 | o_lock_all = 0; |
89 | 86 | break; |
31 | 31 | |
32 | 32 | static unsigned char lines, columns; |
33 | 33 | static void *screen_buf = 0; |
34 | static int vcs = -1; | |
34 | static int vcs = -1; | |
35 | 35 | |
36 | void | |
37 | init_screen(void) | |
36 | void init_screen(void) | |
38 | 37 | { |
39 | int failed = 1; | |
38 | int failed = 1; | |
40 | 39 | const char clear_str[] = "\33[3J\33[H\33[J"; |
41 | 40 | |
42 | 41 | vcs = -1; |
43 | do | |
44 | { | |
42 | do { | |
45 | 43 | struct stat st; |
46 | 44 | unsigned i, size; |
47 | char path[16]; | |
45 | char path[16]; | |
48 | 46 | |
49 | 47 | if (fstat(STDIN_FILENO, &st) == -1) |
50 | 48 | break; |
67 | 65 | if (read(vcs, &lines, 1) != 1) |
68 | 66 | break; |
69 | 67 | |
70 | size = 2 * lines * columns + 2; | |
68 | size = 2 * lines * columns + 2; | |
71 | 69 | screen_buf = malloc(size); |
72 | 70 | if (!screen_buf) |
73 | 71 | break; |
74 | 72 | |
75 | if (read(vcs, screen_buf, size) != (int) size) | |
76 | { | |
73 | if (read(vcs, screen_buf, size) != (int)size) { | |
77 | 74 | free(screen_buf); |
78 | 75 | screen_buf = NULL; |
79 | 76 | break; |
82 | 79 | failed = 0; |
83 | 80 | } while (0); |
84 | 81 | |
85 | if (failed && vcs >= 0) | |
86 | { | |
82 | if (failed && vcs >= 0) { | |
87 | 83 | close(vcs); |
88 | 84 | vcs = -1; |
89 | 85 | } |
94 | 90 | return; |
95 | 91 | } |
96 | 92 | |
97 | void | |
98 | restore_screen(void) | |
93 | void restore_screen(void) | |
99 | 94 | { |
100 | if (screen_buf) | |
101 | { | |
102 | do | |
103 | { | |
95 | if (screen_buf) { | |
96 | do { | |
104 | 97 | if (lseek(vcs, 0, SEEK_SET)) |
105 | 98 | break; |
106 | 99 | if (write(vcs, &columns, 1) != 1) |
35 | 35 | * Try to find out proper login name. |
36 | 36 | */ |
37 | 37 | const char * |
38 | get_username (void) | |
38 | get_username(void) | |
39 | 39 | { |
40 | 40 | const char *name; |
41 | 41 | struct passwd *pw = 0; |
42 | uid_t uid = getuid (); | |
42 | uid_t uid = getuid(); | |
43 | 43 | |
44 | char *logname = getenv ("LOGNAME"); | |
44 | char *logname = getenv("LOGNAME"); | |
45 | 45 | |
46 | if (logname) | |
47 | { | |
48 | pw = getpwnam (logname); | |
46 | if (logname) { | |
47 | pw = getpwnam(logname); | |
49 | 48 | /* Ensure uid is same as current. */ |
50 | 49 | if (pw && pw->pw_uid != uid) |
51 | 50 | pw = 0; |
52 | 51 | } |
53 | 52 | if (!pw) |
54 | pw = getpwuid (uid); | |
53 | pw = getpwuid(uid); | |
55 | 54 | |
56 | 55 | if (!pw) |
57 | kbd_error (EXIT_FAILURE, 0, _("unrecognized user")); | |
56 | kbd_error(EXIT_FAILURE, 0, _("unrecognized user")); | |
58 | 57 | |
59 | name = strdup (pw->pw_name); | |
58 | name = strdup(pw->pw_name); | |
60 | 59 | if (!name) |
61 | kbd_error (EXIT_FAILURE, errno, "strdup"); | |
60 | kbd_error(EXIT_FAILURE, errno, "strdup"); | |
62 | 61 | |
63 | endpwent (); | |
62 | endpwent(); | |
64 | 63 | return name; |
65 | 64 | } |
35 | 35 | #include "version.h" |
36 | 36 | #include "kbd_error.h" |
37 | 37 | |
38 | int | |
39 | main (int ac, char *const av[]) | |
38 | int main(int ac, char *const av[]) | |
40 | 39 | { |
41 | int rc; | |
40 | int rc; | |
42 | 41 | const char dev_prefix[] = "/dev/"; |
43 | 42 | const char *username, *tty; |
44 | 43 | pam_handle_t *pamh; |
50 | 49 | textdomain(PACKAGE_NAME); |
51 | 50 | |
52 | 51 | /* 1st, parse command line arguments. */ |
53 | parse (ac, av); | |
52 | parse(ac, av); | |
54 | 53 | |
55 | 54 | /* 2nd, find out tty name... */ |
56 | tty = ttyname (STDIN_FILENO); | |
55 | tty = ttyname(STDIN_FILENO); | |
57 | 56 | if (!tty) |
58 | 57 | /* stdin is not a tty, so no need to try. */ |
59 | kbd_error (EXIT_FAILURE, 0, _("stdin is not a tty")); | |
58 | kbd_error(EXIT_FAILURE, 0, _("stdin is not a tty")); | |
60 | 59 | |
61 | 60 | /* ... and strip its /dev/ prefix. */ |
62 | if (!strncmp (tty, dev_prefix, sizeof (dev_prefix) - 1)) | |
63 | tty += sizeof (dev_prefix) - 1; | |
61 | if (!strncmp(tty, dev_prefix, sizeof(dev_prefix) - 1)) | |
62 | tty += sizeof(dev_prefix) - 1; | |
64 | 63 | |
65 | 64 | /* 3rd, get username for PAM. */ |
66 | username = get_username (); | |
65 | username = get_username(); | |
67 | 66 | |
68 | 67 | /* 4th, initialize system logger. */ |
69 | openlog ("vlock", LOG_PID, LOG_AUTH); | |
68 | openlog("vlock", LOG_PID, LOG_AUTH); | |
70 | 69 | |
71 | 70 | /* 5th, initialize PAM. */ |
72 | if (!(pamh = init_pam (username, tty, 0))) | |
73 | exit (EXIT_FAILURE); | |
71 | if (!(pamh = init_pam(username, tty, 0))) | |
72 | exit(EXIT_FAILURE); | |
74 | 73 | |
75 | 74 | /* 6th, initialize VT, tty and screen. */ |
76 | if (!init_vt (tty)) | |
77 | { | |
78 | pam_end (pamh, PAM_SUCCESS); | |
79 | exit (EXIT_FAILURE); | |
75 | if (!init_vt(tty)) { | |
76 | pam_end(pamh, PAM_SUCCESS); | |
77 | exit(EXIT_FAILURE); | |
80 | 78 | } |
81 | 79 | |
82 | 80 | /* 7th, Log the fact of console locking. */ |
83 | syslog (LOG_NOTICE, "Locked %s on %s for %s by (uid=%u)", | |
84 | locked_name (), tty, username, getuid ()); | |
81 | syslog(LOG_NOTICE, "Locked %s on %s for %s by (uid=%u)", | |
82 | locked_name(), tty, username, getuid()); | |
85 | 83 | |
86 | rc = get_password (pamh, username, tty); | |
87 | restore_vt (); | |
84 | rc = get_password(pamh, username, tty); | |
85 | restore_vt(); | |
88 | 86 | |
89 | 87 | return rc; |
90 | 88 | } |
20 | 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 | 21 | */ |
22 | 22 | |
23 | int init_vt (const char *tty); | |
24 | void restore_vt (void); | |
23 | int init_vt(const char *tty); | |
24 | void restore_vt(void); | |
25 | 25 | |
26 | void init_screen (void); | |
27 | void restore_screen (void); | |
26 | void init_screen(void); | |
27 | void restore_screen(void); | |
28 | 28 | |
29 | const char *get_username (void); | |
29 | const char *get_username(void); | |
30 | 30 | |
31 | void parse (int ac, char *const av[]); | |
31 | void parse(int ac, char *const av[]); | |
32 | 32 | |
33 | const char *locked_name (void); | |
33 | const char *locked_name(void); | |
34 | 34 | |
35 | 35 | /* |
36 | 36 | * This determines whether the default behavior is to lock only the |
43 | 43 | static int vfd = -1; |
44 | 44 | |
45 | 45 | /* Copy of the VT mode when the program was started. */ |
46 | int is_vt; | |
46 | int is_vt; | |
47 | 47 | |
48 | 48 | /* |
49 | 49 | * This is called by a signal whenever a user tries to change |
50 | 50 | * the VC (with a ALT-Fn key or via VT_ACTIVATE). |
51 | 51 | */ |
52 | 52 | static void |
53 | release_vt (__attribute__ ((unused)) int signo) | |
53 | release_vt(__attribute__((unused)) int signo) | |
54 | 54 | { |
55 | 55 | /* |
56 | 56 | * Kernel is not allowed to switch. |
57 | 57 | * Return code is silently ignored. |
58 | 58 | */ |
59 | ioctl (vfd, VT_RELDISP, 0); | |
59 | ioctl(vfd, VT_RELDISP, 0); | |
60 | 60 | } |
61 | 61 | |
62 | 62 | /* This is called whenever a user switches to that VC. */ |
63 | 63 | static void |
64 | acquire_vt (__attribute__ ((unused)) int signo) | |
64 | acquire_vt(__attribute__((unused)) int signo) | |
65 | 65 | { |
66 | 66 | /* |
67 | 67 | * This call is not currently required under Linux, |
68 | 68 | * but it won't hurt, either. |
69 | 69 | * Return code is silently ignored. |
70 | 70 | */ |
71 | ioctl (vfd, VT_RELDISP, VT_ACKACQ); | |
71 | ioctl(vfd, VT_RELDISP, VT_ACKACQ); | |
72 | 72 | } |
73 | 73 | |
74 | 74 | /* Set the signal masks and handlers. */ |
75 | 75 | static void |
76 | mask_signals (void) | |
76 | mask_signals(void) | |
77 | 77 | { |
78 | 78 | |
79 | 79 | static sigset_t sig; |
80 | 80 | static struct sigaction sa; |
81 | 81 | |
82 | memset (&sa, 0, sizeof sa); | |
83 | sigemptyset (&(sa.sa_mask)); | |
82 | memset(&sa, 0, sizeof sa); | |
83 | sigemptyset(&(sa.sa_mask)); | |
84 | 84 | sa.sa_flags = SA_RESTART; |
85 | 85 | |
86 | if (o_lock_all) | |
87 | { | |
86 | if (o_lock_all) { | |
88 | 87 | /* handle SIGUSR{1,2}... */ |
89 | 88 | sa.sa_handler = release_vt; |
90 | sigaction (SIGUSR1, &sa, 0); | |
89 | sigaction(SIGUSR1, &sa, 0); | |
91 | 90 | sa.sa_handler = acquire_vt; |
92 | sigaction (SIGUSR2, &sa, 0); | |
91 | sigaction(SIGUSR2, &sa, 0); | |
93 | 92 | |
94 | 93 | /* ... and ensure they are unblocked. */ |
95 | sigemptyset (&sig); | |
96 | sigaddset (&sig, SIGUSR1); | |
97 | sigaddset (&sig, SIGUSR2); | |
98 | sigprocmask (SIG_UNBLOCK, &sig, 0); | |
94 | sigemptyset(&sig); | |
95 | sigaddset(&sig, SIGUSR1); | |
96 | sigaddset(&sig, SIGUSR2); | |
97 | sigprocmask(SIG_UNBLOCK, &sig, 0); | |
99 | 98 | } |
100 | 99 | |
101 | 100 | /* Ignore all the rest. */ |
102 | 101 | sa.sa_handler = SIG_IGN; |
103 | if (!o_lock_all) | |
104 | { | |
105 | sigaction (SIGUSR1, &sa, 0); | |
106 | sigaction (SIGUSR2, &sa, 0); | |
107 | } | |
108 | sigaction (SIGHUP, &sa, 0); | |
109 | sigaction (SIGINT, &sa, 0); | |
110 | sigaction (SIGQUIT, &sa, 0); | |
111 | sigaction (SIGPIPE, &sa, 0); | |
112 | sigaction (SIGALRM, &sa, 0); | |
113 | sigaction (SIGTERM, &sa, 0); | |
114 | sigaction (SIGTSTP, &sa, 0); | |
115 | sigaction (SIGTTIN, &sa, 0); | |
116 | sigaction (SIGTTOU, &sa, 0); | |
117 | sigaction (SIGURG, &sa, 0); | |
118 | sigaction (SIGVTALRM, &sa, 0); | |
119 | sigaction (SIGIO, &sa, 0); | |
120 | sigaction (SIGPWR, &sa, 0); | |
102 | if (!o_lock_all) { | |
103 | sigaction(SIGUSR1, &sa, 0); | |
104 | sigaction(SIGUSR2, &sa, 0); | |
105 | } | |
106 | sigaction(SIGHUP, &sa, 0); | |
107 | sigaction(SIGINT, &sa, 0); | |
108 | sigaction(SIGQUIT, &sa, 0); | |
109 | sigaction(SIGPIPE, &sa, 0); | |
110 | sigaction(SIGALRM, &sa, 0); | |
111 | sigaction(SIGTERM, &sa, 0); | |
112 | sigaction(SIGTSTP, &sa, 0); | |
113 | sigaction(SIGTTIN, &sa, 0); | |
114 | sigaction(SIGTTOU, &sa, 0); | |
115 | sigaction(SIGURG, &sa, 0); | |
116 | sigaction(SIGVTALRM, &sa, 0); | |
117 | sigaction(SIGIO, &sa, 0); | |
118 | sigaction(SIGPWR, &sa, 0); | |
121 | 119 | |
122 | 120 | /* |
123 | 121 | * Also block SIGCHLD. |
124 | 122 | * Not really needed; just make sleep(3) more easy. |
125 | 123 | */ |
126 | sigemptyset (&sig); | |
127 | sigaddset (&sig, SIGCHLD); | |
128 | sigprocmask (SIG_BLOCK, &sig, 0); | |
129 | } | |
130 | ||
131 | int | |
132 | init_vt (const char *tty) | |
124 | sigemptyset(&sig); | |
125 | sigaddset(&sig, SIGCHLD); | |
126 | sigprocmask(SIG_BLOCK, &sig, 0); | |
127 | } | |
128 | ||
129 | int init_vt(const char *tty) | |
133 | 130 | { |
134 | 131 | const char dev_tty[] = "/dev/tty"; |
135 | 132 | |
136 | vfd = open (dev_tty, O_RDWR); | |
137 | if (vfd < 0) | |
138 | { | |
133 | vfd = open(dev_tty, O_RDWR); | |
134 | if (vfd < 0) { | |
139 | 135 | kbd_warning(errno, "could not open %s", dev_tty); |
140 | 136 | return 0; |
141 | 137 | } |
146 | 142 | * and will print a warning message. |
147 | 143 | * - If it doesn't fail, it gets the current VT status. |
148 | 144 | */ |
149 | if (ioctl (vfd, VT_GETMODE, &ovtm) < 0) | |
150 | { | |
145 | if (ioctl(vfd, VT_GETMODE, &ovtm) < 0) { | |
151 | 146 | is_vt = 0; |
152 | fprintf (stderr, _("This tty (%s) is not a virtual console.\n"), | |
153 | tty); | |
154 | if (o_lock_all) | |
155 | { | |
147 | fprintf(stderr, _("This tty (%s) is not a virtual console.\n"), | |
148 | tty); | |
149 | if (o_lock_all) { | |
156 | 150 | o_lock_all = 0; |
157 | close (vfd); | |
151 | close(vfd); | |
158 | 152 | vfd = -1; |
159 | fprintf (stderr, | |
160 | _("The entire console display cannot be locked.\n")); | |
153 | fprintf(stderr, | |
154 | _("The entire console display cannot be locked.\n")); | |
161 | 155 | return 0; |
162 | 156 | } |
163 | fprintf (stderr, "\n\n"); | |
164 | fflush (stderr); | |
165 | } else | |
166 | { | |
157 | fprintf(stderr, "\n\n"); | |
158 | fflush(stderr); | |
159 | } else { | |
167 | 160 | is_vt = 1; |
168 | 161 | } |
169 | 162 | |
170 | 163 | /* If we aren't going to lock console, we don't need VT descriptor. */ |
171 | if (!o_lock_all) | |
172 | { | |
173 | close (vfd); | |
164 | if (!o_lock_all) { | |
165 | close(vfd); | |
174 | 166 | vfd = -1; |
175 | 167 | } |
176 | 168 | |
177 | mask_signals (); | |
178 | ||
179 | if (o_lock_all) | |
180 | { | |
169 | mask_signals(); | |
170 | ||
171 | if (o_lock_all) { | |
181 | 172 | struct vt_mode vtm = ovtm; |
182 | 173 | |
183 | vtm.mode = VT_PROCESS; /* Process controls switching. */ | |
184 | vtm.relsig = SIGUSR1; /* Signal to raise on release request, handled by release_vt(). */ | |
185 | vtm.acqsig = SIGUSR2; /* Signal to raise on acquisition, handled by acquire_vt(). */ | |
174 | vtm.mode = VT_PROCESS; /* Process controls switching. */ | |
175 | vtm.relsig = SIGUSR1; /* Signal to raise on release request, handled by release_vt(). */ | |
176 | vtm.acqsig = SIGUSR2; /* Signal to raise on acquisition, handled by acquire_vt(). */ | |
186 | 177 | |
187 | 178 | /* Set mode of active vt. */ |
188 | if (ioctl (vfd, VT_SETMODE, &vtm) < 0) | |
189 | { | |
179 | if (ioctl(vfd, VT_SETMODE, &vtm) < 0) { | |
190 | 180 | kbd_warning(errno, "ioctl VT_SETMODE"); |
191 | 181 | return 0; |
192 | 182 | } |
193 | 183 | } |
194 | 184 | |
195 | 185 | if (is_vt) |
196 | init_screen (); | |
186 | init_screen(); | |
197 | 187 | |
198 | 188 | return 1; |
199 | 189 | } |
200 | 190 | |
201 | void | |
202 | restore_vt (void) | |
203 | { | |
204 | if (is_vt) | |
205 | { | |
206 | restore_screen (); | |
207 | ||
208 | if (o_lock_all) | |
209 | { | |
191 | void restore_vt(void) | |
192 | { | |
193 | if (is_vt) { | |
194 | restore_screen(); | |
195 | ||
196 | if (o_lock_all) { | |
210 | 197 | /* |
211 | 198 | * Reset mode of active vt. |
212 | 199 | * Don't check return code - it won't help anyway. |
213 | 200 | */ |
214 | ioctl (vfd, VT_SETMODE, &ovtm); | |
201 | ioctl(vfd, VT_SETMODE, &ovtm); | |
215 | 202 | } |
216 | 203 | } |
217 | 204 | } |
12 | 12 | but stopped that after i found a system which made wchar_t an |
13 | 13 | unsigned char. |
14 | 14 | */ |
15 | enum | |
16 | { | |
17 | T1 = 0x00, | |
18 | Tx = 0x80, | |
19 | T2 = 0xC0, | |
20 | T3 = 0xE0, | |
21 | T4 = 0xF0, | |
22 | T5 = 0xF8, | |
23 | T6 = 0xFC, | |
15 | enum { | |
16 | T1 = 0x00, | |
17 | Tx = 0x80, | |
18 | T2 = 0xC0, | |
19 | T3 = 0xE0, | |
20 | T4 = 0xF0, | |
21 | T5 = 0xF8, | |
22 | T6 = 0xFC, | |
24 | 23 | |
25 | Bit1 = 7, | |
26 | Bitx = 6, | |
27 | Bit2 = 5, | |
28 | Bit3 = 4, | |
29 | Bit4 = 3, | |
30 | Bit5 = 2, | |
31 | Bit6 = 2, | |
24 | Bit1 = 7, | |
25 | Bitx = 6, | |
26 | Bit2 = 5, | |
27 | Bit3 = 4, | |
28 | Bit4 = 3, | |
29 | Bit5 = 2, | |
30 | Bit6 = 2, | |
32 | 31 | |
33 | Mask1 = (1<<Bit1)-1, | |
34 | Maskx = (1<<Bitx)-1, | |
35 | Mask2 = (1<<Bit2)-1, | |
36 | Mask3 = (1<<Bit3)-1, | |
37 | Mask4 = (1<<Bit4)-1, | |
38 | Mask5 = (1<<Bit5)-1, | |
39 | Mask6 = (1<<Bit6)-1, | |
32 | Mask1 = (1 << Bit1) - 1, | |
33 | Maskx = (1 << Bitx) - 1, | |
34 | Mask2 = (1 << Bit2) - 1, | |
35 | Mask3 = (1 << Bit3) - 1, | |
36 | Mask4 = (1 << Bit4) - 1, | |
37 | Mask5 = (1 << Bit5) - 1, | |
38 | Mask6 = (1 << Bit6) - 1, | |
40 | 39 | |
41 | Wchar1 = (1UL<<Bit1)-1, | |
42 | Wchar2 = (1UL<<(Bit2+Bitx))-1, | |
43 | Wchar3 = (1UL<<(Bit3+2*Bitx))-1, | |
44 | Wchar4 = (1UL<<(Bit4+3*Bitx))-1, | |
45 | Wchar5 = (1UL<<(Bit5+4*Bitx))-1 | |
40 | Wchar1 = (1UL << Bit1) - 1, | |
41 | Wchar2 = (1UL << (Bit2 + Bitx)) - 1, | |
42 | Wchar3 = (1UL << (Bit3 + 2 * Bitx)) - 1, | |
43 | Wchar4 = (1UL << (Bit4 + 3 * Bitx)) - 1, | |
44 | Wchar5 = (1UL << (Bit5 + 4 * Bitx)) - 1 | |
46 | 45 | |
47 | #ifndef EILSEQ | |
46 | #ifndef EILSEQ | |
48 | 47 | , /* we hate ansi c's comma rules */ |
49 | EILSEQ = 123 | |
48 | EILSEQ = 123 | |
50 | 49 | #endif /* PLAN9 */ |
51 | 50 | }; |
52 | 51 | |
53 | 52 | static int |
54 | 53 | our_wctomb(char *s, unsigned long wc) |
55 | 54 | { |
56 | if(s == 0) | |
57 | return 0; /* no shift states */ | |
58 | if(wc & ~Wchar2) { | |
59 | if(wc & ~Wchar4) { | |
60 | if(wc & ~Wchar5) { | |
55 | if (s == 0) | |
56 | return 0; /* no shift states */ | |
57 | if (wc & ~Wchar2) { | |
58 | if (wc & ~Wchar4) { | |
59 | if (wc & ~Wchar5) { | |
61 | 60 | /* 6 bytes */ |
62 | s[0] = T6 | ((wc >> 5*Bitx) & Mask6); | |
63 | s[1] = Tx | ((wc >> 4*Bitx) & Maskx); | |
64 | s[2] = Tx | ((wc >> 3*Bitx) & Maskx); | |
65 | s[3] = Tx | ((wc >> 2*Bitx) & Maskx); | |
66 | s[4] = Tx | ((wc >> 1*Bitx) & Maskx); | |
67 | s[5] = Tx | (wc & Maskx); | |
61 | s[0] = T6 | ((wc >> 5 * Bitx) & Mask6); | |
62 | s[1] = Tx | ((wc >> 4 * Bitx) & Maskx); | |
63 | s[2] = Tx | ((wc >> 3 * Bitx) & Maskx); | |
64 | s[3] = Tx | ((wc >> 2 * Bitx) & Maskx); | |
65 | s[4] = Tx | ((wc >> 1 * Bitx) & Maskx); | |
66 | s[5] = Tx | (wc & Maskx); | |
68 | 67 | return 6; |
69 | 68 | } |
70 | 69 | /* 5 bytes */ |
71 | s[0] = T5 | (wc >> 4*Bitx); | |
72 | s[1] = Tx | ((wc >> 3*Bitx) & Maskx); | |
73 | s[2] = Tx | ((wc >> 2*Bitx) & Maskx); | |
74 | s[3] = Tx | ((wc >> 1*Bitx) & Maskx); | |
75 | s[4] = Tx | (wc & Maskx); | |
70 | s[0] = T5 | (wc >> 4 * Bitx); | |
71 | s[1] = Tx | ((wc >> 3 * Bitx) & Maskx); | |
72 | s[2] = Tx | ((wc >> 2 * Bitx) & Maskx); | |
73 | s[3] = Tx | ((wc >> 1 * Bitx) & Maskx); | |
74 | s[4] = Tx | (wc & Maskx); | |
76 | 75 | return 5; |
77 | 76 | } |
78 | if(wc & ~Wchar3) { | |
77 | if (wc & ~Wchar3) { | |
79 | 78 | /* 4 bytes */ |
80 | s[0] = T4 | (wc >> 3*Bitx); | |
81 | s[1] = Tx | ((wc >> 2*Bitx) & Maskx); | |
82 | s[2] = Tx | ((wc >> 1*Bitx) & Maskx); | |
83 | s[3] = Tx | (wc & Maskx); | |
79 | s[0] = T4 | (wc >> 3 * Bitx); | |
80 | s[1] = Tx | ((wc >> 2 * Bitx) & Maskx); | |
81 | s[2] = Tx | ((wc >> 1 * Bitx) & Maskx); | |
82 | s[3] = Tx | (wc & Maskx); | |
84 | 83 | return 4; |
85 | 84 | } |
86 | 85 | /* 3 bytes */ |
87 | s[0] = T3 | (wc >> 2*Bitx); | |
88 | s[1] = Tx | ((wc >> 1*Bitx) & Maskx); | |
89 | s[2] = Tx | (wc & Maskx); | |
86 | s[0] = T3 | (wc >> 2 * Bitx); | |
87 | s[1] = Tx | ((wc >> 1 * Bitx) & Maskx); | |
88 | s[2] = Tx | (wc & Maskx); | |
90 | 89 | return 3; |
91 | 90 | } |
92 | if(wc & ~Wchar1) { | |
91 | if (wc & ~Wchar1) { | |
93 | 92 | /* 2 bytes */ |
94 | s[0] = T2 | (wc >> 1*Bitx); | |
93 | s[0] = T2 | (wc >> 1 * Bitx); | |
95 | 94 | s[1] = Tx | (wc & Maskx); |
96 | 95 | return 2; |
97 | 96 | } |
11 | 11 | |
12 | 12 | extern char *progname; |
13 | 13 | |
14 | static void __attribute__ ((noreturn)) | |
15 | nomem(void) { | |
14 | static void __attribute__((noreturn)) | |
15 | nomem(void) | |
16 | { | |
16 | 17 | fprintf(stderr, _("%s: out of memory\n"), progname); |
17 | 18 | exit(EX_OSERR); |
18 | 19 | } |
19 | 20 | |
20 | 21 | void * |
21 | xmalloc(size_t sz) { | |
22 | xmalloc(size_t sz) | |
23 | { | |
22 | 24 | void *p = malloc(sz); |
23 | 25 | if (p == NULL) |
24 | 26 | nomem(); |
26 | 28 | } |
27 | 29 | |
28 | 30 | void * |
29 | xrealloc(void *pp, size_t sz) { | |
31 | xrealloc(void *pp, size_t sz) | |
32 | { | |
30 | 33 | void *p = realloc(pp, sz); |
31 | 34 | if (p == NULL) |
32 | 35 | nomem(); |
34 | 37 | } |
35 | 38 | |
36 | 39 | char * |
37 | xstrdup(char *p) { | |
40 | xstrdup(char *p) | |
41 | { | |
38 | 42 | char *q = strdup(p); |
39 | 43 | if (q == NULL) |
40 | 44 | nomem(); |
42 | 46 | } |
43 | 47 | |
44 | 48 | char * |
45 | xstrndup(char *p, size_t n) { | |
49 | xstrndup(char *p, size_t n) | |
50 | { | |
46 | 51 | char *q = strndup(p, n); |
47 | 52 | if (q == NULL) |
48 | 53 | nomem(); |
50 | 55 | } |
51 | 56 | |
52 | 57 | void * |
53 | xfree(void *p) { | |
58 | xfree(void *p) | |
59 | { | |
54 | 60 | if (p != NULL) |
55 | 61 | free(p); |
56 | 62 | return NULL; |
4 | 4 | #include <linux/kd.h> |
5 | 5 | |
6 | 6 | unsigned short plain_map[NR_KEYS] = { |
7 | 0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, | |
8 | 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, | |
9 | 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, | |
10 | 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, | |
11 | 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, | |
12 | 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, | |
13 | 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, | |
14 | 0xf703, 0xf020, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, | |
15 | 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, | |
16 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
17 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, | |
18 | 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
19 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
20 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
21 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
22 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf210, 0xf211, 0xf20e, | |
23 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
24 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
25 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
26 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
27 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
28 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
29 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
30 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
31 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
32 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
33 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
34 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
35 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
36 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
37 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
38 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
7 | 0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, | |
8 | 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, | |
9 | 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, | |
10 | 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, | |
11 | 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, | |
12 | 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, | |
13 | 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, | |
14 | 0xf703, 0xf020, 0xf207, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, | |
15 | 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, | |
16 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
17 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, | |
18 | 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
19 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
20 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
21 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
22 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf210, 0xf211, 0xf20e, | |
23 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
24 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
25 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
26 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
27 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
28 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
29 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
30 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
31 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
32 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
33 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
34 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
35 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
36 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
37 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
38 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
39 | 39 | }; |
40 | 40 | |
41 | 41 | static unsigned short shift_map[NR_KEYS] = { |
42 | 0xf200, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, | |
43 | 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf809, | |
44 | 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, | |
45 | 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, | |
46 | 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, | |
47 | 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, | |
48 | 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, | |
49 | 0xf703, 0xf020, 0xf207, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, | |
50 | 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, | |
51 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
52 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, | |
53 | 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
54 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
55 | 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, | |
56 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
57 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf206, 0xf206, 0xf210, | |
58 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
59 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
60 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
61 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
62 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
63 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
64 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
65 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
66 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
67 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
68 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
69 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
70 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
71 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
72 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
73 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
42 | 0xf200, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, | |
43 | 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf809, | |
44 | 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, | |
45 | 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, | |
46 | 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, | |
47 | 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, | |
48 | 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, | |
49 | 0xf703, 0xf020, 0xf207, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, | |
50 | 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, | |
51 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
52 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, | |
53 | 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
54 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
55 | 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, | |
56 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
57 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf206, 0xf206, 0xf210, | |
58 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
59 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
60 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
61 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
62 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
63 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
64 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
65 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
66 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
67 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
68 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
69 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
70 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
71 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
72 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
73 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
74 | 74 | }; |
75 | 75 | |
76 | 76 | static unsigned short altgr_map[NR_KEYS] = { |
77 | 0xf200, 0xf200, 0xf200, 0xf040, 0xf200, 0xf024, 0xf200, 0xf200, | |
78 | 0xf07b, 0xf05b, 0xf05d, 0xf07d, 0xf05c, 0xf200, 0xf200, 0xf200, | |
79 | 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, | |
80 | 0xfb6f, 0xfb70, 0xf200, 0xf07e, 0xf201, 0xf702, 0xfb61, 0xfb73, | |
81 | 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf200, | |
82 | 0xf200, 0xf200, 0xf700, 0xf200, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, | |
83 | 0xfb62, 0xfb6e, 0xfb6d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
84 | 0xf703, 0xf200, 0xf207, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, | |
85 | 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf202, 0xf307, | |
86 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
87 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, | |
88 | 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
89 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
90 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
91 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
92 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf211, 0xf210, 0xf211, | |
93 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
94 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
95 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
96 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
97 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
98 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
99 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
100 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
101 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
102 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
103 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
104 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
105 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
106 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
107 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
108 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
77 | 0xf200, 0xf200, 0xf200, 0xf040, 0xf200, 0xf024, 0xf200, 0xf200, | |
78 | 0xf07b, 0xf05b, 0xf05d, 0xf07d, 0xf05c, 0xf200, 0xf200, 0xf200, | |
79 | 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, | |
80 | 0xfb6f, 0xfb70, 0xf200, 0xf07e, 0xf201, 0xf702, 0xfb61, 0xfb73, | |
81 | 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf200, | |
82 | 0xf200, 0xf200, 0xf700, 0xf200, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, | |
83 | 0xfb62, 0xfb6e, 0xfb6d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
84 | 0xf703, 0xf200, 0xf207, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, | |
85 | 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf202, 0xf307, | |
86 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
87 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, | |
88 | 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
89 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
90 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
91 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
92 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf211, 0xf210, 0xf211, | |
93 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
94 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
95 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
96 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
97 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
98 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
99 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
100 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
101 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
102 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
103 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
104 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
105 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
106 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
107 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
108 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
109 | 109 | }; |
110 | 110 | |
111 | 111 | static unsigned short shift_altgr_map[NR_KEYS] = { |
112 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
113 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
114 | 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, | |
115 | 0xfb4f, 0xfb50, 0xf200, 0xf200, 0xf201, 0xf702, 0xfb41, 0xfb53, | |
116 | 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf200, | |
117 | 0xf200, 0xf200, 0xf700, 0xf200, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, | |
118 | 0xfb42, 0xfb4e, 0xfb4d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
119 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
120 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
121 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
122 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
123 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
124 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
125 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
126 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
127 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf20e, 0xf20e, 0xf206, | |
128 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
129 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
130 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
131 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
132 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
133 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
134 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
135 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
136 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
137 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
138 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
139 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
140 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
141 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
142 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
143 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
112 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
113 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
114 | 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, | |
115 | 0xfb4f, 0xfb50, 0xf200, 0xf200, 0xf201, 0xf702, 0xfb41, 0xfb53, | |
116 | 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf200, | |
117 | 0xf200, 0xf200, 0xf700, 0xf200, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, | |
118 | 0xfb42, 0xfb4e, 0xfb4d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
119 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
120 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
121 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
122 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
123 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
124 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
125 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
126 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
127 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf20e, 0xf20e, 0xf206, | |
128 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
129 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
130 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
131 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
132 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
133 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
134 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
135 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
136 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
137 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
138 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
139 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
140 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
141 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
142 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
143 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
144 | 144 | }; |
145 | 145 | |
146 | 146 | static unsigned short ctrl_map[NR_KEYS] = { |
147 | 0xf200, 0xf200, 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e, | |
148 | 0xf01f, 0xf07f, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf200, | |
149 | 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, | |
150 | 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf201, 0xf702, 0xf001, 0xf013, | |
151 | 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, | |
152 | 0xf007, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, | |
153 | 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, | |
154 | 0xf703, 0xf000, 0xf207, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, | |
155 | 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, | |
156 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
157 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf12c, | |
158 | 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
159 | 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, | |
160 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
161 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
162 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
163 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
164 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
165 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
166 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
167 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
168 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
169 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
170 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
171 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
172 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
173 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
174 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
175 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
176 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
177 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
178 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
147 | 0xf200, 0xf200, 0xf200, 0xf000, 0xf01b, 0xf01c, 0xf01d, 0xf01e, | |
148 | 0xf01f, 0xf07f, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf200, | |
149 | 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, | |
150 | 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf201, 0xf702, 0xf001, 0xf013, | |
151 | 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, | |
152 | 0xf007, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, | |
153 | 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, | |
154 | 0xf703, 0xf000, 0xf207, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, | |
155 | 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, | |
156 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
157 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf12c, | |
158 | 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
159 | 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, | |
160 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
161 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
162 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
163 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
164 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
165 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
166 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
167 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
168 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
169 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
170 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
171 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
172 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
173 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
174 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
175 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
176 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
177 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
178 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
179 | 179 | }; |
180 | 180 | |
181 | 181 | static unsigned short shift_ctrl_map[NR_KEYS] = { |
182 | 0xf200, 0xf200, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf200, | |
183 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200, | |
184 | 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, | |
185 | 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, | |
186 | 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, | |
187 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, | |
188 | 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf07f, 0xf700, 0xf30c, | |
189 | 0xf703, 0xf200, 0xf207, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, | |
190 | 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf200, 0xf307, | |
191 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
192 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf138, | |
193 | 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
194 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
195 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
196 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
197 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
198 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
199 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
200 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
201 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
202 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
203 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
204 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
205 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
206 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
207 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
208 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
209 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
210 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
211 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
212 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
213 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
182 | 0xf200, 0xf200, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf200, | |
183 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf200, 0xf200, | |
184 | 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, | |
185 | 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, | |
186 | 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, | |
187 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, | |
188 | 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf07f, 0xf700, 0xf30c, | |
189 | 0xf703, 0xf200, 0xf207, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, | |
190 | 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf200, 0xf307, | |
191 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
192 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf138, | |
193 | 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
194 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
195 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
196 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
197 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
198 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
199 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
200 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
201 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
202 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
203 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
204 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
205 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
206 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
207 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
208 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
209 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
210 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
211 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
212 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
213 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
214 | 214 | }; |
215 | 215 | |
216 | 216 | static unsigned short altgr_ctrl_map[NR_KEYS] = { |
217 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
218 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
219 | 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, | |
220 | 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, | |
221 | 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, | |
222 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, | |
223 | 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
224 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
225 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
226 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
227 | 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf200, | |
228 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
229 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
230 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, | |
231 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
232 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
233 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
234 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
235 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
236 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
237 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
238 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
239 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
240 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
241 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
242 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
243 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
244 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
245 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
246 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
247 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
248 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
217 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
218 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
219 | 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, | |
220 | 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, | |
221 | 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, | |
222 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, | |
223 | 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
224 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
225 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
226 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
227 | 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf200, | |
228 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
229 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
230 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, | |
231 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
232 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
233 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
234 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
235 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
236 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
237 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
238 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
239 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
240 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
241 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
242 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
243 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
244 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
245 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
246 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
247 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
248 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
249 | 249 | }; |
250 | 250 | |
251 | 251 | static unsigned short shift_altgr_ctrl_map[NR_KEYS] = { |
252 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
253 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
254 | 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, | |
255 | 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, | |
256 | 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, | |
257 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, | |
258 | 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
259 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
260 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
261 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
262 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
263 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
264 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
265 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
266 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
267 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
268 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
269 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
270 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
271 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
272 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
273 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
274 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
275 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
276 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
277 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
278 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
279 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
280 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
281 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
282 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
283 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
252 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
253 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
254 | 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, | |
255 | 0xf00f, 0xf010, 0xf200, 0xf200, 0xf201, 0xf702, 0xf001, 0xf013, | |
256 | 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, | |
257 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf01a, 0xf018, 0xf003, 0xf016, | |
258 | 0xf002, 0xf00e, 0xf00d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
259 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
260 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
261 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
262 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
263 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
264 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
265 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
266 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
267 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
268 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
269 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
270 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
271 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
272 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
273 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
274 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
275 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
276 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
277 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
278 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
279 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
280 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
281 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
282 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
283 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
284 | 284 | }; |
285 | 285 | |
286 | 286 | static unsigned short alt_map[NR_KEYS] = { |
287 | 0xf200, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, | |
288 | 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, | |
289 | 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, | |
290 | 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, | |
291 | 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, | |
292 | 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, | |
293 | 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, | |
294 | 0xf703, 0xf820, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, | |
295 | 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf907, | |
296 | 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, | |
297 | 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, | |
298 | 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
299 | 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, | |
300 | 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
301 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
302 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
303 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
304 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
305 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
306 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
307 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
308 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
309 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
310 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
311 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
312 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
313 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
314 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
315 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
316 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
317 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
318 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
287 | 0xf200, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, | |
288 | 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, | |
289 | 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, | |
290 | 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, | |
291 | 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, | |
292 | 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, | |
293 | 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, | |
294 | 0xf703, 0xf820, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, | |
295 | 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf907, | |
296 | 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, | |
297 | 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, | |
298 | 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
299 | 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf701, 0xf205, 0xf114, 0xf603, | |
300 | 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
301 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
302 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
303 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
304 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
305 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
306 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
307 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
308 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
309 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
310 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
311 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
312 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
313 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
314 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
315 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
316 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
317 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
318 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
319 | 319 | }; |
320 | 320 | |
321 | 321 | static unsigned short shift_alt_map[NR_KEYS] = { |
322 | 0xf200, 0xf200, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, | |
323 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
324 | 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, | |
325 | 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf201, 0xf702, 0xf841, 0xf853, | |
326 | 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf200, | |
327 | 0xf200, 0xf200, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, | |
328 | 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf200, 0xf700, 0xf30c, | |
329 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
330 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
331 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
332 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
333 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
334 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
335 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
336 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
337 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
338 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
339 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
340 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
341 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
342 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
343 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
344 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
345 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
346 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
347 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
348 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
349 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
350 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
351 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
352 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
353 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
322 | 0xf200, 0xf200, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, | |
323 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
324 | 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, | |
325 | 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf201, 0xf702, 0xf841, 0xf853, | |
326 | 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf200, | |
327 | 0xf200, 0xf200, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, | |
328 | 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf200, 0xf700, 0xf30c, | |
329 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
330 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
331 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
332 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
333 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
334 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
335 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
336 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
337 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
338 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
339 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
340 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
341 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
342 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
343 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
344 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
345 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
346 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
347 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
348 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
349 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
350 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
351 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
352 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
353 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
354 | 354 | }; |
355 | 355 | |
356 | 356 | static unsigned short altgr_alt_map[NR_KEYS] = { |
357 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
358 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
359 | 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, | |
360 | 0xf86f, 0xf870, 0xf200, 0xf200, 0xf201, 0xf702, 0xf861, 0xf873, | |
361 | 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf200, | |
362 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf87a, 0xf878, 0xf863, 0xf876, | |
363 | 0xf862, 0xf86e, 0xf86d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
364 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
365 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
366 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
367 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
368 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
369 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
370 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
371 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
372 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
373 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
374 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
375 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
376 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
377 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
378 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
379 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
380 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
381 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
382 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
383 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
384 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
385 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
386 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
387 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
388 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
357 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
358 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
359 | 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, | |
360 | 0xf86f, 0xf870, 0xf200, 0xf200, 0xf201, 0xf702, 0xf861, 0xf873, | |
361 | 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf200, | |
362 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf87a, 0xf878, 0xf863, 0xf876, | |
363 | 0xf862, 0xf86e, 0xf86d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
364 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
365 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
366 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
367 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
368 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
369 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
370 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
371 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
372 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
373 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
374 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
375 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
376 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
377 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
378 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
379 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
380 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
381 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
382 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
383 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
384 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
385 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
386 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
387 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
388 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
389 | 389 | }; |
390 | 390 | |
391 | 391 | static unsigned short shift_altgr_alt_map[NR_KEYS] = { |
392 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
393 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
394 | 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, | |
395 | 0xf84f, 0xf850, 0xf200, 0xf200, 0xf201, 0xf702, 0xf841, 0xf853, | |
396 | 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf200, | |
397 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf85a, 0xf858, 0xf843, 0xf856, | |
398 | 0xf842, 0xf84e, 0xf84d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
399 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
400 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
401 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
402 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
403 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
404 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
405 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
406 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
407 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
408 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
409 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
410 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
411 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
412 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
413 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
414 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
415 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
416 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
417 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
418 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
419 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
420 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
421 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
422 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
423 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
392 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
393 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
394 | 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, | |
395 | 0xf84f, 0xf850, 0xf200, 0xf200, 0xf201, 0xf702, 0xf841, 0xf853, | |
396 | 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf200, | |
397 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf85a, 0xf858, 0xf843, 0xf856, | |
398 | 0xf842, 0xf84e, 0xf84d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
399 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
400 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
401 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
402 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
403 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
404 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
405 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
406 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
407 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
408 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
409 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
410 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
411 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
412 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
413 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
414 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
415 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
416 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
417 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
418 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
419 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
420 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
421 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
422 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
423 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
424 | 424 | }; |
425 | 425 | |
426 | 426 | static unsigned short ctrl_alt_map[NR_KEYS] = { |
427 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
428 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
429 | 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, | |
430 | 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, | |
431 | 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, | |
432 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, | |
433 | 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
434 | 0xf703, 0xf200, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, | |
435 | 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf200, 0xf307, | |
436 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
437 | 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf50a, | |
438 | 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
439 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
440 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, | |
441 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
442 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
443 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
444 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
445 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
446 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
447 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
448 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
449 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
450 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
451 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
452 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
453 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
454 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
455 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
456 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
457 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
458 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
427 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
428 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
429 | 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, | |
430 | 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, | |
431 | 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, | |
432 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, | |
433 | 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
434 | 0xf703, 0xf200, 0xf207, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, | |
435 | 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf200, 0xf307, | |
436 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
437 | 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf200, 0xf50a, | |
438 | 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
439 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
440 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, | |
441 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
442 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
443 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
444 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
445 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
446 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
447 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
448 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
449 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
450 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
451 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
452 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
453 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
454 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
455 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
456 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
457 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
458 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
459 | 459 | }; |
460 | 460 | |
461 | 461 | static unsigned short shift_ctrl_alt_map[NR_KEYS] = { |
462 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
463 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
464 | 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, | |
465 | 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, | |
466 | 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, | |
467 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, | |
468 | 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
469 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
470 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
471 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
472 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
473 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
474 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
475 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
476 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
477 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
478 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
479 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
480 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
481 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
482 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
483 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
484 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
485 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
486 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
487 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
488 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
489 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
490 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
491 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
492 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
493 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
462 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
463 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
464 | 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, | |
465 | 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, | |
466 | 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, | |
467 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, | |
468 | 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
469 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
470 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
471 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
472 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
473 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
474 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
475 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
476 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
477 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
478 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
479 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
480 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
481 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
482 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
483 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
484 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
485 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
486 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
487 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
488 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
489 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
490 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
491 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
492 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
493 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
494 | 494 | }; |
495 | 495 | |
496 | 496 | static unsigned short altgr_ctrl_alt_map[NR_KEYS] = { |
497 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
498 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
499 | 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, | |
500 | 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, | |
501 | 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, | |
502 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, | |
503 | 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
504 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
505 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
506 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
507 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
508 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
509 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
510 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
511 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
512 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
513 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
514 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
515 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
516 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
517 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
518 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
519 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
520 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
521 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
522 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
523 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
524 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
525 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
526 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
527 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
528 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
497 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
498 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
499 | 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, | |
500 | 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, | |
501 | 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, | |
502 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, | |
503 | 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
504 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
505 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
506 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
507 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
508 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
509 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
510 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
511 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
512 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
513 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
514 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
515 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
516 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
517 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
518 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
519 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
520 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
521 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
522 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
523 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
524 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
525 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
526 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
527 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
528 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
529 | 529 | }; |
530 | 530 | |
531 | 531 | static unsigned short shift_altgr_ctrl_alt_map[NR_KEYS] = { |
532 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
533 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
534 | 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, | |
535 | 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, | |
536 | 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, | |
537 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, | |
538 | 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
539 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
540 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
541 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
542 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
543 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
544 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
545 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
546 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
547 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
548 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
549 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
550 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
551 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
552 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
553 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
554 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
555 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
556 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
557 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
558 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
559 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
560 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
561 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
562 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
563 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
532 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
533 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
534 | 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, | |
535 | 0xf80f, 0xf810, 0xf200, 0xf200, 0xf201, 0xf702, 0xf801, 0xf813, | |
536 | 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, | |
537 | 0xf200, 0xf200, 0xf700, 0xf200, 0xf81a, 0xf818, 0xf803, 0xf816, | |
538 | 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf200, 0xf200, 0xf700, 0xf30c, | |
539 | 0xf703, 0xf200, 0xf207, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
540 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf208, 0xf200, 0xf307, | |
541 | 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, | |
542 | 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf200, 0xf200, | |
543 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
544 | 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf701, 0xf205, 0xf114, 0xf603, | |
545 | 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, | |
546 | 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, | |
547 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
548 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
549 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
550 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
551 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
552 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
553 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
554 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
555 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
556 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
557 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
558 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
559 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
560 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
561 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
562 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
563 | 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, | |
564 | 564 | }; |
565 | 565 | |
566 | 566 | ushort *key_maps[MAX_NR_KEYMAPS] = { |
567 | 567 | plain_map, shift_map, altgr_map, shift_altgr_map, |
568 | 568 | ctrl_map, shift_ctrl_map, altgr_ctrl_map, shift_altgr_ctrl_map, |
569 | 569 | alt_map, shift_alt_map, altgr_alt_map, shift_altgr_alt_map, |
570 | ctrl_alt_map, shift_ctrl_alt_map, altgr_ctrl_alt_map, shift_altgr_ctrl_alt_map, 0 | |
570 | ctrl_alt_map, shift_ctrl_alt_map, altgr_ctrl_alt_map, shift_altgr_ctrl_alt_map, 0 | |
571 | 571 | }; |
572 | 572 | |
573 | 573 | unsigned int keymap_count = 16; |
579 | 579 | */ |
580 | 580 | |
581 | 581 | char func_buf[] = { |
582 | '\033', '[', '[', 'A', 0, | |
583 | '\033', '[', '[', 'B', 0, | |
584 | '\033', '[', '[', 'C', 0, | |
585 | '\033', '[', '[', 'D', 0, | |
586 | '\033', '[', '[', 'E', 0, | |
587 | '\033', '[', '1', '7', '~', 0, | |
588 | '\033', '[', '1', '8', '~', 0, | |
589 | '\033', '[', '1', '9', '~', 0, | |
590 | '\033', '[', '2', '0', '~', 0, | |
591 | '\033', '[', '2', '1', '~', 0, | |
592 | '\033', '[', '2', '3', '~', 0, | |
593 | '\033', '[', '2', '4', '~', 0, | |
594 | '\033', '[', '2', '5', '~', 0, | |
595 | '\033', '[', '2', '6', '~', 0, | |
596 | '\033', '[', '2', '8', '~', 0, | |
597 | '\033', '[', '2', '9', '~', 0, | |
598 | '\033', '[', '3', '1', '~', 0, | |
599 | '\033', '[', '3', '2', '~', 0, | |
600 | '\033', '[', '3', '3', '~', 0, | |
601 | '\033', '[', '3', '4', '~', 0, | |
602 | '\033', '[', '1', '~', 0, | |
603 | '\033', '[', '2', '~', 0, | |
604 | '\033', '[', '3', '~', 0, | |
605 | '\033', '[', '4', '~', 0, | |
606 | '\033', '[', '5', '~', 0, | |
607 | '\033', '[', '6', '~', 0, | |
608 | '\033', '[', 'M', 0, | |
609 | '\033', '[', 'P', 0, | |
582 | '\033', '[', '[', 'A', 0, | |
583 | '\033', '[', '[', 'B', 0, | |
584 | '\033', '[', '[', 'C', 0, | |
585 | '\033', '[', '[', 'D', 0, | |
586 | '\033', '[', '[', 'E', 0, | |
587 | '\033', '[', '1', '7', '~', 0, | |
588 | '\033', '[', '1', '8', '~', 0, | |
589 | '\033', '[', '1', '9', '~', 0, | |
590 | '\033', '[', '2', '0', '~', 0, | |
591 | '\033', '[', '2', '1', '~', 0, | |
592 | '\033', '[', '2', '3', '~', 0, | |
593 | '\033', '[', '2', '4', '~', 0, | |
594 | '\033', '[', '2', '5', '~', 0, | |
595 | '\033', '[', '2', '6', '~', 0, | |
596 | '\033', '[', '2', '8', '~', 0, | |
597 | '\033', '[', '2', '9', '~', 0, | |
598 | '\033', '[', '3', '1', '~', 0, | |
599 | '\033', '[', '3', '2', '~', 0, | |
600 | '\033', '[', '3', '3', '~', 0, | |
601 | '\033', '[', '3', '4', '~', 0, | |
602 | '\033', '[', '1', '~', 0, | |
603 | '\033', '[', '2', '~', 0, | |
604 | '\033', '[', '3', '~', 0, | |
605 | '\033', '[', '4', '~', 0, | |
606 | '\033', '[', '5', '~', 0, | |
607 | '\033', '[', '6', '~', 0, | |
608 | '\033', '[', 'M', 0, | |
609 | '\033', '[', 'P', 0, | |
610 | 610 | }; |
611 | 611 | |
612 | 612 | char *funcbufptr = func_buf; |
613 | int funcbufsize = sizeof(func_buf); | |
614 | int funcbufleft = 0; /* space left */ | |
613 | int funcbufsize = sizeof(func_buf); | |
614 | int funcbufleft = 0; /* space left */ | |
615 | 615 | |
616 | 616 | char *func_table[MAX_NR_FUNC] = { |
617 | 617 | func_buf + 0, |
648 | 648 | }; |
649 | 649 | |
650 | 650 | struct kbdiacr accent_table[MAX_DIACR] = { |
651 | {'`', 'A', '\300'}, {'`', 'a', '\340'}, | |
652 | {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, | |
653 | {'^', 'A', '\302'}, {'^', 'a', '\342'}, | |
654 | {'~', 'A', '\303'}, {'~', 'a', '\343'}, | |
655 | {'"', 'A', '\304'}, {'"', 'a', '\344'}, | |
656 | {'O', 'A', '\305'}, {'o', 'a', '\345'}, | |
657 | {'0', 'A', '\305'}, {'0', 'a', '\345'}, | |
658 | {'A', 'A', '\305'}, {'a', 'a', '\345'}, | |
659 | {'A', 'E', '\306'}, {'a', 'e', '\346'}, | |
660 | {',', 'C', '\307'}, {',', 'c', '\347'}, | |
661 | {'`', 'E', '\310'}, {'`', 'e', '\350'}, | |
662 | {'\'', 'E', '\311'}, {'\'', 'e', '\351'}, | |
663 | {'^', 'E', '\312'}, {'^', 'e', '\352'}, | |
664 | {'"', 'E', '\313'}, {'"', 'e', '\353'}, | |
665 | {'`', 'I', '\314'}, {'`', 'i', '\354'}, | |
666 | {'\'', 'I', '\315'}, {'\'', 'i', '\355'}, | |
667 | {'^', 'I', '\316'}, {'^', 'i', '\356'}, | |
668 | {'"', 'I', '\317'}, {'"', 'i', '\357'}, | |
669 | {'-', 'D', '\320'}, {'-', 'd', '\360'}, | |
670 | {'~', 'N', '\321'}, {'~', 'n', '\361'}, | |
671 | {'`', 'O', '\322'}, {'`', 'o', '\362'}, | |
672 | {'\'', 'O', '\323'}, {'\'', 'o', '\363'}, | |
673 | {'^', 'O', '\324'}, {'^', 'o', '\364'}, | |
674 | {'~', 'O', '\325'}, {'~', 'o', '\365'}, | |
675 | {'"', 'O', '\326'}, {'"', 'o', '\366'}, | |
676 | {'/', 'O', '\330'}, {'/', 'o', '\370'}, | |
677 | {'`', 'U', '\331'}, {'`', 'u', '\371'}, | |
678 | {'\'', 'U', '\332'}, {'\'', 'u', '\372'}, | |
679 | {'^', 'U', '\333'}, {'^', 'u', '\373'}, | |
680 | {'"', 'U', '\334'}, {'"', 'u', '\374'}, | |
681 | {'\'', 'Y', '\335'}, {'\'', 'y', '\375'}, | |
682 | {'T', 'H', '\336'}, {'t', 'h', '\376'}, | |
683 | {'s', 's', '\337'}, {'"', 'y', '\377'}, | |
684 | {'s', 'z', '\337'}, {'i', 'j', '\377'}, | |
651 | { '`', 'A', '\300' }, { '`', 'a', '\340' }, { '\'', 'A', '\301' }, { '\'', 'a', '\341' }, { '^', 'A', '\302' }, { '^', 'a', '\342' }, { '~', 'A', '\303' }, { '~', 'a', '\343' }, { '"', 'A', '\304' }, { '"', 'a', '\344' }, { 'O', 'A', '\305' }, { 'o', 'a', '\345' }, { '0', 'A', '\305' }, { '0', 'a', '\345' }, { 'A', 'A', '\305' }, { 'a', 'a', '\345' }, { 'A', 'E', '\306' }, { 'a', 'e', '\346' }, { ',', 'C', '\307' }, { ',', 'c', '\347' }, { '`', 'E', '\310' }, { '`', 'e', '\350' }, { '\'', 'E', '\311' }, { '\'', 'e', '\351' }, { '^', 'E', '\312' }, { '^', 'e', '\352' }, { '"', 'E', '\313' }, { '"', 'e', '\353' }, { '`', 'I', '\314' }, { '`', 'i', '\354' }, { '\'', 'I', '\315' }, { '\'', 'i', '\355' }, { '^', 'I', '\316' }, { '^', 'i', '\356' }, { '"', 'I', '\317' }, { '"', 'i', '\357' }, { '-', 'D', '\320' }, { '-', 'd', '\360' }, { '~', 'N', '\321' }, { '~', 'n', '\361' }, { '`', 'O', '\322' }, { '`', 'o', '\362' }, { '\'', 'O', '\323' }, { '\'', 'o', '\363' }, { '^', 'O', '\324' }, { '^', 'o', '\364' }, { '~', 'O', '\325' }, { '~', 'o', '\365' }, { '"', 'O', '\326' }, { '"', 'o', '\366' }, { '/', 'O', '\330' }, { '/', 'o', '\370' }, { '`', 'U', '\331' }, { '`', 'u', '\371' }, { '\'', 'U', '\332' }, { '\'', 'u', '\372' }, { '^', 'U', '\333' }, { '^', 'u', '\373' }, { '"', 'U', '\334' }, { '"', 'u', '\374' }, { '\'', 'Y', '\335' }, { '\'', 'y', '\375' }, { 'T', 'H', '\336' }, { 't', 'h', '\376' }, { 's', 's', '\337' }, { '"', 'y', '\377' }, { 's', 'z', '\337' }, { 'i', 'j', '\377' }, | |
685 | 652 | }; |
686 | 653 | |
687 | 654 | unsigned int accent_table_size = 68; |
11 | 11 | |
12 | 12 | f.pipe = 0; |
13 | 13 | strcpy(f.pathname, argv[1]); |
14 | f.fd = fopen( argv[1], "r"); | |
14 | f.fd = fopen(argv[1], "r"); | |
15 | 15 | |
16 | 16 | lk_parse_keymap(ctx, &f); |
17 | 17 | lk_dump_bkeymap(ctx, stdout); |
1 | 1 | #include <stdlib.h> |
2 | 2 | #include <check.h> |
3 | 3 | #include <keymap.h> |
4 | ||
5 | 4 | |
6 | 5 | START_TEST(test0) |
7 | 6 | { |
53 | 52 | static Suite * |
54 | 53 | libkeymap_suite(void) |
55 | 54 | { |
56 | Suite *s = suite_create("libkeymap"); | |
55 | Suite *s = suite_create("libkeymap"); | |
57 | 56 | TCase *tc_core = tcase_create(NULL); |
58 | 57 | |
59 | 58 | tcase_add_test(tc_core, test0); |
67 | 66 | { |
68 | 67 | int number_failed; |
69 | 68 | |
70 | Suite *s = libkeymap_suite(); | |
71 | SRunner *sr = srunner_create (s); | |
69 | Suite *s = libkeymap_suite(); | |
70 | SRunner *sr = srunner_create(s); | |
72 | 71 | |
73 | 72 | srunner_run_all(sr, CK_NORMAL); |
74 | 73 | |
75 | 74 | number_failed = srunner_ntests_failed(sr); |
76 | srunner_free (sr); | |
75 | srunner_free(sr); | |
77 | 76 | |
78 | 77 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
79 | 78 | } |
14 | 14 | return 1; |
15 | 15 | } |
16 | 16 | |
17 | if (!strcasecmp(argv[2], "FULL_TABLE")) table = LK_SHAPE_FULL_TABLE; | |
18 | else if (!strcasecmp(argv[2], "SEPARATE_LINES")) table = LK_SHAPE_SEPARATE_LINES; | |
19 | else if (!strcasecmp(argv[2], "UNTIL_HOLE")) table = LK_SHAPE_UNTIL_HOLE; | |
20 | else table = LK_SHAPE_DEFAULT; | |
17 | if (!strcasecmp(argv[2], "FULL_TABLE")) | |
18 | table = LK_SHAPE_FULL_TABLE; | |
19 | else if (!strcasecmp(argv[2], "SEPARATE_LINES")) | |
20 | table = LK_SHAPE_SEPARATE_LINES; | |
21 | else if (!strcasecmp(argv[2], "UNTIL_HOLE")) | |
22 | table = LK_SHAPE_UNTIL_HOLE; | |
23 | else | |
24 | table = LK_SHAPE_DEFAULT; | |
21 | 25 | |
22 | 26 | numeric = (!strcasecmp(argv[3], "TRUE")) ? 1 : 0; |
23 | 27 | |
26 | 30 | |
27 | 31 | f.pipe = 0; |
28 | 32 | strcpy(f.pathname, argv[1]); |
29 | f.fd = fopen( argv[1], "r"); | |
33 | f.fd = fopen(argv[1], "r"); | |
30 | 34 | |
31 | 35 | lk_parse_keymap(ctx, &f); |
32 | 36 | lk_dump_keymap(ctx, stdout, table, numeric); |
1 | 1 | #include <stdlib.h> |
2 | 2 | #include <check.h> |
3 | 3 | #include <keymap.h> |
4 | ||
5 | 4 | |
6 | 5 | START_TEST(test_create_0) |
7 | 6 | { |
10 | 9 | ctx = lk_init(); |
11 | 10 | |
12 | 11 | fail_if(ctx == NULL, |
13 | "Unable to initialize structure by valid pointer"); | |
12 | "Unable to initialize structure by valid pointer"); | |
14 | 13 | lk_free(ctx); |
15 | 14 | } |
16 | 15 | END_TEST |
22 | 21 | ctx = lk_init(); |
23 | 22 | |
24 | 23 | fail_if(ctx == NULL, |
25 | "Unable to initialize structure by valid pointer"); | |
24 | "Unable to initialize structure by valid pointer"); | |
26 | 25 | |
27 | 26 | fail_unless(lk_free(ctx) == 0, |
28 | "Unable to free by valid pointer"); | |
27 | "Unable to free by valid pointer"); | |
29 | 28 | } |
30 | 29 | END_TEST |
31 | 30 | |
32 | 31 | START_TEST(test_free_1) |
33 | 32 | { |
34 | 33 | fail_if(lk_free(NULL) == 0, |
35 | "Possible to free NULL pointer"); | |
34 | "Possible to free NULL pointer"); | |
36 | 35 | } |
37 | 36 | END_TEST |
38 | ||
39 | 37 | |
40 | 38 | static Suite * |
41 | 39 | libkeymap_suite(void) |
42 | 40 | { |
43 | Suite *s = suite_create("libkeymap"); | |
41 | Suite *s = suite_create("libkeymap"); | |
44 | 42 | TCase *tc_core = tcase_create(NULL); |
45 | 43 | |
46 | 44 | tcase_add_test(tc_core, test_create_0); |
55 | 53 | { |
56 | 54 | int number_failed; |
57 | 55 | |
58 | Suite *s = libkeymap_suite(); | |
59 | SRunner *sr = srunner_create (s); | |
56 | Suite *s = libkeymap_suite(); | |
57 | SRunner *sr = srunner_create(s); | |
60 | 58 | |
61 | 59 | srunner_run_all(sr, CK_NORMAL); |
62 | 60 | |
63 | 61 | number_failed = srunner_ntests_failed(sr); |
64 | srunner_free (sr); | |
62 | srunner_free(sr); | |
65 | 63 | |
66 | 64 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
67 | 65 | } |
1 | 1 | #include <stdlib.h> |
2 | 2 | #include <check.h> |
3 | 3 | #include <keymap.h> |
4 | ||
5 | 4 | |
6 | 5 | START_TEST(test_add_key_0) |
7 | 6 | { |
11 | 10 | lk_set_log_fn(ctx, NULL, NULL); |
12 | 11 | |
13 | 12 | fail_if(lk_add_key(ctx, 0, NR_KEYS + 1, 0) != 0, |
14 | "Unable to use index > NR_KEYS"); | |
13 | "Unable to use index > NR_KEYS"); | |
15 | 14 | |
16 | 15 | fail_if(lk_add_key(ctx, MAX_NR_KEYMAPS + 1, 0, 0) != 0, |
17 | "Unable to use table > MAX_NR_KEYMAPS"); | |
16 | "Unable to use table > MAX_NR_KEYMAPS"); | |
18 | 17 | |
19 | 18 | lk_free(ctx); |
20 | 19 | } |
28 | 27 | lk_set_log_fn(ctx, NULL, NULL); |
29 | 28 | |
30 | 29 | fail_unless(lk_add_key(ctx, 0, 0, 0) == 0, |
31 | "Unable to add keycode = 0"); | |
30 | "Unable to add keycode = 0"); | |
32 | 31 | |
33 | 32 | fail_unless(lk_add_key(ctx, 0, 0, 16) == 0, |
34 | "Unable to add keycode = 16"); | |
33 | "Unable to add keycode = 16"); | |
35 | 34 | |
36 | 35 | fail_unless(lk_add_key(ctx, 1, 1, K_HOLE) == 0, |
37 | "Unable to add keycode = K_HOLE"); | |
36 | "Unable to add keycode = K_HOLE"); | |
38 | 37 | |
39 | 38 | lk_free(ctx); |
40 | 39 | } |
49 | 48 | lk_set_parser_flags(ctx, LK_KEYWORD_ALTISMETA); |
50 | 49 | |
51 | 50 | fail_unless(lk_add_key(ctx, 0, 0, 16) == 0, |
52 | "Unable to add keycode"); | |
51 | "Unable to add keycode"); | |
53 | 52 | |
54 | 53 | fail_unless(lk_get_key(ctx, 0, 0) == 16, |
55 | "Unable to get keycode"); | |
54 | "Unable to get keycode"); | |
56 | 55 | |
57 | 56 | lk_free(ctx); |
58 | 57 | } |
62 | 61 | { |
63 | 62 | char *stringvalues[30] = { |
64 | 63 | /* F1 .. F20 */ |
65 | "\033[[A", "\033[[B", "\033[[C", "\033[[D", "\033[[E", | |
64 | "\033[[A", "\033[[B", "\033[[C", "\033[[D", "\033[[E", | |
66 | 65 | "\033[17~", "\033[18~", "\033[19~", "\033[20~", "\033[21~", |
67 | 66 | "\033[23~", "\033[24~", "\033[25~", "\033[26~", |
68 | 67 | "\033[28~", "\033[29~", |
69 | 68 | "\033[31~", "\033[32~", "\033[33~", "\033[34~", |
70 | 69 | /* Find, Insert, Remove, Select, Prior */ |
71 | "\033[1~", "\033[2~", "\033[3~", "\033[4~", "\033[5~", | |
70 | "\033[1~", "\033[2~", "\033[3~", "\033[4~", "\033[5~", | |
72 | 71 | /* Next, Macro, Help, Do, Pause */ |
73 | "\033[6~", 0, 0, 0, 0 | |
72 | "\033[6~", 0, 0, 0, 0 | |
74 | 73 | }; |
75 | 74 | int i; |
76 | 75 | struct lk_ctx *ctx; |
85 | 84 | continue; |
86 | 85 | |
87 | 86 | strncpy((char *)ke.kb_string, stringvalues[i], |
88 | sizeof(ke.kb_string)); | |
87 | sizeof(ke.kb_string)); | |
89 | 88 | ke.kb_string[sizeof(ke.kb_string) - 1] = 0; |
90 | ke.kb_func = i; | |
89 | ke.kb_func = i; | |
91 | 90 | |
92 | 91 | fail_if(lk_add_func(ctx, &ke) == -1, |
93 | "Unable to add function"); | |
92 | "Unable to add function"); | |
94 | 93 | } |
95 | 94 | |
96 | 95 | lk_free(ctx); |
112 | 111 | |
113 | 112 | while (i > 0) { |
114 | 113 | fail_if(lk_append_diacr(ctx, &ptr) != 0, |
115 | "Unable to add diacr"); | |
114 | "Unable to add diacr"); | |
116 | 115 | i--; |
117 | 116 | } |
118 | 117 | |
123 | 122 | static Suite * |
124 | 123 | libkeymap_suite(void) |
125 | 124 | { |
126 | Suite *s = suite_create("libkeymap"); | |
125 | Suite *s = suite_create("libkeymap"); | |
127 | 126 | TCase *tc_core = tcase_create(NULL); |
128 | 127 | |
129 | 128 | tcase_add_test(tc_core, test_add_key_0); |
140 | 139 | { |
141 | 140 | int number_failed; |
142 | 141 | |
143 | Suite *s = libkeymap_suite(); | |
144 | SRunner *sr = srunner_create (s); | |
142 | Suite *s = libkeymap_suite(); | |
143 | SRunner *sr = srunner_create(s); | |
145 | 144 | |
146 | 145 | srunner_run_all(sr, CK_NORMAL); |
147 | 146 | |
148 | 147 | number_failed = srunner_ntests_failed(sr); |
149 | srunner_free (sr); | |
148 | srunner_free(sr); | |
150 | 149 | |
151 | 150 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
152 | 151 | } |
1 | 1 | #include <stdlib.h> |
2 | 2 | #include <check.h> |
3 | 3 | #include <keymap.h> |
4 | ||
5 | 4 | |
6 | 5 | START_TEST(test_add_map_border) |
7 | 6 | { |
11 | 10 | lk_set_log_fn(ctx, NULL, NULL); |
12 | 11 | |
13 | 12 | fail_unless(lk_add_map(ctx, MAX_NR_KEYMAPS) == 0, |
14 | "Unable to define map == MAX_NR_KEYMAPS"); | |
13 | "Unable to define map == MAX_NR_KEYMAPS"); | |
15 | 14 | |
16 | fail_unless(lk_add_map(ctx, MAX_NR_KEYMAPS*2) == 0, | |
17 | "Unable to define map == MAX_NR_KEYMAPS*2"); | |
15 | fail_unless(lk_add_map(ctx, MAX_NR_KEYMAPS * 2) == 0, | |
16 | "Unable to define map == MAX_NR_KEYMAPS*2"); | |
18 | 17 | |
19 | 18 | fail_unless(lk_add_map(ctx, 0) == 0, |
20 | "Unable to define map"); | |
19 | "Unable to define map"); | |
21 | 20 | |
22 | 21 | fail_unless(lk_add_map(ctx, 0) == 0, |
23 | "Unable to define map"); | |
22 | "Unable to define map"); | |
24 | 23 | |
25 | 24 | lk_free(ctx); |
26 | 25 | } |
41 | 40 | fail_if(lk_add_map(ctx, 0) != 0, "Unable to define map"); |
42 | 41 | lk_get_kmapinfo(ctx, &info); |
43 | 42 | fail_if(info.keymaps != 1, "Wrong keymap number"); |
44 | ||
43 | ||
45 | 44 | fail_if(lk_add_map(ctx, 1) != 0, "Unable to define map"); |
46 | 45 | lk_get_kmapinfo(ctx, &info); |
47 | 46 | fail_if(info.keymaps != 2, "Wrong keymap number"); |
57 | 56 | static Suite * |
58 | 57 | libkeymap_suite(void) |
59 | 58 | { |
60 | Suite *s = suite_create("libkeymap"); | |
59 | Suite *s = suite_create("libkeymap"); | |
61 | 60 | TCase *tc_core = tcase_create(NULL); |
62 | 61 | |
63 | 62 | tcase_add_test(tc_core, test_add_map_border); |
71 | 70 | { |
72 | 71 | int number_failed; |
73 | 72 | |
74 | Suite *s = libkeymap_suite(); | |
75 | SRunner *sr = srunner_create (s); | |
73 | Suite *s = libkeymap_suite(); | |
74 | SRunner *sr = srunner_create(s); | |
76 | 75 | |
77 | 76 | srunner_run_all(sr, CK_NORMAL); |
78 | 77 | |
79 | 78 | number_failed = srunner_ntests_failed(sr); |
80 | srunner_free (sr); | |
79 | srunner_free(sr); | |
81 | 80 | |
82 | 81 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
83 | 82 | } |
11 | 11 | |
12 | 12 | f.pipe = 0; |
13 | 13 | strcpy(f.pathname, argv[1]); |
14 | f.fd = fopen( argv[1], "r"); | |
14 | f.fd = fopen(argv[1], "r"); | |
15 | 15 | |
16 | 16 | lk_parse_keymap(ctx, &f); |
17 | 17 | lk_dump_ctable(ctx, stdout); |
10 | 10 | const char ch; |
11 | 11 | }; |
12 | 12 | |
13 | ||
14 | 13 | START_TEST(test_parse_0) |
15 | 14 | { |
16 | 15 | int c; |
167 | 166 | |
168 | 167 | fail_if(lk_parse_keymap(ctx, &f) != 0, "Unable to parse keymap"); |
169 | 168 | |
170 | for(i = 0; i < MAX_NR_FUNC; i++) { | |
171 | kbs.kb_func = i; | |
169 | for (i = 0; i < MAX_NR_FUNC; i++) { | |
170 | kbs.kb_func = i; | |
172 | 171 | kbs.kb_string[0] = 0; |
173 | 172 | fail_if(lk_get_func(ctx, &kbs) != 0, |
174 | "Unable to get func %d", i); | |
173 | "Unable to get func %d", i); | |
175 | 174 | } |
176 | 175 | |
177 | 176 | lk_free(ctx); |
193 | 192 | |
194 | 193 | fail_if(lk_parse_keymap(ctx, &f) != 0, "Unable to parse keymap"); |
195 | 194 | |
196 | kbs.kb_func = 0; | |
195 | kbs.kb_func = 0; | |
197 | 196 | kbs.kb_string[0] = 0; |
198 | 197 | fail_if(lk_get_func(ctx, &kbs) != 0, "Unable to get func 0"); |
199 | 198 | |
200 | kbs.kb_func = 1; | |
199 | kbs.kb_func = 1; | |
201 | 200 | kbs.kb_string[0] = 0; |
202 | 201 | fail_if(lk_get_func(ctx, &kbs) != 0, "Unable to get func 1"); |
203 | 202 | |
204 | kbs.kb_func = 2; | |
203 | kbs.kb_func = 2; | |
205 | 204 | kbs.kb_string[0] = 0; |
206 | 205 | fail_if(lk_get_func(ctx, &kbs) != -1, "Possible to get not alloced func"); |
207 | 206 | |
212 | 211 | static Suite * |
213 | 212 | libkeymap_suite(void) |
214 | 213 | { |
215 | Suite *s = suite_create("libkeymap"); | |
214 | Suite *s = suite_create("libkeymap"); | |
216 | 215 | TCase *tc_core = tcase_create(NULL); |
217 | 216 | |
218 | 217 | setenv("LOADKEYS_INCLUDE_PATH", DATADIR, 1); |
233 | 232 | { |
234 | 233 | int number_failed; |
235 | 234 | |
236 | Suite *s = libkeymap_suite(); | |
237 | SRunner *sr = srunner_create (s); | |
235 | Suite *s = libkeymap_suite(); | |
236 | SRunner *sr = srunner_create(s); | |
238 | 237 | |
239 | 238 | srunner_run_all(sr, CK_NORMAL); |
240 | 239 | |
241 | 240 | number_failed = srunner_ntests_failed(sr); |
242 | srunner_free (sr); | |
241 | srunner_free(sr); | |
243 | 242 | |
244 | 243 | return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; |
245 | 244 | } |