allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (07/19/89)
Posting-number: Volume 7, Issue 85 Submitted-by: loy@gtx.UUCP (Bob Loy) Archive-name: whpl/part12 # whpl12of13.shar #---cut here---cut here---cut here---cut here---cut here--- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files. # This archive created: Sat Jan 14 04:05:23 MST 1989 export PATH; PATH=/bin:$PATH echo shar: extracting "'symmet.c'" '(25953 characters)' if test -f 'symmet.c' then echo shar: will not over-write existing file "'symmet.c'" else sed 's/^X//' << \SHAR_EOF > 'symmet.c' X X#ifndef lint X static char sccsid[] = " %M% %I% "; X static char dateid[] = " %E% "; X#endif X X/*@#==========================================================================* X@@# X@@@#@^ symmet.c X@# X@# Purpose: X@@# Multiplies whales by 4, shifting genesets 90, 180, & 270 degrees, X@@# and/or multiplies whales by 2, creating whale(s) of opposite sex. X@# X@#@^Options: X@#@^ -g takes each whale from input file and writes out: it, and three new X@#@^ whales with rotated genes. This is also the default if neither X@#@^ -g nor -s is specified. X@#@^ -s takes each whale from input file and writes out: it, and one new X@#@^ whale of the opposite sex. X@#@^ Both the above used together will create 7 new whales for each input X@#@^ whale, two sexes for both the original and rotated gene sets. X@#@^ -i infile name. Must be specified. X@#@^ -o outfile name, optional. See Examples for default. X@#@^ -r similar to the -r opt in whpl.c. Adds to DATRUN in whpl.h. X@#@^ X@# Examples: X@# symmet -i infile -o outfile -s X@# sex-clones only in outfile, no gene-clones X@# symmet -i infile -r 1704 X@# output file will be similar to whpl.c "whc" & "whs" files; lead- X@# ing string will be "whg"; e.g., whg121704, a file of gene-clones. X@# X@# Compiling: X@# cc -O symmet.c -o symmet X@# X@# Dependencies: X@# whpl.h, include file X@# X@# Functions: X@# void gophandle(); X@# void whalewrite(); X@# void checkwhale(); X@# void whaleread(); X@# void genesex(); X@# void main(); X@# X@# General Comments: X@# The name of this program is short for "symmetry." Most whales' X@# genesets will have a tendency to move the whale in one of the four X@# directions. This program will create "clones" of whales read from X@# a file which have the genesets "rotated" to the other three possible X@# directions. Both the original whale and clones are written out to X@# a new file. X@# As a further option, "sex-clones" can also be output. The genes are X@# the same, but the sex of the new whale is oppoosite. The theory X@# behind this is that males and females have somewhat different mating X@# opportunities. Successful females produce offspring more steadily, X@# once per mating cycle, while a successful male may nevertheless go X@# a few cycles without mating at all, and then produce many offspring X@# all at once. Giving two whales the same genes but opposite sex X@# reduces the element of luck for those genes. X@# In order to create unique whale ID's, certain changes must be made to X@# the new cloned whales' ID strings. X@# For gene-cloned whales, the mutate field for all whales, including the X@# original one, is incremented to 2000000000. Also the "clonees" X@# have their gennum field incremented by 100000000, 200000000, & X@# 300000000, respectively, to create unique ID's. X@# For sex-cloned whales, the gennum field for the orignial whale is in- X@# cremented to 2000000000, while the clonee's is bumped to 3000000000. X@# Admittedly, changing any field in the original whale makes it a "diff- X@# erent" whale. That is why only the highest order, easily checked X@# digit in either the gennum or mutate field is affected for this X@# whale. But changing these fields allows this program to warn if X@# this whale is ever used for cloning purposes again. X@# X@# Note: Makes all whales in output file "Live," even if they were dead X@# in the original file. The program automatically multiplies the X@# Number & Live fields in the output file header by 2, 4, or 8. X@# X@#---------------------------------------------------------------------------*/ X X/*---------------------------------------------------------------------------* X Top-level Declaration - includes, defines, externs & globals. X*----------------------------------------------------------------------------*/ X X#include <stdio.h> X#include "whpl.h" X X /* EXTERNS FROM */ X /* Functions From libraries: */ X extern char *malloc(); X extern FILE *fopen(); X extern int fclose(); X X /* GLOBALS */ X static whale_type *whale; /* Start of array of whale structs */ X static Uint whale_size = sizeof(whale_type); /* Whale struct size */ X static Uint limit; X static int debug = 5; /* Debug level from 0 - 9; 9 prints all */ X static int daterun = DATRUN; /* ID stamp for output filename */ X static FILE *whin; /* Pointer to whale input file */ X static char whinfile[40]; /* Holds name of whale in-file */ X static char whinstr[99]; /* For lines read from whale in-file */ X static FILE *whou; /* Pointer to whale output file */ X static char whoutfile[40]; /* Holds name of whale out-file */ X static short infileflg = FALSE; X static short outfileflg = FALSE; X static short geneflg = FALSE; X static short sexflg = FALSE; X static Uint selfd; X static Uint selfg; X static Uint selfm; X static char genes[7]; X static char die[2]; X static char sex[2]; X static int age; X static int ofr; X static int rtg; X static int erec[20]; X static short edex; X static short hg[16]; X static short fg[16]; X static int lsr; X static short df[20]; X static short tl[20]; X static short rk[20]; X static int asav; X static short amax; X static short amin; X static Uint fathd; X static Uint fathg; X static Uint fathm; X static char fgns[7]; X static Uint mothd; X static Uint mothg; X static Uint mothm; X static char mgns[7]; X static short chidex; X static short alchldn; X static Uint ofd[50]; X static Uint ofg[50]; X static Uint ofm[50]; X static char ogns[50][7]; X static char cgns[7]; X X X/*---------------------------------------------------------------------------* X@ X@@ void gophandle(argc, argv); Decipher command line arguments. X@ output: Sets flags & loads values into variables X@ caller: main() X@ calls : getopt(), may call exit() X@ X@*---------------------------------------------------------------------------*/ X Xvoid Xgophandle(argc, argv) X int argc; X char *argv[]; X{ X extern int optind; X extern char *optarg; X int cc; X int run; X X /* check command line arguments */ X while ((cc = getopt(argc, argv, "gi:o:r:s")) != EOF) X switch(cc) X { X case 'g': X case 'G': X geneflg = TRUE; X break; X case 'i': X case 'I': X strncpy(whinfile, optarg, 39); X infileflg = TRUE; X break; X case 'o': X case 'O': X strncpy(whoutfile, optarg, 39); X outfileflg = TRUE; X break; X case 's': X case 'S': X sexflg = TRUE; X break; X case 'r': X case 'R': X run = atoi(optarg); X daterun += run; X break; X default: X if (debug >= 1) X { X fprintf(stderr, "\n"); X fprintf(stderr, "usage: "); X fprintf(stderr, X "symmet -i<input file name> -o<output file name>\n"); X fprintf(stderr, X " -g(do genes) -s(do sex) -r<run number>\n"); X fprintf(stderr, "\n"); X } X exit(2); X break; X } X} X X/*---------------------------------------------------------------------------* X@ X@@ void whalewrite(whale number, whale, fname, limit); Outputs whale record. X@ input : Individual whale number, file for output X@ output: See "WHALE FILE BODY" note in fileout() in whio.c X@ caller: genesex() X@ calls : fprintf() X@ X@*---------------------------------------------------------------------------*/ X Xvoid Xwhalewrite(num, j, whout, lim) X int num; X int j; X FILE *whout; X short lim; X{ X register int k; X char genes[7]; X X genes[0] = whale[j].hunttype; X genes[1] = whale[j].hgperchr; X genes[2] = whale[j].feedtype; X genes[3] = whale[j].fgperchr; X genes[4] = whale[j].countgene; X genes[5] = whale[j].extragene; X genes[6] = '\0'; X if (!lim) X { X fprintf(whout, "\n# %4d", num); X fprintf(whout, "\nwh "); X } X fprintf(whout, " %10u", whale[j].self.datrun); X fprintf(whout, " %10u", whale[j].self.gennum); X fprintf(whout, " %10u", whale[j].self.mutate); X fprintf(whout, " %s", genes); X fprintf(whout, "\n"); X if (lim) X return; X fprintf(whout, " L"); X fprintf(whout, " %c", whale[j].sex); X fprintf(whout, " %3d", whale[j].age); X fprintf(whout, " %5d", whale[j].offratio); X fprintf(whout, " %7d", whale[j].rating); X fprintf(whout, "\n"); X fprintf(whout, " "); X for (k = 0; k < 16; k++) X fprintf(whout, " %2hd", whale[j].huntgene[k]); X fprintf(whout, "\n"); X fprintf(whout, " "); X for (k = 0; k < 16; k++) X fprintf(whout, " %2hd", whale[j].feedgene[k]); X fprintf(whout, "\n"); X fprintf(whout, "en "); X fprintf(whout, " %2hd\n", whale[j].endex); X for (k = 0; k < whale[j].endex; k++) X fprintf(whout, " %7d\n", whale[j].enrec[k]); X fprintf(whout, "rat "); X fprintf(whout, " %7d\n", whale[j].lastrat); X for (k = 0; k < 4; k++) X fprintf(whout, "%6hd %3hd %4hd ", whale[j].comp[k].diff, X whale[j].comp[k].totl, whale[j].comp[k].rank); X fprintf(whout, "\n"); X for (k = 4; k < 8; k++) X fprintf(whout, "%6hd %3hd %4hd ", whale[j].comp[k].diff, X whale[j].comp[k].totl, whale[j].comp[k].rank); X fprintf(whout, "\n"); X for (k = 8; k < 12; k++) X fprintf(whout, "%6hd %3hd %4hd ", whale[j].comp[k].diff, X whale[j].comp[k].totl, whale[j].comp[k].rank); X fprintf(whout, "\n"); X for (k = 12; k < 16; k++) X fprintf(whout, "%6hd %3hd %4hd ", whale[j].comp[k].diff, X whale[j].comp[k].totl, whale[j].comp[k].rank); X fprintf(whout, "\n"); X for (k = 16; k < 20; k++) X fprintf(whout, "%6hd %3hd %4hd ", whale[j].comp[k].diff, X whale[j].comp[k].totl, whale[j].comp[k].rank); X fprintf(whout, "\n"); X fprintf(whout, "anc "); X fprintf(whout, " %7d", whale[j].ancesave); X fprintf(whout, " %3hd", whale[j].ancesmax); X fprintf(whout, " %3hd", whale[j].ancesmin); X fprintf(whout, "\n"); X fprintf(whout, " %10u", whale[j].father.datrun); X fprintf(whout, " %10u", whale[j].father.gennum); X fprintf(whout, " %10u", whale[j].father.mutate); X fprintf(whout, " %s", whale[j].father.gns); X fprintf(whout, "\n"); X fprintf(whout, " %10u", whale[j].mother.datrun); X fprintf(whout, " %10u", whale[j].mother.gennum); X fprintf(whout, " %10u", whale[j].mother.mutate); X fprintf(whout, " %s", whale[j].mother.gns); X fprintf(whout, "\n"); X fprintf(whout, "off "); X fprintf(whout, " %2hd", whale[j].childex); X fprintf(whout, " %4hd", whale[j].allchldn); X fprintf(whout, "\n"); X for (k = 0; k < whale[j].childex; k++) X { X fprintf(whout, " %10u", whale[j].offspr[k].datrun); X fprintf(whout, " %10u", whale[j].offspr[k].gennum); X fprintf(whout, " %10u", whale[j].offspr[k].mutate); X fprintf(whout, " %s\n", whale[j].offspr[k].gns); X } X fprintf(whout, "\n"); X} X X/*---------------------------------------------------------------------------* X@ X@@ void checkwhale(); Checks to see if whale has been cloner/clonee before. X@ output: Warning message X@ caller: whaleread() X@ X@*---------------------------------------------------------------------------*/ X Xvoid Xcheckwhale(j) X int j; X{ X if (sexflg) X { X if (whale[j].self.gennum >= 2000000000) X { X if (debug >= 2) X { X fprintf(stderr, "\ncheckwhale(): whale.gennum = %u\n", X whale[j].self.gennum); X fprintf(stderr, X " This whale already sex-cloned at one time!\n"); X fprintf(stderr, X " Program output may duplicate previous whales.\n"); X } X } X } X if (geneflg) X { X if (whale[j].self.mutate >= 2000000000) X { X if (debug >= 2) X { X fprintf(stderr, "\ncheckwhale(): whale.mutate = %u\n", X whale[j].self.mutate); X fprintf(stderr, X " This whale already gene-cloned at one time!\n"); X fprintf(stderr, X " Program output may duplicate previous whales.\n"); X } X } X } X} X X/*---------------------------------------------------------------------------* X@ X@@ void whaleread(whale, how); Fills whale structures. From whpl.c. X@ output: Filled structure for given whale X@ caller: main() X@ calls : checkwhale(); fgets(), sscanf() X@ X@*---------------------------------------------------------------------------*/ X Xvoid Xwhaleread(j, how) X register int j; X short how; X{ X register int k; X static char blankgns[7] = " "; X X if (how == 1) X { X fgets(whinstr, 97, whin); X sscanf(whinstr, "%*s%u%u%u%s", X &selfd, &selfg, &selfm, genes); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%s%s%d%d%d", die, sex, &age, &ofr, &rtg); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd", X &hg[0],&hg[1],&hg[2],&hg[3],&hg[4],&hg[5],&hg[6],&hg[7], X &hg[8],&hg[9],&hg[10],&hg[11],&hg[12],&hg[13],&hg[14],&hg[15]); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd", X &fg[0],&fg[1],&fg[2],&fg[3],&fg[4],&fg[5],&fg[6],&fg[7], X &fg[8],&fg[9],&fg[10],&fg[11],&fg[12],&fg[13],&fg[14],&fg[15]); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%*s%hd", &edex); X for (k = 0; k < edex; k++) X { X fgets(whinstr, 97, whin); X sscanf(whinstr, "%d", &erec[k]); X } X fgets(whinstr, 97, whin); X sscanf(whinstr, "%*s%d", &lsr); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd", X &df[0],&tl[0],&rk[0], &df[1],&tl[1],&rk[1], X &df[2],&tl[2],&rk[2], &df[3],&tl[3],&rk[3]); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd", X &df[4],&tl[4],&rk[4], &df[5],&tl[5],&rk[5], X &df[6],&tl[6],&rk[6], &df[7],&tl[7],&rk[7]); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd", X &df[8],&tl[8],&rk[8], &df[9],&tl[9],&rk[9], X &df[10],&tl[10],&rk[10], &df[11],&tl[11],&rk[11]); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd", X &df[12],&tl[12],&rk[12], &df[13],&tl[13],&rk[13], X &df[14],&tl[14],&rk[14], &df[15],&tl[15],&rk[15]); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd%hd", X &df[16],&tl[16],&rk[16], &df[17],&tl[17],&rk[17], X &df[18],&tl[18],&rk[18], &df[19],&tl[19],&rk[19]); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%*s%d%hd%hd", &asav, &amax, &amin); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%u%u%u%s", &fathd, &fathg, &fathm, fgns); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%u%u%u%s", &mothd, &mothg, &mothm, mgns); X fgets(whinstr, 97, whin); X sscanf(whinstr, "%*s%hd%hd", &chidex, &alchldn); X for (k = 0; k < chidex; k++) X { X fgets(whinstr, 97, whin); X sscanf(whinstr, "%u%u%u%s", &ofd[k], &ofg[k], &ofm[k], cgns); X strncpy(&ogns[k][0], cgns, 7); X } X /* Begin assigning input to whale[j]: */ X for (k = 0; k < 20; k++) X { X if (k < edex) X whale[j].enrec[k] = erec[k]; X else X whale[j].enrec[k] = 0; X } X if (edex == 20) X { X if (debug >= 2) X { X fprintf(stderr, X "\nwhaleload(): wh[%d].enrec array is FULL\n", j); X fprintf(stderr, " *** WILL OVERWRITE IN PROGRAM ***\n"); X } X edex = 19; X } X whale[j].endex = edex; X whale[j].age = age; X whale[j].sex = sex[0]; X for (k = 0; k < 20; k++) X { X whale[j].comp[k].diff = df[k]; X whale[j].comp[k].totl = tl[k]; X whale[j].comp[k].rank = rk[k]; X } X whale[j].ancesave = asav; X whale[j].ancesmax = amax; X whale[j].ancesmin = amin; X whale[j].father.datrun = fathd; X whale[j].father.gennum = fathg; X whale[j].father.mutate = fathm; X strncpy(whale[j].father.gns, fgns, 7); X whale[j].mother.datrun = mothd; X whale[j].mother.gennum = mothg; X whale[j].mother.mutate = mothm; X strncpy(whale[j].mother.gns, mgns, 7); X whale[j].self.datrun = selfd; X whale[j].self.gennum = selfg; X whale[j].self.mutate = selfm; X strncpy(whale[j].self.gns, genes, 7); X if (chidex == 49) X { X if (debug >= 2) X { X fprintf(stderr, X "\nwhaleload(): wh[%d].offspr array is FULL\n", j); X fprintf(stderr, " *** MAY WRAP AROUND IN PROGRAM ***\n"); X } X } X for (k = 0; k < 50; k++) X { X if (k < chidex) X { X whale[j].offspr[k].datrun = ofd[k]; X whale[j].offspr[k].gennum = ofg[k]; X whale[j].offspr[k].mutate = ofm[k]; X strncpy(whale[j].offspr[k].gns, &ogns[k][0], 7); X } X else X { X whale[j].offspr[k].datrun = 0; X whale[j].offspr[k].gennum = 0; X whale[j].offspr[k].mutate = 0; X strncpy(whale[j].offspr[k].gns, blankgns, 7); X } X } X whale[j].childex = chidex; X whale[j].allchldn = alchldn; X whale[j].hunttype = genes[0]; X whale[j].hgperchr = genes[1]; X whale[j].feedtype = genes[2]; X whale[j].fgperchr = genes[3]; X for (k = 0; k < 16; k++) X whale[j].huntgene[k] = hg[k]; X for (k = 0; k < 16; k++) X whale[j].feedgene[k] = fg[k]; X whale[j].countgene = genes[4]; X whale[j].extragene = genes[5]; X } X whale[j].sortfield = 0; X whale[j].energy = 1000000; X whale[j].die = 0; X whale[j].offratio = 0; X whale[j].rating = 0; X whale[j].lastrat = 0; X whale[j].huntdex = 0; X whale[j].feeddex = 0; X whale[j].lastfed = 1000000; X whale[j].huntfeed = 'H'; X whale[j].locatn = 0; X checkwhale(j); X /* Change structure fields to 2XXXXXXXXX to show cloning */ X if (geneflg) X whale[j].self.mutate += 1000000000; X if (sexflg) X whale[j].self.gennum += 1000000000; X} X X/*---------------------------------------------------------------------------* X@ X@@ void genesex(); Sets up genes and sexes for cloned whales for output. X@ input : globals geneflg, sexflg X@ caller: main() X@ calls : whalewrite() X@ X@*---------------------------------------------------------------------------*/ X Xvoid Xgenesex() X{ X register int j, k; X static int wh = 0; X short gen; X X if (sexflg) X { X if (whale[0].sex == 'M') X { X whale[1].sex = 'F'; X } X else if (whale[0].sex == 'F') X { X whale[1].sex = 'M'; X } X whale[1].self.gennum += 1000000000; X } X if (geneflg && sexflg) X { X if (whale[0].sex == 'M') X { X whale[3].sex = 'F'; X whale[5].sex = 'F'; X whale[7].sex = 'F'; X } X else if (whale[0].sex == 'F') X { X whale[3].sex = 'M'; X whale[5].sex = 'M'; X whale[7].sex = 'M'; X } X whale[3].self.gennum += 1000000000; X whale[5].self.gennum += 1000000000; X whale[7].self.gennum += 1000000000; X } X if (geneflg && sexflg) X { X gen = 1; X for (j = 2; j < limit; j += 2) X { X for (k = 0; k < 16; k++) X { X hg[k] += 16; X if (hg[k] > 63) X hg[k] = hg[k] - 64; X whale[j].huntgene[k] = hg[k]; X whale[j + 1].huntgene[k] = hg[k]; X fg[k] += 16; X if (fg[k] > 63) X fg[k] = fg[k] - 64; X whale[j].feedgene[k] = fg[k]; X whale[j + 1].feedgene[k] = fg[k]; X } X whale[j].self.gennum += 100000000 * gen; X whale[j + 1].self.gennum += 100000000 * gen; X gen++; X } X } X else if (geneflg) X { X for (j = 1; j < limit; j++) X { X for (k = 0; k < 16; k++) X { X hg[k] += 16; X if (hg[k] > 63) X hg[k] = hg[k] - 64; X whale[j].huntgene[k] = hg[k]; X fg[k] += 16; X if (fg[k] > 63) X fg[k] = fg[k] - 64; X whale[j].feedgene[k] = fg[k]; X } X whale[j].self.gennum += 100000000 * j; X } X } X for (j = 0; j < limit; j++) X whalewrite(wh + j, j, whou, 0); X wh += limit; X} X X/*---------------------------------------------------------------------------* X@ X@@ void main(argc, argv); Calling function for symmet.c X@ input : Constants from whpl.h and command line arguments. X@ calls : gophandle(), whaleread() genesex(); malloc(), fopen(), exit() X@ X@*---------------------------------------------------------------------------*/ X Xvoid Xmain(argc, argv) X int argc; X char *argv[]; X{ X register int k; X int j = FNMTRUNC - 1; X char datr[11]; X char temp[11]; X short numinfile = 0; X short livinfile = 0; X char *test = whinstr; X short foundin = 0; X short firstflg = TRUE; X Uint numwh = NUMWH; X X gophandle(argc, argv); /* Handle command line arguments */ X if (!geneflg && !sexflg) X geneflg = TRUE; X if (!outfileflg) X { X if (debug >= 4) X fprintf(stderr, "\n No output file specified on command line\n"); X sprintf(temp, "%8u", daterun); X do{ X j++; X datr[j - FNMTRUNC] = temp[j]; X } while (temp[j] != '\0'); X strcat(whoutfile, "whg"); X strcat(whoutfile, datr); X if (debug >= 4) X fprintf(stdout, " output filename: %s\n", whoutfile); X } X if ((whou = fopen(whoutfile, "w")) == NULL) X if (debug >= 2) X fprintf(stderr, "\n WARNING: did not open output file %s\n\n"); X/* FOR TEST: X whou = stdout; X*/ X if (infileflg) /* Read one input whale file */ X { X if ((whin = fopen(whinfile, "r")) != NULL) X { X while ((test = fgets(whinstr, 97, whin)) != NULL) X { X if (whinstr[0] == '#') X { X test = fgets(whinstr, 97, whin); X if (whinstr[0] == 'w' && whinstr[1] == 'h') X { X test = NULL; X break; X } X else X { X fprintf(stderr, "\n Bad Input Whale File\n"); X fprintf(stderr, " Program exiting.\n\n"); X exit(1); X } X } X if (firstflg) X fputs(whinstr, whou); X if (whinstr[2] == 'I' && whinstr[3] == 'N') X { X foundin++; X break; X } X } X if (test == NULL) X rewind(whin); X } X else X { X if (debug >= 2) X { X fprintf(stderr, "\n WARNING: did not open input file %s\n\n", X whinfile); X fprintf(stderr, " Program exiting.\n\n"); X } X exit(1); X } X } X else X { X if (debug >= 2) X { X fprintf(stderr, "\n No INPUT FILE specified on command line\n"); X fprintf(stderr, " Program exiting.\n\n"); X } X exit(1); X } X if (!foundin) X { X if (debug >= 2) X fprintf(stderr, "\n Warning: not a standard Whale File\n"); X } X /* Make room for whales */ X if (geneflg && sexflg) X limit = 8; X else if (geneflg) X limit = 4; X else if (sexflg) X limit = 2; X whale = (whale_type *) malloc(limit * whale_size); X if (whale == NULL) X { X if (debug >= 2) X fprintf(stderr, "\nWhale malloc problems.\n"); X exit(9); X } X /* Read in whales from file if proper flags set */ X j = 0; X k = 0; X while (fgets(whinstr, 97, whin) != NULL) X { X if (whinstr[0] == '#') X firstflg = 0; X if (firstflg) X { X if (whinstr[4] == 'N' && whinstr[5] == 'u') X { X sscanf(whinstr, "%*s%hd", &numinfile); X if (geneflg) X numinfile *= 4; X if (sexflg) X numinfile *= 2; X fprintf(whou, " Number %4d\n", numinfile); X k++; X } X if (whinstr[4] == 'L' && whinstr[5] == 'i') X { X fprintf(whou, " Live %4d\n", numinfile); X k++; X } X if (!k) X fputs(whinstr, whou); X k = 0; X } X if (whinstr[0] == '#') /* Found a whale */ X { X whaleread(j, 1); /* Fill whale struct from whale file rec */ X if (geneflg && sexflg) X whale[j + 7] = whale[j + 6] = whale[j + 5] = whale[j + 4] = X whale[j + 3] = whale[j + 2] = whale[j + 1] = whale[j]; X else if (geneflg) X whale[j + 3] = whale[j + 2] = whale[j + 1] = whale[j]; X else if (sexflg) X whale[j + 1] = whale[j]; X genesex(); X } X } X fclose(whin); X fclose(whou); X if (debug >= 4) X fprintf(stdout, "\nFINISHED\n\n"); X} SHAR_EOF if test 25953 -ne "`wc -c < 'symmet.c'`" then echo shar: error transmitting "'symmet.c'" '(should have been 25953 characters)' fi fi # end of overwriting check # End of shell archive exit 0 --- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Bob Loy | Life is the detour you take on the ...!sun!sunburn!gtx!loy | way to where you're really going. | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~