static void settrivialscreenmap(void) { unsigned short i; if (getuniscrnmap(fd, obuf)) exit(1); have_obuf = 1; for (i = 0; i < E_TABSZ; i++) nbuf[i] = i; if (loaduniscrnmap(fd, nbuf)) { kbd_error(EXIT_FAILURE, 0, _("cannot change translation table\n")); } }
void saveoldmap(int fd, char *omfil) { FILE *fp; char buf[E_TABSZ]; unsigned short ubuf[E_TABSZ]; int i, havemap, haveumap; if ((fp = fopen(omfil, "w")) == NULL) { perror(omfil); exit(1); } havemap = haveumap = 1; if (getscrnmap(fd,buf)) havemap = 0; if (getuniscrnmap(fd,ubuf)) haveumap = 0; if (havemap && haveumap) { for (i = 0; i < E_TABSZ; i++) { if ((ubuf[i] & ~0xff) != 0xf000) { havemap = 0; break; } } } if (havemap) { if (fwrite(buf,sizeof(buf),1,fp) != 1) { fprintf(stderr, _("Error writing map to file\n")); exit(1); } } else if (haveumap) { if (fwrite(ubuf,sizeof(ubuf),1,fp) != 1) { fprintf(stderr, _("Error writing map to file\n")); exit(1); } } else { fprintf(stderr, _("Cannot read console map\n")); exit(1); } fclose(fp); if (verbose) printf(_("Saved screen map in `%s'\n"), omfil); }