|
Packit Service |
50ad14 |
/* outpsfheader - auxiliary fn - not to be installed */
|
|
Packit Service |
50ad14 |
/* assumes a little-endian machine */
|
|
Packit Service |
50ad14 |
#include "config.h"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
#include <stdio.h>
|
|
Packit Service |
50ad14 |
#include <stdlib.h> /* exit */
|
|
Packit Service |
50ad14 |
#include "kbd.h"
|
|
Packit Service |
50ad14 |
#include "psf.h"
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
static void __attribute__((noreturn))
|
|
Packit Service |
50ad14 |
usage(void)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
fprintf(stderr, "call: outpsfheader psftype fontsize charsize hastable\n");
|
|
Packit Service |
50ad14 |
exit(1);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
int main(int argc, char **argv)
|
|
Packit Service |
50ad14 |
{
|
|
Packit Service |
50ad14 |
int psftype, fontsize, charsize, hastable;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (argc != 5)
|
|
Packit Service |
50ad14 |
usage();
|
|
Packit Service |
50ad14 |
psftype = atoi(argv[1]);
|
|
Packit Service |
50ad14 |
fontsize = atoi(argv[2]);
|
|
Packit Service |
50ad14 |
charsize = atoi(argv[3]);
|
|
Packit Service |
50ad14 |
hastable = atoi(argv[4]);
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (psftype == 1) {
|
|
Packit Service |
50ad14 |
struct psf1_header h1;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
if (fontsize != 256 && fontsize != 512)
|
|
Packit Service |
50ad14 |
usage();
|
|
Packit Service |
50ad14 |
h1.magic[0] = PSF1_MAGIC0;
|
|
Packit Service |
50ad14 |
h1.magic[1] = PSF1_MAGIC1;
|
|
Packit Service |
50ad14 |
h1.mode = (fontsize == 256) ? 0 : PSF1_MODE512;
|
|
Packit Service |
50ad14 |
if (hastable)
|
|
Packit Service |
50ad14 |
h1.mode |= PSF1_MODEHASTAB;
|
|
Packit Service |
50ad14 |
h1.charsize = charsize;
|
|
Packit Service |
50ad14 |
if (fwrite(&h1, sizeof(h1), 1, stdout) != 1) {
|
|
Packit Service |
50ad14 |
fprintf(stderr, "write error\n");
|
|
Packit Service |
50ad14 |
exit(1);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
} else if (psftype == 2) {
|
|
Packit Service |
50ad14 |
struct psf2_header h2;
|
|
Packit Service |
50ad14 |
|
|
Packit Service |
50ad14 |
h2.magic[0] = PSF2_MAGIC0;
|
|
Packit Service |
50ad14 |
h2.magic[1] = PSF2_MAGIC1;
|
|
Packit Service |
50ad14 |
h2.magic[2] = PSF2_MAGIC2;
|
|
Packit Service |
50ad14 |
h2.magic[3] = PSF2_MAGIC3;
|
|
Packit Service |
50ad14 |
h2.version = 0;
|
|
Packit Service |
50ad14 |
h2.headersize = sizeof(h2);
|
|
Packit Service |
50ad14 |
h2.flags = (hastable ? PSF2_HAS_UNICODE_TABLE : 0);
|
|
Packit Service |
50ad14 |
h2.length = fontsize;
|
|
Packit Service |
50ad14 |
h2.charsize = charsize;
|
|
Packit Service |
50ad14 |
h2.width = 8;
|
|
Packit Service |
50ad14 |
h2.height = charsize;
|
|
Packit Service |
50ad14 |
if (fwrite(&h2, sizeof(h2), 1, stdout) != 1) {
|
|
Packit Service |
50ad14 |
fprintf(stderr, "write error\n");
|
|
Packit Service |
50ad14 |
exit(1);
|
|
Packit Service |
50ad14 |
}
|
|
Packit Service |
50ad14 |
} else
|
|
Packit Service |
50ad14 |
usage();
|
|
Packit Service |
50ad14 |
return 0;
|
|
Packit Service |
50ad14 |
}
|