From: astrolog@byron.u.washington.edu (Astrolog)
Newsgroups: alt.astrology
Subject: * Astrolog birthchart program version 2.30 [Part 09/12] driver.c
Summary: (Sagittarius) Source file - extract and save to "driver.c"
Keywords: Astrolog 2.30
Date: 12 Sep 92 03:12:42 GMT
Organization: University of Washington

/*
** Astrolog (Version 2.30) File: driver.c
*/

#include "astrolog.h"

char *filenameout, **extralines;
int prog = FALSE, extracount = 0;

/*
*******************************************************************************
** Option processing
*******************************************************************************
*/

/* Print a list of every command switch that can be passed to the program, */
/* and a description of what it does. This is what the -H switch prints.   */

displayswitches()
{
  printf("Astrolog command switches (version %s) (%s):\n", VERSION, DATE); 
  printf(" -H: Display this help message.\n");
  printf(" -H0: Display names of zodiac signs and houses.\n");
  printf(" -O: Display available planets and other celestial objects.\n");
  printf(" -O0: Like -O but ignore any restrictions.\n");
  printf(" -A: Display available aspects, their angles, and present orbs.\n");
  printf(" -I0 Display meanings of signs, houses, planets, and aspects.\n\n");
  printf("Switches which determine in what format the chart is displayed:\n");
  printf(" -v: Display list of object positions (chosen by default).\n");
  printf(" -v0: Like -v but express velocities relative to average speed.\n");
  printf(" -vI: Interpret meaning of each planet/sign/house placement.\n");
  printf(" -w: Display chart on screen in a graphic house wheel format.\n");
  printf(" -w0: Like -w but show objects in houses 4..9 in reverse order.\n");
  printf(" -g: Display aspect and midpoint grid among planets.\n");
  printf(" -g0: Like -g but flag aspect configurations (e.g. Yod's) too.\n");
  printf(" -g0: For comparison charts, show midpoints instead of aspects.\n");
  printf(" -ga: Like -g but indicate applying instead of difference orbs.\n");
  printf(" -gI: Print interpretation of each aspect between planets.\n");
  printf(" -Z: Display planet locations with respect to the local horizon.\n");
#ifdef GRAPH
  printf(" -Z0: For graphics charts, like -Z but have a polar center.\n");
#endif
  printf(" -S: Display x,y,z coordinate positions of planets in space.\n");
  printf(" -I: Display interpretation of planetary influences.\n");
  printf(" -L [<step>]: Display astro-graph locations of planetary angles.\n");
  printf(" -L0 [..]: Like -L but display list of latitude crossings too.\n");
  printf(" -d: Print all aspects and changes occurring in a day.\n");
  printf(" -d0: Like -d but print all aspects for the entire month.\n");
  printf(" -dp <month> <year>: Print aspects within progressed chart.\n");
  printf(" -e: Print all options for chart (i.e. -v-w-g0-Z-S-I-L0-d).\n\n");
  printf("Switches which affect how the chart parameters are obtained:\n");
#ifdef TIME
  printf(" -n: Compute chart for this exact moment using current time.\n");
#endif
  printf(" -a <month> <date> <year> <time> <zone> <long> <lat>:\n");
  printf("     Compute chart automatically given specified data.\n");
  printf(" -z: Assume Daylight time (change default zone appropriately).\n");
  printf(" -z <zone>: Change the default time zone (for -d-q-T-E options).\n");
  printf(" -l <long> <lat>: ");
  printf("Change the default longitude & latitude.\n");
  printf(" -q <month> <date> <year>: Compute chart for noon on date.\n");
  printf(" -q0 <month> <date> <year> <time>: Like -q but include time too.\n");
  printf(" -i <file>: Compute chart based on info in file.\n");
  printf(" -o <file> [..]: Write parameters of current chart to file.\n");
  printf(" -o0 <file> [..]: Like -o but output planet/house positions.\n\n");
  printf("Switches which affect what information is used in a chart.\n");
  printf(" -R [<obj1> [<obj2> ..]: Restrict specific bodies from displays.\n");
  printf(" -R0 [<obj1> ..]: Like -R but restrict everything first.\n");
  printf(" -R[C,u,U]: Restrict all minor cusps, all uranians, or stars.\n");
  printf(" -C: Include non-angular house cusps in charts.\n");
  printf(" -u: Include transneptunian/uranian bodies in charts.\n");
  printf(" -U: Include locations of fixed background stars in charts.\n");
  printf(" -U[z,l,n,b]: Order by azimuth, altitude, name, or brightness.\n");
  printf(" -A <0-18>: Specify the number of aspects to use in program.\n");
  printf(" -Ao <aspect> <orb>: Specify maximum orb for an aspect.\n");
  printf(" -Am <planet> <orb>: Specify maximum orb allowed to a planet.\n");
  printf(" -Ad <planet> <orb>: Specify orb addition given to a planet.\n\n");
  printf("Switches which affect how a chart is computed:\n");
  printf(" -c <value>: Select a different default system of houses.\n");
  printf("     (0 = Placidus, 1 = Koch, 2 = Equal, 3 = Campanus,\n");
  printf("     4 = Meridian, 5 = Regiomontanus, 6 = Porphry, 7 = Morinus,\n");
  printf("     8 = Topocentric, 9 = None.)\n");
  printf(" -s: Compute a siderial instead of the normal tropical chart.\n");
  printf(" -s0: Display locations as right ascension instead of degrees.\n");
  printf(" -h [<objnum>]: Compute positions centered on specified object.\n");
  printf(" -p <month> <day> <year>: Cast progressed chart based for date.\n");
#ifdef TIME
  printf(" -pn: Cast progressed chart based on current date now.\n");
#endif
  printf(" -p0 <days>: Set no. of days to progress / day (default 365.25).\n");
  printf(" -x <1-360>: Cast harmonic chart based on specified factor.\n");
  printf(" -1 [<objnum>]: Cast chart with specified object on ascendant.\n");
  printf(" -2 [<objnum>]: Cast chart with specified object on midheaven.\n");
  printf(" -3: Display objects in their zodiac decan positions.\n");
  printf(" -f: Display houses as sign positions (flip them).\n");
  printf(" -G: Display houses based on geographic location only.\n");
  printf(" -F <objnum> <sign> <deg>: Force object's position to be value.\n");
  printf(" -+ <days>: Cast chart for specified no. of days in the future.\n");
  printf(" -- <days>: Cast chart for specified no. of days in the past.\n\n");
  printf("Other features or major modes:\n");
  printf(" -r <file1> <file2>: Compute a relationship synastry chart.\n");
  printf(" -rc <file1> <file2>: Compute a composite chart.\n");
  printf(" -rm <file1> <file2>: Compute a time space midpoint chart.\n");
  printf(" -rd <file1> <file2>: Print number of days between files' dates.\n");
  printf(" -rb <file1> <file2>: Display biorythm for file1 at time file2.\n");
  printf(" -r0 <file1> <file2>: Keep the charts separate in comparison.\n");
#ifdef TIME
  printf(" -t <file>: Display current house transits for particular chart.\n");
  printf(" -t[b|d] <file>: Print biorythm/datediff for current time now.\n");
#endif
  printf(" -T <file> <month> <year>: ");
  printf("Compute all transits in month for chart.\n");
  printf(" -T0 <..>: Like -T but include transits of the Moon as well.\n");
  printf(" -Tp <file> <month> <year>: ");
  printf("Compute progressions in month for chart.\n");
  printf(" -E <month> <year>: Display planetary ephemeris for given month.\n");
  printf(" -E0 <..>: Like -E but include all unrestricted bodies.\n");

  /* If X window features are compiled in, call an additional procedure to */
  /* display the command switches offered dealing with the graphics stuff. */

#ifdef GRAPH
  xdisplayswitches();
#endif
}


