From 5eb865523785db903be17d35f356285a061ba6be Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 17:45:54 +0000 Subject: Prepare for a new update Reverting patches so we can apply the latest update and changes can be seen in the spec file and sources. --- diff --git a/data/keymaps/i386/qwertz/sg.map b/data/keymaps/i386/qwertz/sg.map index 827f451..3dc5c86 100644 --- a/data/keymaps/i386/qwertz/sg.map +++ b/data/keymaps/i386/qwertz/sg.map @@ -1,7 +1,7 @@ keymaps 0-2,4-6,8,12 include "qwertz-layout" include "linux-with-alt-and-altgr.inc" - plain keycode 83 = KP_Period + plain keycode 83 = KP_Comma strings as usual keycode 1 = Escape Escape diff --git a/data/keymaps/i386/qwertz/sg.map.sg-decimal-separator b/data/keymaps/i386/qwertz/sg.map.sg-decimal-separator deleted file mode 100644 index 3dc5c86..0000000 --- a/data/keymaps/i386/qwertz/sg.map.sg-decimal-separator +++ /dev/null @@ -1,94 +0,0 @@ -keymaps 0-2,4-6,8,12 -include "qwertz-layout" -include "linux-with-alt-and-altgr.inc" - plain keycode 83 = KP_Comma -strings as usual - -keycode 1 = Escape Escape - alt keycode 1 = Meta_Escape -keycode 2 = one plus - alt keycode 2 = Meta_one -keycode 3 = two quotedbl at - control keycode 3 = nul - alt keycode 3 = Meta_two -keycode 4 = three asterisk numbersign - control keycode 4 = Escape - alt keycode 4 = Meta_three -keycode 5 = four - control keycode 5 = Control_backslash - alt keycode 5 = Meta_four -keycode 6 = five percent - control keycode 6 = Control_bracketright - alt keycode 6 = Meta_five -keycode 7 = six ampersand - control keycode 7 = Control_asciicircum - alt keycode 7 = Meta_six -keycode 8 = seven slash bar - control keycode 8 = Control_underscore - alt keycode 8 = Meta_seven -keycode 9 = eight parenleft - control keycode 9 = Delete - alt keycode 9 = Meta_eight -keycode 10 = nine parenright - alt keycode 10 = Meta_nine -keycode 11 = zero equal - alt keycode 11 = Meta_zero -keycode 12 = apostrophe question apostrophe - control keycode 12 = Control_underscore - alt keycode 12 = Meta_minus -keycode 13 = asciicircum grave asciitilde - alt keycode 13 = Meta_equal -keycode 14 = Delete Delete - alt keycode 14 = Meta_Delete -keycode 15 = Tab Meta_Tab - alt keycode 15 = Meta_Tab -keycode 26 = - altgr keycode 26 = bracketleft - control keycode 26 = Escape - alt keycode 26 = Meta_bracketleft -keycode 27 = - shift keycode 27 = exclam - altgr keycode 27 = bracketright - control keycode 27 = Control_bracketright - alt keycode 27 = Meta_bracketright -keycode 28 = Return - alt keycode 28 = Meta_Control_m -keycode 29 = Control -keycode 39 = - alt keycode 39 = Meta_semicolon -keycode 40 = - altgr keycode 40 = braceleft - control keycode 40 = Control_g - alt keycode 40 = Meta_apostrophe -keycode 41 = - control keycode 41 = nul - alt keycode 41 = Meta_grave -keycode 42 = Shift -keycode 43 = dollar - altgr keycode 43 = braceright - control keycode 43 = Control_backslash - alt keycode 43 = Meta_backslash -keycode 51 = comma semicolon - alt keycode 51 = Meta_comma -keycode 52 = period colon - alt keycode 52 = Meta_period -keycode 53 = minus underscore - control keycode 53 = Delete - alt keycode 53 = Meta_slash - shift control keycode 53 = Control_underscore -keycode 54 = Shift -keycode 56 = Alt -keycode 57 = space space - control keycode 57 = nul - alt keycode 57 = Meta_space -keycode 58 = Caps_Lock -# Otto Wyss reports that his USB keyboard has keycode 84 where -# a serial keyboard has keycode 43: -# -# keycode 84 = dollar -# altgr keycode 84 = braceright -# control keycode 84 = Control_backslash -# alt keycode 84 = Meta_backslash -keycode 86 = less greater backslash - alt keycode 86 = Meta_less -keycode 97 = Control diff --git a/docs/man/man1/dumpkeys.1.in b/docs/man/man1/dumpkeys.1.in index 5c1d98e..d3e894f 100644 --- a/docs/man/man1/dumpkeys.1.in +++ b/docs/man/man1/dumpkeys.1.in @@ -164,14 +164,6 @@ output of .BI \-S shape " " " " \-\-shape= shape .LP .TP -.B \-1 \-\-separate-lines -This forces -.B dumpkeys -to write one line per (modifier,keycode) pair. It prefixes the word -.I plain -for plain keycodes. -.LP -.TP .B \-t \-\-funcs-only When this option is given, .B dumpkeys diff --git a/docs/man/man1/dumpkeys.1.in.dumpkeys-man b/docs/man/man1/dumpkeys.1.in.dumpkeys-man deleted file mode 100644 index d3e894f..0000000 --- a/docs/man/man1/dumpkeys.1.in.dumpkeys-man +++ /dev/null @@ -1,224 +0,0 @@ -.\" @(#)loadkeys.1 1.0 93/09/1 RK -.TH DUMPKEYS 1 "1 Sep 1993" -.SH NAME -dumpkeys \- dump keyboard translation tables -.SH SYNOPSIS -.B dumpkeys -[ -.\".B \-1Vdfhiklnstv -.B \-h \-\-help \-i \-\-short\-info \-l \-s \-\-long\-info -.B \-n \-\-numeric \-f \-\-full\-table \-1 \-\-separate-lines -.BI \-S shape -.BI \-\-shape= shape -.B \-t \-\-funcs\-only \-k \-\-keys\-only \-d \-\-compose\-only -.BI \-c charset -.BI \-\-charset= charset -.B \-v \-\-verbose \-V \-\-version -] -.SH DESCRIPTION -.IX "dumpkeys command" "" "\fLdumpkeys\fR command" -.LP -.B dumpkeys -writes, to the standard output, the current contents of the keyboard -driver's translation tables, in the format specified by -.BR keymaps (5). -.LP -Using the various options, the format of the output can be controlled -and also other information from the kernel and the programs -.BR dumpkeys (1) -and -.BR loadkeys (1) -can be obtained. -.SH OPTIONS -.TP -.B \-h \-\-help -Prints the program's version number and a short usage message to the -program's standard error output and exits. -.TP -.B \-i \-\-short-info -Prints some characteristics of the kernel's keyboard driver. The items -shown are: -.LP -.RS -Keycode range supported by the kernel -.LP -.RS -This tells what values can be used after the -.B keycode -keyword in keytable files. See -.BR keymaps (5) -for more information and the syntax of these files. -.RE -.LP -Number of actions bindable to a key -.LP -.RS -This tells how many different actions a single key can output using -various modifier keys. If the value is 16 for example, you can define up -to 16 different actions to a key combined with modifiers. When the value -is 16, the kernel probably knows about four modifier keys, which you can -press in different combinations with the key to access all the bound -actions. -.RE -.LP -Ranges of action codes supported by the kernel -.LP -.RS -This item contains a list of action code ranges in hexadecimal notation. -These are the values that can be used in the right hand side of a key -definition, ie. the -.IR vv 's -in a line -.LP -.RS -.B keycode -.I xx -= -.I vv vv vv vv -.RE -.LP -(see -.BR keymaps (5) -for more information about the format of key definition lines). -.BR dumpkeys (1) -and -.BR loadkeys (1) -support a symbolic notation, which is preferable to the numeric one, as -the action codes may vary from kernel to kernel while the symbolic names -usually remain the same. However, the list of action code ranges can be -used to determine, if the kernel actually supports all the symbols -.BR loadkeys (1) -knows, or are there maybe some actions supported by the kernel that -have no symbolic name in your -.BR loadkeys (1) -program. To see this, you compare the range list with the action symbol -list, see option -.B --long-info -below. -.RE -.LP -Number of function keys supported by kernel -.LP -.RS -This tells the number of action codes that can be used to output -strings of characters. These action codes are traditionally bound to -the various function and editing keys of the keyboard and are defined -to send standard escape sequences. However, you can redefine these to -send common command lines, email addresses or whatever you like. -Especially if the number of this item is greater than the number of -function and editing keys in your keyboard, you may have some "spare" -action codes that you can bind to AltGr-letter combinations, for example, -to send some useful strings. See -.BR loadkeys (1) -for more details. -.RE -.LP -Function strings -.LP -.RS -You can see you current function key definitions with the command -.LP -.RS -.B dumpkeys --funcs-only -.RE -.LP -.RE -.RE -.LP -.TP -.B \-l \-s \-\-long-info -This option instructs -.B dumpkeys -to print a long information listing. The output is the same as with the -.B --short-info -appended with the list of action symbols supported by -.BR loadkeys (1) -and -.BR dumpkeys (1), -along with the symbols' numeric values. -.LP -.TP -.B \-n \-\-numeric -This option causes -.B dumpkeys -to by-pass the conversion of action code values to symbolic notation and -to print the in hexadecimal format instead. -.LP -.TP -.B \-f \-\-full-table -This makes -.B dumpkeys -skip all the short-hand heuristics (see -.BR keymaps (5)) -and output the key bindings in the canonical form. First a keymaps -line describing the currently defined modifier combinations -is printed. Then for each key a row with a column for each -modifier combination is printed. For -example, if the current keymap in use uses seven modifiers, -every row will have seven action code columns. This format -can be useful for example to programs that post-process the -output of -.BR dumpkeys . -.LP -.TP -.BI \-S shape " " " " \-\-shape= shape -.LP -.TP -.B \-t \-\-funcs-only -When this option is given, -.B dumpkeys -prints only the function key string definitions. Normally -.B dumpkeys -prints both the key bindings and the string definitions. -.LP -.TP -.B \-k \-\-keys-only -When this option is given, -.B dumpkeys -prints only the key bindings. Normally -.B dumpkeys -prints both the key bindings and the string definitions. -.LP -.TP -.B \-d \-\-compose-only -When this option is given, -.B dumpkeys -prints only the compose key combinations. -This option is available only if your kernel has compose key support. -.LP -.TP -.BI \-c charset " " " " \-\-charset= charset -This instructs -.B dumpkeys -to interpret character code values according to the specified character -set. This affects only the translation of character code values to -symbolic names. Valid values for -.I charset -currently are -.BR iso-8859-X , -Where X is a digit in 1-9. If no -.I charset -is specified, -.B iso-8859-1 -is used as a default. -This option produces an output line `charset "iso-8859-X"', telling -loadkeys how to interpret the keymap. (For example, "division" is -0xf7 in iso-8859-1 but 0xba in iso-8859-8.) -.LP -.TP -.B \-v \-\-verbose -.LP -.TP -.B \-V \-\-version -Prints version number and exits. -.LP -.SH FILES -.PD 0 -.TP 20 -.BI @DATADIR@/keymaps -recommended directory for keytable files -.PD -.SH "SEE ALSO" -.BR loadkeys (1), -.BR keymaps (5) - diff --git a/docs/man/man1/showkey.1 b/docs/man/man1/showkey.1 index 7690e99..7a5b8e1 100644 --- a/docs/man/man1/showkey.1 +++ b/docs/man/man1/showkey.1 @@ -84,19 +84,6 @@ corresponds to what the keyboard hardware did send. So, if you want to know the scan codes sent by various keys it is better to boot a 2.4 kernel. Since 2.6.9 there also is the boot option atkbd.softraw=0 that tells the 2.6 kernel to return the actual scan codes. - -.SH NOTES -The raw scan codes are available only on AT and PS/2 keyboards, -and even then they are disabled unless the -.B atkbd.softraw=0 -kernel parameter is used. -When the raw scan codes are not available, the kernel uses a fixed built-in -table to produce scan codes from keycodes. Thus, -.BR setkeycodes (8) -can affect the output of -.B showkey -in scan code dump mode. - .SH "SEE ALSO" .BR loadkeys (1), .BR dumpkeys (1), diff --git a/docs/man/man1/showkey.1.keycodes-man b/docs/man/man1/showkey.1.keycodes-man deleted file mode 100644 index 7a5b8e1..0000000 --- a/docs/man/man1/showkey.1.keycodes-man +++ /dev/null @@ -1,91 +0,0 @@ -.\" @(#)showkey.1 1.1 980201 aeb -.TH SHOWKEY 1 "1 Feb 1998" -.SH NAME -showkey \- examine the codes sent by the keyboard -.SH SYNOPSIS -showkey [\-h|\-\-help] [\-a|\-\-ascii] [\-s|\-\-scancodes] [\-k|\-\-keycodes] [\-V|\-\-version] -.SH DESCRIPTION -.IX "showkey command" "" "\fLshowkey\fR command" -.LP -.B showkey -prints to standard output either the scan codes or the keycode -or the `ascii' code of each key pressed. -In the first two modes the program runs until 10 seconds have elapsed -since the last key press or release event, or until it receives -a suitable signal, like SIGTERM, from another process. -In `ascii' mode the program terminates when the user types ^D. -.LP -When in scancode dump mode, -.B showkey -prints in hexadecimal format each byte received from the keyboard to the -standard output. A new line is printed when an interval of about 0.1 -seconds occurs between the bytes received, or when the internal receive -buffer fills up. This can be used to determine roughly, what byte -sequences the keyboard sends at once on a given key press. The scan code -dumping mode is primarily intended for debugging the keyboard driver or -other low level interfaces. As such it shouldn't be of much interest to -the regular end-user. However, some modern keyboards have keys or buttons -that produce scancodes to which the kernel does not associate a keycode, -and, after finding out what these are, the user can assign keycodes with -.BR setkeycodes (8). -.LP -When in the default keycode dump mode, -.B showkey -prints to the standard output the keycode number or each key pressed or -released. The kind of the event, press or release, is also reported. -Keycodes are numbers assigned by the kernel to each individual physical -key. Every key has always only one associated keycode number, whether -the keyboard sends single or multiple scan codes when pressing it. Using -.B showkey -in this mode, you can find out what numbers to use in your personalized -keymap files. -.LP -When in `ascii' dump mode, -.B showkey -prints to the standard output the decimal, octal, and hexadecimal -value(s) of the key pressed, according to he present keymap. -.SH OPTIONS -.TP -\-h \-\-help -.B showkey -prints to the standard error output its version number, a compile -option and a short usage message, then exits. -.TP -\-s \-\-scancodes -Starts -.B showkey -in scan code dump mode. -.TP -\-k \-\-keycodes -Starts -.B showkey -in keycode dump mode. This is the default, when no command line options -are present. -.TP -\-a \-\-ascii -Starts -.B showkey -in `ascii' dump mode. -.TP -\-V \-\-version -.B showkey -prints version number and exits. -.SH "2.6 KERNELS" -In 2.6 kernels key codes lie in the range 1-255, instead of 1-127. -Key codes larger than 127 are returned as three bytes of which the -low order 7 bits are: zero, bits 13-7, and bits 6-0 of the key code. -The high order bits are: 0/1 for make/break, 1, 1. -.LP -In 2.6 kernels raw mode, or scancode mode, is not very raw at all. -Scan codes are first translated to key codes, and when scancodes -are desired, the key codes are translated back. Various transformations -are involved, and there is no guarantee at all that the final result -corresponds to what the keyboard hardware did send. So, if you want -to know the scan codes sent by various keys it is better to boot a -2.4 kernel. Since 2.6.9 there also is the boot option atkbd.softraw=0 -that tells the 2.6 kernel to return the actual scan codes. -.SH "SEE ALSO" -.BR loadkeys (1), -.BR dumpkeys (1), -.BR keymaps (5), -.BR setkeycodes (8) diff --git a/docs/man/man8/kbdrate.8 b/docs/man/man8/kbdrate.8 index e5d2006..d16b7c9 100644 --- a/docs/man/man8/kbdrate.8 +++ b/docs/man/man8/kbdrate.8 @@ -22,7 +22,7 @@ Using without any options will reset the repeat rate to 10.9 characters per second (cps) and the delay to 250 milliseconds (ms) for Intel- and M68K-based systems. These are the IBM defaults. On SPARC-based systems it will reset the repeat rate -to 20 cps and the delay to 200 ms. +to 5 cps and the delay to 200 ms. .SH OPTIONS .TP diff --git a/docs/man/man8/kbdrate.8.sparc b/docs/man/man8/kbdrate.8.sparc deleted file mode 100644 index d16b7c9..0000000 --- a/docs/man/man8/kbdrate.8.sparc +++ /dev/null @@ -1,71 +0,0 @@ -.\" Copyright 1992, 1994 Rickard E. Faith (faith@cs.unc.edu) -.\" May be distributed under the GNU General Public License -.\" Updated Wed Jun 22 21:09:43 1994, faith@cs.unc.edu -.\" -.TH KBDRATE 8 "22 June 1994" "Linux 1.1.19" "Linux Programmer's Manual" -.SH NAME -kbdrate \- reset the keyboard repeat rate and delay time -.SH SYNOPSIS -.B "kbdrate [ \-s ] [ \-r" -rate -.B "] [ \-d" -delay -.B ] -.SH DESCRIPTION -.B kbdrate -is used to change the keyboard repeat rate and delay time. The delay -is the amount of time that a key must be depressed before it will start to -repeat. - -Using -.B kbdrate -without any options will reset the repeat rate to 10.9 characters per second (cps) -and the delay to 250 milliseconds (ms) for Intel- and M68K-based systems. -These are the IBM defaults. On SPARC-based systems it will reset the repeat rate -to 5 cps and the delay to 200 ms. - -.SH OPTIONS -.TP -.B \-s -Silent. No messages are printed. -.TP -.BI \-r " rate" -Change the keyboard repeat rate to -.I rate -cps. For Intel-based systems, the allowable range is from 2.0 to 30.0 cps. -Only certain, specific values are possible, and the program will select the -nearest possible value to the one specified. The possible values are given, -in characters per second, as follows: 2.0, 2.1, 2.3, 2.5, 2.7, 3.0, 3.3, 3.7, -4.0, 4.3, 4.6, 5.0, 5.5, 6.0, 6.7, 7.5, 8.0, 8.6, 9.2, 10.0, 10.9, 12.0, 13.3, -15.0, 16.0, 17.1, 18.5, 20.0, 21.8, 24.0, 26.7, 30.0. -For SPARC-based systems, the allowable range is from 0 (no repeat) to 50 cps. -.TP -.BI \-d " delay" -Change the delay to -.I delay -milliseconds. -For Intel-based systems, the allowable range is from 250 to 1000 ms, -in 250 ms steps. For SPARC systems, possible values are between 10 ms and 1440 ms, -in 10 ms steps. -.TP -.B \-V \-\-version -Display a version number and exit. -.SH BUGS -Not all keyboards support all rates. -.PP -Not all keyboards have the rates mapped in the same way. -.PP -Setting the repeat rate on the Gateway AnyKey keyboard does not work. If -someone with a Gateway figures out how to program the keyboard, please send -mail to util-linux@math.uio.no. -.PP -All this is very architecture dependent. -Nowadays -.B kbdrate -first tries the KDKBDREP and KIOCSRATE ioctls. -(The former usually works on an m68k machine, the latter for SPARC.) -When these ioctls fail an ioport interface as on i386 is assumed. -.SH FILES -.I /etc/rc.local -.br -.I /dev/port diff --git a/docs/man/man8/setkeycodes.8 b/docs/man/man8/setkeycodes.8 index 3fb7d4a..8cad162 100644 --- a/docs/man/man8/setkeycodes.8 +++ b/docs/man/man8/setkeycodes.8 @@ -38,10 +38,6 @@ to showkey(1), the command .RE will assign the keycode 112 to it, and then loadkeys(1) can be used to define the function of this key. - -USB keyboards have standardized keycodes and -.B setkeycodes -doesn't affect them at all. .LP Some older kernels might hardwire a low scancode range to the equivalent keycodes; setkeycodes will fail when you try to remap @@ -60,14 +56,6 @@ None. .SH BUGS The keycodes of X have nothing to do with those of Linux. Unusual keys can be made visible under Linux, but not under X. - -.B setkeycodes -affects only the "first" input device -that has modifiable scancode-to-keycode mapping. -If there is more than one such device, -.B setkeycodes -cannot change the mapping of other devices than the "first" one. - .SH "SEE ALSO" .I "dumpkeys (1), loadkeys (1), showkey (1), getkeycodes (8)" diff --git a/docs/man/man8/setkeycodes.8.keycodes-man b/docs/man/man8/setkeycodes.8.keycodes-man deleted file mode 100644 index 8cad162..0000000 --- a/docs/man/man8/setkeycodes.8.keycodes-man +++ /dev/null @@ -1,62 +0,0 @@ -.\" @(#)man/man8/setkeycodes.8 1.0 Nov 8 22:30:48 MET 1994 -.TH SETKEYCODES 8 "8 Nov 1994" "Local" "Keyboard Support" -.SH NAME -setkeycodes \- load kernel scancode-to-keycode mapping table entries -.SH SYNOPSIS -.B setkeycodes -.I "scancode keycode ..." -.SH DESCRIPTION -The -.I setkeycodes -command reads its arguments two at a time, each pair of arguments -consisting of a scancode (given in hexadecimal) and a keycode (given -in decimal). For each such pair, it tells the kernel keyboard driver -to map the specified scancode to the specified keycode. - -This command is useful only for people with slightly unusual keyboards, -that have a few keys which produce scancodes that the kernel does not -recognize. - -.SH THEORY -The usual PC keyboard produces a series of scancodes for each -key press and key release. (Scancodes are shown by -\fBshowkey \-s\fP, see showkey(1).) -The kernel parses this stream of scancodes, and converts it to -a stream of keycodes (key press/release events). -(Keycodes are shown by \fBshowkey\fP.) -Apart from a few scancodes with special meaning, and apart from -the sequence produced by the Pause key, and apart from shiftstate -related scancodes, and apart from the key up/down bit, -the stream of scancodes consists of unescaped -scancodes xx (7 bits) and escaped scancodes e0 xx (8+7 bits). -To these scancodes or scancode pairs, a corresponding keycode can be -assigned (in the range 1-127). -For example, if you have a Macro key that produces e0 6f according -to showkey(1), the command -.RS -.B "setkeycodes e06f 112" -.RE -will assign the keycode 112 to it, and then loadkeys(1) can be used -to define the function of this key. -.LP -Some older kernels might hardwire a low scancode range to the -equivalent keycodes; setkeycodes will fail when you try to remap -these. - -.SH "2.6 KERNELS" -In 2.6 kernels key codes lie in the range 1-255, instead of 1-127. -(It might be best to confine oneself to the range 1-239.) -.LP -In 2.6 kernels raw mode, or scancode mode, is not very raw at all. -The code returned by showkey \-s will change after use of setkeycodes. -A kernel bug. See also -.BR showkey (1). -.SH OPTIONS -None. -.SH BUGS -The keycodes of X have nothing to do with those of Linux. -Unusual keys can be made visible under Linux, but not under X. -.SH "SEE ALSO" -.I "dumpkeys (1), loadkeys (1), showkey (1), getkeycodes (8)" - - diff --git a/src/kbdrate.c b/src/kbdrate.c index f8ef0e9..834855c 100644 --- a/src/kbdrate.c +++ b/src/kbdrate.c @@ -111,12 +111,9 @@ static int valid_delays[] = { 250, 500, 750, 1000 }; static int KDKBDREP_ioctl_ok(double rate, int delay, int silent) { -#if defined(KDKBDREP) && !defined(__sparc__) /* * This ioctl is defined in but is not * implemented anywhere - must be in some m68k patches. - * We cannot blindly try unimplemented ioctls on sparc64 - - * the 32<->64bit transition layer does not like it. * Since 2.4.9 also on i386. */ struct my_kbd_repeat kbdrep_s; @@ -179,9 +176,6 @@ KDKBDREP_ioctl_ok(double rate, int delay, int silent) rate, kbdrep_s.delay); return 1; /* success! */ -#else /* no KDKBDREP or __sparc__ */ - return 0; -#endif /* KDKBDREP */ } #ifndef KIOCSRATE @@ -232,7 +226,7 @@ sigalrmhandler(int sig __attribute__((unused))) int main(int argc, char **argv) { #ifdef __sparc__ - double rate = 20.0; /* Default rate */ + double rate = 5.0; /* Default rate */ int delay = 200; /* Default delay */ #else double rate = 10.9; /* Default rate */ @@ -281,9 +275,8 @@ int main(int argc, char **argv) if (KIOCSRATE_ioctl_ok(rate, delay, silent)) /* sparc? */ return 0; - /* The ioport way - will crash on sparc */ + /* The ioport way */ -#ifndef __sparc__ for (i = 0; i < RATE_COUNT; i++) if (rate * 10 >= valid_rates[i]) { value &= 0x60; @@ -340,6 +333,5 @@ int main(int argc, char **argv) valid_rates[value & 0x1f] / 10.0, valid_delays[(value & 0x60) >> 5]); -#endif return EXIT_SUCCESS; } diff --git a/src/kbdrate.c.sparc b/src/kbdrate.c.sparc deleted file mode 100644 index 834855c..0000000 --- a/src/kbdrate.c.sparc +++ /dev/null @@ -1,337 +0,0 @@ -/* -From: faith@cs.unc.edu (Rik Faith) -Subject: User mode keyboard rate changer -Date: 27 Apr 92 13:44:26 GMT - -I put together this program, called kbdrate.c, which will reset the keyboard -repeat rate and delay in user mode. The program must have read/write -access to /dev/port, so if /dev/port is only read/writeable by group port, -then kbdrate must run setgid to group port (for example). - -The "rate" is the rate in characters per second - -The "delay" is the amount of time the key must remain depressed before it -will start to repeat. - -Usage examples: - -kbdrate set rate to IBM default (10.9 cps, 250ms delay) -kbdrate -r 30.0 set rate to 30 cps and delay to 250ms -kbdrate -r 20.0 -s set rate to 20 cps (delay 250ms) -- don't print message -kbdrate -r 0 -d 0 set rate to 2.0 cps and delay to 250 ms - -I find it useful to put kbdrate in my /etc/rc file so that the keyboard -rate is set to something that I find comfortable at boot time. This sure -beats rebuilding the kernel! - - - kbdrate.c -- Set keyboard typematic rate (and delay) - Created: Thu Apr 23 12:24:30 1992 - Author: Rickard E. Faith, faith@cs.unc.edu - - Copyright 1992 Rickard E. Faith. Distributed under the GPL. - This program comes with ABSOLUTELY NO WARRANTY. - Usage: kbdrate [-r rate] [-d delay] [-s] - Rate can range from 2.0 to 30.0 (units are characters per second) - Delay can range from 250 to 1000 (units are milliseconds) - -s suppressed message - Compiles under gcc 2.1 for Linux (tested with the pre-0.96 kernel) - - Wed Jun 22 21:35:43 1994, faith@cs.unc.edu: - Changed valid_rates per suggestion by Andries.Brouwer@cwi.nl. - Wed Jun 22 22:18:29 1994, faith@cs.unc.edu: - Added patch for AUSTIN notebooks from John Bowman - (bowman@hagar.ph.utexas.edu) - - Linux/68k modifications by Roman Hodek - (Roman.Hodek@informatik.uni-erlangen.de): - - Reading/writing the Intel I/O ports via /dev/port is not the - English way... Such hardware dependent stuff can never work on - other architectures. - - Linux/68k has an new ioctl for setting the keyboard repeat rate - and delay. Both values are counted in msecs, the kernel will do - any rounding to values possible with the underlying hardware. - - kbdrate now first tries if the KDKBDREP ioctl is available. If it - is, it is used, else the old method is applied. - - 1999-02-22 Arkadiusz Miƛkiewicz - - added Native Language Support - - 1999-03-17 - Linux/SPARC modifications by Jeffrey Connell : - It seems that the KDKBDREP ioctl is not available on this platform. - However, Linux/SPARC has its own ioctl for this (since 2.1.30), - with yet another measurement system. Thus, try for KIOCSRATE, too. - -*/ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __sparc__ -#include -#endif - -#ifdef COMPAT_HEADERS -#include "compat/linux-kd.h" -#endif - -/* Equal to kernel version, but field names vary. */ -struct my_kbd_repeat { - int delay; /* in msec; <= 0: don't change */ - int period; /* in msec; <= 0: don't change */ - /* earlier this field was misnamed "rate" */ -}; - -#include - -#include "nls.h" -#include "version.h" -#include "kbd_error.h" - -static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150, - 133, 120, 109, 100, 92, 86, 80, 75, 67, - 60, 55, 50, 46, 43, 40, 37, 33, 30, 27, - 25, 23, 21, 20 }; -#define RATE_COUNT (sizeof(valid_rates) / sizeof(int)) - -static int valid_delays[] = { 250, 500, 750, 1000 }; -#define DELAY_COUNT (sizeof(valid_delays) / sizeof(int)) - -static int -KDKBDREP_ioctl_ok(double rate, int delay, int silent) -{ - /* - * This ioctl is defined in but is not - * implemented anywhere - must be in some m68k patches. - * Since 2.4.9 also on i386. - */ - struct my_kbd_repeat kbdrep_s; - - /* don't change, just test */ - kbdrep_s.period = -1; - kbdrep_s.delay = -1; - if (ioctl(0, KDKBDREP, &kbdrep_s)) { - if (errno == EINVAL || errno == ENOTTY) - return 0; - kbd_error(EXIT_FAILURE, errno, "ioctl KDKBDREP"); - } - -#if 0 - printf("old delay %d, period %d\n", - kbdrep_s.delay, kbdrep_s.period); -#endif - - /* do the change */ - if (rate == 0) /* switch repeat off */ - kbdrep_s.period = 0; - else - kbdrep_s.period = 1000.0 / rate; /* convert cps to msec */ - if (kbdrep_s.period < 1) - kbdrep_s.period = 1; - kbdrep_s.delay = delay; - if (kbdrep_s.delay < 1) - kbdrep_s.delay = 1; - - if (ioctl(0, KDKBDREP, &kbdrep_s)) { - kbd_error(EXIT_FAILURE, errno, "ioctl KDKBDREP"); - } - - /* report */ - if (kbdrep_s.period == 0) - rate = 0; - else - rate = 1000.0 / (double)kbdrep_s.period; - - if (!silent) - printf(_("Typematic Rate set to %.1f cps (delay = %d ms)\n"), - rate, kbdrep_s.delay); - - kbdrep_s.period = -1; - kbdrep_s.delay = -1; - if (ioctl(0, KDKBDREP, &kbdrep_s)) { - if (errno == EINVAL) - return 0; - kbd_error(EXIT_FAILURE, errno, "ioctl KDKBDREP"); - } - printf("old delay %d, period %d\n", - kbdrep_s.delay, kbdrep_s.period); - if (kbdrep_s.period == 0) - rate = 0; - else - rate = 1000.0 / (double)kbdrep_s.period; - - if (!silent) - printf(_("Typematic Rate set to %.1f cps (delay = %d ms)\n"), - rate, kbdrep_s.delay); - - return 1; /* success! */ -} - -#ifndef KIOCSRATE -#define arg_state __attribute__((unused)) -#else -#define arg_state -#endif - -static int -KIOCSRATE_ioctl_ok(arg_state double rate, arg_state int delay, arg_state int silent) -{ -#ifdef KIOCSRATE - struct kbd_rate kbdrate_s; - int fd; - - fd = open("/dev/kbd", O_RDONLY); - if (fd == -1) { - kbd_error(EXIT_FAILURE, errno, "open /dev/kbd"); - } - - kbdrate_s.rate = (int)(rate + 0.5); /* round up */ - kbdrate_s.delay = delay * HZ / 1000; /* convert ms to Hz */ - if (kbdrate_s.rate > 50) - kbdrate_s.rate = 50; - - if (ioctl(fd, KIOCSRATE, &kbdrate_s)) { - kbd_error(EXIT_FAILURE, errno, "ioctl KIOCSRATE"); - } - close(fd); - - if (!silent) - printf("Typematic Rate set to %d cps (delay = %d ms)\n", - kbdrate_s.rate, kbdrate_s.delay * 1000 / HZ); - - return 1; -#else /* no KIOCSRATE */ - return 0; -#endif /* KIOCSRATE */ -} - -static void -sigalrmhandler(int sig __attribute__((unused))) -{ - kbd_warning(0, "Failed waiting for kbd controller!\n"); - raise(SIGINT); -} - -int main(int argc, char **argv) -{ -#ifdef __sparc__ - double rate = 5.0; /* Default rate */ - int delay = 200; /* Default delay */ -#else - double rate = 10.9; /* Default rate */ - int delay = 250; /* Default delay */ -#endif - int value = 0x7f; /* Maximum delay with slowest rate */ - /* DO NOT CHANGE this value */ - int silent = 0; - int fd; - char data; - int c; - unsigned int i; - extern char *optarg; - - set_progname(argv[0]); - - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE_NAME, LOCALEDIR); - textdomain(PACKAGE_NAME); - - if (argc == 2 && - (!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version"))) - print_version_and_exit(); - - while ((c = getopt(argc, argv, "r:d:s")) != EOF) { - switch (c) { - case 'r': - rate = atof(optarg); - break; - case 'd': - delay = atoi(optarg); - break; - case 's': - silent = 1; - break; - default: - fprintf(stderr, - _("Usage: kbdrate [-V | --version] [-s] [-r rate] [-d delay]\n")); - exit(EXIT_FAILURE); - } - } - - if (KDKBDREP_ioctl_ok(rate, delay, silent)) /* m68k? */ - return 0; - - if (KIOCSRATE_ioctl_ok(rate, delay, silent)) /* sparc? */ - return 0; - - /* The ioport way */ - - for (i = 0; i < RATE_COUNT; i++) - if (rate * 10 >= valid_rates[i]) { - value &= 0x60; - value |= i; - break; - } - - for (i = 0; i < DELAY_COUNT; i++) - if (delay <= valid_delays[i]) { - value &= 0x1f; - value |= i << 5; - break; - } - - if ((fd = open("/dev/port", O_RDWR)) < 0) { - kbd_error(EXIT_FAILURE, errno, _("Cannot open /dev/port")); - } - - signal(SIGALRM, sigalrmhandler); - alarm(3); - - do { - lseek(fd, 0x64, 0); - if (read(fd, &data, 1) == -1) { - kbd_error(EXIT_FAILURE, errno, "read"); - } - } while ((data & 2) == 2); /* wait */ - - lseek(fd, 0x60, 0); - data = 0xf3; /* set typematic rate */ - if (write(fd, &data, 1) == -1) { - kbd_error(EXIT_FAILURE, errno, "write"); - } - - do { - lseek(fd, 0x64, 0); - if (read(fd, &data, 1) == -1) { - kbd_error(EXIT_FAILURE, errno, "read"); - } - } while ((data & 2) == 2); /* wait */ - - alarm(0); - - lseek(fd, 0x60, 0); - sleep(1); - if (write(fd, &value, 1) == -1) { - kbd_error(EXIT_FAILURE, errno, "write"); - } - - close(fd); - - if (!silent) - printf(_("Typematic Rate set to %.1f cps (delay = %d ms)\n"), - valid_rates[value & 0x1f] / 10.0, - valid_delays[(value & 0x60) >> 5]); - - return EXIT_SUCCESS; -} diff --git a/src/kdmapop.c b/src/kdmapop.c index a3d9969..f9b72ae 100644 --- a/src/kdmapop.c +++ b/src/kdmapop.c @@ -154,7 +154,6 @@ int getunimap(int fd, struct unimapdesc *ud0) } if (ioctl(fd, GIO_UNIMAP, &ud)) { perror("GIO_UNIMAP"); - free(ud.entries); return -1; } if (ct != ud.entry_ct) diff --git a/src/kdmapop.c.covscan-fixes b/src/kdmapop.c.covscan-fixes deleted file mode 100644 index f9b72ae..0000000 --- a/src/kdmapop.c.covscan-fixes +++ /dev/null @@ -1,207 +0,0 @@ -/* - * kdmapop.c - export getscrnmap(), loadscrnmap(), - * loaduniscrnmap(), loadunimap() - * - * Hide the ioctl use in this file. - */ -#include "config.h" - -#include -#include -#include -#include -#include -#include "kdmapop.h" -#include "nls.h" -#include "version.h" - -/* - * Linux pre-0.96 defined GIO_SCRNMAP, PIO_SCRNMAP: - typedef char scrnmap_t; - #define E_TABSZ 256 - #define GIO_SCRNMAP 0x4B40 - #define PIO_SCRNMAP 0x4B41 - * and Linux 0.99.14y first implemented them. - * Usage: - scrnmap_t map[E_TABSZ]; - ioctl(fd,GIO_SCRNMAP,map); - ioctl(fd,PIO_SCRNMAP,map); - * to read or write the kernel translation table that is - * applied to user application output before displaying. - * - * Before 1.3.1, the character set was completely undetermined, - * and if the font was in an order different from the character - * set in use, the user screen map was used to map application - * codes to font indices. (To be more precise: there were four - * translation tables, and this ioctl would get/set the fourth - * table, while the other three tables are built-in and constant.) - */ -int getscrnmap(int fd, char *map) -{ - if (ioctl(fd, GIO_SCRNMAP, map)) { - perror("GIO_SCRNMAP"); - return -1; - } - return 0; -} - -int loadscrnmap(int fd, char *map) -{ - if (ioctl(fd, PIO_SCRNMAP, map)) { - perror("PIO_SCRNMAP"); - return -1; - } - return 0; -} - -/* - * Linux 1.3.1 introduces GIO_UNISCRNMAP, PIO_UNISCRNMAP: - #define GIO_UNISCRNMAP 0x4B69 - #define PIO_UNISCRNMAP 0x4B6A - * Usage: - unsigned short umap[E_TABSZ]; - ioctl(fd,GIO_UNISCRNMAP,umap); - ioctl(fd,PIO_UNISCRNMAP,umap); - * to read or write the kernel translation table that is - * applied to user application output before displaying. - * (When the console is not in utf8 mode.) - * - * The idea is that the umap values are 16-bit unicode (ucs2) - * values, and that the fonts will have an index giving the - * unicode value for each glyph, so that the kernel can match up - * application codes to font positions. - #define UNI_DIRECT_BASE 0xF000 - #define UNI_DIRECT_MASK 0x01FF - * For compatibility, and for fonts without table, the unicode - * values 0xF000+n, 0 <= n <= 0x01FF, acts as direct font indices. - * In the new scheme, the old PIO_SCRNMAP fills the kernel umap - * table with such direct-to-font values. - */ - -int getuniscrnmap(int fd, unsigned short *map) -{ - if (ioctl(fd, GIO_UNISCRNMAP, map)) { - perror("GIO_UNISCRNMAP"); - return -1; - } - return 0; -} - -int loaduniscrnmap(int fd, unsigned short *map) -{ - if (ioctl(fd, PIO_UNISCRNMAP, map)) { - perror("PIO_UNISCRNMAP"); - return -1; - } - return 0; -} - -/* - * Linux 1.1.63 introduces GIO_UNIMAP, PIO_UNIMAP, PIO_UNIMAPCLR: - #define GIO_UNIMAP 0x4B66 - #define PIO_UNIMAP 0x4B67 - #define PIO_UNIMAPCLR 0x4B68 - * And Linux 1.1.92 implements them. - * Usage: - struct unimapinit { - unsigned short advised_hashsize; - unsigned short advised_hashstep; - unsigned short advised_hashlevel; - } ui; - ioctl(fd, PIO_UNIMAPCLR, &ui); - * to clear the unimap table and advise about the kind of - * hash setup appropriate to what one is going to load - * (with 0 for "don't care"). - struct unipair { - unsigned short unicode; - unsigned short fontpos; - }; - struct unimapdesc { - unsigned short entry_ct; - struct unipair *entries; - } ud; - ioctl(fd, PIO_UNIMAP, &ud); - ioctl(fd, GIO_UNIMAP, &ud); - * to add the indicated pairs to the kernel unimap table - * or to read the kernel unimap table, where in the latter case - * ud.entry_ct indicated the room available. - * - * In Linux 1.3.28 the hash table was replaced by a 3-level - * paged table, so the contents of a struct unimapinit are - * no longer meaningful. - * - * Linux 2.6.1 makes GIO_UNIMAP, PIO_UNIMAP, PIO_UNIMAPCLR per-vt - * so that fd no longer is random. - */ -int getunimap(int fd, struct unimapdesc *ud0) -{ - struct unimapdesc ud; - int ct; - - ud.entry_ct = 0; - ud.entries = 0; - if (ioctl(fd, GIO_UNIMAP, &ud)) { - if (errno != ENOMEM || ud.entry_ct == 0) { - perror("GIO_UNIMAP(0)"); - return -1; - } - ct = ud.entry_ct; - ud.entries = (struct unipair *) - malloc(ct * sizeof(struct unipair)); - if (ud.entries == NULL) { - fprintf(stderr, _("%s: out of memory\n"), progname); - return -1; - } - if (ioctl(fd, GIO_UNIMAP, &ud)) { - perror("GIO_UNIMAP"); - return -1; - } - if (ct != ud.entry_ct) - fprintf(stderr, - _("strange... ct changed from %d to %d\n"), - ct, ud.entry_ct); - /* someone could change the unimap between our - first and second ioctl, so the above errors - are not impossible */ - } - *ud0 = ud; - return 0; -} - -int loadunimap(int fd, struct unimapinit *ui, struct unimapdesc *ud) -{ - struct unimapinit advice; - - if (ui) - advice = *ui; - else { - advice.advised_hashsize = 0; - advice.advised_hashstep = 0; - advice.advised_hashlevel = 0; - } -again: - if (ioctl(fd, PIO_UNIMAPCLR, &advice)) { -#ifdef ENOIOCTLCMD - if (errno == ENOIOCTLCMD) { - fprintf(stderr, - _("It seems this kernel is older than 1.1.92\n" - "No Unicode mapping table loaded.\n")); - } else -#endif - perror("PIO_UNIMAPCLR"); - return -1; - } - if (ud == NULL) - return 0; - - if (ioctl(fd, PIO_UNIMAP, ud)) { - if (errno == ENOMEM && advice.advised_hashlevel < 100) { - advice.advised_hashlevel++; - goto again; - } - perror("PIO_UNIMAP"); - return -1; - } - - return 0; -} diff --git a/src/libkeymap/common.c b/src/libkeymap/common.c index dfb15c0..cfe8507 100644 --- a/src/libkeymap/common.c +++ b/src/libkeymap/common.c @@ -246,8 +246,5 @@ int lk_free(struct lk_ctx *ctx) ctx->key_line = NULL; } - free(ctx); - ctx = NULL; - return 0; } diff --git a/src/libkeymap/common.c.covscan-fixes b/src/libkeymap/common.c.covscan-fixes deleted file mode 100644 index cfe8507..0000000 --- a/src/libkeymap/common.c.covscan-fixes +++ /dev/null @@ -1,250 +0,0 @@ -#include "config.h" - -#include -#include -#include - -#include "keymap.h" - -#include "kbd.h" -#include "nls.h" -#include "contextP.h" - -void __attribute__((format(printf, 6, 7))) -lk_log(struct lk_ctx *ctx, int priority, - const char *file, int line, const char *fn, - const char *fmt, ...) -{ - va_list args; - if (ctx->log_fn == NULL) - return; - va_start(args, fmt); - ctx->log_fn(ctx->log_data, priority, file, line, fn, fmt, args); - va_end(args); -} - -#ifndef DEBUG -#define log_unused __attribute__((unused)) -#else -#define log_unused -#endif - -static void __attribute__((format(printf, 6, 0))) -log_file(void *data, - int priority log_unused, - const char *file log_unused, - const int line log_unused, - const char *fn log_unused, - const char *format, va_list args) -{ - FILE *fp = data; -#ifdef DEBUG - char buf[16]; - const char *priname; - - switch (priority) { - case LOG_EMERG: - priname = "EMERGENCY"; - break; - case LOG_ALERT: - priname = "ALERT"; - break; - case LOG_CRIT: - priname = "CRITICAL"; - break; - case LOG_ERR: - priname = "ERROR"; - break; - case LOG_WARNING: - priname = "WARNING"; - break; - case LOG_NOTICE: - priname = "NOTICE"; - break; - case LOG_INFO: - priname = "INFO"; - break; - case LOG_DEBUG: - priname = "DEBUG"; - break; - default: - snprintf(buf, sizeof(buf), "L:%d", priority); - priname = buf; - } - fprintf(fp, "libkeymap: %s %s:%d %s: ", priname, file, line, fn); -#endif - vfprintf(fp, format, args); - fprintf(fp, "\n"); -} - -#undef log_unused - -int lk_set_log_fn(struct lk_ctx *ctx, - void (*log_fn)(void *data, int priority, - const char *file, int line, const char *fn, - const char *format, va_list args), - const void *data) -{ - if (!ctx) - return -1; - - ctx->log_fn = log_fn; - ctx->log_data = (void *)data; - - return 0; -} - -int lk_get_log_priority(struct lk_ctx *ctx) -{ - if (!ctx) - return -1; - - return ctx->log_priority; -} - -int lk_set_log_priority(struct lk_ctx *ctx, int priority) -{ - if (!ctx) - return -1; - - ctx->log_priority = priority; - return 0; -} - -lk_flags -lk_get_parser_flags(struct lk_ctx *ctx) -{ - if (!ctx) - return -1; - - return ctx->flags; -} - -int lk_set_parser_flags(struct lk_ctx *ctx, lk_flags flags) -{ - if (!ctx) - return -1; - - ctx->flags = flags; - return 0; -} - -static int -init_array(struct lk_ctx *ctx, struct lk_array **arr, size_t size) -{ - int rc; - void *ptr; - - ptr = malloc(sizeof(struct lk_array)); - if (!ptr) { - ERR(ctx, _("out of memory")); - return -1; - } - - rc = lk_array_init(ptr, size, 0); - if (rc < 0) { - ERR(ctx, _("unable to initialize array: %s"), strerror(rc)); - return -1; - } - - *arr = ptr; - - return 0; -} - -struct lk_ctx * -lk_init(void) -{ - struct lk_ctx *ctx; - - ctx = malloc(sizeof(struct lk_ctx)); - if (!ctx) - return NULL; - - memset(ctx, 0, sizeof(struct lk_ctx)); - - lk_set_log_fn(ctx, log_file, stderr); - lk_set_log_priority(ctx, LOG_ERR); - - if (init_array(ctx, &ctx->keymap, sizeof(void *)) < 0 || - init_array(ctx, &ctx->func_table, sizeof(void *)) < 0 || - init_array(ctx, &ctx->accent_table, sizeof(void *)) < 0 || - init_array(ctx, &ctx->key_constant, sizeof(char)) < 0 || - init_array(ctx, &ctx->key_line, sizeof(int)) < 0) { - lk_free(ctx); - return NULL; - } - - return ctx; -} - -int lk_free(struct lk_ctx *ctx) -{ - unsigned int i; //, j; - - if (!ctx) - return -1; - - if (ctx->keymap) { - for (i = 0; i < ctx->keymap->total; i++) { - struct lk_array *map; - - map = lk_array_get_ptr(ctx->keymap, i); - if (!map) - continue; - - lk_array_free(map); - free(map); - } - lk_array_free(ctx->keymap); - free(ctx->keymap); - - ctx->keymap = NULL; - } - - if (ctx->func_table) { - for (i = 0; i < ctx->func_table->total; i++) { - char *ptr; - - ptr = lk_array_get_ptr(ctx->func_table, i); - if (!ptr) - continue; - - free(ptr); - } - lk_array_free(ctx->func_table); - free(ctx->func_table); - - ctx->func_table = NULL; - } - - if (ctx->accent_table) { - for (i = 0; i < ctx->accent_table->total; i++) { - struct lk_array *ptr; - - ptr = lk_array_get_ptr(ctx->accent_table, i); - if (!ptr) - continue; - - free(ptr); - } - lk_array_free(ctx->accent_table); - free(ctx->accent_table); - - ctx->accent_table = NULL; - } - - if (ctx->key_constant) { - lk_array_free(ctx->key_constant); - free(ctx->key_constant); - ctx->key_constant = NULL; - } - - if (ctx->key_line) { - lk_array_free(ctx->key_line); - free(ctx->key_line); - ctx->key_line = NULL; - } - - return 0; -} diff --git a/src/loadkeys.c b/src/loadkeys.c index b3b05fe..8b4f3b5 100644 --- a/src/loadkeys.c +++ b/src/loadkeys.c @@ -27,7 +27,7 @@ #include "keymap.h" static const char *progname = NULL; -static const char *const dirpath1[] = { "", DATADIR "/" KEYMAPDIR "/**", DATADIR "/" XKBKEYMAPDIR "/", DATADIR "/" LEGACYKEYMAPDIR "/**", KERNDIR "/", 0 }; +static const char *const dirpath1[] = { "", DATADIR "/" KEYMAPDIR "/**", KERNDIR "/", 0 }; static const char *const suffixes[] = { "", ".kmap", ".map", 0 }; static void __attribute__((noreturn)) diff --git a/src/loadkeys.c.loadkeys-search-path b/src/loadkeys.c.loadkeys-search-path deleted file mode 100644 index 8b4f3b5..0000000 --- a/src/loadkeys.c.loadkeys-search-path +++ /dev/null @@ -1,272 +0,0 @@ -/* loadkeys.c - * - * This file is part of kbd project. - * Copyright (C) 1993 Risto Kankkunen. - * Copyright (C) 1993 Eugene G. Crosser. - * Copyright (C) 1994-2007 Andries E. Brouwer. - * Copyright (C) 2007-2012 Alexey Gladkov - * - * This file is covered by the GNU General Public License, - * which should be included with kbd as the file COPYING. - */ -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include "nls.h" -#include "kbd.h" -#include "paths.h" -#include "getfd.h" -#include "kbd_error.h" - -#include "keymap.h" - -static const char *progname = NULL; -static const char *const dirpath1[] = { "", DATADIR "/" KEYMAPDIR "/**", KERNDIR "/", 0 }; -static const char *const suffixes[] = { "", ".kmap", ".map", 0 }; - -static void __attribute__((noreturn)) -usage(void) -{ - fprintf(stderr, _("loadkeys version %s\n" - "\n" - "Usage: %s [option...] [mapfile...]\n" - "\n" - "Valid options are:\n" - "\n" - " -a --ascii force conversion to ASCII\n" - " -b --bkeymap output a binary keymap to stdout\n" - " -c --clearcompose clear kernel compose table\n" - " -C --console=file\n" - " the console device to be used\n" - " -d --default load \"%s\"\n" - " -h --help display this help text\n" - " -m --mktable output a \"defkeymap.c\" to stdout\n" - " -p --parse search and parse keymap without action\n" - " -q --quiet suppress all normal output\n" - " -s --clearstrings clear kernel string table\n" - " -u --unicode force conversion to Unicode\n" - " -v --verbose report the changes\n" - " -V --version print version number\n"), - PACKAGE_VERSION, progname, DEFMAP); - exit(EXIT_FAILURE); -} - -static inline const char * -set_progname(const char *name) -{ - char *p; - p = strrchr(name, '/'); - return (p && p + 1 ? p + 1 : name); -} - -int main(int argc, char *argv[]) -{ - const char *const short_opts = "abcC:dhmpsuqvV"; - const struct option const long_opts[] = { - { "console", required_argument, NULL, 'C' }, - { "ascii", no_argument, NULL, 'a' }, - { "bkeymap", no_argument, NULL, 'b' }, - { "clearcompose", no_argument, NULL, 'c' }, - { "default", no_argument, NULL, 'd' }, - { "help", no_argument, NULL, 'h' }, - { "mktable", no_argument, NULL, 'm' }, - { "parse", no_argument, NULL, 'p' }, - { "clearstrings", no_argument, NULL, 's' }, - { "unicode", no_argument, NULL, 'u' }, - { "quiet", no_argument, NULL, 'q' }, - { "verbose", no_argument, NULL, 'v' }, - { "version", no_argument, NULL, 'V' }, - { NULL, 0, NULL, 0 } - }; - - enum options { - OPT_A = (1 << 1), - OPT_B = (1 << 2), - OPT_D = (1 << 3), - OPT_M = (1 << 4), - OPT_U = (1 << 5), - OPT_P = (1 << 6) - }; - int options = 0; - - const char *const *dirpath; - const char *dirpath2[] = { 0, 0 }; - - struct lk_ctx *ctx; - lk_flags flags = 0; - - int c, i, rc = -1; - int fd = -1; - int kbd_mode; - int kd_mode; - char *console = NULL; - char *ev; - lkfile_t f; - - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE_NAME, LOCALEDIR); - textdomain(PACKAGE_NAME); - - progname = set_progname(argv[0]); - - ctx = lk_init(); - if (!ctx) { - exit(EXIT_FAILURE); - } - - while ((c = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) { - switch (c) { - case 'a': - options |= OPT_A; - break; - case 'b': - options |= OPT_B; - break; - case 'c': - flags |= LK_FLAG_CLEAR_COMPOSE; - break; - case 'C': - console = optarg; - break; - case 'd': - options |= OPT_D; - break; - case 'm': - options |= OPT_M; - break; - case 'p': - options |= OPT_P; - break; - case 's': - flags |= LK_FLAG_CLEAR_STRINGS; - break; - case 'u': - options |= OPT_U; - flags |= LK_FLAG_UNICODE_MODE; - flags |= LK_FLAG_PREFER_UNICODE; - break; - case 'q': - lk_set_log_priority(ctx, LOG_ERR); - break; - case 'v': - lk_set_log_priority(ctx, LOG_INFO); - break; - case 'V': - fprintf(stdout, _("%s from %s\n"), progname, PACKAGE_STRING); - exit(0); - case 'h': - case '?': - usage(); - } - } - - if ((options & OPT_U) && (options & OPT_A)) { - fprintf(stderr, - _("%s: Options --unicode and --ascii are mutually exclusive\n"), - progname); - exit(EXIT_FAILURE); - } - - if (!(options & OPT_M) && !(options & OPT_B)) { - /* get console */ - if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); - - /* check whether the keyboard is in Unicode mode */ - if (ioctl(fd, KDGKBMODE, &kbd_mode) || - ioctl(fd, KDGETMODE, &kd_mode)) { - fprintf(stderr, _("%s: error reading keyboard mode: %m\n"), - progname); - exit(EXIT_FAILURE); - } - - if (kbd_mode == K_UNICODE) { - if (options & OPT_A) { - fprintf(stderr, - _("%s: warning: loading non-Unicode keymap on Unicode console\n" - " (perhaps you want to do `kbd_mode -a'?)\n"), - progname); - } else { - flags |= LK_FLAG_PREFER_UNICODE; - } - - /* reset -u option if keyboard is in K_UNICODE anyway */ - flags ^= LK_FLAG_UNICODE_MODE; - - } else if (options & OPT_U && kd_mode != KD_GRAPHICS) { - fprintf(stderr, - _("%s: warning: loading Unicode keymap on non-Unicode console\n" - " (perhaps you want to do `kbd_mode -u'?)\n"), - progname); - } - } - - lk_set_parser_flags(ctx, flags); - - dirpath = dirpath1; - if ((ev = getenv("LOADKEYS_KEYMAP_PATH")) != NULL) { - dirpath2[0] = ev; - dirpath = dirpath2; - } - - if (options & OPT_D) { - /* first read default map - search starts in . */ - - if (lk_findfile(DEFMAP, dirpath, suffixes, &f)) { - fprintf(stderr, _("Cannot find %s\n"), DEFMAP); - exit(EXIT_FAILURE); - } - - if ((rc = lk_parse_keymap(ctx, &f)) == -1) - goto fail; - - } else if (optind == argc) { - f.fd = stdin; - strcpy(f.pathname, ""); - - if ((rc = lk_parse_keymap(ctx, &f)) == -1) - goto fail; - } - - for (i = optind; argv[i]; i++) { - if (!strcmp(argv[i], "-")) { - f.fd = stdin; - strcpy(f.pathname, ""); - - } else if (lk_findfile(argv[i], dirpath, suffixes, &f)) { - fprintf(stderr, _("cannot open file %s\n"), argv[i]); - goto fail; - } - - if ((rc = lk_parse_keymap(ctx, &f)) == -1) - goto fail; - } - - if (!(options & OPT_P)) { - if (options & OPT_B) { - rc = lk_dump_bkeymap(ctx, stdout); - } else if (options & OPT_M) { - rc = lk_dump_ctable(ctx, stdout); - } else { - rc = lk_load_keymap(ctx, fd, kbd_mode); - } - } - -fail: - lk_free(ctx); - lk_fpclose(&f); - - if (fd >= 0) - close(fd); - - if (rc < 0) - exit(EXIT_FAILURE); - - exit(EXIT_SUCCESS); -} diff --git a/src/paths.h b/src/paths.h index 90c2e46..5109393 100644 --- a/src/paths.h +++ b/src/paths.h @@ -5,8 +5,6 @@ * The following five subdirectories are defined: */ #define KEYMAPDIR "keymaps" -#define XKBKEYMAPDIR "keymaps/xkb" -#define LEGACYKEYMAPDIR "keymaps/legacy" #define UNIMAPDIR "unimaps" #define TRANSDIR "consoletrans" #define VIDEOMODEDIR "videomodes" diff --git a/src/paths.h.loadkeys-search-path b/src/paths.h.loadkeys-search-path deleted file mode 100644 index 5109393..0000000 --- a/src/paths.h.loadkeys-search-path +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _PATHS_H -#define _PATHS_H -/* - * All data is in subdirectories of DATADIR, by default /usr/lib/kbd - * The following five subdirectories are defined: - */ -#define KEYMAPDIR "keymaps" -#define UNIMAPDIR "unimaps" -#define TRANSDIR "consoletrans" -#define VIDEOMODEDIR "videomodes" -#define FONTDIR "consolefonts" -/* subdir of the latter */ -#define PARTIALDIR "partialfonts" -/* obsolete */ -#define OLDKEYMAPDIR "keytables" - -/* - * Default keymap, and where the kernel copy of it lives. - */ -#ifdef __sparc__ -#define DEFMAP "sunkeymap.map" -#define KERNDIR "/usr/src/linux/drivers/sbus/char" -#else -#define DEFMAP "defkeymap.map" -#define KERNDIR "/usr/src/linux/drivers/tty/vt" -#endif - -extern int verbose; -extern int debug; - -#endif /* _PATHS_H */ diff --git a/src/setfont.c b/src/setfont.c index e1a16c4..d5a577d 100644 --- a/src/setfont.c +++ b/src/setfont.c @@ -327,8 +327,6 @@ do_loadfont(int fd, char *inbuf, int width, int height, int hwunit, if (putfont(fd, buf, fontsize, width, hwunit)) exit(EX_OSERR); - - free(buf); } static void diff --git a/src/setfont.c.covscan-fixes b/src/setfont.c.covscan-fixes deleted file mode 100644 index d5a577d..0000000 --- a/src/setfont.c.covscan-fixes +++ /dev/null @@ -1,758 +0,0 @@ -/* - * setfont.c - Eugene Crosser & Andries Brouwer - * - * Version 1.05 - * - * Loads the console font, and possibly the corresponding screen map(s). - * We accept two kind of screen maps, one [-m] giving the correspondence - * between some arbitrary 8-bit character set currently in use and the - * font positions, and the second [-u] giving the correspondence between - * font positions and Unicode values. - */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "paths.h" -#include "getfd.h" -#include "findfile.h" -#include "loadunimap.h" -#include "psf.h" -#include "psffontop.h" -#include "kdfontop.h" -#include "kdmapop.h" -#include "xmalloc.h" -#include "nls.h" -#include "version.h" -#include "kbd_error.h" - -static int position_codepage(int iunit); -static void saveoldfont(int fd, char *ofil); -static void saveoldfontplusunicodemap(int fd, char *Ofil); -static void loadnewfont(int fd, char *ifil, - int iunit, int hwunit, int no_m, int no_u); -static void loadnewfonts(int fd, char **ifiles, int ifilct, - int iunit, int hwunit, int no_m, int no_u); -extern void saveoldmap(int fd, char *omfil); -extern void loadnewmap(int fd, char *mfil); -extern void activatemap(int fd); -extern void disactivatemap(int fd); - -int verbose = 0; -int force = 0; -int debug = 0; - -/* search for the font in these directories (with trailing /) */ -const char *const fontdirpath[] = { "", DATADIR "/" FONTDIR "/", 0 }; -const char *const fontsuffixes[] = { "", ".psfu", ".psf", ".cp", ".fnt", 0 }; -/* hide partial fonts a bit - loading a single one is a bad idea */ -const char *const partfontdirpath[] = { "", DATADIR "/" FONTDIR "/" PARTIALDIR "/", 0 }; -const char *const partfontsuffixes[] = { "", 0 }; - -static inline int -findfont(char *fnam, lkfile_t *fp) -{ - return lk_findfile(fnam, fontdirpath, fontsuffixes, fp); -} - -static inline int -findpartialfont(char *fnam, lkfile_t *fp) -{ - return lk_findfile(fnam, partfontdirpath, partfontsuffixes, fp); -} - -static void __attribute__((noreturn)) -usage(void) -{ - fprintf(stderr, _( - "Usage: setfont [write-options] [-] [newfont..] [-m consolemap] [-u unicodemap]\n" - " write-options (take place before file loading):\n" - " -o Write current font to \n" - " -O Write current font and unicode map to \n" - " -om Write current consolemap to \n" - " -ou Write current unicodemap to \n" - "If no newfont and no -[o|O|om|ou|m|u] option is given,\n" - "a default font is loaded:\n" - " setfont Load font \"default[.gz]\"\n" - " setfont - Load font \"default8x[.gz]\"\n" - "The - option selects a font from a codepage that contains three fonts:\n" - " setfont -{8|14|16} codepage.cp[.gz] Load 8x font from codepage.cp\n" - "Explicitly (with -m or -u) or implicitly (in the fontfile) given mappings\n" - "will be loaded and, in the case of consolemaps, activated.\n" - " -h (no space) Override font height.\n" - " -m Load console screen map.\n" - " -u Load font unicode map.\n" - " -m none Suppress loading and activation of a screen map.\n" - " -u none Suppress loading of a unicode map.\n" - " -v Be verbose.\n" - " -C Indicate console device to be used.\n" - " -V Print version and exit.\n" - "Files are loaded from the current directory or %s/*/.\n"), - DATADIR); - exit(EX_USAGE); -} - -#define MAXIFILES 256 - -int main(int argc, char *argv[]) -{ - char *ifiles[MAXIFILES]; - char *mfil, *ufil, *Ofil, *ofil, *omfil, *oufil, *console; - int ifilct = 0, fd, i, iunit, hwunit, no_m, no_u; - int restore = 0; - - set_progname(argv[0]); - - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE_NAME, LOCALEDIR); - textdomain(PACKAGE_NAME); - - ifiles[0] = mfil = ufil = Ofil = ofil = omfil = oufil = NULL; - iunit = hwunit = 0; - no_m = no_u = 0; - console = NULL; - - /* - * No getopt() here because of the -om etc options. - */ - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-V")) { - print_version_and_exit(); - } else if (!strcmp(argv[i], "-v")) { - verbose++; - } else if (!strcmp(argv[i], "-R")) { - restore = 1; - } else if (!strcmp(argv[i], "-C")) { - if (++i == argc || console) - usage(); - console = argv[i]; - } else if (!strcmp(argv[i], "-O")) { - if (++i == argc || Ofil) - usage(); - Ofil = argv[i]; - } else if (!strcmp(argv[i], "-o")) { - if (++i == argc || ofil) - usage(); - ofil = argv[i]; - } else if (!strcmp(argv[i], "-om")) { - if (++i == argc || omfil) - usage(); - omfil = argv[i]; - } else if (!strcmp(argv[i], "-ou")) { - if (++i == argc || oufil) - usage(); - oufil = argv[i]; - } else if (!strcmp(argv[i], "-m")) { - if (++i == argc || mfil) - usage(); - if (!strcmp(argv[i], "none")) - no_m = 1; - else - mfil = argv[i]; - } else if (!strcmp(argv[i], "-u")) { - if (++i == argc || ufil) - usage(); - if (!strcmp(argv[i], "none")) - no_u = 1; - else - ufil = argv[i]; - } else if (!strcmp(argv[i], "-f")) { - force = 1; - } else if (!strncmp(argv[i], "-h", 2)) { - hwunit = atoi(argv[i] + 2); - if (hwunit <= 0 || hwunit > 32) - usage(); - } else if (argv[i][0] == '-') { - iunit = atoi(argv[i] + 1); - if (iunit <= 0 || iunit > 32) - usage(); - } else { - if (ifilct == MAXIFILES) { - fprintf(stderr, _("setfont: too many input files\n")); - exit(EX_USAGE); - } - ifiles[ifilct++] = argv[i]; - } - } - - if (ifilct && restore) { - fprintf(stderr, _("setfont: cannot both restore from character ROM" - " and from file. Font unchanged.\n")); - exit(EX_USAGE); - } - - if ((fd = getfd(console)) < 0) - kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console")); - - int kd_mode = -1; - if (!ioctl(fd, KDGETMODE, &kd_mode) && (kd_mode == KD_GRAPHICS)) { - /* - * PIO_FONT will fail on a console which is in foreground and in KD_GRAPHICS mode. - * 2005-03-03, jw@suse.de. - */ - if (verbose) - printf("setfont: graphics console %s skipped\n", console ? console : ""); - close(fd); - return 0; - } - - if (!ifilct && !mfil && !ufil && - !Ofil && !ofil && !omfil && !oufil && !restore) - /* reset to some default */ - ifiles[ifilct++] = ""; - - if (Ofil) - saveoldfontplusunicodemap(fd, Ofil); - - if (ofil) - saveoldfont(fd, ofil); - - if (omfil) - saveoldmap(fd, omfil); - - if (oufil) - saveunicodemap(fd, oufil); - - if (mfil) { - loadnewmap(fd, mfil); - activatemap(fd); - no_m = 1; - } - - if (ufil) - no_u = 1; - - if (restore) - restorefont(fd); - - if (ifilct) - loadnewfonts(fd, ifiles, ifilct, iunit, hwunit, no_m, no_u); - - if (ufil) - loadunicodemap(fd, ufil); - - return 0; -} - -/* - * 0 - do not test, 1 - test and warn, 2 - test and wipe, 3 - refuse - */ -static int erase_mode = 1; - -static void -do_loadfont(int fd, char *inbuf, int width, int height, int hwunit, - int fontsize, char *filename) -{ - unsigned char *buf; - int i, buflen; - int bytewidth = (width + 7) / 8; - int charsize = height * bytewidth; - int kcharsize = 32 * bytewidth; - int bad_video_erase_char = 0; - - if (height < 1 || height > 32) { - fprintf(stderr, _("Bad character height %d\n"), height); - exit(EX_DATAERR); - } - if (width < 1 || width > 32) { - fprintf(stderr, _("Bad character width %d\n"), width); - exit(EX_DATAERR); - } - - if (!hwunit) - hwunit = height; - - buflen = kcharsize * ((fontsize < 128) ? 128 : fontsize); - buf = xmalloc(buflen); - memset(buf, 0, buflen); - - for (i = 0; i < fontsize; i++) - memcpy(buf + (i * kcharsize), inbuf + (i * charsize), charsize); - - /* - * Due to a kernel bug, font position 32 is used - * to erase the screen, regardless of maps loaded. - * So, usually this font position should be blank. - */ - if (erase_mode) { - for (i = 0; i < kcharsize; i++) - if (buf[32 * kcharsize + i]) - bad_video_erase_char = 1; - if (bad_video_erase_char) { - fprintf(stderr, - _("%s: font position 32 is nonblank\n"), - progname); - switch (erase_mode) { - case 3: - exit(EX_DATAERR); - case 2: - for (i = 0; i < kcharsize; i++) - buf[32 * kcharsize + i] = 0; - fprintf(stderr, _("%s: wiped it\n"), progname); - break; - case 1: - fprintf(stderr, - _("%s: background will look funny\n"), - progname); - } - fflush(stderr); - sleep(2); - } - } - - if (verbose) { - if (height == hwunit && filename) - printf(_("Loading %d-char %dx%d font from file %s\n"), - fontsize, width, height, filename); - else if (height == hwunit) - printf(_("Loading %d-char %dx%d font\n"), - fontsize, width, height); - else if (filename) - printf(_("Loading %d-char %dx%d (%d) font from file %s\n"), - fontsize, width, height, hwunit, filename); - else - printf(_("Loading %d-char %dx%d (%d) font\n"), - fontsize, width, height, hwunit); - } - - if (putfont(fd, buf, fontsize, width, hwunit)) - exit(EX_OSERR); -} - -static void -do_loadtable(int fd, struct unicode_list *uclistheads, int fontsize) -{ - struct unimapdesc ud; - struct unipair *up; - int i, ct = 0, maxct; - struct unicode_list *ul; - struct unicode_seq *us; - - maxct = 0; - for (i = 0; i < fontsize; i++) { - ul = uclistheads[i].next; - while (ul) { - us = ul->seq; - if (us && !us->next) - maxct++; - ul = ul->next; - } - } - up = xmalloc(maxct * sizeof(struct unipair)); - for (i = 0; i < fontsize; i++) { - ul = uclistheads[i].next; - if (debug) - printf("char %03x:", i); - while (ul) { - us = ul->seq; - if (us && !us->next) { - up[ct].unicode = us->uc; - up[ct].fontpos = i; - ct++; - if (debug) - printf(" %04x", us->uc); - } else if (debug) { - printf(" seq: <"); - while (us) { - printf(" %04x", us->uc); - us = us->next; - } - printf(" >"); - } - ul = ul->next; - if (debug) - printf(","); - } - if (debug) - printf("\n"); - } - if (ct != maxct) { - char *u = _("%s: bug in do_loadtable\n"); - fprintf(stderr, u, progname); - exit(EX_SOFTWARE); - } - - if (verbose) - printf(_("Loading Unicode mapping table...\n")); - - ud.entry_ct = ct; - ud.entries = up; - if (loadunimap(fd, NULL, &ud)) - exit(EX_OSERR); -} - -static void -loadnewfonts(int fd, char **ifiles, int ifilct, - int iunit, int hwunit, int no_m, int no_u) -{ - char *ifil, *inbuf, *fontbuf, *bigfontbuf; - int inputlth, fontbuflth, fontsize, height, width, bytewidth; - int bigfontbuflth, bigfontsize, bigheight, bigwidth; - struct unicode_list *uclistheads; - int i; - lkfile_t fp; - - if (ifilct == 1) { - loadnewfont(fd, ifiles[0], iunit, hwunit, no_m, no_u); - return; - } - - /* several fonts that must be merged */ - /* We just concatenate the bitmaps - only allow psf fonts */ - bigfontbuf = NULL; - bigfontbuflth = 0; - bigfontsize = 0; - uclistheads = NULL; - bigheight = 0; - bigwidth = 0; - - for (i = 0; i < ifilct; i++) { - ifil = ifiles[i]; - if (findfont(ifil, &fp) && findpartialfont(ifil, &fp)) { - fprintf(stderr, _("Cannot open font file %s\n"), ifil); - exit(EX_NOINPUT); - } - - inbuf = fontbuf = NULL; - inputlth = fontbuflth = 0; - fontsize = 0; - - if (readpsffont(fp.fd, &inbuf, &inputlth, &fontbuf, &fontbuflth, - &width, &fontsize, bigfontsize, - no_u ? NULL : &uclistheads)) { - fprintf(stderr, _("When loading several fonts, all " - "must be psf fonts - %s isn't\n"), - fp.pathname); - lk_fpclose(&fp); - exit(EX_DATAERR); - } - lk_fpclose(&fp); // avoid zombies, jw@suse.de (#88501) - bytewidth = (width + 7) / 8; - height = fontbuflth / (bytewidth * fontsize); - if (verbose) - printf(_("Read %d-char %dx%d font from file %s\n"), - fontsize, width, height, fp.pathname); - - if (bigheight == 0) - bigheight = height; - else if (bigheight != height) { - fprintf(stderr, _("When loading several fonts, all " - "must have the same height\n")); - exit(EX_DATAERR); - } - if (bigwidth == 0) - bigwidth = width; - else if (bigwidth != width) { - fprintf(stderr, _("When loading several fonts, all " - "must have the same width\n")); - exit(EX_DATAERR); - } - - bigfontsize += fontsize; - bigfontbuflth += fontbuflth; - bigfontbuf = xrealloc(bigfontbuf, bigfontbuflth); - memcpy(bigfontbuf + bigfontbuflth - fontbuflth, - fontbuf, fontbuflth); - } - do_loadfont(fd, bigfontbuf, bigwidth, bigheight, hwunit, - bigfontsize, NULL); - free(bigfontbuf); - - if (uclistheads && !no_u) - do_loadtable(fd, uclistheads, bigfontsize); -} - -static void -loadnewfont(int fd, char *ifil, int iunit, int hwunit, int no_m, int no_u) -{ - lkfile_t fp; - char defname[20]; - int height, width, bytewidth, def = 0; - char *inbuf, *fontbuf; - int inputlth, fontbuflth, fontsize, offset; - struct unicode_list *uclistheads; - - if (!*ifil) { - /* try to find some default file */ - - def = 1; /* maybe also load default unimap */ - - if (iunit < 0 || iunit > 32) - iunit = 0; - if (iunit == 0) { - if (findfont(ifil = "default", &fp) && - findfont(ifil = "default8x16", &fp) && - findfont(ifil = "default8x14", &fp) && - findfont(ifil = "default8x8", &fp)) { - fprintf(stderr, _("Cannot find default font\n")); - exit(EX_NOINPUT); - } - } else { - sprintf(defname, "default8x%d", iunit); - if (findfont(ifil = defname, &fp) && - findfont(ifil = "default", &fp)) { - fprintf(stderr, _("Cannot find %s font\n"), ifil); - exit(EX_NOINPUT); - } - } - } else { - if (findfont(ifil, &fp)) { - fprintf(stderr, _("Cannot open font file %s\n"), ifil); - exit(EX_NOINPUT); - } - } - - if (verbose > 1) - printf(_("Reading font file %s\n"), ifil); - - inbuf = fontbuf = NULL; - inputlth = fontbuflth = fontsize = 0; - width = 8; - uclistheads = NULL; - if (readpsffont(fp.fd, &inbuf, &inputlth, &fontbuf, &fontbuflth, - &width, &fontsize, 0, - no_u ? NULL : &uclistheads) == 0) { - lk_fpclose(&fp); - /* we've got a psf font */ - bytewidth = (width + 7) / 8; - height = fontbuflth / (bytewidth * fontsize); - - do_loadfont(fd, fontbuf, width, height, hwunit, - fontsize, fp.pathname); - if (uclistheads && !no_u) - do_loadtable(fd, uclistheads, fontsize); -#if 1 - if (!uclistheads && !no_u && def) - loadunicodemap(fd, "def.uni"); -#endif - return; - } - lk_fpclose(&fp); // avoid zombies, jw@suse.de (#88501) - - /* instructions to combine fonts? */ - { - char *combineheader = "# combine partial fonts\n"; - int chlth = strlen(combineheader); - char *p, *q; - if (inputlth >= chlth && !strncmp(inbuf, combineheader, chlth)) { - char *ifiles[MAXIFILES]; - int ifilct = 0; - q = inbuf + chlth; - while (q < inbuf + inputlth) { - p = q; - while (q < inbuf + inputlth && *q != '\n') - q++; - if (q == inbuf + inputlth) { - fprintf(stderr, - _("No final newline in combine file\n")); - exit(EX_DATAERR); - } - *q++ = 0; - if (ifilct == MAXIFILES) { - fprintf(stderr, - _("Too many files to combine\n")); - exit(EX_DATAERR); - } - ifiles[ifilct++] = p; - } - /* recursive call */ - loadnewfonts(fd, ifiles, ifilct, iunit, hwunit, no_m, no_u); - return; - } - } - - /* file with three code pages? */ - if (inputlth == 9780) { - offset = position_codepage(iunit); - height = iunit; - fontsize = 256; - width = 8; - } else if (inputlth == 32768) { - /* restorefont -w writes a SVGA font to file - restorefont -r restores it - These fonts have size 32768, for two 512-char fonts. - In fact, when BROKEN_GRAPHICS_PROGRAMS is defined, - and it always is, there is no default font that is saved, - so probably the second half is always garbage. */ - fprintf(stderr, _("Hmm - a font from restorefont? " - "Using the first half.\n")); - inputlth = 16384; /* ignore rest */ - fontsize = 512; - offset = 0; - width = 8; - height = 32; - if (!hwunit) - hwunit = 16; - } else { - int rem = (inputlth % 256); - if (rem == 0 || rem == 40) { - /* 0: bare code page bitmap */ - /* 40: preceded by .cp header */ - /* we might check some header details */ - offset = rem; - } else { - fprintf(stderr, _("Bad input file size\n")); - exit(EX_DATAERR); - } - fontsize = 256; - width = 8; - height = inputlth / 256; - } - do_loadfont(fd, inbuf + offset, width, height, hwunit, fontsize, - fp.pathname); -} - -static int -position_codepage(int iunit) -{ - int offset; - - /* code page: first 40 bytes, then 8x16 font, - then 6 bytes, then 8x14 font, - then 6 bytes, then 8x8 font */ - - if (!iunit) { - fprintf(stderr, - _("This file contains 3 fonts: 8x8, 8x14 and 8x16." - " Please indicate\n" - "using an option -8 or -14 or -16 " - "which one you want loaded.\n")); - exit(EX_USAGE); - } - switch (iunit) { - case 8: - offset = 7732; - break; - case 14: - offset = 4142; - break; - case 16: - offset = 40; - break; - default: - fprintf(stderr, _("You asked for font size %d, " - "but only 8, 14, 16 are possible here.\n"), - iunit); - exit(EX_USAGE); - } - return offset; -} - -static void -do_saveoldfont(int fd, char *ofil, FILE *fpo, int unimap_follows, - int *count, int *utf8) -{ - -/* this is the max font size the kernel is willing to handle */ -#define MAXFONTSIZE 65536 - unsigned char buf[MAXFONTSIZE]; - - int i, ct, width, height, bytewidth, charsize, kcharsize; - - ct = sizeof(buf) / (32 * 32 / 8); /* max size 32x32, 8 bits/byte */ - if (getfont(fd, buf, &ct, &width, &height)) - exit(EX_OSERR); - - /* save as efficiently as possible */ - bytewidth = (width + 7) / 8; - height = font_charheight(buf, ct, width); - charsize = height * bytewidth; - kcharsize = 32 * bytewidth; - -/* Do we need a psf header? */ -/* Yes if ct==512 - otherwise we cannot distinguish - a 512-char 8x8 and a 256-char 8x16 font. */ -#define ALWAYS_PSF_HEADER 1 - - if (ct != 256 || width != 8 || unimap_follows || ALWAYS_PSF_HEADER) { - int psftype = 1; - int flags = 0; - - if (unimap_follows) - flags |= WPSFH_HASTAB; - writepsffontheader(fpo, width, height, ct, &psftype, flags); - if (utf8) - *utf8 = (psftype == 2); - } - - if (height == 0) { - fprintf(stderr, _("Found nothing to save\n")); - } else { - for (i = 0; i < ct; i++) { - if (fwrite(buf + (i * kcharsize), charsize, 1, fpo) != 1) { - fprintf(stderr, _("Cannot write font file")); - exit(EX_IOERR); - } - } - if (verbose) { - printf(_("Saved %d-char %dx%d font file on %s\n"), - ct, width, height, ofil); - } - } - - if (count) - *count = ct; -} - -static void -saveoldfont(int fd, char *ofil) -{ - FILE *fpo; - - if ((fpo = fopen(ofil, "w")) == NULL) { - perror(ofil); - exit(EX_CANTCREAT); - } - do_saveoldfont(fd, ofil, fpo, 0, NULL, NULL); - fclose(fpo); -} - -static void -saveoldfontplusunicodemap(int fd, char *Ofil) -{ - FILE *fpo; - int ct; - int utf8 = 0; - - if ((fpo = fopen(Ofil, "w")) == NULL) { - perror(Ofil); - exit(EX_CANTCREAT); - } - ct = 0; - do_saveoldfont(fd, Ofil, fpo, 1, &ct, &utf8); - appendunicodemap(fd, fpo, ct, utf8); - fclose(fpo); -} - -/* Only on the current console? On all allocated consoles? */ -/* A newly allocated console has NORM_MAP by default - - probably it should copy the default from the current console? - But what if we want a new one because the current one is messed up? */ -/* For the moment: only the current console, only the G0 set */ - -static void -send_escseq(int fd, char *seq, int n) -{ - if (write(fd, seq, n) != n) /* maybe fd is read-only */ - printf("%s", seq); -} - -void activatemap(int fd) -{ - send_escseq(fd, "\033(K", 3); -} - -void disactivatemap(int fd) -{ - send_escseq(fd, "\033(B", 3); -} diff --git a/src/unicode_start b/src/unicode_start index 778e549..d5234a8 100755 --- a/src/unicode_start +++ b/src/unicode_start @@ -72,12 +72,6 @@ stty iutf8 # have a Unicode map attached, or explicitly specified, e.g., # by giving `def.uni' as a second argument. -# Source /etc/vconsole.conf to get default font -. /etc/vconsole.conf - -DEFAULT_UNICODE_FONT=$FONT -# Also drdos8x16 is a good candidate. - case "$#" in 2) setfont "$1" -u "$2" @@ -86,7 +80,6 @@ case "$#" in setfont "$1" ;; 0) - setfont $DEFAULT_UNICODE_FONT ;; *) echo "usage: unicode_start [font [unicode map]]" diff --git a/src/unicode_start.unicode-start-font b/src/unicode_start.unicode-start-font deleted file mode 100755 index 702867d..0000000 --- a/src/unicode_start.unicode-start-font +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh - -# 0. Check whether we're on a console -TTY="`/usr/bin/tty`" -case "$TTY" in - /dev/console|/dev/vc*|/dev/tty[0-9]*) - ;; - *) - echo "unicode_start skipped on $TTY" >&2 - exit 0 - ;; -esac - -# Enables Unicode processing in the current console. -# -# 1. The input side: the keyboard driver. - -# Set the keyboard driver in Unicode mode. (Default is ASCII mode.) -# This really does nothing with the way normal keys are handled in -# the kernel. All it does is: -# - It is necessary for `dumpkeys' in order to not drop U+XXXX -# entries from the keymaps. -# - It is necessary for `loadkeys' in order to avoid warnings. -# - Unicode characters typed as Alt-x1 ... Alt-xn (where x1,...,xn -# are digits on the numeric keypad) will be emitted in UTF-8. - -kbd_mode -u - -# Change the keyboard mapping in such a way that the non-ASCII keys -# produce UTF-8 encoded multibyte sequences, instead of single bytes -# >= 0x80 in a legacy 8-bit encoding. - -# Non-root users are allowed to change the unicode mode of their console, but -# not the global keymap. root will have to load the keymap in unicode mode -# explicitly. - -uid="`id -u 2>/dev/null`" ||: -if [ "$uid" = '0' ]; then - # There is no way of reverting the effect of "dumpkeys | loadkeys --unicode", - # the memory of the earlier keymap is lost. Therefore, try - # to save a copy of the original keymap to be able to reload it in unicode_stop. - # (see also http://mail.nl.linux.org/linux-utf8/2003-08/msg00053.html): - - [ -n "$HOME" -a "$HOME" != '/' ] || - HOME='/root' - - if [ -d "$HOME" -a -w "$HOME" ]; then - [ -d "$HOME/.kbd" ] || - mkdir -- "$HOME/.kbd" - - [ ! -w "$HOME/.kbd" ] || - dumpkeys > "$HOME/.kbd/.keymap_sv" - fi - - # redirect stderr and stdout of loadkeys to /dev/null to avoid the confusing - # "plus before udiaeresis ignored" warnings. - - dumpkeys | loadkeys --unicode > /dev/null 2>&1 -fi - -# 2. The output side: the console screen. - -# Tell the console output driver that the bytes arriving are UTF-8 -# encoded multibyte sequences. -if [ -t 1 -a -t 2 ]; then - printf '\033%%G' -fi -stty iutf8 - -# Tell the graphics card how to display Unicode characters not -# contained in the IBM 437 character set (on PCs). The font should -# have a Unicode map attached, or explicitly specified, e.g., -# by giving `def.uni' as a second argument. - -DEFAULT_UNICODE_FONT=latarcyrheb-sun16 -# Also drdos8x16 is a good candidate. - -case "$#" in - 2) - setfont "$1" -u "$2" - ;; - 1) - setfont "$1" - ;; - 0) - setfont $DEFAULT_UNICODE_FONT - ;; - *) - echo "usage: unicode_start [font [unicode map]]" - ;; -esac diff --git a/src/unicode_start.unicode_start b/src/unicode_start.unicode_start deleted file mode 100755 index d5234a8..0000000 --- a/src/unicode_start.unicode_start +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh - -# 0. Check whether we're on a console -TTY="`/usr/bin/tty`" -case "$TTY" in - /dev/console|/dev/vc*|/dev/tty[0-9]*) - ;; - *) - echo "unicode_start skipped on $TTY" >&2 - exit 0 - ;; -esac - -# Enables Unicode processing in the current console. -# -# 1. The input side: the keyboard driver. - -# Set the keyboard driver in Unicode mode. (Default is ASCII mode.) -# This really does nothing with the way normal keys are handled in -# the kernel. All it does is: -# - It is necessary for `dumpkeys' in order to not drop U+XXXX -# entries from the keymaps. -# - It is necessary for `loadkeys' in order to avoid warnings. -# - Unicode characters typed as Alt-x1 ... Alt-xn (where x1,...,xn -# are digits on the numeric keypad) will be emitted in UTF-8. - -kbd_mode -u - -# Change the keyboard mapping in such a way that the non-ASCII keys -# produce UTF-8 encoded multibyte sequences, instead of single bytes -# >= 0x80 in a legacy 8-bit encoding. - -# Non-root users are allowed to change the unicode mode of their console, but -# not the global keymap. root will have to load the keymap in unicode mode -# explicitly. - -uid="`id -u 2>/dev/null`" ||: -if [ "$uid" = '0' ]; then - # There is no way of reverting the effect of "dumpkeys | loadkeys --unicode", - # the memory of the earlier keymap is lost. Therefore, try - # to save a copy of the original keymap to be able to reload it in unicode_stop. - # (see also http://mail.nl.linux.org/linux-utf8/2003-08/msg00053.html): - - [ -n "$HOME" -a "$HOME" != '/' ] || - HOME='/root' - - if [ -d "$HOME" -a -w "$HOME" ]; then - [ -d "$HOME/.kbd" ] || - mkdir -- "$HOME/.kbd" - - [ ! -w "$HOME/.kbd" ] || - dumpkeys > "$HOME/.kbd/.keymap_sv" - fi - - # redirect stderr and stdout of loadkeys to /dev/null to avoid the confusing - # "plus before udiaeresis ignored" warnings. - - dumpkeys | loadkeys --unicode > /dev/null 2>&1 -fi - -# 2. The output side: the console screen. - -# Tell the console output driver that the bytes arriving are UTF-8 -# encoded multibyte sequences. -if [ -t 1 -a -t 2 ]; then - printf '\033%%G' -fi -stty iutf8 - -# Tell the graphics card how to display Unicode characters not -# contained in the IBM 437 character set (on PCs). The font should -# have a Unicode map attached, or explicitly specified, e.g., -# by giving `def.uni' as a second argument. - -case "$#" in - 2) - setfont "$1" -u "$2" - ;; - 1) - setfont "$1" - ;; - 0) - ;; - *) - echo "usage: unicode_start [font [unicode map]]" - ;; -esac