==== Outil d'analyse du fichier PRINTER.SYS ====
Cet outil décode les fichiers de configuration des imprimantes PRINTER.SYS.
Exemple d'utilisation :
$ nrprinter PRINTER.SYS
nrprinter, version 1.0
Printer 0:
Type: parallel
Port: LPT1:
Name: " TALLY MT80 PC "
Translation table: no translation table defined.
Printer 1:
Type: parallel
Port: LPT2:
Name: " MICROLINE 84 "
Translation table:
7F -> 20
80 -> 20
81 -> AD
82 -> A5
83 -> A1
84 -> 20
85 -> A0
87 -> AF
88 -> A4
89 -> A6
8A -> A3
8B -> A8
8C -> A7
93 -> A9
94 -> 20
96 -> AC
97 -> AB
Printer 2:
Type: serial
Port: COM1:
Name: " FACIT 4565 "
Translation table:
40 -> 20
5C -> 20
7B -> 20
7C -> 20
7D -> 20
7E -> 20
7F -> 20
80 -> 20
81 -> 7E 08 75
82 -> 7B
83 -> 5E 08 61
84 -> 7E 08 61
85 -> 40
86 -> 20
87 -> 5C
88 -> 5E 08 65
89 -> 7E 08 65
8A -> 7D
8B -> 7E 08 69
8C -> 5E 08 69
93 -> 5E 08 6F
94 -> 7E 08 6F
96 -> 5E 08 75
97 -> 7C
Printer 3:
Type: parallel
Port: LPT3:
Name: " EPSON FX 100 "
Translation table:
81 -> 1B 52 02 7D 1B 52 00
82 -> 1B 52 01 7B 1B 52 00
83 -> 5E 08 61
85 -> 1B 52 01 40 1B 52 00
87 -> 1B 52 01 5C 1B 52 00
88 -> 5E 08 65
89 -> 1B 52 01 7E 08 65 1B 52 00
8A -> 1B 52 01 7D 1B 52 00
8B -> 1B 52 01 7E 08 69 1B 52 00
8C -> 5E 08 69
93 -> 5E 08 6F
94 -> 1B 52 02 7C 1B 52 00
96 -> 5E 08 75
97 -> 1B 52 01 7C 1B 52 00
7F -> 20
80 -> 20
84 -> 20
86 -> 20
Code source :
#include
#include
#include
FILE *gSource = 0;
unsigned char *gBuffer = 0;
unsigned int gFileSize = 0;
void usage()
{
printf("Usage: nrprinter filename\n");
}
int main(int argc, char *argv[])
{
unsigned int i, j, k, lTmpInt;
char lTmpChar;
printf("nrprinter, version 1.0\n");
if ((argc!=2))
{
usage();
return -1;
}
gSource = fopen(argv[1],"rb");
if (gSource == NULL)
{
printf("Error: cannot open file.\n");
return -2;
}
fseek(gSource,0,SEEK_END);
gFileSize = ftell(gSource);
fseek(gSource,0,SEEK_SET);
gBuffer = malloc(gFileSize);
if (gBuffer == NULL)
{
printf("Error: cannot allocate memory.\n");
fclose(gSource);
return -3;
}
fread(gBuffer,1,gFileSize,gSource);
fclose(gSource);
for (i=0;i<4;i++)
{
printf("\nPrinter %u:\n Type: ",i);
switch (gBuffer[i*22+2])
{
case 'P':
printf("parallel\n Port: LPT%u:\n",gBuffer[i*22+3]+1);
break;
case 'S':
printf("serial\n Port: COM%u:\n",gBuffer[i*22+3]+1);
break;
default : printf("Unknown");
}
printf(" Name: \"");
for(j=0;((lTmpChar=gBuffer[i*22+4+j])!=0)&&(j<18);j++)
{
printf("%c",lTmpChar);
}
printf("\"\n\n");
lTmpInt = gBuffer[i*22]+(gBuffer[i*22+1]<<8);
j=0;
printf(" Translation table: ");
while (gBuffer[lTmpInt+j] != 0xff)
{
printf("\n %02X -> ",gBuffer[lTmpInt+j++]&0xff);
for (k=0;k