/* Print out a list of the various objects - planets, asteroids, house     */
/* cusps, stars - recognized by the program, and their index values. This  */
/* is displayed when the -O switch is invoked. For some objects, display   */
/* additional information, e.g. ruling signs for planets, brightnesses and */
/* positions in the sky for fixed stars, etc.                              */

printobjects(all)
int all;
{
  int i, j;
  double Off;
  if (!cusp)
    for (i = C_LO; i <= C_HI; i++)    /* Set up restrictions properly: Minor */
      ignore[i] = TRUE;               /* cusps and uranians included only if */
  if (!uranian)                       /* -C and -u switches are in effect.   */
    for (i = U_LO; i <= U_HI; i++)
      ignore[i] = TRUE;
  printf("Astrolog planets and objects:\n");
  printf("No. Name       Rule Co-Rule Fall Co-Fall Exalt Debilitate\n\n");
  for (i = 1; i <= BASE; i++) if (all || !ignore[i]) {
    printf("%2d %-12s", i, objectname[i]);
    if (i <= OBJECTS) {                      /* Print rulerships, etc */
      if (ruler1[i]) {                       /* for the planets.      */
	j = ruler2[i];
	printf("%c%c%c  %c%c%c     ", SIGNAM(ruler1[i]),
	       j ? signname[j][0] : ' ', j ? signname[j][1] : ' ',
	       j ? signname[j][2] : ' ');
	printf("%c%c%c  %c%c%c     ", SIGNAM(mod12(ruler1[i]+6)),
	       j ? signname[mod12(j+6)][0] : ' ',
	       j ? signname[mod12(j+6)][1] : ' ',
	       j ? signname[mod12(j+6)][2] : ' ');
	printf("%c%c%c   %c%c%c", SIGNAM(exalt[i]),
	       SIGNAM(mod12(exalt[i]+6)));
      }
    } else if (i <= C_HI)
      printf("Minor House Cusp #%d", i-OBJECTS);
    else
      printf("Uranian #%d", i-U_LO+1);
    putchar('\n');
  }

  /* Now, if -U in effect, read in and display stars in specified order. */

  if (all || universe) {
    Off = processinput(TRUE);
    caststar(siderial ? 0.0 : -Off);
    for (i = S_LO; i <= S_HI; i++) if (all | !ignore[i]) {
      j = BASE+starname[i-BASE];
      printf("%2d %-12s", i, objectname[j]);
      printf("Star #%2d    ", i-BASE);
      printminute(planet[j]);
      printf("  ");
      printaltitude(planetalt[j]);
      printf(" %5.2f\n", starbright[j-BASE]);
    }
  }
}


