|
Packit Service |
50ad14 |
#include "config.h"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
#include <stdio.h>
|
|
Packit Service |
50ad14 |
#include <stdlib.h>
|
|
Packit Service |
50ad14 |
#include <errno.h>
|
|
Packit Service |
50ad14 |
#include <ctype.h>
|
|
Packit Service |
50ad14 |
#include <unistd.h>
|
|
Packit Service |
50ad14 |
#include <sys/ioctl.h>
|
|
Packit Service |
50ad14 |
#include <linux/kd.h>
|
|
Packit Service |
50ad14 |
#include "getfd.h"
|
|
Packit Service |
50ad14 |
#include "xmalloc.h"
|
|
Packit Service |
50ad14 |
#include "kdmapop.h"
|
|
Packit Service |
50ad14 |
#include "nls.h"
|
|
Packit Service |
50ad14 |
#include "version.h"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
#ifndef USE_LIBC
|
|
Packit Service |
50ad14 |
/* There is such function in libc5 but it doesn't work for me [libc 5.4.13] */
|
|
Packit Service |
50ad14 |
#include "wctomb.c"
|
|
Packit Service |
50ad14 |
#define wctomb our_wctomb
|
|
Packit Service |
50ad14 |
#endif
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
static int
|
|
Packit Service |
50ad14 |
ud_compar(const void *u1, const void *u2)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
unsigned short fp1 = ((struct unipair *)u1)->fontpos;
|
|
Packit Service |
50ad14 |
unsigned short fp2 = ((struct unipair *)u2)->fontpos;
|
|
Packit Service |
50ad14 |
return (int)fp1 - (int)fp2;
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
static void __attribute__((noreturn))
|
|
Packit Service |
50ad14 |
usage(void)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
fprintf(stderr, _("Usage:\n\t%s [-s] [-C console]\n"), progname);
|
|
Packit Service |
50ad14 |
exit(EXIT_FAILURE);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
int main(int argc, char **argv)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
int sortflag = 0;
|
|
Packit Service |
50ad14 |
char mb[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
Packit Service |
50ad14 |
unsigned mb_length;
|
|
Packit Service |
50ad14 |
int fd, c, i;
|
|
Packit Service |
50ad14 |
char *console = NULL;
|
|
Packit Service |
50ad14 |
struct unimapdesc ud;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
set_progname(argv[0]);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
setlocale(LC_ALL, "");
|
|
Packit Service |
50ad14 |
bindtextdomain(PACKAGE_NAME, LOCALEDIR);
|
|
Packit Service |
50ad14 |
textdomain(PACKAGE_NAME);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (argc == 2 &&
|
|
Packit Service |
50ad14 |
(!strcmp(argv[1], "-V") || !strcmp(argv[1], "--version")))
|
|
Packit Service |
50ad14 |
print_version_and_exit();
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
while ((c = getopt(argc, argv, "sC:")) != EOF) {
|
|
Packit Service |
50ad14 |
switch (c) {
|
|
Packit Service |
50ad14 |
case 's':
|
|
Packit Service |
50ad14 |
sortflag = 1;
|
|
Packit Service |
50ad14 |
break;
|
|
Packit Service |
50ad14 |
case 'C':
|
|
Packit Service |
50ad14 |
console = optarg;
|
|
Packit Service |
50ad14 |
break;
|
|
Packit Service |
50ad14 |
default:
|
|
Packit Service |
50ad14 |
usage();
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (optind < argc)
|
|
Packit Service |
50ad14 |
usage();
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if ((fd = getfd(console)) < 0)
|
|
Packit Service |
50ad14 |
kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (getunimap(fd, &ud))
|
|
Packit Service |
50ad14 |
return EXIT_FAILURE;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (sortflag) {
|
|
Packit Service |
50ad14 |
printf("# sorted kernel unimap - count=%d\n", ud.entry_ct);
|
|
Packit Service |
50ad14 |
/* sort and merge entries */
|
|
Packit Service |
50ad14 |
qsort(ud.entries, ud.entry_ct, sizeof(ud.entries[0]),
|
|
Packit Service |
50ad14 |
ud_compar);
|
|
Packit Service |
50ad14 |
for (i = 0; i < ud.entry_ct; i++) {
|
|
Packit Service |
50ad14 |
int fp = ud.entries[i].fontpos;
|
|
Packit Service |
50ad14 |
printf("0x%03x\tU+%04x", fp, ud.entries[i].unicode);
|
|
Packit Service |
50ad14 |
while (i + 1 < ud.entry_ct &&
|
|
Packit Service |
50ad14 |
ud.entries[i + 1].fontpos == fp)
|
|
Packit Service |
50ad14 |
printf(" U+%04x", ud.entries[++i].unicode);
|
|
Packit Service |
50ad14 |
printf("\n");
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
} else {
|
|
Packit Service |
50ad14 |
printf("# kernel unimap - count=%d\n", ud.entry_ct);
|
|
Packit Service |
50ad14 |
for (i = 0; i < ud.entry_ct; i++) {
|
|
Packit Service |
50ad14 |
mb_length = wctomb(mb, ud.entries[i].unicode);
|
|
Packit Service |
50ad14 |
mb[(mb_length > 6) ? 0 : mb_length] = 0;
|
|
Packit Service |
50ad14 |
if (mb_length == 1 && !isprint(mb[0])) {
|
|
Packit Service |
50ad14 |
mb[2] = 0;
|
|
Packit Service |
50ad14 |
mb[1] = mb[0] + 0100;
|
|
Packit Service |
50ad14 |
mb[0] = '^';
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
printf("0x%03x\tU+%04x\t# %s \n",
|
|
Packit Service |
50ad14 |
ud.entries[i].fontpos,
|
|
Packit Service |
50ad14 |
ud.entries[i].unicode, mb);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
return EXIT_SUCCESS;
|
|
Packit Service |
50ad14 |
}
|