clang-format in src/printer/

This commit is contained in:
Jasmine Iwanek
2022-09-18 17:17:25 -04:00
parent 97a7459fd4
commit d4c4ef6a5d
5 changed files with 2276 additions and 2335 deletions

View File

@@ -60,209 +60,222 @@
#include <86box/png_struct.h> #include <86box/png_struct.h>
#ifdef _WIN32 #ifdef _WIN32
# define PATH_PNG_DLL "libpng16-16.dll" # define PATH_PNG_DLL "libpng16-16.dll"
#elif defined __APPLE__ #elif defined __APPLE__
# define PATH_PNG_DLL "libpng16.dylib" # define PATH_PNG_DLL "libpng16.dylib"
#else #else
# define PATH_PNG_DLL "libpng16.so" # define PATH_PNG_DLL "libpng16.so"
#endif #endif
#ifndef PNG_Z_DEFAULT_STRATEGY #ifndef PNG_Z_DEFAULT_STRATEGY
#define PNG_Z_DEFAULT_STRATEGY 1 # define PNG_Z_DEFAULT_STRATEGY 1
#endif #endif
# define PNGFUNC(x) png_ ## x #define PNGFUNC(x) png_##x
#ifdef ENABLE_ESCP_LOG #ifdef ENABLE_ESCP_LOG
int png_do_log = ENABLE_ESCP_LOG; int png_do_log = ENABLE_ESCP_LOG;
static void static void
png_log(const char *fmt, ...) png_log(const char *fmt, ...)
{ {
va_list ap; va_list ap;
if (escp_do_log) { if (escp_do_log) {
va_start(ap, fmt); va_start(ap, fmt);
pclog_ex(fmt, ap); pclog_ex(fmt, ap);
va_end(ap); va_end(ap);
} }
} }
#else #else
#define png_log(fmt, ...) # define png_log(fmt, ...)
#endif #endif
static void static void
error_handler(png_structp arg, const char *str) error_handler(png_structp arg, const char *str)
{ {
png_log("PNG: stream 0x%08lx error '%s'\n", arg, str); png_log("PNG: stream 0x%08lx error '%s'\n", arg, str);
} }
static void static void
warning_handler(png_structp arg, const char *str) warning_handler(png_structp arg, const char *str)
{ {
png_log("PNG: stream 0x%08lx warning '%s'\n", arg, str); png_log("PNG: stream 0x%08lx warning '%s'\n", arg, str);
} }
/* Write the given image as an 8-bit GrayScale PNG image file. */ /* Write the given image as an 8-bit GrayScale PNG image file. */
int int
png_write_gray(char *fn, int inv, uint8_t *pix, int16_t w, int16_t h) png_write_gray(char *fn, int inv, uint8_t *pix, int16_t w, int16_t h)
{ {
png_structp png = NULL; png_structp png = NULL;
png_infop info = NULL; png_infop info = NULL;
png_bytep row; png_bytep row;
int16_t x, y; int16_t x, y;
FILE *fp; FILE *fp;
/* Create the image file. */ /* Create the image file. */
fp = plat_fopen(fn, "wb"); fp = plat_fopen(fn, "wb");
if (fp == NULL) { if (fp == NULL) {
/* Yes, this looks weird. */ /* Yes, this looks weird. */
if (fp == NULL) if (fp == NULL)
png_log("PNG: file %s could not be opened for writing!\n", fn); png_log("PNG: file %s could not be opened for writing!\n", fn);
else else
error: error:
png_log("PNG: fatal error, bailing out, error = %i\n", errno); png_log("PNG: fatal error, bailing out, error = %i\n", errno);
if (png != NULL) if (png != NULL)
PNGFUNC(destroy_write_struct)(&png, &info); PNGFUNC(destroy_write_struct)
if (fp != NULL) (&png, &info);
(void)fclose(fp); if (fp != NULL)
return(0); (void) fclose(fp);
return (0);
} }
/* Initialize PNG stuff. */ /* Initialize PNG stuff. */
png = PNGFUNC(create_write_struct)(PNG_LIBPNG_VER_STRING, NULL, png = PNGFUNC(create_write_struct)(PNG_LIBPNG_VER_STRING, NULL,
error_handler, warning_handler); error_handler, warning_handler);
if (png == NULL) { if (png == NULL) {
png_log("PNG: create_write_struct failed!\n"); png_log("PNG: create_write_struct failed!\n");
goto error; goto error;
} }
info = PNGFUNC(create_info_struct)(png); info = PNGFUNC(create_info_struct)(png);
if (info == NULL) { if (info == NULL) {
png_log("PNG: create_info_struct failed!\n"); png_log("PNG: create_info_struct failed!\n");
goto error; goto error;
} }
PNGFUNC(init_io)
(png, fp);
PNGFUNC(init_io)(png, fp); PNGFUNC(set_IHDR)
(png, info, w, h, 8, PNG_COLOR_TYPE_GRAY,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
PNGFUNC(set_IHDR)(png, info, w, h, 8, PNG_COLOR_TYPE_GRAY, PNGFUNC(write_info)
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, (png, info);
PNG_FILTER_TYPE_DEFAULT);
PNGFUNC(write_info)(png, info);
/* Create a buffer for one scanline of pixels. */ /* Create a buffer for one scanline of pixels. */
row = (png_bytep)malloc(PNGFUNC(get_rowbytes)(png, info)); row = (png_bytep) malloc(PNGFUNC(get_rowbytes)(png, info));
/* Process all scanlines in the image. */ /* Process all scanlines in the image. */
for (y = 0; y < h; y++) { for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) { for (x = 0; x < w; x++) {
/* Copy the pixel data. */ /* Copy the pixel data. */
if (inv) if (inv)
row[x] = 255 - pix[(y * w) + x]; row[x] = 255 - pix[(y * w) + x];
else else
row[x] = pix[(y * w) + x]; row[x] = pix[(y * w) + x];
} }
/* Write image to the file. */ /* Write image to the file. */
PNGFUNC(write_rows)(png, &row, 1); PNGFUNC(write_rows)
(png, &row, 1);
} }
/* No longer need the row buffer. */ /* No longer need the row buffer. */
free(row); free(row);
PNGFUNC(write_end)(png, NULL); PNGFUNC(write_end)
(png, NULL);
PNGFUNC(destroy_write_struct)(&png, &info); PNGFUNC(destroy_write_struct)
(&png, &info);
/* Clean up. */ /* Clean up. */
(void)fclose(fp); (void) fclose(fp);
return(1); return (1);
} }
/* Write the given BITMAP-format image as an 8-bit RGBA PNG image file. */ /* Write the given BITMAP-format image as an 8-bit RGBA PNG image file. */
void void
png_write_rgb(char *fn, uint8_t *pix, int16_t w, int16_t h, uint16_t pitch, PALETTE palcol) png_write_rgb(char *fn, uint8_t *pix, int16_t w, int16_t h, uint16_t pitch, PALETTE palcol)
{ {
png_structp png = NULL; png_structp png = NULL;
png_infop info = NULL; png_infop info = NULL;
png_bytep* rows; png_bytep *rows;
png_color palette[256]; png_color palette[256];
FILE *fp; FILE *fp;
int i; int i;
/* Create the image file. */ /* Create the image file. */
fp = plat_fopen(fn, "wb"); fp = plat_fopen(fn, "wb");
if (fp == NULL) { if (fp == NULL) {
png_log("PNG: File %s could not be opened for writing!\n", fn); png_log("PNG: File %s could not be opened for writing!\n", fn);
error: error:
if (png != NULL) if (png != NULL)
PNGFUNC(destroy_write_struct)(&png, &info); PNGFUNC(destroy_write_struct)
if (fp != NULL) (&png, &info);
(void)fclose(fp); if (fp != NULL)
return; (void) fclose(fp);
return;
} }
/* Initialize PNG stuff. */ /* Initialize PNG stuff. */
png = PNGFUNC(create_write_struct)(PNG_LIBPNG_VER_STRING, NULL, png = PNGFUNC(create_write_struct)(PNG_LIBPNG_VER_STRING, NULL,
error_handler, warning_handler); error_handler, warning_handler);
if (png == NULL) { if (png == NULL) {
png_log("PNG: create_write_struct failed!\n"); png_log("PNG: create_write_struct failed!\n");
goto error; goto error;
} }
info = PNGFUNC(create_info_struct)(png); info = PNGFUNC(create_info_struct)(png);
if (info == NULL) { if (info == NULL) {
png_log("PNG: create_info_struct failed!\n"); png_log("PNG: create_info_struct failed!\n");
goto error; goto error;
} }
/* Finalize the initing of png library */ /* Finalize the initing of png library */
PNGFUNC(init_io)(png, fp); PNGFUNC(init_io)
PNGFUNC(set_compression_level)(png, 9); (png, fp);
PNGFUNC(set_compression_level)
(png, 9);
/* set other zlib parameters */ /* set other zlib parameters */
PNGFUNC(set_compression_mem_level)(png, 8); PNGFUNC(set_compression_mem_level)
PNGFUNC(set_compression_strategy)(png, PNG_Z_DEFAULT_STRATEGY); (png, 8);
PNGFUNC(set_compression_window_bits)(png, 15); PNGFUNC(set_compression_strategy)
PNGFUNC(set_compression_method)(png, 8); (png, PNG_Z_DEFAULT_STRATEGY);
PNGFUNC(set_compression_buffer_size)(png, 8192); PNGFUNC(set_compression_window_bits)
(png, 15);
PNGFUNC(set_compression_method)
(png, 8);
PNGFUNC(set_compression_buffer_size)
(png, 8192);
PNGFUNC(set_IHDR)(png, info, w, h, 8, PNG_COLOR_TYPE_PALETTE, PNGFUNC(set_IHDR)
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, (png, info, w, h, 8, PNG_COLOR_TYPE_PALETTE,
PNG_FILTER_TYPE_DEFAULT); PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
palette[i].red = palcol[i].r; palette[i].red = palcol[i].r;
palette[i].green = palcol[i].g; palette[i].green = palcol[i].g;
palette[i].blue = palcol[i].b; palette[i].blue = palcol[i].b;
} }
PNGFUNC(set_PLTE)(png, info, palette, 256); PNGFUNC(set_PLTE)
(png, info, palette, 256);
/* Create a buffer for scanlines of pixels. */ /* Create a buffer for scanlines of pixels. */
rows = (png_bytep *)malloc(sizeof(png_bytep) * h); rows = (png_bytep *) malloc(sizeof(png_bytep) * h);
for (i = 0; i < h; i++) { for (i = 0; i < h; i++) {
/* Create a buffer for this scanline. */ /* Create a buffer for this scanline. */
rows[i] = (pix + (i * pitch)); rows[i] = (pix + (i * pitch));
} }
PNGFUNC(set_rows)(png, info, rows); PNGFUNC(set_rows)
(png, info, rows);
PNGFUNC(write_png)(png, info, 0, NULL); PNGFUNC(write_png)
(png, info, 0, NULL);
/* Clean up. */ /* Clean up. */
(void)fclose(fp); (void) fclose(fp);
PNGFUNC(destroy_write_struct)(&png, &info); PNGFUNC(destroy_write_struct)
(&png, &info);
/* No longer need the row buffers. */ /* No longer need the row buffers. */
free(rows); free(rows);

View File

@@ -57,503 +57,501 @@
#include <86box/plat.h> #include <86box/plat.h>
#include <86box/printer.h> #include <86box/printer.h>
static const uint16_t cp437Map[256] = { static const uint16_t cp437Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x00e0,0x00e5,0x00e7, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
0x00ea,0x00eb,0x00e8,0x00ef,0x00ee,0x00ec,0x00c4,0x00c5, 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
0x00c9,0x00e6,0x00c6,0x00f4,0x00f6,0x00f2,0x00fb,0x00f9, 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
0x00ff,0x00d6,0x00dc,0x00a2,0x00a3,0x00a5,0x20a7,0x0192, 0x00ff, 0x00d6, 0x00dc, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x00aa,0x00ba, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
0x00bf,0x2310,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb, 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x00b5,0x03c4, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248, 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp737Map[256] = { static const uint16_t cp737Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x0391,0x0392,0x0393,0x0394,0x0395,0x0396,0x0397,0x0398, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
0x0399,0x039a,0x039b,0x039c,0x039d,0x039e,0x039f,0x03a0, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, 0x03a0,
0x03a1,0x03a3,0x03a4,0x03a5,0x03a6,0x03a7,0x03a8,0x03a9, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9,
0x03b1,0x03b2,0x03b3,0x03b4,0x03b5,0x03b6,0x03b7,0x03b8, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8,
0x03b9,0x03ba,0x03bb,0x03bc,0x03bd,0x03be,0x03bf,0x03c0, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0,
0x03c1,0x03c3,0x03c2,0x03c4,0x03c5,0x03c6,0x03c7,0x03c8, 0x03c1, 0x03c3, 0x03c2, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8,
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x03c9,0x03ac,0x03ad,0x03ae,0x03ca,0x03af,0x03cc,0x03cd, 0x03c9, 0x03ac, 0x03ad, 0x03ae, 0x03ca, 0x03af, 0x03cc, 0x03cd,
0x03cb,0x03ce,0x0386,0x0388,0x0389,0x038a,0x038c,0x038e, 0x03cb, 0x03ce, 0x0386, 0x0388, 0x0389, 0x038a, 0x038c, 0x038e,
0x038f,0x00b1,0x2265,0x2264,0x03aa,0x03ab,0x00f7,0x2248, 0x038f, 0x00b1, 0x2265, 0x2264, 0x03aa, 0x03ab, 0x00f7, 0x2248,
0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp775Map[256] = { static const uint16_t cp775Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x0106,0x00fc,0x00e9,0x0101,0x00e4,0x0123,0x00e5,0x0107, 0x0106, 0x00fc, 0x00e9, 0x0101, 0x00e4, 0x0123, 0x00e5, 0x0107,
0x0142,0x0113,0x0156,0x0157,0x012b,0x0179,0x00c4,0x00c5, 0x0142, 0x0113, 0x0156, 0x0157, 0x012b, 0x0179, 0x00c4, 0x00c5,
0x00c9,0x00e6,0x00c6,0x014d,0x00f6,0x0122,0x00a2,0x015a, 0x00c9, 0x00e6, 0x00c6, 0x014d, 0x00f6, 0x0122, 0x00a2, 0x015a,
0x015b,0x00d6,0x00dc,0x00f8,0x00a3,0x00d8,0x00d7,0x00a4, 0x015b, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x00d7, 0x00a4,
0x0100,0x012a,0x00f3,0x017b,0x017c,0x017a,0x201d,0x00a6, 0x0100, 0x012a, 0x00f3, 0x017b, 0x017c, 0x017a, 0x201d, 0x00a6,
0x00a9,0x00ae,0x00ac,0x00bd,0x00bc,0x0141,0x00ab,0x00bb, 0x00a9, 0x00ae, 0x00ac, 0x00bd, 0x00bc, 0x0141, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x0104,0x010c,0x0118, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0104, 0x010c, 0x0118,
0x0116,0x2563,0x2551,0x2557,0x255d,0x012e,0x0160,0x2510, 0x0116, 0x2563, 0x2551, 0x2557, 0x255d, 0x012e, 0x0160, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x0172,0x016a, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x0172, 0x016a,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x017d, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x017d,
0x0105,0x010d,0x0119,0x0117,0x012f,0x0161,0x0173,0x016b, 0x0105, 0x010d, 0x0119, 0x0117, 0x012f, 0x0161, 0x0173, 0x016b,
0x017e,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x017e, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x00d3,0x00df,0x014c,0x0143,0x00f5,0x00d5,0x00b5,0x0144, 0x00d3, 0x00df, 0x014c, 0x0143, 0x00f5, 0x00d5, 0x00b5, 0x0144,
0x0136,0x0137,0x013b,0x013c,0x0146,0x0112,0x0145,0x2019, 0x0136, 0x0137, 0x013b, 0x013c, 0x0146, 0x0112, 0x0145, 0x2019,
0x00ad,0x00b1,0x201c,0x00be,0x00b6,0x00a7,0x00f7,0x201e, 0x00ad, 0x00b1, 0x201c, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x201e,
0x00b0,0x2219,0x00b7,0x00b9,0x00b3,0x00b2,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp850Map[256] = { static const uint16_t cp850Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x00e0,0x00e5,0x00e7, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
0x00ea,0x00eb,0x00e8,0x00ef,0x00ee,0x00ec,0x00c4,0x00c5, 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
0x00c9,0x00e6,0x00c6,0x00f4,0x00f6,0x00f2,0x00fb,0x00f9, 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
0x00ff,0x00d6,0x00dc,0x00f8,0x00a3,0x00d8,0x00d7,0x0192, 0x00ff, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x00d7, 0x0192,
0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x00aa,0x00ba, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
0x00bf,0x00ae,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb, 0x00bf, 0x00ae, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x00c1,0x00c2,0x00c0, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1, 0x00c2, 0x00c0,
0x00a9,0x2563,0x2551,0x2557,0x255d,0x00a2,0x00a5,0x2510, 0x00a9, 0x2563, 0x2551, 0x2557, 0x255d, 0x00a2, 0x00a5, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x00e3,0x00c3, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x00a4, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4,
0x00f0,0x00d0,0x00ca,0x00cb,0x00c8,0x0131,0x00cd,0x00ce, 0x00f0, 0x00d0, 0x00ca, 0x00cb, 0x00c8, 0x0131, 0x00cd, 0x00ce,
0x00cf,0x2518,0x250c,0x2588,0x2584,0x00a6,0x00cc,0x2580, 0x00cf, 0x2518, 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580,
0x00d3,0x00df,0x00d4,0x00d2,0x00f5,0x00d5,0x00b5,0x00fe, 0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5, 0x00b5, 0x00fe,
0x00de,0x00da,0x00db,0x00d9,0x00fd,0x00dd,0x00af,0x00b4, 0x00de, 0x00da, 0x00db, 0x00d9, 0x00fd, 0x00dd, 0x00af, 0x00b4,
0x00ad,0x00b1,0x2017,0x00be,0x00b6,0x00a7,0x00f7,0x00b8, 0x00ad, 0x00b1, 0x2017, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x00b8,
0x00b0,0x00a8,0x00b7,0x00b9,0x00b3,0x00b2,0x25a0,0x00a0 0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp852Map[256] = { static const uint16_t cp852Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x016f,0x0107,0x00e7, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x016f, 0x0107, 0x00e7,
0x0142,0x00eb,0x0150,0x0151,0x00ee,0x0179,0x00c4,0x0106, 0x0142, 0x00eb, 0x0150, 0x0151, 0x00ee, 0x0179, 0x00c4, 0x0106,
0x00c9,0x0139,0x013a,0x00f4,0x00f6,0x013d,0x013e,0x015a, 0x00c9, 0x0139, 0x013a, 0x00f4, 0x00f6, 0x013d, 0x013e, 0x015a,
0x015b,0x00d6,0x00dc,0x0164,0x0165,0x0141,0x00d7,0x010d, 0x015b, 0x00d6, 0x00dc, 0x0164, 0x0165, 0x0141, 0x00d7, 0x010d,
0x00e1,0x00ed,0x00f3,0x00fa,0x0104,0x0105,0x017d,0x017e, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x0104, 0x0105, 0x017d, 0x017e,
0x0118,0x0119,0x00ac,0x017a,0x010c,0x015f,0x00ab,0x00bb, 0x0118, 0x0119, 0x00ac, 0x017a, 0x010c, 0x015f, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x00c1,0x00c2,0x011a, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1, 0x00c2, 0x011a,
0x015e,0x2563,0x2551,0x2557,0x255d,0x017b,0x017c,0x2510, 0x015e, 0x2563, 0x2551, 0x2557, 0x255d, 0x017b, 0x017c, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x0102,0x0103, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x0102, 0x0103,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x00a4, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4,
0x0111,0x0110,0x010e,0x00cb,0x010f,0x0147,0x00cd,0x00ce, 0x0111, 0x0110, 0x010e, 0x00cb, 0x010f, 0x0147, 0x00cd, 0x00ce,
0x011b,0x2518,0x250c,0x2588,0x2584,0x0162,0x016e,0x2580, 0x011b, 0x2518, 0x250c, 0x2588, 0x2584, 0x0162, 0x016e, 0x2580,
0x00d3,0x00df,0x00d4,0x0143,0x0144,0x0148,0x0160,0x0161, 0x00d3, 0x00df, 0x00d4, 0x0143, 0x0144, 0x0148, 0x0160, 0x0161,
0x0154,0x00da,0x0155,0x0170,0x00fd,0x00dd,0x0163,0x00b4, 0x0154, 0x00da, 0x0155, 0x0170, 0x00fd, 0x00dd, 0x0163, 0x00b4,
0x00ad,0x02dd,0x02db,0x02c7,0x02d8,0x00a7,0x00f7,0x00b8, 0x00ad, 0x02dd, 0x02db, 0x02c7, 0x02d8, 0x00a7, 0x00f7, 0x00b8,
0x00b0,0x00a8,0x02d9,0x0171,0x0158,0x0159,0x25a0,0x00a0 0x00b0, 0x00a8, 0x02d9, 0x0171, 0x0158, 0x0159, 0x25a0, 0x00a0
}; };
static const uint16_t cp855Map[256] = { static const uint16_t cp855Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x0452,0x0402,0x0453,0x0403,0x0451,0x0401,0x0454,0x0404, 0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
0x0455,0x0405,0x0456,0x0406,0x0457,0x0407,0x0458,0x0408, 0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
0x0459,0x0409,0x045a,0x040a,0x045b,0x040b,0x045c,0x040c, 0x0459, 0x0409, 0x045a, 0x040a, 0x045b, 0x040b, 0x045c, 0x040c,
0x045e,0x040e,0x045f,0x040f,0x044e,0x042e,0x044a,0x042a, 0x045e, 0x040e, 0x045f, 0x040f, 0x044e, 0x042e, 0x044a, 0x042a,
0x0430,0x0410,0x0431,0x0411,0x0446,0x0426,0x0434,0x0414, 0x0430, 0x0410, 0x0431, 0x0411, 0x0446, 0x0426, 0x0434, 0x0414,
0x0435,0x0415,0x0444,0x0424,0x0433,0x0413,0x00ab,0x00bb, 0x0435, 0x0415, 0x0444, 0x0424, 0x0433, 0x0413, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x0445,0x0425,0x0438, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x0445, 0x0425, 0x0438,
0x0418,0x2563,0x2551,0x2557,0x255d,0x0439,0x0419,0x2510, 0x0418, 0x2563, 0x2551, 0x2557, 0x255d, 0x0439, 0x0419, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x043a,0x041a, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x043a, 0x041a,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x00a4, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4,
0x043b,0x041b,0x043c,0x041c,0x043d,0x041d,0x043e,0x041e, 0x043b, 0x041b, 0x043c, 0x041c, 0x043d, 0x041d, 0x043e, 0x041e,
0x043f,0x2518,0x250c,0x2588,0x2584,0x041f,0x044f,0x2580, 0x043f, 0x2518, 0x250c, 0x2588, 0x2584, 0x041f, 0x044f, 0x2580,
0x042f,0x0440,0x0420,0x0441,0x0421,0x0442,0x0422,0x0443, 0x042f, 0x0440, 0x0420, 0x0441, 0x0421, 0x0442, 0x0422, 0x0443,
0x0423,0x0436,0x0416,0x0432,0x0412,0x044c,0x042c,0x2116, 0x0423, 0x0436, 0x0416, 0x0432, 0x0412, 0x044c, 0x042c, 0x2116,
0x00ad,0x044b,0x042b,0x0437,0x0417,0x0448,0x0428,0x044d, 0x00ad, 0x044b, 0x042b, 0x0437, 0x0417, 0x0448, 0x0428, 0x044d,
0x042d,0x0449,0x0429,0x0447,0x0427,0x00a7,0x25a0,0x00a0 0x042d, 0x0449, 0x0429, 0x0447, 0x0427, 0x00a7, 0x25a0, 0x00a0
}; };
static const uint16_t cp857Map[256] = { static const uint16_t cp857Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x00e0,0x00e5,0x00e7, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
0x00ea,0x00eb,0x00e8,0x00ef,0x00ee,0x0131,0x00c4,0x00c5, 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x0131, 0x00c4, 0x00c5,
0x00c9,0x00e6,0x00c6,0x00f4,0x00f6,0x00f2,0x00fb,0x00f9, 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
0x0130,0x00d6,0x00dc,0x00f8,0x00a3,0x00d8,0x015e,0x015f, 0x0130, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x015e, 0x015f,
0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x011e,0x011f, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x011e, 0x011f,
0x00bf,0x00ae,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb, 0x00bf, 0x00ae, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x00c1,0x00c2,0x00c0, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1, 0x00c2, 0x00c0,
0x00a9,0x2563,0x2551,0x2557,0x255d,0x00a2,0x00a5,0x2510, 0x00a9, 0x2563, 0x2551, 0x2557, 0x255d, 0x00a2, 0x00a5, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x00e3,0x00c3, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x00a4, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4,
0x00ba,0x00aa,0x00ca,0x00cb,0x00c8,0x0000,0x00cd,0x00ce, 0x00ba, 0x00aa, 0x00ca, 0x00cb, 0x00c8, 0x0000, 0x00cd, 0x00ce,
0x00cf,0x2518,0x250c,0x2588,0x2584,0x00a6,0x00cc,0x2580, 0x00cf, 0x2518, 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580,
0x00d3,0x00df,0x00d4,0x00d2,0x00f5,0x00d5,0x00b5,0x0000, 0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5, 0x00b5, 0x0000,
0x00d7,0x00da,0x00db,0x00d9,0x00ec,0x00ff,0x00af,0x00b4, 0x00d7, 0x00da, 0x00db, 0x00d9, 0x00ec, 0x00ff, 0x00af, 0x00b4,
0x00ad,0x00b1,0x0000,0x00be,0x00b6,0x00a7,0x00f7,0x00b8, 0x00ad, 0x00b1, 0x0000, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x00b8,
0x00b0,0x00a8,0x00b7,0x00b9,0x00b3,0x00b2,0x25a0,0x00a0 0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp860Map[256] = { static const uint16_t cp860Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00c7,0x00fc,0x00e9,0x00e2,0x00e3,0x00e0,0x00c1,0x00e7, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e3, 0x00e0, 0x00c1, 0x00e7,
0x00ea,0x00ca,0x00e8,0x00cd,0x00d4,0x00ec,0x00c3,0x00c2, 0x00ea, 0x00ca, 0x00e8, 0x00cd, 0x00d4, 0x00ec, 0x00c3, 0x00c2,
0x00c9,0x00c0,0x00c8,0x00f4,0x00f5,0x00f2,0x00da,0x00f9, 0x00c9, 0x00c0, 0x00c8, 0x00f4, 0x00f5, 0x00f2, 0x00da, 0x00f9,
0x00cc,0x00d5,0x00dc,0x00a2,0x00a3,0x00d9,0x20a7,0x00d3, 0x00cc, 0x00d5, 0x00dc, 0x00a2, 0x00a3, 0x00d9, 0x20a7, 0x00d3,
0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x00aa,0x00ba, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
0x00bf,0x00d2,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb, 0x00bf, 0x00d2, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x00b5,0x03c4, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248, 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp861Map[256] = { static const uint16_t cp861Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x00e0,0x00e5,0x00e7, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
0x00ea,0x00eb,0x00e8,0x00d0,0x00f0,0x00de,0x00c4,0x00c5, 0x00ea, 0x00eb, 0x00e8, 0x00d0, 0x00f0, 0x00de, 0x00c4, 0x00c5,
0x00c9,0x00e6,0x00c6,0x00f4,0x00f6,0x00fe,0x00fb,0x00dd, 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00fe, 0x00fb, 0x00dd,
0x00fd,0x00d6,0x00dc,0x00f8,0x00a3,0x00d8,0x20a7,0x0192, 0x00fd, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x20a7, 0x0192,
0x00e1,0x00ed,0x00f3,0x00fa,0x00c1,0x00cd,0x00d3,0x00da, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00c1, 0x00cd, 0x00d3, 0x00da,
0x00bf,0x2310,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb, 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x00b5,0x03c4, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248, 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp862Map[256] = { static const uint16_t cp862Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x05d0,0x05d1,0x05d2,0x05d3,0x05d4,0x05d5,0x05d6,0x05d7, 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
0x05d8,0x05d9,0x05da,0x05db,0x05dc,0x05dd,0x05de,0x05df, 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
0x05e0,0x05e1,0x05e2,0x05e3,0x05e4,0x05e5,0x05e6,0x05e7, 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
0x05e8,0x05e9,0x05ea,0x00a2,0x00a3,0x00a5,0x20a7,0x0192, 0x05e8, 0x05e9, 0x05ea, 0x00a2, 0x00a3, 0x00a5, 0x20a7, 0x0192,
0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x00aa,0x00ba, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
0x00bf,0x2310,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00bb, 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x00b5,0x03c4, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248, 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp863Map[256] = { static const uint16_t cp863Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00c7,0x00fc,0x00e9,0x00e2,0x00c2,0x00e0,0x00b6,0x00e7, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00c2, 0x00e0, 0x00b6, 0x00e7,
0x00ea,0x00eb,0x00e8,0x00ef,0x00ee,0x2017,0x00c0,0x00a7, 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x2017, 0x00c0, 0x00a7,
0x00c9,0x00c8,0x00ca,0x00f4,0x00cb,0x00cf,0x00fb,0x00f9, 0x00c9, 0x00c8, 0x00ca, 0x00f4, 0x00cb, 0x00cf, 0x00fb, 0x00f9,
0x00a4,0x00d4,0x00dc,0x00a2,0x00a3,0x00d9,0x00db,0x0192, 0x00a4, 0x00d4, 0x00dc, 0x00a2, 0x00a3, 0x00d9, 0x00db, 0x0192,
0x00a6,0x00b4,0x00f3,0x00fa,0x00a8,0x00b8,0x00b3,0x00af, 0x00a6, 0x00b4, 0x00f3, 0x00fa, 0x00a8, 0x00b8, 0x00b3, 0x00af,
0x00ce,0x2310,0x00ac,0x00bd,0x00bc,0x00be,0x00ab,0x00bb, 0x00ce, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00be, 0x00ab, 0x00bb,
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x00b5,0x03c4, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248, 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp864Map[256] = { static const uint16_t cp864Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x066a,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x066a, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00b0,0x00b7,0x2219,0x221a,0x2592,0x2500,0x2502,0x253c, 0x00b0, 0x00b7, 0x2219, 0x221a, 0x2592, 0x2500, 0x2502, 0x253c,
0x2524,0x252c,0x251c,0x2534,0x2510,0x250c,0x2514,0x2518, 0x2524, 0x252c, 0x251c, 0x2534, 0x2510, 0x250c, 0x2514, 0x2518,
0x03b2,0x221e,0x03c6,0x00b1,0x00bd,0x00bc,0x2248,0x00ab, 0x03b2, 0x221e, 0x03c6, 0x00b1, 0x00bd, 0x00bc, 0x2248, 0x00ab,
0x00bb,0xfef7,0xfef8,0x0000,0x0000,0xfefb,0xfefc,0x0000, 0x00bb, 0xfef7, 0xfef8, 0x0000, 0x0000, 0xfefb, 0xfefc, 0x0000,
0x00a0,0x00ad,0xfe82,0x00a3,0x00a4,0xfe84,0x0000,0x0000, 0x00a0, 0x00ad, 0xfe82, 0x00a3, 0x00a4, 0xfe84, 0x0000, 0x0000,
0xfe8e,0xfe8f,0xfe95,0xfe99,0x060c,0xfe9d,0xfea1,0xfea5, 0xfe8e, 0xfe8f, 0xfe95, 0xfe99, 0x060c, 0xfe9d, 0xfea1, 0xfea5,
0x0660,0x0661,0x0662,0x0663,0x0664,0x0665,0x0666,0x0667, 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667,
0x0668,0x0669,0xfed1,0x061b,0xfeb1,0xfeb5,0xfeb9,0x061f, 0x0668, 0x0669, 0xfed1, 0x061b, 0xfeb1, 0xfeb5, 0xfeb9, 0x061f,
0x00a2,0xfe80,0xfe81,0xfe83,0xfe85,0xfeca,0xfe8b,0xfe8d, 0x00a2, 0xfe80, 0xfe81, 0xfe83, 0xfe85, 0xfeca, 0xfe8b, 0xfe8d,
0xfe91,0xfe93,0xfe97,0xfe9b,0xfe9f,0xfea3,0xfea7,0xfea9, 0xfe91, 0xfe93, 0xfe97, 0xfe9b, 0xfe9f, 0xfea3, 0xfea7, 0xfea9,
0xfeab,0xfead,0xfeaf,0xfeb3,0xfeb7,0xfebb,0xfebf,0xfec1, 0xfeab, 0xfead, 0xfeaf, 0xfeb3, 0xfeb7, 0xfebb, 0xfebf, 0xfec1,
0xfec5,0xfecb,0xfecf,0x00a6,0x00ac,0x00f7,0x00d7,0xfec9, 0xfec5, 0xfecb, 0xfecf, 0x00a6, 0x00ac, 0x00f7, 0x00d7, 0xfec9,
0x0640,0xfed3,0xfed7,0xfedb,0xfedf,0xfee3,0xfee7,0xfeeb, 0x0640, 0xfed3, 0xfed7, 0xfedb, 0xfedf, 0xfee3, 0xfee7, 0xfeeb,
0xfeed,0xfeef,0xfef3,0xfebd,0xfecc,0xfece,0xfecd,0xfee1, 0xfeed, 0xfeef, 0xfef3, 0xfebd, 0xfecc, 0xfece, 0xfecd, 0xfee1,
0xfe7d,0x0651,0xfee5,0xfee9,0xfeec,0xfef0,0xfef2,0xfed0, 0xfe7d, 0x0651, 0xfee5, 0xfee9, 0xfeec, 0xfef0, 0xfef2, 0xfed0,
0xfed5,0xfef5,0xfef6,0xfedd,0xfed9,0xfef1,0x25a0,0x00a0 0xfed5, 0xfef5, 0xfef6, 0xfedd, 0xfed9, 0xfef1, 0x25a0, 0x00a0
}; };
static const uint16_t cp865Map[256] = { static const uint16_t cp865Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x00c7,0x00fc,0x00e9,0x00e2,0x00e4,0x00e0,0x00e5,0x00e7, 0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
0x00ea,0x00eb,0x00e8,0x00ef,0x00ee,0x00ec,0x00c4,0x00c5, 0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
0x00c9,0x00e6,0x00c6,0x00f4,0x00f6,0x00f2,0x00fb,0x00f9, 0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
0x00ff,0x00d6,0x00dc,0x00f8,0x00a3,0x00d8,0x20a7,0x0192, 0x00ff, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x20a7, 0x0192,
0x00e1,0x00ed,0x00f3,0x00fa,0x00f1,0x00d1,0x00aa,0x00ba, 0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
0x00bf,0x2310,0x00ac,0x00bd,0x00bc,0x00a1,0x00ab,0x00a4, 0x00bf, 0x2310, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00a4,
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x03b1,0x00df,0x0393,0x03c0,0x03a3,0x03c3,0x00b5,0x03c4, 0x03b1, 0x00df, 0x0393, 0x03c0, 0x03a3, 0x03c3, 0x00b5, 0x03c4,
0x03a6,0x0398,0x03a9,0x03b4,0x221e,0x03c6,0x03b5,0x2229, 0x03a6, 0x0398, 0x03a9, 0x03b4, 0x221e, 0x03c6, 0x03b5, 0x2229,
0x2261,0x00b1,0x2265,0x2264,0x2320,0x2321,0x00f7,0x2248, 0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
0x00b0,0x2219,0x00b7,0x221a,0x207f,0x00b2,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
}; };
static const uint16_t cp866Map[256] = { static const uint16_t cp866Map[256] = {
0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
0x0030,0x0031,0x0032,0x0033,0x0034,0x0035,0x0036,0x0037, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0x0038,0x0039,0x003a,0x003b,0x003c,0x003d,0x003e,0x003f, 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f,
0x0040,0x0041,0x0042,0x0043,0x0044,0x0045,0x0046,0x0047, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0048,0x0049,0x004a,0x004b,0x004c,0x004d,0x004e,0x004f, 0x0048, 0x0049, 0x004a, 0x004b, 0x004c, 0x004d, 0x004e, 0x004f,
0x0050,0x0051,0x0052,0x0053,0x0054,0x0055,0x0056,0x0057, 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
0x0058,0x0059,0x005a,0x005b,0x005c,0x005d,0x005e,0x005f, 0x0058, 0x0059, 0x005a, 0x005b, 0x005c, 0x005d, 0x005e, 0x005f,
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067, 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
0x0068,0x0069,0x006a,0x006b,0x006c,0x006d,0x006e,0x006f, 0x0068, 0x0069, 0x006a, 0x006b, 0x006c, 0x006d, 0x006e, 0x006f,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
0x0078,0x0079,0x007a,0x007b,0x007c,0x007d,0x007e,0x007f, 0x0078, 0x0079, 0x007a, 0x007b, 0x007c, 0x007d, 0x007e, 0x007f,
0x0410,0x0411,0x0412,0x0413,0x0414,0x0415,0x0416,0x0417, 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
0x0418,0x0419,0x041a,0x041b,0x041c,0x041d,0x041e,0x041f, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
0x0420,0x0421,0x0422,0x0423,0x0424,0x0425,0x0426,0x0427, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
0x0428,0x0429,0x042a,0x042b,0x042c,0x042d,0x042e,0x042f, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
0x0430,0x0431,0x0432,0x0433,0x0434,0x0435,0x0436,0x0437, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
0x0438,0x0439,0x043a,0x043b,0x043c,0x043d,0x043e,0x043f, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
0x2591,0x2592,0x2593,0x2502,0x2524,0x2561,0x2562,0x2556, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
0x2555,0x2563,0x2551,0x2557,0x255d,0x255c,0x255b,0x2510, 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
0x2514,0x2534,0x252c,0x251c,0x2500,0x253c,0x255e,0x255f, 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
0x255a,0x2554,0x2569,0x2566,0x2560,0x2550,0x256c,0x2567, 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
0x2568,0x2564,0x2565,0x2559,0x2558,0x2552,0x2553,0x256b, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
0x256a,0x2518,0x250c,0x2588,0x2584,0x258c,0x2590,0x2580, 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
0x0440,0x0441,0x0442,0x0443,0x0444,0x0445,0x0446,0x0447, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
0x0448,0x0449,0x044a,0x044b,0x044c,0x044d,0x044e,0x044f, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
0x0401,0x0451,0x0404,0x0454,0x0407,0x0457,0x040e,0x045e, 0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040e, 0x045e,
0x00b0,0x2219,0x00b7,0x221a,0x2116,0x00a4,0x25a0,0x00a0 0x00b0, 0x2219, 0x00b7, 0x221a, 0x2116, 0x00a4, 0x25a0, 0x00a0
}; };
static const struct { static const struct {
uint16_t code; uint16_t code;
const uint16_t *map; const uint16_t *map;
} maps[] = { } maps[] = {
// clang-format off // clang-format off
{ 437, cp437Map }, { 437, cp437Map },
{ 737, cp737Map }, { 737, cp737Map },
{ 775, cp775Map }, { 775, cp775Map },
@@ -569,27 +567,26 @@ static const struct {
{ 865, cp865Map }, { 865, cp865Map },
{ 866, cp866Map }, { 866, cp866Map },
{ -1, NULL } { -1, NULL }
// clang-format on // clang-format on
}; };
/* Select a ASCII->Unicode mapping by CP number */ /* Select a ASCII->Unicode mapping by CP number */
void void
select_codepage(uint16_t code, uint16_t *curmap) select_codepage(uint16_t code, uint16_t *curmap)
{ {
int i = 0; int i = 0;
const uint16_t *map_to_use; const uint16_t *map_to_use;
map_to_use = maps[0].map; map_to_use = maps[0].map;
while (maps[i].code != 0) { while (maps[i].code != 0) {
if (maps[i].code == code) { if (maps[i].code == code) {
map_to_use = maps[i].map; map_to_use = maps[i].map;
break; break;
} }
i++; i++;
} }
for (i = 0; i < 256; i++) for (i = 0; i < 256; i++)
curmap[i] = map_to_use[i]; curmap[i] = map_to_use[i];
} }

File diff suppressed because it is too large Load Diff

View File

@@ -33,75 +33,71 @@
#include <86box/ui.h> #include <86box/ui.h>
#include <86box/prt_devs.h> #include <86box/prt_devs.h>
#ifdef _WIN32 #ifdef _WIN32
# define GSDLLAPI __stdcall # define GSDLLAPI __stdcall
#else #else
# define GSDLLAPI # define GSDLLAPI
#endif #endif
#define GS_ARG_ENCODING_UTF8 1
#define GS_ARG_ENCODING_UTF8 1 #define gs_error_Quit -101
#define gs_error_Quit -101
#ifdef _WIN32 #ifdef _WIN32
#if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64)) # if (!(defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64))
# define PATH_GHOSTSCRIPT_DLL "gsdll32.dll" # define PATH_GHOSTSCRIPT_DLL "gsdll32.dll"
#else # else
# define PATH_GHOSTSCRIPT_DLL "gsdll64.dll" # define PATH_GHOSTSCRIPT_DLL "gsdll64.dll"
#endif # endif
#elif defined __APPLE__ #elif defined __APPLE__
#define PATH_GHOSTSCRIPT_DLL "libgs.dylib" # define PATH_GHOSTSCRIPT_DLL "libgs.dylib"
#else #else
#define PATH_GHOSTSCRIPT_DLL "libgs.so.9" # define PATH_GHOSTSCRIPT_DLL "libgs.so.9"
#endif #endif
#define POSTSCRIPT_BUFFER_LENGTH 65536 #define POSTSCRIPT_BUFFER_LENGTH 65536
typedef struct typedef struct
{ {
const char *name; const char *name;
void *lpt; void *lpt;
pc_timer_t pulse_timer; pc_timer_t pulse_timer;
pc_timer_t timeout_timer; pc_timer_t timeout_timer;
char data; char data;
bool ack; bool ack;
bool select; bool select;
bool busy; bool busy;
bool int_pending; bool int_pending;
bool error; bool error;
bool autofeed; bool autofeed;
uint8_t ctrl; uint8_t ctrl;
char printer_path[260]; char printer_path[260];
char filename[260]; char filename[260];
char buffer[POSTSCRIPT_BUFFER_LENGTH]; char buffer[POSTSCRIPT_BUFFER_LENGTH];
size_t buffer_pos; size_t buffer_pos;
} ps_t; } ps_t;
typedef struct gsapi_revision_s { typedef struct gsapi_revision_s {
const char *product; const char *product;
const char *copyright; const char *copyright;
long revision; long revision;
long revisiondate; long revisiondate;
} gsapi_revision_t; } gsapi_revision_t;
static int(GSDLLAPI *gsapi_revision)(gsapi_revision_t *pr, int len);
static int (GSDLLAPI *gsapi_revision)(gsapi_revision_t *pr, int len); static int(GSDLLAPI *gsapi_new_instance)(void **pinstance, void *caller_handle);
static int (GSDLLAPI *gsapi_new_instance)(void **pinstance, void *caller_handle); static void(GSDLLAPI *gsapi_delete_instance)(void *instance);
static void (GSDLLAPI *gsapi_delete_instance)(void *instance); static int(GSDLLAPI *gsapi_set_arg_encoding)(void *instance, int encoding);
static int (GSDLLAPI *gsapi_set_arg_encoding)(void *instance, int encoding); static int(GSDLLAPI *gsapi_init_with_args)(void *instance, int argc, char **argv);
static int (GSDLLAPI *gsapi_init_with_args)(void *instance, int argc, char **argv); static int(GSDLLAPI *gsapi_exit)(void *instance);
static int (GSDLLAPI *gsapi_exit)(void *instance);
static dllimp_t ghostscript_imports[] = { static dllimp_t ghostscript_imports[] = {
// clang-format off // clang-format off
{ "gsapi_revision", &gsapi_revision }, { "gsapi_revision", &gsapi_revision },
{ "gsapi_new_instance", &gsapi_new_instance }, { "gsapi_new_instance", &gsapi_new_instance },
{ "gsapi_delete_instance", &gsapi_delete_instance }, { "gsapi_delete_instance", &gsapi_delete_instance },
@@ -109,48 +105,45 @@ static dllimp_t ghostscript_imports[] = {
{ "gsapi_init_with_args", &gsapi_init_with_args }, { "gsapi_init_with_args", &gsapi_init_with_args },
{ "gsapi_exit", &gsapi_exit }, { "gsapi_exit", &gsapi_exit },
{ NULL, NULL } { NULL, NULL }
// clang-format on // clang-format on
}; };
static void *ghostscript_handle = NULL; static void *ghostscript_handle = NULL;
static void static void
reset_ps(ps_t *dev) reset_ps(ps_t *dev)
{ {
if (dev == NULL) if (dev == NULL)
return; return;
dev->ack = false; dev->ack = false;
dev->buffer[0] = 0; dev->buffer[0] = 0;
dev->buffer_pos = 0; dev->buffer_pos = 0;
timer_disable(&dev->pulse_timer); timer_disable(&dev->pulse_timer);
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static void static void
pulse_timer(void *priv) pulse_timer(void *priv)
{ {
ps_t *dev = (ps_t *) priv; ps_t *dev = (ps_t *) priv;
if (dev->ack) { if (dev->ack) {
dev->ack = 0; dev->ack = 0;
lpt_irq(dev->lpt, 1); lpt_irq(dev->lpt, 1);
} }
timer_disable(&dev->pulse_timer); timer_disable(&dev->pulse_timer);
} }
static int static int
convert_to_pdf(ps_t *dev) convert_to_pdf(ps_t *dev)
{ {
volatile int code; volatile int code;
void *instance = NULL; void *instance = NULL;
char input_fn[1024], output_fn[1024], *gsargv[9]; char input_fn[1024], output_fn[1024], *gsargv[9];
strcpy(input_fn, dev->printer_path); strcpy(input_fn, dev->printer_path);
path_slash(input_fn); path_slash(input_fn);
@@ -171,40 +164,39 @@ convert_to_pdf(ps_t *dev)
code = gsapi_new_instance(&instance, dev); code = gsapi_new_instance(&instance, dev);
if (code < 0) if (code < 0)
return code; return code;
code = gsapi_set_arg_encoding(instance, GS_ARG_ENCODING_UTF8); code = gsapi_set_arg_encoding(instance, GS_ARG_ENCODING_UTF8);
if (code == 0) if (code == 0)
code = gsapi_init_with_args(instance, 9, gsargv); code = gsapi_init_with_args(instance, 9, gsargv);
if (code == 0 || code == gs_error_Quit) if (code == 0 || code == gs_error_Quit)
code = gsapi_exit(instance); code = gsapi_exit(instance);
else else
gsapi_exit(instance); gsapi_exit(instance);
gsapi_delete_instance(instance); gsapi_delete_instance(instance);
if (code == 0) if (code == 0)
plat_remove(input_fn); plat_remove(input_fn);
else else
plat_remove(output_fn); plat_remove(output_fn);
return code; return code;
} }
static void static void
write_buffer(ps_t *dev, bool finish) write_buffer(ps_t *dev, bool finish)
{ {
char path[1024]; char path[1024];
FILE *fp; FILE *fp;
if (dev->buffer[0] == 0) if (dev->buffer[0] == 0)
return; return;
if (dev->filename[0] == 0) if (dev->filename[0] == 0)
plat_tempfile(dev->filename, NULL, ".ps"); plat_tempfile(dev->filename, NULL, ".ps");
strcpy(path, dev->printer_path); strcpy(path, dev->printer_path);
path_slash(path); path_slash(path);
@@ -212,7 +204,7 @@ write_buffer(ps_t *dev, bool finish)
fp = plat_fopen(path, "a"); fp = plat_fopen(path, "a");
if (fp == NULL) if (fp == NULL)
return; return;
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
@@ -220,18 +212,17 @@ write_buffer(ps_t *dev, bool finish)
fclose(fp); fclose(fp);
dev->buffer[0] = 0; dev->buffer[0] = 0;
dev->buffer_pos = 0; dev->buffer_pos = 0;
if (finish) { if (finish) {
if (ghostscript_handle != NULL) if (ghostscript_handle != NULL)
convert_to_pdf(dev); convert_to_pdf(dev);
dev->filename[0] = 0; dev->filename[0] = 0;
} }
} }
static void static void
timeout_timer(void *priv) timeout_timer(void *priv)
{ {
@@ -242,133 +233,128 @@ timeout_timer(void *priv)
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static void static void
ps_write_data(uint8_t val, void *p) ps_write_data(uint8_t val, void *p)
{ {
ps_t *dev = (ps_t *) p; ps_t *dev = (ps_t *) p;
if (dev == NULL) if (dev == NULL)
return; return;
dev->data = (char) val; dev->data = (char) val;
} }
static void static void
process_data(ps_t *dev) process_data(ps_t *dev)
{ {
/* Check for non-printable characters */ /* Check for non-printable characters */
if ((dev->data < 0x20) || (dev->data == 0x7f)) { if ((dev->data < 0x20) || (dev->data == 0x7f)) {
switch (dev->data) { switch (dev->data) {
/* The following characters are considered white-space /* The following characters are considered white-space
by the PostScript specification */ by the PostScript specification */
case '\t': case '\t':
case '\n': case '\n':
case '\f': case '\f':
case '\r': case '\r':
break; break;
/* Same with NUL, except we better change it to a space first */ /* Same with NUL, except we better change it to a space first */
case '\0': case '\0':
dev->data = ' '; dev->data = ' ';
break; break;
/* Ctrl+D (0x04) marks the end of the document */ /* Ctrl+D (0x04) marks the end of the document */
case '\4': case '\4':
write_buffer(dev, true); write_buffer(dev, true);
return; return;
/* Don't bother with the others */ /* Don't bother with the others */
default: default:
return; return;
} }
} }
/* Flush the buffer if we have run to its end */ /* Flush the buffer if we have run to its end */
if (dev->buffer_pos == POSTSCRIPT_BUFFER_LENGTH - 1) if (dev->buffer_pos == POSTSCRIPT_BUFFER_LENGTH - 1)
write_buffer(dev, false); write_buffer(dev, false);
dev->buffer[dev->buffer_pos++] = dev->data; dev->buffer[dev->buffer_pos++] = dev->data;
dev->buffer[dev->buffer_pos] = 0; dev->buffer[dev->buffer_pos] = 0;
} }
static void static void
ps_write_ctrl(uint8_t val, void *p) ps_write_ctrl(uint8_t val, void *p)
{ {
ps_t *dev = (ps_t *) p; ps_t *dev = (ps_t *) p;
if (dev == NULL) if (dev == NULL)
return; return;
dev->autofeed = val & 0x02 ? true : false; dev->autofeed = val & 0x02 ? true : false;
if (val & 0x08) if (val & 0x08)
dev->select = true; dev->select = true;
if ((val & 0x04) && !(dev->ctrl & 0x04)) { if ((val & 0x04) && !(dev->ctrl & 0x04)) {
/* Reset printer */ /* Reset printer */
dev->select = false; dev->select = false;
reset_ps(dev); reset_ps(dev);
} }
if (!(val & 0x01) && (dev->ctrl & 0x01)) { if (!(val & 0x01) && (dev->ctrl & 0x01)) {
process_data(dev); process_data(dev);
dev->ack = true; dev->ack = true;
timer_set_delay_u64(&dev->pulse_timer, ISACONST); timer_set_delay_u64(&dev->pulse_timer, ISACONST);
timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC); timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC);
} }
dev->ctrl = val; dev->ctrl = val;
} }
static uint8_t static uint8_t
ps_read_status(void *p) ps_read_status(void *p)
{ {
ps_t *dev = (ps_t *) p; ps_t *dev = (ps_t *) p;
uint8_t ret = 0x9f; uint8_t ret = 0x9f;
if (!dev->ack) if (!dev->ack)
ret |= 0x40; ret |= 0x40;
return(ret); return (ret);
} }
static void * static void *
ps_init(void *lpt) ps_init(void *lpt)
{ {
ps_t *dev; ps_t *dev;
gsapi_revision_t rev; gsapi_revision_t rev;
dev = (ps_t *) malloc(sizeof(ps_t)); dev = (ps_t *) malloc(sizeof(ps_t));
memset(dev, 0x00, sizeof(ps_t)); memset(dev, 0x00, sizeof(ps_t));
dev->ctrl = 0x04; dev->ctrl = 0x04;
dev->lpt = lpt; dev->lpt = lpt;
/* Try loading the DLL. */ /* Try loading the DLL. */
ghostscript_handle = dynld_module(PATH_GHOSTSCRIPT_DLL, ghostscript_imports); ghostscript_handle = dynld_module(PATH_GHOSTSCRIPT_DLL, ghostscript_imports);
if (ghostscript_handle == NULL) if (ghostscript_handle == NULL)
ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2114, (wchar_t *) IDS_2132); ui_msgbox_header(MBX_ERROR, (wchar_t *) IDS_2114, (wchar_t *) IDS_2132);
else { else {
if (gsapi_revision(&rev, sizeof(rev)) == 0) if (gsapi_revision(&rev, sizeof(rev)) == 0)
pclog("Loaded %s, rev %ld (%ld)\n", rev.product, rev.revision, rev.revisiondate); pclog("Loaded %s, rev %ld (%ld)\n", rev.product, rev.revision, rev.revisiondate);
else { else {
dynld_close(ghostscript_handle); dynld_close(ghostscript_handle);
ghostscript_handle = NULL; ghostscript_handle = NULL;
} }
} }
/* Cache print folder path. */ /* Cache print folder path. */
memset(dev->printer_path, 0x00, sizeof(dev->printer_path)); memset(dev->printer_path, 0x00, sizeof(dev->printer_path));
path_append_filename(dev->printer_path, usr_path, "printer"); path_append_filename(dev->printer_path, usr_path, "printer");
if (!plat_dir_check(dev->printer_path)) if (!plat_dir_check(dev->printer_path))
plat_dir_create(dev->printer_path); plat_dir_create(dev->printer_path);
path_slash(dev->printer_path); path_slash(dev->printer_path);
timer_add(&dev->pulse_timer, pulse_timer, dev, 0); timer_add(&dev->pulse_timer, pulse_timer, dev, 0);
@@ -376,38 +362,36 @@ ps_init(void *lpt)
reset_ps(dev); reset_ps(dev);
return(dev); return (dev);
} }
static void static void
ps_close(void *p) ps_close(void *p)
{ {
ps_t *dev = (ps_t *) p; ps_t *dev = (ps_t *) p;
if (dev == NULL) if (dev == NULL)
return; return;
if (dev->buffer[0] != 0) if (dev->buffer[0] != 0)
write_buffer(dev, true); write_buffer(dev, true);
if (ghostscript_handle != NULL) { if (ghostscript_handle != NULL) {
dynld_close(ghostscript_handle); dynld_close(ghostscript_handle);
ghostscript_handle = NULL; ghostscript_handle = NULL;
} }
free(dev); free(dev);
} }
const lpt_device_t lpt_prt_ps_device = { const lpt_device_t lpt_prt_ps_device = {
.name = "Generic PostScript Printer", .name = "Generic PostScript Printer",
.internal_name = "postscript", .internal_name = "postscript",
.init = ps_init, .init = ps_init,
.close = ps_close, .close = ps_close,
.write_data = ps_write_data, .write_data = ps_write_data,
.write_ctrl = ps_write_ctrl, .write_ctrl = ps_write_ctrl,
.read_data = NULL, .read_data = NULL,
.read_status = ps_read_status, .read_status = ps_read_status,
.read_ctrl = NULL .read_ctrl = NULL
}; };

View File

@@ -66,93 +66,88 @@
#include <86box/printer.h> #include <86box/printer.h>
#include <86box/prt_devs.h> #include <86box/prt_devs.h>
#define FULL_PAGE 1 /* set if no top/bot margins */
#define FULL_PAGE 1 /* set if no top/bot margins */
/* Default page values (for now.) */ /* Default page values (for now.) */
#define PAGE_WIDTH 8.5 /* standard U.S. Letter */ #define PAGE_WIDTH 8.5 /* standard U.S. Letter */
#define PAGE_HEIGHT 11 #define PAGE_HEIGHT 11
#define PAGE_LMARGIN 0.25 /* 0.25" left and right */ #define PAGE_LMARGIN 0.25 /* 0.25" left and right */
#define PAGE_RMARGIN 0.25 #define PAGE_RMARGIN 0.25
#if FULL_PAGE #if FULL_PAGE
# define PAGE_TMARGIN 0 # define PAGE_TMARGIN 0
# define PAGE_BMARGIN 0 # define PAGE_BMARGIN 0
#else #else
# define PAGE_TMARGIN 0.25 # define PAGE_TMARGIN 0.25
# define PAGE_BMARGIN 0.25 # define PAGE_BMARGIN 0.25
#endif #endif
#define PAGE_CPI 10.0 /* standard 10 cpi */ #define PAGE_CPI 10.0 /* standard 10 cpi */
#define PAGE_LPI 6.0 /* standard 6 lpi */ #define PAGE_LPI 6.0 /* standard 6 lpi */
typedef struct { typedef struct {
int8_t dirty; /* has the page been printed on? */ int8_t dirty; /* has the page been printed on? */
char pad; char pad;
uint8_t w; /* size //INFO */ uint8_t w; /* size //INFO */
uint8_t h; uint8_t h;
char *chars; /* character data */ char *chars; /* character data */
} psurface_t; } psurface_t;
typedef struct { typedef struct {
const char *name; const char *name;
void * lpt; void *lpt;
/* Output file name. */ /* Output file name. */
char filename[1024]; char filename[1024];
/* Printer timeout. */ /* Printer timeout. */
pc_timer_t pulse_timer; pc_timer_t pulse_timer;
pc_timer_t timeout_timer; pc_timer_t timeout_timer;
/* page data (TODO: make configurable) */ /* page data (TODO: make configurable) */
double page_width, /* all in inches */ double page_width, /* all in inches */
page_height, page_height,
left_margin, left_margin,
top_margin, top_margin,
right_margin, right_margin,
bot_margin; bot_margin;
/* internal page data */ /* internal page data */
psurface_t *page; psurface_t *page;
uint8_t max_chars, uint8_t max_chars,
max_lines; max_lines;
uint8_t curr_x, /* print head position (chars) */ uint8_t curr_x, /* print head position (chars) */
curr_y; curr_y;
/* font data */ /* font data */
double cpi, /* defined chars per inch */ double cpi, /* defined chars per inch */
lpi; /* defined lines per inch */ lpi; /* defined lines per inch */
/* handshake data */ /* handshake data */
uint8_t data; uint8_t data;
int8_t ack; int8_t ack;
int8_t select; int8_t select;
int8_t busy; int8_t busy;
int8_t int_pending; int8_t int_pending;
int8_t error; int8_t error;
int8_t autofeed; int8_t autofeed;
uint8_t ctrl; uint8_t ctrl;
} prnt_t; } prnt_t;
/* Dump the current page into a formatted file. */ /* Dump the current page into a formatted file. */
static void static void
dump_page(prnt_t *dev) dump_page(prnt_t *dev)
{ {
char path[1024]; char path[1024];
uint16_t x, y; uint16_t x, y;
uint8_t ch; uint8_t ch;
FILE *fp; FILE *fp;
/* Create the full path for this file. */ /* Create the full path for this file. */
memset(path, 0x00, sizeof(path)); memset(path, 0x00, sizeof(path));
path_append_filename(path, usr_path, "printer"); path_append_filename(path, usr_path, "printer");
if (! plat_dir_check(path)) if (!plat_dir_check(path))
plat_dir_create(path); plat_dir_create(path);
path_slash(path); path_slash(path);
strcat(path, dev->filename); strcat(path, dev->filename);
@@ -160,95 +155,91 @@ dump_page(prnt_t *dev)
/* Create the file. */ /* Create the file. */
fp = plat_fopen(path, "a"); fp = plat_fopen(path, "a");
if (fp == NULL) { if (fp == NULL) {
//ERRLOG("PRNT: unable to create print page '%s'\n", path); // ERRLOG("PRNT: unable to create print page '%s'\n", path);
return; return;
} }
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
/* If this is not a new file, add a formfeed first. */ /* If this is not a new file, add a formfeed first. */
if (ftell(fp) != 0) if (ftell(fp) != 0)
fputc('\014', fp); fputc('\014', fp);
for (y = 0; y < dev->curr_y; y++) { for (y = 0; y < dev->curr_y; y++) {
for (x = 0; x < dev->page->w; x++) { for (x = 0; x < dev->page->w; x++) {
ch = dev->page->chars[(y * dev->page->w) + x]; ch = dev->page->chars[(y * dev->page->w) + x];
if (ch == 0x00) { if (ch == 0x00) {
/* End of line marker. */ /* End of line marker. */
fputc('\n', fp); fputc('\n', fp);
break; break;
} else { } else {
fputc(ch, fp); fputc(ch, fp);
} }
} }
} }
/* All done, close the file. */ /* All done, close the file. */
fclose(fp); fclose(fp);
} }
static void static void
new_page(prnt_t *dev) new_page(prnt_t *dev)
{ {
/* Dump the current page if needed. */ /* Dump the current page if needed. */
if (dev->page->dirty) if (dev->page->dirty)
dump_page(dev); dump_page(dev);
/* Clear page. */ /* Clear page. */
memset(dev->page->chars, 0x00, dev->page->h * dev->page->w); memset(dev->page->chars, 0x00, dev->page->h * dev->page->w);
dev->curr_y = 0; dev->curr_y = 0;
dev->page->dirty = 0; dev->page->dirty = 0;
} }
static void static void
pulse_timer(void *priv) pulse_timer(void *priv)
{ {
prnt_t *dev = (prnt_t *) priv; prnt_t *dev = (prnt_t *) priv;
if (dev->ack) { if (dev->ack) {
dev->ack = 0; dev->ack = 0;
lpt_irq(dev->lpt, 1); lpt_irq(dev->lpt, 1);
} }
timer_disable(&dev->pulse_timer); timer_disable(&dev->pulse_timer);
} }
static void static void
timeout_timer(void *priv) timeout_timer(void *priv)
{ {
prnt_t *dev = (prnt_t *) priv; prnt_t *dev = (prnt_t *) priv;
if (dev->page->dirty) if (dev->page->dirty)
new_page(dev); new_page(dev);
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static void static void
reset_printer(prnt_t *dev) reset_printer(prnt_t *dev)
{ {
/* TODO: these three should be configurable */ /* TODO: these three should be configurable */
dev->page_width = PAGE_WIDTH; dev->page_width = PAGE_WIDTH;
dev->page_height = PAGE_HEIGHT; dev->page_height = PAGE_HEIGHT;
dev->left_margin = PAGE_LMARGIN; dev->left_margin = PAGE_LMARGIN;
dev->right_margin = PAGE_RMARGIN; dev->right_margin = PAGE_RMARGIN;
dev->top_margin = PAGE_TMARGIN; dev->top_margin = PAGE_TMARGIN;
dev->bot_margin = PAGE_BMARGIN; dev->bot_margin = PAGE_BMARGIN;
dev->cpi = PAGE_CPI; dev->cpi = PAGE_CPI;
dev->lpi = PAGE_LPI; dev->lpi = PAGE_LPI;
dev->ack = 0; dev->ack = 0;
/* Default page layout. */ /* Default page layout. */
dev->max_chars = (int) ((dev->page_width - dev->left_margin - dev->right_margin) * dev->cpi); dev->max_chars = (int) ((dev->page_width - dev->left_margin - dev->right_margin) * dev->cpi);
dev->max_lines = (int) ((dev->page_height -dev->top_margin - dev->bot_margin) * dev->lpi); dev->max_lines = (int) ((dev->page_height - dev->top_margin - dev->bot_margin) * dev->lpi);
dev->curr_x = dev->curr_y = 0; dev->curr_x = dev->curr_y = 0;
if (dev->page != NULL) if (dev->page != NULL)
dev->page->dirty = 0; dev->page->dirty = 0;
/* Create a file for this page. */ /* Create a file for this page. */
plat_tempfile(dev->filename, NULL, ".txt"); plat_tempfile(dev->filename, NULL, ".txt");
@@ -257,240 +248,235 @@ reset_printer(prnt_t *dev)
timer_disable(&dev->timeout_timer); timer_disable(&dev->timeout_timer);
} }
static int static int
process_char(prnt_t *dev, uint8_t ch) process_char(prnt_t *dev, uint8_t ch)
{ {
uint8_t i; uint8_t i;
switch (ch) { switch (ch) {
case 0x07: /* Beeper (BEL) */ case 0x07: /* Beeper (BEL) */
/* TODO: beep? */ /* TODO: beep? */
return 1; return 1;
case 0x08: /* Backspace (BS) */ case 0x08: /* Backspace (BS) */
if (dev->curr_x > 0) if (dev->curr_x > 0)
dev->curr_x--; dev->curr_x--;
return 1; return 1;
case 0x09: /* Tab horizontally (HT) */ case 0x09: /* Tab horizontally (HT) */
/* Find tab right to current pos. */ /* Find tab right to current pos. */
i = dev->curr_x; i = dev->curr_x;
dev->page->chars[(dev->curr_y * dev->page->w) + i++] = ' '; dev->page->chars[(dev->curr_y * dev->page->w) + i++] = ' ';
while ((i < dev->max_chars) && ((i % 8) != 0)) { while ((i < dev->max_chars) && ((i % 8) != 0)) {
dev->page->chars[(dev->curr_y * dev->page->w) + i] = ' '; dev->page->chars[(dev->curr_y * dev->page->w) + i] = ' ';
i++; i++;
} }
dev->curr_x = i; dev->curr_x = i;
return 1; return 1;
case 0x0b: /* Tab vertically (VT) */ case 0x0b: /* Tab vertically (VT) */
dev->curr_x = 0; dev->curr_x = 0;
return 1; return 1;
case 0x0c: /* Form feed (FF) */ case 0x0c: /* Form feed (FF) */
new_page(dev); new_page(dev);
return 1; return 1;
case 0x0d: /* Carriage Return (CR) */ case 0x0d: /* Carriage Return (CR) */
dev->curr_x = 0; dev->curr_x = 0;
if (! dev->autofeed) if (!dev->autofeed)
return 1; return 1;
/*FALLTHROUGH*/ /*FALLTHROUGH*/
case 0x0a: /* Line feed */ case 0x0a: /* Line feed */
dev->curr_x = 0; dev->curr_x = 0;
if (++dev->curr_y >= dev->max_lines) if (++dev->curr_y >= dev->max_lines)
new_page(dev); new_page(dev);
return 1; return 1;
case 0x0e: /* select wide printing (SO) */ case 0x0e: /* select wide printing (SO) */
/* Ignore. */ /* Ignore. */
return 1; return 1;
case 0x0f: /* select condensed printing (SI) */ case 0x0f: /* select condensed printing (SI) */
/* Ignore. */ /* Ignore. */
return 1; return 1;
case 0x11: /* select printer (DC1) */ case 0x11: /* select printer (DC1) */
/* Ignore. */ /* Ignore. */
return 0; return 0;
case 0x12: /* cancel condensed printing (DC2) */ case 0x12: /* cancel condensed printing (DC2) */
/* Ignore. */ /* Ignore. */
return 1; return 1;
case 0x13: /* deselect printer (DC3) */ case 0x13: /* deselect printer (DC3) */
/* Ignore. */ /* Ignore. */
return 1; return 1;
case 0x14: /* cancel double-width printing (one line) (DC4) */ case 0x14: /* cancel double-width printing (one line) (DC4) */
/* Ignore. */ /* Ignore. */
return 1; return 1;
case 0x18: /* cancel line (CAN) */ case 0x18: /* cancel line (CAN) */
/* Ignore. */ /* Ignore. */
return 1; return 1;
case 0x1b: /* ESC */ case 0x1b: /* ESC */
/* Ignore. */ /* Ignore. */
return 1; return 1;
default: default:
break; break;
} }
/* Just a printable character. */ /* Just a printable character. */
return(0); return (0);
} }
static void static void
handle_char(prnt_t *dev) handle_char(prnt_t *dev)
{ {
uint8_t ch = dev->data; uint8_t ch = dev->data;
if (dev->page == NULL) return; if (dev->page == NULL)
return;
if (process_char(dev, ch) == 1) { if (process_char(dev, ch) == 1) {
/* Command was processed. */ /* Command was processed. */
return; return;
} }
/* Store character in the page buffer. */ /* Store character in the page buffer. */
dev->page->chars[(dev->curr_y * dev->page->w) + dev->curr_x] = ch; dev->page->chars[(dev->curr_y * dev->page->w) + dev->curr_x] = ch;
dev->page->dirty = 1; dev->page->dirty = 1;
/* Update print head position. */ /* Update print head position. */
if (++dev->curr_x >= dev->max_chars) { if (++dev->curr_x >= dev->max_chars) {
dev->curr_x = 0; dev->curr_x = 0;
if (++dev->curr_y >= dev->max_lines) if (++dev->curr_y >= dev->max_lines)
new_page(dev); new_page(dev);
} }
} }
static void static void
write_data(uint8_t val, void *priv) write_data(uint8_t val, void *priv)
{ {
prnt_t *dev = (prnt_t *)priv; prnt_t *dev = (prnt_t *) priv;
if (dev == NULL) return; if (dev == NULL)
return;
dev->data = val; dev->data = val;
} }
static void static void
write_ctrl(uint8_t val, void *priv) write_ctrl(uint8_t val, void *priv)
{ {
prnt_t *dev = (prnt_t *)priv; prnt_t *dev = (prnt_t *) priv;
if (dev == NULL) return; if (dev == NULL)
return;
/* set autofeed value */ /* set autofeed value */
dev->autofeed = val & 0x02 ? 1 : 0; dev->autofeed = val & 0x02 ? 1 : 0;
if (val & 0x08) { /* SELECT */ if (val & 0x08) { /* SELECT */
/* select printer */ /* select printer */
dev->select = 1; dev->select = 1;
} }
if ((val & 0x04) && !(dev->ctrl & 0x04)) { if ((val & 0x04) && !(dev->ctrl & 0x04)) {
/* reset printer */ /* reset printer */
dev->select = 0; dev->select = 0;
reset_printer(dev); reset_printer(dev);
} }
if (!(val & 0x01) && (dev->ctrl & 0x01)) { /* STROBE */ if (!(val & 0x01) && (dev->ctrl & 0x01)) { /* STROBE */
/* Process incoming character. */ /* Process incoming character. */
handle_char(dev); handle_char(dev);
/* ACK it, will be read on next READ STATUS. */ /* ACK it, will be read on next READ STATUS. */
dev->ack = 1; dev->ack = 1;
timer_set_delay_u64(&dev->pulse_timer, ISACONST); timer_set_delay_u64(&dev->pulse_timer, ISACONST);
timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC); timer_set_delay_u64(&dev->timeout_timer, 5000000 * TIMER_USEC);
} }
dev->ctrl = val; dev->ctrl = val;
} }
static uint8_t static uint8_t
read_status(void *priv) read_status(void *priv)
{ {
prnt_t *dev = (prnt_t *)priv; prnt_t *dev = (prnt_t *) priv;
uint8_t ret = 0x1f; uint8_t ret = 0x1f;
ret |= 0x80; ret |= 0x80;
if (!dev->ack) if (!dev->ack)
ret |= 0x40; ret |= 0x40;
return(ret); return (ret);
} }
static void * static void *
prnt_init(void *lpt) prnt_init(void *lpt)
{ {
prnt_t *dev; prnt_t *dev;
/* Initialize a device instance. */ /* Initialize a device instance. */
dev = (prnt_t *)malloc(sizeof(prnt_t)); dev = (prnt_t *) malloc(sizeof(prnt_t));
memset(dev, 0x00, sizeof(prnt_t)); memset(dev, 0x00, sizeof(prnt_t));
dev->ctrl = 0x04; dev->ctrl = 0x04;
dev->lpt = lpt; dev->lpt = lpt;
/* Initialize parameters. */ /* Initialize parameters. */
reset_printer(dev); reset_printer(dev);
/* Create a page buffer. */ /* Create a page buffer. */
dev->page = (psurface_t *)malloc(sizeof(psurface_t)); dev->page = (psurface_t *) malloc(sizeof(psurface_t));
dev->page->w = dev->max_chars; dev->page->w = dev->max_chars;
dev->page->h = dev->max_lines; dev->page->h = dev->max_lines;
dev->page->chars = (char *)malloc(dev->page->w * dev->page->h); dev->page->chars = (char *) malloc(dev->page->w * dev->page->h);
memset(dev->page->chars, 0x00, dev->page->w * dev->page->h); memset(dev->page->chars, 0x00, dev->page->w * dev->page->h);
timer_add(&dev->pulse_timer, pulse_timer, dev, 0); timer_add(&dev->pulse_timer, pulse_timer, dev, 0);
timer_add(&dev->timeout_timer, timeout_timer, dev, 0); timer_add(&dev->timeout_timer, timeout_timer, dev, 0);
return(dev); return (dev);
} }
static void static void
prnt_close(void *priv) prnt_close(void *priv)
{ {
prnt_t *dev = (prnt_t *)priv; prnt_t *dev = (prnt_t *) priv;
if (dev == NULL) if (dev == NULL)
return; return;
if (dev->page) { if (dev->page) {
/* print last page if it contains data */ /* print last page if it contains data */
if (dev->page->dirty) if (dev->page->dirty)
dump_page(dev); dump_page(dev);
if (dev->page->chars != NULL) if (dev->page->chars != NULL)
free(dev->page->chars); free(dev->page->chars);
free(dev->page); free(dev->page);
} }
free(dev); free(dev);
} }
const lpt_device_t lpt_prt_text_device = { const lpt_device_t lpt_prt_text_device = {
.name = "Generic Text Printer", .name = "Generic Text Printer",
.internal_name = "text_prt", .internal_name = "text_prt",
.init = prnt_init, .init = prnt_init,
.close = prnt_close, .close = prnt_close,
.write_data = write_data, .write_data = write_data,
.write_ctrl = write_ctrl, .write_ctrl = write_ctrl,
.read_data = NULL, .read_data = NULL,
.read_status = read_status, .read_status = read_status,
.read_ctrl = NULL .read_ctrl = NULL
}; };