User Tools

Site Tools


outil_d_analyse_des_fichiers_printer.sys

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
outil_d_analyse_des_fichiers_printer.sys [2025/03/17 22:45] – created fool-duplexoutil_d_analyse_des_fichiers_printer.sys [2025/03/19 14:22] (current) – external edit 127.0.0.1
Line 102: Line 102:
 #include <stdlib.h> #include <stdlib.h>
 #include <string.h> #include <string.h>
- 
-#define NRDATSIZE 732 
  
 FILE *gSource = 0; FILE *gSource = 0;
- +unsigned char *gBuffer = 0; 
-unsigned char gBuffer[NRDATSIZE]; +unsigned int gFileSize = 0;
- +
- +
-unsigned int GetVersion(char* xBuffer) +
-{ +
-    return (xBuffer[0]<<8)+xBuffer[1]; +
-} +
- +
-void GetSystemAppName(char* xBuffer, char* xOutput)  +
-{ +
-    xOutput[0] = '/'+xBuffer[2]; +
-    xOutput[1] = ':'; +
-    memcpy(xOutput+2,xBuffer+3,8); +
-    xOutput[10] = 0; +
-} +
- +
-unsigned int GetPrinterStatus(char *xBuffer, unsigned int xIndex) +
-{ +
-    return xBuffer[11+(xIndex&0x03)];     +
-} +
- +
-unsigned int GetSpoolerDisk(char *xBuffer) +
-{ +
-    return xBuffer[25]; +
-} +
- +
-unsigned int GetListingHeader(char *xBuffer) +
-{ +
-    return xBuffer[26]; +
-} +
- +
-unsigned int GetDisk(char *xBuffer, unsigned int xIndex) +
-{ +
-    return xBuffer[15+xIndex]; +
-} +
- +
-unsigned int GetSignatureCount(char *xBuffer) +
-{ +
-    return xBuffer[27]; +
-} +
- +
-void GetSignature(char *xBuffer, unsigned int xIndex, char* xOutput) +
-{ +
-    unsigned int i; +
- +
-    for (i=0;i<32;i++) { +
-        sprintf(xOutput+i*2,"%02X", xBuffer[28+i+xIndex*44]&0xff); +
-    }    +
-    xOutput[64]=0; +
-} +
- +
-void GetBootApplicationFilename(char *xBuffer, unsigned int xIndex, char* xOutput) +
-{ +
-    unsigned int i,j = 0; +
- +
-    xOutput[0] = '/'+xBuffer[xIndex*44+60]; +
-    xOutput[1] = ':'; +
- +
-    while ((xBuffer[xIndex*44+61+i]!=' ')&&(i<8)) xOutput[2+i] = xBuffer[xIndex*44+61+i++]; +
-    xOutput[2+i++] = '.'; +
-     +
-    while ((xBuffer[xIndex*44+69+j]!=' ')&&(j<3)) xOutput[2+i++] = xBuffer[xIndex*44+69+j++]; +
-    xOutput[2+i] = 0; +
-     +
-}+
  
  
 void usage() void usage()
 { {
-    printf("Usage: nrdatview filename\n");+    printf("Usage: nrprinter filename\n");
 } }
  
 int main(int argc, char *argv[]) int main(int argc, char *argv[])
 { {
-    unsigned int lTmpuInt, i; +    unsigned int i, j, k, lTmpInt; 
-    char lTmpStr[65];+    char lTmpChar;
  
-    printf("NRDATView, version 1.0\n\n");+    printf("nrprinter, version 1.0\n");
     if ((argc!=2))     if ((argc!=2))
     {     {
Line 198: Line 132:
     }     }
  
-    fread(gBuffer,1,NRDATSIZE,gSource); +    fseek(gSource,0,SEEK_END); 
-    fclose(gSource); +    gFileSize = ftell(gSource); 
-  +    fseek(gSource,0,SEEK_SET); 
-    lTmpuInt = GetVersion(gBuffer); + 
-    if ((lTmpuInt!=0x0301)&&(lTmpuInt!=0x0303))+    gBuffer = malloc(gFileSize); 
 +    if (gBuffer == NULL)
     {     {
-        printf("Error: incorrect file version (%u.%u).\n",(lTmpuInt>>8)&0xff,lTmpuInt&0xff);+        printf("Error: cannot allocate memory.\n"); 
 +        fclose(gSource);
         return -3;         return -3;
     }     }
  
-    printf("Nanoreseau version: %u.%u\n\n",(lTmpuInt>>8)&0xff,lTmpuInt&0xff);+    fread(gBuffer,1,gFileSize,gSource); 
 +    fclose(gSource);
  
-    GetSystemAppName(gBuffer,lTmpStr); +    for (i=0;i<4;i++) 
-    printf("System application: %s (.MO5/.TO7)\n\n",lTmpStr); +
- +
-    for (i=0;i<4;i++)+
     {     {
-        printf("Printer %01u is %sinstalled.\n",i,GetPrinterStatus(gBuffer,i)?"":"not "); +        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;
  
-    printf("The spooler is on disk %c:\n",'/'+GetSpoolerDisk(gBuffer)); +            default : printf("Unknown"); 
-    lTmpuInt = GetListingHeader(gBuffer); +        } 
-    printf("Listing header: %s\n",lTmpuInt&0x10?"one line":"one page"); +        printf("  Name: \""); 
-    printf("Listing footer: %s\n",lTmpuInt&0x10?"three lines":"next page");+        for(j=0;((lTmpChar=gBuffer[i*22+4+j])!=0)&&(j<18);j++)  
 +        { 
 +            printf("%c",lTmpChar); 
 +        } 
 +        printf("\"\n\n");
  
-    printf("\n");  +        lTmpInt = gBuffer[i*22]+(gBuffer[i*22+1]<<8); 
- +        j=0; 
-    for (i=0;i<10;i++) { +        printf("  Translation table: "); 
-        lTmpuInt = GetDisk(gBuffer,i); +        while (gBuffer[lTmpInt+j] != 0xff) 
-        printf("Disk %01u: is ",i); +        {  
-        if (lTmpuInt) { +            printf("\n    %02X -> ",gBuffer[lTmpInt+j++]&0xff); 
-            printf("assigned to %c:\n",lTmpuInt+'A'-1); +            for (k=0;k<gBuffer[lTmpInt+j];k++)  
-        } else+            { 
 +                printf("%02X ", gBuffer[lTmpInt+k+j+1]&0xff); 
 +            } 
 +            j += k+1; 
 +        } 
 +        if (j==0) 
         {         {
-            printf("not assigned.\n");+            printf("no translation table defined.");
         }         }
 +        printf("\n");
     }     }
- +  
-    lTmpuInt = GetSignatureCount(gBuffer); +    free(gBuffer);
-    printf("\nSignature table (%u entries):\n",lTmpuInt); +
-    for (i=0;i<lTmpuInt;i++)  +
-    { +
-        GetSignature(gBuffer,i,lTmpStr); +
-        printf("   %s  ",lTmpStr); +
-        GetBootApplicationFilename(gBuffer,i,lTmpStr); +
-        printf("%s\n",lTmpStr); +
-    } +
     return 0;     return 0;
 } }
 </code> </code>
outil_d_analyse_des_fichiers_printer.sys.1742247944.txt.gz · Last modified: (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki