⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 escpdump.c

📁 Tool to dump Epson ESC/P print files to readable Text
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 * escpdump.c: Dump escp-P data as a readable Textfile
 */

#include <ctype.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>


#define	BS	'\b'		/* backspace */
#define	TAB	'\t'		/* tab */
#define	SPACE	' '		/* space */
#define	NL	'\n'		/* newline */
#define	CR	'\r'		/* carriage return */
#define	LF	'\n'		/* Line Feed */
#define	FF	'\f'		/* FormFeed */
#define	ESC	'\033'		/* escape */
#define	SI	'\017'		/* shift in to normal character set */
#define	SO	'\016'		/* shift out to alternate character set */
#define	VT	'\013'		/* vertical tab (aka reverse line feed) */
#define	HT	'\011'		/* vertical tab (aka reverse line feed) */
#define	DC2	0x12
#define	DC4	0x14
#define	BEL	0x07

typedef struct 
{
    int ctrl_len, data_len, special;
    unsigned char byte1;
    unsigned char byte2;
    unsigned char byte3;
    char *command;
    unsigned char escp2, escp, escp9pin;
    char *chapter;
} ESCP;

ESCP escp[] = {
    { 1, 0, 0, BEL, ' ',  ' ',     "Beeper",                                       1, 1, 1,  "C-163" },
    { 1, 0, 0, BS , ' ',  ' ',     "Backspace",                                    1, 1, 1,  "C-48 " },
    { 1, 0, 0, CR , ' ',  ' ',     "Carriage return",                              1, 1, 1,  "C-25 " },
    { 1, 0, 0, DC2, ' ',  ' ',     "Cancel condensed printing",                    1, 1, 1,  "C-138" },
    { 1, 0, 0, DC4, ' ',  ' ',     "Cancel double-width printing (one line)",      1, 1, 1,  "C-144" },
    { 1, 0, 0, FF , ' ',  ' ',     "Form feed",                                    1, 1, 1,  "C-29 " },
    { 1, 0, 0, HT , ' ',  ' ',     "Tab horizontally",                             1, 1, 1,  "C-43 " },
    { 1, 0, 0, LF , ' ',  ' ',     "Line feed",                                    1, 1, 1,  "C-27 " },
    { 1, 0, 0, SI , ' ',  ' ',     "Select condensed printing",                    1, 1, 1,  "C-134" },
    { 1, 0, 0, SO , ' ',  ' ',     "Select double-width printing (one line)",      1, 1, 1,  "C-140" },
    { 1, 0, 0, VT , ' ',  ' ',     "Tab vertically",                               1, 1, 1,  "C-45 " },
    { 2, 0, 0, ESC, '@',  ' ',     "Initialize printer",                           1, 1, 1,  "C-198" },
    { 2, 0, 0, ESC, '0',  ' ',     "Select 1/8-inch line spacing",                 1, 1, 1,  "C-51 " },
    { 2, 0, 0, ESC, '1',  ' ',     "Select 7/72-inch line spacing",                0, 0, 1,  "C-60 " },
    { 2, 0, 0, ESC, '2',  ' ',     "Select 1/6-inch line spacing",                 1, 1, 1,  "C-53 " },
    { 2, 0, 0, ESC, '4',  ' ',     "Select italic font",                           1, 1, 1,  "C-114" },
    { 2, 0, 0, ESC, '5',  ' ',     "Cancel italic font",                           1, 1, 1,  "C-116" },
    { 2, 0, 0, ESC, '6',  ' ',     "Enable printing of upper control codes",       1, 1, 1,  "C-151" },
    { 2, 0, 0, ESC, '7',  ' ',     "Enable upper control codes",                   1, 1, 1,  "C-153" },
    { 2, 0, 0, ESC, '8',  ' ',     "Disable paper-out detector",                   0, 0, 1,  "C-165" },
    { 2, 0, 0, ESC, '9',  ' ',     "Enable paper-out detector",                    0, 0, 1,  "C-166" },
    { 2, 0, 0, ESC, '<',  ' ',     "Unidirectional mode (one line)",               1, 1, 1,  "C-161" },
    { 2, 0, 0, ESC, 'E',  ' ',     "Select bold font",                             1, 1, 1,  "C-110" },
    { 2, 0, 0, ESC, 'F',  ' ',     "Cancel bold font",                             1, 1, 1,  "C-112" },
    { 2, 0, 0, ESC, 'G',  ' ',     "Select double-strike printing",                1, 1, 1,  "C-121" },
    { 2, 0, 0, ESC, 'H',  ' ',     "Cancel double-strike printing",                1, 1, 1,  "C-123" },
    { 2, 0, 0, ESC, 'M',  ' ',     "Select 10.5-point, 12-cpi",                    1, 1, 0,  "C-102" },
    { 2, 0, 0, ESC, 'M',  ' ',     "Select 12-cpi",                                0, 0, 1,  "C-103" },
    { 2, 0, 0, ESC, 'O',  ' ',     "Cancel bottom margin",                         1, 1, 1,  "C-19 " },
    { 2, 0, 0, ESC, 'P',  ' ',     "Select 10-cpi",                                0, 0, 1,  "C-101" },
    { 2, 0, 0, ESC, 'P',  ' ',     "Select 10.5-point, 10-cpi",                    1, 1, 0,  "C-100" },
    { 2, 0, 0, ESC, 'T',  ' ',     "Cancel superscript/subscript printing",        1, 1, 1,  "C-131" },
    { 2, 0, 0, ESC, 'g',  ' ',     "Select 10.5-point, 15-cpi",                    1, 1, 0,  "C-104" },
    { 2, 0, 0, ESC, 'g',  ' ',     "Select 15-cpi",                                0, 0, 1,  "C-105" },
    { 2, 0, 0, ESC, 0x0e, ' ',     "Select double-width printing (one line)",      1, 1, 1,  "C-142" },
    { 2, 0, 0, ESC, 0x0f, ' ',     "Select condensed printing",                    1, 1, 1,  "C-136" },
    { 2, 0, 1, ESC, '&',  ' ',     "Define user-defined characters",               1, 1, 1,  "C-84 " },
    { 2, 0, 1, ESC, '*',  ' ',     "Select bit image",                             1, 1, 1,  "C-177" },
    { 2, 0, 1, ESC, '.',  ' ',     "Print raster graphics",                        1, 0, 0,  "C-172" },
    { 2, 0, 1, ESC, 'B',  ' ',     "Set vertical tabs",                            1, 1, 1,  "C-63 " },
    { 2, 0, 1, ESC, 'D',  ' ',     "Set horizontal tabs",                          1, 1, 1,  "C-61 " },
    { 2, 0, 1, ESC, 'K',  ' ',     "Select 60-dpi graphics",                       1, 1, 1,  "C-183" },
    { 2, 0, 1, ESC, 'L',  ' ',     "Select 120-dpi graphics",                      1, 1, 1,  "C-185" },
    { 2, 0, 1, ESC, 'Y',  ' ',     "Select 120-dpi, double-speed graphics",        1, 1, 1,  "C-187" },
    { 2, 0, 1, ESC, 'Z',  ' ',     "Select 240-dpi graphics",                      1, 1, 1,  "C-189" },
    { 2, 0, 1, ESC, '^',  ' ',     "Select 60/120-dpi, 9-pin graphics",            0, 0, 1,  "C-191" },
    { 2, 0, 1, ESC, 'b',  ' ',     "Set vertical tabs in VFU channels",            0, 1, 1,  "C-65 " },
    { 2, 1, 0, ESC, ' ',  ' ',     "Set intercharacter space",                     1, 1, 1,  "C-108" },
    { 2, 1, 0, ESC, '!',  ' ',     "Master select",                                1, 1, 1,  "C-118" },
    { 2, 1, 0, ESC, '%',  ' ',     "Select user-defined set",                      1, 1, 1,  "C-91 " },
    { 2, 1, 0, ESC, '+',  ' ',     "Set n/360-inch line spacing",                  1, 1, 0,  "C-57 " },
    { 2, 1, 0, ESC, '-',  ' ',     "Turn underline on/off",                        1, 1, 1,  "C-125" },
    { 2, 1, 0, ESC, '/',  ' ',     "Select vertical tab channel",                  0, 1, 1,  "C-67 " },
    { 2, 1, 0, ESC, '3',  ' ',     "Set n/180-inch line spacing",                  1, 1, 0,  "C-55 " },
    { 2, 1, 0, ESC, '3',  ' ',     "Set n/216-inch line spacing",                  0, 0, 1,  "C-56 " },
    { 2, 1, 0, ESC, 'A',  ' ',     "Set n/60-inch line spacing",                   1, 1, 0,  "C-58 " },
    { 2, 1, 0, ESC, 'A',  ' ',     "Set n/72-inch line spacing",                   0, 0, 1,  "C-59 " },
    { 2, 1, 0, ESC, 'C',  ' ',     "Set page length in lines",                     1, 1, 1,  "C-13 " },
    { 2, 1, 0, ESC, 'I',  ' ',     "Enable printing of control codes",             0, 0, 1,  "C-155" },
    { 2, 1, 0, ESC, 'J',  ' ',     "Advance print position vertically",            1, 1, 1,  "C-41 " },
    { 2, 1, 0, ESC, 'N',  ' ',     "Set bottom margin",                            1, 1, 1,  "C-17 " },
    { 2, 1, 0, ESC, 'Q',  ' ',     "Set right margin",                             1, 1, 1,  "C-21 " },
    { 2, 1, 0, ESC, 'R',  ' ',     "Select an international character set",        1, 1, 1,  "C-80 " },
    { 2, 1, 0, ESC, 'S',  ' ',     "Select superscript/subscript printing",        1, 1, 1,  "C-129" },
    { 2, 1, 0, ESC, 'U',  ' ',     "Turn unidirectional mode on/off",              1, 1, 1,  "C-159" },
    { 2, 1, 0, ESC, 'W',  ' ',     "Turn double-width printing on/off",            1, 1, 1,  "C-146" },
    { 2, 1, 0, ESC, 'a',  ' ',     "Select justification",                         0, 1, 1,  "C-71 " },
    { 2, 1, 0, ESC, 'k',  ' ',     "Select typeface",                              1, 1, 1,  "C-95 " },
    { 2, 1, 0, ESC, 'l',  ' ',     "Set left margin",                              1, 1, 1,  "C-23 " },
    { 2, 1, 0, ESC, 'm',  ' ',     "Select printing of upper control codes",       0, 0, 1,  "C-156" },
    { 2, 1, 0, ESC, 'p',  ' ',     "Turn proportional mode on/off",                1, 1, 1,  "C-106" },
    { 2, 1, 0, ESC, 'q',  ' ',     "Select character style",                       1, 1, 0,  "C-133" },
    { 2, 1, 0, ESC, 'r',  ' ',     "Select printing color",                        1, 1, 1,  "C-193" },
    { 2, 1, 0, ESC, 's',  ' ',     "Select low-speed mode",                        0, 1, 1,  "C-167" },
    { 2, 1, 0, ESC, 't',  ' ',     "Select character table",                       1, 1, 1,  "C-77 " },
    { 2, 1, 0, ESC, 'w',  ' ',     "Turn double-height printing on/off",           1, 1, 1,  "C-148" },
    { 2, 1, 0, ESC, 'x',  ' ',     "Select LQ or draft",                           1, 1, 0,  "C-93 " },
    { 2, 1, 0, ESC, 'x',  ' ',     "Select NLQ or draft",                          0, 0, 1,  "C-94 " },
    { 2, 1, 0, ESC, 0x19, ' ',     "Control paper loading/ejecting",               1, 1, 1,  "C-157" },
    { 2, 2, 0, ESC, '$',  ' ',     "Set absolute horizontal print position",       1, 1, 1,  "C-31 " },
    { 2, 2, 0, ESC, '?',  ' ',     "Reassign bit-image mode",                      1, 1, 1,  "C-181" },
    { 2, 2, 0, ESC, '\\', ' ',     "Set relative horizontal print position",       1, 1, 1,  "C-33 " },
    { 2, 2, 0, ESC, 'c',  ' ',     "Set horizontal motion index (HMI)",            1, 0, 0,  "C-99 " },
    { 2, 2, 0, ESC, 'e',  ' ',     "Set fixed tab increment",                      0, 0, 1,  "C-69 " },
    { 2, 2, 0, ESC, 'f',  ' ',     "Horizontal/vertical skip",                     0, 0, 1,  "C-47 " },
    { 2, 3, 0, ESC, ':',  ' ',     "Copy ROM to RAM",                              1, 1, 1,  "C-89 " },
    { 2, 3, 0, ESC, 'X',  ' ',     "Select font by pitch and point",               1, 0, 0,  "C-97 " },
    { 3, 0, 1, ESC, '(',  '^',     "Print data as characters",                     1, 0, 0,  "C-150" },
    { 3, 1, 0, ESC, 'C',    0,     "Set page length in inches",                    1, 1, 1,  "C-15 " },
    { 3, 3, 0, ESC, '(',  'G',     "Select graphics mode",                         1, 0, 0,  "C-169" },
    { 3, 3, 0, ESC, '(',  'U',     "Set unit",                                     1, 0, 0,  "C-50 " },
    { 3, 3, 0, ESC, '(',  'i',     "Select MicroWeave print mode",                 1, 0, 0,  "C-171" },
    { 3, 4, 0, ESC, '(',  'C',     "Set page length in defined unit",              1, 0, 0,  "C-10 " },
    { 3, 4, 0, ESC, '(',  'V',     "Set absolute vertical print position",         1, 0, 0,  "C-37 " },
    { 3, 4, 0, ESC, '(',  'v',     "Set relative vertical print position",         1, 0, 0,  "C-39 " },
    { 3, 5, 0, ESC, '(',  '-',     "Select line/score",                            1, 1, 0,  "C-127" },
    { 3, 5, 0, ESC, '(',  't',     "Assign character table",                       1, 0, 1,  "C-73 " },
    { 3, 5, 0, ESC, '.',  '2',     "Enter TIFF compressed mode",                   1, 0, 0,  "C-175" },
    { 3, 6, 0, ESC, '(',  'c',     "Set page format",                              1, 0, 0,  "C-11 " },
    { 3, 8, 0, ESC, '(',  'B',     "Bar code setup and print",                     1, 1, 1,  "C-195" },
    { 0, 0, 0, 0,   0,    0,       (char *)NULL, 0, 0, 0,  (char *)NULL }
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -