home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / EDUCATIO / STAGES12.ZIP / ANIMAL.C next >
Encoding:
C/C++ Source or Header  |  1991-04-21  |  5.5 KB  |  193 lines

  1. #include "header.h"
  2. #include "file.h"
  3.  
  4. /************************************************************************/
  5. /**    animals functions                           **/
  6. /************************************************************************/
  7. /* currently supported animals:
  8.  
  9.   animal               code#   animal abbrev.
  10. -----------------------------------------------
  11.   sprague-dawley rat     0        sdrat
  12.   sherman rat            1        shrat
  13.   hamster                2      hamster
  14.   c3h mouse              3          c3h
  15.   dog             4        dog
  16.  
  17.   all animals require the following files:
  18.      <abbrev>.stg
  19.      <abbrev>.seq
  20.      <abbrev>.fil
  21.      <abbrev>.mcl
  22.      <abbrev>.ref
  23.   in the same directory where stages.exe is
  24.  
  25.    to add new animals:
  26.        1/  create a <animal>.stg file
  27.         this file holds the stage cycle data.  see stages.doc
  28.         for format info.
  29.     2/  create a <animal>.seq file
  30.         this file holds the cell sequence data.  see stages.doc
  31.         for format info.
  32.     3/  create a <animal>.fil file
  33.         this file holds the format of the cell sequence.  see
  34.         sdrat.fil for format example.
  35.     4/  create a <animal>.mcl file
  36.         this file holds the cell names for stages with multiple
  37.         cell names possible (mcl = Multiple CeL names).  see
  38.         sdrat.mcl for format example.
  39.     5/  create a <animal>.ref file
  40.         this file holds the reference data from which the stage
  41.         and sequence information were taken.  see sdrat.ref for
  42.         format example.
  43.     6/  install the <animal>.stg, <animal>.seq, <animal>.fil,
  44.         <animal>.mcl and <animal>.ref files in the same directory
  45.         where the stages program is
  46.     6/  add lines to the animalmenu function (in file menus1.c):
  47.         entries to the menu, and
  48.         cases to the menu selection switch statement
  49.     7/  add lines to getanimal function (here), patterned after other
  50.         cases in the function
  51.     8/  add lines to the Help! Using the Animal Menu file, in helps2.c,
  52.         listing the animals supported by stages
  53. */
  54.  
  55. /********************************/
  56. /*     function: getanimal    */
  57. /********************************/
  58. /* gets data for animal from files *.stg, *.seq, and *.mcl
  59.    NB: the code char "animal" doesn't have any mnemonic meaning,
  60.    see animalmenu() in menus1.c to see which animal has which animal code */
  61. getanimal (pfpstg, pfpseq, pfpmcl, stgfil, seqfil, mclfil, id)
  62.   FILE **pfpstg, **pfpseq, **pfpmcl;
  63.   char *stgfil, *seqfil, *mclfil, id;
  64. {
  65.   int val1, val2, val3;
  66.   char tmpstr[MAXLEN];        /* tmp str for Animal name */
  67.  
  68.   switch (id) {
  69.   case 'H':
  70.     strcpy(stgfil, "sdrat.stg");
  71.     strcpy(seqfil, "sdrat.seq");
  72.     strcpy(mclfil, "sdrat.mcl");
  73.     strcpy(tmpstr, "Sprague-Dawley Rat");
  74.     AnimalNum = 0;
  75.     break;
  76.   case 'I':
  77.     strcpy(stgfil, "shrat.stg");
  78.     strcpy(seqfil, "shrat.seq");
  79.     strcpy(mclfil, "shrat.mcl");
  80.     strcpy(tmpstr, "Sherman Rat");
  81.     AnimalNum = 1;
  82.     break;
  83.   case 'J':
  84.     strcpy(stgfil, "hamster.stg");
  85.     strcpy(seqfil, "hamster.seq");
  86.     strcpy(mclfil, "hamster.mcl");
  87.     strcpy(tmpstr, "Hamster");
  88.     AnimalNum = 2;
  89.     break;
  90.   case 'K':
  91.     strcpy(stgfil, "c3h.stg");
  92.     strcpy(seqfil, "c3h.seq");
  93.     strcpy(mclfil, "c3h.mcl");
  94.     strcpy(tmpstr, "C3H Mouse");
  95.     AnimalNum = 3;
  96.     break;
  97.   case 'L':
  98.     strcpy(stgfil, "dog.stg");
  99.     strcpy(seqfil, "dog.seq");
  100.     strcpy(mclfil, "dog.mcl");
  101.     strcpy(tmpstr, "Dog");
  102.     AnimalNum = 4;
  103.     break;
  104.   default:    /* shouldn't */
  105.     strcpy(stgfil, "sdrat.stg");
  106.     strcpy(seqfil, "sdrat.seq");
  107.     strcpy(mclfil, "sdrat.mcl");
  108.     strcpy(tmpstr, "Sprague-Dawley Rat");
  109.     AnimalNum = 0;
  110.   } /* switch */
  111.  
  112. #if (PC && (DEBUG > 4))
  113.   clrscr1(1);
  114.   gotoxy(1, 5);
  115.   cprintf("%sanimal: getting stgfil & stgfil data", tab);
  116.   hitreturn(1);
  117. #endif
  118.   val1 = getipfile(stgfil, pfpstg, 'F', 'C');
  119.   getstgdat(stgfil, *pfpstg);
  120.   fclose(*pfpstg);
  121. #if (PC && (DEBUG > 4))
  122.   clrscr1(1);
  123.   gotoxy(1, 5);
  124.   cprintf("%sanimal: got stage data", tab);
  125.   gotoxy(1, 7);
  126.   cprintf("%s        getting seqfil & seqfil data", tab);
  127.   hitreturn(1);
  128. #endif
  129.   val2 = getipfile(seqfil, pfpseq, 'F', 'S');
  130.   getseqdat(seqfil, *pfpseq);
  131.   fclose(*pfpseq);
  132. #if (PC && (DEBUG > 4))
  133.   clrscr1(1);
  134.   gotoxy(1, 5);
  135.   cprintf("%sanimal: got cell seq data", tab);
  136.   gotoxy(1, 7);
  137.   cprintf("%s        getting mclfil & mclfil data", tab);
  138.   hitreturn(1);
  139. #endif
  140.   val3 = getipfile(mclfil, pfpmcl, 'F', 'S');
  141.   getmcldat(mclfil, *pfpmcl);
  142.   fclose(*pfpmcl);
  143. #if (PC && (DEBUG > 4))
  144.   clrscr1(1);
  145.   gotoxy(1, 5);
  146.   cprintf("%sgot sdrat stg/seq/mcl data", tab);
  147.   gotoxy (1, 7);
  148.   cprintf("%sval1=%d  val2=%d  val3=%d", tab, val1, val2, val3);
  149.   hitreturn(1);
  150. #endif
  151.  
  152.   if (val1 || val2 || val3) {
  153.     return(101);    /* back to general menu */
  154.   } else {
  155. #if (DEBUG > 4)
  156. #if PC
  157.     clrscr1(1);
  158.     gotoxy(1, 5);
  159.     cprintf("%sgetanimal: free(Animal)", tab);
  160.     gotoxy(1, 7);
  161.     cprintf("%s           Animal = <%s>", tab, Animal);
  162.     hitreturn(1);
  163. #else
  164.     printf("\tgetanimal: free(Animal)\n");
  165. #endif
  166. #endif
  167.     free1(Animal);
  168.     Animal = strdup(tmpstr);  /* does AUTOmagic malloc */
  169.     if (Animal==NULL) {
  170. #if PC
  171.       clrscr1(1);
  172.       gotoxy(1, 5);
  173.       cprintf("%sgetanimal:  strdup returns NULL on Animal", tab);
  174. #else
  175.       printf("\tgetanimal:  strdup returns NULL on Animal\n");
  176. #endif
  177.       printexit(401);
  178.     } /* if */
  179.     strcpy(Animal, tmpstr);
  180. #if (DEBUG > 4)
  181. #if PC
  182.     clrscr1(1);
  183.     gotoxy(1, 5);
  184.     cprintf("%sgetanimal:  Animal=<%s>", tab, Animal);
  185.     hitreturn(1);
  186. #else
  187.     printf("\tgetanimal:  Animal=<%s>\n", Animal);
  188. #endif
  189. #endif
  190.     return(0);
  191.   } /* else */
  192. } /* getanimal */
  193.