home *** CD-ROM | disk | FTP | other *** search
/ Phenomenon / Phenomenon.iso / quake / utils / quakec / qdtool10 / qdexport.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-03  |  2.1 KB  |  80 lines

  1. /*
  2.  * Copyright (C) 1996 by Chris Johnson.  All rights reserved.
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and
  5.  * its documentation for any purpose and without fee is hereby
  6.  * granted, provided that the above copyright notice appear in all
  7.  * copies and that both that copyright notice and this permission
  8.  * notice appear in supporting documentation.  If more than a few
  9.  * lines of this code are used in a program which displays a copyright
  10.  * notice or credit notice, the following acknowledgment must also be
  11.  * displayed on the same screen: "This product includes software
  12.  * developed by Chris Johnson for use in the QuakeDef Tools package."
  13.  * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESSED OR IMPLIED
  14.  * WARRANTY.
  15.  *
  16.  * (Thanks to Raphael Quinet for this nifty disclaimer!)
  17.  */
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21.  
  22. #include "qdexport.h"
  23. #include "fileutil.h"
  24. #include "qdfunct.h"
  25.  
  26. int main(int argc, char *argv[])
  27. {
  28.     FILE *    bsp;
  29.     FILE *    qdf;
  30.     long *    addr;
  31.  
  32.     if (argc < 3)
  33.     {
  34.         show_help();
  35.         return (OKAY);
  36.     }
  37.  
  38.     // in file
  39.     if ((bsp = safeopen(argv[1], "rb")) == NULL)
  40.         exit(ERROR);
  41.  
  42.     // out file
  43.     if ((qdf = safeopen(argv[2], "wt")) == NULL)
  44.         exit(ERROR);
  45.  
  46.     // Get BSP header file
  47.     if ((addr = grab_addresses(bsp)) == NULL)
  48.         exit(ERROR);
  49.  
  50.     fseek(bsp, addr[BH_QD_ELEM], SEEK_SET);
  51.  
  52.     if (export_quake_def(bsp, qdf, addr[BH_QDSIZE_ELEM]) == EOF)
  53.     {
  54.         fprintf(stderr, "\nError -- premature end of file in file:");
  55.         fprintf(stderr, "\n%s\n", argv[1]);
  56.         exit(ERROR);
  57.     }
  58.  
  59.     // Tidy up
  60.     free(addr);
  61.     fclose(bsp);
  62.     fclose(qdf);
  63.  
  64.     fprintf(stderr, "\nExport of BSP file successful!\n");
  65.  
  66.     return (OKAY);
  67. }
  68.  
  69. void show_help(void)
  70. {
  71.     printf("\nQuakeDef Exporter v1.0.  Copyright 1996 by Chris Johnson.");
  72.     printf("\n\nUsage:");
  73.     printf("\n\nqdexport <drive:><\\path\\><mapfile.bsp> "
  74.             "<drive:><\\path\\><deffile.def>");
  75.     printf("\n\n<drive:> and <\\path\\> unnecessary if "
  76.             "current directory is adequate");
  77.     printf("\n<mapfile.bsp> is the filename of the .BSP "
  78.             "file to extract from");
  79.     printf("\n<deffile.def> is the filename for the ASCII dump\n");
  80. }