[comp.sources.misc] v11i041: starchart 3.2 Part 13/32

ccount@ATHENA.MIT.EDU (03/16/90)

Posting-number: Volume 11, Issue 41
Submitted-by: ccount@ATHENA.MIT.EDU
Archive-name: starchart/part13

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 13 (of 32)."
# Contents:  observe/outsat.c starchart/readfile.c
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'observe/outsat.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'observe/outsat.c'\"
else
echo shar: Extracting \"'observe/outsat.c'\" \(23472 characters\)
sed "s/^X//" >'observe/outsat.c' <<'END_OF_FILE'
X/*
X * outsat.c
X * Output satellite, PostScript file for satellites
X *
X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
X *
X * This software may be redistributed freely, not sold.
X * This copyright notice and disclaimer of warranty must remain
X *    unchanged. 
X *
X * No representation is made about the suitability of this
X * software for any purpose.  It is provided "as is" without express or
X * implied warranty, to the extent permitted by applicable law.
X *
X */
X
X#ifndef  lint
Xstatic char rcsid[] =
X  "$Header: outsat.c,v 1.7 90/02/25 16:38:03 ccount Exp $";
X#endif
X
X
X#include <stdio.h>
X#include "observe.h"
X#include "date.h"
X
X#ifndef FALSE
X#define FALSE 0
X#endif
X#ifndef TRUE
X#define TRUE 1
X#endif
X
Xvoid outjs(), outjs_PS();
Xvoid jupsat(), satsat();
X
X/* Output satellite, .PS file for satellites */
Xvoid out_sat(o_sat, o_sat_PS, one_day, invert_sats, jd, moon_data, planets)
X     FILE *o_sat, *o_sat_PS;
X     int one_day, invert_sats;
X     double jd;
X     moon_data_t moon_data;
X     planet_data_t planets[];
X{
X  sat_t jovesats[4], saturnsats[8];
X  static int last_jd = 0;
X  static int doing_saturn = FALSE;
X
X  jupsat(jd, planets[3], jovesats);
X  satsat(jd, planets[4], saturnsats);
X
X
X  if (jd < last_jd) {
X    doing_saturn = TRUE;
X  };
X  last_jd = jd;
X  if (!doing_saturn)
X    outjs(o_sat, one_day, jd, jovesats, saturnsats, planets);
X  outjs_PS(o_sat_PS, one_day, invert_sats, jd,
X	   jovesats, saturnsats, moon_data, planets);
X}
X
X
Xvoid outjs(outf, one_day, jd, jovesats, saturnsats)
X     FILE *outf;
X     int one_day;
X     double jd;
X     sat_t jovesats[], saturnsats[];
X{
X  int i;
X  char datestr[15];
X
X
X  jd_to_str(jd, datestr);
X  fprintf(outf, "%s\n", datestr);
X
X  fprintf(outf,
X  "Relative position in planet radii, +x west +y north, RA seconds east\n");
X  fprintf(outf,
X"Satellite     Relative position: x  y  z      R.A.      Dec.       mag\n");
X  for (i = 0; i < 4; i++)
X    fprintf(outf, "%-10.10s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
X	    jovesats[i].name, jovesats[i].dx, jovesats[i].dy, jovesats[i].dz,
X	    jovesats[i].dalpha/15.0, jovesats[i].ddelta,
X	    jovesats[i].mag);
X  fprintf(outf, "\n");
X  for (i = 0; i < 8; i++)
X    fprintf(outf, "%-10.10s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
X	    saturnsats[i].name, saturnsats[i].dx, saturnsats[i].dy,
X	    saturnsats[i].dz,
X	    saturnsats[i].dalpha/15.0, saturnsats[i].ddelta,
X	    saturnsats[i].mag);
X
X
X  if (!one_day) fprintf(outf, "\f\n");
X}
X
X#define CenterLine 288
X#define DateY 720
X#define JupY 580
X#define SatY 396
X#define JupOneRad 6
X#define SatOneRad 3
X#define JOrderOff 36
X#define SOrderOff 144
X
X#define JupManyRad 4.5
X#define SatManyRad 2.25
X#define JupColumn 144
X#define SatColumn 144
X#define OrderOffset 72
X#define DateOffset 192
X
X#define Fontname "/Times-Roman"
X#define Bigsize 10
X#define JSFontname "/Times-Roman"
X#define JSmlsz 10
X#define SSFontname "/Times-Roman"
X#define SSmlsz 8
X
Xint n_called = 0;
X
X/* output postscript picture of jupiter and saturn */
Xvoid outjs_PS(outf, one_day, invert_sats, jd,
X	      jovesats, saturnsats, moon_data, planets)
X     FILE *outf;
X     int one_day, invert_sats;
X     double jd;
X     sat_t jovesats[], saturnsats[];
X     moon_data_t moon_data;
X     planet_data_t planets[];
X{
X  int i, j;
X  static int printed_header = FALSE;
X  static int top = 720;
X  static int last_jd = 0;
X  static int doing_saturn = FALSE;
X  char datestr[15];
X  int zindex[9];
X  double z[9];
X  int yindex[9];
X  double y[9];
X  int xindex[9];
X  double x[9];
X  double beta_e_saturn;
X  int psx, psy;
X
X  jd_to_str(jd, datestr);
X
X  n_called++;
X
X  beta_e_saturn = planets[4].rotation_elements.beta_e;
X
X  /* Start postscript */
X  if (!printed_header) {
X    fprintf(outf, "%%!\n");
X    fprintf(outf, "%%Remove this header and the later footer\n");
X    fprintf(outf,
X     "%%    if you are adding the code to a starchart postscript file.\n");
X    fprintf(outf,
X"%%Place the function definitions after the chart header in that file.\n");
X    if (!one_day) {
X      fprintf(outf, "%%This file was produced for a multiple day display,\n");
X      fprintf(outf,
X"%% and is not suitable for use within a starpost output file.\n");
X      fprintf(outf,
X"%% Prepare charts for individual days\n");
X    };
X    fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
X    fprintf(outf, "\n");
X    fprintf(outf, "1 setlinewidth 2 setlinecap\n");
X    fprintf(outf, "[] 0 setdash 0 setgray\n");
X    fprintf(outf, "/s {newpath 0 360 arc closepath fill} def\n");
X    fprintf(outf, "/s0 {8 s} def\n");
X    fprintf(outf, "/s1 {7 s} def\n");
X    fprintf(outf, "/s2 {6 s} def\n");
X    fprintf(outf, "/s3 {5 s} def\n");
X    fprintf(outf, "/s4 {4 s} def\n");
X    fprintf(outf, "/s5 {3.25 s} def\n");
X    fprintf(outf, "/s6 {2.5 s} def\n");
X    fprintf(outf, "/s7 {2.0 s} def\n");
X    fprintf(outf, "/s8 {1.5 s} def\n");
X    fprintf(outf, "/s9 {1.0 s} def\n");
X    fprintf(outf, "/s10 {0.5 s} def\n");
X    fprintf(outf, "%%\n%%\n%%\n%%End of header\n%%\n%%\n");
X    fprintf(outf, "%%\n%%\n%%\n%%Begin definitions\n%%\n%%\n");
X    fprintf(outf,
X"/centershow { dup stringwidth pop 2 div neg 0 rmoveto show } def\n");
X    fprintf(outf,
X"/atshow10pt { dup stringwidth pop 2 div neg 3.5 neg rmoveto show } def\n");
X
X
X    fprintf(outf,
X "/array-centershow { /str-arr exch def /widthskip exch def\n");
X    fprintf(outf, "  str-arr length widthskip mul 2 div neg 0 rmoveto\n");
X    fprintf(outf, "  str-arr {\n");
X    fprintf(outf, "    gsave show grestore\n");
X    fprintf(outf, "    widthskip 0 rmoveto\n");
X    fprintf(outf, "  } forall\n");
X    fprintf(outf, "} def\n");
X    fprintf(outf, "/array-vertshow { /str-arr exch def /lineskip exch def\n");
X    fprintf(outf, "  0 str-arr length lineskip mul 2 div neg rmoveto\n");
X    fprintf(outf, "  str-arr {\n");
X    fprintf(outf, "    gsave\n");
X    fprintf(outf, "      dup stringwidth pop 2 div neg 0 rmoveto show\n");
X    fprintf(outf, "    grestore\n");
X    fprintf(outf, "    0 lineskip rmoveto\n");
X    fprintf(outf, "  } forall\n");
X    fprintf(outf, "} def\n");
X
X    fprintf(outf, "/Textx 2 def\n");
X    fprintf(outf, "/Texty 2 def\n");
X
X
X    fprintf(outf, "%% x y r phase p_n beta_e chi\n");
X    fprintf(outf, "/planet-with-phase {\n");
X    fprintf(outf, "  /chi exch def /beta_e exch def /p_n exch def\n");
X    fprintf(outf, "  /phase exch def\n");
X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
X    fprintf(outf, "    x y translate r r scale\n");
X    if (invert_sats) {
X      if (one_day)
X	fprintf(outf, "    1 -1 scale\n");
X      else
X	fprintf(outf, "    -1 1 scale\n");
X      };
X    fprintf(outf, "    gsave p_n rotate\n");
X    fprintf(outf, "      1 setgray\n");
X    fprintf(outf, "      0 0 1.05 0 360 arc fill\n");
X    fprintf(outf, "      0 setgray\n");
X    fprintf(outf, "      0 0 1 0 360 arc stroke\n");
X    fprintf(outf, "      gsave\n");
X    fprintf(outf, "        1 beta_e cos scale\n");
X    fprintf(outf, "        0 1 moveto 0 1.25 lineto stroke\n");
X    fprintf(outf, "      grestore\n");
X    fprintf(outf, "      gsave\n");
X    fprintf(outf, "        1 beta_e sin scale\n");
X    fprintf(outf, "        0 0 1 180 360 arc stroke\n");
X    fprintf(outf, "      grestore\n");
X    fprintf(outf, "    grestore %% restore p_n rotation\n");
X    fprintf(outf, "    gsave\n");
X    fprintf(outf, "      chi rotate\n");
X    fprintf(outf, "      newpath\n");
X    fprintf(outf, "      0 0 1 0 180 arcn\n");
X    fprintf(outf, "      1 phase cos scale\n");
X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
X    fprintf(outf, "    grestore\n");
X    fprintf(outf, "  grestore\n} def\n");
X
X  /* Saturn with rings, no satellites, with north pole and equator */
X    fprintf(outf, "/saturn-with-phase  {\n");
X    fprintf(outf, "  /chi exch def /beta_e exch def /p_n exch def\n");
X    fprintf(outf, "  /phase exch def\n");
X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
X    fprintf(outf, "    x y translate r r scale\n");
X    if (invert_sats) {
X      if (one_day)
X	fprintf(outf, "    1 -1 scale\n");
X      else
X	fprintf(outf, "    -1 1 scale\n");
X      };
X    fprintf(outf, "    gsave p_n rotate\n");
X    fprintf(outf, "      gsave 1 beta_e sin scale newpath\n"); /* back ring */
X    fprintf(outf, "        0 0 1.51 0 180 arc stroke\n");
X    fprintf(outf, "        0 0 1.94 0 180 arc stroke\n");
X    fprintf(outf, "        0 0 2.00 0 180 arc stroke\n");
X    fprintf(outf, "        0 0 2.27 0 180 arc stroke\n");
X    fprintf(outf, "      grestore\n");
X    fprintf(outf, "      1 setgray\n");
X    fprintf(outf, "      0 0 1.05 0 360 arc fill\n");
X    fprintf(outf, "      0 setgray\n");
X    fprintf(outf, "      0 0 1 0 360 arc stroke\n");
X    fprintf(outf, "      gsave\n");
X    fprintf(outf, "        1 beta_e cos scale\n");
X    fprintf(outf, "        0 1 moveto 0 1.25 lineto stroke\n");
X    fprintf(outf, "      grestore\n");
X    fprintf(outf, "      gsave\n");
X    fprintf(outf, "        1 beta_e sin scale\n");
X    fprintf(outf, "        0 0 1 180 360 arc stroke\n");
X    fprintf(outf, "      grestore\n");
X    fprintf(outf, "    grestore %% restore p_n rotation\n");
X    fprintf(outf, "    gsave\n");
X    fprintf(outf, "      chi rotate\n");
X    fprintf(outf, "      newpath\n");
X    fprintf(outf, "      0 0 1 0 180 arcn\n");
X    fprintf(outf, "      1 phase cos scale\n");
X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
X    fprintf(outf, "    grestore\n");
X    fprintf(outf, "    gsave p_n rotate\n");
X    fprintf(outf, "      gsave 1 beta_e sin scale newpath\n"); /* front ring */
X    fprintf(outf, "        0 0 1.51 180 360 arc stroke\n");
X    fprintf(outf, "        0 0 1.94 180 360 arc stroke\n");
X    fprintf(outf, "        0 0 2.00 180 360 arc stroke\n");
X    fprintf(outf, "        0 0 2.27 180 360 arc stroke\n");
X    fprintf(outf, "      grestore\n");
X    fprintf(outf, "    grestore\n");
X    fprintf(outf, "  grestore\n} def\n");
X
X
X    fprintf(outf, "/Luna-with-phase {\n");
X    fprintf(outf, "  /chi exch def\n");
X    fprintf(outf, "  /phase exch def\n");
X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
X    fprintf(outf, "    x y translate r r scale\n");
X    if (invert_sats) {
X      if (one_day)
X	fprintf(outf, "    1 -1 scale\n");
X      else
X	fprintf(outf, "    -1 1 scale\n");
X      };
X    fprintf(outf, "    1 setgray\n");
X    fprintf(outf, "    0 0 1.05 0 360 arc fill\n");
X    fprintf(outf, "    0 setgray\n");
X    fprintf(outf, "    0 0 1 0 360 arc stroke\n");
X    fprintf(outf, "    gsave\n");
X    fprintf(outf, "      chi rotate\n");
X    fprintf(outf, "      newpath\n");
X    fprintf(outf, "      0 0 1 0 180 arcn\n");
X    fprintf(outf, "      1 phase cos scale\n");
X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
X    fprintf(outf, "    grestore\n");
X    fprintf(outf, "  grestore\n} def\n");
X
X
X    /* Define satellites */
X    for (i = 0; i < 4; i++) {
X/*
X      if (one_day) {
X	fprintf(outf, "/%s {2 copy s%d\n", jovesats[i].name,
X		(int) (jovesats[i].mag+0.5));
X	fprintf(outf,
X		"     Texty add exch Textx add exch moveto (%c%c) show\n",
X		jovesats[i].name[0], jovesats[i].name[1]);
X      } else {
X	fprintf(outf, "/%s {s%d\n", jovesats[i].name,
X		(int) (jovesats[i].mag+0.5));
X      };
X*/
X      fprintf(outf, "/%s {s%d\n", jovesats[i].name,
X	      (int) (jovesats[i].mag+0.5));
X      fprintf(outf, "     } def\n");
X    };
X
X    fprintf(outf,
X"%% Saturn satellites are shown 4 magnitudes brighter then they are\n");
X    for (i = 0; i < 8; i++) {
X      j = saturnsats[i].mag - 4 +0.5;
X      if (j > 10) j = 10;
X      fprintf(outf, "/%s {s%d\n", saturnsats[i].name, j);
X      fprintf(outf, "     } def\n");
X    };
X
X    /* Define Jupiter and saturn without satellites */
X    fprintf(outf, "\n");
X    fprintf(outf, "/Jupiter-body {3 copy newpath 0 360 arc 1 setgray fill\n");
X    fprintf(outf, "    0 360 arc 0 setgray stroke} def\n");
X
X
X    fprintf(outf,
X	  "/back-ring {/beta exch def /r exch def /y exch def /x exch def\n");
X    fprintf(outf, "    newpath gsave x y translate 1 beta sin scale\n");
X    fprintf(outf, "    0 0 r 1.51 mul 0 180 arc stroke\n");
X    fprintf(outf, "    0 0 r 2.27 mul 0 180 arc stroke\n");
X    fprintf(outf, "    grestore} def\n");
X    fprintf(outf,
X	  "/front-ring {/beta exch def /r exch def /y exch def /x exch def\n");
X    fprintf(outf, "    newpath gsave x y translate 1 beta sin scale\n");
X    fprintf(outf, "    0 0 r 1.51 mul 180 360 arc stroke\n");
X    fprintf(outf, "    0 0 r 2.27 mul 180 360 arc stroke\n");
X    fprintf(outf, "    grestore} def\n");
X    fprintf(outf, "\n");
X    fprintf(outf, "/Saturn-body {/r exch def /y exch def /x exch def\n");
X    fprintf(outf, "    /beta %f def\n", beta_e_saturn);
X    fprintf(outf, "    x y r beta back-ring\n");
X    fprintf(outf, "    x y r 0 360 arc 1 setgray fill\n");
X    fprintf(outf, "    x y r 0 360 arc 0 setgray stroke\n");
X    fprintf(outf, "    x y r beta front-ring\n");
X    fprintf(outf, "} def\n");
X
X
X    fprintf(outf, "\n");
X    fprintf(outf, "\n");
X
X    printed_header = TRUE;
X  };
X
X
X
X  /* Define Jupiter and saturn with satellites */
X  /* Jupiter */
X  /* Find drawing order */
X  for (i = 0; i < 4; i++)
X    z[i] = jovesats[i].dz;
X  z[4] = 0.0;			/* Jupiter's body */
X  HeapSort0(z, zindex, 5);
X
X  fprintf(outf, "/Jupiter ");
X  fprintf(outf, " { /r exch def gsave translate\n");
X  if (invert_sats) {
X    if (one_day)
X      fprintf(outf, "    1 -1 scale\n");
X    else
X      fprintf(outf, "    -1 1 scale\n");
X  };
X  fprintf(outf, "    %f rotate\n",
X	  planets[3].rotation_elements.p_n);
X  for (i = 0; i < 5; i++) {
X    if (zindex[i] < 4) {
X      fprintf(outf, "    r %f mul r %f mul %s\n",
X	      jovesats[zindex[i]].dx,
X	      jovesats[zindex[i]].dy, jovesats[zindex[i]].name);
X    } else {
X      fprintf(outf, "    0 0 r Jupiter-body\n");
X    };
X  };
X  fprintf(outf, "grestore } def\n");
X  /* Define order string */
X  for (i = 0; i < 4; i++)
X    x[i] = -jovesats[i].dalpha;
X
X  if (invert_sats)
X    if (!one_day)
X      for (i = 0; i < 4; i++)
X	x[i] = jovesats[i].dalpha;
X      
X  x[4] = 0.0;			/* Jupiter's body */
X  HeapSort0(x, xindex, 5);
X  for (i = 0; i < 5; i++)
X    if (xindex[i] == 4) j = i;
X
X  fprintf(outf, "/Jup-order-array [");
X  for (i = 0; i < (4 - 2*j); i++) fprintf(outf, " (  )");
X  for (i = 0; i < 5; i++) {
X    if (xindex[i] < 4) {
X      fprintf(outf, " (%c%c)",
X	      jovesats[xindex[i]].name[0], jovesats[xindex[i]].name[1]);
X    } else {
X      fprintf(outf, " (J)");
X    }
X  };
X  for (i = 0; i < (2*(j-2)); i++) fprintf(outf, " (  )");
X  fprintf(outf, "] def\n\n");
X  fprintf(outf, "\n");
X
X  /* Saturn */
X  /* Find drawing order */
X  for (i = 0; i < 8; i++)
X    z[i] = saturnsats[i].dz;
X  z[8] = 0.0;			/* Saturn's body */
X  HeapSort0(z, zindex, 9);
X
X  fprintf(outf, "/Saturn ");
X  fprintf(outf, " { /r exch def gsave translate\n");
X  if (invert_sats) {
X    if (one_day)
X      fprintf(outf, "    1 -1 scale\n");
X    else
X      fprintf(outf, "    -1 1 scale\n");
X  };
X  fprintf(outf, "    %f rotate\n",
X	  planets[4].rotation_elements.p_n);
X  for (i = 0; i < 9; i++) {
X    if (zindex[i] < 8) {
X      fprintf(outf, "    r %f mul r %f mul %s\n",
X	      saturnsats[zindex[i]].dx,
X	      saturnsats[zindex[i]].dy, saturnsats[zindex[i]].name);
X    } else {
X      fprintf(outf, "    0 0 r Saturn-body\n");
X    };
X  };
X  fprintf(outf, "grestore } def\n");
X
X  /* Define order string */
X  for (i = 0; i < 8; i++)
X    x[i] = -saturnsats[i].dalpha;
X
X  if (invert_sats)
X    if (!one_day)
X      for (i = 0; i < 8; i++)
X	x[i] = saturnsats[i].dalpha;
X      
X  x[8] = 0.0;			/* Saturn's body */
X  HeapSort0(x, xindex, 9);
X  for (i = 0; i < 9; i++)
X    if (xindex[i] == 8) j = i;
X  fprintf(outf, "/Sat-order-array [");
X  for (i = 0; i < (8 - 2*j); i++) fprintf(outf, " (  )");
X  for (i = 0; i < 9; i++) {
X    if (xindex[i] < 8) {
X      fprintf(outf, " (%c%c)",
X	      saturnsats[xindex[i]].name[0], saturnsats[xindex[i]].name[1]);
X    } else {
X      fprintf(outf, " (S)");
X    }
X  };
X  for (i = 0; i < (2*(j-4)); i++) fprintf(outf, " (  )");
X  fprintf(outf, "] def\n\n");
X  fprintf(outf, "\n");
X  fprintf(outf, "\n");
X
X  /* Vertical for saturn */
X  for (i = 0; i < 8; i++)
X    y[i] = saturnsats[i].ddelta;
X
X  if (invert_sats)
X    if (one_day)
X      for (i = 0; i < 8; i++)
X	y[i] = -saturnsats[i].ddelta;
X
X  y[8] = 0.0;			/* Saturn's body */
X  HeapSort0(y, yindex, 9);
X  for (i = 0; i < 9; i++)
X    if (yindex[i] == 8) j = i;
X  fprintf(outf, "/Sat-yorder-array [");
X  for (i = 0; i < (8 - 2*j); i++) fprintf(outf, " (  )");
X  for (i = 0; i < 9; i++) {
X    if (yindex[i] < 8) {
X      fprintf(outf, " (%c%c)",
X	      saturnsats[yindex[i]].name[0], saturnsats[yindex[i]].name[1]);
X    } else {
X      fprintf(outf, " (S)");
X    }
X  };
X  for (i = 0; i < (2*(j-4)); i++) fprintf(outf, " (  )");
X  fprintf(outf, "] def\n\n");
X  fprintf(outf, "\n");
X  fprintf(outf, "\n");
X
X  /* Draw them */
X  if (one_day) {
X    fprintf(outf, "/jupiter {2 div Jupiter} def\n");
X    fprintf(outf, "/saturn {2 div Saturn} def\n");
X    fprintf(outf,
X"%% The above \"jupiter\" and \"saturn\" can be called from starchart postscript\n");
X    fprintf(outf, "%%End definitions\n");
X    fprintf(outf,
X	  "%%Begin footer: Remove if inserted in starchart postscript file\n");
X    for (i = 0; i < 5; i++) {
X      psx = 72 + i*72;
X      psy = 180;
X      if (i != 4)
X	fprintf(outf,"%d %d %f %f %f %f %f planet-with-phase\n", psx, psy,
X		planets[i].size* 0.70866141732283465, /* 1 cm = 20 s */
X		planets[i].phase,
X		planets[i].rotation_elements.p_n,
X		planets[i].rotation_elements.beta_e,
X		planets[i].chi);
X      else
X	fprintf(outf,"%d %d %f %f %f %f %f saturn-with-phase\n", psx, psy,
X		planets[i].size* 0.70866141732283465, /* 1 cm = 20 s */
X		planets[i].phase,
X		planets[i].rotation_elements.p_n,
X		planets[i].rotation_elements.beta_e,
X		planets[i].chi);
X      fprintf(outf, "%d %d moveto (%s) centershow\n", psx, psy - 72,
X	      planets[i].name);
X      fprintf(outf, "%d %d moveto (Meridian) centershow\n",
X	      psx, psy - 90);
X      fprintf(outf, "%d %d moveto (%.0f\\312) centershow\n",
X	      psx, psy - 102,
X	      planets[i].rotation_elements.lambda_e);
X    };
X
X    fprintf(outf, "504 180 36 %f %f Luna-with-phase\n",
X	    moon_data.phase, moon_data.chi);
X    fprintf(outf, "504 108 moveto (Moon) centershow\n");
X    fprintf(outf, "504 90 moveto (%.2f arcmin) centershow\n",
X	    moon_data.size/60.0);
X
X    psy = 48;
X    psx = 72;
X    fprintf(outf,
X "%d %d moveto %f %d lineto stroke %f %d moveto (  1 cm = 20 arcsec) show\n",
X	    psx, psy, psx + 20*0.70866141732283465, /* 1 cm = 20 s */ psy,
X	    psx + 20*0.70866141732283465, psy);
X	    
X    fprintf(outf, "%d %d moveto (%s) centershow\n",
X	    CenterLine, DateY, datestr);
X
X    psx = CenterLine;
X    psy = DateY - 72;
X    if (invert_sats) {
X      fprintf(outf, "%d %d moveto %d %d lineto %d %d lineto stroke\n",
X	      psx, psy + 12, psx, psy - 12, psx - 4, psy - 12 + 4);
X      fprintf(outf, "%d %d moveto (N) atshow10pt\n", psx, psy - 12 - 9);
X      fprintf(outf, "%d %d moveto (S) atshow10pt\n", psx, psy + 12 + 9);
X    } else {
X      fprintf(outf, "%d %d moveto %d %d lineto %d %d lineto stroke\n",
X	      psx, psy - 12, psx, psy + 12, psx + 4, psy + 12 - 4);
X      fprintf(outf, "%d %d moveto (N) atshow10pt\n", psx, psy + 12 + 9);
X      fprintf(outf, "%d %d moveto (S) atshow10pt\n", psx, psy - 12 - 9);
X    };
X    fprintf(outf, "%d %d moveto %d %d lineto stroke\n",
X	    psx-12, psy, psx+12, psy);
X    fprintf(outf, "%d %d moveto (E) atshow10pt\n", psx - 12 - 9, psy);
X    fprintf(outf, "%d %d moveto (W) atshow10pt\n", psx + 12 + 9, psy);
X
X
X    fprintf(outf, "%d %d %d Jupiter\n", CenterLine, JupY, JupOneRad);
X    fprintf(outf, "/MMwidth (MM) stringwidth pop def\n");
X    fprintf(outf,
X "%d MMwidth 2 div add %d moveto MMwidth Jup-order-array array-centershow\n",
X	    CenterLine, JupY-JOrderOff);
X    fprintf(outf, "\n");
X
X    fprintf(outf, "%d %d %d Saturn\n", CenterLine, SatY, SatOneRad);
X    fprintf(outf,
X "%d MMwidth 2 div add %d moveto MMwidth Sat-order-array array-centershow\n",
X	    CenterLine, SatY-SOrderOff);
X    fprintf(outf, "%d %d moveto 12 Sat-yorder-array array-vertshow\n",
X	    CenterLine + SOrderOff, SatY);
X    fprintf(outf, "\n");
X  } else {
X    if (jd < last_jd) {
X      doing_saturn = TRUE;
X      fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
X      fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
X      if (invert_sats) {
X	fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
X	fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
X      } else {
X	fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
X	fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
X      };
X      fprintf(outf, "showpage\n");
X
X      top = 720;
X    };
X    last_jd = jd;
X    if (!doing_saturn) {
X      fprintf(outf, "%d %d %f Jupiter\n", JupColumn, top, JupManyRad);
X      fprintf(outf, "%s findfont %d scalefont setfont\n", JSFontname, JSmlsz);
X      fprintf(outf,
X "%f %d moveto (MM) stringwidth pop Jup-order-array array-centershow\n",
X	      JupColumn + 36*JupManyRad + OrderOffset, top);
X      fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
X      fprintf(outf, "%f %d moveto (%s) show\n",
X	      JupColumn + 36*JupManyRad + DateOffset,
X	      top, datestr);
X
X      fprintf(outf, "\n");
X      top -= 18;
X      if (top <= 71) {
X	fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
X	fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
X	if (invert_sats) {
X	  fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
X	  fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
X	} else {
X	  fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
X	  fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
X	};
X	fprintf(outf, "showpage\n");
X	top = 720;
X      };
X    } else {
X      fprintf(outf, "%d %d %f Saturn\n", SatColumn, top, SatManyRad);
X      fprintf(outf, "%s findfont %d scalefont setfont\n", SSFontname, SSmlsz);
X      fprintf(outf,
X "%f %d moveto (MM) stringwidth pop Sat-order-array array-centershow\n",
X	      SatColumn + 72*SatManyRad + OrderOffset, top);
X      fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
X      fprintf(outf, "%f %d moveto (%s) show\n",
X	      SatColumn + 72*SatManyRad + DateOffset,
X	      top, datestr);
X
X      fprintf(outf, "\n");
X      top -= 72;
X      if (top <= 71) {
X	fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
X	fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
X	if (invert_sats) {
X	  fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
X	  fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
X	} else {
X	  fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
X	  fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
X	};
X	fprintf(outf, "showpage\n");
X	top = 720;
X      };
X    };
X  };
X
X  if (one_day)
X    fprintf(outf, "showpage\n");
X}
X
X/* End: called if multiple day */
Xvoid out_sat_end(o_sat, outf, invert_sats, start_date, interval_days)
X     FILE *o_sat, *outf;
X     int invert_sats;
X     double start_date, interval_days;
X{
X
X  fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
X  fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
X  fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
X  if (invert_sats) {
X    fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
X    fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
X  } else {
X    fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
X    fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
X  };
X  fprintf(outf, "showpage\n");
X}
END_OF_FILE
if test 23472 -ne `wc -c <'observe/outsat.c'`; then
    echo shar: \"'observe/outsat.c'\" unpacked with wrong size!
