PSCOMP.C 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: h:/miner/source/compress/RCS/test.c $
  15. * $Revision: 1.1 $
  16. * $Author: john $
  17. * $Date: 1994/02/10 15:54:38 $
  18. *
  19. * Test program...
  20. *
  21. * $Log: test.c $
  22. * Revision 1.1 1994/02/10 15:54:38 john
  23. * Initial revision
  24. *
  25. *
  26. */
  27. #pragma off (unreferenced)
  28. static char rcsid[] = "$Id: test.c 1.1 1994/02/10 15:54:38 john Exp $";
  29. #pragma on (unreferenced)
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <io.h>
  34. #include "cfile.h"
  35. #include "cflib.h"
  36. int main(int argc, char * argv[] )
  37. {
  38. int size, size1;
  39. CFILE * cfile;
  40. void * buffer;
  41. lib_init( "JOHN.LIB" );
  42. if (strcmpi( argv[1], "x" )==0) {
  43. // extract argv[2] into argv[3];
  44. printf( "Uncompressing %s into %s\n", argv[2], argv[3] );
  45. cfile = cfopen(argv[2], "rc" );
  46. size = cfilelength( cfile );
  47. buffer = malloc(size);
  48. size1 = cfread( buffer, 1, size, cfile );
  49. printf( "File expanded to %d bytes (Orginal was %d bytes)\n", size1, size );
  50. cfclose(cfile);
  51. cfile = cfopen( argv[3], "wb" );
  52. cfwrite( buffer, 1, size, cfile );
  53. cfclose( cfile );
  54. free(buffer);
  55. } else if (strcmpi( argv[1], "c" )==0) {
  56. // compress argv[2] into argv[3];
  57. printf( "Compressing %s into %s\n", argv[2], argv[3] );
  58. cfile = cfopen( argv[2], "rb" );
  59. size = cfilelength( cfile );
  60. printf( "File is %d bytes big\n", size );
  61. buffer = malloc(size);
  62. size1 = cfread( buffer, 1, size, cfile );
  63. printf( "Read in %d bytes\n", size1 );
  64. cfclose(cfile);
  65. cfile = cfopen( argv[3], "wc" );
  66. if ((size1=cfwrite( buffer, 1, size, cfile ))!=size)
  67. printf( "Error! Only wrote %d bytes\n", size1 );
  68. cfclose( cfile );
  69. free(buffer);
  70. }
  71. }
  72.