/* Print out a list of all the aspects recognized by the program, and info  */
/* about them: their names, index numbers, degree angles, present orbs, and */
/* the description of their glyph. This gets displayed when the -A switch   */
/* is invoked (without any argument).                                       */

printaspects()
{
  static char *aspectglyph[]
    = {"", "Circle with extending line", "Two circles joined by line",
	 "Quadrilateral", "Triangle", "Six pointed asterisk",
	 "'K' rotated right", "'K' rotated left", "Acute angle",
	 "Square with extending lines", "Letter 'Q'", "'+' over '-'",
	 "'-' over '+'", "Number '7'", "Number '9'", "'9' under Roman 'II'",
	 "'7' under Roman 'II'", "'7' under Roman 'III'",
	 "'9' under Roman 'IV'"};
  int i;
  printf("Astrolog aspects:\nNo. Name         Abbrev. Angle    Orb");
  printf("          Description of glyph\n\n");
  for (i = 1; i <= ASPECTS; i++)
    printf("%2d %-15s(%s) %6.2f +/- %1.0f degrees - %s\n", i, aspectname[i],
	   aspectabbrev[i], aspectangle[i], aspectorb[i], aspectglyph[i]);
}


/* Print out a list of the 12 signs and houses of the zodiac, and their    */
/* standard and traditional names, as done when the -H0 switch is invoked. */

printsigns()
{
  static char *signenglish[]
    = {"", "Ram", "Bull", "Twins", "Crab", "Lion", "Virgin",
	 "Scales", "Scorpion", "Archer", "Sea-Goat", "Water-Bearer", "Fishes"};
  static char *housetradition[]
    = {"", "Personality", "Money", "Communication", "Home",
	 "Children", "Servants", "Marriage", "Death",
	 "Long Journeys Over Water", "Career", "Friends", "Troubles"};

  int i;
  printf("Astrolog signs and houses:\n");
  printf("Sign        English name      House Traditional name\n\n");
  for (i = 1; i <= SIGNS; i++)
    printf("%-12sthe %-14s%2d%s  House of %s\n", signname[i], signenglish[i],
	   i, post[i], housetradition[i]);
}


/* Read in a set of default program values used in the program, such as */
/* present location, time zone, the system of houses to use, the number */
/* of aspects and what orbs to use, and so on. These values are always  */
/* read in at the beginning of program execution.                       */

/* The NEXTDEFAULT macro means to skip all comments in the file until we   */
/* reach the beginning of the next set of data, delimited with a '=' sign. */

#define NEXTDEFAULT while(getc(data) != '=');

int inputdefaults()
{
  char name[STRING];
  int i;
  filename = DEFAULT_INFOFILE;     /* First lets open the info file.      */
  data = fopen(filename, "r");     /* Look for file in current directory. */
  if (data == NULL) {
    sprintf(name, "%s%s", DEFAULT_DIR, filename);   /* Look for file in   */
    data = fopen(name, "r");                        /* default directory. */
    if (data == NULL)          /* If file not found anywhere, then forget */
      return FALSE;            /* it and use the compile time defaults.   */
  }
  NEXTDEFAULT; fscanf(data, "%lf", &defzone);        /* Time zone    */
  NEXTDEFAULT; fscanf(data, "%lf", &deflong);        /* Longitude    */
  NEXTDEFAULT; fscanf(data, "%lf", &deflat);         /* Latitude     */
  NEXTDEFAULT; fscanf(data, "%d",  &aspects);        /* # of aspects */
  NEXTDEFAULT; fscanf(data, "%d",  &housesystem);    /* House type   */
  NEXTDEFAULT;
  for (i = 1; i <= OBJECTS; i++)       /* Object restrictions   */
    fscanf(data, "%d", &ignore[i]);
  NEXTDEFAULT;
  for (i = 1; i <= ASPECTS; i++)           /* Orbs for aspects  */
    fscanf(data, "%lf", &aspectorb[i]);
  NEXTDEFAULT;
  for (i = 1; i <= OBJECTS; i++)           /* Orbs for planets  */
    fscanf(data, "%lf", &planetorb[i]);
  NEXTDEFAULT;
  for (i = 1; i <= OBJECTS; i++)           /* Extra planet orbs */
    fscanf(data, "%lf", &planetadd[i]);
  NEXTDEFAULT; fscanf(data, "%lf", &objectinf[OBJECTS+1]);   /* Rules sign  */
  NEXTDEFAULT; fscanf(data, "%lf", &objectinf[OBJECTS+2]);   /* Exalts in   */
  NEXTDEFAULT; fscanf(data, "%lf",  &houseinf[SIGNS+1]);     /* Rules house */
  NEXTDEFAULT; fscanf(data, "%lf",  &houseinf[SIGNS+2]);     /* Exalts in   */
  NEXTDEFAULT;
  for (i = 1; i <= OBJECTS; i++)
    fscanf(data, "%lf", &objectinf[i]);    /* Influence of each object */
  for (i = 1; i <= SIGNS; i++)
    fscanf(data, "%lf", &houseinf[i]);     /* Influence of each house  */
  for (i = 1; i <= ASPECTS; i++)
    fscanf(data, "%lf", &aspectinf[i]);    /* Influence of each aspect */
  fclose(data);
  return TRUE;
}


/* Take the current chart information, and write it out to the file   */
/* as indicated by the -o switch. This is only executed at the end of */
/* program execution if the -o switch is in effect.                   */

outputdata()
{
  int i, j;
  double k;
  data = fopen(filenameout, "w");    /* Create and open the file for output. */
  if (data == NULL) {
    fprintf(stderr, "File %s can not be created.\n", filenameout);
    exit(1);
  }
  if (!(todisplay & DASHO0)) {

    /* Write the chart information to the file. */

    if (Mon < 1) {
      fprintf(stderr, "\nCan't output chart with no time/space to file.\n");
      fclose(data);
      exit(1);
    }
    fprintf(data, "%.0f\n%.0f\n%.0f\n%.2f\n%.2f\n%.2f\n%.2f\n",
	    Mon, Day, Yea, Tim, Zon, Lon, Lat);
  } else {

    /* However, if the -o0 switch is in effect, then write the actual */
    /* positions of the planets and houses to the file instead.       */

    for (i = 1; i <= OBJECTS; i++) {
      j = (int) planet[i];
      fprintf(data, "%c%c%c: %2d %2d %10.7f\n", OBJNAM(i),
	      j%30, j/30+1, (planet[i]-floor(planet[i]))*60.0);  /* Position */
      k = planetalt[i];
      fprintf(data, "[%c]: %3d %12.8f\n",                        /* Altitude */
	      ret[i] >= 0.0 ? 'D' : 'R', (int)(sgn(k)*
              floor(dabs(k))), (k-(double)(int)k)*60.0);      /* Retrograde? */
    }
    for (i = 1; i <= SIGNS/2; i++) {       /* Write first six cusp positions */
      j = (int) house[i];
      fprintf(data, "H_%c: %2d %2d %10.7f\n",
	      'a'+i-1, j%30, j/30+1, (house[i]-floor(house[i]))*60.0);
    }
  }

  /* Now write any extra strings that were on the command line after the -o */
  /* specification but before the next switch, to the file as comments.     */

  for (i = 1; i < extracount; i++) {
    extralines++;
    fprintf(data, "%s\n", extralines[1]);
  }
  fclose(data);
}


