home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TIERRA40.ZIP / TIERRA / EXTRACT.C < prev    next >
C/C++ Source or Header  |  1992-09-09  |  2KB  |  67 lines

  1. /* extract.c   9-9-92  genome extraction for the Tierra Simulator */
  2. /* Tierra Simulator V4.0: Copyright (c) 1991, 1992 Tom Ray & Virtual Life */
  3.  
  4. #ifndef lint
  5. static char sccsid[] = "@(#)extract.c    1.5    7/21/92";
  6. #endif
  7.  
  8. #include "license.h"
  9. #include "tierra.h"
  10. #include "extern.h"
  11.  
  12.  
  13. #ifdef MEM_CHK
  14. #include <memcheck.h>
  15. #endif
  16.  
  17. void extract(ce)
  18.     Pcells ce;
  19. {
  20.     I16u i, j;
  21.     I32s size;
  22.     I32s ip;
  23.     Pgl g;
  24.     FILE *fp;
  25.     head_t head;
  26.     indx_t *indx, gindx;
  27.  
  28.     if (!GeneBnker)
  29.         return;
  30.     isolate = 0;
  31. #ifdef IBM3090
  32.     sprintf(Buff, "%04ld.gen.d", ce->d.gen.size);
  33. #else
  34.     sprintf(Buff, "%s%04ld.gen", GenebankPath, ce->d.gen.size);
  35. #endif
  36.     size = ce->d.gen.size;
  37.     g = sl[size]->g[ce->d.gi];
  38.     sprintf(ExtrG, "%04ld%s @ %ld", g->gen.size, g->gen.label, g->pop);
  39. #if FRONTEND == STDIO
  40. sprintf(mes[0], "extract: %s", ExtrG);
  41. FEMessage(1,mes);
  42. #else /* FRONTEND == STDIO */
  43.     if (Log) fprintf(tfp_log, "ex = %s\n", ExtrG);
  44. #endif /* FRONTEND == STDIO */
  45.  
  46. /* DAN open an archive, if it does not exist, create it */
  47.     if (!(fp = open_ar(Buff, ce->d.gen.size, GFormat, -1)))
  48.     {   FEError(-200,EXIT,NOWRITE,
  49.             "Tierra extract() Unable to open extract file %s",Buff);
  50.     }
  51.     head = read_head(fp);
  52. #ifdef __TURBOC__
  53.     indx = &gindx;
  54. #else  /* __TURBOC__ */
  55.     indx = read_indx(fp, &head);
  56. #endif /* __TURBOC__ */
  57.     add_gen(fp, &head, &indx, g);
  58. #ifndef __TURBOC__
  59.     if (indx)
  60.     {   thfree(indx);
  61.         indx = NULL;
  62.     }
  63. #endif /* __TURBOC__ */
  64.     fclose(fp);
  65.     NumGenDG++;
  66. }
  67.