Imported Upstream version 2.0.90
[platform/upstream/kbd.git] / src / clrunimap.c
index e75a3f9..feddc4e 100644 (file)
@@ -3,33 +3,30 @@
  *
  * Note: nowadays this kills kernel console output!
  */
+#include "config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
+#include <string.h>
 #include <linux/kd.h>
-#include <sys/ioctl.h>
-#include "nls.h"
+#include "kdmapop.h"
 
-extern int getfd(void);
+#include "libcommon.h"
 
-int
-main(int argc, char *argv[]) {
-       struct unimapinit advice;
+int main(int argc, char *argv[])
+{
        int fd;
+       char *console = NULL;
 
-       setlocale(LC_ALL, "");
-       bindtextdomain(PACKAGE, LOCALEDIR);
-       textdomain(PACKAGE);
+       set_progname(argv[0]);
+       setuplocale();
 
-       fd = getfd();
+       if (argc >= 3 && !strcmp(argv[1], "-C"))
+               console = argv[2];
 
-       advice.advised_hashsize = 0;
-       advice.advised_hashstep = 0;
-       advice.advised_hashlevel = 0;
+       if ((fd = getfd(console)) < 0)
+               kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
 
-       if(ioctl(fd, PIO_UNIMAPCLR, &advice)) {
-               perror("PIO_UNIMAPCLR");
-               exit(1);
-       }
+       return loadunimap(fd, NULL, NULL);
 }