/* This is the dispatch procedure for the entire program. After all the   */
/* command switches have been processed, this routine is called to        */
/* actually call the various routines to generate and display the charts. */

action()
{
  int i;

  /* First let's adjust the restriction status of the minor cusps, uranians, */
  /* and fixed stars based on whether -C, -u, and -U switches are in effect. */

  if (!cusp)
    for (i = C_LO; i <= C_HI; i++)
      ignore[i] = TRUE;
  if (!uranian)
    for (i = U_LO; i <= U_HI; i++)
      ignore[i] = TRUE;
  if (!universe)
    for (i = S_LO; i <= S_HI; i++)
      ignore[i] = TRUE;

  if (Delta != 0.0) {                   /* If -+ or -- switches in effect   */
    JD = mdytojulian(M, D+Delta, Y);    /* then add the specified delta     */
    juliantomdy(JD, &M, &D, &Y);        /* value to date before proceeding. */
  }
  if (operation & 2)         /* Some charts, like transit searches and   */
    printtransit(prog);      /* ephemeris printing, don't require any    */
  else if (operation & 4)    /* other input, so lets do them right away. */
    printephemeris();
  else {

    /* Here we either do a normal chart or some kind of relationship chart. */

    if (!relation) {
      if (!autom)            /* If chart information not in memory yet, */
	inputdata("tty");    /* then prompt the user for the time, etc. */
      Mon = M; Day = D; Yea = Y; Tim = F; Zon = X; Lon = L5; Lat = LA;
      castchart(TRUE);
    } else
      castrelation();
#ifdef GRAPH
    if (operation & 8)     /* If any of the X window switches in effect, */
      xaction();           /* then go make a graphics chart...           */
    else
#endif
      printchart(prog);    /* Otherwise print chart on text screen.      */
  }
  if (operation & 1)       /* If -o switch in effect, then write */
    outputdata();          /* the chart information to a file.   */
}


/* This routine is called by the main program to actually prompt the user */
/* for the command switches and parameters, to be entered one by one in   */
/* the same format as they would be on a unix command line. This is only  */
/* executed for those non-unix systems which don't allow passing of the   */
/* command line to the program. The result of this routine is passed back */
/* to the main program which then processes it just like in a unix        */
/* system. (Not very graceful, but it works and gets the job done.)       */

#ifndef SWITCHES
#define MAXSWITCHES 30
int inputswitches(argv)
char argv[][];
{
  int argc = 0;
  printf("** Astrolog version %s (%s) **\n", VERSION, ADDRESS); 
  printf("Enter all the switch parameters below. (Enter -H for help.)\n");
  printf("Press return after each switch or number parameter input.\n");
  printf("Input a '.' on a line by itself when done.\n\n");
  do {
    argc++;
    printf("Input parameter string #%2d: ", argc);
    if (gets(argv[argc]) == (char *) NULL) {
      printf("\nAstrolog terminated.\n");
      exit(2);
    }
  } while (argc < MAXSWITCHES && (argv[argc][0] != '.' || argv[argc][1] != 0));
  putchar('\n');
  return argc;
}
#endif


/*
*******************************************************************************
** Main program
*******************************************************************************
*/

/* The main program, the starting point for Astrolog, follows. This section */
/* basically consists of looping through and processing each switch on the  */
/* command line, before actually calling a routine to do the neat stuff.    */

