home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / MOD15INS.ZIP / 3115.C < prev    next >
C/C++ Source or Header  |  1995-04-10  |  2KB  |  82 lines

  1. #include <string.h> /* pour les gestions de strings */
  2. #include <stdio.h> /* pour printf et les fichiers */
  3. #include <io.h> /* pour filelenght et eof */
  4. #include <dos.h> /* pour getdfree */
  5. #include <stdlib.h> /* pour exit */
  6.  
  7. char *destname (char *name) {
  8.   char *buf = "            " ;
  9.  
  10.   strcpy (buf, name) ;
  11.   strncpy (buf, "_", 1) ;
  12.   return buf;
  13.   }
  14.  
  15.  
  16. int main (int nbparam, char *param[] ) {
  17.   FILE *src, *dest ;
  18.   unsigned char buf1 [469], buf2 [129] , buf3 [32000] ;
  19.   int i=0,j=0,s ;
  20.  
  21.   printf ("\nMOD 4 CH 31 INSTR to 15 INSTR converter \n") ;
  22.   printf ("Coded by Fred of TFL-TDV \n \n") ;
  23.   if (nbparam != 2) {
  24.     printf ("Syntax: 3115 <filename> \n") ;
  25.     exit (0) ;
  26.     }
  27.  
  28.   if (strcmp (destname (param [1]),param [1]) == 0) {
  29.     printf("I don't want to convert a file with \n") ;
  30.     printf("a name beginning by '_'. Sorry guy !\n\n") ;
  31.     exit (1) ;
  32.     }
  33.  
  34.   if ((src=fopen(param[1],"rb")) == NULL) {
  35.     printf ("File '%s' not found in current directory.\n",param[1]) ;
  36.     printf ("Type 3115 without any parameter for help\n \n");
  37.     exit (1) ;
  38.     }
  39.   if ((dest=fopen(destname(param[1]),"wb")) == NULL) {
  40.     printf ("Cannot open destination file. \n \n") ;
  41.     exit (1) ;
  42.     }
  43.  
  44.  
  45.   /* Convertion : */
  46.  
  47.   for ( i=0 ; i<470 ; i++ ) {
  48.     buf1 [i] = getc (src) ;
  49.     if (feof(src) != 0) {
  50.       printf ("Too early eof error -Is this a mod ? \n \n") ;
  51.       exit (1) ;
  52.     } }
  53.   fseek(src,950,SEEK_SET);
  54.   for ( i=0 ; i<130 ; i++ ) {
  55.     buf2 [i] = getc (src) ;
  56.     if (feof(src) != 0) {
  57.       printf ("Too early eof error -Is this a mod ? \n \n") ;
  58.       exit (1) ;
  59.     } }
  60.  
  61.   for ( i=0 ; i<470 ; i++ )
  62.     putc ( buf1 [i] , dest ) ;
  63.   for ( i=0 ; i<130 ; i++ )
  64.     putc ( buf2 [i] , dest ) ;
  65.  
  66.  
  67.   fseek(src,1084,SEEK_SET);
  68.   while (feof(src) == 0) {
  69.     buf3 [j] = getc(src) ;
  70.     j++ ;
  71.     if (j == 32000) {
  72.       for (i=0 ; i<32000 ; i++) putc (buf3 [i] , dest) ;
  73.       j = 0 ;
  74.       }
  75.     }
  76.   for (i=0 ; i<=j ; i++)
  77.     putc (buf3 [i] , dest) ;
  78.  
  79.   printf("Converted module is '%s'.\n\n",destname (param[1]) ) ;
  80.  
  81.   return 0 ;
  82. }