home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / misc / chunker.lha / Chunker / source / dechunk.c < prev    next >
C/C++ Source or Header  |  1995-11-10  |  1KB  |  65 lines

  1. /*************************************************************************
  2.  *
  3.  * DeChunker
  4.  *
  5.  * Copyright ©1995 Lee Kindness and Evan Tuer
  6.  * cs2lk@scms.rgu.ac.uk
  7.  *
  8.  * dechunk.c
  9.  */
  10.  
  11. #include "dechunk.h"
  12.  
  13.  
  14. /*************************************************************************
  15.  * main() - DaDDDaaah!
  16.  */
  17.  
  18. int main(int argc, char **argv)
  19. {
  20.     long ret = 10;
  21.     /* init */
  22.     if( InitSystem() )
  23.     {
  24.         struct Args *args;
  25.         
  26.         if( args = GetDeChunkArgs(argc, argv) )
  27.         {
  28.             FILEt dest;
  29.         
  30.             if( dest = mfopen(args->arg_Filename, FILEOPEN_WRITE) )
  31.             {
  32.                 char *srcname;
  33.                 long num = 0;
  34.                 FILEt src;
  35.                 
  36.                 while( (srcname = BuildFName(args->arg_Basename, &num)) &&
  37.                        (src = mfopen(srcname, FILEOPEN_READ)) )
  38.                 {
  39.                     register int c;
  40.                                     
  41.                     mprintf("%s\n", srcname);
  42.                     
  43.                     for( c = mfgetc(src);
  44.                          c != EOF;
  45.                          c = mfgetc(src) )
  46.                         mfputc(c, dest);
  47.                 
  48.                     FreeFName(srcname);
  49.                     mfclose(src);
  50.                 }
  51.             
  52.                 ret = 0;
  53.                 
  54.                 mfclose(dest);
  55.             }
  56.             FreeDeChunkArgs(args);
  57.         }
  58.         FreeSystem();
  59.     } else
  60.         mprintf("Usage:\n dechunk <outputfile> <basename>\n");
  61.     
  62.     return( ret );
  63. }
  64.  
  65.