home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / webkoi.zip / wpatch.c < prev    next >
C/C++ Source or Header  |  1995-09-10  |  2KB  |  84 lines

  1. /* 
  2.  * Patch Web Explorer translation table to see KOI-8 coded 
  3.  *    russian text
  4.  */
  5.  
  6.  
  7. #include <stdio.h>
  8. #include <sys\types.h>
  9. #include <sys\stat.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12.  
  13. #include "866.tbl"
  14. char tst[4]={125,126,127,0};
  15.  
  16. void main(int argc, char *argv[])
  17. {
  18. FILE *fp;
  19. int i;
  20. char buf[200];
  21. struct stat st;
  22. int count;
  23. char ch;
  24. int found=0;
  25.  
  26.    if(argc < 2)
  27.    {
  28.      printf("%s - Patch Web Explorer to display KOI-8 text\nUsage:\n\t%s <file> \
  29.      \n\n\tWhere <file> is the file to patch (i.e. explore.exe (prior to v0814)\
  30.  or\n\t\twebexwin.dll for latter versions\n",
  31.       argv[0], argv[0]);
  32.      exit(1);
  33.    }
  34.    stat(argv[1], &st);
  35.    count=st.st_size;
  36.    fp=fopen(argv[1], "rb+");
  37.    
  38.    /* 
  39.        Seek forward to fasten things a bit
  40.        you may remove this line and change
  41.         the next line to read "for(i=0; i < count; i++)"
  42.         if you have problems
  43.   
  44.    fseek(fp, 2000, SEEK_SET); */
  45.    for(i=0; i < count; i++)
  46.    {
  47.      if(found==2)
  48.        break;
  49.      ch=fgetc(fp);
  50.      if(ch == tst[0])
  51.      {
  52.      
  53.        fseek(fp, i, SEEK_SET);
  54.        fread(buf,1,3,fp);
  55.        buf[3]='\0';
  56.     /*   printf("Buf:[%s]\n",buf); */
  57.        i+=2;
  58.        if(strcmp(buf, tst) == 0)
  59.        {
  60.          if(found == 0)
  61.          {
  62.            found++;
  63.            printf("Found table #1...\n");
  64.            fseek(fp, i+1, SEEK_SET);
  65.            if(fwrite(koi82alt,1,128,fp) < 128)
  66.              perror("Writing data");
  67.            i+=128;
  68.            fseek(fp, i, SEEK_SET);
  69.          }
  70.          else
  71.          {
  72.            found++;
  73.            printf("Found table #2...\n");
  74.            fseek(fp, i+1, SEEK_SET);
  75.            if(fwrite(koi82alt,1,128,fp) < 128)
  76.              perror("Writing data2");
  77.            i+=128;
  78.            fseek(fp, i, SEEK_SET);
  79.          }
  80.        }
  81.      }
  82.    }
  83.    fclose(fp);
  84. }