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); }
leave(int n) { if (have_obuf && loaduniscrnmap(fd, obuf)) { kbd_warning(0, _("failed to restore original translation table\n")); n = EXIT_FAILURE; } if (have_ounimap && loadunimap(fd, NULL, &ounimap)) { kbd_warning(0, _("failed to restore original unimap\n")); n = EXIT_FAILURE; } exit(n); }
int main(int argc, char *argv[]) { int fd; char *console = NULL; setlocale(LC_ALL, ""); bindtextdomain(PACKAGE_NAME, LOCALEDIR); textdomain(PACKAGE_NAME); if (argc >= 3 && !strcmp(argv[1], "-C")) console = argv[2]; fd = getfd(console); return loadunimap (fd, NULL, NULL); }
static void setnewunicodemap(int *list, int cnt) { unsigned short i; if (!nunimap.entry_ct) { nunimap.entry_ct = 512; nunimap.entries = (struct unipair *)xmalloc(nunimap.entry_ct * sizeof(struct unipair)); } for (i = 0; i < 512; i++) { nunimap.entries[i].fontpos = i; nunimap.entries[i].unicode = 0; } for (i = 0; i < cnt; i++) nunimap.entries[list[i]].unicode = (unsigned short) (BASE + i); if (loadunimap(fd, NULL, &nunimap)) leave(EXIT_FAILURE); }
void loadunicodemap(int fd, char *tblname) { FILE *mapf; char buffer[65536]; char *p; mapf = findfile(tblname, unidirpath, unisuffixes); if ( !mapf ) { perror(tblname); exit(EX_NOINPUT); } if (verbose) printf(_("Loading unicode map from file %s\n"), pathname); while ( fgets(buffer, sizeof(buffer), mapf) != NULL ) { if ( (p = strchr(buffer, '\n')) != NULL ) *p = '\0'; else fprintf(stderr, _("%s: %s: Warning: line too long\n"), progname, tblname); parseline(buffer, tblname); } fpclose(mapf); if (listct == 0 && !force) { fprintf(stderr, _("%s: not loading empty unimap\n" "(if you insist: use option -f to override)\n"), progname); } else { descr.entry_ct = listct; descr.entries = list; if (loadunimap (fd, NULL, &descr)) exit(1); listct = 0; } }