T.C 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include <stdlib.h>
  14. #include <stdio.h>
  15. typedef struct hogfile {
  16. char name[13];
  17. int offset;
  18. int length;
  19. } hogfile;
  20. void main()
  21. {
  22. char id[4];
  23. FILE * fp, *fp1;
  24. int i, len;
  25. char name[16];
  26. char * ptr;
  27. fp = fopen( "DESCENT.HOG", "rb" );
  28. if ( fp == NULL ) return;
  29. fread( id, 3, 1, fp );
  30. if ( strncmp( id, "DHF", 3 ) ) {
  31. fclose(fp);
  32. return;
  33. }
  34. while( 1 )
  35. {
  36. i = fread( name, 13, 1, fp );
  37. if ( i != 1 ) {
  38. fclose(fp);
  39. return;
  40. }
  41. i = fread( &len, 4, 1, fp );
  42. if ( i != 1 ) {
  43. fclose(fp);
  44. return;
  45. }
  46. fp1 = fopen( name, "wb" );
  47. if ( fp1 == NULL ) printf( "Error opening '%s'\n", name );
  48. printf( "Extracting: '%s'\n", name );
  49. ptr = malloc( len );
  50. if ( ptr == NULL ) printf( "Error mallocing '%s'\n", name );
  51. fread( ptr, len, 1, fp );
  52. fwrite( ptr, len, 1, fp1 );
  53. free(ptr);
  54. fclose(fp1);
  55. }
  56. }
  57.