main(argc, argv)
int argc;
char **argv;
{
#ifdef TIME
  struct tm curtime;
  long curtimer;
#endif
  int pos, i, j;
  double k;
  char *c;
#ifndef SWITCHES
  char strings[MAXSWITCHES][10];
  char *pointers[MAXSWITCHES];
  inputdefaults();
  for (i = 0; i < MAXSWITCHES; i++)
    pointers[i] = strings[i];
  argc = inputswitches(strings);
  argv = pointers;
#else
  inputdefaults();
#endif
  argc--; argv++;
  while (argc) {
    pos = 1;
    if (argv[0][0] == '-')
      pos++;
    switch (argv[0][pos-1]) {
    case 'H':
      if (argv[0][pos] != '0')
	displayswitches();
      else
	printsigns();
      exit(0);
    case 'O':
      printobjects(argv[0][pos] == '0');
      exit(0);
    case 'R':
      if (argv[0][pos] == '0')
	for (i = 1; i <= total; i++)
	  ignore[i] = TRUE;
      else if (argv[0][pos] == 'C')
	for (i = C_LO; i <= C_HI; i++)
	  ignore[i] = TRUE;
      else if (argv[0][pos] == 'u')
	for (i = U_LO; i <= U_HI; i++)
	  ignore[i] = TRUE;
      else if (argv[0][pos] == 'U')
	for (i = S_LO; i <= S_HI; i++)
	  ignore[i] = TRUE;
      else if (argc <= 1 || (!atoi(argv[1]))) {
	for (i = 11; i <= 15; i++)
	  ignore[i] = 1-ignore[i];
	ignore[17] = 1-ignore[17]; ignore[20] = 1-ignore[20];
      }
      while (argc > 1 && (i = atoi(argv[1])))
	if (i < 1 || i > total) {
	  fprintf(stderr, "Bad value %d to switch -R\n", i);
	  exit(1);
	} else {
	  ignore[i] = 1-ignore[i];
	  argc--; argv++;
	}
      break;
    case 'u':
      uranian = TRUE;
      break;
    case 'U':
      if (argv[0][pos] == 'n' || argv[0][pos] == 'b' ||
	  argv[0][pos] == 'z' || argv[0][pos] == 'l')
	universe = argv[0][pos];
      else
	universe = TRUE;
      break;
    case 'C':
      cusp = TRUE;
      break;
    case 'A':
      if (argc <= 1) {
	printaspects();
	exit(0);
      }
      if (argv[0][pos] != 'o' && argv[0][pos] != 'm' && argv[0][pos] != 'd') {
	aspects = atoi(argv[1]);
	if (aspects < 0 || aspects > ASPECTS) {
	  fprintf(stderr, "Bad value %d to switch -A\n", aspects);
	  exit(1);
	}
	argc--; argv++;
      } else {
	if (argc <= 2)
	  toofew("A");
	i = atoi(argv[1]);
	if (i < 1 || i > (argv[0][pos] == 'o' ? ASPECTS : OBJECTS)) {
	  fprintf(stderr, "Bad value %d to switch -A%c\n", i, argv[0][pos]);
	  exit(1);
	}
	k = atof(argv[2]);
	if (k < -360.0 || k > 360.0) {
	  fprintf(stderr, "Bad value %.1f to switch -A%c\n", k, argv[0][pos]);
	  exit(1);
	}
	if (argv[0][pos] == 'm')
	  planetorb[i] = k;
	else if (argv[0][pos] == 'd')
	  planetadd[i] = k;
	else
	  aspectorb[i] = k;
	argc -= 2; argv += 2;
      }
      break;
    case 's':
      if (argv[0][pos] != '0')
	siderial = TRUE;
      else
	right = TRUE;
      break;
    case 'h':
      if (argc > 1 && (centerplanet = atoi(argv[1]))) {
	argc--; argv++;
      } else
	centerplanet = 1;
      if (centerplanet < 0 || centerplanet == 2 || (centerplanet >= THINGS &&
	  centerplanet < U_LO) || centerplanet > U_HI) {
	fprintf(stderr, "Bad value %d to switch -h\n", centerplanet);
	exit(1);
      }
      c = objectname[0];
      objectname[0] = objectname[centerplanet];
      objectname[centerplanet] = c;
      if (centerplanet < 2)
	centerplanet = 1-centerplanet;
      break;
    case 'c':
      if (argc <= 1)
	toofew("c");
      housesystem = atoi(argv[1]);
      if (housesystem < 0 || housesystem >= SYSTEMS) {
	fprintf(stderr, "Bad value %d to switch -c\n", housesystem);
	exit(1);
      }
      argc--; argv++;
      break;
    case 'x':
      if (argc <= 1)
	toofew("x");
      multiplyfactor = atoi(argv[1]);
      if (multiplyfactor < 1 || multiplyfactor > DEGREES) {
	fprintf(stderr, "Bad value %d to switch -x\n", multiplyfactor);
	exit(1);
      }
      argc--; argv++;
      break;
    case '1':
      if (argc > 1 && (onasc = atoi(argv[1]))) {
	argc--; argv++;
      } else
	onasc = 1;
      if (onasc < 1 || onasc > OBJECTS) {
	fprintf(stderr, "Bad value %d to switch -1\n", onasc);
	exit(1);
      }
      break;
    case '2':
      if (argc > 1 && (onasc = atoi(argv[1]))) {
	argc--; argv++;
      } else
	onasc = 1;
      if (onasc < 1 || onasc > OBJECTS) {
	fprintf(stderr, "Bad value %d to switch -2\n", onasc);
	exit(1);
      } else
	onasc = -onasc;
      break;
    case 'f':
      flip = TRUE;
      break;
    case '3':
      decan = TRUE;
      break;
    case 'G':
      geodetic = TRUE;
      break;
    case 'p':
#ifdef TIME
      if (argv[0][pos] == 'n') {
	progress = TRUE;
	curtimer = (long) time((long *) 0);
	curtime = *localtime(&curtimer);
	Mon = (double) curtime.tm_mon + 1.0;
	Day = (double) curtime.tm_mday;
	Yea = (double) curtime.tm_year + 1900.0;
	Jdp = mdytojulian(Mon, Day, Yea);
	break;
      }
#endif
      if (argv[0][pos] == '0') {
	if (argc <= 1)
	  toofew("p0");
	progday = atof(argv[1]);
	if (progday == 0.0) {
	  fprintf(stderr, "Bad progression value %.2f to switch -p0\n",
		  progday);
	  exit(1);
	}
	argc--; argv++;
	break;
      }
      if (argc <= 3)
	toofew("p");
      progress = TRUE;
      Mon = atof(argv[1]);
      Day = atof(argv[2]);
      Yea = atof(argv[3]);
      if (Mon < 1.0 || Mon > 12.0 || Day < 1.0 || Day > 31.0) {
	fprintf(stderr, "Bad date value %.0f,%.0f,%.0f to switch -p\n",
		Mon, Day, Yea);
	exit(1);
      }
      Jdp = mdytojulian(Mon, Day, Yea);
      argc -= 3; argv += 3;
      break;
    case 'F':
      if (argc <= 3)
	toofew("F");
      i = atoi(argv[1]);
      if (i < 1 || i > TOTAL) {
	fprintf(stderr, "Bad object value %d to switch -F\n", i);
	exit(1);
      }
      force[i] = atof(argv[2])*30.0-30.0+dectodeg(atof(argv[3]));
      if (force[i] < 0.0 || force[i] >= DEGREES) {
	fprintf(stderr, "Bad value %.0f to switch -F\n", force[i]);
	exit(1);
      } else
	force[i] += DEGREES;
      argc -= 3; argv += 3;
      break;
    case '+':
      if (argc <= 1)
	toofew("+");
      Delta += atof(argv[1]);
      argc--; argv++;
      break;
    case '-': case '\0':
      if (argc <= 1)
	toofew("-");
      Delta -= atof(argv[1]);
      argc--; argv++;
      break;
    case 'v':
      if (argv[0][pos] == '0')
	todisplay |= DASHV0;
      else if (argv[0][pos] == 'I')
	todisplay |= DASHVI;
      todisplay |= DASHV;
      break;
    case 'w':
      if (argv[0][pos] == '0')
	todisplay |= DASHW0;
      todisplay |= DASHW;
      break;
    case 'g':
      if (argv[0][pos] == '0')
	todisplay |= DASHG0;
      else if (argv[0][pos] == 'a') {
	todisplay |= DASHGA;
	if (argv[0][pos+1] == '0')
	  todisplay |= DASHG0;
      } else if (argv[0][pos] == 'I')
	todisplay |= DASHGI;
      todisplay |= DASHG;
      break;
    case 'Z':
      if (argv[0][pos] == '0')
	todisplay |= DASHZ0;
      todisplay |= DASHZ;
      break;
    case 'S':
      todisplay |= DASHS;
      break;
    case 'I':
      if (argv[0][pos] == '0') {
	chartlocation(TRUE);
	chartgrid(TRUE);
	exit(0);
      }
      todisplay |= DASHI;
      break;
    case 'L':
      if (argv[0][pos] == '0')
	todisplay |= DASHL0;
      if (argc > 1 && (i = atoi(argv[1]))) {
	graphstep = i;
	argc--; argv++;
      }
      if (graphstep < 1 || 160%graphstep > 0) {
	fprintf(stderr, "Bad value %d to switch -L\n", graphstep);
	exit(1);
      }
      todisplay |= DASHL;
      break;
    case 'd':
      if (argv[0][pos] == 'p') {
	if (argc <= 2)
	  toofew("dp");
	prog = TRUE;
	todisplay |= DASHD0;
	Mon2 = atof(argv[1]);
	Yea2 = atof(argv[2]);
	if (Mon2 < 0.0 || Mon2 > 12.0) {
	  fprintf(stderr, "Bad date value %.0f to switch -dp\n", Mon2);
	  exit(1);
	}
	argc -= 2; argv += 2;
      } else if (argv[0][pos] == '0')
	todisplay |= DASHD0;
      todisplay |= DASHD;
      break;
    case 'e':
      todisplay = DASHE | DASHG0 | DASHL0;
      break;
#ifdef TIME
    case 'n':
      inputdata("now");
      break;
#endif
    case 'l':
      if (argc <= 2)
	toofew("l");
      deflong = atof(argv[1]);
      deflat  = atof(argv[2]);
      argc -= 2; argv += 2;
      break;
    case 'z':
      if (argc <= 1 || (atoi(argv[1]) == 0 && argv[1][0] != '0'))
	defzone--;
      else {
	defzone = atof(argv[1]);
	if (defzone < -24.0 || defzone > 24.0) {
	  fprintf(stderr, "Bad value %.0f to switch -z\n", defzone);
	  exit(1);
	}
	argc--; argv++;
      }
      break;
    case 'a':
      if (argc <= 7)
	toofew("a");
      autom = TRUE;
      M = atof(argv[1]); D = atof(argv[2]); Y = atof(argv[3]);
      F = atof(argv[4]); X = atof(argv[5]);
      L5 = atof(argv[6]); LA = atof(argv[7]);
      argc -= 7; argv += 7;
      break;
    case 'q':
      i = (argv[0][pos] == '0');
      if (argc <= 3+i)
	toofew("q");
      autom = TRUE;
      M = atof(argv[1]); D = atof(argv[2]); Y = atof(argv[3]);
      F = i ? atof(argv[4]) : 12.0; X = defzone; L5 = deflong; LA = deflat;
      argc -= 3+i; argv += 3+i;
      break;
    case 'i':
      if (argc <= 1)
	toofew("i");
      inputdata(argv[1]);
      argc--; argv++;
      break;
    case 'o':
      if (argv[0][pos] == '0')
	todisplay |= DASHO0;
      if (argc <= 1)
	toofew("o");
      operation |= 1;
      filenameout = argv[1];
      extralines = argv;
      do {
	argc--; argv++;
	extracount++;
      } while (argc > 1 && argv[1][0] != '-');
      break;
    case 'r':
      if (argc <= 2)
	toofew("r");
      if (argv[0][pos] == 'c')
	relation = 2;
      else if (argv[0][pos] == 'm')
	relation = 3;
      else if (argv[0][pos] == 'd')
	relation = 4;
      else if (argv[0][pos] == 'b')
	relation = 5;
      else if (argv[0][pos] == '0')
	relation = -1;
      else
	relation = 1;
      filename = argv[1]; filename2 = argv[2];
      argc -= 2; argv += 2;
      break;
#ifdef TIME
    case 't':
      if (argc <= 1)
	toofew("t");
      if (argv[0][pos] == 'd')
	relation = 4;
      else if (argv[0][pos] == 'b')
	relation = 5;
      else
	relation = -1;
      filename = argv[1]; filename2 = "now";
      argc--; argv++;
      break;
#endif
    case 'T':
      if (argc <= 3)
	toofew("T");
      if (argv[0][pos] == 'p') {
	prog = TRUE;
	todisplay |= DASHT0;
      } else if (argv[0][pos] == '0')
	todisplay |= DASHT0;
      operation |= 2;
      filename = argv[1];
      Mon2 = atof(argv[2]);
      Yea2 = atof(argv[3]);
      if (Mon2 < 0.0 || Mon2 > 12.0) {
	fprintf(stderr, "Bad date value %.0f to switch -T\n", Mon2);
	exit(1);
      }
      argc -= 3; argv += 3;
      break;
    case 'E':
      if (argc <= 2)
	toofew("E");
      if (argv[0][pos] == '0')
	todisplay |= DASHE0;
      operation |= 4;
      Mon2 = atof(argv[1]);
      Yea2 = atof(argv[2]);
      if (Mon2 < 0.0 || Mon2 > 12.0) {
	fprintf(stderr, "Bad date value %.0f to switch -E\n", Mon2);
	exit(1);
      }
      argc -= 2; argv += 2;
      break;
#ifdef GRAPH
    case 'X':
      i = xprocess(argc, argv, pos);
      operation |= 8;
      argc -= i; argv += i;
      break;
#endif
    default:
      fprintf(stderr, "Unknown switch '%s'\n", argv[0]);
      exit(1);
    }
    argc--; argv++;
  }
  action();
}

/**/
Newsgroups: alt.cyberpunk