fi
# end of 'observe/outsat.c'
fi
if test -f 'starchart/readfile.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'starchart/readfile.c'\"
else
echo shar: Extracting \"'starchart/readfile.c'\" \(22399 characters\)
sed "s/^X//" >'starchart/readfile.c' <<'END_OF_FILE'
X/*
X * readfile.c
X * readstar routine
X * Copyright (c) 1989 by Craig Counterman (email: ccount@athena.mit.edu)
X * and Alan Paeth (awpaeth@watcgl)
X * all rights reserved
X *
X * You may copy the program, compile it, and run it,
X * but you may not try to make money off it, or pretend you wrote it.
X * (This copyright prevents you from selling the program - the
X *  author grants anyone the right to copy and install the program
X *  on any machine it will run on)
X */
X
Xstatic char rcsid[]="$Header: readfile.c,v 2.7 90/03/10 15:31:11 ccount Exp $";
X
X#include <stdio.h>
X#include <math.h>
X
Xchar *malloc();
X
X
X#ifndef SYSV
X#include <strings.h>
X#else
X#include <string.h>
X#endif
X#include <ctype.h>
X
X#include "star3.h"
X
X#ifndef READMODE
X#define READMODE "r"
X#endif
X#define OPENFAIL 0
X#define LINELEN 82
X
X
X/* PI / 180 = .0174532925199 */
X#define DCOS(x) (cos((x)*.0174532925199))
X#define DSIN(x) (sin((x)*.0174532925199))
X#define DTAN(x) (tan((x)*.0174532925199))
X#define DASIN(x) (asin(x)/.0174532925199)
X#define DATAN2(x,y) (atan2(x,y)/.0174532925199)
X#define MAX(a,b) ((a)>(b)?(a):(b))
X#define MIN(a,b) ((a)<(b)?(a):(b))
X
X
X/* read file function indirection to allow for use of alternate file readers */
Xextern int (*readfile)();
Xextern char *cur_file_name;
X
X/* Readstar globals */
Xextern double obj_lat, obj_lon, obj_mag;
Xextern char obj_type[3], obj_color[3], obj_label[3];
Xextern char obj_constell[4], obj_name[LINELEN];
Xextern char *obj_commnt, fileline[LINELEN];
X
X
X/* constellation abbreviations */
Xchar *con_table[] = {
X  "   ",
X  "AND",
X  "ANT",
X  "APS",
X  "AQL",
X  "AQR",
X  "ARA",
X  "ARI",
X  "AUR",
X  "BOO",
X  "CAE",
X  "CAM",
X  "CAP",
X  "CAR",
X  "CAS",
X  "CEN",
X  "CEP",
X  "CET",
X  "CHA",
X  "CIR",
X  "CMA",
X  "CMI",
X  "CNC",
X  "COL",
X  "COM",
X  "CRA",
X  "CRB",
X  "CRT",
X  "CRU",
X  "CRV",
X  "CVN",
X  "CYG",
X  "DEL",
X  "DOR",
X  "DRA",
X  "EQU",
X  "ERI",
X  "FOR",
X  "GEM",
X  "GRU",
X  "HER",
X  "HOR",
X  "HYA",
X  "HYI",
X  "IND",
X  "LAC",
X  "LEO",
X  "LEP",
X  "LIB",
X  "LMI",
X  "LUP",
X  "LYN",
X  "LYR",
X  "MEN",
X  "MIC",
X  "MON",
X  "MUS",
X  "NOR",
X  "OCT",
X  "OPH",
X  "ORI",
X  "PAV",
X  "PEG",
X  "PER",
X  "PHE",
X  "PIC",
X  "PSA",
X  "PSC",
X  "PUP",
X  "PYX",
X  "RET",
X  "SCL",
X  "SCO",
X  "SCT",
X  "SER",
X  "SEX",
X  "SGE",
X  "SGR",
X  "TAU",
X  "TEL",
X  "TRA",
X  "TRI",
X  "TUC",
X  "UMA",
X  "UMI",
X  "VEL",
X  "VIR",
X  "VOL",
X  "VUL"
X  };
X
X
X/* typedefs for exact sizes of int */
Xtypedef char int_8;
Xtypedef short int int_16;
Xtypedef long int int_32;
X
X/* BINFULL structure */
Xstruct bfull_struct {
X  int_32 lat;			/* RA in seconds * 1000 */
X  int_32 lon;			/* Dec in seconds * 1000 */
X  int_16 mag;			/* Mag * 1000 */
X  char tycolb[6];		/* Type, color, label fields */
X  int_8 consindx;		/* Index number of constellation */
X  int_16 strlen;		/* length of name and comment field */
X} binfull_in;
X
Xchar name_comment[LINELEN];
X
X/* BINOBJ structure */
Xstruct bobj_struct {
X  int_32 lat;			/* RA in seconds * 1000 */
X  int_32 lon;			/* Dec in seconds * 1000 */
X  int_16 mag;			/* Mag * 1000 */
X  char type[2];			/* e.g. 'SD', 'CO' */
X} binobj_in;
X
X/* BINSTAR structure */
Xstruct bstar_struct {
X  int_32 lat;			/* RA in seconds * 1000 */
X  int_32 lon;			/* Dec in seconds * 1000 */
X  int_16 mag;			/* Mag * 1000 */
X} binstar_in;
X
X#ifndef NO_GSC
X
X#ifndef MAXPATHLEN
X#define MAXPATHLEN 1025
X#endif
X
X/* GSC data */
Xstruct {
X  double ra_deg, dec_deg, mag;
X  int mag_band, class;
X} GSC[100];
Xint GSC_nlines;
Xint GSC_ID = 0;
Xint GSC_skip = FALSE;
Xchar id_str[5];
Xchar last_gsc[MAXPATHLEN] = "";
X#endif /* NO_GSC */
X
X/* readstar reads from the file the information for one object, and
X   loads the following variables:
Xdouble obj_lat, obj_lon, obj_mag;
Xchar obj_type[] ="SS", obj_color[3], obj_label[3];
Xchar obj_constell[3], obj_name[LINELEN];
Xchar *obj_commnt, fileline[LINELEN];
X
Xonly lat, lon, and mag are required.  type should default to 'SS',
Xcolor, label, constell default to "  ", and the rest default to ""
X*/
Xint readstar(file, ftype)
X     FILE *file;
X     int ftype;
X{
X  char *ptr;
X  double rah, ram, ras, dld, dlm, dl, inten;
X  int i, j;
X  int nchars;
X  char m1;
X
X  if ((ftype != LINEREAD) && (ftype != BINFULL)
X      && (ftype != BINOBJ) && (ftype != BINSTAR) && (ftype != GSCTYPE))
X    return (TRUE);
X  /* only LINEREAD, BINFULL, BINOBJ, BINSTAR and GSC supported at this time */
X
X  if (ftype == BINSTAR) {
X    if (fread((char *) &binstar_in, sizeof(binstar_in), 1, file) != 1) {
X      if (feof(file)) return TRUE;
X      perror("Error reading input file");
X      exit(2);
X    }
X
X    obj_lat = ((double) binstar_in.lat) / 3600000L;
X    obj_lon = ((double) binstar_in.lon) / 3600000L;
X    obj_mag = ((double) binstar_in.mag) / 1000L;
X    obj_type[0] = 'S';
X    obj_type[1] = 'S';
X    obj_color[0] = ' ';
X    obj_color[1] = ' ';
X    obj_label[0] = ' ';
X    obj_label[1] = ' ';
X    obj_constell[0] = ' ';
X    obj_constell[1] = ' ';
X    obj_constell[2] = ' ';
X    obj_name[0] = '\0';
X    obj_commnt = "";
X
X    strcpy(fileline, "");
X  } else if (ftype == BINOBJ) {
X    if (fread((char *) &binobj_in, sizeof(binobj_in), 1, file) != 1) {
X      if (feof(file)) return TRUE;
X      perror("Error reading input file");
X      exit(2);
X    }
X
X    obj_lat = ((double) binobj_in.lat) / 3600000L;
X    obj_lon = ((double) binobj_in.lon) / 3600000L;
X    obj_mag = ((double) binobj_in.mag) / 1000L;
X    obj_type[0] = binobj_in.type[0];
X    obj_type[1] = binobj_in.type[1];
X    obj_color[0] = ' ';
X    obj_color[1] = ' ';
X    obj_label[0] = ' ';
X    obj_label[1] = ' ';
X    obj_constell[0] = ' ';
X    obj_constell[1] = ' ';
X    obj_constell[2] = ' ';
X    obj_name[0] = '\0';
X    obj_commnt = "";
X
X    strcpy(fileline, "");
X  } else if (ftype == BINFULL) {
X    if (fread((char *) &binfull_in, sizeof(binfull_in), 1, file) != 1) {
X      if (feof(file)) return TRUE;
X      perror("Error reading input file");
X      exit(2);
X    }
X
X    if (binfull_in.strlen == 0)
X      strcpy(name_comment, "");
X    else {
X      if (fread((char *) name_comment, binfull_in.strlen, 1, file) != 1) {
X	perror("Error reading input file");
X	exit(2);
X      }
X      name_comment[binfull_in.strlen] = '\0';
X    }
X
X    obj_lat = ((double) binfull_in.lat) / 3600000L;
X    obj_lon = ((double) binfull_in.lon) / 3600000L;
X    obj_mag = ((double) binfull_in.mag) / 1000L;
X    obj_type[0] = binfull_in.tycolb[0];
X    obj_type[1] = binfull_in.tycolb[1];
X    obj_color[0] = binfull_in.tycolb[2];
X    obj_color[1] = binfull_in.tycolb[3];
X    obj_label[0] = binfull_in.tycolb[4];
X    obj_label[1] = binfull_in.tycolb[5];
X    strcpy(obj_constell,con_table[binfull_in.consindx]);
X
X    ptr = name_comment;
X    i = 0;
X    while (*ptr == ' ') ptr++;
X    while (*ptr != ',' && *ptr != '\n' && *ptr)
X      obj_name[i++] = *ptr++;
X    obj_name[i] = '\0';
X    if ((*ptr == ',') && (*++ptr) && name_comment[0]) obj_commnt = ptr;
X    else obj_commnt = "";
X
X    strcpy(fileline, "");
X#ifndef NO_GSC
X  } else if (ftype == GSCTYPE) {
X#define Val(ch) (ch - '0')
X    if (strcmp(cur_file_name, last_gsc)) { /* New file */
X      fseek(file, 8640L, 0);
X      strcpy(last_gsc, cur_file_name);
X      if (fread((char *) id_str, 5, 1, file) != 1) {
X	if (feof(file)) return TRUE;
X	perror("Error reading input file");
X	exit(2);
X      };
X      GSC_ID = Val(id_str[0])*10000 +
X	Val(id_str[1])*1000 +
X	Val(id_str[2])*100 +
X	Val(id_str[3])*10 +
X	Val(id_str[4]);
X    };
X    GSC_skip = FALSE;
X    do {
X      if (id_str[0] == ' ') return TRUE;
X      i = 0;
X      do {
X	if (fread((char *) fileline, 40, 1, file) != 1) {
X	  if (feof(file)) return TRUE;
X	  perror("Error reading input file");
X	  exit(2);
X	};
X	for (j = 0; j < 40; j++) if (fileline[j] == ' ') fileline[j] = '0';
X	/* We care about RA_DEG, DEC_DEG, MAG, MAG_BAND, CLASS, MULTIPLE */
X	/* We read the GSC_ID already to see if it is a continuation */
X	GSC[i].ra_deg = Val(fileline[0]) * 100.0 +
X	  Val(fileline[1]) * 10.0 +
X	  Val(fileline[2]) +
X	  Val(fileline[4]) / 10.0 +
X	  Val(fileline[5]) / 100.0 +
X	  Val(fileline[6]) / 1000.0 +
X	  Val(fileline[7]) / 10000.0 +
X	  Val(fileline[8]) / 100000.0;
X	if (fileline[10] == '-')
X	  GSC[i].dec_deg = -1 *
X	    (Val(fileline[11]) +
X	     Val(fileline[13]) / 10.0 +
X	     Val(fileline[14]) / 100.0 +
X	     Val(fileline[15]) / 1000.0 +
X	     Val(fileline[16]) / 10000.0 +
X	     Val(fileline[17]) / 100000.0);
X	else
X	  GSC[i].dec_deg =  ((fileline[9] == '-') ? -1 : 1) *
X	    (Val(fileline[10]) * 10.0 +
X	     Val(fileline[11]) +
X	     Val(fileline[13]) / 10.0 +
X	     Val(fileline[14]) / 100.0 +
X	     Val(fileline[15]) / 1000.0 +
X	     Val(fileline[16]) / 10000.0 +
X	     Val(fileline[17]) / 100000.0);
X	GSC[i].mag = Val(fileline[23]) * 10.0 +
X	  Val(fileline[24]) +
X	  Val(fileline[26]) / 10.0 +
X	  Val(fileline[27]) / 100.0;
X	GSC[i].mag_band = Val(fileline[32])*10 + Val(fileline[33]);
X	GSC[i].class = Val(fileline[34]);
X	i++;
X	if (fread((char *) id_str, 5, 1, file) != 1) {
X	  if (!feof(file)) {
X	    perror("Error reading input file");
X	    exit(2);
X	  };
X	};
X	if (!feof(file)) {
X	  j = Val(id_str[0])*10000 +
X	    Val(id_str[1])*1000 +
X	    Val(id_str[2])*100 +
X	    Val(id_str[3])*10 +
X	    Val(id_str[4]);
X	};
X      } while ((j == GSC_ID) && (!feof(file)) && (id_str[0] != ' '));
X      GSC_nlines = i;
X      GSC_ID = j;
X      /* for now just use first */
X/* There are many stars with class == 3, so we'll ignore class */
X/*      if (GSC[0].class == 0) {*/	/* is a star if class == 0 */
X	obj_lon = GSC[0].ra_deg;
X	obj_lat = GSC[0].dec_deg;
X	obj_mag = GSC[0].mag;
X	obj_type[0] = 'S';
X	obj_type[1] = 'S';
X	obj_color[0] = ' ';
X	obj_color[1] = ' ';
X	obj_label[0] = ' ';
X	obj_label[1] = ' ';
X	obj_constell[0] = ' ';
X	obj_constell[1] = ' ';
X	obj_constell[2] = ' ';
X	obj_name[0] = '\0';
X/*	obj_commnt = &fileline[0];*/
X	obj_commnt = "";
X	fileline[0] = '\0';
X	GSC_skip = FALSE;
X/* Ignoring class seems to be the right thing */
X/*      } else {*/			/* not a star, skip */
X/*	GSC_skip = TRUE;
X      };*/
X    } while (GSC_skip);
X#endif /* NO_GSC */
X  } else { /* LINEREAD */
X
X/*
X * file formats:
X * new
X064509-1643-14SDA1a CMASirius
X051432-0812015SDB8b ORIRigel
X * old
X064509-1643-146SSSirius
X051432-08120015SSRigel
X */
X
X    fgets(fileline, LINELEN, file);
X    if (feof(file)) return(TRUE);	/* IS AN ERROR or eof */
X    nchars = 0;
X    while (fileline[nchars++]);
X    nchars--;
X    nchars--;
X
X/*
X * sscanf of floats is TOOO slow:
X *     sscanf(fileline, "%2f%2f%2f%c%2f%2f ... );
X * use alternate:
X */
X#define F2(i) (((fileline[i]-'0')*10.0+fileline[i+1]-'0'))
X#define F3(i) (((fileline[i]-'0')*100.0+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
X#define F4(i) (((fileline[i]-'0')*1000.0+(fileline[i+1]-'0')*100+(fileline[i+2])-'0')*10+fileline[i+3]-'0')
X#define F3M(i) (((fileline[i]-'A'+10.0)*100+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
X    rah = F2(0);
X    ram = F2(2);
X    ras = F2(4);
X    dld = F2(7);
X    dlm = F2(9);
X/*
X * common code
X */
X#define DLDEGSEC 3600.0
X#define DLMINSEC 60.0
X#define RAHRSSEC 54000.0
X#define RAMINSEC 900.0
X#define RASECSEC 15.0
X
X
X    obj_lon = (RAHRSSEC*rah + RAMINSEC*ram + RASECSEC*ras)/DLDEGSEC;
X    dl = (DLDEGSEC*dld + DLMINSEC*dlm)/DLDEGSEC;
X    obj_lat = (fileline[6]  == '-') ? -dl : dl;
X    
X    /* set unknowns to blanks */
X    obj_color[0] = ' ';
X    obj_color[1] = ' ';
X    obj_color[2] = '\0';
X    obj_label[0] = ' ';
X    obj_label[1] = ' ';
X    obj_label[2] = '\0';
X    obj_constell[0] = ' ';
X    obj_constell[1] = ' ';
X    obj_constell[2] = ' ';
X    obj_constell[3] = '\0';
X    
X    if  (isdigit(fileline[14])) {
X    /*
X     * old reduced Yale catalog
X     */
X      inten = F3(12);
X      if (fileline[11] == '0' || fileline[11] == '+') obj_mag = inten/100.0;
X      else if (fileline[11] == '-') obj_mag = -inten/100.0;
X      else obj_mag = F4(11)/1000.0;	/* new feature for stars >= 10.0 mag */
X      
X      if (nchars > 15) {
X	obj_type[0] = fileline[15];
X	obj_type[1] = fileline[16];
X	ptr = &fileline[MIN(17,nchars)];
X	i = 0;
X	while (*ptr == ' ') ptr++;
X#ifdef ATARI_ST
X	while (*ptr != ',' && *ptr != '\n' && *ptr != '\r' && *ptr)
X	  obj_name[i++] = *ptr++;
X#else
X	while (*ptr != ',' && *ptr != '\n' && *ptr)
X	  obj_name[i++] = *ptr++;
X#endif
X	obj_name[i] = '\0';
X	if (*++ptr) obj_commnt = ptr;
X	else obj_commnt = "";
X      } else {
X	obj_type[0] = obj_type[1] = 'S'; /* Default SS single star */
X	obj_name[0] = '\0';
X	obj_commnt = "";
X      }
X    } else {
X      /*
X       * new reduced Yale catalog
X       */
X      m1 = fileline[11];
X      obj_mag = ((m1 == '-') ? -F2(12)/10.0 :
X		 (m1 <= '9') ? F3(11)/100.0 : F3M(11)/100.0);
X      /* let's get Sirius */
X    
X      /*
X       * extract color, label, constellation, name, and comment
X       * Would be faster to just guarentee that the data file is correct
X       */
X      if (nchars > 22) {
X	obj_constell[0] = fileline[20];
X	obj_constell[1] = fileline[21];
X	obj_constell[2] = fileline[22];
X	obj_constell[3] = '\0';
X      }
X      if (nchars > 19) {
X	obj_label[0] = fileline[18];
X	obj_label[1] = fileline[19];
X	obj_label[2] = '\0';
X      }
X      if (nchars > 17) {
X	obj_color[0] = fileline[16]; 
X	obj_color[1] = fileline[17];
X	obj_color[2] = '\0';
X      }
X      if (nchars > 15) {
X	obj_type[0] = fileline[14];
X	obj_type[1] = fileline[15];
X      }
X
X      ptr = &fileline[MIN(23,nchars)];
X      i = 0;
X      while (*ptr == ' ') ptr++;
X#ifdef ATARI_ST
X      while (*ptr != ',' && *ptr != '\n' && *ptr != '\r' && *ptr)
X	obj_name[i++] = *ptr++;
X#else
X      while (*ptr != ',' && *ptr != '\n' && *ptr)
X	obj_name[i++] = *ptr++;
X#endif
X      obj_name[i] = '\0';
X      if (*++ptr) obj_commnt = ptr;
X      else obj_commnt = "";
X    }
X  }
X
X  return(FALSE); /* NO error */
X}
X
X/* Macintosh, under MPW, currently won't do buf_readstar */
X#ifndef macintosh
X#ifdef ATARI_ST
X#include<types.h>
X#include<stat.h>
X#else
X#include<sys/types.h>
X#include<sys/stat.h>
X#endif
X
X/* > MAXMAPFILES because more files may be read
X   if chart is changed interactively */
Xstruct fbuf {
X  char *name;
X  char *data;
X  char *cur_point;
X  char *last_point;
X} buf_files[10*MAXMAPFILES];
X
Xint nbuf_files = 0;
X
Xchar *last_read = "";
Xchar *cur_fpt = NULL;
Xchar *eodata = NULL;
Xint cur_buf = 0;
X
Xint buf_readstar(file, ftype)
X     FILE *file;
X     int ftype;
X{
X  int i;
X  struct stat fstats;
X  unsigned fsze;
X
X  char *ptr;
X  double rah, ram, ras, dld, dlm, dl, inten;
X  int nchars;
X  char m1;
X
X  if (ftype == GSCTYPE) return readstar(file, ftype);
X  /* We don't do buffered reads of the GSC data. */
X
X  /* if we've read this file before, access from memory
X     usually will be last read
X     Otherwise, try to allocate memory for file */
X
X  if (strcmp(cur_file_name, last_read)) {	/* New file, most likely */
X    for (i = 0; i < nbuf_files; i++)
X      if (!strcmp(cur_file_name, buf_files[i].name)) break;
X
X    if (i == nbuf_files) {	/* Need to read the file */
X      buf_files[nbuf_files].name =
X	(char *) malloc((unsigned) strlen(cur_file_name)+1);
X      strcpy(buf_files[nbuf_files].name, cur_file_name);
X
X#ifndef ATARI_ST
X      fstat(fileno(file), &fstats);
X#else
X      /* MWC 3.06 fstat is not implemented correctly. st_size is
X	 always 0 (according to the manual !!) despite it's known. */
X      stat(cur_file_name, &fstats);
X#endif
X      fsze = fstats.st_size;
X      if (fsze != 0) {		/* e.g. /dev/null */
X	buf_files[nbuf_files].data = (char *) malloc(fsze);
X	if ((buf_files[nbuf_files].data == NULL)
X	    || (((fsze = fread(buf_files[nbuf_files].data, 1,
X			       (int) fsze, file)) == 0)  /* no bytes read */
X		&& (!feof(file)))) { /* And it's not the end of the file */
X	  readfile = readstar;	/* Give up on buf_readstar */
X	  D_comment("buffered file read: Out of memory\n");
X
X				/* call readstar now */
X	  return readstar(file, ftype);
X	}
X      } else
X	buf_files[nbuf_files].data = "";
X
X      buf_files[nbuf_files].cur_point = buf_files[nbuf_files].data;
X      cur_fpt = buf_files[nbuf_files].cur_point;
X      buf_files[nbuf_files].last_point =
X	buf_files[nbuf_files].cur_point + fsze;
X      eodata = buf_files[nbuf_files].last_point;
X      last_read = buf_files[nbuf_files].name;
X      cur_buf = nbuf_files;
X      nbuf_files++;
X    } else { 			/* Old file */
X/*      D_comment("Reading from memory\n");*/
X      last_read = buf_files[i].name;
X      cur_fpt = buf_files[i].cur_point = buf_files[i].data;
X      eodata = buf_files[i].last_point;
X      cur_buf = i;
X    }
X  }
X
X  /* Now, cur_fpt points to file data.  Read the data as in readstar above */
X  if ((ftype != LINEREAD) && (ftype != BINFULL)
X      && (ftype != BINOBJ) && (ftype != BINSTAR))
X    return (TRUE);
X  /* only LINEREAD, BINFULL, BINOBJ and BINSTAR supported at this time */
X
X  if (cur_fpt == eodata) return TRUE; /* End of data, end of file */
X
X
X  if (ftype == BINSTAR) {
X    for (i = 0, ptr = (char *) &binstar_in; i < sizeof(binstar_in); i++) 
X      *ptr++ = *cur_fpt++;
X    buf_files[cur_buf].cur_point += sizeof(binstar_in);
X
X    obj_lat = ((double) binstar_in.lat) / 3600000L;
X    obj_lon = ((double) binstar_in.lon) / 3600000L;
X    obj_mag = ((double) binstar_in.mag) / 1000L;
X    obj_type[0] = 'S';
X    obj_type[1] = 'S';
X    obj_color[0] = ' ';
X    obj_color[1] = ' ';
X    obj_label[0] = ' ';
X    obj_label[1] = ' ';
X    obj_constell[0] = ' ';
X    obj_constell[1] = ' ';
X    obj_constell[2] = ' ';
X    obj_name[0] = '\0';
X    obj_commnt = "";
X
X    strcpy(fileline, "");
X  } else if (ftype == BINOBJ) {
X    for (i = 0, ptr = (char *) &binobj_in; i < sizeof(binobj_in); i++) 
X      *ptr++ = *cur_fpt++;
X    buf_files[cur_buf].cur_point += sizeof(binobj_in);
X
X    obj_lat = ((double) binobj_in.lat) / 3600000L;
X    obj_lon = ((double) binobj_in.lon) / 3600000L;
X    obj_mag = ((double) binobj_in.mag) / 1000L;
X    obj_type[0] = binobj_in.type[0];
X    obj_type[1] = binobj_in.type[1];
X    obj_color[0] = ' ';
X    obj_color[1] = ' ';
X    obj_label[0] = ' ';
X    obj_label[1] = ' ';
X    obj_constell[0] = ' ';
X    obj_constell[1] = ' ';
X    obj_constell[2] = ' ';
X    obj_name[0] = '\0';
X    obj_commnt = "";
X
X    strcpy(fileline, "");
X  } else if (ftype == BINFULL) {
X    for (i = 0, ptr = (char *) &binfull_in; i < sizeof(binfull_in); i++) 
X      *ptr++ = *cur_fpt++;
X    buf_files[cur_buf].cur_point += sizeof(binfull_in);
X
X    if (binfull_in.strlen == 0)
X      strcpy(name_comment, "");
X    else {
X      for (i = 0; i < binfull_in.strlen; i++) 
X	name_comment[i] = *cur_fpt++;
X      buf_files[cur_buf].cur_point += binfull_in.strlen;
X
X      name_comment[binfull_in.strlen] = '\0';
X    }
X
X    obj_lat = ((double) binfull_in.lat) / 3600000L;
X    obj_lon = ((double) binfull_in.lon) / 3600000L;
X    obj_mag = ((double) binfull_in.mag) / 1000L;
X    obj_type[0] = binfull_in.tycolb[0];
X    obj_type[1] = binfull_in.tycolb[1];
X    obj_color[0] = binfull_in.tycolb[2];
X    obj_color[1] = binfull_in.tycolb[3];
X    obj_label[0] = binfull_in.tycolb[4];
X    obj_label[1] = binfull_in.tycolb[5];
X    strcpy(obj_constell,con_table[binfull_in.consindx]);
X
X    ptr = name_comment;
X    i = 0;
X    while (*ptr == ' ') ptr++;
X    while (*ptr != ',' && *ptr != '\n' && *ptr)
X      obj_name[i++] = *ptr++;
X    obj_name[i] = '\0';
X    if ((*ptr == ',') && (*++ptr) && name_comment[0]) obj_commnt = ptr;
X    else obj_commnt = "";
X
X    strcpy(fileline, "");
X  } else { /* LINEREAD */
X
X/*
X * file formats:
X * new
X064509-1643-14SDA1a CMASirius
X051432-0812015SDB8b ORIRigel
X * old
X064509-1643-146SSSirius
X051432-08120015SSRigel
X */
X
X    ptr = fileline;
X    while ((*ptr++ = *cur_fpt++) != '\n');
X    *ptr = '\0';
X    buf_files[cur_buf].cur_point = cur_fpt;
X
X    nchars = 0;
X    while (fileline[nchars++]);
X    nchars--;
X    nchars--;
X
X/*
X * sscanf of floats is TOOO slow:
X *     sscanf(fileline, "%2f%2f%2f%c%2f%2f ... );
X * use alternate:
X */
X#define F2(i) (((fileline[i]-'0')*10.0+fileline[i+1]-'0'))
X#define F3(i) (((fileline[i]-'0')*100.0+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
X#define F4(i) (((fileline[i]-'0')*1000.0+(fileline[i+1]-'0')*100+(fileline[i+2])-'0')*10+fileline[i+3]-'0')
X#define F3M(i) (((fileline[i]-'A'+10.0)*100+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
X    rah = F2(0);
X    ram = F2(2);
X    ras = F2(4);
X    dld = F2(7);
X    dlm = F2(9);
X/*
X * common code
X */
X#define DLDEGSEC 3600.0
X#define DLMINSEC 60.0
X#define RAHRSSEC 54000.0
X#define RAMINSEC 900.0
X#define RASECSEC 15.0
X
X
X    obj_lon = (RAHRSSEC*rah + RAMINSEC*ram + RASECSEC*ras)/DLDEGSEC;
X    dl = (DLDEGSEC*dld + DLMINSEC*dlm)/DLDEGSEC;
X    obj_lat = (fileline[6]  == '-') ? -dl : dl;
X    
X    /* set unknowns to blanks */
X    obj_color[0] = ' ';
X    obj_color[1] = ' ';
X    obj_color[2] = '\0';
X    obj_label[0] = ' ';
X    obj_label[1] = ' ';
X    obj_label[2] = '\0';
X    obj_constell[0] = ' ';
X    obj_constell[1] = ' ';
X    obj_constell[2] = ' ';
X    obj_constell[3] = '\0';
X    
X    if  (isdigit(fileline[14])) {
X    /*
X     * old reduced Yale catalog
X     */
X      inten = F3(12);
X      if (fileline[11] == '0' || fileline[11] == '+') obj_mag = inten/100.0;
X      else if (fileline[11] == '-') obj_mag = -inten/100.0;
X      else obj_mag = F4(11)/1000.0;	/* new feature for stars >= 10.0 mag */
X      
X      if (nchars > 15) {
X	obj_type[0] = fileline[15];
X	obj_type[1] = fileline[16];
X	ptr = &fileline[MIN(17,nchars)];
X	i = 0;
X	while (*ptr == ' ') ptr++;
X	while (*ptr != ',' && *ptr != '\n' && *ptr)
X	  obj_name[i++] = *ptr++;
X	obj_name[i] = '\0';
X	if (*++ptr) obj_commnt = ptr;
X	else obj_commnt = "";
X      } else {
X	obj_type[0] = obj_type[1] = 'S'; /* Default SS single star */
X	obj_name[0] = '\0';
X	obj_commnt = "";
X      }
X    } else {
X      /*
X       * new reduced Yale catalog
X       */
X      m1 = fileline[11];
X      obj_mag = ((m1 == '-') ? -F2(12)/10.0 :
X		 (m1 <= '9') ? F3(11)/100.0 : F3M(11)/100.0);
X      /* let's get Sirius */
X    
X      /*
X       * extract color, label, constellation, name, and comment
X       * Would be faster to just guarentee that the data file is correct
X       */
X      if (nchars > 22) {
X	obj_constell[0] = fileline[20];
X	obj_constell[1] = fileline[21];
X	obj_constell[2] = fileline[22];
X	obj_constell[3] = '\0';
X      }
X      if (nchars > 19) {
X	obj_label[0] = fileline[18];
X	obj_label[1] = fileline[19];
X	obj_label[2] = '\0';
X      }
X      if (nchars > 17) {
X	obj_color[0] = fileline[16]; 
X	obj_color[1] = fileline[17];
X	obj_color[2] = '\0';
X      }
X      if (nchars > 15) {
X	obj_type[0] = fileline[14];
X	obj_type[1] = fileline[15];
X      }
X
X      ptr = &fileline[MIN(23,nchars)];
X      i = 0;
X      while (*ptr == ' ') ptr++;
X      while (*ptr != ',' && *ptr != '\n' && *ptr)
X	obj_name[i++] = *ptr++;
X      obj_name[i] = '\0';
X      if (*++ptr) obj_commnt = ptr;
X      else obj_commnt = "";
X    }
X  }
X
X  return(FALSE); /* NO error */
X}
X#endif /* macintosh */
END_OF_FILE
if test 22399 -ne `wc -c <'starchart/readfile.c'`; then
    echo shar: \"'starchart/readfile.c'\" unpacked with wrong size!
fi
# end of 'starchart/readfile.c'
fi
echo shar: End of archive 13 \(of 32\).
cp /dev/null ark13isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 32 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0