Index: /trunk/SophyaExt/XephemAstroLib/Makefile
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/Makefile	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/Makefile	(revision 2551)
@@ -10,4 +10,5 @@
 	if [ ! -d $(EXTINCPATH)/XAstro ] ; then mkdir $(EXTINCPATH)/XAstro ; fi
 	rm -f $(EXTINCPATH)/XAstro/astro.h
+	rm -f $(EXTINCPATH)/XAstro/bdl.h
 	rm -f $(EXTINCPATH)/XAstro/P_.h
 	rm -f $(EXTLIBPATH)/libxastro.a
Index: unk/SophyaExt/XephemAstroLib/Makefile.bak
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/Makefile.bak	(revision 2550)
+++ 	(revision )
@@ -1,64 +1,0 @@
-# Makefile for the basic astronomy routines.
-# The idea is to compile and archive them into libastro.a
-
-# flags assume gcc
-CFLAGS= -O2 -ffast-math -Wall
-CC = cc
-
-OBJS =	\
-	aa_hadec.o \
-	aberration.o \
-	actan.o \
-	airmass.o \
-	anomaly.o \
-	ap_as.o \
-	auxil.o \
-	chap95.o \
-	chap95_data.o \
-	circum.o \
-	comet.o \
-	dbfmt.o \
-	deep.o \
-	deltat.o \
-	earthsat.o \
-	eq_ecl.o \
-	eq_gal.o \
-	formats.o \
-	helio.o \
-	libration.o \
-	misc.o \
-	mjd.o \
-	moon.o \
-	mooncolong.o \
-	nutation.o \
-	obliq.o \
-	parallax.o \
-	plans.o \
-	precess.o \
-	reduce.o \
-	refract.o \
-	rings.o \
-	riset.o \
-	riset_cir.o \
-	sdp4.o \
-	sgp4.o \
-	sphcart.o \
-	sun.o \
-	thetag.o \
-	utc_gst.o \
-	twobody.o \
-	vsop87.o \
-	vsop87_data.o
-
-libastro.a:	$(OBJS)
-	ar rv $@ $?
-	ranlib $@
-
-libastro.so:    $(OBJS)
-	$(CC) -shared -o $@ $(OBJS)
-
-clobber:
-	rm -f *.o libastro.a
-
-# For RCS Only -- Do Not Edit
-# @(#) $RCSfile: Makefile.bak,v $ $Date: 2001-10-22 12:08:25 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $
Index: /trunk/SophyaExt/XephemAstroLib/Makefile.org
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/Makefile.org	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/Makefile.org	(revision 2551)
@@ -0,0 +1,93 @@
+# Makefile for the basic astronomy routines.
+# The idea is to compile and archive them into libastro.a
+
+# compiler and flags
+
+# gcc
+CC = gcc
+CFLAGS= -O2 -ffast-math -Wall
+
+# solaris
+# CC = cc
+# CFLAGS= -O
+
+# AIX
+# CC = xlc
+# CFLAGS= -O2 -qlanglvl=ansi -qarch=com -qmaxmem=16384
+
+# HP-UX
+# CC = cc
+# CFLAGS= -Aa -fast
+
+HS = astro.h bdl.h chap95.h deepconst.h preferences.h satlib.h satspec.h \
+	sattypes.h vector.h vsop87.h
+
+OBJS =			\
+	aa_hadec.o	\
+	aberration.o	\
+	actan.o		\
+	airmass.o	\
+	anomaly.o	\
+	ap_as.o		\
+	atlas.o		\
+	auxil.o		\
+	bdl.o		\
+	chap95.o	\
+	chap95_data.o	\
+	circum.o	\
+	comet.o		\
+	constel.o	\
+	dbfmt.o		\
+	deep.o		\
+	deltat.o	\
+	earthsat.o	\
+	eq_ecl.o	\
+	eq_gal.o	\
+	formats.o	\
+	helio.o		\
+	jupmoon.o	\
+	libration.o	\
+	magdecl.o	\
+	marsmoon.o	\
+	misc.o		\
+	mjd.o		\
+	moon.o		\
+	mooncolong.o	\
+	moonnf.o	\
+	nutation.o	\
+	obliq.o		\
+	parallax.o	\
+	parallactic.o	\
+	plans.o		\
+	plmoon.o	\
+	plshadow.o	\
+	precess.o	\
+	reduce.o	\
+	refract.o	\
+	rings.o		\
+	riset.o		\
+	riset_cir.o	\
+	satmoon.o	\
+	sdp4.o		\
+	sgp4.o		\
+	sphcart.o	\
+	sun.o		\
+	thetag.o	\
+	utc_gst.o	\
+	umoon.o		\
+	twobody.o	\
+	vsop87.o	\
+	vsop87_data.o
+
+libastro.a: $(HS) $(OBJS)
+	ar rv $@ $(OBJS)
+	ranlib $@
+
+libastro.so: $(HS) $(OBJS)
+	$(CC) -shared -o $@ $(OBJS)
+
+clobber:
+	rm -f *.o libastro.a
+
+# For RCS Only -- Do Not Edit
+# @(#) $RCSfile: Makefile.org,v $ $Date: 2004-06-15 16:54:11 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $
Index: unk/SophyaExt/XephemAstroLib/P_.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/P_.h	(revision 2550)
+++ 	(revision )
@@ -1,14 +1,0 @@
-/* surround declarations with P_() to include prototypes if it looks likes
- * compiler should handle them.
- */
-#ifndef P_
-#if defined(__STDC__) || defined(__cplusplus) || NeedFunctionPrototypes
-#define P_(s) s
-#else
-#define P_(s) ()
-#endif
-#endif /* P_ */
-
-/* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: P_.h,v $ $Date: 2001-10-22 12:08:25 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
- */
Index: unk/SophyaExt/XephemAstroLib/README
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/README	(revision 2550)
+++ 	(revision )
@@ -1,21 +1,0 @@
-This library contains the basic ephemeris code.
-
-Earth satellite orbit propagation is based on the NORAD SGP4/SDP4 code, as
-converted from the orginal FORTRAN to C by Magnus Backstrom. The paper
-"Spacetrack Report Number 3: Models for Propagation of NORAD Element Sets"
-describes the calculations.
-See http://www.celestrak.com/NORAD/documentation/spacetrk.pdf.
-He following files implement this package:
-    actan.c
-    deep.c
-    deepconst.h
-    satlib.h
-    satspec.h
-    sattypes.h
-    sdp4.c
-    sgp4.c
-    thetag.c
-    vector.h
-
-! For RCS Only -- Do Not Edit
-! @(#) $RCSfile: README,v $ $Date: 2001-10-22 12:08:25 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
Index: unk/SophyaExt/XephemAstroLib/VERSION
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/VERSION	(revision 2550)
+++ 	(revision )
@@ -1,5 +1,0 @@
---------------------------------------------------------
-     "libastro" Xephem library version 3.4
---------------------------------------------------------
-That code comes out of the Xephem software "libastro" part.
-http://www.clearskyinstitute.com/xephem/xephem.html
Index: /trunk/SophyaExt/XephemAstroLib/aa_hadec.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/aa_hadec.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/aa_hadec.c	(revision 2551)
@@ -5,35 +5,34 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
-static void aaha_aux P_((double lat, double x, double y, double *p, double *q));
+static void aaha_aux (double lt, double x, double y, double *p, double *q);
 
-/* given geographical latitude (n+, radians), lat, altitude (up+, radians),
+/* given geographical latitude (n+, radians), lt, altitude (up+, radians),
  * alt, and azimuth (angle round to the east from north+, radians),
  * return hour angle (radians), ha, and declination (radians), dec.
  */
 void
-aa_hadec (lat, alt, az, ha, dec)
-double lat;
-double alt, az;
-double *ha, *dec;
+aa_hadec (
+double lt,
+double alt, double az,
+double *ha, double *dec)
 {
-	aaha_aux (lat, az, alt, ha, dec);
+	aaha_aux (lt, az, alt, ha, dec);
 	if (*ha > PI)
 	    *ha -= 2*PI;
 }
 
-/* given geographical (n+, radians), lat, hour angle (radians), ha, and
+/* given geographical (n+, radians), lt, hour angle (radians), ha, and
  * declination (radians), dec, return altitude (up+, radians), alt, and
  * azimuth (angle round to the east from north+, radians),
  */
 void
-hadec_aa (lat, ha, dec, alt, az)
-double lat;
-double ha, dec;
-double *alt, *az;
+hadec_aa (
+double lt,
+double ha, double dec,
+double *alt, double *az)
 {
-	aaha_aux (lat, ha, dec, az, alt);
+	aaha_aux (lt, ha, dec, az, alt);
 }
 
@@ -43,6 +42,6 @@
  */
 double
-geoc_lat (phi)
-double phi;
+geoc_lat (
+double phi)
 {
 #define	MAXLAT	degrad(89.9999)	/* avoid tan() greater than this */
@@ -56,19 +55,19 @@
  */
 static void
-aaha_aux (lat, x, y, p, q)
-double lat;
-double x, y;
-double *p, *q;
+aaha_aux (
+double lt,
+double x, double y,
+double *p, double *q)
 {
-	static double last_lat = -3434, slat, clat;
+	static double last_lt = -3434, slt, clt;
 	double cap, B;
 
-	if (lat != last_lat) {
-	    slat = sin(lat);
-	    clat = cos(lat);
-	    last_lat = lat;
+	if (lt != last_lt) {
+	    slt = sin(lt);
+	    clt = cos(lt);
+	    last_lt = lt;
 	}
 
-	solve_sphere (-x, PI/2-y, slat, clat, &cap, &B);
+	solve_sphere (-x, PI/2-y, slt, clt, &cap, &B);
 	*p = B;
 	*q = PI/2 - acos(cap);
@@ -76,3 +75,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aa_hadec.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aa_hadec.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/aberration.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/aberration.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/aberration.c	(revision 2551)
@@ -2,5 +2,5 @@
  * based on secular unperturbed Kepler orbit
  *
- * the corrections should be applied to ra/dec and lam/beta of the 
+ * the corrections should be applied to ra/dec and lam/beta at the 
  * epoch of date.
  */
@@ -8,10 +8,6 @@
 #include <stdio.h>
 #include <math.h>
+#include <stdlib.h>
 
-#if defined(__STDC__)
-#include <stdlib.h>
-#endif
-
-#include "P_.h"
 #include "astro.h"
 
@@ -20,27 +16,24 @@
 #define AB_EQ_EOD	1
 
-static void ab_aux P_((double mjd, double *x, double *y, double lsn,
-	int mode));
+static void ab_aux (double mj, double *x, double *y, double lsn, int mode);
 
 /* apply aberration correction to ecliptical coordinates *lam and *bet
- * (in radians) for a given time mjd and handily supplied longitude of sun,
+ * (in radians) for a given time m and handily supplied longitude of sun,
  * lsn (in radians)
  */
 void
-ab_ecl (mjd, lsn, lam, bet)
-double mjd, lsn, *lam, *bet;
+ab_ecl (double mj, double lsn, double *lam, double *bet)
 {
-	ab_aux(mjd, lam, bet, lsn, AB_ECL_EOD);
+	ab_aux(mj, lam, bet, lsn, AB_ECL_EOD);
 }
 
 /* apply aberration correction to equatoreal coordinates *ra and *dec
- * (in radians) for a given time mjd and handily supplied longitude of sun,
+ * (in radians) for a given time m and handily supplied longitude of sun,
  * lsn (in radians)
  */
 void
-ab_eq (mjd, lsn, ra, dec)
-double mjd, lsn, *ra, *dec;
+ab_eq (double mj, double lsn, double *ra, double *dec)
 {
-	ab_aux(mjd, ra, dec, lsn, AB_EQ_EOD);
+	ab_aux(mj, ra, dec, lsn, AB_EQ_EOD);
 }
 
@@ -51,20 +44,18 @@
  */
 static void
-ab_aux (mjd, x, y, lsn, mode)
-double mjd, *x, *y, lsn;
-int mode;
+ab_aux (double mj, double *x, double *y, double lsn, int mode)
 {
-	static double lastmjd = -10000;
+	static double lastmj = -10000;
 	static double eexc;	/* earth orbit excentricity */
 	static double leperi;	/* ... and longitude of perihelion */
 	static char dirty = 1;	/* flag for cached trig terms */
 
-	if (mjd != lastmjd) {
+	if (mj != lastmj) {
 	    double T;		/* centuries since J2000 */
 
-	    T = (mjd - J2000)/36525.;
+	    T = (mj - J2000)/36525.;
 	    eexc = 0.016708617 - (42.037e-6 + 0.1236e-6 * T) * T;
 	    leperi = degrad(102.93735 + (0.71953 + 0.00046 * T) * T);
-	    lastmjd = mjd;
+	    lastmj = mj;
 	    dirty = 1;
 	}
@@ -99,5 +90,5 @@
 		    cp = cos(leperi);
 		    sp = sin(leperi);
-		    obliquity(mjd, &eps);
+		    obliquity(mj, &eps);
 		    se = sin(eps);
 		    ce = cos(eps);
@@ -127,5 +118,5 @@
 	default:
 	    printf ("ab_aux: bad mode: %d\n", mode);
-	    exit (1);
+	    abort();
 	    break;
 
@@ -134,3 +125,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aberration.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: aberration.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/actan.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/actan.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/actan.c	(revision 2551)
@@ -1,5 +1,5 @@
 #include <math.h>
 
-/* @(#) $Id: actan.c,v 1.2 2001-10-22 12:08:26 cmv Exp $ */
+/* @(#) $Id: actan.c,v 1.3 2004-06-15 16:52:37 cmv Exp $ */
 
 /* commonly in math.h, but not in strict ANSI C */
@@ -65,3 +65,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: actan.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: actan.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/airmass.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/airmass.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/airmass.c	(revision 2551)
@@ -1,5 +1,4 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
@@ -10,7 +9,7 @@
  */
 void
-airmass (aa, Xp)
-double aa;		/* apparent altitude, rads */
-double *Xp;		/* airmasses */
+airmass (
+double aa,		/* apparent altitude, rads */
+double *Xp)		/* airmasses */
 {
 	double sm1;	/* secant zenith angle, minus 1 */
@@ -25,3 +24,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: airmass.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: airmass.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/anomaly.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/anomaly.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/anomaly.c	(revision 2551)
@@ -4,5 +4,4 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
@@ -16,7 +15,5 @@
  */
 void
-anomaly (ma, s, nu, ea)
-double ma, s;
-double *nu, *ea;
+anomaly (double ma, double s, double *nu, double *ea)
 {
         double m, fea, corr;
@@ -64,3 +61,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: anomaly.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: anomaly.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/ap_as.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/ap_as.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/ap_as.c	(revision 2551)
@@ -1,7 +1,5 @@
 #include <string.h>
 
-#include "P_.h"
 #include "astro.h"
-#include "circum.h"
 
 /* convert the given apparent RA/Dec to astrometric precessed to Mjd IN PLACE.
@@ -11,8 +9,5 @@
  */
 void
-ap_as (np, Mjd, rap, decp)
-Now *np;
-double Mjd;
-double *rap, *decp;
+ap_as (Now *np, double Mjd, double *rap, double *decp)
 {
 	Obj o;
@@ -29,8 +24,7 @@
 	*rap -= o.s_ra - *rap;
 	*decp -= o.s_dec - *decp;
-	if (*decp >  PI/2) {*decp =  PI - *decp; *rap += PI; }
-	if (*decp < -PI/2) {*decp = -PI - *decp; *rap += PI; }
-	range (rap, 2*PI);
+	radecrange (rap, decp);
 	precess (mjd, Mjd, rap, decp);
+	radecrange (rap, decp);
 }
 
@@ -39,8 +33,5 @@
  */
 void
-as_ap (np, Mjd, rap, decp)
-Now *np;
-double Mjd;
-double *rap, *decp;
+as_ap (Now *np, double Mjd, double *rap, double *decp)
 {
 	Obj o;
@@ -60,3 +51,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: ap_as.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: ap_as.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/astro.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/astro.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/astro.h	(revision 2551)
@@ -1,2 +1,5 @@
+#ifndef _ASTRO_H
+#define _ASTRO_H
+
 #ifndef PI
 #define	PI		3.141592653589793
@@ -20,25 +23,549 @@
  * N.B. only the first 8 are valid for use with plans().
  */
-#define	MERCURY	0
-#define	VENUS	1
-#define	MARS	2
-#define	JUPITER	3
-#define	SATURN	4
-#define	URANUS	5
-#define	NEPTUNE	6
-#define	PLUTO	7
-
-/* a few more handy ones */
-#define	SUN	8
-#define	MOON	9
-#define	OBJX	10
-#define	OBJY	11
-#define	OBJZ	12
-#define	NOBJ	13	/* total number of basic objects */
+typedef enum {
+    MERCURY,
+    VENUS,
+    MARS,
+    JUPITER,
+    SATURN,
+    URANUS,
+    NEPTUNE,
+    PLUTO,
+    SUN,
+    MOON,
+    NOBJ	/* total number of basic objects */
+} PLCode;
+
+/* moon constants for pl_moon */
+typedef enum {
+    X_PLANET = 0,			/* use to mean planet itself */
+    PHOBOS = NOBJ, DEIMOS,
+    IO, EUROPA, GANYMEDE, CALLISTO,
+    MIMAS, ENCELADUS, TETHYS, DIONE, RHEA, TITAN, HYPERION, IAPETUS,
+    ARIEL, UMBRIEL, TITANIA, OBERON, MIRANDA,
+    NBUILTIN
+} MCode;
 
 /* starting point for MJD calculations
  */
 #define MJD0  2415020.0
-#define J2000 (2451545.0 - MJD0)      /* let compiler optimise */
+#define J2000 (2451545.0 - MJD0)      /* yes, 2000 January 1 at 12h */
+
+/* the Now and Obj typedefs.
+ * also, a few miscellaneous constants and declarations.
+ */
+
+#define	SPD	(24.0*3600.0)	/* seconds per day */
+#define	MAU	(1.4959787e11)	/* m / au */
+#define	LTAU	499.005		/* seconds light takes to travel 1 AU */
+#define	ERAD	(6.37816e6)	/* earth equitorial radius, m */
+#define	MRAD	(1.740e6)	/* moon equitorial radius, m */
+#define	SRAD	(6.95e8)	/* sun equitorial radius, m */
+#define	FTPM	3.28084		/* ft per m */
+#define	ESAT_MAG	2	/* default satellite magnitude */
+#define	FAST_SAT_RPD	0.25	/* max earth sat rev/day considered "fast" */
+
+#define	EOD	(-9786)		/* special epoch flag: use epoch of date */
+
+/* info about the local observing circumstances and misc preferences */
+typedef struct {
+	double n_mjd;	/* modified Julian date, ie, days since
+			 * Jan 0.5 1900 (== 12 noon, Dec 30, 1899), utc.
+			 * enough precision to get well better than 1 second.
+			 * N.B. if not first member, must move NOMJD inits.
+			 */
+	double n_lat;	/* geographic (surface-normal) lt, >0 north, rads */
+	double n_lng;	/* longitude, >0 east, rads */
+	double n_tz;	/* time zone, hrs behind UTC */
+	double n_temp;	/* atmospheric temp, degrees C */
+	double n_pressure; /* atmospheric pressure, mBar */
+	double n_elev;	/* elevation above sea level, earth radii */
+	double n_dip;	/* dip of sun below hzn at twilight, >0 below, rads */
+	double n_epoch;	/* desired precession display ep as an mjd, or EOD */
+	char n_tznm[8];	/* time zone name; 7 chars or less, always 0 at end */
+} Now;
+
+/* handy shorthands for fields in a Now pointer, np */
+#define mjd	np->n_mjd
+#define lat	np->n_lat
+#define lng	np->n_lng
+#define tz	np->n_tz
+#define temp	np->n_temp
+#define pressure np->n_pressure
+#define elev	np->n_elev
+#define	dip	np->n_dip
+#define epoch	np->n_epoch
+#define tznm	np->n_tznm
+#define mjed	mm_mjed(np)
+
+/* structures to describe objects of various types.
+ */
+
+/* magnitude values in two different systems */
+typedef struct {
+    float m1, m2;	/* either g/k or H/G, depending on... */
+    int whichm;		/* one of MAG_gk or MAG_HG */
+} Mag;
+
+/* whichm */
+#define MAG_HG          0       /* using 0 makes HG the initial default */
+#define MAG_gk          1
+
+/* we actually store magnitudes times this scale factor in a short int */
+#define	MAGSCALE	100.0
+#define	set_smag(op,m)	((op)->s_mag = (short)floor((m)*MAGSCALE + 0.5))
+#define	set_fmag(op,m)	((op)->f_mag = (short)floor((m)*MAGSCALE + 0.5))
+#define	get_mag(op)	((op)->s_mag / MAGSCALE)
+
+/* longest object name, including trailing '\0' */
+#define	MAXNM	21
+
+typedef unsigned char ObjType_t;
+typedef unsigned char ObjAge_t;
+typedef unsigned char byte;
+
+/* Obj is a massive union.
+ * many fields are in common so we use macros to make things a little easier.
+ */
+
+/* fields common to *all* structs in the Obj union */
+#define	OBJ_COMMON_FLDS							\
+    ObjType_t co_type;	/* current object type; see flags, below */	\
+    byte co_flags;	/* FUSER*... used by others */			\
+    ObjAge_t co_age;	/* update aging code; see db.c */		\
+    char co_name[MAXNM];/* name, including \0 */			\
+    float co_ra;	/* geo/topo app/mean ra, rads */		\
+    float co_dec;	/* geo/topo app/mean dec, rads */		\
+    float co_gaera;	/* geo apparent ra, rads */			\
+    float co_gaedec;	/* geo apparent dec, rads */			\
+    float co_az;	/* azimuth, >0 e of n, rads */			\
+    float co_alt;	/* altitude above topocentric horizon, rads */	\
+    float co_elong;	/* angular sep btwen obj and sun, >0 E, degs */	\
+    float co_size;	/* angular size, arc secs */			\
+    short co_mag	/* visual magnitude * MAGSCALE */
+
+/* fields common to all solar system objects in the Obj union */
+#define	OBJ_SOLSYS_FLDS							\
+    OBJ_COMMON_FLDS;	/* all the fixed ones plus ... */		\
+    float so_sdist;	/* dist from object to sun, au */		\
+    float so_edist;	/* dist from object to earth, au */		\
+    float so_hlong;	/* heliocentric longitude, rads */		\
+    float so_hlat;	/* heliocentric latitude, rads */		\
+    float so_phase	/* phase, % */
+
+/* fields common to all fixed objects in the Obj union */
+#define	OBJ_FIXED_FLDS 							\
+    char  fo_spect[2];	/* spectral codes, if appropriate */		\
+    float fo_epoch;	/* eq of ra/dec and time when pm=0; mjd */ 	\
+    float fo_ra;	/* ra, rads, in epoch frame */ 			\
+    float fo_dec;	/* dec, rads, in epoch frame */ 		\
+    float fo_pmra;	/* ra proper motion, rads/day/cos(dec) */ 	\
+    float fo_pmdec;	/* dec proper motion, rads/day */ 		\
+    char  fo_class	/* object class */
+
+/* a generic object */
+typedef struct {
+    OBJ_COMMON_FLDS;
+} ObjAny;
+
+/* a generic sol system object */
+typedef struct {
+    OBJ_SOLSYS_FLDS;
+} ObjSS;
+
+/* basic Fixed object info.
+ */
+typedef struct {
+    OBJ_COMMON_FLDS;
+    OBJ_FIXED_FLDS;
+
+    /* following are for galaxies */
+    byte  fo_ratio;	/* minor/major diameter ratio. use s/get_ratio() */
+    byte  fo_pa;	/* position angle, E of N, rads. use s/get_pa() */
+} ObjF;
+
+/* true-orbit parameters of binary-star object type */
+typedef struct {
+    float bo_T;		/* epoch of periastron, years */
+    float bo_e;		/* eccentricity */
+    float bo_o;		/* argument of periastron, degress */
+    float bo_O;		/* longitude of node, degrees */
+    float bo_i;		/* inclination to plane of sky, degrees */
+    float bo_a;		/* semi major axis, arc secs */
+    float bo_P;		/* period, years */
+
+    /* companion position, computed by obj_cir() iff b_2compute */
+    float bo_pa;	/* position angle @ ep, rads E of N */
+    float bo_sep;	/* separation @ ep, arc secs */
+    float bo_ra;	/* geo/topo app/mean ra, rads */
+    float bo_dec;	/* geo/topo app/mean dec, rads */
+} BinOrbit;
+typedef struct {
+    float bp_ep;	/* epoch of pa/sep, year */
+    float bp_pa;	/* position angle @ ep, rads E of N */
+    float bp_sep;	/* separation @ ep, arc secs */
+
+    /* companion position, computed by obj_cir() iff b_2compute */
+    float bp_ra;	/* geo/topo app/mean ra, rads */
+    float bp_dec;	/* geo/topo app/mean dec, rads */
+} BinPos;
+#define MAXBINPOS 2	/* max discrete epochs to store when no elements */
+typedef struct {
+    OBJ_COMMON_FLDS;
+    OBJ_FIXED_FLDS;
+
+    byte b_2compute;	/* whether to compute secondary positions */
+    byte b_nbp;		/* number of b_bp[] or 0 to use b_bo */
+    short b_2mag;	/* secondary's magnitude * MAGSCALE */
+    char b_2spect[2];	/* secondary's spectrum */
+
+    /* either a real orbit or a set of discrete pa/sep */
+    union {
+	BinOrbit b_bo;			/* orbital elements */
+	BinPos b_bp[MAXBINPOS];		/* table of discrete positions */
+    } u;
+} ObjB;
+
+#define	fo_mag	co_mag	/* pseudonym for so_mag since it is not computed */
+#define	fo_size	co_size	/* pseudonym for so_size since it is not computed */
+
+/* macros to pack/unpack some fields */
+#define	SRSCALE		255.0		/* galaxy size ratio scale */
+#define	PASCALE		(255.0/(2*PI))	/* pos angle scale factor */
+#define	get_ratio(op)	(((int)(op)->f_ratio)/SRSCALE)
+#define	set_ratio(op,maj,min) ((op)->f_ratio = (byte)(((maj) > 0)	    \
+					? ((min)*SRSCALE/(double)(maj)+0.5) \
+					: 0))
+#define	get_pa(op)	((double)(op)->f_pa/PASCALE)
+#define	set_pa(op,s)	((op)->f_pa = (byte)((s)*PASCALE + 0.5))
+
+#define	NCLASSES	128 /* n potential fo_classes -- allow for all ASCII */
+
+/* basic planet object info */
+typedef struct {
+    OBJ_SOLSYS_FLDS;
+    PLCode plo_code;		/* which planet */
+    MCode plo_moon;		/* which moon, or X_PLANET if planet */
+    char plo_evis, plo_svis;	/* if moon: whether visible from earth, sun */
+    double plo_x, plo_y, plo_z;	/* if moon: eq dist from center, planet radii */
+    double plo_aux1, plo_aux2;	/* various values, depending on type */
+} ObjPl;
+
+/* basic info about an object in elliptical heliocentric orbit */
+typedef struct {
+    OBJ_SOLSYS_FLDS;
+    float  eo_inc;	/* inclination, degrees */
+    float  eo_Om;	/* longitude of ascending node, degrees */
+    float  eo_om;	/* argument of perihelion, degress */
+    float  eo_a;	/* mean distance, aka,semi-maj axis,AU */
+    float  eo_M;	/* mean anomaly, ie, degrees from perihelion at cepoch*/
+    float  eo_size;	/* angular size, in arc seconds at 1 AU */
+    float  eo_startok;	/* nominal first mjd this set is ok, else 0 */
+    float  eo_endok;	/* nominal last mjd this set is ok, else 0 */
+    double eo_e;	/* eccentricity (double for when near 1 computing q) */
+    double eo_cepoch;	/* epoch date (M reference), as an mjd */
+    double eo_epoch;	/* equinox year (inc/Om/om reference), as an mjd. */
+    Mag    eo_mag;	/* magnitude */
+} ObjE;
+
+/* basic info about an object in hyperbolic heliocentric orbit */
+typedef struct {
+    OBJ_SOLSYS_FLDS;
+    double ho_epoch;	/* equinox year (inc/Om/om reference), as an mjd */
+    double ho_ep;	/* epoch of perihelion, as an mjd */
+    float  ho_startok;	/* nominal first mjd this set is ok, else 0 */
+    float  ho_endok;	/* nominal last mjd this set is ok, else 0 */
+    float  ho_inc;	/* inclination, degs */
+    float  ho_Om;	/* longitude of ascending node, degs */
+    float  ho_om;	/* argument of perihelion, degs. */
+    float  ho_e;	/* eccentricity */
+    float  ho_qp;	/* perihelion distance, AU */
+    float  ho_g, ho_k;	/* magnitude model coefficients */
+    float  ho_size;	/* angular size, in arc seconds at 1 AU */
+} ObjH;
+
+/* basic info about an object in parabolic heliocentric orbit */
+typedef struct {
+    OBJ_SOLSYS_FLDS;
+    double po_epoch;	/* reference epoch, as an mjd */
+    double po_ep;	/* epoch of perihelion, as an mjd */
+    float  po_startok;	/* nominal first mjd this set is ok, else 0 */
+    float  po_endok;	/* nominal last mjd this set is ok, else 0 */
+    float  po_inc;	/* inclination, degs */
+    float  po_qp;	/* perihelion distance, AU */
+    float  po_om;	/* argument of perihelion, degs. */
+    float  po_Om;	/* longitude of ascending node, degs */
+    float  po_g, po_k;	/* magnitude model coefficients */
+    float  po_size;	/* angular size, in arc seconds at 1 AU */
+} ObjP;
+
+/* basic earth satellite object info */
+typedef struct {
+    OBJ_COMMON_FLDS;
+    double eso_epoch;	/* reference epoch, as an mjd */
+    double eso_n;	/* mean motion, rev/day
+			 * N.B. we need double due to a sensitive differencing
+			 * operation used to compute MeanAnomaly in
+			 * esat_main()/satellite.c.
+			 */
+    float  eso_startok;	/* nominal first mjd this set is ok, else 0 */
+    float  eso_endok;	/* nominal last mjd this set is ok, else 0 */
+    float  eso_inc;	/* inclination, degs */
+    float  eso_raan;	/* RA of ascending node, degs */
+    float  eso_e;	/* eccentricity */
+    float  eso_ap;	/* argument of perigee at epoch, degs */
+    float  eso_M;	/* mean anomaly, ie, degrees from perigee at epoch */
+    float  eso_decay;	/* orbit decay rate, rev/day^2 */
+    float  eso_drag;	/* object drag coefficient, (earth radii)^-1 */
+    int    eso_orbit;	/* integer orbit number of epoch */
+
+    /* computed "sky" results unique to earth satellites */
+    float  ess_elev;	/* height of satellite above sea level, m */
+    float  ess_range;	/* line-of-site distance from observer to satellite, m*/
+    float  ess_rangev;	/* rate-of-change of range, m/s */
+    float  ess_sublat;	/* latitude below satellite, >0 north, rads */
+    float  ess_sublng;	/* longitude below satellite, >0 east, rads */
+    int    ess_eclipsed;/* 1 if satellite is in earth's shadow, else 0 */
+} ObjES;
+
+typedef union {
+    ObjAny  any;	/* these fields valid for all types */
+    ObjSS   anyss;	/* these fields valid for all solar system types */
+    ObjPl   pl;		/* planet */
+    ObjF    f;		/* fixed object, plus proper motion */
+    ObjB    b;		/* bona fide binary stars (doubles are stored in f) */
+    ObjE    e;		/* object in heliocentric elliptical orbit */
+    ObjH    h;		/* object in heliocentric hyperbolic trajectory */
+    ObjP    p;		/* object in heliocentric parabolic trajectory */
+    ObjES   es;		/* earth satellite */
+} Obj;
+
+
+/* for o_flags -- everybody must agree */
+#define	FUSER0		0x01
+#define	FUSER1		0x02
+#define	FUSER2		0x04
+#define	FUSER3		0x08
+#define	FUSER4		0x10
+#define	FUSER5		0x20
+#define	FUSER6		0x40
+#define	FUSER7		0x80
+
+/* mark an object as being a "field star" */
+#define	FLDSTAR		FUSER3
+/* mark an object as circum calculation failed */
+#define NOCIRCUM	FUSER7
+
+/* Obj shorthands: */
+#define	o_type		any.co_type
+#define	o_name		any.co_name
+#define	o_flags		any.co_flags
+#define	o_age		any.co_age
+#define	s_ra		any.co_ra
+#define	s_dec		any.co_dec
+#define	s_gaera		any.co_gaera
+#define	s_gaedec 	any.co_gaedec
+#define	s_az		any.co_az
+#define	s_alt		any.co_alt
+#define	s_elong		any.co_elong
+#define	s_size		any.co_size
+#define	s_mag		any.co_mag
+
+#define	s_sdist		anyss.so_sdist
+#define	s_edist		anyss.so_edist
+#define	s_hlong		anyss.so_hlong
+#define	s_hlat		anyss.so_hlat
+#define	s_phase 	anyss.so_phase
+
+#define	s_elev		es.ess_elev
+#define	s_range		es.ess_range
+#define	s_rangev	es.ess_rangev
+#define	s_sublat	es.ess_sublat
+#define	s_sublng	es.ess_sublng
+#define	s_eclipsed	es.ess_eclipsed
+
+#define	f_class		f.fo_class
+#define	f_spect		f.fo_spect
+#define	f_ratio		f.fo_ratio
+#define	f_pa		f.fo_pa
+#define	f_epoch		f.fo_epoch
+#define	f_RA		f.fo_ra
+#define	f_pmRA		f.fo_pmra
+#define	f_dec		f.fo_dec
+#define	f_pmdec		f.fo_pmdec
+#define	f_mag		f.fo_mag
+#define	f_size		f.fo_size
+
+#define	e_cepoch 	e.eo_cepoch
+#define	e_epoch		e.eo_epoch
+#define	e_startok	e.eo_startok
+#define	e_endok		e.eo_endok
+#define	e_inc		e.eo_inc
+#define	e_Om		e.eo_Om
+#define	e_om		e.eo_om
+#define	e_a		e.eo_a
+#define	e_e		e.eo_e
+#define	e_M		e.eo_M
+#define	e_size		e.eo_size
+#define	e_mag		e.eo_mag
+
+#define	h_epoch		h.ho_epoch
+#define	h_startok	h.ho_startok
+#define	h_endok		h.ho_endok
+#define	h_ep		h.ho_ep
+#define	h_inc		h.ho_inc
+#define	h_Om		h.ho_Om
+#define	h_om		h.ho_om
+#define	h_e		h.ho_e
+#define	h_qp		h.ho_qp
+#define	h_g		h.ho_g
+#define	h_k		h.ho_k
+#define	h_size		h.ho_size
+
+#define	p_epoch		p.po_epoch
+#define	p_startok	p.po_startok
+#define	p_endok		p.po_endok
+#define	p_ep		p.po_ep
+#define	p_inc		p.po_inc
+#define	p_qp		p.po_qp
+#define	p_om		p.po_om
+#define	p_Om		p.po_Om
+#define	p_g		p.po_g
+#define	p_k		p.po_k
+#define	p_size		p.po_size
+
+#define	es_epoch	es.eso_epoch
+#define	es_startok	es.eso_startok
+#define	es_endok	es.eso_endok
+#define	es_inc		es.eso_inc
+#define	es_raan		es.eso_raan
+#define	es_e		es.eso_e
+#define	es_ap		es.eso_ap
+#define	es_M		es.eso_M
+#define	es_n		es.eso_n
+#define	es_decay	es.eso_decay
+#define	es_drag		es.eso_drag
+#define	es_orbit	es.eso_orbit
+
+#define	pl_code		pl.plo_code
+#define	pl_moon		pl.plo_moon
+#define	pl_evis		pl.plo_evis
+#define	pl_svis		pl.plo_svis
+#define	pl_x		pl.plo_x
+#define	pl_y		pl.plo_y
+#define	pl_z		pl.plo_z
+#define	pl_aux1		pl.plo_aux1
+#define	pl_aux2		pl.plo_aux2
+
+#define b_2compute	b.b_2compute
+#define b_2spect	b.b_2spect
+#define b_2mag		b.b_2mag
+#define b_bo		b.u.b_bo
+#define b_bp		b.u.b_bp
+#define b_nbp		b.b_nbp
+
+/* insure we always refer to the fields and no monkey business */
+#undef OBJ_COMMON_FLDS
+#undef OBJ_SOLSYS_FLDS
+
+/* o_type code.
+ * N.B. names are assigned in order in objmenu.c
+ * N.B. if add one add switch in obj_cir().
+ * N.B. UNDEFOBJ must be zero so new objects are undefinied by being zeroed.
+ * N.B. maintain the bitmasks too.
+ */
+enum ObjType {
+    UNDEFOBJ=0,
+    FIXED, BINARYSTAR, ELLIPTICAL, HYPERBOLIC, PARABOLIC, EARTHSAT, PLANET,
+    NOBJTYPES
+};
+
+/* types as handy bitmasks too */
+#define	OBJTYPE2MASK(t)	(1<<(t))
+#define	FIXEDM		OBJTYPE2MASK(FIXED)
+#define	BINARYSTARM	OBJTYPE2MASK(BINARYSTAR)
+#define	ELLIPTICALM	OBJTYPE2MASK(ELLIPTICAL)
+#define	HYPERBOLICM	OBJTYPE2MASK(HYPERBOLIC)
+#define	PARABOLICM	OBJTYPE2MASK(PARABOLIC)
+#define	EARTHSATM	OBJTYPE2MASK(EARTHSAT)
+#define	PLANETM		OBJTYPE2MASK(PLANET)
+#define	ALLM		(~0)
+
+/* rise, set and transit information.
+ */
+typedef struct {
+    int rs_flags;	/* info about what has been computed and any
+			 * special conditions; see flags, below.
+			 */
+    double rs_risetm;	/* mjd time of rise today */
+    double rs_riseaz;	/* azimuth of rise, rads E of N */
+    double rs_trantm;	/* mjd time of transit today */
+    double rs_tranalt;	/* altitude of transit, rads up from horizon */
+    double rs_settm;	/* mjd time of set today */
+    double rs_setaz;	/* azimuth of set, rads E of N */
+} RiseSet;
+
+/* RiseSet flags */
+#define	RS_NORISE	0x0001	/* object does not rise as such today */
+#define	RS_NOSET	0x0002	/* object does not set as such today */
+#define	RS_NOTRANS	0x0004	/* object does not transit as such today */
+#define	RS_CIRCUMPOLAR	0x0010	/* object stays up all day today */
+#define	RS_NEVERUP	0x0020	/* object never up at all today */
+#define	RS_ERROR	0x1000	/* can't figure out anything! */
+#define	RS_RISERR	(0x0100|RS_ERROR) /* error computing rise */
+#define	RS_SETERR	(0x0200|RS_ERROR) /* error computing set */
+#define	RS_TRANSERR	(0x0400|RS_ERROR) /* error computing transit */
+
+#define	is_type(op,m)	(OBJTYPE2MASK((op)->o_type) & (m))
+
+/* any planet or its moons */
+#define	is_planet(op,p)	(is_type(op,PLANETM) && op->pl_code == (p))
+
+/* any solar system object */
+#define	is_ssobj(op)	is_type(op,PLANETM|HYPERBOLICM|PARABOLICM|ELLIPTICALM)
+
+
+
+/* natural satellite support */
+
+typedef struct {
+    char *full;		/* full name */
+    char *tag;		/* Roman numeral tag */
+    float x, y, z;	/* radii: +x:east +y:south +z:front */
+    float ra, dec;
+    float mag;
+    int evis;		/* whether geometrically visible from earth */
+    int svis;		/* whether in sun light */
+} MoonData;
+
+/* separate set for each planet -- use in pl_moon */
+
+
+enum _marsmoons {
+    M_MARS = 0,					/* == X_PLANET */
+    M_PHOBOS, M_DEIMOS,
+    M_NMOONS					/* including planet at 0 */
+};
+
+enum _jupmoons {
+    J_JUPITER = 0,				/* == X_PLANET */
+    J_IO, J_EUROPA, J_GANYMEDE, J_CALLISTO,
+    J_NMOONS					/* including planet */
+};
+
+enum _satmoons {
+    S_SATURN = 0,				/* == X_PLANET */
+    S_MIMAS, S_ENCELADUS, S_TETHYS, S_DIONE,
+    S_RHEA, S_TITAN, S_HYPERION, S_IAPETUS,
+    S_NMOONS					/* including planet */
+};
+
+enum _uramoons {
+    U_URANUS = 0,				/* == X_PLANET */
+    U_ARIEL, U_UMBRIEL, U_TITANIA, U_OBERON, U_MIRANDA,
+    U_NMOONS					/* including planet */
+};
+
+#define	X_MAXNMOONS	S_NMOONS		/* N.B. chosen by hand */
 
 
@@ -46,149 +573,233 @@
 /* global function declarations */
 
+
 /* aa_hadec.c */
-extern void aa_hadec P_((double lat, double alt, double az, double *ha,
-    double *dec));
-extern void hadec_aa P_((double lat, double ha, double dec, double *alt,
-    double *az)); 
+extern void aa_hadec (double lt, double alt, double az, double *ha,
+    double *dec);
+extern void hadec_aa (double lt, double ha, double dec, double *alt,
+    double *az); 
 
 /* aberration.c */
-extern void ab_ecl P_((double mjd, double lsn, double *lam, double *bet));
-extern void ab_eq P_((double mjd, double lsn, double *ra, double *dec));
+extern void ab_ecl (double m, double lsn, double *lam, double *bet);
+extern void ab_eq (double m, double lsn, double *ra, double *dec);
 
 /* airmass.c */
-extern void airmass P_((double aa, double *Xp));
+extern void airmass (double aa, double *Xp);
 
 /* anomaly.c */
-extern void anomaly P_((double ma, double s, double *nu, double *ea));
+extern void anomaly (double ma, double s, double *nu, double *ea);
+
+/* ap_as.c */
+extern void ap_as ( Now *np, double Mjd, double *rap, double *decp);
+extern void as_ap ( Now *np, double Mjd, double *rap, double *decp);
+
+/* atlas.c */
+extern char *um_atlas (double ra, double dec);
+extern char *u2k_atlas (double ra, double dec);
+extern char *msa_atlas (double ra, double dec);
+
+/* aux.c */
+extern double mm_mjed (Now *np);
 
 /* chap95.c */
-extern int chap95 P_((double mjd, int obj, double prec, double *ret));
+extern int chap95 (double m, int obj, double prec, double *ret);
 
 /* chap95_data.c */
 
+/* circum.c */
+extern int obj_cir (Now *np, Obj *op);
+
 /* comet.c */
-extern void comet P_((double mjd, double ep, double inc, double ap, double qp,
+extern void comet (double m, double ep, double inc, double ap, double qp,
     double om, double *lpd, double *psi, double *rp, double *rho, double *lam,
-    double *bet));
+    double *bet);
+
+/* constel.c */
+#define	NCNS	89
+extern int cns_pick (double r, double d, double e);
+extern int cns_id (char *abbrev);
+extern char *cns_name (int id);
+extern int cns_edges (double e, double **ra0p, double **dec0p, double **ra1p,
+    double **dec1p);
+extern int cns_list (double ra, double dec, double e, double rad, int ids[]);
+extern int cns_figure (int id, double e, double ra[],double dec[],int dcodes[]);
+extern int cns_reyfigure (int id, double e, double ra[], double dec[],
+    int dcodes[]);
+
+/* dbfmt.c */
+extern int db_crack_line (char s[], Obj *op, char nm[][MAXNM], int nnm,
+    char whynot[]);
+extern void db_write_line (Obj *op, char *lp);
+extern int dbline_candidate (char line[]);
+extern int get_fields (char *s, int delim, char *fields[]);
+extern int db_tle (char *name, char *l1, char *l2, Obj *op);
+extern int dateRangeOK (Now *np, Obj *op);
 
 /* deltat.c */
-extern double deltat P_((double mjd));
+extern double deltat (double m);
+
+/* earthsat.c */
+extern int obj_earthsat (Now *np, Obj *op);
 
 /* eq_ecl.c */
-extern void eq_ecl P_((double mjd, double ra, double dec, double *lat,
-    double *lng));
-extern void ecl_eq P_((double mjd, double lat, double lng, double *ra,
-    double *dec));
+extern void eq_ecl (double m, double ra, double dec, double *lt,double *lg);
+extern void ecl_eq (double m, double lt, double lg, double *ra,double *dec);
 
 /* eq_gal.c */
-extern void eq_gal P_((double mjd, double ra, double dec, double *lat,
-    double *lng));
-extern void gal_eq P_((double mjd, double lat, double lng, double *ra,
-    double *dec));
+extern void eq_gal (double m, double ra, double dec, double *lt,double *lg);
+extern void gal_eq (double m, double lt, double lg, double *ra,double *dec);
 
 /* formats.c */
-extern void fs_sexa P_((char *out, double a, int w, int fracbase));
-extern void fs_date P_((char out[], double jd));
-extern void f_scansex P_((double o, char *str, double *dp));
-extern void f_sscandate P_((char *bp, int pref, int *m, double *d, int *y));
-extern int scansex P_((char *str, double *dp));
+extern int fs_sexa (char *out, double a, int w, int fracbase);
+extern int fs_date (char out[], double jd);
+extern int f_scansexa (const char *str, double *dp);
+extern void f_sscandate (char *bp, int pref, int *m, double *d, int *y);
 
 /* helio.c */
-extern void heliocorr P_((double jd, double ra, double dec, double *hcp));
+extern void heliocorr (double jd, double ra, double dec, double *hcp);
+
+/* jupmoon.c */
+extern void jupiter_data (double Mjd, char dir[], Obj *eop, Obj *jop,
+    double *jupsize, double *cmlI, double *cmlII, MoonData md[J_NMOONS]); 
 
 /* libration.c */
-extern void llibration P_((double JD, double *llatp, double *llonp));
+extern void llibration (double JD, double *llatp, double *llonp);
+
+/* magdecl.c */
+extern int magdecl (double l, double L, double e, double y, char *dir,
+    double *dp, char *err);
+
+/* marsmoon.c */
+extern void marsm_data (double Mjd, char dir[], Obj *eop, Obj *mop,
+    double *marssize, MoonData md[M_NMOONS]); 
 
 /* misc.c */
-extern void zero_mem P_((void *loc, unsigned len));
-extern int tickmarks P_((double min, double max, int numdiv, double ticks[]));
-extern int lc P_((int cx, int cy, int cw, int x1, int y1, int x2, int y2,
-    int *sx1, int *sy1, int *sx2, int *sy2));
-extern void hg_mag P_((double h, double g, double rp, double rho, double rsn,
-    double *mp));
-extern int magdiam P_((int fmag, int magstp, double scale, double mag,
-    double size));
-extern void gk_mag P_((double g, double k, double rp, double rho, double *mp));
-extern double atod P_((char *buf));
-extern void solve_sphere P_((double A, double b, double cc, double sc,
-    double *cap, double *Bp));
-extern double delra P_((double dra));
+extern void zero_mem (void *loc, unsigned len);
+extern int tickmarks (double min, double max, int numdiv, double ticks[]);
+extern int lc (int cx, int cy, int cw, int x1, int y1, int x2, int y2,
+    int *sx1, int *sy1, int *sx2, int *sy2);
+extern void hg_mag (double h, double g, double rp, double rho, double rsn,
+    double *mp);
+extern int magdiam (int fmag, int magstp, double scale, double mag,
+    double size);
+extern void gk_mag (double g, double k, double rp, double rho, double *mp);
+extern double atod (char *buf);
+extern void solve_sphere (double A, double b, double cc, double sc,
+    double *cap, double *Bp);
+extern double delra (double dra);
+extern void now_lst (Now *np, double *lstp);
+extern void radec2ha (Now *np, double ra, double dec, double *hap);
+extern char *obj_description (Obj *op);
+extern int is_deepsky (Obj *op);
 
 /* mjd.c */
-extern void cal_mjd P_((int mn, double dy, int yr, double *mjd));
-extern void mjd_cal P_((double mjd, int *mn, double *dy, int *yr));
-extern int mjd_dow P_((double mjd, int *dow));
-extern int isleapyear P_((int year));
-extern void mjd_dpm P_((double mjd, int *ndays));
-extern void mjd_year P_((double mjd, double *yr));
-extern void year_mjd P_((double y, double *mjd));
-extern void rnd_second P_((double *t));
-extern void mjd_dayno P_((double jd, int *yr, double *dy));
-extern double mjd_day P_((double jd));
-extern double mjd_hr P_((double jd));
-extern void range P_((double *v, double r));
+extern void cal_mjd (int mn, double dy, int yr, double *m);
+extern void mjd_cal (double m, int *mn, double *dy, int *yr);
+extern int mjd_dow (double m, int *dow);
+extern int isleapyear (int year);
+extern void mjd_dpm (double m, int *ndays);
+extern void mjd_year (double m, double *yr);
+extern void year_mjd (double y, double *m);
+extern void rnd_second (double *t);
+extern void mjd_dayno (double jd, int *yr, double *dy);
+extern double mjd_day (double jd);
+extern double mjd_hr (double jd);
+extern void range (double *v, double r);
+extern void radecrange (double *ra, double *dec);
 
 /* moon.c */
-extern void moon P_((double mjd, double *lam, double *bet, double *rho,
-    double *msp, double *mdp));
+extern void moon (double m, double *lam, double *bet, double *rho,
+    double *msp, double *mdp);
 
 /* mooncolong.c */
-extern void moon_colong P_((double jd, double lt, double lg, double *cp, double *kp, double *ap, double *sp));
+extern void moon_colong (double jd, double lt, double lg, double *cp,
+    double *kp, double *ap, double *sp);
+
+/* moonnf.c */
+extern void moonnf (double mj, double *mjn, double *mjf);
 
 /* nutation.c */
-extern void nutation P_((double mjd, double *deps, double *dpsi));
-extern void nut_eq P_((double mjd, double *ra, double *dec));
+extern void nutation (double m, double *deps, double *dpsi);
+extern void nut_eq (double m, double *ra, double *dec);
 
 /* obliq.c */
-extern void obliquity P_((double mjd, double *eps));
+extern void obliquity (double m, double *eps);
 
 /* parallax.c */
-extern void ta_par P_((double tha, double tdec, double phi, double ht,
-    double *rho, double *aha, double *adec));
+extern void ta_par (double tha, double tdec, double phi, double ht,
+    double *rho, double *aha, double *adec);
+
+/* parallactic.c */
+extern double parallacticLDA (double lt, double dec, double alt);
+extern double parallacticLHD (double lt, double ha, double dec);
 
 /* plans.c */
-extern void plans P_((double mjd, int p, double *lpd0, double *psi0,
+extern void plans (double m, PLCode p, double *lpd0, double *psi0,
     double *rp0, double *rho0, double *lam, double *bet, double *dia,
-    double *mag));
+    double *mag);
+
+/* plshadow.c */
+extern int plshadow (Now *np, Obj *op, Obj *sop, double polera,
+double poledec, double x, double y, double z, double *sxp, double *syp);
+
+/* plmoon_cir.c */
+extern int plmoon_cir (Now *np, Obj *moonop);
+extern int getBuiltInObjs (Obj **opp);
+extern void setMoonDir (char *dir);
 
 /* precess.c */
-extern void precess P_((double mjd1, double mjd2, double *ra, double *dec));
+extern void precess (double mjd1, double mjd2, double *ra, double *dec);
 
 /* reduce.c */
-extern void reduce_elements P_((double mjd0, double mjd, double inc0,
-    double ap0, double om0, double *inc, double *ap, double *om));
+extern void reduce_elements (double mjd0, double m, double inc0,
+    double ap0, double om0, double *inc, double *ap, double *om);
 
 /* refract.c */
-extern void unrefract P_((double pr, double tr, double aa, double *ta));
-extern void refract P_((double pr, double tr, double ta, double *aa));
+extern void unrefract (double pr, double tr, double aa, double *ta);
+extern void refract (double pr, double tr, double ta, double *aa);
 
 /* rings.c */
-extern void satrings P_((double sb, double sl, double sr, double el, double er,
-    double JD, double *etiltp, double *stiltp));
+extern void satrings (double sb, double sl, double sr, double el, double er,
+    double JD, double *etiltp, double *stiltp);
 
 /* riset.c */
-extern void riset P_((double ra, double dec, double lat, double dis,
-    double *lstr, double *lsts, double *azr, double *azs, int *status));
+extern void riset (double ra, double dec, double lt, double dis,
+    double *lstr, double *lsts, double *azr, double *azs, int *status);
+
+/* riset_cir.c */
+extern void riset_cir (Now *np, Obj *op, double dis, RiseSet *rp);
+extern void twilight_cir (Now *np, double dis, double *dawn, double *dusk,
+    int *status);
+
+/* satmoon.c */
+extern void saturn_data (double Mjd, char dir[], Obj *eop, Obj *sop,
+    double *satsize, double *etilt, double *stlit, MoonData md[S_NMOONS]); 
 
 /* sphcart.c */
-extern void sphcart P_((double l, double b, double r, double *x, double *y,
-    double *z));
-extern void cartsph P_((double x, double y, double z, double *l, double *b,
-    double *r));
+extern void sphcart (double l, double b, double r, double *x, double *y,
+    double *z);
+extern void cartsph (double x, double y, double z, double *l, double *b,
+    double *r);
 
 /* sun.c */
-extern void sunpos P_((double mjd, double *lsn, double *rsn, double *bsn));
+extern void sunpos (double m, double *lsn, double *rsn, double *bsn);
 
 /* twobody.c */
-extern void vrc P_((double *v, double *r, double tp, double e, double q));
+extern int vrc (double *v, double *r, double tp, double e, double q);
+
+/* umoon.c */
+extern void uranus_data (double Mjd, char dir[], Obj *eop, Obj *uop,
+    double *usize, MoonData md[U_NMOONS]); 
 
 /* utc_gst.c */
-extern void utc_gst P_((double mjd, double utc, double *gst));
-extern void gst_utc P_((double mjd, double gst, double *utc));
+extern void utc_gst (double m, double utc, double *gst);
+extern void gst_utc (double m, double gst, double *utc);
 
 /* vsop87.c */
-extern int vsop87 P_((double mjd, int obj, double prec, double *ret));
+extern int vsop87 (double m, int obj, double prec, double *ret);
+
+#endif /* _ASTRO_H */
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: astro.h,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: astro.h,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/atlas.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/atlas.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/atlas.c	(revision 2551)
@@ -0,0 +1,196 @@
+/* look up which star atlas an ra/dec is in.
+ * Urano and Mill contributed by Atsuo Ohki <ohki@gssm.otsuka.tsukuba.ac.jp>
+ * U2K by Robert Lane <roblane@alum.mit.edu>
+ *
+ * N.B. skylist.c assumes a certain max length for any returned string.
+ */
+ 
+#include <stdio.h>
+#include <string.h>
+
+#include "astro.h"
+
+/* for Millennium Star Atlas */
+static int msa_charts[] = {
+    /* 90*/  2, /* 84*/  4, /* 78*/  8, /* 72*/ 10, /* 66*/ 12,
+    /* 60*/ 14, /* 54*/ 16, /* 48*/ 20, /* 42*/ 20, /* 36*/ 22,
+    /* 30*/ 22, /* 24*/ 24, /* 18*/ 24, /* 12*/ 24, /*  6*/ 24,
+    /*  0*/ 24,
+    /* -6*/ 24, /*-12*/ 24, /*-18*/ 24, /*-24*/ 24, /*-30*/ 22,
+    /*-36*/ 22, /*-42*/ 20, /*-48*/ 20, /*-54*/ 16, /*-60*/ 14,
+    /*-66*/ 12, /*-72*/ 10, /*-78*/  8, /*-84*/  4, /*-90*/  2
+};
+
+/*
+ * find the chart number of Millennium Star Atlas and return pointer to static
+ * string describing location.
+ * 0 <= ra < 24;  -90 <= dec <= 90
+ */
+char *
+msa_atlas(double ra, double dec)
+{
+	static char buf[512];
+	int zone, band;
+	int i, p;
+
+	ra = radhr(ra);
+	dec = raddeg(dec);
+	buf[0] = 0;
+	if (ra < 0.0 || 24.0 <= ra || dec < -90.0 || 90.0 < dec)
+	    return (buf);
+	zone = (int)(ra/8.0);
+	band = -((int)(dec+((dec>=0)?3:-3))/6 - 15);
+	for (p=0, i=0; i <= band; i++)
+	    p += msa_charts[i];
+	i = (int)((ra - 8.0*zone) / (8.0/msa_charts[band]));
+	sprintf(buf, "V%d - P%3d", zone+1, p-i+zone*516);
+	return (buf);
+}
+
+/* for original Uranometria */
+static struct {
+    double l;
+    int n;
+} um_zones[] = {
+    /* 84 - 90 */ { 84.5,  2},
+    /* 72 - 85 */ { 72.5, 12},
+    /* 60 - 73 */ { 61.0, 20},
+    /* 49 - 62 */ { 50.0, 24},
+    /* 38 - 51 */ { 39.0, 30},
+    /* 27 - 40 */ { 28.0, 36},
+    /* 16 - 29 */ { 17.0, 45},
+    /*  5 - 18 */ {  5.5, 45},
+    /*  0 -  6 */ {  0.0, 45},
+		  {  0.0,  0}
+};
+
+/*
+ * find the chart number of Uranometria first edition and return pointer to
+ * static string describing location.
+ * 0 <= ra < 24;  -90 <= dec <= 90
+ */
+char *
+um_atlas(double ra, double dec)
+{
+	static char buf[512];
+	int band, south;
+	int p;
+	double w;
+
+	ra = radhr(ra);
+	dec = raddeg(dec);
+	buf[0] = 0;
+	if (ra < 0.0 || 24.0 <= ra || dec < -90.0 || 90.0 < dec)
+	    return (buf);
+	p = 0;
+	if (dec < 0.0) {
+	    dec = -dec;
+	    south = 1;
+	} else
+	    south = 0;
+	p = 1;
+	for (band=0; um_zones[band].n; band++) {
+	    if (um_zones[band].l <= dec)
+		break; 
+	    p += um_zones[band].n;
+	}
+	if (!um_zones[band].n)
+	    return (buf);
+	w = 24.0 / um_zones[band].n;
+	if (band) {
+	    ra += w/2.0;
+	    if (ra >= 24.0)
+		ra -= 24.0;
+	}
+	if (south && um_zones[band+1].n)
+	    p = 475 - p - um_zones[band].n;
+	if (south && band == 0) {
+	    /* south pole part is mis-ordered! */
+	    ra = 24.0 - ra;
+	}
+	sprintf(buf, "V%d - P%3d", south+1, p+(int)(ra/w));
+	return (buf);
+}
+
+/* for Uranometria 2000.0 */
+static struct {
+    double lowDec; 	/* lower dec cutoff */
+    int numZones;	/* number of panels (aka zones) */
+
+} u2k_zones[] = { /* array of book layout info */
+    /* 84 - 90 */ { 84.5,  1}, /* lower dec cutoff, # of panels in band */
+    /* 73 - 85 */ { 73.5,  6},
+    /* 62 - 74 */ { 62.0, 10},
+    /* 51 - 63 */ { 51.0, 12},
+    /* 40 - 52 */ { 40.0, 15},
+    /* 29 - 41 */ { 29.0, 18},
+    /* 17 - 30 */ { 17.0, 18},
+    /*  5 - 18 */ {  5.5, 20},
+    /*  0 -  6 */ {  0.0, 20},
+                  {  0.0,  0} /*numZones value in this line is a stopper.*/
+};
+
+/* find the chart number of Uranometria 2000.0 and return pointer to static
+ * string describing location.
+ * 0 <= ra < 24;  -90 <= dec <= 90
+ */
+char *
+u2k_atlas(double ra, double dec)
+{
+	static char buf[512];
+	static char err[] = "???";
+	int band; 		/* index to array */
+	int south;		/* flag for volume 2*/
+	int panel;		/* panel number */
+
+	ra = radhr(ra);
+	dec = raddeg(dec);
+	buf[0] = 0;
+	if (ra < 0.0 || 24.0 <= ra || dec < -90.0 || 90.0 < dec) {
+	    strcpy (buf, err);
+	    return (buf); /* range checking */
+	}
+
+	if (dec < 0.0) {
+	    dec = -dec;
+	    south = 1; /* South is mirror of North */
+	} else
+	    south = 0;
+
+	panel = 1;
+	band = 0;
+
+	/* scan u2k_zones for the correct band: */
+	while (u2k_zones[band].numZones != 0 && dec <= u2k_zones[band].lowDec ){
+	    panel += u2k_zones[band].numZones; /*accumulate total panels */
+	    band++ ;
+	}
+
+	if (!u2k_zones[band].numZones) { /* hit end of array with no match. */
+	    strcpy (buf, err);
+	    return (buf);
+	}
+
+	ra -= 12.0 / u2k_zones[band].numZones; /*offset by half-width of panel*/
+	if (ra >= 24.0)			/* reality check. shouldn't happen. */
+	    ra -= 24.0;
+
+	if (ra < 0.0)			/* offset could give negative ra */
+	    ra += 24.0;
+
+	if (south && u2k_zones[band+1].numZones)
+	    panel = 222 - panel - u2k_zones[band].numZones;
+
+	/* resultant panel number is accumulated panels in prior bands plus
+	 * ra's fraction of panels in dec's band. panel # goes up as ra goes
+	 * down.
+	 */
+	sprintf(buf, "V%d - P%3d", south+1,
+	panel+(int)(u2k_zones[band].numZones*(24.0 - ra)/24.0));
+
+	return (buf);
+}
+
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: atlas.c,v $ $Date: 2004-06-15 16:54:11 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/auxil.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/auxil.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/auxil.c	(revision 2551)
@@ -3,17 +3,13 @@
 
 #include <stdio.h>
+#include <stdlib.h>
 
-#if defined (__STDC__)
-#include <stdlib.h>
-#endif
-
-#include "P_.h"
 #include "astro.h"
-#include "circum.h"
 #include "preferences.h"
 
+/* default preferences */
 static int prefs[NPREFS] = {
     PREF_TOPO, PREF_METRIC, PREF_MDY, PREF_UTCTZ, PREF_HIPREC, PREF_NOMSGBELL,
-    PREF_PREFILL, PREF_TIPSON, PREF_CONFIRMON, PREF_WEEKSTART
+    PREF_PREFILL, PREF_TIPSON, PREF_CONFIRMON, PREF_SUN
 };
 
@@ -21,6 +17,5 @@
  */
 int
-pref_get(pref)
-Preferences pref;
+pref_get(Preferences pref)
 {
 	return (prefs[pref]);
@@ -30,10 +25,8 @@
  */
 int
-pref_set (pref, new)
-Preferences pref;
-int new;
+pref_set (Preferences pref, int newp)
 {
 	int prior = pref_get(pref);
-	prefs[pref] = new;
+	prefs[pref] = newp;
 	return (prior);
 }
@@ -41,6 +34,5 @@
 /* given an mjd, return it modified for terrestial dynamical time */
 double
-mm_mjed (np)
-Now *np;
+mm_mjed (Now *np)
 {
 	return (mjd + deltat(mjd)/86400.0);
@@ -48,3 +40,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: auxil.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: auxil.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/bdl.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/bdl.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/bdl.c	(revision 2551)
@@ -0,0 +1,234 @@
+/* crack natural satellite files from BDL */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <unistd.h>
+
+#include "astro.h"
+#include "bdl.h"
+
+typedef enum {I, F, NL} ScanType;
+#define	SCANFLD(f,w,vp)	if(readField(fp,f,w,(void *)vp,ynot)<0) return (-1)
+
+static int readField (FILE *fp, ScanType f, int w, void *ptr, char ynot[]);
+static int readRec (FILE *fp, double *t0, double cmx[], double cfx[],
+    double cmy[], double cfy[], double cmz[], double cfz[], char ynot[]);
+
+/* given a sequencial text file in BDL natural satellite ephemeris format and a
+ * JD, find the x/y/z positions of each satellite. store in the given arrays,
+ * assumed to have one entry per moon. values are planetocentric, +x east, +y
+ * north, +z away from earth, all in au. corrected for light time.
+ * return the number of satellites or -1 and reason in ymot[].
+ * files obtained from ftp://ftp.bdl.fr/pub/misc/satxyz.
+ */
+int
+read_bdl (FILE *fp, double jd, double *xp, double *yp, double *zp, char ynot[])
+{
+	int npla;
+	int nsat;
+	int idn[8];
+	double freq[8];
+	double delt[8];
+	double djj;
+	double cmx[6], cfx[4], cmy[6], cfy[4], cmz[6], cfz[4];
+	int ienrf;
+	int jan;
+	int reclen;
+	long os0;
+	double t0;
+	int i;
+
+	/* read header line */
+	SCANFLD (I, 2, &npla);
+	SCANFLD (I, 2, &nsat);
+	for (i = 0; i < nsat; i++)
+	    SCANFLD (I, 5, &idn[i]);
+	for (i = 0; i < nsat; i++)
+	    SCANFLD (F, 8, &freq[i]);
+	for (i = 0; i < nsat; i++)
+	    SCANFLD (F, 5, &delt[i]);
+	SCANFLD (I, 5, &ienrf);
+	SCANFLD (F, 15, &djj);
+	SCANFLD (I, 5, &jan);
+	SCANFLD (NL, 0, NULL);
+
+	/* record position of first record */
+	os0 = ftell (fp);
+
+	/* read first record to get length */
+	reclen = readRec (fp, &t0, cmx, cfx, cmy, cfy, cmz, cfz, ynot);
+	if (reclen < 0)
+	    return (-1);
+
+	/* compute location of each satellite */
+	for (i = 0; i < nsat; i++) {
+	    int id = (int)floor((jd-djj)/delt[i]) + idn[i] - 2;
+	    long os = os0 + id*reclen;
+	    double t1, anu, tau, tau2, at;
+	    double tbx, tby, tbz;
+
+	    if (fseek (fp, os, SEEK_SET) < 0) {
+		sprintf (ynot, "Seek error to %ld for rec %d", os, id);
+		return (-1);
+	    }
+
+	    if (readRec (fp, &t0, cmx, cfx, cmy, cfy, cmz, cfz, ynot) < 0)
+		return (-1);
+
+	    t1 = floor(t0) + 0.5;
+	    anu = freq[i];
+	    tau = jd - t1;
+	    tau2 = tau * tau;
+	    at = tau*anu;
+
+	    tbx = cmx[0]+cmx[1]*tau+cmx[2]*sin(at+cfx[0])
+			    +cmx[3]*tau*sin(at+cfx[1])
+			    +cmx[4]*tau2*sin(at+cfx[2])
+			    +cmx[5]*sin(2*at+cfx[3]);
+	    tby = cmy[0]+cmy[1]*tau+cmy[2]*sin(at+cfy[0])
+			    +cmy[3]*tau*sin(at+cfy[1])
+			    +cmy[4]*tau2*sin(at+cfy[2])
+			    +cmy[5]*sin(2*at+cfy[3]);
+	    tbz = cmz[0]+cmz[1]*tau+cmz[2]*sin(at+cfz[0])
+			    +cmz[3]*tau*sin(at+cfz[1])
+			    +cmz[4]*tau2*sin(at+cfz[2])
+			    +cmz[5]*sin(2*at+cfz[3]);
+
+	    xp[i] = tbx*1000./149597870.;
+	    yp[i] = tby*1000./149597870.;
+	    zp[i] = tbz*1000./149597870.;
+	}
+
+	return (nsat);
+}
+
+/* read one field.
+ * return 0 if ok else -1
+ * N.B. this is enforce width, without skipping leading blanks.
+ */
+static int
+readField (FILE *fp, ScanType f, int width, void *ptr, char ynot[])
+{
+	char buf[128];
+	char *bp;
+
+	if (buf && width != (int)fread (buf, 1, width, fp)) {
+	    if (ferror(fp)) strcpy (ynot, "IO error");
+	    else if (feof(fp)) strcpy (ynot, "unexpected EOF");
+	    else strcpy (ynot, "short file");
+	    return (-1);
+	}
+
+	buf[width] = '\0';
+	switch (f) {
+	case I:
+	    *(int *)ptr = atoi (buf);
+	    break;
+	case F:
+	    bp = strchr (buf, 'D');
+	    if (bp)
+		*bp = 'e';
+	    *(double *)ptr = atof (buf);
+	    break;
+	case NL:
+	    fgets (buf, sizeof(buf), fp);
+	    break;
+	default:
+	    sprintf (ynot, "Bug! format = %d", f);
+	    return (-1);
+	}
+	return (0);
+}
+
+/* read one satellite record.
+ * return number of chars read else -1.
+ */
+static int
+readRec (FILE *fp, double *t0, double cmx[], double cfx[], double cmy[],
+double cfy[], double cmz[], double cfz[], char ynot[])
+{
+
+	long pos0, pos1;
+	int isat, idx;
+	int ldat1, ldat2;
+	int i;
+
+	pos0 = ftell (fp);
+
+	SCANFLD (I, 1, &isat);
+	SCANFLD (I, 5, &idx);
+	SCANFLD (I, 8, &ldat1);
+	SCANFLD (I, 8, &ldat2);
+	SCANFLD (F, 9, t0);
+	for (i = 0; i < 6; i++)
+	    SCANFLD (F, 17, &cmx[i]);
+	for (i = 0; i < 4; i++)
+	    SCANFLD (F, 17, &cfx[i]);
+	for (i = 0; i < 6; i++)
+	    SCANFLD (F, 17, &cmy[i]);
+	for (i = 0; i < 4; i++)
+	    SCANFLD (F, 17, &cfy[i]);
+	for (i = 0; i < 6; i++)
+	    SCANFLD (F, 17, &cmz[i]);
+	for (i = 0; i < 4; i++)
+	    SCANFLD (F, 17, &cfz[i]);
+	SCANFLD (NL, 0, NULL);
+
+	pos1 = ftell (fp);
+
+	return (pos1 - pos0);
+}
+
+
+#ifdef TEST_IT
+/* stand-alone test program.
+ * for example, compare
+ *   a.out jupiter.9910 2451910.50000
+ * with
+ *   satxyz2
+ *     jup.dir.9910
+ *     2001 1 1 0 0 0
+ *     1 0 0 0
+ *     1
+ */
+int
+main (int ac, char *av[])
+{
+	double x[10], y[10], z[10];
+	char ynot[1024];
+	double jd;
+	char *fn;
+	FILE *fp;
+	int nm;
+	int i;
+
+	if (ac != 3) {
+	    fprintf (stderr, "Usage: %s <filename> <jd>\n", av[0]);
+	    abort();
+	}
+	fn = av[1];
+	jd = atof (av[2]);
+
+	fp = fopen (fn, "r");
+	if (!fp) {
+	    perror (fn);
+	    abort();
+	}
+
+	nm = read_bdl (fp, jd, x, y, z, ynot);
+	if (nm < 0) {
+	    fprintf (stderr, "%s\n", ynot);
+	    abort();
+	}
+
+	for (i = 0; i < nm; i++)
+	    printf (" X= %19.11E Y= %19.11E Z= %19.11E\n", x[i], y[i], z[i]);
+
+	return (0);
+}
+#endif
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: bdl.c,v $ $Date: 2004-06-15 16:54:11 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/bdl.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/bdl.h	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/bdl.h	(revision 2551)
@@ -0,0 +1,6 @@
+extern int read_bdl (FILE *fp, double jd, double *xp, double *yp, double *zp,
+    char ynot[]);
+
+/* For RCS Only -- Do Not Edit
+ * @(#) $RCSfile: bdl.h,v $ $Date: 2004-06-15 16:54:11 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $
+ */
Index: /trunk/SophyaExt/XephemAstroLib/chap95.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/chap95.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/chap95.c	(revision 2551)
@@ -19,9 +19,7 @@
 
 #include <math.h>
-#include "P_.h"
+
 #include "astro.h"
 #include "chap95.h"
-
-extern void zero_mem P_((void *loc, unsigned len));
 
 #define CHAP_MAXTPOW	2	/* NB: valid for all 5 outer planets */
@@ -30,5 +28,5 @@
  *
  * input:
- *	mjd	modified JD; days from J1900.0 = 2415020.0
+ *	m	modified JD; days from J1900.0 = 2415020.0
  *
  *	prec	precision level, in radians.
@@ -50,9 +48,5 @@
  */
 int
-chap95 (mjd, obj, prec, ret)
-double mjd;
-int obj;
-double prec;
-double *ret;
+chap95 (double m, int obj, double prec, double *ret)
 {
 	static double a0[] = {		/* semimajor axes for precision ctrl */
@@ -67,5 +61,5 @@
 
 	/* check parameters */
-	if (mjd < CHAP_BEGIN || mjd > CHAP_END)
+	if (m < CHAP_BEGIN || m > CHAP_END)
 		return (1);
 
@@ -79,5 +73,5 @@
 	zero_mem ((void *)sum, sizeof(sum));
 
-	T = (mjd - J2000)/36525.0;	/* centuries since J2000.0 */
+	T = (m - J2000)/36525.0;	/* centuries since J2000.0 */
 
 	/* modify precision treshold for
@@ -178,3 +172,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: chap95.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: chap95.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/chap95.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/chap95.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/chap95.h	(revision 2551)
@@ -61,9 +61,8 @@
 extern chap95_rec chap95_pluto[];
 
-#include "P_.h"
-extern int chap95 P_((double mjd, int obj, double prec, double *ret));
+extern int chap95 (double m, int obj, double prec, double *ret);
 
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: chap95.h,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: chap95.h,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/chap95_data.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/chap95_data.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/chap95_data.c	(revision 2551)
@@ -781,3 +781,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: chap95_data.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: chap95_data.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/circum.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/circum.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/circum.c	(revision 2551)
@@ -9,28 +9,29 @@
 #include <stdio.h>
 #include <math.h>
-#if defined(__STDC__)
 #include <stdlib.h>
-#endif
-
-#include "P_.h"
+
 #include "astro.h"
-#include "circum.h"
 #include "preferences.h"
 
 
-static int obj_planet P_((Now *np, Obj *op));
-static int obj_fixed P_((Now *np, Obj *op));
-static int obj_elliptical P_((Now *np, Obj *op));
-static int obj_hyperbolic P_((Now *np, Obj *op));
-static int obj_parabolic P_((Now *np, Obj *op));
-static int sun_cir P_((Now *np, Obj *op));
-static int moon_cir P_((Now *np, Obj *op));
-static void cir_sky P_((Now *np, double lpd, double psi, double rp, double *rho,
-    double lam, double bet, double lsn, double rsn, Obj *op));
-static void cir_pos P_((Now *np, double bet, double lam, double *rho, Obj *op));
-static void elongation P_((double lam, double bet, double lsn, double *el));
-static void deflect P_((double mjd1, double lpd, double psi, double rsn,
-    double lsn, double rho, double *ra, double *dec));
-static double h_albsize P_((double H));
+static int obj_planet (Now *np, Obj *op);
+static int obj_binary (Now *np, Obj *op);
+static int obj_2binary (Now *np, Obj *op);
+static int obj_fixed (Now *np, Obj *op);
+static int obj_elliptical (Now *np, Obj *op);
+static int obj_hyperbolic (Now *np, Obj *op);
+static int obj_parabolic (Now *np, Obj *op);
+static int sun_cir (Now *np, Obj *op);
+static int moon_cir (Now *np, Obj *op);
+static double solveKepler (double M, double e);
+static void binaryStarOrbit (double t, double T, double e, double o, double O,
+    double i, double a, double P, double *thetap, double *rhop);
+static void cir_sky (Now *np, double lpd, double psi, double rp, double *rho,
+    double lam, double bet, double lsn, double rsn, Obj *op);
+static void cir_pos (Now *np, double bet, double lam, double *rho, Obj *op);
+static void elongation (double lam, double bet, double lsn, double *el);
+static void deflect (double mjd1, double lpd, double psi, double rsn,
+    double lsn, double rho, double *ra, double *dec);
+static double h_albsize (double H);
 
 /* given a Now and an Obj, fill in the approprirate s_* fields within Obj.
@@ -38,9 +39,9 @@
  */
 int
-obj_cir (np, op)
-Now *np;
-Obj *op;
-{
+obj_cir (Now *np, Obj *op)
+{
+	op->o_flags &= ~NOCIRCUM;
 	switch (op->o_type) {
+	case BINARYSTAR: return (obj_binary (np, op));
 	case FIXED:	 return (obj_fixed (np, op));
 	case ELLIPTICAL: return (obj_elliptical (np, op));
@@ -50,6 +51,6 @@
 	case PLANET:     return (obj_planet (np, op));
 	default:
-	    printf ("obj_cir() called with type %d\n", op->o_type);
-	    exit(1);
+	    printf ("obj_cir() called with type %d %s\n", op->o_type, op->o_name);
+	    abort();
 	    return (-1);	/* just for lint */
 	}
@@ -57,7 +58,5 @@
 
 static int
-obj_planet (np, op)
-Now *np;
-Obj *op;
+obj_planet (Now *np, Obj *op)
 {
 	double lsn, rsn;	/* true geoc lng of sun; dist from sn to earth*/
@@ -67,16 +66,20 @@
 	double lam, bet;	/* geocentric ecliptic long and lat */
 	double dia, mag;	/* angular diameter at 1 AU and magnitude */
-	int p;
+	PLCode p;
 
 	/* validate code and check for a few special cases */
-	p = op->pl.pl_code;
+	p = op->pl_code;
+	if (p == SUN)
+	    return (sun_cir (np, op));
+	if (p == MOON)
+	    return (moon_cir (np, op));
+	if (op->pl_moon != X_PLANET)
+	    return (plmoon_cir (np, op));
 	if (p < 0 || p > MOON) {
 	    printf ("unknown planet code: %d\n", p);
-	    exit(1);
-	}
-	else if (p == SUN)
-	    return (sun_cir (np, op));
-	else if (p == MOON)
-	    return (moon_cir (np, op));
+	    abort();
+	}
+
+	/* planet itself */
 
 	/* find solar ecliptical longitude and distance to sun from earth */
@@ -99,7 +102,109 @@
 
 static int
-obj_fixed (np, op)
-Now *np;
-Obj *op;
+obj_binary (Now *np, Obj *op)
+{
+	/* always compute circumstances of primary */
+	if (obj_fixed (np, op) < 0)
+	    return (0);
+
+	/* compute secondary only if requested, and always reset request flag */
+	if (!op->b_2compute)
+	    return (0);
+	op->b_2compute = 0;
+	return (obj_2binary (np, op));
+}
+
+/* compute position of secondary component of a BINARYSTAR */
+static int
+obj_2binary (Now *np, Obj *op)
+{
+	if (op->b_nbp > 0) {
+	    /* we just have discrete pa/sep, project each from primary */
+	    int i;
+	    for (i = 0; i < op->b_nbp; i++) {
+		BinPos *bp = &op->b_bp[i];
+		bp->bp_dec = op->s_dec + bp->bp_sep*cos(bp->bp_pa);
+		bp->bp_ra = op->s_ra + bp->bp_sep*sin(bp->bp_pa)/cos(op->s_dec);
+	    }
+	} else {
+	    BinOrbit *bp = &op->b_bo;
+	    double t, theta, rho;
+
+	    mjd_year (mjd, &t);
+	    binaryStarOrbit (t, bp->bo_T, bp->bo_e, bp->bo_o, bp->bo_O,
+				bp->bo_i, bp->bo_a, bp->bo_P, &theta, &rho);
+	    bp->bo_pa = (float)theta;
+	    bp->bo_sep = (float)rho;
+	    rho = degrad(rho/3600.);	/* arc secs to rads */
+	    bp->bo_dec = op->s_dec + rho*cos(theta);
+	    bp->bo_ra =  op->s_ra  + rho*sin(theta)/cos(op->s_dec);
+	}
+
+	return (0);
+}
+
+/* from W. M. Smart */
+static void
+binaryStarOrbit (
+double t,		/* desired ephemeris epoch, year */
+double T,		/* epoch of periastron, year */
+double e,		/* eccentricity */
+double o,		/* argument of periastron, degrees */
+double O,		/* ascending node, degrees */
+double i,		/* inclination, degrees */
+double a,		/* semi major axis, arcsecs */
+double P,		/* period, years */
+double *thetap,		/* position angle, rads E of N */
+double *rhop)		/* separation, arcsecs */
+{
+	double M, E, cosE, nu, cosnu, r, rho, theta;
+
+	/* find mean anomaly, insure 0..2*PI */
+	M = 2*PI/P*(t-T);
+	range (&M, 2*PI);
+
+	/* solve for eccentric anomaly */
+	E = solveKepler (M, e);
+	cosE = cos(E);
+
+	/* find true anomaly and separation */
+	cosnu = (cosE - e)/(1.0 - e*cosE);
+	r = a*(1.0 - e*e)/(1.0 + e*cosnu);
+	nu = acos(cosnu);
+	if (E > PI)
+	    nu = -nu;
+
+	/* project onto sky */
+	theta = atan(tan(nu+degrad(o))*cos(degrad(i))) + degrad(O);
+	rho = r*cos(nu+degrad(o))/cos(theta-degrad(O));
+	if (rho < 0) {
+	    theta += PI;
+	    rho = -rho;
+	}
+	range (&theta, 2*PI);
+
+	*thetap = theta;
+	*rhop = rho;
+}
+
+/* solve kepler equation using Newton-Raphson search.
+ * Charles and Tatum have shown it always converges starting with PI.
+ */
+static double
+solveKepler (double M, double e)
+{
+	double E, Eprime = PI;
+
+	do {
+	    double cosE = cos(Eprime);
+	    E = Eprime;
+	    Eprime = (M - e*(E*cosE - sin(E)))/(1.0 - e*cosE);
+	} while (fabs(E-Eprime) > 1e-7);
+
+	return (Eprime);
+}
+
+static int
+obj_fixed (Now *np, Obj *op)
 {
 	double lsn, rsn;	/* true geoc lng of sun, dist from sn to earth*/
@@ -108,23 +213,36 @@
 	double el;		/* elongation */
 	double alt, az;		/* current alt, az */
-	double ra, dec;		/* ra and dec at epoch of date */
+	double ra, dec;		/* ra and dec at equinox of date */
+	double rpm, dpm; 	/* astrometric ra and dec with PM to now */
 	double lst;
 
-	if (epoch != EOD && (float)epoch != op->f_epoch) {
-	    /* want a certain epoch -- if it's not what the database is at
-	     * we change the original to save time next time assuming the
-	     * user is likely to stick with this for a while.
-	     */
-	    double tra = op->f_RA, tdec = op->f_dec;
-	    float tepoch = (float)epoch;	/* compare w/float precision */
-	    precess (op->f_epoch, tepoch, &tra, &tdec);
-	    op->f_epoch = tepoch;
-	    op->f_RA = (float)tra;
-	    op->f_dec = (float)tdec;
-	}
-
-	/* set ra/dec to astrometric @ epoch of date */
-	ra = op->f_RA;
-	dec = op->f_dec;
+	/* on the assumption that the user will stick with their chosen display
+	 * epoch for a while, we move the defining values to match and avoid
+	 * precession for every call until it is changed again.
+	 * N.B. only compare and store jd's to lowest precission (f_epoch).
+	 * N.B. maintaining J2k ref (which is arbitrary) helps avoid accum err
+	 */
+	if (epoch != EOD && (float)epoch != (float)op->f_epoch) {
+	    double pr = op->f_RA, pd = op->f_dec, fe = (float)epoch;
+	    /* first bring back to 2k */
+	    precess (op->f_epoch, J2000, &pr, &pd);
+	    pr += op->f_pmRA*(J2000-op->f_epoch);
+	    pd += op->f_pmdec*(J2000-op->f_epoch);
+	    /* then to epoch */
+	    pr += op->f_pmRA*(fe-J2000);
+	    pd += op->f_pmdec*(fe-J2000);
+	    precess (J2000, fe, &pr, &pd);
+	    op->f_RA = (float)pr;
+	    op->f_dec = (float)pd;
+	    op->f_epoch = (float)fe;
+	}
+
+	/* apply proper motion .. assume pm epoch reference equals equinox */
+	rpm = op->f_RA + op->f_pmRA*(mjd-op->f_epoch);
+	dpm = op->f_dec + op->f_pmdec*(mjd-op->f_epoch);
+
+	/* set ra/dec to astrometric @ equinox of date */
+	ra = rpm;
+	dec = dpm;
 	precess (op->f_epoch, mjed, &ra, &dec);
 
@@ -154,8 +272,8 @@
 	} else {
 	    /* annual parallax at time mjd is to be added here, too, but
-	     * technically in the frame of epoch (usually different from mjd)
+	     * technically in the frame of equinox (usually different from mjd)
 	     */
-	    op->s_ra = op->f_RA;	/* already precessed */
-	    op->s_dec = op->f_dec;
+	    op->s_ra = rpm;
+	    op->s_dec = dpm;
 	}
 
@@ -184,7 +302,5 @@
  */
 static int
-obj_elliptical (np, op)
-Now *np;
-Obj *op;
+obj_elliptical (Now *np, Obj *op)
 {
 	double lsn, rsn;	/* true geoc lng of sun; dist from sn to earth*/
@@ -230,5 +346,6 @@
 
 	    tp = mjed - dt - (op->e_cepoch - op->e_M/e_n);
-	    vrc (&nu, &rp, tp, op->e_e, op->e_a*(1-op->e_e));
+	    if (vrc (&nu, &rp, tp, op->e_e, op->e_a*(1-op->e_e)) < 0)
+		op->o_flags |= NOCIRCUM;
 	    nu = degrad(nu);
 	    lo = nu + om;
@@ -288,7 +405,5 @@
  */
 static int
-obj_hyperbolic (np, op)
-Now *np;
-Obj *op;
+obj_hyperbolic (Now *np, Obj *op)
 {
 	double lsn, rsn;	/* true geoc lng of sun; dist from sn to earth*/
@@ -309,5 +424,4 @@
 	double e;		/* fast eccentricity */
 	double ll=0, sll, cll;	/* helio angle between object and earth */
-	double n;		/* mean daily motion */
 	double mag;		/* magnitude */
 	double a;		/* mean distance */
@@ -323,5 +437,4 @@
 	e = op->h_e;
 	a = op->h_qp/(e - 1.0);
-	n = .98563/sqrt(a*a*a);
 
 	/* correct for light time by computing position at time mjd, then
@@ -337,5 +450,6 @@
 
 	    tp = mjed - dt - op->h_ep;
-	    vrc (&nu, &rp, tp, op->h_e, op->h_qp);
+	    if (vrc (&nu, &rp, tp, op->h_e, op->h_qp) < 0)
+		op->o_flags |= NOCIRCUM;
 	    nu = degrad(nu);
 	    lo = nu + om;
@@ -382,7 +496,5 @@
  */
 static int
-obj_parabolic (np, op)
-Now *np;
-Obj *op;
+obj_parabolic (Now *np, Obj *op)
 {
 	double lsn, rsn;	/* true geoc lng of sun; dist from sn to earth*/
@@ -422,7 +534,5 @@
  */
 static int
-sun_cir (np, op)
-Now *np;
-Obj *op;
+sun_cir (Now *np, Obj *op)
 {
 	double lsn, rsn;	/* true geoc lng of sun; dist from sn to earth*/
@@ -452,7 +562,5 @@
  */
 static int
-moon_cir (np, op)
-Now *np;
-Obj *op;
+moon_cir (Now *np, Obj *op)
 {
 	double lsn, rsn;	/* true geoc lng of sun; dist from sn to earth*/
@@ -480,5 +588,7 @@
 
 	/* TODO: improve mag; this is based on a flat moon model. */
-	set_smag (op, -12.7 + 2.5*(log10(PI) - log10(PI/2*(1+1.e-6-cos(el)))));
+	i = -12.7 + 2.5*(log10(PI) - log10(PI/2*(1+1.e-6-cos(el)))) 
+					+ 5*log10(edistau/.0025) /* dist */;
+	set_smag (op, i);
 
 	/* find phase -- allow for projection effects */
@@ -500,12 +610,15 @@
  */
 static void
-cir_sky (np, lpd, psi, rp, rho, lam, bet, lsn, rsn, op)
-Now *np;
-double lpd, psi;	/* heliocentric ecliptic long and lat */
-double rp;		/* dist from sun */
-double *rho;		/* dist from earth: in as geo, back as geo or topo */
-double lam, bet;	/* true geocentric ecliptic long and lat */
-double lsn, rsn;	/* true geoc lng of sun; dist from sn to earth*/
-Obj *op;
+cir_sky (
+Now *np,
+double lpd,		/* heliocentric ecliptic longitude */
+double psi,		/* heliocentric ecliptic lat */
+double rp,		/* dist from sun */
+double *rho,		/* dist from earth: in as geo, back as geo or topo */
+double lam,		/* true geocentric ecliptic long */
+double bet,		/* true geocentric ecliptic lat */
+double lsn,		/* true geoc lng of sun */
+double rsn,		/* dist from sn to earth*/
+Obj *op)
 {
 	double el;		/* elongation */
@@ -546,5 +659,5 @@
  *   refract	--> alt/az	observed --> output
  *
- * algorithm at fixed epoch:
+ * algorithm at fixed equinox:
  *   ecl_eq	--> ra/dec	geocentric mean equatoreal EOD (via mean obliq)
  *   deflect	--> ra/dec	  relativistic deflection [for alt/az only]
@@ -558,9 +671,10 @@
  */
 static void
-cir_pos (np, bet, lam, rho, op)
-Now *np;
-double bet, lam;/* geo lat/long (mean ecliptic of date) */
-double *rho;	/* in: geocentric dist in AU; out: geo- or topocentic dist */
-Obj *op;	/* object to set s_ra/dec as per epoch */
+cir_pos (
+Now *np,
+double bet,	/* geo lat (mean ecliptic of date) */
+double lam,	/* geo long (mean ecliptic of date) */
+double *rho,	/* in: geocentric dist in AU; out: geo- or topocentic dist */
+Obj *op)	/* object to set s_ra/dec as per equinox */
 {
 	double ra, dec;		/* apparent ra/dec, corrected for nut/ab */
@@ -649,7 +763,5 @@
  */
 static void
-elongation (lam, bet, lsn, el)
-double lam, bet, lsn;
-double *el;
+elongation (double lam, double bet, double lsn, double *el)
 {
 	*el = acos(cos(bet)*cos(lam-lsn));
@@ -675,10 +787,10 @@
  */
 static void
-deflect (mjd1, lpd, psi, lsn, rsn, rho, ra, dec)
-double mjd1;		/* epoch */
-double lpd, psi;	/* heliocentric ecliptical long / lat */
-double rsn, lsn;	/* distance and longitude of sun */
-double rho;		/* geocentric distance */
-double *ra, *dec;	/* geocentric equatoreal */
+deflect (
+double mjd1,		/* equinox */
+double lpd, double psi,	/* heliocentric ecliptical long / lat */
+double rsn, double lsn,	/* distance and longitude of sun */
+double rho,		/* geocentric distance */
+double *ra, double *dec)/* geocentric equatoreal */
 {
 	double hra, hdec;	/* object heliocentric equatoreal */
@@ -742,6 +854,5 @@
  */
 static double
-h_albsize (H)
-double H;
+h_albsize (double H)
 {
 	return (3600*raddeg(.707*1500*pow(2.51,(18-H)/2)/MAU));
@@ -749,3 +860,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: circum.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: circum.c,v $ $Date: 2004-06-15 16:52:37 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: unk/SophyaExt/XephemAstroLib/circum.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/circum.h	(revision 2550)
+++ 	(revision )
@@ -1,443 +1,0 @@
-/* the Now and Obj typedefs.
- * also, a few miscellaneous constants and declarations.
- */
-#ifndef _CIRCUM_H
-#define _CIRCUM_H
-
-#define	SPD	(24.0*3600.0)	/* seconds per day */
-#define	MAU	(1.4959787e11)	/* m / au */
-#define	LTAU	499.005		/* seconds light takes to travel 1 AU */
-#define	ERAD	(6.37816e6)	/* earth equitorial radius, m */
-#define	MRAD	(1.740e6)	/* moon equitorial radius, m */
-#define	SRAD	(6.95e8)	/* sun equitorial radius, m */
-#define	FTPM	3.28084		/* ft per m */
-#define	ESAT_MAG	2	/* default satellite magnitude */
-#define	FAST_SAT_RPD	0.25	/* max earth sat rev/day considered "fast" */
-
-#define	EOD	(-9786)		/* special epoch flag: use epoch of date */
-
-/* info about the local observing circumstances and misc preferences */
-typedef struct {
-	double n_mjd;	/* modified Julian date, ie, days since
-			 * Jan 0.5 1900 (== 12 noon, Dec 30, 1899), utc.
-			 * enough precision to get well better than 1 second.
-			 * N.B. if not first member, must move NOMJD inits.
-			 */
-	double n_lat;	/* geographic (surface-normal) lat, >0 north, rads */
-	double n_lng;	/* longitude, >0 east, rads */
-	double n_tz;	/* time zone, hrs behind UTC */
-	double n_temp;	/* atmospheric temp, degrees C */
-	double n_pressure; /* atmospheric pressure, mBar */
-	double n_elev;	/* elevation above sea level, earth radii */
-	double n_dip;	/* dip of sun below hzn at twilight, >0 below, rads */
-	double n_epoch;	/* desired precession display epoch as an mjd, or EOD */
-	char n_tznm[8];	/* time zone name; 7 chars or less, always 0 at end */
-} Now;
-
-/* handy shorthands for fields in a Now pointer, np */
-#define mjd	np->n_mjd
-#define lat	np->n_lat
-#define lng	np->n_lng
-#define tz	np->n_tz
-#define temp	np->n_temp
-#define pressure np->n_pressure
-#define elev	np->n_elev
-#define	dip	np->n_dip
-#define epoch	np->n_epoch
-#define tznm	np->n_tznm
-#define mjed	mm_mjed(np)
-
-/* structures to describe objects of various types.
- */
-
-/* magnitude values in two different systems */
-typedef struct {
-    float m1, m2;	/* either g/k or H/G, depending on... */
-    int whichm;		/* one of MAG_gk or MAG_HG */
-} Mag;
-
-/* whichm */
-#define MAG_HG          0       /* using 0 makes HG the initial default */
-#define MAG_gk          1
-
-/* we actually store magnitudes times this scale factor in a short int */
-#define	MAGSCALE	100.0
-#define	set_smag(op,m)	((op)->s_mag = (short)floor((m)*MAGSCALE + 0.5))
-#define	set_fmag(op,m)	((op)->f_mag = (short)floor((m)*MAGSCALE + 0.5))
-#define	get_mag(op)	((op)->s_mag / MAGSCALE)
-
-/* longest object name, including trailing '\0' */
-#define	MAXNM	22
-
-/* Obj is a massive union.
- * many fields are in common so we use macros to make things a little easier.
- */
-
-typedef unsigned char ObjType_t;
-typedef unsigned char ObjAge_t;
-
-/* fields common to *all* structs in the Obj union.
- */
-#define	OBJ_COMMON_FLDS							\
-    ObjType_t co_type;	/* current object type; see flags, below */	\
-    unsigned char co_flags;/* FUSER*... used by others */		\
-    char co_name[MAXNM];/* name, including \0 */			\
-    float co_ra;	/* geo/topo app/mean ra, rads */		\
-    float co_dec;	/* geo/topo app/mean dec, rads */		\
-    float co_gaera;	/* geo apparent ra, rads */			\
-    float co_gaedec;	/* geo apparent dec, rads */			\
-    double co_az;	/* azimuth, >0 e of n, rads */			\
-    double co_alt;	/* altitude above topocentric horizon, rads */	\
-    float co_elong;	/* angular sep btwen obj and sun, >0 E, degs */	\
-    float co_size;	/* angular size, arc secs */			\
-    short co_mag;	/* visual magnitude * MAGSCALE */		\
-    ObjAge_t co_age	/* update aging code; see db.c */
-
-/* fields common to all solar system objects in the Obj union */
-#define	OBJ_SOLSYS_FLDS							\
-    OBJ_COMMON_FLDS;	/* all the fixed ones plus ... */		\
-    float so_sdist;	/* dist from object to sun, au */		\
-    float so_edist;	/* dist from object to earth, au */		\
-    float so_hlong;	/* heliocentric longitude, rads */		\
-    float so_hlat;	/* heliocentric latitude, rads */		\
-    float so_phase	/* phase, % */
-
-
-/* a generic object */
-typedef struct {
-    OBJ_COMMON_FLDS;
-} ObjAny;
-
-/* a generic sol system object */
-typedef struct {
-    OBJ_SOLSYS_FLDS;
-} ObjSS;
-
-/* basic Fixed object info.
- */
-typedef unsigned char byte;
-typedef struct {
-    OBJ_COMMON_FLDS;
-    char  fo_class;	/* object class --  see db.c:db_set_field() et al */
-    char  fo_spect[2];	/* spectral codes, if appropriate */
-    byte  fo_ratio;	/* minor/major diameter ratio. use s/get_ratio() */
-    byte  fo_pa;	/* position angle, E of N, rads. use s/get_pa() */
-    float fo_epoch;	/* epoch of f_RA/dec */
-    float fo_ra;	/* ra, rads, at given epoch */
-    float fo_dec;	/* dec, rads, at given epoch */
-} ObjF;
-
-#define	fo_mag	co_mag	/* pseudonym for so_mag since it is not computed */
-#define	fo_size	co_size	/* pseudonym for so_size since it is not computed */
-
-/* macros to pack/unpack some fields */
-#define	SRSCALE		255.0		/* galaxy size ratio scale */
-#define	PASCALE		(255.0/(2*PI))	/* pos angle scale factor */
-#define	get_ratio(op)	((int)(op)->f_ratio/SRSCALE)
-#define	set_ratio(op,maj,min) ((op)->f_ratio = (byte)(((maj) > 0)	    \
-					? ((min)*SRSCALE/(double)(maj)+0.5) \
-					: 0))
-#define	get_pa(op)	((double)(op)->f_pa/PASCALE)
-#define	set_pa(op,s)	((op)->f_pa = (byte)((s)*PASCALE + 0.5))
-
-#define	NCLASSES	128 /* n potential fo_classes -- allow for all ASCII */
-
-/* basic planet object info */
-typedef struct {
-    OBJ_SOLSYS_FLDS;
-    int pl_code;	/* one of the codes in astro.h */
-} ObjPl;
-
-/* basic info about an object in elliptical heliocentric orbit */
-typedef struct {
-    OBJ_SOLSYS_FLDS;
-    float  eo_inc;	/* inclination, degrees */
-    float  eo_Om;	/* longitude of ascending node, degrees */
-    float  eo_om;	/* argument of perihelion, degress */
-    float  eo_a;	/* mean distance, aka,semi-maj axis,AU */
-    float  eo_M;	/* mean anomaly, ie, degrees from perihelion at cepoch*/
-    float  eo_size;	/* angular size, in arc seconds at 1 AU */
-    double eo_e;	/* eccentricity (double for when near 1 computing q) */
-    double eo_cepoch;	/* epoch date (M reference), as an mjd */
-    double eo_epoch;	/* equinox year (inc/Om/om reference), as an mjd. */
-    Mag    eo_mag;	/* magnitude */
-} ObjE;
-
-/* basic info about an object in hyperbolic heliocentric orbit */
-typedef struct {
-    OBJ_SOLSYS_FLDS;
-    double ho_epoch;	/* equinox year (inc/Om/om reference), as an mjd */
-    double ho_ep;	/* epoch of perihelion, as an mjd */
-    float  ho_inc;	/* inclination, degs */
-    float  ho_Om;	/* longitude of ascending node, degs */
-    float  ho_om;	/* argument of perihelion, degs. */
-    float  ho_e;	/* eccentricity */
-    float  ho_qp;	/* perihelion distance, AU */
-    float  ho_g, ho_k;	/* magnitude model coefficients */
-    float  ho_size;	/* angular size, in arc seconds at 1 AU */
-} ObjH;
-
-/* basic info about an object in parabolic heliocentric orbit */
-typedef struct {
-    OBJ_SOLSYS_FLDS;
-    double po_epoch;	/* reference epoch, as an mjd */
-    double po_ep;	/* epoch of perihelion, as an mjd */
-    float  po_inc;	/* inclination, degs */
-    float  po_qp;	/* perihelion distance, AU */
-    float  po_om;	/* argument of perihelion, degs. */
-    float  po_Om;	/* longitude of ascending node, degs */
-    float  po_g, po_k;	/* magnitude model coefficients */
-    float  po_size;	/* angular size, in arc seconds at 1 AU */
-} ObjP;
-
-/* basic earth satellite object info */
-typedef struct {
-    OBJ_COMMON_FLDS;
-    double eso_epoch;	/* reference epoch, as an mjd */
-    double eso_n;	/* mean motion, rev/day
-			 * N.B. we need double due to a sensitive differencing
-			 * operation used to compute MeanAnomaly in
-			 * esat_main()/satellite.c.
-			 */
-    float  eso_inc;	/* inclination, degs */
-    float  eso_raan;	/* RA of ascending node, degs */
-    float  eso_e;	/* eccentricity */
-    float  eso_ap;	/* argument of perigee at epoch, degs */
-    float  eso_M;	/* mean anomaly, ie, degrees from perigee at epoch */
-    float  eso_decay;	/* orbit decay rate, rev/day^2 */
-    float  eso_drag;	/* object drag coefficient, (earth radii)^-1 */
-    int    eso_orbit;	/* integer orbit number of epoch */
-
-    /* computed "sky" results unique to earth satellites */
-    float  ess_elev;	/* height of satellite above sea level, m */
-    float  ess_range;	/* line-of-site distance from observer to satellite, m*/
-    float  ess_rangev;	/* rate-of-change of range, m/s */
-    float  ess_sublat;	/* latitude below satellite, >0 north, rads */
-    float  ess_sublng;	/* longitude below satellite, >0 east, rads */
-    int    ess_eclipsed;/* 1 if satellite is in earth's shadow, else 0 */
-} ObjES;
-
-typedef union {
-    ObjAny  any;	/* these fields valid for all types */
-    ObjSS   anyss;	/* these fields valid for all solar system types */
-    ObjPl   pl;		/* planet */
-    ObjF    f;		/* fixed object */
-    ObjE    e;		/* object in heliocentric elliptical orbit */
-    ObjH    h;		/* object in heliocentric hyperbolic trajectory */
-    ObjP    p;		/* object in heliocentric parabolic trajectory */
-    ObjES   es;		/* earth satellite */
-} Obj;
-
-
-/* for o_flags -- everybody must agree */
-#define	FUSER0		0x01
-#define	FUSER1		0x02
-#define	FUSER2		0x04
-#define	FUSER3		0x08
-#define	FUSER4		0x10
-#define	FUSER5		0x20
-#define	FUSER6		0x40
-#define	FUSER7		0x80
-
-/* mark an object as being a "field star" */
-#define	FLDSTAR		FUSER3
-
-/* Obj shorthands: */
-#define	o_type	any.co_type
-#define	o_name	any.co_name
-#define	o_flags	any.co_flags
-#define	o_age	any.co_age
-#define	s_ra	any.co_ra
-#define	s_dec	any.co_dec
-#define	s_gaera	any.co_gaera
-#define	s_gaedec any.co_gaedec
-#define	s_az	any.co_az
-#define	s_alt	any.co_alt
-#define	s_elong	any.co_elong
-#define	s_size	any.co_size
-#define	s_mag	any.co_mag
-
-#define	s_sdist	anyss.so_sdist
-#define	s_edist	anyss.so_edist
-#define	s_hlong	anyss.so_hlong
-#define	s_hlat	anyss.so_hlat
-#define	s_phase anyss.so_phase
-
-#define	s_elev		es.ess_elev
-#define	s_range		es.ess_range
-#define	s_rangev	es.ess_rangev
-#define	s_sublat	es.ess_sublat
-#define	s_sublng	es.ess_sublng
-#define	s_eclipsed	es.ess_eclipsed
-
-#define	f_class	f.fo_class
-#define	f_spect	f.fo_spect
-#define	f_ratio	f.fo_ratio
-#define	f_pa	f.fo_pa
-#define	f_epoch	f.fo_epoch
-#define	f_RA	f.fo_ra
-#define	f_dec	f.fo_dec
-#define	f_mag	f.fo_mag
-#define	f_size	f.fo_size
-
-#define	e_cepoch e.eo_cepoch
-#define	e_epoch	e.eo_epoch
-#define	e_inc	e.eo_inc
-#define	e_Om	e.eo_Om
-#define	e_om	e.eo_om
-#define	e_a	e.eo_a
-#define	e_e	e.eo_e
-#define	e_M	e.eo_M
-#define	e_size	e.eo_size
-#define	e_mag	e.eo_mag
-
-#define	h_epoch	h.ho_epoch
-#define	h_ep	h.ho_ep
-#define	h_inc	h.ho_inc
-#define	h_Om	h.ho_Om
-#define	h_om	h.ho_om
-#define	h_e	h.ho_e
-#define	h_qp	h.ho_qp
-#define	h_g	h.ho_g
-#define	h_k	h.ho_k
-#define	h_size	h.ho_size
-
-#define	p_epoch	p.po_epoch
-#define	p_ep	p.po_ep
-#define	p_inc	p.po_inc
-#define	p_qp	p.po_qp
-#define	p_om	p.po_om
-#define	p_Om	p.po_Om
-#define	p_g	p.po_g
-#define	p_k	p.po_k
-#define	p_size	p.po_size
-
-#define	es_epoch	es.eso_epoch
-#define	es_inc		es.eso_inc
-#define	es_raan		es.eso_raan
-#define	es_e		es.eso_e
-#define	es_ap		es.eso_ap
-#define	es_M		es.eso_M
-#define	es_n		es.eso_n
-#define	es_decay	es.eso_decay
-#define	es_drag		es.eso_drag
-#define	es_orbit	es.eso_orbit
-
-/* insure we always refer to the fields and no monkey business */
-#undef OBJ_COMMON_FLDS
-#undef OBJ_SOLSYS_FLDS
-
-/* o_type code.
- * N.B. names are assigned in order in objmenu.c
- * N.B. if add one: update the size init in db_init(); switch in obj_cir().
- * N.B. UNDEFOBJ must be zero so new objects are undefinied by being zeroed.
- * N.B. maintain the bitmasks too.
- * N.B. PLANET must be last -- see objmenu.c
- */
-enum ObjType {
-    UNDEFOBJ=0,
-    FIXED, ELLIPTICAL, HYPERBOLIC, PARABOLIC, EARTHSAT, PLANET,
-    NOBJTYPES
-};
-
-/* types as handy bitmasks too */
-#define	FIXEDM		(1<<FIXED)
-#define	ELLIPTICALM	(1<<ELLIPTICAL)
-#define	HYPERBOLICM	(1<<HYPERBOLIC)
-#define	PARABOLICM	(1<<PARABOLIC)
-#define	EARTHSATM	(1<<EARTHSAT)
-#define	PLANETM		(1<<PLANET)
-#define	ALLM		(FIXEDM | HYPERBOLICM | PARABOLICM | EARTHSATM \
-						      | ELLIPTICALM | PLANETM)
-
-/* define a code for each member in each object type struct.
- * making them globally unique avoids a nested switch in db_set_field() and
- * helps with dynamic prompting based on preferences.
- */
-enum {
-    O_TYPE, O_NAME,
-    F_RA, F_DEC, F_EPOCH, F_MAG, F_SIZE, F_CLASS, F_SPECT,
-    E_INC, E_LAN, E_AOP, E_A, E_N, E_E, E_M, E_CEPOCH, E_EPOCH,E_M1,E_M2,E_SIZE,
-    H_EP, H_INC, H_LAN, H_AOP, H_E, H_QP, H_EPOCH, H_G, H_K, H_SIZE,
-    P_EP, P_INC, P_AOP, P_QP, P_LAN, P_EPOCH, P_G, P_K, P_SIZE,
-    ES_EPOCH,ES_INC,ES_RAAN,ES_E,ES_AP,ES_M,ES_N,ES_DECAY,ES_ORBIT,ES_DRAG
-};
-
-/* rise, set and transit information.
- */
-typedef struct {
-    int rs_flags;	/* info about what has been computed and any
-			 * special conditions; see flags, below.
-			 */
-    double rs_risetm;	/* mjd time of rise today */
-    double rs_riseaz;	/* azimuth of rise, rads E of N */
-    double rs_trantm;	/* mjd time of transit today */
-    double rs_tranalt;	/* altitude of transit, rads up from horizon */
-    double rs_settm;	/* mjd time of set today */
-    double rs_setaz;	/* azimuth of set, rads E of N */
-} RiseSet;
-
-/* RiseSet flags */
-#define	RS_NORISE	0x0001	/* object does not rise as such today */
-#define	RS_NOSET	0x0002	/* object does not set as such today */
-#define	RS_NOTRANS	0x0004	/* object does not transit as such today */
-#define	RS_CIRCUMPOLAR	0x0010	/* object stays up all day today */
-#define	RS_NEVERUP	0x0020	/* object never up at all today */
-#define	RS_ERROR	0x1000	/* can't figure out anything! */
-#define	RS_RISERR	(0x0100|RS_ERROR) /* error computing rise */
-#define	RS_SETERR	(0x0200|RS_ERROR) /* error computing set */
-#define	RS_TRANSERR	(0x0400|RS_ERROR) /* error computing transit */
-
-#define	is_type(op,m)	((1<<(op)->o_type) & (m))
-#define	is_planet(op,p)	(is_type(op,PLANETM) && ((ObjPl *)op)->pl_code==(p))
-#define	is_ssobj(op)	is_type(op,PLANETM|HYPERBOLICM|PARABOLICM|ELLIPTICALM)
-
-/* used to maintain progress state with db_scanint() and db_scan */
-typedef struct {
-    int m;	/* mask of *N types desired */
-    int t;	/* current Object type, as per ObjType */
-    int n;	/* number of objects "scanned" so far */
-    ObjF *op;	/* local list to also scan */
-    int nop;	/* number in op[] */
-} DBScan;
-
-#endif /* _CIRCUM_H */
-
-
-
-/* Some handy declarations */
-
-/* ap_as.c */
-extern void ap_as P_(( Now *np, double Mjd, double *rap, double *decp));
-extern void as_ap P_(( Now *np, double Mjd, double *rap, double *decp));
-
-/* aux.c */
-extern double mm_mjed P_((Now *np));
-
-/* circum.c */
-extern int obj_cir P_((Now *np, Obj *op));
-
-/* earthsat.c */
-extern int obj_earthsat P_((Now *np, Obj *op));
-
-/* dbfmt.c */
-extern int db_crack_line P_((char s[], Obj *op, char whynot[]));
-extern void db_write_line P_((Obj *op, char *lp));
-extern int get_fields P_((char *s, int delim, char *fields[]));
-extern int db_chk_planet P_((char name[], Obj *op));
-extern int db_tle P_((char *name, char *l1, char *l2, Obj *op));
-
-/* misc.c */
-extern void now_lst P_((Now *np, double *lstp));
-extern void radec2ha P_((Now *np, double ra, double dec, double *hap));
-extern char *obj_description P_((Obj *op));
-extern int is_deepsky P_((Obj *op));
-
-/* riset_cir.c */
-extern void riset_cir P_((Now *np, Obj *op, double dis, RiseSet *rp));
-extern void twilight_cir P_((Now *np, double dis, double *dawn, double *dusk,
-    int *status));
-
-/* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: circum.h,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
- */
Index: /trunk/SophyaExt/XephemAstroLib/comet.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/comet.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/comet.c	(revision 2551)
@@ -1,9 +1,8 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
-/* given a modified Julian date, mjd, and a set of heliocentric parabolic
- * orbital elements referred to the epoch of date (mjd):
+/* given a modified Julian date, mj, and a set of heliocentric parabolic
+ * orbital elements referred to the epoch of date (mj):
  *   ep:   epoch of perihelion,
  *   inc:  inclination,
@@ -30,8 +29,6 @@
  */
 void
-comet (mjd, ep, inc, ap, qp, om, lpd, psi, rp, rho, lam, bet)
-double mjd;
-double ep, inc, ap, qp, om;
-double *lpd, *psi, *rp, *rho, *lam, *bet;
+comet (double mj, double ep, double inc, double ap, double qp, double om,
+double *lpd, double *psi, double *rp, double *rho, double *lam, double *bet)
 {
 	double w, s, s2;
@@ -44,5 +41,5 @@
 
 #define	ERRLMT	0.0001
-        w = ((mjd-ep)*3.649116e-02)/(qp*sqrt(qp));
+        w = ((mj-ep)*3.649116e-02)/(qp*sqrt(qp));
         s = w/3;
 	for (;;) {
@@ -68,5 +65,5 @@
 	range (lpd, 2*PI);
         rd = *rp * cpsi;
-	sunpos (mjd, &lsn, &rsn, 0);
+	sunpos (mj, &lsn, &rsn, 0);
 	lg = lsn+PI;
         re = rsn;
@@ -84,3 +81,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: comet.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: comet.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/compare_with_xephem.csh
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/compare_with_xephem.csh	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/compare_with_xephem.csh	(revision 2551)
@@ -4,9 +4,9 @@
   echo 'Placez vous dans le repertoire ou vous avez'
   echo 'mis le NOUVEAU code du libastro de Xephem.'
-  echo '> $DPCSOURCE/XephemAstroLib/compare_with_xephem.csh'
+  echo '> $SOPHYASOURCE/XephemAstroLib/compare_with_xephem.csh'
   exit -1
 endif
 
-set dir = $DPCSOURCE/XephemAstroLib/
+set dir = $SOPHYASOURCE/XephemAstroLib/
 set log = `pwd`/compare.log
 
Index: /trunk/SophyaExt/XephemAstroLib/constel.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/constel.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/constel.c	(revision 2551)
@@ -0,0 +1,4709 @@
+/* code to handle constellation boundaries and figures */
+
+/*
+Constellation boundaries:
+
+ Primary reference:
+
+  METHOD TO DETERMINE THE CONSTELLATION IN WHICH A POSITION IS LOCATED
+
+        Recently, Mr. Barry N. Rappaport of New  Mexico State University
+  transcribed  the constellation  boundaries as  fixed  by the IAU  into
+  machine-readable form.  These have  been  transcribed  by Dr. Nancy G.
+  Roman to make it possible  to determine by  computer the constellation
+  in which a position is located.
+
+ NSSDC catalog description:
+ 6042   AN     Catalog of Constellation Boundary Data (Delporte, E. 1930, 
+               Cambridge Univ. Press)
+               Comment(s): includes constellation identification software 
+               (ADC 1987; see Roman, N.G. 1987, Publ. Astron. Soc. Pacific 
+               99, 695); 23 description, 118 software, 358 data records. 
+               3 files: 23x80, 118x80, 358x29 
+
+ Further adapted for xephem by:
+
+    Craig Counterman: conversion from original F77 to C
+    Elwood Downey:    incorporation into xephem
+    Ernie Wright:     additional speed and time improvments
+
+Constellation figures:
+
+    Chris Marriott:   original figures
+    Elwood Downey:    incorporated into xephem
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "astro.h"
+
+/*
+======================================================================
+Ernie Wright  2 Mar 94
+
+Find the constellation for a given position.
+
+First C version by Craig Counterman and Elwood Downey.  Based on a
+FORTRAN program by Nancy G. Roman (Roman, N.G. 1987, Publ. Astron.
+Soc. Pacific 99, 695).  IAU constellation boundaries transcribed into
+machine-readable form by Barry N. Rappaport, New Mexico State Univ.
+======================================================================
+*/
+
+#define NBOUNDS 357
+
+/* constellation ids */
+#define And  0
+#define Ant  1
+#define Aps  2
+#define Aql  3
+#define Aqr  4
+#define Ara  5
+#define Ari  6
+#define Aur  7
+#define Boo  8
+#define CMa  9
+#define CMi 10
+#define CVn 11
+#define Cae 12
+#define Cam 13
+#define Cap 14
+#define Car 15
+#define Cas 16
+#define Cen 17
+#define Cep 18
+#define Cet 19
+#define Cha 20
+#define Cir 21
+#define Cnc 22
+#define Col 23
+#define Com 24
+#define CrA 25
+#define CrB 26
+#define Crt 27
+#define Cru 28
+#define Crv 29
+#define Cyg 30
+#define Del 31
+#define Dor 32
+#define Dra 33
+#define Equ 34
+#define Eri 35
+#define For 36
+#define Gem 37
+#define Gru 38
+#define Her 39
+#define Hor 40
+#define Hya 41
+#define Hyi 42
+#define Ind 43
+#define LMi 44
+#define Lac 45
+#define Leo 46
+#define Lep 47
+#define Lib 48
+#define Lup 49
+#define Lyn 50
+#define Lyr 51
+#define Men 52
+#define Mic 53
+#define Mon 54
+#define Mus 55
+#define Nor 56
+#define Oct 57
+#define Oph 58
+#define Ori 59
+#define Pav 60
+#define Peg 61
+#define Per 62
+#define Phe 63
+#define Pic 64
+#define PsA 65
+#define Psc 66
+#define Pup 67
+#define Pyx 68
+#define Ret 69
+#define Scl 70
+#define Sco 71
+#define Sct 72
+#define Se1 73
+#define Sex 74
+#define Sge 75
+#define Sgr 76
+#define Tau 77
+#define Tel 78
+#define TrA 79
+#define Tri 80
+#define Tuc 81
+#define UMa 82
+#define UMi 83
+#define Vel 84
+#define Vir 85
+#define Vol 86
+#define Vul 87
+#define Se2 88
+
+static char *cns_namemap[ NCNS ] = {
+   /*  0 */   "And: Andromeda",
+   /*  1 */   "Ant: Antlia",
+   /*  2 */   "Aps: Apus",
+   /*  3 */   "Aql: Aquila",
+   /*  4 */   "Aqr: Aquarius",
+   /*  5 */   "Ara: Ara",
+   /*  6 */   "Ari: Aries",
+   /*  7 */   "Aur: Auriga",
+   /*  8 */   "Boo: Bootes",
+   /*  9 */   "CMa: Canis Major",
+   /* 10 */   "CMi: Canis Minor",
+   /* 11 */   "CVn: Canes Venatici",
+   /* 12 */   "Cae: Caelum",
+   /* 13 */   "Cam: Camelopardalis",
+   /* 14 */   "Cap: Capricornus",
+   /* 15 */   "Car: Carina",
+   /* 16 */   "Cas: Cassiopeia",
+   /* 17 */   "Cen: Centaurus",
+   /* 18 */   "Cep: Cepheus",
+   /* 19 */   "Cet: Cetus",
+   /* 20 */   "Cha: Chamaeleon",
+   /* 21 */   "Cir: Circinus",
+   /* 22 */   "Cnc: Cancer",
+   /* 23 */   "Col: Columba",
+   /* 24 */   "Com: Coma Berenices",
+   /* 25 */   "CrA: Corona Australis",
+   /* 26 */   "CrB: Corona Borealis",
+   /* 27 */   "Crt: Crater",
+   /* 28 */   "Cru: Crux",
+   /* 29 */   "Crv: Corvus",
+   /* 30 */   "Cyg: Cygnus",
+   /* 31 */   "Del: Delphinus",
+   /* 32 */   "Dor: Dorado",
+   /* 33 */   "Dra: Draco",
+   /* 34 */   "Equ: Equuleus",
+   /* 35 */   "Eri: Eridanus",
+   /* 36 */   "For: Fornax",
+   /* 37 */   "Gem: Gemini",
+   /* 38 */   "Gru: Grus",
+   /* 39 */   "Her: Hercules",
+   /* 40 */   "Hor: Horologium",
+   /* 41 */   "Hya: Hydra",
+   /* 42 */   "Hyi: Hydrus",
+   /* 43 */   "Ind: Indus",
+   /* 44 */   "LMi: Leo Minor",
+   /* 45 */   "Lac: Lacerta",
+   /* 46 */   "Leo: Leo",
+   /* 47 */   "Lep: Lepus",
+   /* 48 */   "Lib: Libra",
+   /* 49 */   "Lup: Lupus",
+   /* 50 */   "Lyn: Lynx",
+   /* 51 */   "Lyr: Lyra",
+   /* 52 */   "Men: Mensa",
+   /* 53 */   "Mic: Microscopium",
+   /* 54 */   "Mon: Monoceros",
+   /* 55 */   "Mus: Musca",
+   /* 56 */   "Nor: Norma",
+   /* 57 */   "Oct: Octans",
+   /* 58 */   "Oph: Ophiuchus",
+   /* 59 */   "Ori: Orion",
+   /* 60 */   "Pav: Pavo",
+   /* 61 */   "Peg: Pegasus",
+   /* 62 */   "Per: Perseus",
+   /* 63 */   "Phe: Phoenix",
+   /* 64 */   "Pic: Pictor",
+   /* 65 */   "PsA: Piscis Austrinus",
+   /* 66 */   "Psc: Pisces",
+   /* 67 */   "Pup: Puppis",
+   /* 68 */   "Pyx: Pyxis",
+   /* 69 */   "Ret: Reticulum",
+   /* 70 */   "Scl: Sculptor",
+   /* 71 */   "Sco: Scorpius",
+   /* 72 */   "Sct: Scutum",
+   /* 73 */   "Se1: Serpens Caput",
+   /* 74 */   "Sex: Sextans",
+   /* 75 */   "Sge: Sagitta",
+   /* 76 */   "Sgr: Sagittarius",
+   /* 77 */   "Tau: Taurus",
+   /* 78 */   "Tel: Telescopium",
+   /* 79 */   "TrA: Triangulum Australe",
+   /* 80 */   "Tri: Triangulum",
+   /* 81 */   "Tuc: Tucana",
+   /* 82 */   "UMa: Ursa Major",
+   /* 83 */   "UMi: Ursa Minor",
+   /* 84 */   "Vel: Vela",
+   /* 85 */   "Vir: Virgo",
+   /* 86 */   "Vol: Volans",
+   /* 87 */   "Vul: Vulpecula",
+   /* 88 */   "Se2: Serpens Cauda",
+};
+
+static struct {
+   unsigned short lower_ra;      /* hours * 1800 */
+   unsigned short upper_ra;      /* hours * 1800 */
+   short          lower_dec;     /* degrees * 60 */
+   short          index;
+} cbound[ NBOUNDS ] = {
+   {     0, 43200,  5280, UMi },
+   { 14400, 26100,  5190, UMi },
+   { 37800, 41400,  5170, UMi },
+   { 32400, 37800,  5160, UMi },
+   {     0, 14400,  5100, Cep },
+   { 16500, 19200,  4920, Cam },
+   {     0,  9000,  4800, Cep },
+   { 19200, 26100,  4800, Cam },
+   { 31500, 32400,  4800, UMi },
+   { 36300, 37800,  4800, Dra },
+   {     0,  6315,  4620, Cep },
+   { 20700, 24450,  4620, Cam },
+   { 29760, 31500,  4500, UMi },
+   { 36300, 37200,  4500, Cep },
+   { 14340, 16500,  4410, Cam },
+   { 16500, 20400,  4410, Dra },
+   { 23400, 29760,  4200, UMi },
+   {  5580,  6150,  4080, Cas },
+   { 36750, 37200,  4020, Dra },
+   { 20400, 21600,  3990, Dra },
+   {     0,   600,  3960, Cep },
+   { 25200, 28200,  3960, UMi },
+   { 42450, 43200,  3960, Cep },
+   { 21600, 24300,  3840, Dra },
+   { 24300, 25950,  3780, Dra },
+   { 41700, 42450,  3780, Cep },
+   { 10980, 12600,  3720, Cam },
+   { 36000, 36750,  3690, Dra },
+   { 36966, 37080,  3655, Cep },
+   { 12600, 14340,  3600, Cam },
+   { 14340, 15150,  3600, UMa },
+   { 35580, 36000,  3570, Dra },
+   { 36000, 36966,  3570, Cep },
+   { 41160, 41700,  3545, Cep },
+   {     0,  4380,  3510, Cas },
+   { 34950, 35580,  3480, Dra },
+   {  3060,  3435,  3450, Cas },
+   {  4380,  5580,  3420, Cas },
+   {  5580,  5700,  3420, Cam },
+   { 40170, 41160,  3375, Cep },
+   {  9000, 10980,  3360, Cam },
+   { 25260, 25950,  3330, UMa },
+   { 25950, 34950,  3330, Dra },
+   {  5700,  6000,  3300, Cam },
+   { 39840, 40170,  3300, Cep },
+   { 37080, 39540,  3290, Cep },
+   {     0,  3060,  3240, Cas },
+   { 10980, 11700,  3240, Lyn },
+   { 21750, 24300,  3180, UMa },
+   { 27450, 28350,  3180, Dra },
+   { 39540, 39840,  3165, Cep },
+   {  6000,  9000,  3150, Cam },
+   { 41160, 42000,  3150, Cas },
+   { 28350, 30600,  3090, Dra },
+   {  3675,  4530,  3030, Per },
+   { 30600, 32820,  3030, Dra },
+   {     0,  2460,  3000, Cas },
+   {  2460,  3000,  3000, Per },
+   { 11700, 12240,  3000, Lyn },
+   { 42000, 43200,  3000, Cas },
+   { 24300, 25260,  2910, UMa },
+   {     0,  2010,  2880, Cas },
+   { 42450, 43200,  2880, Cas },
+   { 32715, 32820,  2850, Her },
+   { 32820, 34350,  2850, Dra },
+   { 34350, 34500,  2850, Cyg },
+   {  3000,  3675,  2820, Per },
+   { 15150, 16500,  2820, UMa },
+   {   300,  1560,  2760, Cas },
+   { 21600, 21750,  2700, UMa },
+   { 12240, 13260,  2670, Lyn },
+   { 39435, 39540,  2640, Cyg },
+   { 39375, 39435,  2625, Cyg },
+   { 34500, 34920,  2610, Cyg },
+   { 16500, 18300,  2520, UMa },
+   { 18300, 19410,  2400, UMa },
+   { 27780, 28350,  2400, Boo },
+   { 28350, 29400,  2400, Her },
+   { 16650, 17250,  2385, Lyn },
+   {     0,  4530,  2205, And },
+   {  4530,  4620,  2205, Per },
+   { 34845, 34920,  2190, Lyr },
+   {  8100,  8445,  2160, Per },
+   { 39120, 39375,  2160, Cyg },
+   { 39375, 39600,  2160, Lac },
+   { 11760, 13260,  2130, Aur },
+   { 13260, 13950,  2130, Lyn },
+   {     0,  3600,  2100, And },
+   { 39600, 41070,  2100, Lac },
+   { 41070, 41160,  2070, Lac },
+   { 41160, 42300,  2070, And },
+   {  4620,  4890,  2040, Per },
+   { 19410, 19800,  2040, UMa },
+   { 21600, 22200,  2040, CVn },
+   { 13950, 16650,  2010, Lyn },
+   { 16650, 17790,  2010, LMi },
+   {  1290,  2535,  1980, And },
+   { 27330, 27780,  1980, Boo },
+   { 42300, 42750,  1925, And },
+   { 22200, 23850,  1920, CVn },
+   { 42750, 43200,  1880, And },
+   { 25125, 25260,  1845, CVn },
+   {  4350,  4890,  1840, Tri },
+   {  4890,  8100,  1840, Per },
+   {  8100,  8550,  1800, Aur },
+   { 32715, 34845,  1800, Lyr },
+   { 19800, 21600,  1740, UMa },
+   { 35400, 37650,  1740, Cyg },
+   {  8550, 10590,  1710, Aur },
+   { 17790, 18900,  1710, LMi },
+   { 23850, 25125,  1710, CVn },
+   {     0,   120,  1680, And },
+   {  2535,  3000,  1680, Tri },
+   { 10590, 11760,  1680, Aur },
+   { 14190, 14400,  1680, Gem },
+   { 37650, 39120,  1680, Cyg },
+   { 34665, 35400,  1650, Cyg },
+   {  3450,  4350,  1635, Tri },
+   { 29100, 29400,  1620, CrB },
+   { 27150, 27330,  1560, Boo },
+   { 27330, 29100,  1560, CrB },
+   { 33060, 33960,  1560, Lyr },
+   { 19350, 19800,  1530, LMi },
+   { 33960, 34665,  1530, Lyr },
+   {  3000,  3450,  1500, Tri },
+   {  1290,  1530,  1425, Psc },
+   { 18900, 19350,  1410, LMi },
+   { 38250, 38550,  1410, Vul },
+   { 10260, 10590,  1370, Tau },
+   {   120,   255,  1320, And },
+   { 28650, 28860,  1320, Se1 },
+   { 10590, 11190,  1290, Gem },
+   { 35700, 36450,  1275, Vul },
+   { 33960, 34650,  1265, Vul },
+   {   255,  1530,  1260, And },
+   { 36450, 37020,  1230, Vul },
+   { 14055, 14190,  1200, Gem },
+   { 37020, 38250,  1170, Vul },
+   { 34650, 35700,  1150, Vul },
+   {  5910,  6060,  1140, Ari },
+   { 33960, 34200,  1110, Sge },
+   { 10260, 10380,  1080, Ori },
+   { 11190, 11355,  1050, Gem },
+   { 34200, 35700,   970, Sge },
+   {  8940,  9600,   960, Tau },
+   { 28650, 28950,   960, Her },
+   { 35700, 36450,   945, Sge },
+   {  8310,  8940,   930, Tau },
+   {  9600, 10080,   930, Tau },
+   { 23100, 24300,   900, Com },
+   { 31050, 32850,   860, Her },
+   { 21360, 23100,   840, Com },
+   { 13500, 14055,   810, Gem },
+   { 30150, 31050,   770, Her },
+   {     0,   255,   750, Peg },
+   { 10080, 10380,   750, Tau },
+   { 12600, 13500,   750, Gem },
+   { 38010, 38400,   750, Peg },
+   { 11355, 12480,   720, Gem },
+   { 32850, 33960,   720, Her },
+   { 37575, 37890,   710, Del },
+   { 37890, 38010,   710, Peg },
+   { 20730, 21360,   660, Leo },
+   { 11235, 11355,   600, Ori },
+   { 12480, 12600,   600, Gem },
+   { 14055, 14265,   600, Cnc },
+   { 42900, 43200,   600, Peg },
+   {  3000,  5910,   595, Ari },
+   { 36255, 36540,   510, Del },
+   { 24300, 27150,   480, Boo },
+   { 40950, 42900,   450, Peg },
+   { 14265, 16650,   420, Cnc },
+   { 16650, 19350,   420, Leo },
+   { 32850, 33592,   375, Oph },
+   { 33592, 33960,   375, Aql },
+   { 37500, 37575,   360, Del },
+   { 12600, 12630,   330, CMi },
+   { 32850, 33165,   270, Se2 },
+   { 28950, 30150,   240, Her },
+   { 32850, 33165,   180, Oph },
+   { 38640, 39000,   165, Peg },
+   {     0,  3600,   120, Psc },
+   { 33450, 33960,   120, Se2 },
+   { 36540, 37500,   120, Del },
+   { 37500, 38400,   120, Equ },
+   { 38400, 38640,   120, Peg },
+   { 39600, 40950,   120, Peg },
+   { 39000, 39600,   105, Peg },
+   { 12630, 12960,    90, CMi },
+   {  6450,  8310,     0, Tau },
+   {  8310,  8400,     0, Ori },
+   { 12960, 14550,     0, CMi },
+   { 26400, 27150,     0, Vir },
+   { 32100, 32850,     0, Oph },
+   {  4770,  5910,  -105, Cet },
+   {  5910,  6450,  -105, Tau },
+   { 27150, 29280,  -195, Se1 },
+   {  8400,  9150,  -240, Ori },
+   { 10500, 11235,  -240, Ori },
+   { 32100, 32340,  -240, Se2 },
+   { 32850, 33450,  -240, Se2 },
+   { 33450, 33960,  -240, Aql },
+   { 40950, 42900,  -240, Psc },
+   { 19350, 20730,  -360, Leo },
+   { 20730, 21300,  -360, Vir },
+   {     0,   600,  -420, Psc },
+   { 42900, 43200,  -420, Psc },
+   { 25650, 26400,  -480, Vir },
+   { 28650, 29280,  -480, Oph },
+   { 36000, 36960,  -540, Aql },
+   { 38400, 39360,  -540, Aqr },
+   { 30900, 32340,  -600, Oph },
+   { 10500, 14550,  -660, Mon },
+   {  8850,  9150,  -660, Eri },
+   {  9150, 10500,  -660, Ori },
+   { 14550, 15060,  -660, Hya },
+   { 17250, 19350,  -660, Sex },
+   { 21300, 23100,  -660, Vir },
+   { 31650, 31800,  -700, Oph },
+   { 33960, 36000,  -722, Aql },
+   {  8700,  8850,  -870, Eri },
+   { 36960, 38400,  -900, Aqr },
+   { 30900, 32850,  -960, Se2 },
+   { 32850, 33960,  -960, Sct },
+   { 15060, 15450, -1020, Hya },
+   { 29280, 29475, -1095, Oph },
+   { 15450, 16350, -1140, Hya },
+   { 19350, 19500, -1140, Crt },
+   { 29280, 29475, -1155, Sco },
+   { 28200, 28650, -1200, Lib },
+   { 22650, 23100, -1320, Crv },
+   { 23100, 25650, -1320, Vir },
+   { 16350, 17550, -1440, Hya },
+   {  3000,  4770, -1463, Cet },
+   {  4770,  6750, -1463, Eri },
+   { 19500, 21300, -1470, Crt },
+   { 21300, 22650, -1470, Crv },
+   { 25650, 26850, -1470, Lib },
+   { 29280, 30150, -1475, Oph },
+   {     0,  3000, -1530, Cet },
+   { 38400, 39360, -1530, Cap },
+   { 39360, 42900, -1530, Aqr },
+   { 42900, 43200, -1530, Cet },
+   { 17550, 18450, -1590, Hya },
+   {  8460,  8700, -1635, Eri },
+   {  8700, 11010, -1635, Lep },
+   { 36000, 38400, -1680, Cap },
+   { 18450, 19050, -1750, Hya },
+   { 22650, 26850, -1770, Hya },
+   { 26850, 28200, -1770, Lib },
+   { 28200, 28800, -1770, Sco },
+   {  8250,  8460, -1800, Eri },
+   { 30150, 31680, -1800, Oph },
+   { 31680, 32100, -1800, Sgr },
+   { 19050, 19500, -1870, Hya },
+   { 11010, 13260, -1980, CMa },
+   { 22050, 22650, -1980, Hya },
+   { 19500, 22050, -2100, Hya },
+   {  6300,  6750, -2160, For },
+   { 15060, 16860, -2205, Pyx },
+   {  7680,  8250, -2220, Eri },
+   { 32100, 34500, -2220, Sgr },
+   { 38400, 41400, -2220, PsA },
+   { 41400, 42000, -2220, Scl },
+   {  5400,  6300, -2375, For },
+   { 16860, 19800, -2385, Ant },
+   {     0,  3000, -2400, Scl },
+   {  3000,  5400, -2400, For },
+   {  6960,  7680, -2400, Eri },
+   { 42000, 43200, -2400, Scl },
+   { 25500, 26850, -2520, Cen },
+   { 28200, 28800, -2520, Lup },
+   { 28800, 29557, -2520, Sco },
+   {  8700,  9000, -2580, Cae },
+   {  9000, 11850, -2580, Col },
+   { 14400, 15060, -2580, Pup },
+   {  6150,  6960, -2640, Eri },
+   { 29557, 32100, -2730, Sco },
+   { 32100, 34500, -2730, CrA },
+   { 34500, 36600, -2730, Sgr },
+   { 36600, 38400, -2730, Mic },
+   {  5400,  6150, -2760, Eri },
+   {  8100,  8700, -2790, Cae },
+   { 27600, 28200, -2880, Lup },
+   {     0,  4200, -2890, Phe },
+   {  4800,  5400, -2940, Eri },
+   {  7350,  7680, -2940, Hor },
+   {  7680,  8100, -2940, Cae },
+   { 38400, 39600, -3000, Gru },
+   { 10800, 14400, -3045, Pup },
+   { 14400, 14700, -3045, Vel },
+   {  4350,  4800, -3060, Eri },
+   {  6900,  7350, -3060, Hor },
+   {     0,  3300, -3090, Phe },
+   { 10800, 11100, -3150, Car },
+   { 14700, 15210, -3180, Vel },
+   {  6300,  6900, -3190, Hor },
+   {  6900,  7200, -3190, Dor },
+   {     0,  2850, -3210, Phe },
+   {  3900,  4350, -3240, Eri },
+   {  8100,  9000, -3240, Pic },
+   { 27090, 27600, -3240, Lup },
+   { 15210, 15900, -3270, Vel },
+   { 11100, 11700, -3300, Car },
+   { 21300, 23100, -3300, Cen },
+   { 25500, 27090, -3300, Lup },
+   { 27090, 27600, -3300, Nor },
+   {  7200,  7800, -3390, Dor },
+   { 15900, 19800, -3390, Vel },
+   { 19800, 20250, -3390, Cen },
+   { 31500, 32400, -3420, Ara },
+   { 32400, 36600, -3420, Tel },
+   { 39600, 42000, -3420, Gru },
+   {  5760,  6300, -3450, Hor },
+   {  9000,  9900, -3450, Pic },
+   { 11700, 12300, -3480, Car },
+   {     0,  2400, -3510, Phe },
+   {  2400,  3900, -3510, Eri },
+   { 42000, 43200, -3510, Phe },
+   {  7800,  8250, -3540, Dor },
+   { 27600, 29557, -3600, Nor },
+   { 36600, 38400, -3600, Ind },
+   {  9900, 10800, -3660, Pic },
+   { 27300, 27600, -3660, Cir },
+   { 29557, 29850, -3660, Ara },
+   { 26850, 27300, -3815, Cir },
+   { 29850, 30150, -3815, Ara },
+   { 10800, 12300, -3840, Pic },
+   { 12300, 16260, -3840, Car },
+   { 20250, 21300, -3840, Cen },
+   { 21300, 23100, -3840, Cru },
+   { 23100, 26160, -3840, Cen },
+   { 24300, 24600, -3900, Cir },
+   { 30150, 30300, -3900, Ara },
+   {  3900,  5760, -4050, Hor },
+   {  5760,  8250, -4050, Ret },
+   { 26550, 26850, -4050, Cir },
+   { 30300, 31500, -4050, Ara },
+   { 31500, 32400, -4050, Pav },
+   { 39600, 42000, -4050, Tuc },
+   {  8250, 11850, -4200, Dor },
+   { 24600, 26550, -4200, Cir },
+   { 26550, 30600, -4200, TrA },
+   {     0,  2400, -4500, Tuc },
+   {  6300,  8250, -4500, Hyi },
+   { 11850, 16260, -4500, Vol },
+   { 16260, 20250, -4500, Car },
+   { 20250, 24600, -4500, Mus },
+   { 32400, 38400, -4500, Pav },
+   { 38400, 42000, -4500, Ind },
+   { 42000, 43200, -4500, Tuc },
+   {  1350,  2400, -4560, Tuc },
+   {     0,  6300, -4950, Hyi },
+   { 13800, 24600, -4950, Cha },
+   { 24600, 32400, -4950, Aps },
+   {  6300, 13800, -5100, Men },
+   {     0, 43200, -5400, Oct }
+};
+
+static short start[] = {
+   355, 352, 343, 340, 332, 320,
+   303, 288, 277, 266, 257, 251,
+   239, 229, 221, 211, 203, 189,
+   177, 163, 149, 136, 124, 104,
+    87,  75,  69,  54,  43,  29,
+    23,  16,  12,   6,   4,   0,   0
+};
+
+
+/*
+======================================================================
+constellation_pick()
+
+Do a constellation pick from RA and Dec.
+
+INPUTS
+   r        right ascension, radians
+   d        declination, radians
+   e        epoch to which r and d precessed, as an mjd
+
+RESULTS
+   Returns an index for the constellation region that the coordinates
+   belong to, or -1 if no constellation pick can be found.
+
+The constellation is identified by linear search.  We look for a
+member of cbound[] whose lower_dec is less than the declination of the
+pick point and whose lower_ra and upper_ra bracket the pick point's
+right ascension.  The data for that cbound[] member describes a sub-
+region belonging to the picked constellation.
+
+In geometric terms, the search amounts to starting at the north pole
+and traveling south on a line of constant right ascension through the
+pick point.  At every declination where a cbound[] member lives, we
+wake up, and if (1) the pick point is now behind us, and (2) the
+cbound[] segment is crossing our path, we know we've hit the edge of
+a constellation subregion that the pick point belongs to.
+
+The cbound[] right ascension and declination values are scaled into
+integers; this conserves storage and makes comparisons faster.  The
+start[] array, which gives starting points in cbound[] for different
+declinations in 5-degree increments, further speeds the search by
+skipping early parts of the list for which we know the search can't
+succeed--geometrically, we start no more than 5 degrees north of the
+pick point, rather than at the north pole.
+
+The data in cbound[] are for epoch 1875.
+======================================================================
+*/
+
+int
+cns_pick(double r, double d, double e)
+{
+   double Mjd;
+   unsigned short ra;
+   short de, i;
+
+   cal_mjd( 1, 1.0, 1875, &Mjd );
+   precess( e, Mjd, &r, &d );
+   ra = ( unsigned short )( radhr( r ) * 1800 );
+   de = ( short )( raddeg( d ) * 60 );
+   if (d < 0.0) --de;
+
+   i = ( de + 5400 ) / 300;
+   if ( i < 0 || i > 36 ) return -1;
+   i = start[ i ];
+
+   for ( ; i < NBOUNDS; i++ )
+      if ( cbound[ i ].lower_dec <= de &&
+           cbound[ i ].upper_ra   > ra &&
+           cbound[ i ].lower_ra  <= ra ) break;
+
+   return ( i == NBOUNDS ) ? -1 : ( int ) cbound[ i ].index;
+}
+
+/* given a constellation id (as from cns_pick()), return pointer to static
+ * storage containg its name in the form "AAA: Name".
+ * return "???: ???" if id is invalid.
+ */
+char *
+cns_name (int id)
+{
+	if (id < 0 || id >= NCNS)
+	    return ("???: ???");
+	return (cns_namemap[id]);
+}
+
+/* return cns_namemap index matching first three chars in abbrev[], else -1.
+ */
+int
+cns_id (char *abbrev)
+{
+	int i;
+
+	for (i = 0; i < NCNS; i++)
+	    if (strncmp (abbrev, cns_namemap[i], 3) == 0)
+		return (i);
+	return (-1);
+}
+
+/* edges of constant ra */
+static struct {
+   unsigned short ra;	/* hours * 1800 */
+   short dec0, dec1;	/* degrees * 60 */
+} ra_edges[] = {
+    {     0, -4950, -4500 },
+    {     0,   600,   750 },
+    {     0,  1680,  1879 },
+    {   120,  1320,  1680 },
+    {   255,   750,  1260 },
+    {   255,  1260,  1320 },
+    {   300,  2760,  2880 },
+    {   599,  -420,     0 },
+    {   599,     0,   120 },
+    {   599,  3960,  4620 },
+    {  1290,  1425,  1980 },
+    {  1350, -4500, -4560 },
+    {  1530,  1260,  1425 },
+    {  1560,  2760,  2880 },
+    {  2010,  2880,  3000 },
+    {  2399, -4560, -3510 },
+    {  2399, -3510, -3210 },
+    {  2460,  3000,  3240 },
+    {  2534,  1680,  1980 },
+    {  2534,  1980,  2100 },
+    {  2849, -3210, -3090 },
+    {  3000, -2400, -1530 },
+    {  3000, -1530, -1462 },
+    {  3000,   595,  1500 },
+    {  3000,  1500,  1680 },
+    {  3000,  2820,  3000 },
+    {  3060,  3240,  3450 },
+    {  3299, -3090, -2890 },
+    {  3434,  3450,  3510 },
+    {  3450,  1500,  1635 },
+    {  3600,   120,   595 },
+    {  3600,  2100,  2205 },
+    {  3675,  2820,  3030 },
+    {  3900, -4050, -3510 },
+    {  3900, -3510, -3240 },
+    {  4199, -2890, -2400 },
+    {  4350, -3240, -3060 },
+    {  4350,  1635,  1840 },
+    {  4379,  3420,  3510 },
+    {  4530,  2205,  3030 },
+    {  4620,  2040,  2205 },
+    {  4770, -1462,  -105 },
+    {  4800, -3060, -2940 },
+    {  4890,  1840,  2040 },
+    {  5400, -2940, -2760 },
+    {  5400, -2400, -2374 },
+    {  5580,  3420,  4080 },
+    {  5700,  3300,  3420 },
+    {  5760, -3450, -4050 },
+    {  5909,  -105,     0 },
+    {  5909,     0,   595 },
+    {  5909,   595,  1140 },
+    {  5999,  3150,  3300 },
+    {  6060,  1140,  1840 },
+    {  6150, -2760, -2640 },
+    {  6150,  4080,  4620 },
+    {  6300, -5100, -4950 },
+    {  6300, -4950, -4500 },
+    {  6300, -3190, -3450 },
+    {  6300, -2374, -2160 },
+    {  6314,  4620,  4800 },
+    {  6449,  -105,     0 },
+    {  6750, -2160, -1462 },
+    {  6899, -3060, -3190 },
+    {  6960, -2640, -2400 },
+    {  7200, -3390, -3190 },
+    {  7349, -2940, -3060 },
+    {  7680, -2400, -2940 },
+    {  7680, -2220, -2400 },
+    {  7799, -3540, -3390 },
+    {  8100, -3240, -2940 },
+    {  8100, -2940, -2790 },
+    {  8100,  1800,  1840 },
+    {  8100,  1840,  2160 },
+    {  8249, -4500, -4200 },
+    {  8249, -4050, -4200 },
+    {  8249, -4050, -3540 },
+    {  8249, -1800, -2220 },
+    {  8310,     0,   930 },
+    {  8400,  -240,     0 },
+    {  8445,  2160,  3150 },
+    {  8460, -1635, -1800 },
+    {  8550,  1710,  1800 },
+    {  8699, -2790, -2580 },
+    {  8699,  -870, -1635 },
+    {  8850,  -660,  -870 },
+    {  8940,   930,   960 },
+    {  9000, -3450, -3240 },
+    {  9000, -2580, -1635 },
+    {  9000,  3150,  3360 },
+    {  9000,  4800,  5100 },
+    {  9149,  -660,  -240 },
+    {  9599,   930,   960 },
+    {  9900, -3660, -3450 },
+    { 10080,   750,   930 },
+    { 10260,  1080,  1369 },
+    { 10380,   750,  1080 },
+    { 10499,  -660,  -240 },
+    { 10589,  1290,  1369 },
+    { 10589,  1369,  1680 },
+    { 10589,  1680,  1710 },
+    { 10800, -3840, -3660 },
+    { 10800, -3150, -3045 },
+    { 10800, -3045, -2580 },
+    { 10980,  3240,  3360 },
+    { 10980,  3360,  3720 },
+    { 11010, -1980, -1635 },
+    { 11010, -1635,  -660 },
+    { 11100, -3300, -3150 },
+    { 11190,  1050,  1290 },
+    { 11235,  -240,     0 },
+    { 11235,     0,   600 },
+    { 11354,   600,   720 },
+    { 11354,   720,  1050 },
+    { 11700, -3480, -3300 },
+    { 11700,  3000,  3240 },
+    { 11759,  1680,  2130 },
+    { 11849, -4200, -4500 },
+    { 11849, -4200, -3840 },
+    { 11849, -1980, -2580 },
+    { 12240,  2670,  3000 },
+    { 12299, -3840, -3480 },
+    { 12479,   600,   720 },
+    { 12600,   330,   600 },
+    { 12600,   600,   750 },
+    { 12600,  3600,  3720 },
+    { 12630,    90,   330 },
+    { 12960,     0,    90 },
+    { 13260,  -660, -1980 },
+    { 13260,  2130,  2670 },
+    { 13500,   750,   810 },
+    { 13800, -5100, -4950 },
+    { 13800, -4500, -4950 },
+    { 13950,  2010,  2130 },
+    { 14054,   600,   810 },
+    { 14054,   810,  1200 },
+    { 14189,  1200,  1680 },
+    { 14265,   420,   600 },
+    { 14340,  3600,  4410 },
+    { 14400, -3045, -2580 },
+    { 14400,  1680,  2010 },
+    { 14400,  5100,  5190 },
+    { 14400,  5280,  5190 },
+    { 14549,  -660,     0 },
+    { 14549,     0,   420 },
+    { 14700, -3180, -3045 },
+    { 15060, -2580, -2205 },
+    { 15060, -2205, -1020 },
+    { 15060, -1020,  -660 },
+    { 15150,  2820,  3600 },
+    { 15209, -3270, -3180 },
+    { 15449, -1140, -1020 },
+    { 15899, -3390, -3270 },
+    { 16259, -4500, -3840 },
+    { 16349, -1440, -1140 },
+    { 16500,  2520,  2820 },
+    { 16500,  4410,  4920 },
+    { 16650,   420,  2010 },
+    { 16650,  2010,  2385 },
+    { 16860, -2385, -2205 },
+    { 16860, -1440, -2205 },
+    { 17249,  -660,     0 },
+    { 17249,     0,   420 },
+    { 17249,  2385,  2520 },
+    { 17550, -1590, -1440 },
+    { 17789,  1710,  2010 },
+    { 18300,  2400,  2520 },
+    { 18450, -1750, -1590 },
+    { 18900,  1410,  1710 },
+    { 19049, -1870, -1750 },
+    { 19200,  4800,  4920 },
+    { 19350,  -660, -1140 },
+    { 19350,  -360,  -660 },
+    { 19350,  -360,     0 },
+    { 19350,     0,   420 },
+    { 19350,  1410,  1530 },
+    { 19409,  2040,  2400 },
+    { 19499, -2100, -1870 },
+    { 19499, -1140, -1470 },
+    { 19800, -3390, -2385 },
+    { 19800, -2385, -2100 },
+    { 19800,  1530,  1740 },
+    { 19800,  1740,  2040 },
+    { 20250, -4500, -3840 },
+    { 20250, -3840, -3390 },
+    { 20399,  3990,  4410 },
+    { 20700,  4620,  4800 },
+    { 20730,  -360,     0 },
+    { 20730,     0,   660 },
+    { 21299, -3840, -3300 },
+    { 21299, -1470,  -660 },
+    { 21299,  -660,  -360 },
+    { 21360,   660,   840 },
+    { 21360,   840,  1740 },
+    { 21600,  1740,  2040 },
+    { 21600,  2040,  2700 },
+    { 21600,  3840,  3990 },
+    { 21749,  2700,  3180 },
+    { 22050, -1980, -2100 },
+    { 22199,  1920,  2040 },
+    { 22649, -1770, -1980 },
+    { 22649, -1470, -1320 },
+    { 23099, -3840, -3300 },
+    { 23099, -1320,  -660 },
+    { 23099,   840,   900 },
+    { 23400,  4620,  4200 },
+    { 23850,  1710,  1920 },
+    { 24300, -3900, -3840 },
+    { 24300,   480,   900 },
+    { 24300,   900,  1710 },
+    { 24300,  2910,  3180 },
+    { 24300,  3780,  3840 },
+    { 24449,  4800,  4620 },
+    { 24600, -4950, -4500 },
+    { 24600, -4500, -4200 },
+    { 24600, -4200, -3900 },
+    { 25124,  1710,  1845 },
+    { 25200,  4200,  3960 },
+    { 25259,  1845,  2910 },
+    { 25259,  2910,  3330 },
+    { 25500, -3300, -2520 },
+    { 25650, -1320, -1470 },
+    { 25650,  -480, -1320 },
+    { 25950,  3330,  3780 },
+    { 26100,  5190,  4800 },
+    { 26159, -3840, -3300 },
+    { 26400,     0,  -480 },
+    { 26550, -4200, -4050 },
+    { 26850, -4050, -3814 },
+    { 26850, -2520, -1770 },
+    { 26850, -1470, -1770 },
+    { 27090, -3300, -3240 },
+    { 27149,  -195,     0 },
+    { 27149,     0,   480 },
+    { 27149,   480,  1560 },
+    { 27300, -3814, -3660 },
+    { 27329,  1560,  1980 },
+    { 27450,  3180,  3330 },
+    { 27599, -3660, -3600 },
+    { 27599, -3600, -3300 },
+    { 27599, -3240, -2880 },
+    { 27779,  1980,  2400 },
+    { 28200, -2880, -2520 },
+    { 28200, -1770, -1200 },
+    { 28200,  3960,  4200 },
+    { 28350,  2400,  3090 },
+    { 28350,  3090,  3180 },
+    { 28650, -1200,  -480 },
+    { 28650,  -480,  -195 },
+    { 28650,   960,  1320 },
+    { 28800, -2520, -1770 },
+    { 28859,  1320,  1560 },
+    { 28949,   240,   960 },
+    { 29100,  1560,  1620 },
+    { 29280, -1474, -1155 },
+    { 29280, -1095,  -480 },
+    { 29280,  -195,     0 },
+    { 29280,     0,   240 },
+    { 29399,  1620,  2400 },
+    { 29475, -1155, -1095 },
+    { 29557, -3660, -3600 },
+    { 29557, -3600, -2730 },
+    { 29557, -2730, -2520 },
+    { 29759,  4200,  4500 },
+    { 29849, -3814, -3660 },
+    { 30150, -3900, -3814 },
+    { 30150, -1800, -1474 },
+    { 30150,   240,   769 },
+    { 30299, -4050, -3900 },
+    { 30600, -4050, -4200 },
+    { 30600,  3030,  3090 },
+    { 30900,  -960,  -600 },
+    { 31050,   769,   859 },
+    { 31500, -3420, -4050 },
+    { 31500,  4500,  4800 },
+    { 31649,  -700,  -600 },
+    { 31680,  -960, -1800 },
+    { 31800,  -700,  -600 },
+    { 32099, -2730, -2220 },
+    { 32099, -1800, -2220 },
+    { 32099,  -240,     0 },
+    { 32340,  -600,  -240 },
+    { 32400, -4950, -4500 },
+    { 32400, -4500, -4050 },
+    { 32400, -2730, -3420 },
+    { 32400,  4800,  5160 },
+    { 32715,  1800,  2850 },
+    { 32819,  2850,  3030 },
+    { 32850,  -240,  -960 },
+    { 32850,     0,   180 },
+    { 32850,   270,   375 },
+    { 32850,   720,   859 },
+    { 33060,  1560,  1800 },
+    { 33165,   180,   270 },
+    { 33449,  -240,     0 },
+    { 33449,     0,   120 },
+    { 33591,   375,   720 },
+    { 33960,  -960,  -721 },
+    { 33960,  -721,  -240 },
+    { 33960,   120,   375 },
+    { 33960,   720,  1110 },
+    { 33960,  1110,  1264 },
+    { 33960,  1264,  1530 },
+    { 33960,  1530,  1560 },
+    { 34200,   970,  1110 },
+    { 34349,  2850,  3330 },
+    { 34500, -2220, -2730 },
+    { 34500,  2610,  2850 },
+    { 34650,  1150,  1264 },
+    { 34664,  1530,  1650 },
+    { 34664,  1650,  1800 },
+    { 34844,  1800,  2190 },
+    { 34920,  2190,  2610 },
+    { 34950,  3330,  3480 },
+    { 35400,  1650,  1740 },
+    { 35580,  3480,  3570 },
+    { 35699,   945,   970 },
+    { 35699,  1150,  1275 },
+    { 36000, -1680,  -721 },
+    { 36000,  -540,  -721 },
+    { 36000,  3570,  3690 },
+    { 36255,   510,   945 },
+    { 36300,  4500,  4800 },
+    { 36450,   945,  1230 },
+    { 36450,  1230,  1275 },
+    { 36540,   120,   510 },
+    { 36599, -3600, -3420 },
+    { 36599, -3420, -2730 },
+    { 36599, -2730, -1680 },
+    { 36750,  3690,  4020 },
+    { 36959,  -900,  -540 },
+    { 36959,  -540,     0 },
+    { 36959,     0,   120 },
+    { 36966,  3570,  3655 },
+    { 37020,  1170,  1230 },
+    { 37080,  3289,  3655 },
+    { 37200,  4020,  4500 },
+    { 37499,   120,   360 },
+    { 37575,   360,   709 },
+    { 37650,  1680,  1740 },
+    { 37800,  4800,  5160 },
+    { 37800,  5160,  5169 },
+    { 37890,   709,  1170 },
+    { 38010,   709,   750 },
+    { 38250,  1170,  1410 },
+    { 38399, -4500, -3600 },
+    { 38399, -3000, -2730 },
+    { 38399, -2220, -2730 },
+    { 38399, -1680, -2220 },
+    { 38399, -1680, -1530 },
+    { 38399,  -540,  -900 },
+    { 38399,   120,   750 },
+    { 38550,  1410,  1680 },
+    { 38640,   120,   165 },
+    { 39000,   105,   165 },
+    { 39119,  1680,  2160 },
+    { 39360, -1530,  -540 },
+    { 39375,  2160,  2625 },
+    { 39434,  2625,  2640 },
+    { 39540,  2640,  3165 },
+    { 39540,  3165,  3289 },
+    { 39600, -4050, -3420 },
+    { 39600, -3420, -3000 },
+    { 39600,   105,   120 },
+    { 39600,  2100,  2160 },
+    { 39839,  3165,  3300 },
+    { 40170,  3300,  3375 },
+    { 40950,  -240,     0 },
+    { 40950,     0,   120 },
+    { 40950,   120,   450 },
+    { 41070,  2070,  2100 },
+    { 41160,  2070,  3150 },
+    { 41160,  3150,  3375 },
+    { 41160,  3375,  3544 },
+    { 41400, -2220, -1530 },
+    { 41400,  5169,  5280 },
+    { 41700,  3544,  3780 },
+    { 41999, -4500, -4050 },
+    { 41999, -3510, -3420 },
+    { 41999, -3420, -2400 },
+    { 41999, -2400, -2220 },
+    { 41999,  3000,  3150 },
+    { 42300,  1924,  2070 },
+    { 42449,  2880,  3000 },
+    { 42449,  3780,  3960 },
+    { 42750,  1879,  1924 },
+    { 42899, -1530,  -420 },
+    { 42899,  -420,  -240 },
+    { 42899,   450,   600 },
+};
+
+#define	NRA	((int)(sizeof(ra_edges)/sizeof(ra_edges[0])))
+
+/* edges of constant dec */
+static struct {
+   short dec;			/* degrees * 60 */
+   unsigned short ra0, ra1;	/* hours * 1800 */
+} dec_edges[] = {
+    { -5100,  6300, 13800 },
+    { -4950,     0,  6300 },
+    { -4950, 13800, 24600 },
+    { -4950, 24600, 32400 },
+    { -4560,  1350,  2399 },
+    { -4500,     0,  1350 },
+    { -4500,  6300,  8249 },
+    { -4500, 11849, 13800 },
+    { -4500, 13800, 16259 },
+    { -4500, 16259, 20250 },
+    { -4500, 20250, 24600 },
+    { -4500, 32400, 38399 },
+    { -4500, 38399, 41999 },
+    { -4500, 41999,     0 },
+    { -4200,  8249, 11849 },
+    { -4200, 24600, 26550 },
+    { -4200, 30600, 26550 },
+    { -4050,  3900,  5760 },
+    { -4050,  5760,  8249 },
+    { -4050, 26550, 26850 },
+    { -4050, 30299, 30600 },
+    { -4050, 31500, 30600 },
+    { -4050, 31500, 32400 },
+    { -4050, 39600, 41999 },
+    { -3900, 24300, 24600 },
+    { -3900, 30150, 30299 },
+    { -3840, 10800, 11849 },
+    { -3840, 11849, 12299 },
+    { -3840, 12299, 16259 },
+    { -3840, 20250, 21299 },
+    { -3840, 21299, 23099 },
+    { -3840, 23099, 24300 },
+    { -3840, 24300, 26159 },
+    { -3814, 26850, 27300 },
+    { -3814, 29849, 30150 },
+    { -3660,  9900, 10800 },
+    { -3660, 27300, 27599 },
+    { -3660, 29557, 29849 },
+    { -3600, 27599, 29557 },
+    { -3600, 36599, 38399 },
+    { -3540,  7799,  8249 },
+    { -3510,  2399,  3900 },
+    { -3510,  2399, 41999 },
+    { -3510,  3900,  2399 },
+    { -3510, 41999,  2399 },
+    { -3480, 11700, 12299 },
+    { -3450,  6300,  5760 },
+    { -3450,  9000,  9900 },
+    { -3420, 32400, 31500 },
+    { -3420, 32400, 36599 },
+    { -3420, 39600, 41999 },
+    { -3390,  7200,  7799 },
+    { -3390, 15899, 19800 },
+    { -3390, 19800, 20250 },
+    { -3300, 11100, 11700 },
+    { -3300, 21299, 23099 },
+    { -3300, 25500, 26159 },
+    { -3300, 26159, 27090 },
+    { -3300, 27090, 27599 },
+    { -3270, 15209, 15899 },
+    { -3240,  3900,  4350 },
+    { -3240,  8100,  9000 },
+    { -3240, 27090, 27599 },
+    { -3210,  2399,  2849 },
+    { -3190,  6899,  6300 },
+    { -3190,  6899,  7200 },
+    { -3180, 14700, 15209 },
+    { -3150, 10800, 11100 },
+    { -3090,  2849,  3299 },
+    { -3060,  4350,  4800 },
+    { -3060,  7349,  6899 },
+    { -3045, 10800, 14400 },
+    { -3045, 14400, 14700 },
+    { -3000, 38399, 39600 },
+    { -2940,  4800,  5400 },
+    { -2940,  7680,  7349 },
+    { -2940,  7680,  8100 },
+    { -2890,  3299,  4199 },
+    { -2880, 27599, 28200 },
+    { -2790,  8100,  8699 },
+    { -2760,  5400,  6150 },
+    { -2730, 29557, 32099 },
+    { -2730, 32099, 32400 },
+    { -2730, 34500, 32400 },
+    { -2730, 34500, 36599 },
+    { -2730, 38399, 36599 },
+    { -2640,  6150,  6960 },
+    { -2580,  8699,  9000 },
+    { -2580, 10800,  9000 },
+    { -2580, 11849, 10800 },
+    { -2580, 14400, 15060 },
+    { -2520, 25500, 26850 },
+    { -2520, 28200, 28800 },
+    { -2520, 29557, 28800 },
+    { -2400,  3000, 41999 },
+    { -2400,  4199,  3000 },
+    { -2400,  4199,  5400 },
+    { -2400,  6960,  7680 },
+    { -2385, 16860, 19800 },
+    { -2374,  5400,  6300 },
+    { -2220,  8249,  7680 },
+    { -2220, 32099, 34500 },
+    { -2220, 38399, 41400 },
+    { -2220, 41999, 41400 },
+    { -2205, 16860, 15060 },
+    { -2160,  6300,  6750 },
+    { -2100, 19800, 19499 },
+    { -2100, 22050, 19800 },
+    { -1980, 11010, 11849 },
+    { -1980, 13260, 11849 },
+    { -1980, 22649, 22050 },
+    { -1870, 19499, 19049 },
+    { -1800,  8460,  8249 },
+    { -1800, 30150, 31680 },
+    { -1800, 31680, 32099 },
+    { -1770, 26850, 22649 },
+    { -1770, 26850, 28200 },
+    { -1770, 28800, 28200 },
+    { -1750, 19049, 18450 },
+    { -1680, 36000, 36599 },
+    { -1680, 36599, 38399 },
+    { -1635,  8699,  8460 },
+    { -1635,  8699,  9000 },
+    { -1635,  9000, 11010 },
+    { -1590, 18450, 17550 },
+    { -1530,  3000, 42899 },
+    { -1530, 38399, 39360 },
+    { -1530, 41400, 39360 },
+    { -1530, 41400, 42899 },
+    { -1530, 42899,  3000 },
+    { -1530, 42899, 41400 },
+    { -1474, 29280, 30150 },
+    { -1470, 19499, 21299 },
+    { -1470, 21299, 22649 },
+    { -1470, 25650, 26850 },
+    { -1462,  3000,  4770 },
+    { -1462,  4770,  6750 },
+    { -1440, 16349, 16860 },
+    { -1440, 17550, 16860 },
+    { -1320, 22649, 23099 },
+    { -1320, 23099, 25650 },
+    { -1200, 28200, 28650 },
+    { -1155, 29280, 29475 },
+    { -1140, 15449, 16349 },
+    { -1140, 19350, 19499 },
+    { -1095, 29280, 29475 },
+    { -1020, 15060, 15449 },
+    {  -960, 30900, 31680 },
+    {  -960, 32850, 31680 },
+    {  -960, 32850, 33960 },
+    {  -900, 38399, 36959 },
+    {  -870,  8850,  8699 },
+    {  -721, 36000, 33960 },
+    {  -700, 31649, 31800 },
+    {  -660,  9149,  8850 },
+    {  -660, 10499,  9149 },
+    {  -660, 11010, 10499 },
+    {  -660, 11010, 13260 },
+    {  -660, 14549, 13260 },
+    {  -660, 15060, 14549 },
+    {  -660, 17249, 19350 },
+    {  -660, 23099, 21299 },
+    {  -600, 30900, 31649 },
+    {  -600, 31800, 32340 },
+    {  -540, 36959, 36000 },
+    {  -540, 39360, 38399 },
+    {  -480, 26400, 25650 },
+    {  -480, 28650, 29280 },
+    {  -420,   599, 42899 },
+    {  -360, 20730, 19350 },
+    {  -360, 21299, 20730 },
+    {  -240,  8400,  9149 },
+    {  -240, 10499, 11235 },
+    {  -240, 32099, 32340 },
+    {  -240, 33449, 32850 },
+    {  -240, 33960, 33449 },
+    {  -240, 40950, 42899 },
+    {  -195, 28650, 27149 },
+    {  -195, 28650, 29280 },
+    {  -105,  4770,  5909 },
+    {  -105,  5909,  6449 },
+    {     0,  6449,  8310 },
+    {     0,  8310,  8400 },
+    {     0, 12960, 14549 },
+    {     0, 27149, 26400 },
+    {     0, 32099, 32850 },
+    {    90, 12630, 12960 },
+    {   105, 39000, 39600 },
+    {   120,   599,  3600 },
+    {   120, 33449, 33960 },
+    {   120, 36540, 36959 },
+    {   120, 36959, 37499 },
+    {   120, 37499, 38399 },
+    {   120, 38399, 38640 },
+    {   120, 39600, 40950 },
+    {   165, 38640, 39000 },
+    {   180, 32850, 33165 },
+    {   240, 28949, 29280 },
+    {   240, 29280, 30150 },
+    {   270, 33165, 32850 },
+    {   330, 12600, 12630 },
+    {   360, 37499, 37575 },
+    {   375, 32850, 33591 },
+    {   375, 33591, 33960 },
+    {   420, 14265, 14549 },
+    {   420, 14549, 16650 },
+    {   420, 16650, 17249 },
+    {   420, 17249, 19350 },
+    {   450, 40950, 42899 },
+    {   480, 24300, 27149 },
+    {   510, 36255, 36540 },
+    {   595,  3000,  3600 },
+    {   595,  3600,  5909 },
+    {   600,     0, 42899 },
+    {   600, 11235, 11354 },
+    {   600, 12479, 12600 },
+    {   600, 14054, 14265 },
+    {   600, 42899,     0 },
+    {   660, 20730, 21360 },
+    {   709, 37575, 37890 },
+    {   709, 37890, 38010 },
+    {   720, 11354, 12479 },
+    {   720, 32850, 33591 },
+    {   720, 33591, 33960 },
+    {   750,     0,   255 },
+    {   750, 10080, 10380 },
+    {   750, 12600, 13500 },
+    {   750, 38010, 38399 },
+    {   769, 30150, 31050 },
+    {   810, 13500, 14054 },
+    {   840, 21360, 23099 },
+    {   859, 31050, 32850 },
+    {   900, 23099, 24300 },
+    {   930,  8310,  8940 },
+    {   930,  9599, 10080 },
+    {   945, 35699, 36255 },
+    {   945, 36255, 36450 },
+    {   960,  8940,  9599 },
+    {   960, 28650, 28949 },
+    {   970, 34200, 35699 },
+    {  1050, 11190, 11354 },
+    {  1080, 10260, 10380 },
+    {  1110, 33960, 34200 },
+    {  1140,  5909,  6060 },
+    {  1150, 34650, 35699 },
+    {  1170, 37020, 37890 },
+    {  1170, 37890, 38250 },
+    {  1200, 14054, 14189 },
+    {  1230, 36450, 37020 },
+    {  1260,   255,  1530 },
+    {  1264, 33960, 34650 },
+    {  1275, 35699, 36450 },
+    {  1290, 10589, 11190 },
+    {  1320,   120,   255 },
+    {  1320, 28650, 28859 },
+    {  1369, 10260, 10589 },
+    {  1410, 18900, 19350 },
+    {  1410, 38250, 38550 },
+    {  1425,  1290,  1530 },
+    {  1500,  3000,  3450 },
+    {  1530, 19350, 19800 },
+    {  1530, 33960, 34664 },
+    {  1560, 27149, 27329 },
+    {  1560, 27329, 28859 },
+    {  1560, 28859, 29100 },
+    {  1560, 33060, 33960 },
+    {  1620, 29100, 29399 },
+    {  1635,  3450,  4350 },
+    {  1650, 34664, 35400 },
+    {  1680,     0,   120 },
+    {  1680,  2534,  3000 },
+    {  1680, 10589, 11759 },
+    {  1680, 14189, 14400 },
+    {  1680, 37650, 38550 },
+    {  1680, 38550, 39119 },
+    {  1710,  8550, 10589 },
+    {  1710, 17789, 18900 },
+    {  1710, 23850, 24300 },
+    {  1710, 24300, 25124 },
+    {  1740, 19800, 21360 },
+    {  1740, 21360, 21600 },
+    {  1740, 35400, 37650 },
+    {  1800,  8100,  8550 },
+    {  1800, 32715, 33060 },
+    {  1800, 34664, 34844 },
+    {  1840,  4350,  4890 },
+    {  1840,  4890,  6060 },
+    {  1840,  6060,  8100 },
+    {  1845, 25124, 25259 },
+    {  1879,     0, 42750 },
+    {  1920, 22199, 23850 },
+    {  1924, 42300, 42750 },
+    {  1980,  1290,  2534 },
+    {  1980, 27329, 27779 },
+    {  2010, 13950, 14400 },
+    {  2010, 14400, 16650 },
+    {  2010, 16650, 17789 },
+    {  2040,  4620,  4890 },
+    {  2040, 19409, 19800 },
+    {  2040, 21600, 22199 },
+    {  2070, 41070, 41160 },
+    {  2070, 41160, 42300 },
+    {  2100,  2534,  3600 },
+    {  2100, 39600, 41070 },
+    {  2130, 11759, 13260 },
+    {  2130, 13260, 13950 },
+    {  2160,  8100,  8445 },
+    {  2160, 39119, 39375 },
+    {  2160, 39375, 39600 },
+    {  2190, 34844, 34920 },
+    {  2205,  3600,  4530 },
+    {  2205,  4530,  4620 },
+    {  2385, 16650, 17249 },
+    {  2400, 18300, 19409 },
+    {  2400, 27779, 28350 },
+    {  2400, 28350, 29399 },
+    {  2520, 16500, 17249 },
+    {  2520, 17249, 18300 },
+    {  2610, 34500, 34920 },
+    {  2625, 39375, 39434 },
+    {  2640, 39434, 39540 },
+    {  2670, 12240, 13260 },
+    {  2700, 21600, 21749 },
+    {  2760,   300,  1560 },
+    {  2820,  3000,  3675 },
+    {  2820, 15150, 16500 },
+    {  2850, 32715, 32819 },
+    {  2850, 32819, 34349 },
+    {  2850, 34349, 34500 },
+    {  2880,   300, 42449 },
+    {  2880,  1560,  2010 },
+    {  2880, 42449,   300 },
+    {  2910, 24300, 25259 },
+    {  3000,  2010,  2460 },
+    {  3000,  2460,  3000 },
+    {  3000, 11700, 12240 },
+    {  3000, 41999, 42449 },
+    {  3030,  3675,  4530 },
+    {  3030, 30600, 32819 },
+    {  3090, 28350, 30600 },
+    {  3150,  5999,  8445 },
+    {  3150,  8445,  9000 },
+    {  3150, 41160, 41999 },
+    {  3165, 39540, 39839 },
+    {  3180, 21749, 24300 },
+    {  3180, 27450, 28350 },
+    {  3240,  2460,  3060 },
+    {  3240, 10980, 11700 },
+    {  3289, 37080, 39540 },
+    {  3300,  5700,  5999 },
+    {  3300, 39839, 40170 },
+    {  3330, 25259, 25950 },
+    {  3330, 25950, 27450 },
+    {  3330, 34349, 34950 },
+    {  3360,  9000, 10980 },
+    {  3375, 40170, 41160 },
+    {  3420,  4379,  5580 },
+    {  3420,  5580,  5700 },
+    {  3450,  3060,  3434 },
+    {  3480, 34950, 35580 },
+    {  3510,  3434,  4379 },
+    {  3544, 41160, 41700 },
+    {  3570, 35580, 36000 },
+    {  3570, 36000, 36966 },
+    {  3600, 12600, 14340 },
+    {  3600, 14340, 15150 },
+    {  3655, 36966, 37080 },
+    {  3690, 36000, 36750 },
+    {  3720, 10980, 12600 },
+    {  3780, 24300, 25950 },
+    {  3780, 41700, 42449 },
+    {  3840, 21600, 24300 },
+    {  3960,   599, 42449 },
+    {  3960, 25200, 28200 },
+    {  3960, 42449,   599 },
+    {  3990, 20399, 21600 },
+    {  4020, 36750, 37200 },
+    {  4080,  5580,  6150 },
+    {  4200, 23400, 25200 },
+    {  4200, 28200, 29759 },
+    {  4410, 14340, 16500 },
+    {  4410, 16500, 20399 },
+    {  4500, 29759, 31500 },
+    {  4500, 36300, 37200 },
+    {  4620,   599,  6150 },
+    {  4620,  6150,  6314 },
+    {  4620, 20700, 23400 },
+    {  4620, 24449, 23400 },
+    {  4800,  6314,  9000 },
+    {  4800, 19200, 20700 },
+    {  4800, 26100, 24449 },
+    {  4800, 31500, 32400 },
+    {  4800, 36300, 37800 },
+    {  4920, 16500, 19200 },
+    {  5100,  9000, 14400 },
+    {  5160, 32400, 37800 },
+    {  5169, 37800, 41400 },
+    {  5190, 14400, 26100 },
+    {  5280,  6300, 14400 },
+    {  5280, 41400,  6300 },
+};
+
+#define	NDEC	((int)(sizeof(dec_edges)/sizeof(dec_edges[0])))
+
+/* given an epoch, give caller a list of all constellation edges.
+ * return count if ok, else -1.
+ * N.B. caller should *not* free what we return because we cache it here.
+ */
+int
+cns_edges (double e, double **ra0p, double **dec0p, double **ra1p,
+double **dec1p)
+{
+#define	NEDGES	(NRA+NDEC)
+	static double *ra0, *dec0, *ra1, *dec1;
+	static double laste = -12345.6;		/* any bogus value */
+	double mjd0;
+	int i, n;
+
+	/* if same epoch just return the same list */
+	if (e == laste) {
+	    *ra0p = ra0;
+	    *dec0p = dec0;
+	    *ra1p = ra1;
+	    *dec1p = dec1;
+	    return (NEDGES);
+	}
+
+	/* get space for arrays, first time only */
+	if (!ra0) {
+	    ra0 = (double *)malloc (NEDGES * sizeof(double));
+	    if (!ra0)
+		return (-1);
+	    dec0 = (double *)malloc (NEDGES * sizeof(double));
+	    if (!dec0) {
+		free ((void *)ra0);
+		return (-1);
+	    }
+	    ra1 = (double *)malloc (NEDGES * sizeof(double));
+	    if (!ra1) {
+		free ((void *)ra0);
+		free ((void *)dec0);
+		return (-1);
+	    }
+	    dec1 = (double *)malloc (NEDGES * sizeof(double));
+	    if (!dec1) {
+		free ((void *)ra0);
+		free ((void *)dec0);
+		free ((void *)ra1);
+		return (-1);
+	    }
+	}
+
+	/* prepare for precession from 1875 */
+	cal_mjd (1, 1.0, 1875, &mjd0);
+
+	/* build the constant-ra edge lists */
+	n = 0;
+	for (i = 0; i < NRA; i++) {
+	    ra0[n] = ra1[n] = hrrad((double)ra_edges[i].ra/1800.0);
+	    dec0[n] = degrad((double)ra_edges[i].dec0/60.0);
+	    dec1[n] = degrad((double)ra_edges[i].dec1/60.0);
+	    precess (mjd0, e, &ra0[n], &dec0[n]);
+	    precess (mjd0, e, &ra1[n], &dec1[n]);
+	    n++;
+	}
+
+	/* add the constant-dec edge lists */
+	for (i = 0; i < NDEC; i++) {
+	    ra0[n] = hrrad((double)dec_edges[i].ra0/1800.0);
+	    ra1[n] = hrrad((double)dec_edges[i].ra1/1800.0);
+	    dec0[n] = dec1[n] = degrad((double)dec_edges[i].dec/60.0);
+	    precess (mjd0, e, &ra0[n], &dec0[n]);
+	    precess (mjd0, e, &ra1[n], &dec1[n]);
+	    n++;
+	}
+
+	/* sanity check the count */
+	if (n != NEDGES) {
+	    printf ("cns_edges(): n=%d NEDGES=%ld\n", n, (long)NEDGES);
+	    abort();
+	}
+	
+	/* ok */
+	*ra0p = ra0;
+	*dec0p = dec0;
+	*ra1p = ra1;
+	*dec1p = dec1;
+	laste = e;
+	return (NEDGES);
+}
+
+/* given an ra, dec and epoch return the list of constellation ids which
+ * *may* fall within the given radius of said location.
+ * return the number of ids.
+ * ids[] need be no larger than 89.
+ */
+/* ARGSUSED */
+int
+cns_list (double ra, double dec, double e, double rad, int ids[])
+{
+	int i;
+
+	/* TODO: this! */
+	for (i = 0; i < NCNS; i++)
+	    ids[i] = i;
+	return (NCNS);
+}
+
+/* epoch 2000 RA/Dec of constellation figure end-points.
+ * drawcodes: 0=move to; 1=draw to; 2=draw to dashed; 3=end
+ */
+typedef struct {
+    short drawcode;
+    unsigned short ra;	/* hours * 1800 */
+    short dec;		/* degrees * 60 */
+} ConFig;
+
+/* Andromeda */
+static ConFig _Andromeda_figs[] = {
+    { 0,  3717,  2539},		/* move gamma 1 */
+    { 1,  2091,  2137},		/* draw beta */
+    { 1,  1179,  1851},		/* draw delta */
+    { 1,   251,  1745},		/* draw alpha */
+    { 0,  1716,  1405},		/* move eta */
+    { 1,  1420,  1456},		/* draw zeta */
+    { 1,  1156,  1758},		/* draw epsilon */
+    { 1,  1179,  1851},		/* draw delta */
+    { 1,  1106,  2023},		/* draw pi */
+    { 1,   512,  2320},		/* draw theta */
+    { 1, 42544,  2596},		/* draw iota */
+    { 1, 42612,  2660},		/* draw kappa */
+    { 1, 42526,  2787},		/* draw lambda */
+    { 0, 42544,  2596},		/* move iota */
+    { 1, 41457,  2539},		/* draw omicron */
+    { 0,  1106,  2023},		/* move pi */
+    { 1,  2091,  2137},		/* draw beta */
+    { 1,  1702,  2309},		/* draw mu */
+    { 1,  1494,  2464},		/* draw nu */
+    { 1,  2085,  2834},		/* draw phi */
+    { 1,  2939,  2917},		/* draw 51 */
+    {-1,     0,     0},
+};
+
+/* Antlia */
+static ConFig _Antlia_figs[] = {
+    { 0, 17077, -2157},		/* move epsilon */
+    { 2, 18814, -1864},		/* dotted alpha */
+    { 2, 19701, -2228},		/* dotted iota */
+    {-1,     0,     0},
+};
+
+/* Apus */
+static ConFig _Apus_figs[] = {
+    { 0, 26635, -4742},		/* move alpha */
+    { 2, 29803, -4733},		/* dotted gamma */
+    { 2, 30092, -4651},		/* dotted beta */
+    { 2, 29410, -4721},		/* dotted delta 1 */
+    { 2, 29803, -4733},		/* dotted gamma */
+    {-1,     0,     0},
+};
+
+/* Aquarius */
+static ConFig _Aquarius_figs[] = {
+    { 0, 37430,  -569},		/* move epsilon */
+    { 1, 38746,  -334},		/* draw beta */
+    { 1, 39773,   -19},		/* draw alpha */
+    { 1, 40249,   -83},		/* draw gamma */
+    { 1, 40464,    -1},		/* draw zeta 1 */
+    { 1, 40358,    82},		/* draw pi */
+    { 1, 39773,   -19},		/* draw alpha */
+    { 0, 40464,    -1},		/* move zeta 1 */
+    { 1, 40660,    -7},		/* draw eta */
+    { 0, 38746,  -334},		/* move beta */
+    { 1, 39793,  -832},		/* draw iota */
+    { 0, 39773,   -19},		/* move alpha */
+    { 1, 40105,  -467},		/* draw theta */
+    { 1, 41178,  -454},		/* draw lambda */
+    { 1, 41829,  -362},		/* draw phi */
+    { 1, 41937,  -550},		/* draw psi 2 */
+    { 1, 41239,  -949},		/* draw delta */
+    { 1, 41087,  -815},		/* draw tau 2 */
+    { 1, 41178,  -454},		/* draw lambda */
+    { 0, 42089, -1206},		/* move 98 */
+    { 1, 41937,  -550},		/* draw psi 2 */
+    { 1, 41683, -1270},		/* draw 88 */
+    {-1,     0,     0},
+};
+
+/* Aquila */
+static ConFig _Aquila_figs[] = {
+    { 0, 35859,   384},		/* move beta */
+    { 1, 35723,   532},		/* draw alpha */
+    { 1, 35587,   636},		/* draw gamma */
+    { 1, 34964,   186},		/* draw delta */
+    { 1, 34387,  -292},		/* draw lambda */
+    { 1, 34362,   831},		/* draw zeta */
+    { 1, 34964,   186},		/* draw delta */
+    { 1, 35774,    60},		/* draw eta */
+    { 1, 36339,   -49},		/* draw theta */
+    { 1, 35301,   -77},		/* draw iota */
+    { 1, 34387,  -292},		/* draw lambda */
+    {-1,     0,     0},
+};
+
+/* Ara */
+static ConFig _Ara_figs[] = {
+    { 0, 31811, -2964},		/* move lambda */
+    { 1, 31555, -2992},		/* draw alpha */
+    { 1, 31359, -3331},		/* draw beta */
+    { 1, 31361, -3382},		/* draw gamma */
+    { 1, 31532, -3641},		/* draw delta */
+    { 1, 30293, -3542},		/* draw eta */
+    { 1, 30558, -3359},		/* draw zeta */
+    { 1, 30587, -3189},		/* draw epsilon 1 */
+    { 1, 31555, -2992},		/* draw alpha */
+    {-1,     0,     0},
+};
+
+/* Aries */
+static ConFig _Aries_figs[] = {
+    { 0,  3405,  1157},		/* move gamma */
+    { 1,  3439,  1248},		/* draw beta */
+    { 1,  3815,  1407},		/* draw alpha */
+    { 1,  5099,  1635},		/* draw 41 */
+    {-1,     0,     0},
+};
+
+/* Auriga */
+static ConFig _Auriga_figs[] = {
+    { 0,  9500,  2759},		/* move capella */
+    { 1, 10785,  2696},		/* draw beta */
+    { 1, 10791,  2232},		/* draw theta */
+    { 1,  9788,  1716},		/* draw beta tau */
+    { 1,  8909,  1989},		/* draw iota */
+    { 1,  9500,  2759},		/* draw capella */
+    { 1, 10785,  3257},		/* draw delta */
+    { 1, 10785,  2696},		/* draw beta */
+    { 0,  9500,  2759},		/* move capella */
+    { 1,  9059,  2629},		/* draw epsilon */
+    { 1,  9074,  2464},		/* draw zeta */
+    {-1,     0,     0},
+};
+
+/* Bootes */
+static ConFig _Bootes_figs[] = {
+    { 0, 26434,   823},		/* move zeta */
+    { 1, 25669,  1150},		/* draw arcturus */
+    { 1, 26549,  1624},		/* draw epsilon */
+    { 1, 27465,  1998},		/* draw delta */
+    { 1, 27058,  2423},		/* draw beta */
+    { 1, 26162,  2298},		/* draw gamma */
+    { 1, 26154,  1822},		/* draw rho */
+    { 1, 25669,  1150},		/* draw arcturus */
+    { 1, 25040,  1103},		/* draw eta */
+    { 1, 24817,  1047},		/* draw tau */
+    { 0, 26162,  2298},		/* move gamma */
+    { 1, 25691,  2765},		/* draw lambda */
+    { 1, 25604,  3107},		/* draw kappa 2 */
+    { 1, 25955,  3111},		/* draw theta */
+    { 1, 25691,  2765},		/* draw lambda */
+    {-1,     0,     0},
+};
+
+/* Caelum */
+static ConFig _Caelum_figs[] = {
+    { 0,  9132, -2129},		/* move gamma */
+    { 2,  8461, -2228},		/* dotted beta */
+    { 2,  8416, -2511},		/* dotted alpha */
+    { 2,  8125, -2697},		/* dotted delta */
+    {-1,     0,     0},
+};
+
+/* Camelopardalis */
+static ConFig _Camelopardalis_figs[] = {
+    { 0,  8918,  3225},		/* move 7 */
+    { 2,  9102,  3626},		/* dotted beta */
+    { 2,  8821,  3980},		/* dotted alpha */
+    { 2,  6910,  4279},		/* dotted gamma */
+    { 2,  6885,  3931},		/* dotted 3:49:31 65:31:34 */
+    { 2,  6272,  3596},		/* dotted 6272 3596 */
+    { 0,  8821,  3980},		/* move alpha */
+    { 2, 11365,  4159},		/* dotted 6:18:51 69:19:11 */
+    { 2, 12602,  4618},		/* dotted 7:00:04 76:58:39 */
+    {-1,     0,     0},
+};
+
+/* Cancer */
+static ConFig _Cancer_figs[] = {
+    { 0, 15800,  1725},		/* move iota1 */
+    { 2, 15698,  1288},		/* dotted gamma */
+    { 2, 15740,  1089},		/* dotted delta */
+    { 2, 16154,   711},		/* dotted alpha */
+    { 0, 15740,  1089},		/* move delta */
+    { 2, 14895,   551},		/* dotted beta */
+    {-1,     0,     0},
+};
+
+/* Canes Venatici */
+static ConFig _Canes_Venatici_figs[] = {
+    { 0, 23280,  2299},		/* move alpha2 */
+    { 2, 22612,  2481},		/* dotted beta */
+    {-1,     0,     0},
+};
+
+/* Canis Major */
+static ConFig _Canis_Major_figs[] = {
+    { 0, 13322, -1758},		/* move eta */
+    { 1, 12851, -1583},		/* draw delta */
+    { 1, 12690, -1430},		/* draw omicron2 */
+    { 1, 12154, -1002},		/* draw alpha */
+    { 1, 11481, -1077},		/* draw beta */
+    { 1, 11900, -1155},		/* draw nu2 */
+    { 1, 12423, -1451},		/* draw omicron1 */
+    { 1, 12558, -1738},		/* draw epsilon */
+    { 1, 12651, -1676},		/* draw sigma */
+    { 1, 12851, -1583},		/* draw delta */
+    { 0, 12154, -1002},		/* move alpha */
+    { 2, 12484, -1023},		/* dotted iota */
+    { 2, 12712,  -938},		/* dotted gamma */
+    { 2, 12483,  -842},		/* dotted mu */
+    { 2, 12484, -1023},		/* dotted iota */
+    {-1,     0,     0},
+};
+
+/* Canis Minor */
+static ConFig _Canis_Minor_figs[] = {
+    { 0, 13779,   313},		/* move alpha */
+    { 1, 13414,   497},		/* draw beta */
+    {-1,     0,     0},
+};
+
+/* Capricornus */
+static ConFig _Capricornus_figs[] = {
+    { 0, 36529,  -750},		/* move alpha1 */
+    { 1, 36630,  -886},		/* draw beta */
+    { 1, 37382, -1516},		/* draw psi */
+    { 1, 37554, -1615},		/* draw omega */
+    { 1, 38013, -1500},		/* draw 24 */
+    { 1, 38600, -1344},		/* draw zeta */
+    { 1, 38912, -1167},		/* draw epsilon */
+    { 1, 39211,  -967},		/* draw delta */
+    { 1, 39002,  -999},		/* draw gamma */
+    { 1, 38467, -1010},		/* draw iota */
+    { 1, 37978, -1033},		/* draw theta */
+    { 1, 36529,  -750},		/* draw alpha1 */
+    {-1,     0,     0},
+};
+
+/* Carina */
+static ConFig _Carina_figs[] = {
+    { 0, 11518, -3161},		/* move canopus */
+    { 1, 16596, -4183},		/* draw beta */
+    { 1, 18412, -4202},		/* draw omega */
+    { 1, 19288, -3863},		/* draw theta */
+    { 1, 19996, -3745},		/* draw 11:06:32 -62:25:27 */
+    { 1, 20178, -3619},		/* draw 11:12:36 -60:19:03 */
+    { 1, 20057, -3538},		/* draw 11:08:35 -58:58:30 */
+    { 1, 19605, -3531},		/* draw 10:53:30 -58:51:12 */
+    { 1, 19351, -3581},		/* draw eta */
+    { 1, 18960, -3701},		/* draw 10:32:01 -61:41:07 */
+    { 1, 19288, -3863},		/* draw theta */
+    { 0, 18960, -3701},		/* move 10:32:01 -61:41:07 */
+    { 1, 18512, -3679},		/* draw 10:17:05 -61:19:56 */
+    { 1, 16712, -3556},		/* draw iota */
+    { 1, 15741, -3282},		/* draw delta vel */
+    { 0, 16712, -3556},		/* move iota */
+    { 1, 15075, -3570},		/* draw epsilon */
+    { 1, 14303, -3178},		/* draw chi */
+    { 1, 14686, -2840},		/* draw gamma2 vel */
+    {-1,     0,     0},
+};
+
+/* Cassiopeia */
+static ConFig _Cassiopeia_figs[] = {
+    { 0,   275,  3548},		/* move beta */
+    { 1,  1215,  3392},		/* draw alpha */
+    { 1,  1701,  3643},		/* draw gamma */
+    { 1,  2574,  3614},		/* draw delta */
+    { 1,  3431,  3820},		/* draw epsilon */
+    {-1,     0,     0},
+};
+
+/* Centaurus */
+static ConFig _Centaurus_figs[] = {
+    { 0, 26387, -3650},		/* move alpha1 */
+    { 1, 25314, -3622},		/* draw hadar (agena) */
+    { 1, 24596, -3207},		/* draw epsilon */
+    { 1, 25066, -2837},		/* draw zeta */
+    { 1, 25251, -2736},		/* draw upsilon2 */
+    { 1, 25160, -2688},		/* draw upsilon1 */
+    { 1, 25148, -2526},		/* draw phi */
+    { 1, 26265, -2529},		/* draw eta */
+    { 1, 26974, -2526},		/* draw kappa */
+    { 0, 25148, -2526},		/* move phi */
+    { 1, 25381, -2470},		/* draw chi */
+    { 1, 25816, -2273},		/* draw psi */
+    { 1, 25400, -2182},		/* draw theta */
+    { 1, 24885, -2501},		/* draw nu */
+    { 1, 24331, -2364},		/* draw 24331 -2364 */
+    { 1, 24017, -2202},		/* draw iota */
+    { 1, 23203, -2410},		/* draw 23203 -2410 */
+    { 0, 24885, -2501},		/* move nu */
+    { 1, 24888, -2548},		/* draw mu */
+    { 1, 25066, -2837},		/* draw zeta */
+    { 1, 22845, -2937},		/* draw gamma */
+    { 1, 24596, -3207},		/* draw epsilon */
+    { 0, 22845, -2937},		/* move gamma */
+    { 1, 22441, -3013},		/* draw sigma */
+    { 1, 21949, -3142},		/* draw rho */
+    { 1, 21195, -3670},		/* draw 21195 -3670 */
+    { 1, 20873, -3781},		/* draw lambda */
+    { 0, 22441, -3013},		/* move sigma */
+    { 1, 21850, -3043},		/* draw delta */
+    { 1, 20430, -3269},		/* draw pi */
+    {-1,     0,     0},
+};
+
+/* Cepheus */
+static ConFig _Cepheus_figs[] = {
+    { 0, 38357,  3755},		/* move alpha */
+    { 1, 38659,  4233},		/* draw beta */
+    { 1, 42580,  4657},		/* draw gamma */
+    { 1, 41090,  3972},		/* draw iota */
+    { 1, 42580,  4657},		/* draw gamma */
+    { 0, 41090,  3972},		/* move iota */
+    { 1, 39925,  3492},		/* draw zeta */
+    { 1, 39163,  3667},		/* draw nu */
+    { 1, 39105,  3526},		/* draw mu */
+    { 1, 38357,  3755},		/* draw alpha */
+    { 1, 37358,  3710},		/* draw eta */
+    { 1, 36887,  3779},		/* draw theta */
+    {-1,     0,     0},
+};
+
+/* Cetus */
+static ConFig _Cetus_figs[] = {
+    { 0,  4899,   194},		/* move gamma */
+    { 1,  5468,   245},		/* draw alpha */
+    { 1,  5391,   534},		/* draw lambda */
+    { 1,  4948,   606},		/* draw mu */
+    { 1,  4444,   507},		/* draw xi2 */
+    { 1,  4676,   335},		/* draw nu */
+    { 1,  4899,   194},		/* draw gamma */
+    { 1,  4784,    19},		/* draw delta */
+    { 1,  4180,  -178},		/* draw mira */
+    { 1,  3343,  -620},		/* draw zeta */
+    { 1,  2520,  -491},		/* draw theta */
+    { 1,  2057,  -610},		/* draw eta */
+    { 1,   582,  -529},		/* draw iota */
+    { 1,  1307, -1079},		/* draw beta */
+    { 1,  3122,  -956},		/* draw tau */
+    { 1,  3343,  -620},		/* draw zeta */
+    {-1,     0,     0},
+};
+
+/* Chamaeleon */
+static ConFig _Chamaeleon_figs[] = {
+    { 0, 14955, -4615},		/* move alpha */
+    { 1, 15019, -4649},		/* draw theta */
+    { 1, 19064, -4716},		/* draw gamma */
+    { 1, 21588, -4693},		/* draw epsilon */
+    { 1, 22150, -4758},		/* draw beta */
+    { 1, 19357, -4828},		/* draw delta1 */
+    { 1, 19064, -4716},		/* draw gamma */
+    {-1,     0,     0},
+};
+
+/* Circinus */
+static ConFig _Circinus_figs[] = {
+    { 0, 27525, -3528},		/* move beta */
+    { 1, 26475, -3898},		/* draw alpha */
+    { 1, 27701, -3559},		/* draw gamma */
+    {-1,     0,     0},
+};
+
+/* Columba */
+static ConFig _Columba_figs[] = {
+    { 0,  9936, -2128},		/* move epsilon */
+    { 1, 10189, -2044},		/* draw alpha */
+    { 1, 10528, -2146},		/* draw beta */
+    { 1, 10726, -2117},		/* draw gamma */
+    { 1, 11463, -2006},		/* draw delta */
+    { 0, 10528, -2146},		/* move beta */
+    { 1, 10774, -2568},		/* draw eta */
+    {-1,     0,     0},
+};
+
+/* Coma Berenices */
+static ConFig _Coma_Berenices_figs[] = {
+    { 0, 23699,  1051},		/* move alpha */
+    { 2, 23756,  1672},		/* dotted beta */
+    { 2, 22408,  1696},		/* dotted gamma */
+    {-1,     0,     0},
+};
+
+/* Corona Australis */
+static ConFig _Corona_Australis_figs[] = {
+    { 0, 34392, -2223},		/* move gamma */
+    { 1, 34484, -2274},		/* draw alpha */
+    { 1, 34500, -2360},		/* draw beta */
+    { 1, 34450, -2429},		/* draw delta */
+    { 1, 33405, -2538},		/* draw theta */
+    {-1,     0,     0},
+};
+
+/* Corona Borealis */
+static ConFig _Corona_Borealis_figs[] = {
+    { 0, 27987,  1881},		/* move theta */
+    { 1, 27834,  1746},		/* draw beta */
+    { 1, 28040,  1602},		/* draw alpha */
+    { 1, 28282,  1577},		/* draw gamma */
+    { 1, 28487,  1564},		/* draw delta */
+    { 1, 28727,  1612},		/* draw epsilon */
+    { 1, 28843,  1791},		/* draw iota */
+    {-1,     0,     0},
+};
+
+/* Corvus */
+static ConFig _Corvus_figs[] = {
+    { 0, 21852, -1483},		/* move alpha */
+    { 1, 21903, -1357},		/* draw epsilon */
+    { 1, 22631, -1403},		/* draw beta */
+    { 1, 22495,  -990},		/* draw delta */
+    { 1, 22074, -1052},		/* draw gamma */
+    { 1, 21903, -1357},		/* draw epsilon */
+    {-1,     0,     0},
+};
+
+/* Crater */
+static ConFig _Crater_figs[] = {
+    { 0, 21480, -1029},		/* move eta */
+    { 1, 21142, -1101},		/* draw zeta */
+    { 1, 20546, -1061},		/* draw gamma */
+    { 1, 20500, -1126},		/* draw lambda */
+    { 1, 20149, -1369},		/* draw beta */
+    { 1, 19793, -1097},		/* draw alpha */
+    { 1, 20380,  -886},		/* draw delta */
+    { 1, 20546, -1061},		/* draw gamma */
+    { 0, 20380,  -886},		/* move delta */
+    { 1, 20538,  -651},		/* draw epsilon */
+    { 1, 20900,  -588},		/* draw theta */
+    {-1,     0,     0},
+};
+
+/* Crux */
+static ConFig _Crux_figs[] = {
+    { 0, 22397, -3785},		/* move alpha1 */
+    { 1, 22534, -3426},		/* draw gamma */
+    { 0, 23031, -3581},		/* move beta */
+    { 1, 22054, -3524},		/* draw delta */
+    {-1,     0,     0},
+};
+
+/* Cygnus */
+static ConFig _Cygnus_figs[] = {
+    { 0, 35121,  1677},		/* move beta1 */
+    { 1, 35716,  1974},		/* draw chi */
+    { 1, 35889,  2105},		/* draw eta */
+    { 1, 36666,  2415},		/* draw gamma */
+    { 1, 37386,  2038},		/* draw epsilon */
+    { 2, 38188,  1813},		/* dotted zeta */
+    { 2, 37715,  2470},		/* dotted nu */
+    { 2, 37242,  2716},		/* dotted deneb */
+    { 1, 36666,  2415},		/* draw gamma */
+    { 1, 35549,  2707},		/* draw delta */
+    { 2, 35091,  3103},		/* dotted iota */
+    { 2, 34713,  3202},		/* dotted kappa */
+    { 0, 35091,  3103},		/* move iota */
+    { 2, 36464,  2862},		/* dotted 32 */
+    { 2, 37242,  2716},		/* dotted deneb */
+    {-1,     0,     0},
+};
+
+/* Delphinus */
+static ConFig _Delphinus_figs[] = {
+    { 0, 36996,   678},		/* move epsilon */
+    { 1, 37018,   781},		/* draw eta */
+    { 1, 37126,   875},		/* draw beta */
+    { 1, 37303,   904},		/* draw delta */
+    { 1, 37399,   967},		/* draw gamma1 */
+    { 1, 37189,   954},		/* draw alpha */
+    { 1, 37126,   875},		/* draw beta */
+    {-1,     0,     0},
+};
+
+/* Dorado */
+static ConFig _Dorado_figs[] = {
+    { 0,  7680, -3089},		/* move gamma */
+    { 1,  8219, -3302},		/* draw alpha */
+    { 1, 10008, -3749},		/* draw beta */
+    { 1, 10343, -3944},		/* draw delta */
+    { 1, 10623, -3785},		/* draw 5:54:06 -63:05:23 */
+    { 1, 10008, -3749},		/* draw beta */
+    { 1,  9165, -3448},		/* draw zeta */
+    { 1,  8219, -3302},		/* draw alpha */
+    {-1,     0,     0},
+};
+
+/* Draco */
+static ConFig _Draco_figs[] = {
+    { 0, 20742,  4159},		/* move lambda */
+    { 1, 22604,  4187},		/* draw kappa */
+    { 1, 25331,  3862},		/* draw alpha */
+    { 1, 27747,  3537},		/* draw iota */
+    { 1, 28856,  3513},		/* draw theta */
+    { 1, 29519,  3690},		/* draw eta */
+    { 1, 30863,  3942},		/* draw zeta */
+    { 1, 33022,  4280},		/* draw phi */
+    { 1, 33031,  4363},		/* draw chi */
+    { 0, 33022,  4280},		/* move phi */
+    { 1, 34576,  4059},		/* draw delta */
+    { 1, 35645,  4216},		/* draw epsilon */
+    { 0, 34576,  4059},		/* move delta */
+    { 1, 32205,  3412},		/* draw xi */
+    { 1, 31565,  3311},		/* draw nu1 */
+    { 1, 31513,  3138},		/* draw beta */
+    { 1, 32298,  3089},		/* draw gamma */
+    { 1, 32205,  3412},		/* draw xi */
+    {-1,     0,     0},
+};
+
+/* Equuleus */
+static ConFig _Equuleus_figs[] = {
+    { 0, 38110,   607},		/* move gamma */
+    { 2, 38234,   600},		/* dotted delta */
+    { 2, 38274,   314},		/* dotted alpha */
+    {-1,     0,     0},
+};
+
+/* Eridanus */
+static ConFig _Eridanus_figs[] = {
+    { 0,  9235,  -305},		/* move beta */
+    { 1,  8786,  -327},		/* draw omega */
+    { 1,  8565,  -195},		/* draw mu */
+    { 1,  8289,  -201},		/* draw nu */
+    { 1,  7555,  -410},		/* draw omicron1 */
+    { 1,  7140,  -810},		/* draw gamma */
+    { 1,  6784,  -726},		/* draw pi */
+    { 1,  6697,  -585},		/* draw delta */
+    { 1,  6387,  -567},		/* draw epsilon */
+    { 1,  5292,  -533},		/* draw eta */
+    { 1,  4923,  -831},		/* draw cet pi */
+    { 1,  4953, -1114},		/* draw tau1 */
+    { 1,  5471, -1417},		/* draw tau3 */
+    { 1,  5985, -1305},		/* draw tau4 */
+    { 1,  6413, -1297},		/* draw tau5 */
+    { 1,  6805, -1394},		/* draw tau6 */
+    { 1,  7011, -1476},		/* draw tau8 */
+    { 1,  7197, -1440},		/* draw tau9 */
+    { 1,  8205, -1786},		/* draw upsilon1 */
+    { 1,  8266, -1833},		/* draw upsilon2 */
+    { 1,  7921, -2041},		/* draw 43 */
+    { 1,  7736, -2027},		/* draw upsilon4 */
+    { 1,  6883, -2172},		/* draw 3:49:27 -36:12:01 */
+    { 1,  6685, -2238},		/* draw 3:42:50 -37:18:49 */
+    { 1,  6513, -2416},		/* draw 3:37:06 -40:16:29 */
+    { 1,  5998, -2584},		/* draw 3:19:56 -43:04:11 */
+    { 1,  5348, -2418},		/* draw theta2 */
+    { 1,  4820, -2391},		/* draw iota */
+    { 1,  4794, -2573},		/* draw 4794 -2573 */
+    { 1,  4409, -2862},		/* draw kappa */
+    { 1,  4095, -3090},		/* draw phi */
+    { 1,  3478, -3096},		/* draw chi */
+    { 1,  2931, -3434},		/* draw achernar */
+    {-1,     0,     0},
+};
+
+/* Fornax */
+static ConFig _Fornax_figs[] = {
+    { 0,  5762, -1739},		/* move alpha */
+    { 1,  5072, -1944},		/* draw beta */
+    { 1,  3734, -1757},		/* draw nu */
+    {-1,     0,     0},
+};
+
+/* Gemini */
+static ConFig _Gemini_figs[] = {
+    { 0, 10923,  1395},		/* move gem 1 */
+    { 1, 11246,  1350},		/* draw gem eta */
+    { 1, 11488,  1350},		/* draw gem mu */
+    { 1, 12117,  1507},		/* draw gem epsilon */
+    { 1, 12934,  1814},		/* draw gem tau */
+    { 1, 13473,  1907},		/* draw gem rho */
+    { 1, 13638,  1913},		/* draw castor */
+    { 0, 13959,  1681},		/* move pollux */
+    { 1, 13677,  1613},		/* draw gem upsilon */
+    { 1, 13203,  1318},		/* draw gem delta */
+    { 1, 12723,  1234},		/* draw gem zeta */
+    { 1, 11931,   983},		/* draw gem gamma */
+    { 0, 12383,  2037},		/* move gem theta */
+    { 1, 12934,  1814},		/* draw gem tau */
+    { 1, 13336,  1658},		/* draw gem 59 */
+    { 1, 13677,  1613},		/* draw gem upsilon */
+    { 1, 13933,  1463},		/* draw gem kappa */
+    { 0, 13203,  1318},		/* move gem delta */
+    { 1, 13142,   992},		/* draw gem lambda */
+    { 1, 13001,   969},		/* draw gem 51 */
+    { 1, 13001,   969},		/* draw gem 51 */
+    { 1, 12158,   773},		/* draw gem xi */
+    { 0, 12117,  1507},		/* move gem epsilon */
+    { 1, 11668,  1212},		/* draw gem nu */
+    {-1,     0,     0},
+};
+
+/* Grus */
+static ConFig _Grus_figs[] = {
+    { 0, 39417, -2241},		/* move gamma */
+    { 1, 39783, -2372},		/* draw lambda */
+    { 1, 40478, -2609},		/* draw delta1 */
+    { 1, 40880, -2813},		/* draw beta */
+    { 1, 41056, -3079},		/* draw epsilon */
+    { 1, 41426, -3165},		/* draw zeta */
+    { 0, 40880, -2813},		/* move beta */
+    { 1, 39847, -2817},		/* draw alpha */
+    { 1, 40478, -2609},		/* draw delta1 */
+    {-1,     0,     0},
+};
+
+/* Hercules */
+static ConFig _Hercules_figs[] = {
+    { 0, 28580,  2547},		/* move chi */
+    { 1, 29063,  2696},		/* draw phi */
+    { 1, 29392,  2778},		/* draw tau */
+    { 1, 29823,  2546},		/* draw sigma */
+    { 1, 30086,  2335},		/* draw eta */
+    { 1, 30038,  1896},		/* draw zeta */
+    { 1, 29706,  1289},		/* draw beta */
+    { 1, 29457,  1149},		/* draw gamma */
+    { 1, 29562,   842},		/* draw omega */
+    { 1, 29778,   689},		/* draw 29 */
+    { 0, 29706,  1289},		/* move beta */
+    { 1, 31039,   863},		/* draw alpha */
+    { 1, 31050,  1490},		/* draw delta */
+    { 1, 30608,  1855},		/* draw epsilon */
+    { 1, 30038,  1896},		/* draw zeta */
+    { 0, 31050,  1490},		/* move delta */
+    { 1, 31522,  1566},		/* draw lambda */
+    { 1, 31993,  1663},		/* draw mu */
+    { 1, 32332,  1754},		/* draw xi */
+    { 1, 32626,  1725},		/* draw omicron */
+    { 0, 30608,  1855},		/* move epsilon */
+    { 1, 31051,  2208},		/* draw pi */
+    { 1, 30086,  2335},		/* draw eta */
+    { 0, 31051,  2208},		/* move pi */
+    { 1, 32287,  2235},		/* draw theta */
+    { 1, 31783,  2760},		/* draw iota */
+    {-1,     0,     0},
+};
+
+/* Horologium */
+static ConFig _Horologium_figs[] = {
+    { 0,  7620, -2537},		/* move alpha */
+    { 1,  4876, -3048},		/* draw iota */
+    { 1,  4722, -3152},		/* draw eta */
+    { 1,  4819, -3273},		/* draw zeta */
+    { 1,  5508, -3584},		/* draw mu */
+    { 1,  5363, -3844},		/* draw beta */
+    {-1,     0,     0},
+};
+
+/* Hydra */
+static ConFig _Hydra_figs[] = {
+    { 0, 26708, -1677},		/* move 58 */
+    { 1, 25391, -1600},		/* draw pi */
+    { 1, 23967, -1390},		/* draw gamma */
+    { 1, 21387, -2034},		/* draw beta */
+    { 1, 20790, -1911},		/* draw xi */
+    { 1, 20149, -1369},		/* draw crt beta */
+    { 1, 19793, -1097},		/* draw crt alpha */
+    { 1, 19488,  -971},		/* draw nu */
+    { 1, 18782, -1010},		/* draw mu */
+    { 1, 18317,  -741},		/* draw lambda */
+    { 1, 18153,  -783},		/* draw upsilon2 */
+    { 1, 17744,  -890},		/* draw upsilon1 */
+    { 1, 17027,  -519},		/* draw alpha */
+    { 1, 17395,   -68},		/* draw iota */
+    { 1, 16630,   138},		/* draw theta */
+    { 1, 16061,   356},		/* draw zeta */
+    { 1, 15803,   385},		/* draw epsilon */
+    { 1, 15529,   342},		/* draw delta */
+    { 1, 15562,   200},		/* draw sigma */
+    { 1, 15696,   203},		/* draw eta */
+    { 1, 15853,   350},		/* draw rho */
+    { 1, 15803,   385},		/* draw epsilon */
+    {-1,     0,     0},
+};
+
+/* Hydrus */
+static ConFig _Hydrus_figs[] = {
+    { 0,  6817, -4454},		/* move gamma */
+    { 1,   772, -4635},		/* draw beta */
+    { 1,  3563, -3694},		/* draw alpha */
+    { 1,  6817, -4454},		/* draw gamma */
+    {-1,     0,     0},
+};
+
+/* Indus */
+static ConFig _Indus_figs[] = {
+    { 0, 37644, -3507},		/* move beta */
+    { 2, 37321, -3115},		/* dotted eta */
+    { 2, 37127, -2837},		/* dotted alpha */
+    { 2, 38396, -3206},		/* dotted theta */
+    { 2, 39537, -3299},		/* dotted delta */
+    {-1,     0,     0},
+};
+
+/* Lacerta */
+static ConFig _Lacerta_figs[] = {
+    { 0, 40079,  2264},		/* move 1 */
+    { 2, 40016,  2382},		/* dotted 22:13:53 39:42:53 */
+    { 2, 40514,  2587},		/* dotted 6 */
+    { 2, 40815,  2656},		/* dotted 11 */
+    { 2, 40485,  2862},		/* dotted 5 */
+    { 2, 40538,  3016},		/* dotted alpha */
+    { 2, 40306,  3133},		/* dotted beta */
+    { 2, 40335,  2968},		/* dotted 4 */
+    { 2, 40485,  2862},		/* dotted 5 */
+    { 2, 40230,  2792},		/* dotted 2 */
+    { 2, 40514,  2587},		/* dotted 6 */
+    {-1,     0,     0},
+};
+
+/* Leo */
+static ConFig _Leo_figs[] = {
+    { 0, 18251,   718},		/* move regulus */
+    { 1, 18220,  1005},		/* draw eta */
+    { 1, 18599,  1190},		/* draw gamma1 */
+    { 1, 18500,  1405},		/* draw zeta */
+    { 1, 17782,  1560},		/* draw mu */
+    { 1, 16939,  1570},		/* draw kappa */
+    { 1, 17151,  1378},		/* draw lambda */
+    { 1, 17575,  1426},		/* draw epsilon */
+    { 1, 17782,  1560},		/* draw mu */
+    { 0, 17575,  1426},		/* move epsilon */
+    { 1, 18220,  1005},		/* draw eta */
+    { 1, 20227,   925},		/* draw theta */
+    { 1, 20517,   631},		/* draw iota */
+    { 1, 20434,   361},		/* draw sigma */
+    { 0, 20227,   925},		/* move theta */
+    { 1, 21271,   874},		/* draw beta */
+    { 1, 20223,  1231},		/* draw delta */
+    { 1, 20227,   925},		/* draw theta */
+    { 0, 20223,  1231},		/* move delta */
+    { 1, 18599,  1190},		/* draw gamma1 */
+    {-1,     0,     0},
+};
+
+/* Leo Minor */
+static ConFig _Leo_Minor_figs[] = {
+    { 0, 17226,  2183},		/* move 10 */
+    { 2, 18222,  2114},		/* dotted 21 */
+    { 2, 18777,  2027},		/* dotted 30 */
+    { 2, 19599,  2052},		/* dotted 46 */
+    { 2, 18836,  2202},		/* dotted beta */
+    { 2, 18222,  2114},		/* dotted 21 */
+    {-1,     0,     0},
+};
+
+/* Lepus */
+static ConFig _Lepus_figs[] = {
+    { 0,  9396,  -776},		/* move kappa */
+    { 1,  9387,  -972},		/* draw mu */
+    { 1,  9587,  -790},		/* draw lambda */
+    { 0,  9981, -1069},		/* move alpha */
+    { 1,  9847, -1245},		/* draw beta */
+    { 1, 10333, -1346},		/* draw gamma */
+    { 1, 10539, -1252},		/* draw delta */
+    { 1, 10984,  -896},		/* draw theta */
+    { 1, 10692,  -850},		/* draw eta */
+    { 1, 10408,  -889},		/* draw zeta */
+    { 1,  9981, -1069},		/* draw alpha */
+    { 1,  9387,  -972},		/* draw mu */
+    { 1,  9163, -1342},		/* draw epsilon */
+    { 1,  9847, -1245},		/* draw beta */
+    {-1,     0,     0},
+};
+
+/* Libra */
+static ConFig _Libra_figs[] = {
+    { 0, 27122, -1516},		/* move sigma */
+    { 1, 26726,  -962},		/* draw alpha2 */
+    { 1, 27510,  -562},		/* draw beta */
+    { 1, 28065,  -887},		/* draw gamma */
+    { 1, 26726,  -962},		/* draw alpha2 */
+    { 0, 28065,  -887},		/* move gamma */
+    { 1, 28110, -1688},		/* draw upsilon */
+    { 1, 28159, -1786},		/* draw tau */
+    {-1,     0,     0},
+};
+
+/* Lupus */
+static ConFig _Lupus_figs[] = {
+    { 0, 26955, -2588},		/* move beta */
+    { 1, 27641, -2438},		/* draw delta */
+    { 1, 28054, -2470},		/* draw gamma */
+    { 1, 28803, -2303},		/* draw eta */
+    { 1, 28528, -2017},		/* draw chi */
+    { 1, 27654, -2175},		/* draw phi1 */
+    { 1, 28803, -2303},		/* draw eta */
+    { 1, 27368, -3125},		/* draw zeta */
+    { 1, 26457, -2843},		/* draw alpha */
+    { 0, 27368, -3125},		/* move zeta */
+    { 1, 27556, -2872},		/* draw mu */
+    { 1, 27680, -2681},		/* draw epsilon */
+    { 1, 28054, -2470},		/* draw gamma */
+    {-1,     0,     0},
+};
+
+/* Lynx */
+static ConFig _Lynx_figs[] = {
+    { 0, 16831,  2063},		/* move alpha */
+    { 2, 16765,  2208},		/* dotted 38 */
+    { 2, 16396,  2307},		/* dotted 9:06:32 38:27:08 */
+    { 2, 16219,  2506},		/* dotted 9:00:38 41:46:58 */
+    { 2, 15085,  2591},		/* dotted 31 */
+    { 2, 13401,  2952},		/* dotted 21 */
+    { 2, 12518,  3505},		/* dotted 15 */
+    { 2, 11388,  3540},		/* dotted 2 */
+    {-1,     0,     0},
+};
+
+/* Lyra */
+static ConFig _Lyra_figs[] = {
+    { 0, 33743,  2256},		/* move zeta1 */
+    { 1, 33730,  2380},		/* draw epsilon1 */
+    { 1, 33508,  2327},		/* draw vega */
+    { 1, 33743,  2256},		/* draw zeta1 */
+    { 1, 33902,  2001},		/* draw beta */
+    { 1, 34168,  1961},		/* draw gamma */
+    { 1, 34035,  2213},		/* draw delta2 */
+    { 1, 33743,  2256},		/* draw zeta1 */
+    {-1,     0,     0},
+};
+
+/* Mensa */
+static ConFig _Mensa_figs[] = {
+    { 0, 11107, -4485},		/* move alpha */
+    { 2,  9956, -4580},		/* dotted gamma */
+    { 2,  8855, -4496},		/* dotted eta */
+    { 2,  9081, -4278},		/* dotted beta */
+    {-1,     0,     0},
+};
+
+/* Microscopium */
+static ConFig _Microscopium_figs[] = {
+    { 0, 38422, -2448},		/* move theta1 */
+    { 2, 38338, -1930},		/* dotted epsilon */
+    { 2, 37838, -1935},		/* dotted gamma */
+    { 2, 37499, -2026},		/* dotted alpha */
+    {-1,     0,     0},
+};
+
+/* Monoceros */
+static ConFig _Monoceros_figs[] = {
+    { 0, 12029,   593},		/* move 15 */
+    { 2, 11787,   439},		/* dotted 13 */
+    { 2, 11513,   275},		/* dotted epsilon */
+    { 2, 12235,   144},		/* dotted 18 */
+    { 2, 11787,   439},		/* dotted 13 */
+    { 0, 12235,   144},		/* move 18 */
+    { 2, 12955,   -29},		/* dotted delta */
+    { 2, 11664,  -422},		/* dotted beta */
+    { 1, 11245,  -376},		/* draw gamma */
+    { 0, 12955,   -29},		/* move delta */
+    { 2, 13837,  -573},		/* dotted alpha */
+    { 2, 14657,  -179},		/* dotted zeta */
+    {-1,     0,     0},
+};
+
+/* Musca */
+static ConFig _Musca_figs[] = {
+    { 0, 21168, -4003},		/* move lambda */
+    { 1, 22127, -4077},		/* draw epsilon */
+    { 1, 22715, -4148},		/* draw alpha */
+    { 1, 22574, -4327},		/* draw gamma */
+    { 1, 23468, -4292},		/* draw delta */
+    { 1, 22988, -4086},		/* draw beta */
+    {-1,     0,     0},
+};
+
+/* Norma */
+static ConFig _Norma_figs[] = {
+    { 0, 29615, -2853},		/* move epsilon */
+    { 1, 29310, -3004},		/* draw gamma1 */
+    { 1, 29395, -3009},		/* draw gamma2 */
+    { 1, 28896, -2953},		/* draw eta */
+    { 1, 28994, -2710},		/* draw delta */
+    { 1, 29615, -2853},		/* draw epsilon */
+    {-1,     0,     0},
+};
+
+/* Octans */
+static ConFig _Octans_figs[] = {
+    { 0, 26007, -5020},		/* move delta */
+    { 1, 39044, -4643},		/* draw nu */
+    { 1, 40200, -4826},		/* draw epsilon */
+    { 1, 40981, -4882},		/* draw beta */
+    { 1, 26007, -5020},		/* draw delta */
+    {-1,     0,     0},
+};
+
+/* Ophiuchus */
+static ConFig _Ophiuchus_figs[] = {
+    { 0, 31420, -1792},		/* move 45 */
+    { 1, 31260, -1499},		/* draw theta */
+    { 1, 30911,  -943},		/* draw eta */
+    { 1, 29914,  -634},		/* draw zeta */
+    { 1, 29734,  -996},		/* draw phi */
+    { 1, 29610, -1107},		/* draw chi */
+    { 1, 29523, -1202},		/* draw psi */
+    { 1, 29567, -1406},		/* draw rho */
+    { 0, 29914,  -634},		/* move zeta */
+    { 1, 29634,  -502},		/* draw upsilon */
+    { 1, 29349,  -281},		/* draw epsilon */
+    { 1, 29230,  -221},		/* draw delta */
+    { 1, 29727,   119},		/* draw lambda */
+    { 1, 30530,   562},		/* draw kappa */
+    { 1, 29914,  -634},		/* draw zeta */
+    { 0, 30530,   562},		/* move kappa */
+    { 1, 31648,   753},		/* draw alpha */
+    { 1, 31904,   274},		/* draw beta */
+    { 1, 30911,  -943},		/* draw eta */
+    { 0, 31904,   274},		/* move beta */
+    { 1, 32036,   162},		/* draw gamma */
+    { 1, 32370,  -586},		/* draw nu */
+    {-1,     0,     0},
+};
+
+/* Orion */
+static ConFig _Orion_figs[] = {
+    { 0, 11158,   852},		/* move xi */
+    { 1, 11027,   886},		/* draw nu */
+    { 1, 10631,  1216},		/* draw chi1 */
+    { 1, 10917,  1208},		/* draw chi2 */
+    { 1, 11158,   852},		/* draw xi */
+    { 1, 10871,   578},		/* draw mu */
+    { 1, 10655,   444},		/* draw betelgeuse */
+    { 1,  9753,   380},		/* draw gamma */
+    { 1, 10054,   596},		/* draw lambda */
+    { 1, 10655,   444},		/* draw betelgeuse */
+    { 1, 10222,  -116},		/* draw zeta */
+    { 1, 10432,  -580},		/* draw kappa */
+    { 0, 10222,  -116},		/* move zeta */
+    { 1, 10086,   -72},		/* draw epsilon */
+    { 1,  9960,   -17},		/* draw delta */
+    { 1,  9734,  -143},		/* draw eta */
+    { 1,  9436,  -492},		/* draw rigel */
+    { 0,  9960,   -17},		/* move delta */
+    { 1,  9753,   380},		/* draw gamma */
+    { 1,  8695,   417},		/* draw pi3 */
+    { 1,  8736,   336},		/* draw pi4 */
+    { 1,  8827,   146},		/* draw pi5 */
+    { 1,  8956,   102},		/* draw pi6 */
+    { 0,  8695,   417},		/* move pi3 */
+    { 1,  8718,   534},		/* draw pi2 */
+    { 1,  8846,   609},		/* draw pi1 */
+    { 1,  8891,   810},		/* draw omicron2 */
+    { 1,  9137,   924},		/* draw 11 */
+    {-1,     0,     0},
+};
+
+/* Pavo */
+static ConFig _Pavo_figs[] = {
+    { 0, 36017, -4374},		/* move epsilon */
+    { 1, 36261, -3970},		/* draw delta */
+    { 1, 33691, -4285},		/* draw zeta */
+    { 0, 31971, -3883},		/* move eta */
+    { 1, 32657, -3820},		/* draw pi */
+    { 1, 33096, -3689},		/* draw xi */
+    { 1, 33966, -3731},		/* draw lambda */
+    { 1, 36261, -3970},		/* draw delta */
+    { 1, 36769, -3404},		/* draw alpha */
+    { 1, 38593, -3921},		/* draw gamma */
+    { 1, 37348, -3972},		/* draw beta */
+    { 1, 36261, -3970},		/* draw delta */
+    { 1, 34108, -4034},		/* draw kappa */
+    { 1, 32657, -3820},		/* draw pi */
+    {-1,     0,     0},
+};
+
+/* Pegasus */
+static ConFig _Pegasus_figs[] = {
+    { 0, 39125,   592},		/* move epsilon */
+    { 1, 39906,   371},		/* draw theta */
+    { 1, 40843,   649},		/* draw zeta */
+    { 1, 41542,   912},		/* draw alpha */
+    { 1,   397,   911},		/* draw gamma */
+    { 1,   251,  1745},		/* draw and alpha */
+    { 1, 41513,  1684},		/* draw beta */
+    { 1, 41542,   912},		/* draw alpha */
+    { 0, 39899,  1990},		/* move pi2 */
+    { 1, 40890,  1813},		/* draw eta */
+    { 1, 41513,  1684},		/* draw beta */
+    { 1, 41100,  1476},		/* draw mu */
+    { 1, 40995,  1413},		/* draw lambda */
+    { 1, 39810,  1520},		/* draw iota */
+    { 1, 39139,  1538},		/* draw kappa */
+    {-1,     0,     0},
+};
+
+/* Perseus */
+static ConFig _Perseus_figs[] = {
+    { 0,  3109,  3041},		/* move phi */
+    { 1,  4926,  2953},		/* draw theta */
+    { 1,  5672,  2976},		/* draw iota */
+    { 1,  5684,  2691},		/* draw kappa */
+    { 1,  5645,  2457},		/* draw algol */
+    { 1,  5555,  2330},		/* draw rho */
+    { 0,  5645,  2457},		/* move algol */
+    { 1,  7135,  2400},		/* draw epsilon */
+    { 1,  7168,  2147},		/* draw xi */
+    { 1,  7023,  1913},		/* draw zeta */
+    { 1,  6729,  1937},		/* draw omicron */
+    { 0,  7135,  2400},		/* move epsilon */
+    { 1,  6687,  2867},		/* draw delta */
+    { 1,  7459,  2862},		/* draw 48 */
+    { 1,  7646,  2904},		/* draw mu */
+    { 1,  7747,  3017},		/* draw 4:18:15 50:17:44 */
+    { 1,  7397,  3021},		/* draw lambda */
+    { 0,  6687,  2867},		/* move delta */
+    { 1,  6129,  2991},		/* draw alpha */
+    { 1,  5543,  3210},		/* draw gamma */
+    { 1,  5120,  3353},		/* draw eta */
+    { 1,  5227,  3165},		/* draw tau */
+    { 1,  5672,  2976},		/* draw iota */
+    { 1,  6129,  2991},		/* draw alpha */
+    {-1,     0,     0},
+};
+
+/* Phoenix */
+static ConFig _Phoenix_figs[] = {
+    { 0,  1982, -2803},		/* move beta */
+    { 1,   282, -2744},		/* draw epsilon */
+    { 1,   788, -2538},		/* draw alpha */
+    { 1,  1982, -2803},		/* draw beta */
+    { 1,  2650, -2599},		/* draw gamma */
+    { 1,  2737, -2944},		/* draw delta */
+    { 1,  2051, -3314},		/* draw zeta */
+    { 1,  1982, -2803},		/* draw beta */
+    {-1,     0,     0},
+};
+
+/* Pictor */
+static ConFig _Pictor_figs[] = {
+    { 0, 12245, -3716},		/* move alpha */
+    { 2, 10494, -3370},		/* dotted gamma */
+    { 2, 10418, -3063},		/* dotted beta */
+    {-1,     0,     0},
+};
+
+/* Pisces */
+static ConFig _Pisces_figs[] = {
+    { 0,  1970,  1288},		/* move psi1 */
+    { 1,  2384,  1635},		/* draw upsilon */
+    { 1,  2149,  1805},		/* draw tau */
+    { 1,  1970,  1288},		/* draw psi1 */
+    { 1,  2143,  1262},		/* draw chi */
+    { 1,  2744,   920},		/* draw eta */
+    { 1,  3161,   549},		/* draw omicron */
+    { 1,  3661,   165},		/* draw alpha */
+    { 1,  3406,   191},		/* draw xi */
+    { 1,  3042,   329},		/* draw nu */
+    { 1,  2705,   368},		/* draw mu */
+    { 1,  1888,   473},		/* draw epsilon */
+    { 1,  1460,   455},		/* draw delta */
+    { 1, 43179,   411},		/* draw omega */
+    { 1, 42598,   337},		/* draw iota */
+    { 1, 42239,   382},		/* draw theta */
+    { 1, 41914,   196},		/* draw gamma */
+    { 1, 42208,    75},		/* draw kappa */
+    { 1, 42661,   106},		/* draw lambda */
+    { 1, 42598,   337},		/* draw iota */
+    {-1,     0,     0},
+};
+
+/* Piscis Austrinus */
+static ConFig _Piscis_Austrinus_figs[] = {
+    { 0, 41329, -1777},		/* move fomalhaut */
+    { 1, 40819, -1622},		/* draw epsilon */
+    { 1, 39851, -1979},		/* draw mu */
+    { 1, 39232, -1853},		/* draw theta */
+    { 1, 39148, -1981},		/* draw iota */
+    { 1, 39851, -1979},		/* draw mu */
+    { 1, 40545, -1940},		/* draw beta */
+    { 1, 41175, -1972},		/* draw gamma */
+    { 1, 41278, -1952},		/* draw delta */
+    { 1, 41329, -1777},		/* draw fomalhaut */
+    {-1,     0,     0},
+};
+
+/* Puppis */
+static ConFig _Puppis_figs[] = {
+    { 0, 11518, -3161},		/* move canopus */
+    { 1, 11932, -2591},		/* draw nu */
+    { 1, 13114, -2225},		/* draw pi */
+    { 1, 13906, -1704},		/* draw 1 */
+    { 1, 13914, -1737},		/* draw 3 */
+    { 1, 14078, -1491},		/* draw xi */
+    { 1, 13764, -1608},		/* draw 7:38:49 -26:48:06 */
+    { 1, 13906, -1704},		/* draw 1 */
+    { 0, 14078, -1491},		/* move xi */
+    { 1, 14626, -1458},		/* draw rho */
+    { 1, 14507, -2400},		/* draw zeta */
+    { 1, 14686, -2840},		/* draw vel gamma2 */
+    {-1,     0,     0},
+};
+
+/* Pyxis */
+static ConFig _Pyxis_figs[] = {
+    { 0, 15915, -1662},		/* move gamma */
+    { 1, 15707, -1991},		/* draw alpha */
+    { 1, 15603, -2118},		/* draw beta */
+    { 1, 14507, -2400},		/* draw pup zeta */
+    {-1,     0,     0},
+};
+
+/* Reticulum */
+static ConFig _Reticulum_figs[] = {
+    { 0,  7632, -3748},		/* move alpha */
+    { 1,  6726, -3888},		/* draw beta */
+    { 1,  7162, -3684},		/* draw delta */
+    { 1,  7694, -3558},		/* draw epsilon */
+    { 1,  7632, -3748},		/* draw alpha */
+    {-1,     0,     0},
+};
+
+/* Sagitta */
+static ConFig _Sagitta_figs[] = {
+    { 0, 35402,  1080},		/* move alpha */
+    { 1, 35621,  1112},		/* draw delta */
+    { 1, 35962,  1169},		/* draw gamma */
+    { 0, 35621,  1112},		/* move delta */
+    { 1, 35431,  1048},		/* draw beta */
+    {-1,     0,     0},
+};
+
+/* Sagittarius */
+static ConFig _Sagittarius_figs[] = {
+    { 0, 32928, -2205},		/* move eta */
+    { 2, 33125, -2063},		/* dotted epsilon */
+    { 1, 32574, -1825},		/* draw gamma */
+    { 1, 33029, -1789},		/* draw delta */
+    { 1, 33125, -2063},		/* draw epsilon */
+    { 1, 34278, -1792},		/* draw zeta */
+    { 1, 34408, -1660},		/* draw tau */
+    { 1, 34057, -1577},		/* draw sigma */
+    { 1, 33769, -1619},		/* draw phi */
+    { 1, 34278, -1792},		/* draw zeta */
+    { 0, 33239, -1525},		/* move lambda */
+    { 1, 33769, -1619},		/* draw phi */
+    { 1, 33029, -1789},		/* draw delta */
+    { 1, 33239, -1525},		/* draw lambda */
+    { 2, 32812, -1263},		/* dotted mu */
+    { 0, 34850, -1070},		/* move rho1 */
+    { 2, 34492, -1261},		/* dotted pi */
+    { 2, 34340, -1304},		/* dotted omicron */
+    { 2, 34131, -1266},		/* dotted xi2 */
+    { 2, 34492, -1261},		/* dotted pi */
+    {-1,     0,     0},
+};
+
+/* Scorpius */
+static ConFig _Scorpius_figs[] = {
+    { 0, 32095, -2222},		/* move 17:49:52 -37:02:36 */
+    { 1, 31608, -2226},		/* draw lambda */
+    { 1, 31522, -2237},		/* draw upsilon */
+    { 1, 31874, -2341},		/* draw kappa */
+    { 1, 32027, -2407},		/* draw iota1 */
+    { 1, 31719, -2579},		/* draw theta */
+    { 1, 30964, -2594},		/* draw eta */
+    { 1, 30437, -2541},		/* draw zeta 2 */
+    { 1, 30356, -2282},		/* draw mu 1 */
+    { 1, 30304, -2057},		/* draw epsilon */
+    { 1, 29876, -1692},		/* draw tau */
+    { 1, 29682, -1585},		/* draw antares */
+    { 1, 29435, -1535},		/* draw sigma */
+    { 1, 28810, -1357},		/* draw delta */
+    { 1, 28765, -1566},		/* draw pi */
+    { 1, 28706, -1752},		/* draw rho */
+    { 0, 28810, -1357},		/* move delta */
+    { 1, 28963, -1188},		/* draw beta1 */
+    { 1, 29159, -1166},		/* draw nu */
+    {-1,     0,     0},
+};
+
+/* Sculptor */
+static ConFig _Sculptor_figs[] = {
+    { 0,  1758, -1761},		/* move alpha */
+    { 1, 42867, -1687},		/* draw delta */
+    { 1, 41964, -1951},		/* draw gamma */
+    { 1, 42389, -2269},		/* draw beta */
+    {-1,     0,     0},
+};
+
+/* Scutum */
+static ConFig _Scutum_figs[] = {
+    { 0, 33456,  -494},		/* move alpha */
+    { 1, 33815,  -284},		/* draw beta */
+    { 1, 33668,  -543},		/* draw delta */
+    { 1, 33275,  -873},		/* draw gamma */
+    { 1, 33456,  -494},		/* draw alpha */
+    {-1,     0,     0},
+};
+
+/* Serpens Caput */
+static ConFig _Serpens_Caput_figs[] = {
+    { 0, 28385,   925},		/* move ser beta */
+    { 1, 28693,   939},		/* draw ser gamma */
+    { 1, 28462,  1088},		/* draw ser kappa */
+    { 1, 28246,  1180},		/* draw ser iota */
+    { 1, 28385,   925},		/* draw ser beta */
+    { 1, 28044,   632},		/* draw ser delta */
+    { 1, 28328,   385},		/* draw ser alpha */
+    { 1, 28524,   268},		/* draw ser epsilon */
+    { 1, 28488,  -205},		/* draw ser mu */
+    { 1, 29230,  -221},		/* draw oph delta */
+    {-1,     0,     0},
+};
+
+/* Serpens Cauda */
+static ConFig _Serpens_Cauda_figs[] = {
+    { 0, 34086,   252},		/* move ser theta1 */
+    { 1, 33039,  -173},		/* draw ser eta */
+    { 1, 32370,  -586},		/* draw oph nu */
+    { 1, 31727,  -923},		/* draw ser xi */
+    { 1, 30911,  -943},		/* draw oph eta */
+    {-1,     0,     0},
+};
+
+/* Sextans */
+static ConFig _Sextans_figs[] = {
+    { 0, 18884,  -164},		/* move delta */
+    { 2, 18908,   -38},		/* dotted beta */
+    { 2, 18238,   -22},		/* dotted alpha */
+    { 2, 17775,  -486},		/* dotted gamma */
+    {-1,     0,     0},
+};
+
+/* Taurus */
+static ConFig _Taurus_figs[] = {
+    { 0,  6506,    24},		/* move 10 */
+    { 1,  6144,   541},		/* draw omicron */
+    { 1,  6215,   583},		/* draw xi */
+    { 1,  7294,   359},		/* draw nu */
+    { 0,  6215,   583},		/* move xi */
+    { 1,  7220,   749},		/* draw lambda */
+    { 1,  7793,   937},		/* draw gamma */
+    { 1,  8057,   957},		/* draw theta1 */
+    { 1,  8277,   990},		/* draw aldebaran */
+    { 1, 10129,  1268},		/* draw zeta */
+    { 0,  7793,   937},		/* move gamma */
+    { 1,  7888,  1052},		/* draw delta1 */
+    { 1,  7964,  1075},		/* draw delta3 */
+    { 1,  8058,  1150},		/* draw epsilon */
+    { 1,  9788,  1716},		/* draw beta */
+    {-1,     0,     0},		
+};
+
+/* Telescopium */
+static ConFig _Telescopium_figs[] = {
+    { 0, 32736, -2757},		/* move epsilon */
+    { 1, 33209, -2758},		/* draw alpha */
+    { 1, 33264, -2944},		/* draw zeta */
+    {-1,     0,     0},
+};
+
+/* Triangulum */
+static ConFig _Triangulum_figs[] = {
+    { 0,  3392,  1774},		/* move alpha */
+    { 1,  3886,  2099},		/* draw beta */
+    { 1,  4119,  2030},		/* draw gamma */
+    { 1,  3392,  1774},		/* draw alpha */
+    {-1,     0,     0},
+};
+
+/* Triangulum Australe */
+static ConFig _Triangulum_Australe_figs[] = {
+    { 0, 30259, -4141},		/* move alpha */
+    { 1, 28654, -3805},		/* draw beta */
+    { 1, 28101, -3979},		/* draw epsilon */
+    { 1, 27567, -4120},		/* draw gamma */
+    { 1, 30259, -4141},		/* draw alpha */
+    {-1,     0,     0},
+};
+
+/* Tucana */
+static ConFig _Tucana_figs[] = {
+    { 0, 40420, -3897},		/* move delta */
+    { 1, 40155, -3615},		/* draw alpha */
+    { 1, 41922, -3494},		/* draw gamma */
+    { 1,   946, -3777},		/* draw beta1 */
+    { 1,   602, -3892},		/* draw zeta */
+    { 1, 43197, -3934},		/* draw epsilon */
+    { 1, 40420, -3897},		/* draw delta */
+    {-1,     0,     0},
+};
+
+/* Ursa Major */
+static ConFig _Ursa_Major_figs[] = {
+    { 0, 24826,  2958},		/* move eta */
+    { 1, 24117,  3295},		/* draw mizar a */
+    { 1, 23220,  3357},		/* draw epsilon */
+    { 1, 22062,  3421},		/* draw delta */
+    { 1, 21414,  3221},		/* draw gamma */
+    { 1, 19855,  3382},		/* draw beta */
+    { 1, 19911,  3705},		/* draw alpha */
+    { 1, 22062,  3421},		/* draw delta */
+    { 0, 21414,  3221},		/* move gamma */
+    { 2, 21181,  2866},		/* dotted chi */
+    { 2, 20354,  1985},		/* dotted nu */
+    { 2, 20345,  1891},		/* dotted xi */
+    { 0, 21181,  2866},		/* move chi */
+    { 2, 20089,  2669},		/* dotted psi */
+    { 2, 18669,  2489},		/* dotted mu */
+    { 2, 18512,  2574},		/* dotted lambda */
+    { 0, 19855,  3382},		/* move beta */
+    { 2, 17729,  3542},		/* dotted upsilon */
+    { 2, 15307,  3643},		/* dotted omicron */
+    { 2, 17145,  3783},		/* dotted 23 */
+    { 2, 19911,  3705},		/* dotted alpha */
+    { 0, 17145,  3783},		/* move 23 */
+    { 2, 17729,  3542},		/* dotted upsilon */
+    { 2, 17185,  3100},		/* dotted theta */
+    { 2, 16308,  2829},		/* dotted kappa */
+    { 2, 16176,  2882},		/* dotted iota */
+    {-1,     0,     0},
+};
+
+/* Ursa Minor */
+static ConFig _Ursa_Minor_figs[] = {
+    { 0,  4554,  5355},		/* move polaris */
+    { 1, 31566,  5195},		/* draw umi delta */
+    { 1, 30179,  4922},		/* draw umi epsilon */
+    { 1, 28321,  4667},		/* draw umi zeta */
+    { 1, 26721,  4449},		/* draw umi beta */
+    { 1, 27621,  4310},		/* draw umi gamma */
+    { 1, 29325,  4545},		/* draw umi eta */
+    { 1, 28321,  4667},		/* draw umi zeta */
+    {-1,     0,     0},
+};
+
+/* Vela */
+static ConFig _Vela_figs[] = {
+    { 0, 15741, -3282},		/* move delta */
+    { 1, 16863, -3300},		/* draw kappa */
+    { 1, 17905, -3274},		/* draw phi */
+    { 1, 19403, -2965},		/* draw mu */
+    { 1, 18442, -2527},		/* draw 10:14:44 -42:07:20 */
+    { 1, 17121, -2428},		/* draw psi */
+    { 1, 16439, -2605},		/* draw lambda */
+    { 1, 14684, -2840},		/* draw gamma1 */
+    { 1, 15741, -3282},		/* draw delta */
+    {-1,     0,     0},
+};
+
+/* Virgo */
+static ConFig _Virgo_figs[] = {
+    { 0, 26491,  -339},		/* move mu */
+    { 1, 25680,  -360},		/* draw iota */
+    { 1, 24155,  -669},		/* draw spica */
+    { 1, 22849,   -86},		/* draw gamma */
+    { 1, 22197,   -40},		/* draw eta */
+    { 1, 21320,   105},		/* draw beta */
+    { 1, 21175,   391},		/* draw nu */
+    { 1, 21756,   523},		/* draw omicron */
+    { 1, 22849,   -86},		/* draw gamma */
+    { 1, 23268,   203},		/* draw delta */
+    { 1, 23465,   657},		/* draw epsilon */
+    { 0, 23268,   203},		/* move delta */
+    { 1, 24440,   -35},		/* draw zeta */
+    { 1, 24155,  -669},		/* draw spica */
+    { 0, 24440,   -35},		/* move zeta */
+    { 1, 25249,    92},		/* draw tau */
+    { 1, 25680,  -360},		/* draw iota */
+    { 0, 25249,    92},		/* move tau */
+    { 1, 26587,   113},		/* draw 109 */
+    {-1,     0,     0},
+};
+
+/* Volans */
+static ConFig _Volans_figs[] = {
+    { 0, 16273, -3983},		/* move alpha */
+    { 1, 14994, -4290},		/* draw kappa1 */
+    { 1, 13854, -4356},		/* draw zeta */
+    { 1, 12861, -4229},		/* draw gamma1 */
+    { 1, 13104, -4077},		/* draw delta */
+    { 1, 14637, -4117},		/* draw epsilon */
+    { 1, 15172, -3968},		/* draw beta */
+    { 1, 16273, -3983},		/* draw alpha */
+    {-1,     0,     0},
+};
+
+/* Vulpecula */
+static ConFig _Vulpecula_figs[] = {
+    { 0, 35803,  1444},		/* move 13 */
+    { 2, 35061,  1479},		/* dotted alpha */
+    {-1,     0,     0},
+};
+
+
+static ConFig *figmap[NCNS] = {
+    _Andromeda_figs,
+    _Antlia_figs,
+    _Apus_figs,
+    _Aquila_figs,
+    _Aquarius_figs,
+    _Ara_figs,
+    _Aries_figs,
+    _Auriga_figs,
+    _Bootes_figs,
+    _Canis_Major_figs,
+    _Canis_Minor_figs,
+    _Canes_Venatici_figs,
+    _Caelum_figs,
+    _Camelopardalis_figs,
+    _Capricornus_figs,
+    _Carina_figs,
+    _Cassiopeia_figs,
+    _Centaurus_figs,
+    _Cepheus_figs,
+    _Cetus_figs,
+    _Chamaeleon_figs,
+    _Circinus_figs,
+    _Cancer_figs,
+    _Columba_figs,
+    _Coma_Berenices_figs,
+    _Corona_Australis_figs,
+    _Corona_Borealis_figs,
+    _Crater_figs,
+    _Crux_figs,
+    _Corvus_figs,
+    _Cygnus_figs,
+    _Delphinus_figs,
+    _Dorado_figs,
+    _Draco_figs,
+    _Equuleus_figs,
+    _Eridanus_figs,
+    _Fornax_figs,
+    _Gemini_figs,
+    _Grus_figs,
+    _Hercules_figs,
+    _Horologium_figs,
+    _Hydra_figs,
+    _Hydrus_figs,
+    _Indus_figs,
+    _Leo_Minor_figs,
+    _Lacerta_figs,
+    _Leo_figs,
+    _Lepus_figs,
+    _Libra_figs,
+    _Lupus_figs,
+    _Lynx_figs,
+    _Lyra_figs,
+    _Mensa_figs,
+    _Microscopium_figs,
+    _Monoceros_figs,
+    _Musca_figs,
+    _Norma_figs,
+    _Octans_figs,
+    _Ophiuchus_figs,
+    _Orion_figs,
+    _Pavo_figs,
+    _Pegasus_figs,
+    _Perseus_figs,
+    _Phoenix_figs,
+    _Pictor_figs,
+    _Piscis_Austrinus_figs,
+    _Pisces_figs,
+    _Puppis_figs,
+    _Pyxis_figs,
+    _Reticulum_figs,
+    _Sculptor_figs,
+    _Scorpius_figs,
+    _Scutum_figs,
+    _Serpens_Caput_figs,
+    _Sextans_figs,
+    _Sagitta_figs,
+    _Sagittarius_figs,
+    _Taurus_figs,
+    _Telescopium_figs,
+    _Triangulum_Australe_figs,
+    _Triangulum_figs,
+    _Tucana_figs,
+    _Ursa_Major_figs,
+    _Ursa_Minor_figs,
+    _Vela_figs,
+    _Virgo_figs,
+    _Volans_figs,
+    _Vulpecula_figs,
+    _Serpens_Cauda_figs,
+};
+
+/* given a constellation id and epoch, return arrays of ra[] and dec[]
+ *   end-points precessed to the desired epoch that, if connected, will form the
+ *   given constellation figure.
+ * dcodes is 0 if the coord is a "move-to", 1 if a "draw-to" or 2 if a "draw-to
+ *   as dotted-line".
+ * return the total number of tripples or -1 if id is bogus.
+ * the arrays need be no larger than 35 entries.
+ */
+int
+cns_figure (int id, double e, double ra[], double dec[], int dcodes[])
+{
+	ConFig *cfp;
+
+	if (id < 0 || id >= NCNS)
+	    return (-1);
+
+	for (cfp = figmap[id]; cfp->drawcode >= 0; cfp++) {
+	    *ra = hrrad((double)cfp->ra/1800.0);
+	    *dec = degrad((double)cfp->dec/60.0);
+	    precess (J2000, e, ra, dec);
+	    ra++;
+	    dec++;
+	    *dcodes++ = cfp->drawcode;
+	}
+
+	return (cfp - figmap[id]);
+}
+
+/*
+    Following figures changed to those created by H.A. Rey
+    (incorporated by Michael Mills):
+*/
+
+/* Andromeda */
+static ConFig _Andromeda_rey_figs[] = {
+  { 0,  3717,  2539}, /* gamma-1 */
+  { 1,  2904,  2484}, /* upsilon */
+  { 1,  2092,  2137}, /* Mirach */ 
+  { 1,  1180,  1851}, /* delta */ 
+  { 1,   251,  1745}, /* Alpheratz */
+  { 0,  2092,  2137}, /* Mirach */
+  { 1,  1702,  2309}, /* mu */
+  { 1,  1494,  2464}, /* nu */
+  { 1,  2085,  2834}, /* phi */
+  { 1,  2940,  2917}, /* 51 */
+  { 0,  1716,  1405}, /* eta */
+  { 1,  1420,  1456}, /* zeta */
+  { 1,  1156,  1758}, /* epsilon */
+  { 1,  1180,  1851}, /* delta */
+  { 1,  1106,  2023}, /* pi */
+  { 1,   513,  2320}, /* theta */ 
+  { 1, 42544,  2596}, /* iota */
+  { 1, 42612,  2660}, /* kappa */
+  { 1, 42527,  2787}, /* lambda */
+  { 0, 42544,  2596}, /* iota */
+  { 1, 41457,  2539}, /* omicron */
+  { 0,  1106,  2023}, /* pi */
+  { 1,  2092,  2137}, /* Mirach */ 
+  {-1,     0,     0},
+};
+
+/* Antlia - no change */
+
+/* Apus */
+static ConFig _Apus_rey_figs[] = {
+    { 0, 30092, -4651},
+    { 1, 29803, -4733},
+    { 1, 29410, -4721},
+    { 1, 26636, -4742},
+    { 0, 30092, -4651}, /* Aps Beta */
+    { 1, 29410, -4721}, /* Aps Delta1 */
+    {-1,     0,     0},
+};
+
+/* Aquarius */
+static ConFig _Aquarius_rey_figs[] = {
+  {0, 37430, -569}, /* Aqr Epsilon-2 */
+  {1, 37580, -539}, /* Aqr Mu-6 */
+  {1, 38088, -682}, /* Aqr Nu-13 */
+  {1, 38747, -334}, /* Sadalsud */
+  {1, 39774, -19}, /* Sadalmelik */
+  {1, 40250, -83}, /* Sadachbia */
+  {1, 40661, -7}, /* Aqr Eta-62 */
+  {1, 40358, 83}, /* Aqr Pi-52 */
+  {1, 39774, -19}, /* Sadalmelik */
+  {0, 39793, -832}, /* Aqr Iota-33 */
+  {1, 38747, -334}, /* Sadalsud */
+  {0, 39774, -19}, /* Sadalmelik */
+  {1, 40105, -467}, /* Aqr Theta-43 */
+  {1, 41178, -454}, /* Aqr Lambda-73 */
+  {1, 41830, -362}, /* Aqr Phi-90 */
+  {1, 41877, -545}, /* Aqr Psi1-91 */
+  {1, 41240, -949}, /* Skat */
+  {1, 41088, -815}, /* Aqr Tau2-71 */
+  {1, 41178, -454}, /* Aqr Lambda-73 */
+  {0, 41178, -454}, /* Aqr Lambda-73 */
+  {1, 41877, -545}, /* Aqr Psi1-91 */
+  {1, 42089, -1206}, /* Aqr 98 */
+  {1, 42181, -1238}, /* Aqr 99 */
+  {1, 42398, -1254}, /* Aqr 101 */
+  {0, 41877, -545}, /* Aqr Psi1-91 */
+  {1, 41683, -1270}, /* Aqr 88 */
+  {1, 41697, -1347}, /* Aqr 89 */
+  {1, 41600, -1424}, /* Aqr 86 */
+  {-1,     0,     0},
+};
+
+/* Aquila */
+static ConFig _Aquila_rey_figs[] = {
+  {0, 35859, 384}, /* Aql Beta-60 */
+  {1, 35724, 532}, /* Altair */
+  {1, 35588, 637}, /* Tarazed */
+  {1, 34965, 187}, /* Aql Delta-30 */
+  {1, 34387, -292}, /* Aql Lambda-16 */
+  {1, 34250, -344}, /* Aql 12 */
+  {0, 36339, -49}, /* Aql Theta-65 */
+  {1, 35774, 60}, /* Aql Eta-55 */
+  {1, 34965, 187}, /* Aql Delta-30 */
+  {1, 34362, 832}, /* Aql Zeta-17 */
+  {1, 34189, 904}, /* Aql Epsilo-13 */
+  {-1,     0,     0},
+};
+
+/* Ara */
+static ConFig _Ara_rey_figs[] = {
+  {0, 31555, -2992}, /* Ara Alpha */
+  {1, 30588, -3189}, /* Ara Epsilon1 */
+  {1, 30559, -3359}, /* Ara Zeta */
+  {1, 30294, -3542}, /* Ara Eta */
+  {1, 31533, -3641}, /* Ara Delta */
+  {1, 32599, -3005}, /* Ara Theta */
+  {1, 31555, -2992}, /* Ara Alpha */
+  {-1,     0,     0},
+};
+
+/* Aries */
+static ConFig _Aries_rey_figs[] = {
+  { 0,  5749,  1183}, /* delta */
+  { 1,  5376,  1280}, /* epsilon */
+  { 1,  5099,  1635}, /* 41 */
+  { 1,  5037,  1754}, /* 39 */
+  { 1,  4903,  1662}, /* 35 */
+  { 1,  3815,  1407}, /* Hamal */
+  { 1,  3439,  1248}, /* Sheratan */
+  { 1,  3537,  1415}, /* lambda */
+  { 1,  3815,  1407}, /* Hamal */
+  { 1,  3984,  1272}, /* eta */
+  { 0,  5376,  1280}, /* epsilon */  
+  { 1,  3984,  1272}, /* eta */
+  { 1,  3406,  1157}, /* gamma */
+  { 0,  5099,  1635}, /* 41 */
+  { 1,  4903,  1662}, /* 35 */
+  {-1,     0,     0},
+};
+
+/* Auriga */
+static ConFig _Auriga_rey_figs[] = {
+  { 0, 10786,  3257}, /* delta */
+  { 1, 10786,  2696}, /* Menkalinan */ 
+  { 1, 10791,  2232}, /* theta */ 
+  { 1,  8910,  1989}, /* iota */
+  { 1,  9195,  2474}, /* eta */
+  { 1,  9074,  2464}, /* zeta */
+  { 1,  9059,  2629}, /* epsilon */
+  { 1,  9500,  2759}, /* Capella */
+  { 1,  9195,  2474}, /* eta */
+  { 1, 10786,  2696}, /* Menkalinan */
+  { 0, 10786,  3257}, /* delta */
+  { 1,  9500,  2759}, /* Capella */
+  {-1,     0,     0},
+};
+
+/* Bootes */
+static ConFig _Bootes_rey_figs[] = {
+    { 0, 24818,  1047}, /* Tau */
+    { 1, 24884,   947}, /* Upsilon */
+    { 1, 25040,  1103}, /* Muphrid */
+    { 1, 25670,  1150}, /* Arcturus */
+    { 1, 26422,   985}, /* Pi */
+    { 1, 26549,  1624}, /* Pulcherrima */
+    { 1, 26240,   1784}, /* Sigma */
+    { 1, 26155,  1822}, /* Rho */
+    { 1, 26162,  2298}, /* Gamma  */
+    { 1, 27058,  2423}, /* Nekkar */
+    { 1, 27465,  1998}, /* Delta  */
+    { 0, 25670,  1150}, /* Arcturus */
+    { 1, 26549,  1624}, /* Pulcherrima */
+    { 1, 27465,  1998}, /* Delta  */
+    { 2, 27734,  2242}, /* Mu */
+    { 2, 27058,  2423}, /* Nekkar */
+    { 0, 26162,  2298}, /* Gamma  */
+    { 1, 25691,  2765}, /* Lambda */
+    { 1, 25604,  3107}, /* Kappa2 */
+    { 1, 25956,  3111}, /* Theta */
+    { 1, 25691,  2765}, /* Lambda */
+    {-1,     0,     0}, 
+};
+
+/* Caelum - no change */
+
+/* Camelopardalis */
+static ConFig _Camelopardalis_rey_figs[] = {
+  {0,  8919, 3225}, /* Cam 7 */
+  {1,  9103, 3627}, /* Cam Beta-10 */
+  {1,  8822, 3981}, /* Cam Alpha-9 */
+  {1,  6911, 4280}, /* Cam Gamma */
+  {1,  6886, 3932}, /* From GSC */
+  {1,  6272, 3596}, /* From GSC */
+  {0,  8822, 3981}, /* Cam Alpha-9 */
+  {1, 12602, 4619}, /*  */
+  {1, 12016, 4305}, /*  */
+  {0,  9103, 3627}, /* Cam Beta-10 */
+  {1,  6886, 3932}, /* From GSC */
+  {-1,     0,     0},
+};
+
+/* Cancer */
+static ConFig _Cancer_rey_figs[] = {
+  {0, 16432, 640}, /* Cnc Kappa-76 */
+  {1, 15741, 1089}, /* Cnc Delta-47 */
+  {1, 14895, 551}, /* Cnc Beta-17 */
+  {1, 14633, 1295}, /* Cnc Mu2-10 */
+  {1, 15699, 1288}, /* Cnc Gamma-43 */
+  {1, 15741, 1089}, /* Cnc Delta-47 */
+  {0, 15699, 1288}, /* Cnc Gamma-43 */
+  {1, 15801, 1726}, /* Cnc Iota-48 */
+  {-1,     0,     0},
+};
+
+/* Canes Venatici - no change */
+
+/* Canis Major */
+static ConFig _Canis_Major_rey_figs[] = {
+  {0, 13323, -1758}, /* CMa Eta-31 */
+  {1, 13044, -1606}, /* CMa Omega-28 */
+  {1, 12852, -1583}, /* CMa Delta-25 */
+  {1, 12691, -1430}, /* CMa Omicr2-24 */
+  {1, 12154, -1002}, /* Sirius */
+  {1, 12484, -1023}, /* CMa Iota-20 */
+  {1, 12713, -938}, /* CMa Gamma-23 */
+  {1, 12426, -722}, /* CMa Theta-14 */
+  {1, 12484, -1023}, /* CMa Iota-20 */
+  {0, 12852, -1583}, /* CMa Delta-25 */
+  {1, 12652, -1676}, /* CMa Sigma-22 */
+  {1, 12559, -1738}, /* Adara */
+  {1, 12295, -1950}, /* CMa Kappa-13 */
+  {0, 11409, -1803}, /* CMa Zeta-1 */
+  {1, 12559, -1738}, /* Adara */
+  {1, 12424, -1451}, /* CMa Omicr1-16 */
+  {1, 11901, -1155}, /* CMa Nu2-7 */
+  {1, 12154, -1002}, /* Sirius */
+  {0 , 11756, -1405}, /* CMa Xi1-4 */
+  {1, 11901, -1155}, /* CMa Nu2-7 */
+  {1, 11481, -1077}, /* Mirzam */
+  {-1,     0,     0},
+};
+
+/* Capricornus */
+static ConFig _Capricornus_rey_figs[] = {
+  {0, 36542, -752}, /* Cap Alpha2-6 */
+  {1, 36630, -886}, /* Cap Beta-9 */
+  {1, 36866, -1068}, /* Cap Rho-11 */
+  {1, 37383, -1516}, /* Cap Psi-16 */
+  {1, 37555, -1615}, /* Cap Omega-18 */
+  {0, 36866, -1068}, /* Cap Rho-11 */
+  {1, 37932, -1191}, /* Cap Eta-22 */
+  {0, 38014, -1500}, /* Cap 24 */
+  {1, 37932, -1191}, /* Cap Eta-22 */
+  {1, 37978, -1033}, /* Cap Theta-23 */
+  {1, 38600, -1344}, /* Cap Zeta-34 */
+  {1, 38662, -1308}, /* Cap 36 */
+  {1, 38467, -1010}, /* Cap Iota-32 */
+  {0, 39211, -967}, /* Deneb Algiedi */
+  {1, 39003, -999}, /* Cap Gamma-40 */
+  {1, 38467, -1010}, /* Cap Iota-32 */
+  {1, 37978, -1033}, /* Cap Theta-23 */
+  {1, 36630, -886}, /* Cap Beta-9 */
+  {-1,     0,     0},
+};
+
+/* Carina */
+static ConFig _Carina_rey_figs[] = {
+  {0, 11519, -3161}, /* Canopus */
+  {1, 16596, -4183}, /* Car Beta */
+  {1, 18412, -4202}, /* Car Omega */
+  {1, 19289, -3863}, /* Car Theta */
+  /* Figurehead follows, made up of stars not present in YBS */
+  {1, 18961, -3701}, /* GSC star */
+  {1, 19306, -3634},
+  {1, 19601, -3534},
+  {1, 19003, -3491},
+  {1, 18836, -3524},
+  {1, 18512, -3680},
+  {1, 16713, -3556}, /* Car Iota */
+  {1, 15075, -3570}, /* Car Epsilon */
+  {1, 14303, -3178}, /* Car Chi */
+  {1, 14686, -2840}, /* Vel Gamma2 */
+  {0, 19601, -3534}, 
+  {1, 20058, -3539}, /* "Nose" of figurehead */
+  {0, 15075, -3570}, /* Car Epsilon */
+  {2, 16863, -3300}, /* Vel Kappa */
+  {0, 16713, -3556}, /* Car Iota */
+  {2, 15741, -3282}, /* Vel Delta */
+  {-1,     0,     0},
+};
+
+/* Cassiopeia */
+static ConFig _Cassiopeia_rey_figs[] = {
+  {0,  275, 3549}, /* Caph */
+  {1, 1215, 3392}, /* Schedar */
+  {1, 1701, 3643}, /* Cas Gamma-27 */
+  {1, 2575, 3614}, /* Cas Delta-37 */
+  {1, 3432, 3820}, /* Cas Epsilo-45 */
+  {1, 3703, 4345}, /* Cas 50 */
+  {-1,     0,     0},
+};
+
+/* Centaurus */
+static ConFig _Centaurus_rey_figs[] = {
+  {0, 20873, -3781}, /* Cen Lambda */
+  {1, 21950, -3142}, /* Cen Rho */
+  {1, 22441, -3013}, /* Cen Sigma */
+  {1, 21851, -3043}, /* Cen Delta */
+  {1, 20430, -3269}, /* Cen Pi */
+  {0, 22441, -3013}, /* Cen Sigma */
+  {1, 22846, -2937}, /* Cen Gamma */
+  {1, 24597, -3207}, /* Cen Epsilon */
+  {1, 25066, -2837}, /* Cen Zeta */
+  {1, 22846, -2937}, /* Cen Gamma */
+  {0, 26388, -3650}, /* Rigil Kentaurus */
+  {1, 24597, -3207}, /* Cen Epsilon */
+  {1, 25315, -3622}, /* Hadar (Agena) */
+  {0, 25066, -2837}, /* Cen Zeta */
+  {1, 25252, -2736}, /* Cen Upsilon2 */
+  {1, 25160, -2688}, /* Cen Upsilon1 */
+  {1, 25148, -2526}, /* Cen Phi */
+  {1, 24885, -2501}, /* Cen Nu */
+  {1, 24889, -2548}, /* Cen Mu */
+  {1, 25066, -2837}, /* Cen Zeta */
+  {0, 24885, -2501}, /* Cen Nu */
+  {1, 25401, -2182}, /* Cen Theta-5 */
+  {1, 25817, -2273}, /* Cen Psi */
+  {1, 25891, -2371}, /* From GSC 7809-2783 */
+  {1, 25381, -2470}, /* Cen Chi */
+  {1, 25148, -2526}, /* Cen Phi */
+  {1, 26265, -2529}, /* Cen Eta */
+  {1, 26975, -2526}, /* Cen Kappa */
+  {1, 26459, -2268}, /* From GSC */
+  {1, 26510, -2110}, /* From GSC */
+  {0, 24885, -2501}, /* Cen Nu */
+  {1, 24331, -2364}, /* From GSC */
+  {1, 24018, -2202}, /* Cen Iota */
+  {1, 24771, -1982}, /* Cen 1 */
+  {0, 24771, -1982}, /* Cen 1 */
+  {1, 24883, -2067}, /* Cen 2 */
+  {0, 24771, -1982}, /* Cen 1 */
+  {1, 24955, -1979}, /* Cen 3 */
+  {0, 24771, -1982}, /* Cen 1 */
+  {1, 24996, -1915}, /* Cen 4 */
+  {-1,     0,     0},
+};
+
+/* Cepheus */
+static ConFig _Cepheus_rey_figs[] = {
+  {0, 36887, 3780}, /* Cep Theta-2 */
+  {1, 37359, 3710}, /* Cep Eta-3 */
+  {1, 38357, 3755}, /* Alderamin */
+  {1, 38660, 4234}, /* Alphirk */
+  {1, 42580, 4658}, /* Alrai */
+  {1, 41090, 3972}, /* Cep Iota-32 */
+  {1, 40475, 3505}, /* Cep Delta-27 */
+  {1, 39926, 3492}, /* Cep Zeta-21 */
+  {1, 40051, 3423}, /* Cep Epsilo-23 */
+  {1, 39105, 3527}, /* Cep Mu */
+  {1, 38357, 3755}, /* Alderamin */
+  {0, 38660, 4234}, /* Alphirk */
+  {1, 41090, 3972}, /* Cep Iota-32 */
+  {0, 39926, 3492}, /* Cep Zeta-21 */
+  {1, 39163, 3667}, /* Cep Nu-10 */
+  {-1,     0,     0}, 
+};
+
+/* Cetus */
+static ConFig _Cetus_rey_figs[] = {
+  {0, 583, -529}, /* Cet Iota-8 */
+  {1, 2521, -491}, /* Cet Theta-45 */
+  {1, 4180, -178}, /* Mira */
+  {1, 4785, 20}, /* Cet Delta-82 */
+  {1, 4899, 194}, /* Cet Gamma-86 */
+  {1, 4676, 336}, /* Cet Nu-78 */
+  {1, 4445, 508}, /* Cet Xi2-73 */
+  {1, 4948, 607}, /* Cet Mu-87 */
+  {1, 5391, 534}, /* Cet Lambda-91 */
+  {1, 5468, 245}, /* Mekab */
+  {1, 4899, 194}, /* Cet Gamma-86 */
+  {0, 4785, 20}, /* Cet Delta-82 */
+  {1, 3600, -1264}, /* Cet Upsilo-59 */
+  {1, 1308, -1079}, /* Diphda */
+  {1, 583, -529}, /* Cet Iota-8 */
+  {0, 1308, -1079}, /* Diphda */
+  {1, 3122, -956}, /* Cet Tau-52 */
+  {-1,     0,     0},
+};
+
+/* Chamaeleon */
+static ConFig _Chamaeleon_rey_figs[] = {
+  {0, 14956, -4615}, /* Cha Alpha */
+  {1, 19064, -4716}, /* Cha Gamma */
+  {1, 21589, -4693}, /* Cha Epsilon */
+  {1, 22150, -4758}, /* Cha Beta */
+  {1, 19373, -4832}, /* Cha Delta2 */
+  {1, 19064, -4716}, /* Cha Gamma */
+  {-1,     0,     0},
+};
+
+/* Circinus - no change */
+
+/* Columba */
+static ConFig _Columba_rey_figs[] = {
+    { 0,  9936, -2128},
+    { 1, 10189, -2044},
+    { 1, 10529, -2146},
+    { 1, 10726, -2117},
+    { 1, 11296, -2108},
+    { 1, 11463, -2006},
+    { 0, 10529, -2146},
+    { 1, 10774, -2568},
+    { 0, 10774, -2568}, /* Col Eta */
+    { 1, 10726, -2117}, /* Col Gamma */
+    { 1, 11463, -2006}, /* Col Delta */
+    {-1,     0,     0},
+};
+
+/* Coma Berenices */
+static ConFig _Coma_Berenices_rey_figs[] = {
+    { 0, 23699,  1051}, /* Alpha */
+    { 1, 23756,  1672}, /* Beta */
+    { 1, 22408,  1696}, /* Gamma */
+    { 0, 23756,  1672}, /* Beta */
+    { 2, 22090,  1436}, /* Com 7 */
+    { 0, 23756,  1672}, /* Beta */
+    { 2, 22275,  1550}, /* Com 12 */
+    { 0, 23756,  1672}, /* Beta */
+    { 2, 22392,  1636}, /* Com 14 */
+    {-1,     0,     0},
+};
+
+/* Corona Australis - no change */
+
+/* Corona Borealis - no change */
+
+/* Corvus */
+static ConFig _Corvus_rey_figs[] = {
+  {0, 21852, -1483}, /* Crv Alpha-1 */
+  {1, 21904, -1357}, /* Crv Epsilon-2 */
+  {1, 22217, -1332}, /* Crv Zeta-5 */
+  {1, 22632, -1403}, /* Crv Beta-9 */
+  {0, 22217, -1332}, /* Crv Zeta-5 */
+  {1, 22496, -990}, /* Crv Delta-7 */
+  {1, 22562, -971}, /* Crv Eta-8 */
+  {0, 22496, -990}, /* Crv Delta-7 */
+  {1, 22074, -1052}, /* Crv Gamma-4 */
+  {1, 21904, -1357}, /* Crv Epsilon-2 */
+  {-1,     0,     0},
+};
+
+/* Crater */
+static ConFig _Crater_rey_figs[] = {
+  {0, 19793, -1097}, /* Crt Alpha-7 */
+  {1, 20380, -886}, /* Crt Delta-12 */
+  {1, 20546, -1061}, /* Crt Gamma-15 */
+  {1, 21143, -1101}, /* Crt Zeta-27 */
+  {1, 21480, -1029}, /* Crt Eta-30 */
+  {1, 20900, -588}, /* Crt Theta-21 */
+  {1, 20538, -651}, /* Crt Epsilo-14 */
+  {1, 20380, -886}, /* Crt Delta-12 */
+  {0, 20546, -1061}, /* Crt Gamma-15 */
+  {1, 20150, -1369}, /* Crt Beta-11 */
+  {-1,     0,     0},
+};
+
+/* Crux - no change */
+
+/* Cygnus */
+static ConFig _Cygnus_rey_figs[] = {
+    { 0, 34713,  3202}, /* Kappa */
+    { 2, 35549,  2707}, /* Delta */
+    { 1, 36667,  2415}, /* Gamma */
+    { 1, 37386,  2038}, /* Epsilon */
+    { 2, 38188,  1813}, /* Zeta  */
+    /*   { 2, 39124,  1724},*/ /* 78    */
+    { 2, 37715,  2470}, /* Nu    */
+    { 2, 37243,  2716}, /* Deneb */
+    { 2, 36464,  2863}, /* 32    */
+    { 2, 35091,  3103}, /* Iota  */
+    { 2, 34713,  3202}, /* Kappa */
+    /* { 0, 38188,  1813}, */ /* Zeta  */
+    /* { 2, 35293,  3013}, */ /* Theta */
+    /* { 2, 38337,  2093}, */ /* Upsilon */
+    { 0, 38243,  2282}, /* Tau   */
+    { 2, 38322,  2363}, /* Sigma  */
+    { 2, 37715,  2470}, /* Nu    */
+    /* { 2, 38819,  2735}, */ /* Rho   */
+    /* { 2, 39204,  2958}, */ /* Pi    */
+    { 0, 37243,  2716}, /* Deneb */
+    { 2, 37948,  2636}, /* Xi    */
+    { 0, 37243,  2716}, /* Deneb */
+    { 1, 36667,  2415}, /* Gamma */
+    { 1, 35889,  2105}, /* Eta */
+    { 1, 35381,  1809}, /* Phi */
+    { 1, 35121,  1677}, /* Albireo */
+    {-1,     0,     0}, /*  */
+};
+
+/* Delphinus */
+static ConFig _Delphinus_rey_figs[] = {
+  {0, 37135, 683}, /* Del Iota-5 */
+  {1, 36996, 678}, /* Del Epsilon-2 */
+  {1, 37174, 605}, /* Del Kappa-7 */
+  {1, 37135, 683}, /* Del Iota-5 */
+  {1, 37019, 782}, /* Del Eta-3 */
+  {1, 37127, 876}, /* Rotanev */
+  {1, 37189, 955}, /* Svalocin */
+  {1, 37400, 967}, /* Del Gamma2-12 */
+  {1, 37304, 904}, /* Del Delta-11 */
+  {1, 37162, 799}, /* Del Theta-8 */
+  {1, 37135, 683}, /* Del Iota-5 */
+  {0, 37127, 876}, /* Rotanev */
+  {1, 37059, 880}, /* Del Zeta-4 */
+  {-1,     0,     0},
+};
+
+/* Dorado */
+static ConFig _Dorado_rey_figs[] = {
+    { 0,  7681, -3089},
+    { 1,  8220, -3302},
+    { 1,  9165, -3448},
+    { 1, 10009, -3749},
+    { 1, 10343, -3944},
+    { 0, 10009, -3749},
+    { 1, 10623, -3785},
+    { 1, 10343, -3944}, /* Back to Dor Delta */
+    { 0, 10009, -3749}, /* Dor Beta */
+    { 1,  8220, -3302}, /* Dor Alpha */
+    {-1,     0,     0},
+};
+
+/* Draco */
+static ConFig _Draco_rey_figs[] = {
+  {0, 20742, 4160}, /* Dra Lambda-1 */
+  {1, 22605, 4187}, /* Dra Kappa-5 */
+  {1, 25332, 3863}, /* Thuban */
+  {1, 27748, 3538}, /* Dra Iota-12 */
+  {1, 28857, 3514}, /* Dra Theta-13 */
+  {1, 29520, 3691}, /* Dra Eta-14 */
+  {1, 30864, 3943}, /* Dra Zeta-22 */
+  {1, 33023, 4280}, /* Dra Phi-43 */
+  {1, 34577, 4060}, /* Dra Delta-57 */
+  {1, 32206, 3412}, /* Dra Xi-32 */
+  {1, 31568, 3310}, /* Dra Nu2-25 */
+  {1, 31513, 3138}, /* Alwaid */
+  {1, 32298, 3089}, /* Rastaban */
+  {1, 32206, 3412}, /* Dra Xi-32 */
+  {0, 33023, 4280}, /* Dra Phi-43 */
+  {1, 33032, 4364}, /* Dra Chi-44 */
+  {0, 34577, 4060}, /* Dra Delta-57 */
+  {1, 35645, 4216}, /* Dra Epsilo-63 */
+  {-1,     0,     0},
+};
+
+/* Equuleus */
+static ConFig _Equuleus_rey_figs[] = {
+    { 0, 38110,   607},
+    { 1, 38234,   600},
+    /*    { 1, 38487,   408}, */
+    { 1, 38274,   314},
+    {-1,     0,     0},
+};
+
+/* Eridanus */
+static ConFig _Eridanus_rey_figs[] = {
+  {0, 8345, -858}, /* Eri 53 */
+  {1, 9236, -305}, /* Cursa */
+  {1, 8565, -195}, /* Eri Mu-57 */
+  {1, 8290, -201}, /* Eri Nu-48 */
+  {1, 7556, -410}, /* Eri Omicr1-38 */
+  {1, 7658, -459}, /* Eri Omicr2-40 */
+  {1, 7141, -810}, /* Zaurak */
+  {1, 6697, -585}, /* Eri Delta-23 */
+  {1, 6388, -567}, /* Eri Epsilo-18 */
+  {1, 5293, -533}, /* Eri Eta-3 */
+  {1, 5472, -1417}, /* Eri Tau3-11 */
+  {1, 5986, -1305}, /* Eri Tau4-16 */
+  {1, 6414, -1297}, /* Eri Tau5-19 */
+  {1, 6805, -1394}, /* Eri Tau6-27 */
+  {1, 8267, -1833}, /* Eri Upsil2-52 */
+  {1, 7921, -2041}, /* Eri 43 */
+  {1, 7737, -2027}, /* Eri Upsil4-41 */
+  {1, 7737, -2027}, /* Eri Upsil4-41 */
+  {1, 6227, -2140}, /* Fornax Chi2 */
+  {1, 5348, -2418}, /* Eri Theta1 */
+  {1, 5207, -2306}, /* For Psi */
+  {1, 4820, -2391}, /* Eri Iota */
+  {1, 4410, -2862}, /* Eri Kappa */
+  {1, 4095, -3090}, /* Eri Phi */
+  {1, 3479, -3096}, /* Eri Chi */
+  {1, 2931, -3434}, /* Achernar */
+  {-1,     0,     0},
+};
+
+/* Gemini */
+static ConFig _Gemini_rey_figs[] = {
+  { 0, 10923,  1395}, /* 1 */ 
+  { 1, 11246,  1350}, /* eta */
+  { 1, 11489,  1350}, /* mu */
+  { 1, 12118,  1507}, /* Mebsuta */
+  { 1, 12934,  1814}, /* tau */
+  { 1, 13473,  1907}, /* rho */
+  { 1, 13638,  1913}, /* Castor */
+  { 0, 13899,  1733}, /* sigma */
+  { 0, 13959,  1681}, /* Pollux */ 
+  { 1, 13678,  1613}, /* upsilon */
+  { 1, 13203,  1318}, /* Wasat */
+  { 1, 12723,  1234}, /* zeta */
+  { 1, 11931,   983}, /* gamma */
+  { 0, 11669,  1212}, /* nu */
+  { 1, 12118,  1507}, /* Mebsuta */
+  { 0, 11931,   983}, /* gamma */
+  { 0, 13203,  1318}, /* Wasat */
+  { 1, 13143,   992}, /* lambda */
+  { 1, 12159,   773}, /* Xi */
+  { 0, 13933,  1463}, /* kappa */
+  { 1, 13678,  1613}, /* upsilon */
+  { 1, 13372,  1667}, /* iota */
+  { 1, 12934,  1814}, /* tau */
+  { 1, 12383,  2037}, /* theta */
+  {-1,     0,     0},
+};
+
+/* Grus */
+static ConFig _Grus_rey_figs[] = {
+  {0, 39418, -2241}, /* Gru Gamma */
+  {1, 39783, -2372}, /* Gru Lambda */
+  {1, 39847, -2817}, /* Gru Alpha */
+  {1, 40880, -2813}, /* Gru Beta */
+  {1, 41711, -2714}, /* Gru Iota */
+  {1, 41606, -2611}, /* Gru Theta */
+  {1, 40478, -2609}, /* Gru Delta1 */
+  {1, 39847, -2817}, /* Gru Alpha */
+  {0, 41057, -3079}, /* Gru Epsilon */
+  {1, 40880, -2813}, /* Gru Beta */
+  {1, 41426, -3165}, /* Gru Zeta */
+  {-1,     0,     0},
+};
+
+/* Hercules */
+static ConFig _Hercules_rey_figs[] = {
+  { 0, 29457,  1149}, /* gamma */
+  { 1, 29706,  1289}, /* Kornephoros */
+  { 1, 30608,  1855}, /* epsilon */
+  { 1, 31051,  2208}, /* pi */
+  { 1, 31310,  2228}, /* rho */
+  { 1, 32287,  2235}, /* theta */
+  { 1, 31784,  2760}, /* iota */
+  { 1, 29823,  2546}, /* Sigma */
+  { 1, 29063,  2696}, /* Phi */
+  { 1, 29392,  2779}, /* Tau */
+  { 1, 31784,  2760}, /* iota */
+  { 0, 31994,  1663}, /* mu */ 
+  { 1, 31521,  1566}, /* lambda */
+  { 1, 31050,  1490}, /* delta */
+  { 1, 31039,   863}, /* alpha */
+  { 0, 33810,  1090}, /* 111 */
+  { 1, 33770,  1232}, /* 110 */
+  { 1, 33111,  1306}, /* 109 */
+  { 1, 32663,  1248}, /* 102 */
+  { 1, 32445,  1296}, /*  95 */
+  { 1, 32626,  1725}, /* omicron */
+  { 1, 32333,  1754}, /* xi */ 
+  { 1, 31051,  2208}, /* pi */
+  { 1, 30087,  2335}, /* eta */
+  { 1, 30038,  1896}, /* zeta */
+  { 1, 30608,  1855}, /* epsilon */
+  { 1, 31994,  1663}, /* mu */ 
+  { 1, 32333,  1754}, /* xi */ 
+
+  {-1,     0,     0}, 
+};
+
+/* Horologium - no change */
+
+/* Hydra */
+static ConFig _Hydra_rey_figs[] = {
+  {0, 16062, 357}, /* Hya Zeta-16 */
+  {1, 15803, 385}, /* Hya Epsilo-11 */
+  {1, 15530, 342}, /* Hya Delta-4 */
+  {1, 15563, 200}, /* Hya Sigma-5 */
+  {1, 15697, 204}, /* Hya Eta-7 */
+  {1, 16062, 357}, /* Hya Zeta-16 */
+  {1, 16631, 139}, /* Hya Theta-22 */
+  {1, 17396, -68}, /* Hya Iota-35 */
+  {1, 17028, -519}, /* Hya Alpha-30 */
+  {1, 18318, -741}, /* Hya Lambda-41 */
+  {1, 18783, -1010}, /* Hya Mu-42 */
+  {1, 19489, -971}, /* Hya Nu */
+  {1, 19793, -1097}, /* Crt Alpha-7 */
+  {1, 20150, -1369}, /* Crt Beta-11 */
+  {1, 20790, -1911}, /* Hya Xi */
+  {1, 21387, -2034}, /* Hya Beta */
+  {1, 23968, -1390}, /* Hya Gamma-46 */
+  {1, 25391, -1600}, /* Hya Pi-49 */
+  {-1,     0,     0},
+};
+
+/* Hydrus */
+static ConFig _Hydrus_rey_figs[] = {
+    { 0,   773, -4635},
+    { 1,  6817, -4454},
+    { 1,  4788, -4096},
+    { 1,  4252, -4119},
+    { 1,  3448, -4058},
+    { 1,  3563, -3694},
+    {-1,     0,     0},
+};
+
+/* Indus */
+static ConFig _Indus_rey_figs[] = {
+  {0, 37127, -2837}, /* Ind Alpha */
+  {1, 37321, -3115}, /* Ind Eta */
+  {1, 37644, -3507}, /* Ind Beta */
+  {1, 39538, -3299}, /* Ind Delta */
+  {0, 39701, -3407}, /* Ind Epsilon */
+  {1, 37644, -3507}, /* Ind Beta */
+  {-1,     0,     0},
+};
+
+/* Lacerta */
+static ConFig _Lacerta_rey_figs[] = {
+  {0, 40079, 2265}, /* Lac 1 */
+  {1, 40515, 2587}, /* Lac 6 */
+  {1, 40815, 2657}, /* Lac 11 */
+  {1, 40486, 2862}, /* Lac 5 */
+  {1, 40336, 2969}, /* Lac 4 */
+  {1, 40307, 3134}, /* Lac Beta-3 */
+  {1, 40539, 3017}, /* Lac Alpha-7 */
+  {1, 40486, 2862}, /* Lac 5 */
+  {1, 40231, 2792}, /* Lac 2 */
+  {1, 40515, 2587}, /* Lac 6 */
+  {-1,     0,     0},
+  /* Old Figure Follows
+   *    { 0, 40079,  2264},
+   *    { 1, 40514,  2587},
+   *    { 1, 40486,  2862},
+   *    { 1, 40335,  2968},
+   *    { 1, 40307,  3133},
+   *    { 1, 40538,  3016},
+   *    { 1, 40486,  2862}, */
+
+};
+
+/* Leo */
+static ConFig _Leo_rey_figs[] = {
+    { 0, 16939,  1570},
+    { 1, 17151,  1378},
+    { 1, 17575,  1426},
+    { 1, 17783,  1560},
+    { 1, 16939,  1570}, /* Finish going around head */
+    { 0, 17783,  1560},
+    { 1, 18500,  1405},
+    { 1, 18599,  1190},
+    { 1, 18220,  1005},
+    { 1, 18251,   718}, /* Regulus */
+    { 0, 17575,  1426}, /* Draw  */
+    { 1, 18220,  1005}, /* Front of neck */
+    { 1, 17434,   593}, /* and forward front leg */
+    { 0, 18220,  1005}, /* eta */
+    /*{ 0, 18251,   718},  Regulus */ 
+    { 1, 20227,   925}, /* theta */
+    { 1, 20223,  1231}, /* Zozca */
+    { 0, 21272,   874}, /* Denebola */
+    { 1, 20223,  1231}, /* Zozca */
+    { 1, 19870,  1210}, /* 60 */
+    { 1, 18599,  1190}, /* Gamma */
+    { 0, 20227,   925}, /* theta */
+    { 1, 20517,   631}, /* iota */
+    { 1, 20434,   361}, /* sigma */
+    { 0, 20227,   925}, /* theta */
+    { 1, 18984,   558},
+    {-1,     0,     0},
+};
+
+/* Leo Minor */
+static ConFig _Leo_Minor_rey_figs[] = {
+  {0, 18223, 2115}, /* LMi 21 */
+  {1, 18777, 2028}, /* LMi 30 */
+  {1, 19599, 2053}, /* LMi 46 */
+  {1, 18837, 2202}, /* LMi Beta-31 */
+  {1, 18223, 2115}, /* LMi 21 */
+  {1, 17227, 2184}, /* LMi 10 */
+  {-1,     0,     0},
+};
+
+/* Lepus */
+static ConFig _Lepus_rey_figs[] = {
+  {0, 9397, -776}, /* Lep Kappa-4 */
+  {1, 9388, -972}, /* Lep Mu-5 */
+  {1, 9164, -1342}, /* Lep Epsilon-2 */
+  {1, 9847, -1245}, /* Lep Beta-9 */
+  {1, 9982, -1069}, /* Arneb */
+  {1, 10409, -889}, /* Lep Zeta-14 */
+  {1, 10692, -850}, /* Lep Eta-16 */
+  {1, 10540, -1252}, /* Lep Delta-15 */
+  {1, 10334, -1346}, /* Lep Gamma-13 */
+  {1, 9847, -1245}, /* Lep Beta-9 */
+  {0, 9982, -1069}, /* Arneb */
+  {1, 9388, -972}, /* Lep Mu-5 */
+  {1, 9587, -790}, /* Lep Lambda-6 */
+  {-1,     0,     0},
+};
+
+/* Libra */
+static ConFig _Libra_rey_figs[] = {
+  {0, 28160, -1786}, /* Lib Tau-40 */
+  {1, 28111, -1688}, /* Lib Upsilo-39 */
+  {1, 28066, -887}, /* Zuben el Hakrabi */
+  {1, 27510, -562}, /* Zuben el Chamali */
+  {1, 26726, -962}, /* Lib Alpha2-9 */
+  {1, 27122, -1516}, /* Lib Sigma-20 */
+  {0, 28066, -887}, /* Zuben el Hakrabi */
+  {1, 26726, -962}, /* Lib Alpha2-9 */
+  {-1,     0,     0},
+};
+
+/* Lupus */
+static ConFig _Lupus_rey_figs[] = {
+  {0, 28998, -2208}, /* Lup Theta */
+  {1, 28529, -2017}, /* Lup Chi-5 */
+  {1, 28193, -2064}, /* Lup Psi1-3 */
+  {1, 27654, -2175}, /* Lup Phi1 */
+  {1, 28804, -2303}, /* Lup Eta */
+  {0, 27654, -2175}, /* Lup Phi1 */
+  {1, 26956, -2588}, /* Lup Beta */
+  {1, 26458, -2843}, /* Lup Alpha */
+  {1, 26337, -2965}, /* Lup Rho */
+  {1, 27154, -2823}, /* Lup Pi */
+  {1, 27265, -2716}, /* Lup Lambda */
+  {1, 27641, -2438}, /* Lup Delta */
+  {1, 27742, -2382}, /* Lup Upsilon */
+  {1, 27695, -2211}, /* Lup Phi2 */
+  {1, 27654, -2175}, /* Lup Phi1 */
+  {0, 26337, -2965}, /* Lup Rho */
+  {1, 26178, -3027}, /* Lup Sigma */
+  {0, 27154, -2823}, /* Lup Pi */
+  {1, 27358, -2924}, /* Lup Kappa1 */
+  {1, 27369, -3125}, /* Lup Zeta */
+  {0, 27265, -2716}, /* Lup Lambda */
+  {1, 27556, -2872}, /* Lup Mu */
+  {1, 27680, -2681}, /* Lup Epsilon */
+  {0, 27742, -2382}, /* Lup Upsilon */
+  {1, 28054, -2470}, /* Lup Gamma */
+  {1, 28142, -2554}, /* Lup Omega */
+  {1, 28236, -2680}, /*  */
+  {0, 25985, -2722}, /* Lup Tau2 */
+  {1, 26458, -2843}, /* Lup Alpha */
+  {1, 25782, -2763}, /* Lup Iota */
+  {-1,     0,     0},
+};
+
+/* Lynx - no change */
+
+/* Lyra */
+static ConFig _Lyra_rey_figs[] = {
+  {0, 33508, 2327}, /* Vega */
+  {1, 32996, 2164}, /* Lyr Kappa-1 */
+  {1, 33902, 2002}, /* Sheliak */
+  {1, 34168, 1961}, /* Sulaphat */
+  {1, 34691, 2288}, /* Lyr Theta-21 */
+  {1, 34613, 2349}, /* Lyr Eta-20 */
+  {1, 34060, 2637}, /* Lyr 13 */
+  {1, 33730, 2380}, /* Lyr Epsilo1-4 */
+  {2, 33508, 2327}, /* Vega */
+  {0, 33743, 2256}, /* Lyr Zeta1-6 */
+  {1, 33902, 2002}, /* Sheliak */
+  {0, 34012, 2218}, /* Lyr Delta1-11 */
+  {1, 34168, 1961}, /* Sulaphat */
+  {-1,     0,     0},
+    /* Old Figure follows
+     * { 0, 34060,  2636}, 
+     *  { 1, 34613,  2348},
+     *  { 1, 34691,  2288},
+     *  { 1, 33508,  2327},
+     *  { 1, 33730,  2380},
+     *  { 0, 33508,  2327},
+     *  { 1, 33743,  2256},
+     *  { 1, 33902,  2001},
+     *  { 1, 34168,  1961},
+     *  { 1, 34012,  2218},
+     *  { 1, 33743,  2256},
+     *  { 0, 33508,  2327},
+     *  { 1, 32996,  2163}, */
+};
+
+/* Mensa - no change */
+
+/* Microscopium - no change */
+
+/* Monoceros */
+static ConFig _Monoceros_rey_figs[] = {
+  {0, 12029, 594}, /* Mon 15 */
+  {1, 11787, 440}, /* Mon 13 */
+  {1, 11513, 276}, /* Mon Epsilon-8 */
+  {1, 12236, 145}, /* Mon 18 */
+  {1, 11787, 440}, /* Mon 13 */
+  {0, 12236, 145}, /* Mon 18 */
+  {1, 12956, -29}, /* Mon Delta-22 */
+  {1, 11665, -422}, /* Mon Beta-11 */
+  {1, 11246, -376}, /* Mon Gamma-5 */
+  {0, 12956, -29}, /* Mon Delta-22 */
+  {1, 14437, -83}, /* Mon 28 */
+  {1, 14658, -179}, /* Mon Zeta-29 */
+  {0, 14437, -83}, /* Mon 28 */
+  {1, 13837, -573}, /* Mon Alpha-26 */
+  {-1,     0,     0},
+  /* Old figure follows
+   *    { 0, 14657,  -179},
+   *    { 1, 13837,  -573},
+   *    { 1, 12956,   -29},
+   *    { 1, 11664,  -421},
+   *    { 1, 11245,  -376},
+   *    { 1, 11513,   275},
+   *    { 1, 11787,   439}, */
+};
+
+/* Musca */
+static ConFig _Musca_rey_figs[] = {
+  {0, 21168, -4003}, /* Mus Lambda */
+  {1, 21247, -4008}, /* Mus Mu */
+  {1, 22127, -4077}, /* Mus Epsilon */
+  {1, 22716, -4148}, /* Mus Alpha */
+  {1, 23468, -4292}, /* Mus Delta */
+  {1, 22574, -4327}, /* Mus Gamma */
+  {1, 22716, -4148}, /* Mus Alpha */
+  {1, 22988, -4086}, /* Mus Beta */
+  {-1,     0,     0},
+};
+
+/* Norma */
+static ConFig _Norma_rey_figs[] = {
+  {0, 28995, -2710}, /* Nor Delta */
+  {1, 28896, -2953}, /* Nor Eta */
+  {1, 29395, -3009}, /* Nor Gamma2 */
+  {1, 29616, -2853}, /* Nor Epsilon */
+  {1, 28995, -2710}, /* Nor Delta */
+  {-1,     0,     0},
+};
+
+/* Octans */
+static ConFig _Octans_rey_figs[] = {
+   { 0, 26007, -5020},
+   { 1, 39044, -4643},
+   /*   { 1, 40200, -4826}, */
+   { 1, 40981, -4882},
+   { 1, 26007, -5020},
+   {-1,     0,     0},
+};
+
+/* Ophiuchus */
+static ConFig _Ophiuchus_rey_figs[] = {
+    { 0, 31301, -1688}, /* 43    */
+    { 1, 31060, -1596}, /* 36    */
+    { 1, 31260, -1499}, /* Theta */ 
+    { 1, 31391, -1450}, /* 44    */
+    { 1, 31230, -1267}, /* Xi    */
+    { 1, 30911,  -943}, /* Eta   */
+    { 1, 29915,  -634}, /* Zeta  */
+    { 1, 29734,  -996}, /* Phi   */
+    { 1, 29610, -1107}, /* Chi   */
+    { 1, 29523, -1202}, /* Psi   */
+    { 1, 29764, -1288}, /* Omega */
+    { 0, 30911,  -943}, /* Eta   */
+    { 1, 31904,   274}, /* Kelb al Rai */
+    { 1, 31647,   753}, /* Ras Alhague */
+    { 1, 30530,   562}, /* Kappa */
+    { 1, 29915,  -634}, /* Zeta  */
+    { 0, 32419,   175}, /* 67    */
+    { 1, 32036,   162}, /* Gamma */
+    { 1, 31904,   274}, /* Kelb al Rai */
+    { 1, 30530,   562}, /* Kappa */
+    { 1, 30419,   609}, /* Iota  */
+    { 1, 29727,   119}, /* Lambda */
+    { 1, 29230,  -221}, /* Delta */
+    {-1,     0,     0},
+};
+
+/* Orion */
+static ConFig _Orion_rey_figs[] = {
+  {0, 10433, -580}, /* Ori Kappa-53 */
+  {1, 10223, -116}, /* Ori Zeta-50 */
+  {1, 10655, 444}, /* Betelgeuse */
+  {1, 9924, 357}, /* Ori 32 */
+  {1, 9754, 381}, /* Bellatrix */
+  {1, 9960, -17}, /* Mintaka */
+  {1, 9734, -143}, /* Ori Eta-28 */
+  {1, 9436, -492}, /* Rigel */
+  {0, 10223, -116}, /* Ori Zeta-50 */
+  {1, 10086, -72}, /* Alnilam */
+  {1, 9960, -17}, /* Mintaka */
+  {0, 9924, 357}, /* Ori 32 */
+  {1, 10054, 596}, /* Ori Lambda-39 */
+  {0, 9754, 381}, /* Bellatrix */
+  {1, 8695, 418}, /* Ori Pi3-1 */
+  {0, 8956, 103}, /* Ori Pi6-10 */
+  {1, 8828, 146}, /* Ori Pi5-8 */
+  {1, 8736, 336}, /* Ori Pi4-3 */
+  {1, 8695, 418}, /* Ori Pi3-1 */
+  {1, 8718, 534}, /* Ori Pi2-2 */
+  {1, 8847, 609}, /* Ori Pi1-7 */
+  {1, 8891, 811}, /* Ori Omicro2-9 */
+  {0, 10655, 444}, /* Betelgeuse */
+  {1, 10872, 579}, /* Ori Mu-61 */
+  {1, 11158, 853}, /* Ori Xi-70 */
+  {1, 11027, 886}, /* Ori Nu-67 */
+  {1, 10631, 1217}, /* Ori Chi1-54 */
+  {1, 10918, 1208}, /* Ori Chi2-62 */
+  {1, 11158, 853}, /* Ori Xi-70 */
+  {-1,     0,     0},
+};
+
+/* Pavo */
+static ConFig _Pavo_rey_figs[] = {
+  {0, 38593, -3921}, /* Pav Gamma */
+  {1, 36769, -3404}, /* Pav Alpha */
+  {1, 36262, -3970}, /* Pav Delta */
+  {1, 36018, -4374}, /* Pav Epsilon */
+  {1, 33691, -4285}, /* Pav Zeta */
+  {1, 34109, -4034}, /* Pav Kappa */
+  {1, 36262, -3970}, /* Pav Delta */
+  {1, 37349, -3972}, /* Pav Beta */
+  {1, 38593, -3921}, /* Pav Gamma */
+  {0, 34109, -4034}, /* Pav Kappa */
+  {1, 33967, -3731}, /* Pav Lambda */
+  {1, 32657, -3820}, /* Pav Pi */
+  {1, 31972, -3883}, /* Pav Eta */
+  {0, 32657, -3820}, /* Pav Pi */
+  {1, 33097, -3689}, /* Pav Xi */
+  {1, 33967, -3731}, /* Pav Lambda */
+  {-1,     0,     0},
+};
+
+/* Pegasus */
+static ConFig _Pegasus_rey_figs[] = {
+  { 0, 39125,   592}, /* Eniph */
+  { 1, 40844,   649}, /* Homam */
+  { 0, 39906,   371}, /* theta */
+  { 1, 40844,   649}, /* Homam */
+  { 1, 41001,   730}, /* xi */
+  { 1, 41543,   912}, /* Markab */
+  { 1,   397,   911}, /* Algenib */
+  { 2,   251,  1745}, /* Alpheratz */
+  { 2, 41513,  1684}, /* beta */
+  { 1, 41543,   912}, /* Markab */
+  { 0,   397,   911}, /* Algenib */
+  { 1, 41513,  1684}, /* beta */
+  { 0, 38462,  1188}, /* 1 */
+  { 1, 39139,  1538}, /* kappa */
+  { 1, 39810,  1520}, /* iota */
+  { 1, 40996,  1413}, /* lambda */
+  { 1, 41100,  1476}, /* mu */
+  { 1, 40890,  1813}, /* eta */
+  { 1, 39876,  1990}, /* pi */
+  { 0, 39135,  1041}, /* 9 */
+  { 1, 39810,  1520}, /* iota */
+  { 0, 39810,  1520}, /* iota */
+  { 1, 41001,   730}, /* xi */
+  { 0, 41543,   912}, /* Markab */
+  { 1, 40996,  1413}, /* lambda */
+  {-1,     0,     0},
+};
+
+/* Perseus */
+static ConFig _Perseus_rey_figs[] = {
+  { 0,  7397,  3021}, /* lambda */
+  { 1,  7646,  2904}, /* mu */
+  { 1,  7460,  2862}, /* 48 */
+  { 1,  6687,  2867}, /* delta */ 
+  { 1,  6494,  2891}, /* psi */
+  { 1,  6129,  2991}, /* Mirfak */
+  { 1,  5544,  3210}, /* gamma */
+  { 1,  5121,  3353}, /* eta */
+  { 1,  5227,  3165}, /* tau */
+  { 1,  5672,  2976}, /* iota */
+  { 0,  5544,  3210}, /* gamma */
+  { 1,  5227,  3165}, /* tau */
+  { 0,  6129,  2991}, /* Mirfak */
+  { 1,  6317,  2879}, /* sigma */
+  { 1,  6756,  2554}, /* nu */
+  { 1,  7135,  2400}, /* epsilon */
+  { 1,  7169,  2147}, /* xi */
+  { 1,  7024,  1913}, /* zeta */
+  { 1,  6729,  1937}, /* omicron */
+  { 0,  6129,  2991}, /* Mirfak */
+  { 1,  5672,  2976}, /* iota */
+  { 1,  4925,  2953}, /* theta */
+  { 1,  3109,  3041}, /* phi */
+  { 0,  5672,  2976}, /* iota */
+  { 1,  5685,  2691}, /* kappa */
+  { 1,  5645,  2457}, /* Algol */
+  { 1,  5555,  2330}, /* rho */
+  { 1,  5117,  2299}, /* 16 */
+  { 0,  5645,  2457}, /* Algol */
+  { 1,  7135,  2400}, /* epsilon */
+  {-1,     0,     0},
+};
+
+/* Phoenix */
+static ConFig _Phoenix_rey_figs[] = {
+  {0, 2052, -3314}, /* Phe Zeta */
+  {1, 1983, -2803}, /* Phe Beta */
+  {1, 1240, -2765}, /* Phe Mu */
+  {1,  786, -2620}, /* Phe Kappa */
+  {1,  789, -2538}, /* Phe Alpha */
+  {1,  282, -2744}, /* Phe Epsilon */
+  {1,  786, -2620}, /* Phe Kappa */
+  {0, 2738, -2944}, /* Phe Delta */
+  {1, 1983, -2803}, /* Phe Beta */
+  {1, 2651, -2599}, /* Phe Gamma */
+  {1, 1240, -2765}, /* Phe Mu */
+  {0, 1983, -2803}, /* Phe Beta */
+  {1, 1301, -3447}, /* Phe Eta */
+  {1, 1240, -2765}, /* Phe Mu */
+  {-1,     0,     0},
+};
+
+/* Pictor */
+static ConFig _Pictor_rey_figs[] = {
+  {0, 12246, -3716}, /* Pic Alpha */
+  {1, 10495, -3370}, /* Pic Gamma */
+  {1, 10419, -3063}, /* Pic Beta */
+  {1, 12246, -3716}, /* Pic Alpha */
+  {-1,     0,     0},
+};
+
+/* Pisces */
+static ConFig _Pisces_rey_figs[] = {
+  {0, 42599, 338}, /* Psc Iota-17 */
+  {1, 42239, 383}, /* Psc Theta-10 */
+  {1, 42010, 323}, /* Psc 7 */
+  {1, 41915, 197}, /* Psc Gamma-6 */
+  {1, 42217, 67}, /* Psc 9 */
+  {1, 42661, 107}, /* Psc Lambda-18 */
+  {1, 42599, 338}, /* Psc Iota-17 */
+  {1, 43179, 412}, /* Psc Omega-28 */
+  {1, 1461, 455}, /* Psc Delta-63 */
+  {1, 1888, 473}, /* Psc Epsilo-71 */
+  {1, 2213, 455}, /* Psc Zeta-86 */
+  {1, 2706, 369}, /* Psc Mu-98 */
+  {1, 3043, 329}, /* Psc Nu-106 */
+  {1, 3661, 166}, /* Kaitain */
+  {1, 3162, 549}, /* Psc Omicr-110 */
+  {1, 2745, 921}, /* Psc Eta-99 */
+  {1, 2588, 1150}, /* Psc Rho-93 */
+  {1, 2212, 1475}, /* Psc Phi-85 */
+  {1, 2384, 1636}, /* Psc Upsilo-90 */
+  {1, 2150, 1805}, /* Psc Tau-83 */
+  {1, 2212, 1475}, /* Psc Phi-85 */
+  {-1,     0,     0},
+};
+
+/* Piscis Austrinus */
+static ConFig _Piscis_Austrinus_rey_figs[] = {
+  {0, 39148, -1981}, /* PsA Iota-9 */
+  {1, 39852, -1979}, /* PsA Mu-14 */
+  {1, 40545, -1940}, /* PsA Beta-17 */
+  {1, 41176, -1972}, /* PsA Gamma-22 */
+  {1, 41278, -1952}, /* PsA Delta-23 */
+  {1, 41330, -1777}, /* Fomalhaut */
+  {1, 40820, -1622}, /* PsA Epsilo-18 */
+  {1, 39852, -1979}, /* PsA Mu-14 */
+  {1, 39232, -1853}, /* PsA Theta-10 */
+  {1, 39148, -1981}, /* PsA Iota-9 */
+  {-1,     0,     0},
+};
+
+/* Puppis */
+static ConFig _Puppis_rey_figs[] = {
+  {0, 11519, -3161}, /* Canopus */
+  {1, 11933, -2591}, /* Pup Nu */
+  {1, 13114, -2225}, /* Pup Pi */
+  {1, 13661, -1702}, /* GSC star */
+  {1, 13765, -1608}, /* 'Nother GSC star */
+  {1, 13749, -1522}, /* GSC star */
+  {1, 14079, -1492}, /* Pup Xi-7 */
+  {1, 14626, -1458}, /* Pup Rho-15 */
+  {1, 14508, -2400}, /* Pup Zeta */
+  {1, 14686, -2840}, /* Vel Gamma2 */
+  {0, 13661, -1702}, /* GSC Star */
+  {1, 13914, -1737}, /* Pup 3 */
+  {1, 14043, -1556}, /* Pup Omicron */
+  {1, 14079, -1492}, /* Pup Xi-7 */
+  {-1,     0,     0},
+};
+
+/* Pyxis */
+static ConFig _Pyxis_rey_figs[] = {
+  { 0, 14508, -2400}, /* Pup Zeta */
+  { 1, 15603, -2118},
+  { 1, 15708, -1991},
+  { 1, 15916, -1662},
+  {-1,     0,     0},
+};
+
+/* Reticulum - no change */
+
+/* Sagitta */
+static ConFig _Sagitta_rey_figs[] = {
+  /*    { 0, 36154,  1199}, */  /*  Sge Eta-16 */
+    { 0, 35962,  1169},
+    { 1, 35621,  1112},
+    { 1, 35431,  1048},
+    { 0, 35621,  1112},
+    { 1, 35403,  1080},
+    {-1,     0,     0},
+};
+
+/* Sagittarius */
+static ConFig _Sagittarius_rey_figs[] = {
+  {0, 32929, -2205}, /* Sgr Eta */
+  {1, 33125, -2063}, /* Kaus Australis */
+  {1, 33030, -1789}, /* Sgr Delta-19 */
+  {1, 33239, -1525}, /* Sgr Lambda-22 */
+  {1, 32813, -1263}, /* Sgr Mu-13 */
+  {1, 32574, -1825}, /* Sgr Gamma2-10 */
+  {1, 32929, -2205}, /* Sgr Eta */
+  {0, 32574, -1825}, /* Sgr Gamma2-10 */
+  {1, 33030, -1789}, /* Sgr Delta-19 */
+  {1, 33770, -1619}, /* Sgr Phi-27 */
+  {1, 34058, -1577}, /* Sgr Sigma-34 */
+  {1, 34132, -1266}, /* Sgr Xi2-37 */
+  {1, 34493, -1261}, /* Sgr Pi-41 */
+  {1, 34850, -1070}, /* Sgr Rho1-44 */
+  {1, 34852, -957}, /* Sgr Upsilo-46 */
+  {0, 34493, -1261}, /* Sgr Pi-41 */
+  {1, 34058, -1577}, /* Sgr Sigma-34 */
+  {1, 34408, -1660}, /* Sgr Tau-40 */
+  {1, 35992, -2116}, /* Sgr Theta1 */
+  {1, 35858, -2512}, /* Sgr Iota */
+  {0, 33770, -1619}, /* Sgr Phi-27 */
+  {1, 34278, -1792}, /* Sgr Zeta-38 */
+  {1, 34917, -2436}, /* Sgr Alpha */
+  {1, 34879, -2667}, /* Sgr Beta1 */
+  {0, 34917, -2436}, /* Sgr Alpha */
+  {1, 35992, -2116}, /* Sgr Theta1 */
+  {0 , 34278, -1792}, /* Sgr Zeta-38 */
+  {1, 34408, -1660}, /* Sgr Tau-40 */
+  {-1,     0,     0},
+};
+
+/* Scorpius */
+static ConFig _Scorpius_rey_figs[] = {
+  {0, 28810, -1357}, /* Sco Delta-7 */
+  {1, 28963, -1188}, /* Sco Beta1-8 */
+  {1, 29159, -1166}, /* Sco Nu-14 */
+  {1, 29436, -1535}, /* Sco Sigma-20 */
+  {1, 29169, -1675}, /* Sco 13 */
+  {1, 28707, -1752}, /* Sco Rho-5 */
+  {1, 28766, -1566}, /* Sco Pi-6 */
+  {0, 29436, -1535}, /* Sco Sigma-20 */
+  {1, 29682, -1585}, /* Antares */
+  {1, 29877, -1692}, /* Sco Tau-23 */
+  {1, 30305, -2057}, /* Sco Epsilo-26 */
+  {1, 30356, -2282}, /* Sco Mu1 */
+  {1, 30438, -2541}, /* Sco Zeta2 */
+  {1, 30965, -2594}, /* Sco Eta */
+  {1, 31720, -2579}, /* Sco Theta */
+  {1, 32028, -2407}, /* Sco Iota1 */
+  {1, 31875, -2341}, /* Sco Kappa */
+  {1, 31523, -2237}, /* Sco Upsilo-34 */
+  {1, 31608, -2226}, /* Shaula */
+  { 1, 32095, -2222}, /* NGC 6441 (GC) ? */
+  {-1,     0,     0},
+  /* Orginal figure Follows
+     *    { 0, 28963, -1188},
+     *    { 1, 29004, -1240},
+     *  { 1, 29159, -1166},
+     *  { 1, 28930,  -682},
+     *  { 1, 28963, -1188},
+     *  { 1, 28810, -1357},
+     *  { 1, 28765, -1566},
+     *  { 1, 28706, -1752},
+     *  { 0, 28810, -1357},
+     *  { 1, 29435, -1535},
+     *  { 1, 29681, -1585},
+     *  { 1, 29876, -1692},
+     *  { 1, 30305, -2057},
+     *  { 1, 29741, -2082},
+     *  { 1, 29891, -2115},
+     *  { 1, 30305, -2057},
+     *  { 1, 30356, -2282},
+     *  { 1, 30437, -2541},
+     *  { 1, 30964, -2594},
+     *  { 1, 31719, -2579},
+     *  { 1, 32027, -2407},
+     *  { 1, 31874, -2341},
+     *  { 1, 31608, -2226},
+     *  { 0, 32027, -2407}, */
+};
+
+/* Sculptor - no change */
+
+/* Scutum */
+static ConFig _Scutum_rey_figs[] = {
+  {0, 33456, -494}, /* Sct Alpha */
+  {1, 33276, -873}, /* Sct Gamma */
+  {1, 33668, -543}, /* Sct Delta */
+  {1, 33815, -284}, /* Sct Beta */
+  {1, 33456, -494}, /* Sct Alpha */
+  {-1,     0,     0},
+};
+
+/* Serpens Caput */
+static ConFig _Serpens_Caput_rey_figs[] = {
+    { 0, 29634,  -502},  /* Upsilon Oph */
+    { 1, 29350,  -282},  /* Epsilon Oph */
+    { 1, 29230,  -221}, /* Delta Oph*/
+    { 1, 28488,  -205}, /* Mu */
+    { 1, 28509,   131}, /* Omega */
+    { 1, 28524,   268}, /* Epsilon */
+    { 1, 28328,   385}, /* Unulkalhay */
+    { 1, 28407,   441}, /* Lambda */
+    { 1, 28044,   632}, /* Delta */
+    { 1, 28385,   925}, /* Beta  */
+    { 1, 28693,   939}, /* Gamma */
+    { 1, 28462,  1088}, /* Kappa */
+    { 1, 28246,  1180}, /* Iota */
+    { 1, 28385,   925}, /* Beta */
+    {-1,     0,     0},
+};
+
+/* Sextans - no change */
+
+/* Taurus */
+static ConFig _Taurus_rey_figs[] = {
+  { 0,  9789,  1716}, /* Alnath */
+  { 1,  8467,  1377}, /* tau */
+  { 1,  7989,  1368}, /* upsilon */
+  { 1,  8058,  1150}, /* epsilon */
+  { 1,  7964,  1075}, /* delta-3 */
+  { 1,  7888,  1052}, /* delta-1 */
+  { 1,  7794,   937}, /* gamma */
+  { 1,  8060,   952}, /* theta-2 */
+  { 1,  8277,   990}, /* Aldebaran */
+  { 1, 10129,  1268}, /* zeta */
+  { 1,  8467,  1377}, /* tau */
+  { 0,  7794,   937}, /* gamma */
+  { 1,  7220,   749}, /* lambda */
+  { 1,  6215,   583}, /* xi-2 */
+  { 1,  6326,   776}, /* 5 */
+  { 0,  6215,   583}, /* xi-2 */
+  { 1,  6144,   541}, /* omicron-1 */
+  { 1,  6506,    24}, /* 10 */
+  { 0,  6215,   583}, /* xi-2 */
+  { 1,  7294,   359}, /* nu */
+  { 0,  7665,   533}, /* mu */
+  { 1,  7794,   937}, /* gamma */
+  { 1,  8344,   750}, /* 90 */
+  { 1,  8269,   609}, /* 88 */ 
+  { 0,  7989,  1368}, /* upsilon */
+  { 1, 6810,   1447}, /* Pleides */ 
+  {-1,     0,     0},
+};
+
+/* Telescopium */
+static ConFig _Telescopium_rey_figs[] = {
+  /*    { 0, 32737, -2757}, */
+    { 0, 33209, -2758},
+    { 1, 33265, -2944},
+    {-1,     0,     0},
+};
+
+/* Triangulum */
+static ConFig _Triangulum_rey_figs[] = {
+  {0, 3392, 1775}, /* Tri Alpha-2 */
+  {1, 4119, 2031}, /* Tri Gamma-9 */
+  {1, 3886, 2099}, /* Tri Beta-4 */
+  {1, 3392, 1775}, /* Tri Alpha-2 */
+  {-1,     0,     0},
+};
+
+/* Triangulum Australe - no change */
+
+/* Tucana */
+static ConFig _Tucana_rey_figs[] = {
+  /*    { 0, 40420, -3897}, */
+    { 0, 40155, -3615},
+    { 1, 41923, -3494},
+    { 1, 43197, -3934},
+    { 1,   602, -3892},
+    { 1,   946, -3777},
+    { 1, 41923, -3494},
+    {-1,     0,     0},
+};
+
+/* Ursa Major */
+static ConFig _Ursa_Major_rey_figs[] = {
+    { 0, 24826,  2958}, /* Benetnasch */
+    { 1, 24118,  3295}, /* Mizar  */
+    { 1, 23221,  3357}, /* Alioth */
+    { 1, 22063,  3421}, /* Megrez */
+    { 1, 21415,  3221}, /* Phecda */
+    { 1, 19855,  3382}, /* Merak  */
+    { 1, 19912,  3705}, /* Dubhe  */
+    { 0, 24826,  2958}, /* Benetnasch */
+    { 2, 21181,  2866}, /* Chi */
+    { 2, 20090,  2669}, /* Psi */
+    { 2, 20354,  1985}, /* Nu */
+    { 0, 20345,  1891}, /* Xi */
+    { 2, 18670,  2489}, /* Mu */
+    { 2, 16309,  2829}, /* Kappa */
+    { 2, 16176,  2882}, /* Talitha */
+    { 2, 15308,  3643}, /* Omicron */
+    { 2, 17146,  3783}, /* 23 */
+    { 2, 19912,  3705}, /* Dubhe */
+    { 2, 22063,  3421}, /* Megrez */
+    { 0, 17146,  3783}, /* 23 */
+    { 2, 17729,  3542}, /* Upsilon */
+    { 2, 17185,  3100}, /* Theta */
+    { 2, 18513,  2574}, /* Lambda */
+    {-1,     0,     0},
+};
+
+/* Ursa Minor - no change */
+
+/* Vela - no change */
+
+/* Virgo */
+static ConFig _Virgo_rey_figs[] = {
+    { 0, 21756,   523},
+    { 1, 21176,   391},
+    { 1, 21321,   105},
+    { 1, 22197,   -40},
+    { 1, 22850,   -86},
+    { 1, 23268,   203},
+    { 1, 23465,   657},
+    { 0, 23268,   203},
+    { 1, 24441,   -35},
+    { 1, 24156,  -669},
+    { 1, 23698,  -332},
+    { 1, 22850,   -86},
+    { 0, 24441,   -35},
+    { 1, 25249,    92},
+    { 1, 26587,   113},
+    { 0, 24156,  -669},
+    { 1, 25587,  -616},
+    { 1, 25680,  -360},
+    { 1, 26492,  -339},
+    /* Only need to add two segments to generate Rey's figure: */
+    {0, 21756, 524}, /* Vir Omicron-9 */
+    {1, 22850, -86}, /* Vir Gamma-29 */
+    {0, 25249, 93}, /* Vir Tau-93 */
+    {1, 25680, -360}, /* Vir Iota-99 */
+    {-1,     0,     0},
+};
+
+/* Volans - no change */
+
+/* Vulpecula */
+static ConFig _Vulpecula_rey_figs[] = {
+    { 0, 35804,  1444},
+    { 1, 35061,  1479},
+    /*    { 1, 34686,  1283}, */
+    {-1,     0,     0},
+};
+
+/* Serpens Cauda */
+static ConFig _Serpens_Cauda_rey_figs[] = {
+    { 0, 34086,   252}, /* Theta  */
+    { 1, 32620,   573}, /* Oph 72 */
+    { 1, 32563,   149}, /* Oph 70 */
+    { 1, 33039,  -173}, /* Eta    */
+    { 1, 32371,  -586}, /* Oph Nu */
+    { 1, 31842,  -772}, /* Omicron */
+    { 1, 31727,  -923}, /* Xi     */
+    { 1, 31225,  -770}, /* Nu     */ 
+    {-1,     0,     0},
+};
+
+
+static ConFig *reyfigmap[NCNS] = {
+    _Andromeda_rey_figs,
+    _Antlia_figs,
+    _Apus_rey_figs,
+    _Aquila_rey_figs,
+    _Aquarius_rey_figs,
+    _Ara_rey_figs,
+    _Aries_rey_figs,
+    _Auriga_rey_figs,
+    _Bootes_rey_figs,
+    _Canis_Major_rey_figs,
+    _Canis_Minor_figs,
+    _Canes_Venatici_figs,
+    _Caelum_figs,
+    _Camelopardalis_rey_figs,
+    _Capricornus_rey_figs,
+    _Carina_rey_figs,
+    _Cassiopeia_rey_figs,
+    _Centaurus_rey_figs,
+    _Cepheus_rey_figs,
+    _Cetus_rey_figs,
+    _Chamaeleon_rey_figs,
+    _Circinus_figs,
+    _Cancer_rey_figs,
+    _Columba_rey_figs,
+    _Coma_Berenices_rey_figs,
+    _Corona_Australis_figs,
+    _Corona_Borealis_figs,
+    _Crater_rey_figs,
+    _Crux_figs,
+    _Corvus_rey_figs,
+    _Cygnus_rey_figs,
+    _Delphinus_rey_figs,
+    _Dorado_rey_figs,
+    _Draco_rey_figs,
+    _Equuleus_rey_figs,
+    _Eridanus_rey_figs,
+    _Fornax_figs,
+    _Gemini_rey_figs,
+    _Grus_rey_figs,
+    _Hercules_rey_figs,
+    _Horologium_figs,
+    _Hydra_rey_figs,
+    _Hydrus_rey_figs,
+    _Indus_rey_figs,
+    _Leo_Minor_rey_figs,
+    _Lacerta_rey_figs,
+    _Leo_rey_figs,
+    _Lepus_rey_figs,
+    _Libra_rey_figs,
+    _Lupus_rey_figs,
+    _Lynx_figs,
+    _Lyra_rey_figs,
+    _Mensa_figs,
+    _Microscopium_figs,
+    _Monoceros_rey_figs,
+    _Musca_rey_figs,
+    _Norma_rey_figs,
+    _Octans_rey_figs,
+    _Ophiuchus_rey_figs,
+    _Orion_rey_figs,
+    _Pavo_rey_figs,
+    _Pegasus_rey_figs,
+    _Perseus_rey_figs,
+    _Phoenix_rey_figs,
+    _Pictor_rey_figs,
+    _Piscis_Austrinus_rey_figs,
+    _Pisces_rey_figs,
+    _Puppis_rey_figs,
+    _Pyxis_rey_figs,
+    _Reticulum_figs,
+    _Sculptor_figs,
+    _Scorpius_rey_figs,
+    _Scutum_rey_figs,
+    _Serpens_Caput_rey_figs,
+    _Sextans_figs,
+    _Sagitta_rey_figs,
+    _Sagittarius_rey_figs,
+    _Taurus_rey_figs,
+    _Telescopium_rey_figs,
+    _Triangulum_Australe_figs,
+    _Triangulum_rey_figs,
+    _Tucana_rey_figs,
+    _Ursa_Major_rey_figs,
+    _Ursa_Minor_figs,
+    _Vela_figs,
+    _Virgo_rey_figs,
+    _Volans_figs,
+    _Vulpecula_rey_figs,
+    _Serpens_Cauda_rey_figs,
+};
+
+/* given a constellation id and epoch, return arrays of ra[] and dec[]
+ *   end-points precessed to the desired epoch that, if connected, will form the
+ *   given constellation figure.
+ * dcodes is 0 if the coord is a "move-to", 1 if a "draw-to" or 2 if a "draw-to
+ *   as dotted-line".
+ * return the total number of tripples or -1 if id is bogus.
+ * the arrays need be no larger than 33 entries.
+ */
+int
+cns_reyfigure (int id, double e, double ra[], double dec[], int dcodes[])
+{
+	ConFig *cfp;
+
+	if (id < 0 || id >= NCNS)
+	    return (-1);
+
+	for (cfp = reyfigmap[id]; cfp->drawcode >= 0; cfp++) {
+	    *ra = hrrad((double)cfp->ra/1800.0);
+	    *dec = degrad((double)cfp->dec/60.0);
+	    precess (J2000, e, ra, dec);
+	    ra++;
+	    dec++;
+	    *dcodes++ = cfp->drawcode;
+	}
+
+	return (cfp - reyfigmap[id]);
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: constel.c,v $ $Date: 2004-06-15 16:54:11 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/dbfmt.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/dbfmt.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/dbfmt.c	(revision 2551)
@@ -4,21 +4,12 @@
 #include <ctype.h>
 #include <math.h>
-
-#if defined(__STDC__)
 #include <stdlib.h>
 #include <string.h>
-#endif
-
-#include "P_.h"
+
 #include "astro.h"
-#include "circum.h"
 #include "preferences.h"
 
-extern void zero_mem P_((void *loc, unsigned len));
-extern double atod P_((char *buf));
-
-int get_fields P_((char *s, int delim, char *fields[]));
-int db_set_field P_((char bp[], int id, PrefDateFormat pref, Obj *op));
-int db_chk_planet P_((char name[], Obj *op));
+
+int get_fields (char *s, int delim, char *fields[]);
 
 #define MAXDBLINE       256     /* longest allowed db line */
@@ -28,16 +19,31 @@
 #define MAXFLDS 20              /* must be more than on any expected line */
 
-#define ASIZ(a) (sizeof(a)/sizeof(a[0]))
-
-static int line_candidate P_((char *buf));
-static void crack_year P_((char *bp, PrefDateFormat pref, double *p));
-static int db_get_field P_((Obj *op, int id, char *bp));
-static int tle_sum P_((char *l));
-static double tle_fld P_((char *l, int from, int thru));
-static double tle_expfld P_((char *l, int start));
+static char *enm (char *flds[MAXFLDS]);
+static int crack_f (Obj *op, char *flds[MAXFLDS], int nf, char whynot[]);
+static int crack_e (Obj *op, char *flds[MAXFLDS], int nf, char whynot[]);
+static int crack_h (Obj *op, char *flds[MAXFLDS], int nf, char whynot[]);
+static int crack_p (Obj *op, char *flds[MAXFLDS], int nf, char whynot[]);
+static int crack_E (Obj *op, char *flds[MAXFLDS], int nf, char whynot[]);
+static int crack_P (Obj *op, char *flds[MAXFLDS], int nf, char whynot[]);
+static int crack_B (Obj *op, char *flds[MAXFLDS], int nf, char whynot[]);
+static int crack_name (Obj *op, char *flds[MAXFLDS], int nf,
+    char nm[][MAXNM], int nnm);
+static void crack_year (char *bp, double *p);
+static void crack_okdates (char *fld, float *startok, float *endok);
+static int get_okdates (char *lp, float *sp, float *ep);
+static int tle_sum (char *l);
+static double tle_fld (char *l, int from, int thru);
+static double tle_expfld (char *l, int start);
+static void write_f (Obj *op, char lp[]);
+static void write_e (Obj *op, char lp[]);
+static void write_h (Obj *op, char lp[]);
+static void write_p (Obj *op, char lp[]);
+static void write_E (Obj *op, char lp[]);
+static void write_P (Obj *op, char lp[]);
+static void write_B (Obj *op, char lp[]);
 
 /* crack the given .edb database line into op.
  * if ok
- *   return 0
+ *   return number of names in nm[], or 1 if nm == NULL
  * else
  *   if whynot
@@ -47,23 +53,22 @@
  *       fill whynot with reason message.
  *   return -1
+ * only the first name is stored in op, all names (up to nnm) are in nm[], or
+ *   ignored if nm == NULL.
  */
 int
-db_crack_line (s, op, whynot)
-char s[];
-Obj *op;
-char whynot[];
-{
+db_crack_line (char s[], Obj *op, char nm[][MAXNM], int nnm, char whynot[])
+{
+	char copy[MAXDBLINE];	/* work copy; leave s untouched */
 	char *flds[MAXFLDS];	/* point to each field for easy reference */
-	char *sflds[MAXFLDS];	/* point to each sub field for easy reference */
-	char copy[MAXDBLINE];	/* work copy; leave s untouched */
-	int nf, nsf;		/* number of fields and subfields */
+	int nf;
 	int i;
 
+	/* init no response */
+	if (whynot)
+	    whynot[0] = '\0';
+
 	/* basic initial check */
-	if (line_candidate (s) < 0) {
-	    if (whynot)
-		whynot[0] = '\0';
-	    return (-1);
-	}
+	if (dbline_candidate (s) < 0)
+	    return (-1);
 
 	/* do all the parsing on a copy */
@@ -79,5 +84,5 @@
 	if (nf < 2) {
 	    if (whynot)
-		sprintf (whynot, "Found only %d fields", nf);
+		sprintf (whynot, "Bogus: %s", s);
 	    return (-1);
 	}
@@ -85,169 +90,99 @@
 	/* switch out on type of object - the second field */
 	switch (flds[1][0]) {
-	case 'f': {
-	    static int ids[] = {F_RA, F_DEC, F_MAG};
-	    if (nf < 5 || nf > 7) {
-		if (whynot)
-		    sprintf (whynot, "f needs 5-7 fields: %d", nf);
-		return (-1);
-	    }
-	    zero_mem ((void *)op, sizeof(ObjF));
-	    op->o_type = FIXED;
-	    nsf = get_fields(flds[1], SUBFLD, sflds);
-	    if (nsf > 1 && db_set_field (sflds[1], F_CLASS, PREF_MDY, op) < 0) {
-		if (whynot)
-		    sprintf (whynot, "Bad f class: %c", sflds[1][0]);
-		return (-1);
-	    }
-	    if (nsf > 2)
-		(void) db_set_field (sflds[2], F_SPECT, PREF_MDY, op);
-	    for (i = 2; i < ASIZ(ids)+2; i++)
-		(void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
-	    (void) db_set_field (nf>5 && flds[5][0] ? flds[5] : "2000",
-							F_EPOCH, PREF_MDY, op);
-	    if (nf == 7)
-		(void) db_set_field (flds[6], F_SIZE, PREF_MDY, op);
-	    break;
-	}
-
-	case 'e': {
-	    static int ids[] = {E_INC, E_LAN, E_AOP, E_A, E_N, E_E, E_M,
-						E_CEPOCH, E_EPOCH, E_M1, E_M2
-	    };
-	    if (nf != 13 && nf != 14) {
-		if (whynot)
-		    sprintf (whynot, "e needs 13 or 14 fields: %d", nf);
-		return (-1);
-	    }
-	    zero_mem ((void *)op, sizeof(ObjE));
-	    op->o_type = ELLIPTICAL;
-	    for (i = 2; i < ASIZ(ids)+2; i++)
-		(void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
-	    if (nf == 14)
-		(void) db_set_field (flds[13], E_SIZE, PREF_MDY, op);
-	    break;
-	}
-
-	case 'h': {
-	    static int ids[]= {H_EP,H_INC,H_LAN,H_AOP,H_E,H_QP,H_EPOCH,H_G,H_K};
-	    if (nf != 11 && nf != 12) {
-		if (whynot)
-		    sprintf (whynot, "h needs 11 or 12 fields: %d", nf);
-		return (-1);
-	    }
-	    zero_mem ((void *)op, sizeof(ObjH));
-	    op->o_type = HYPERBOLIC;
-	    for (i = 2; i < ASIZ(ids)+2; i++)
-		(void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
-	    if (nf == 12)
-		(void) db_set_field (flds[11], H_SIZE, PREF_MDY, op);
-	    break;
-	}
-
-	case 'p': {
-	    static int ids[] = {P_EP,P_INC,P_AOP,P_QP,P_LAN,P_EPOCH,P_G,P_K};
-	    if (nf != 10 && nf != 11) {
-		if (whynot)
-		    sprintf (whynot, "p needs 10 or 11 fields: %d", nf);
-		return (-1);
-	    }
-	    zero_mem ((void *)op, sizeof(ObjP));
-	    op->o_type = PARABOLIC;
-	    for (i = 2; i < ASIZ(ids)+2; i++)
-		(void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
-	    if (nf == 11)
-		(void) db_set_field (flds[10], P_SIZE, PREF_MDY, op);
-	    break;
-	}
-
-	case 'E': {
-	    static int ids[] = {ES_EPOCH,ES_INC,ES_RAAN,ES_E,ES_AP,ES_M,ES_N,
-							    ES_DECAY,ES_ORBIT};
-	    if (nf != 11 && nf != 12) {
-		if (whynot)
-		    sprintf (whynot, "E needs 11 or 12 fields: %d", nf);
-		return (-1);
-	    }
-	    zero_mem ((void *)op, sizeof(ObjES));
-	    op->o_type = EARTHSAT;
-	    for (i = 2; i < ASIZ(ids)+2; i++)
-		(void) db_set_field (flds[i], ids[i-2], PREF_MDY, op);
-	    if (nf == 12)
-		(void) db_set_field (flds[11], ES_DRAG, PREF_MDY, op);
-	    break;
-	}
+
+	case 'f':
+	    if (crack_f (op, flds, nf, whynot) < 0)
+		return (-1);
+	    break;
+
+	case 'e':
+	    if (crack_e (op, flds, nf, whynot) < 0)
+		return (-1);
+	    break;
+
+	case 'h':
+	    if (crack_h (op, flds, nf, whynot) < 0)
+		return (-1);
+	    break;
+
+	case 'p':
+	    if (crack_p (op, flds, nf, whynot) < 0)
+		return (-1);
+	    break;
+
+	case 'B':
+	    if (crack_B (op, flds, nf, whynot) < 0)
+		return (-1);
+	    break;
+
+	case 'E':
+	    if (crack_E (op, flds, nf, whynot) < 0)
+		return (-1);
+	    break;
 
 	case 'P':
-	    /* allow, though ignore, anything after the P */
-	    i = db_chk_planet (flds[0], op);	/* does o_name too */
-	    if (i < 0) {
-		if (whynot)
-		    sprintf (whynot, "Bad planet: %s", flds[0]);
-	    }
-	    return (i);
+	    if (crack_P (op, flds, nf, whynot) < 0)
+		return (-1);
+	    break;
 
 	default:
 	    if (whynot)
-		sprintf (whynot, "Unknown type: %c", flds[1][0]);
-	    return (-1);
-	}
-
-	/* load up o_name */
-	(void) db_set_field (flds[0], O_NAME, PREF_MDY, op);
-
-	return (0);
-}
-
-/* return 0 if TLE checksum is ok, else -1 */
-static int
-tle_sum (l)
-char *l;
-{
-	char *lastl = l + 68;
-	int sum;
-
-	for (sum = 0; l < lastl; ) {
-	    char c = *l++;
-	    if (c == '\0')
-		return (-1);
-	    if (isdigit(c))
-		sum += c - '0';
-	    else if (c == '-')
-		sum++;
-	}
-
-	return (*l - '0' == (sum%10) ? 0 : -1);
-}
-
-/* extract the given columns and return value.
- * N.B. from and to are 1-based within l
+		sprintf (whynot, "%s: Unknown type %c for %s", enm(flds),
+							flds[1][0], flds[0]);
+	    return (-1);
+	}
+
+	return (crack_name (op, flds, nf, nm, nnm));
+}
+
+/* write the given Obj in .edb format to lp[].
+ * we do _not_ include a trailing '\n'.
  */
-static double
-tle_fld (l, from, thru)
-char *l;
-int from, thru;
-{
-	char buf[32];
-
-	sprintf (buf, "%.*s", thru-from+1, l+from-1);
-	return (atod (buf));
-}
-
-/* extract the exponential value starting at the given column.
- * N.B. start is 1-based within l
- */
-static double
-tle_expfld (l, start)
-char *l;
-int start;
-{
-	char buf[32];
-	double v;
-
-	sprintf (buf, ".%.*s", 5, l+start);
-	v = atod (buf) * pow (10.0, tle_fld(l, start+6, start+7));
-	if (l[start-1] == '-')
-	    v = -v;
-	return (v);
+void
+db_write_line (Obj *op, char lp[])
+{
+	int priorpref;
+
+	/* .edb format always uses MDY.
+	 * N.B. must restore old value before returning from here!
+	 */
+	priorpref = pref_set (PREF_DATE_FORMAT, PREF_MDY);
+
+	switch (op->o_type) {
+	case FIXED:
+	    write_f (op, lp);
+	    break;
+
+	case BINARYSTAR:
+	    write_B (op, lp);
+	    break;
+
+	case ELLIPTICAL:
+	    write_e (op, lp);
+	    break;
+
+	case HYPERBOLIC:
+	    write_h (op, lp);
+	    break;
+
+	case PARABOLIC:
+	    write_p (op, lp);
+	    break;
+
+	case EARTHSAT:
+	    write_E (op, lp);
+	    break;
+
+	case PLANET:
+	    write_P (op, lp);
+	    break;
+
+	default:
+	    printf ("Unknown type for %s: %d\n", op->o_name, op->o_type);
+	    abort();
+	}
+
+	/* restore date format preference */
+	(void) pref_set (PREF_DATE_FORMAT, priorpref);
 }
 
@@ -261,7 +196,5 @@
  */
 int
-db_tle (name, l1, l2, op)
-char *name, *l1, *l2;
-Obj *op;
+db_tle (char *name, char *l1, char *l2, Obj *op)
 {
 	double ep;
@@ -306,4 +239,5 @@
 	/* goodies from "line 1" */
 	op->es_drag = (float) tle_expfld (l1, 54);
+	op->es_decay = (float) tle_fld (l1, 34, 43);
 	i = (int) tle_fld (l1, 19, 20);
 	if (i < 57)
@@ -325,332 +259,36 @@
 }
 
-/* write the given Obj in .edb format to lp[].
- * we do _not_ include a trailing '\n'.
- */
-void
-db_write_line (op, lp)
-Obj *op;
-char *lp;
-{
-	int priorpref;
-	int i;
-
-	/* .edb format always uses MDY.
-	 * N.B. must restore old value before returning from here!
-	 */
-	priorpref = pref_set (PREF_DATE_FORMAT, PREF_MDY);
-
-	switch (op->o_type) {
-	case FIXED: {
-	    static int ids[] = {F_CLASS, F_SPECT, F_RA, F_DEC, F_MAG, F_EPOCH,
-		F_SIZE
-	    };
-
-	    sprintf (lp, "%s,f", op->o_name);
-	    lp += strlen(lp);
-	    for (i = 0; i < ASIZ(ids); i++)
-		lp += db_get_field (op, ids[i], lp);
-	    break;
-	    }
-
-	case ELLIPTICAL: {
-	    static int ids[] = {E_INC, E_LAN, E_AOP, E_A, E_N, E_E, E_M,
-					E_CEPOCH, E_EPOCH, E_M1, E_M2, E_SIZE
-	    };
-
-	    sprintf (lp, "%s,e", op->o_name);
-	    lp += strlen(lp);
-	    for (i = 0; i < ASIZ(ids); i++)
-		lp += db_get_field (op, ids[i], lp);
-	    break;
-	    }
-
-	case HYPERBOLIC: {
-	    static int ids[]= {H_EP, H_INC, H_LAN, H_AOP, H_E, H_QP, H_EPOCH,
-		H_G, H_K, H_SIZE
-	    };
-
-	    sprintf (lp, "%s,h", op->o_name);
-	    lp += strlen(lp);
-	    for (i = 0; i < ASIZ(ids); i++)
-		lp += db_get_field (op, ids[i], lp);
-	    break;
-	    }
-
-	case PARABOLIC: {
-	    static int ids[] = {P_EP, P_INC, P_AOP, P_QP, P_LAN, P_EPOCH, P_G,
-		P_K, P_SIZE
-	    };
-
-	    sprintf (lp, "%s,p", op->o_name);
-	    lp += strlen(lp);
-	    for (i = 0; i < ASIZ(ids); i++)
-		lp += db_get_field (op, ids[i], lp);
-	    break;
-	    }
-
-	case EARTHSAT: {
-	    static int ids[] = {ES_EPOCH, ES_INC, ES_RAAN, ES_E, ES_AP, ES_M,
-		ES_N, ES_DECAY,ES_ORBIT,ES_DRAG
-	    };
-
-	    sprintf (lp, "%s,E", op->o_name);
-	    lp += strlen(lp);
-	    for (i = 0; i < ASIZ(ids); i++)
-		lp += db_get_field (op, ids[i], lp);
-	    break;
-	    }
-
-	case PLANET:
-	    sprintf (lp, "%s,P", op->o_name);
-	    lp += strlen(lp);
-	    break;
-
-	default:
-	    printf ("Unknown type for %s: %d\n", op->o_name, op->o_type);
-	    exit(1);
-	}
-
-	/* restore date format preference */
-	(void) pref_set (PREF_DATE_FORMAT, priorpref);
-}
-
-/* given a text buffer and a field id, and a PREF_DATE_FORMAT,
- *   set the corresponding member in *op.
- * return 0 if ok, else -1.
+/* return 0 if op has no date range information or what it does have brackets
+ * now, else -1
  */
 int
-db_set_field (bp, id, pref, op)
-char bp[];
-int id;
-PrefDateFormat pref;
-Obj *op;
-{
-	double tmp;
-
-	/* include all the enums and in numeric order to give us the best
-	 * possible chance the compiler will implement this as a jump table.
-	 */
-	switch (id) {
-	case O_TYPE:
-	    printf ("db_set_field: called with id==O_TYPE\n");
-	    exit(1);
-	    break;
-	case O_NAME:
-	    (void) strncpy (op->o_name, bp, sizeof(op->o_name)-1);
-	    op->o_name[sizeof(op->o_name)-1] = '\0';
-	    break;
-	case F_RA:
-	    f_scansex (radhr(op->f_RA), bp, &tmp);
-	    op->f_RA = (float) hrrad(tmp);
-	    break;
-	case F_DEC:
-	    f_scansex (raddeg(op->f_dec), bp, &tmp);
-	    op->f_dec = (float) degrad(tmp);
-	    break;
-	case F_EPOCH:
-	    tmp = op->f_epoch;
-	    crack_year (bp, pref, &tmp);
-	    op->f_epoch = (float) tmp;
-	    break;
-	case F_MAG:
-	    set_fmag (op, atod(bp));
-	    break;
-	case F_SIZE:
-	    op->f_size = (float) atod(bp);
-	    {
-		/* optional minor axis and position angle subfields */
-		char *sflds[MAXFLDS];
-		int nsf = get_fields(bp, SUBFLD, sflds);
-
-		if (nsf == 3) {
-		    set_ratio(op, op->s_size, atod(sflds[1]));
-		    set_pa(op,degrad(atod(sflds[2])));
-		} else {
-		    set_ratio(op,1,1);	/* round */
-		    set_pa(op,0.0);
-		}
-	    }
-	    break;
-	case F_CLASS:
-	    switch (bp[0]) {
-	    case 'A': case 'B': case 'C': case 'D': case 'F': case 'G':
-	    case 'H': case 'K': case 'J': case 'L': case 'M': case 'N':
-	    case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T':
-	    case 'U': case 'V':
-		op->f_class = bp[0];
-		break;
-	    default:
-		return (-1);
-	    }
-	    break;
-	case F_SPECT: {
-	    int i, j;
-	    /* fill f_spect all the way */
-	    for (i = j = 0; i < sizeof(op->f_spect); i++)
-		if ((op->f_spect[i] = bp[j]) != 0)
-		    j++;
-	    break;
-	}
-
-	case E_INC:
-	    op->e_inc = (float) atod (bp);
-	    break;
-	case E_LAN:
-	    op->e_Om = (float) atod (bp);
-	    break;
-	case E_AOP:
-	    op->e_om = (float) atod (bp);
-	    break;
-	case E_A:
-	    op->e_a = (float) atod (bp);
-	    break;
-	case E_N:
-	    /* retired */
-	    break;
-	case E_E:
-	    op->e_e = atod (bp);
-	    break;
-	case E_M:
-	    op->e_M = (float) atod (bp);
-	    break;
-	case E_CEPOCH:
-	    crack_year (bp, pref, &op->e_cepoch);
-	    break;
-	case E_EPOCH:
-	    crack_year (bp, pref, &op->e_epoch);
-	    break;
-	case E_M1:
-	    switch (bp[0]) {
-	    case 'g':
-		op->e_mag.whichm = MAG_gk;
-		bp++;
-		break;
-	    case 'H':
-		op->e_mag.whichm = MAG_HG;
-		bp++;
-		break;
-	    default:
-		/* leave type unchanged if no or unrecognized prefix */
-		break;
-	    }
-	    op->e_mag.m1 = (float) atod(bp);
-	    break;
-	case E_M2:
-	    switch (bp[0]) {
-	    case 'k':
-		op->e_mag.whichm = MAG_gk;
-		bp++;
-		break;
-	    case 'G':
-		op->e_mag.whichm = MAG_HG;
-		bp++;
-		break;
-	    default:
-		/* leave type unchanged if no or unrecognized prefix */
-		break;
-	    }
-	    op->e_mag.m2 = (float) atod(bp);
-	    break;
-	case E_SIZE:
-	    op->e_size = (float) atod (bp);
-	    break;
-
-	case H_EP:
-	    crack_year (bp, pref, &op->h_ep);
-	    break;
-	case H_INC:
-	    op->h_inc = (float) atod (bp);
-	    break;
-	case H_LAN:
-	    op->h_Om = (float) atod (bp);
-	    break;
-	case H_AOP:
-	    op->h_om = (float) atod (bp);
-	    break;
-	case H_E:
-	    op->h_e = (float) atod (bp);
-	    break;
-	case H_QP:
-	    op->h_qp = (float) atod (bp);
-	    break;
-	case H_EPOCH:
-	    crack_year (bp, pref, &op->h_epoch);
-	    break;
-	case H_G:
-	    op->h_g = (float) atod (bp);
-	    break;
-	case H_K:
-	    op->h_k = (float) atod (bp);
-	    break;
-	case H_SIZE:
-	    op->h_size = (float) atod (bp);
-	    break;
-
-	case P_EP:
-	    crack_year (bp, pref, &op->p_ep);
-	    break;
-	case P_INC:
-	    op->p_inc = (float) atod (bp);
-	    break;
-	case P_AOP:
-	    op->p_om = (float) atod (bp);
-	    break;
-	case P_QP:
-	    op->p_qp = (float) atod (bp);
-	    break;
-	case P_LAN:
-	    op->p_Om = (float) atod (bp);
-	    break;
-	case P_EPOCH:
-	    crack_year (bp, pref, &op->p_epoch);
-	    break;
-	case P_G:
-	    op->p_g = (float) atod (bp);
-	    break;
-	case P_K:
-	    op->p_k = (float) atod (bp);
-	    break;
-	case P_SIZE:
-	    op->p_size = (float) atod (bp);
-	    break;
-
-	case ES_EPOCH:
-	    crack_year (bp, pref, &op->es_epoch);
-	    break;
-	case ES_INC:
-	    op->es_inc = (float) atod (bp);
-	    break;
-	case ES_RAAN:
-	    op->es_raan = (float) atod (bp);
-	    break;
-	case ES_E:
-	    op->es_e = (float) atod (bp);
-	    break;
-	case ES_AP:
-	    op->es_ap = (float) atod (bp);
-	    break;
-	case ES_M:
-	    op->es_M = (float) atod (bp);
-	    break;
-	case ES_N:
-	    op->es_n = atod (bp);
-	    break;
-	case ES_DECAY:
-	    op->es_decay = (float) atod (bp);
-	    break;
-	case ES_ORBIT:
-	    op->es_orbit = atoi (bp);
-	    break;
-	case ES_DRAG:
-	    op->es_drag = (float) atod (bp);
-	    break;
-
+dateRangeOK (Now *np, Obj *op)
+{
+	float *sp, *ep;
+
+	switch (op->o_type) {
+	case ELLIPTICAL:
+	    sp = &op->e_startok;
+	    ep = &op->e_endok;
+	    break;
+	case HYPERBOLIC:
+	    sp = &op->h_startok;
+	    ep = &op->h_endok;
+	    break;
+	case PARABOLIC:
+	    sp = &op->p_startok;
+	    ep = &op->p_endok;
+	    break;
+	case EARTHSAT:
+	    sp = &op->es_startok;
+	    ep = &op->es_endok;
+	    break;
 	default:
-	    printf ("BUG! db_set_field: bad id: %d\n", id);
-	    exit (1);
-	}
-
-	return (0);
+	    return (0);
+	}
+
+	if (*sp <= mjd && (!*ep || mjd <= *ep))
+	    return (0);
+	return (-1);
 }
 
@@ -662,8 +300,5 @@
  */
 int
-get_fields (s, delim, fields)
-char *s;
-int delim;
-char *fields[];
+get_fields (char *s, int delim, char *fields[])
 {
 	int n;
@@ -684,62 +319,471 @@
 }
 
-/* check name for being a planet.
- * if so, fill in *op and return 0, else return -1.
- */
-int
-db_chk_planet (name, op)
-char name[];
-Obj *op;
-{
-	char namecpy[256];
-	int i;
-
-	/* these must match the order in astro.h */
-	static char *planet_names[] = {
-	    "Mercury", "Venus", "Mars", "Jupiter", "Saturn",
-	    "Uranus", "Neptune", "Pluto", "Sun", "Moon",
-	};
-
-	/* make a copy to match our case -- strcasecmp() not entirely portable*/
-	strcpy (namecpy, name);
-	if (islower(namecpy[0]))
-	    namecpy[0] = toupper(namecpy[0]);
-	for (i = 1; namecpy[i]; i++)
-	    if (isupper(namecpy[i]))
-		namecpy[i] = tolower(namecpy[i]);
-
-	for (i = MERCURY; i <= MOON; i++) {
-	    if (strcmp (namecpy, planet_names[i]) == 0) {
-		zero_mem ((void *)op, sizeof(ObjPl));
-		op->o_type = PLANET;
-		(void) strcpy (op->o_name, planet_names[i]);
-		op->pl.pl_code = i;
-		return (0);
-	    }
-	}
-
-	return (-1);
-}
-
 /* return 0 if buf qualifies as a database line worthy of a cracking
  * attempt, else -1.
  */
+int
+dbline_candidate (char *buf)
+{
+	char c = buf[0];
+
+	return (c == '#' || c == '!' || isspace(c) ? -1 : 0);
+}
+
+/* return 0 if TLE checksum is ok, else -1 */
 static int
-line_candidate (buf)
-char *buf;
-{
-	char c = buf[0];
-
-	return (c == '#' || c == '!' || isspace(c) ? -1 : 0);
-}
-
-/* given either a decimal year (xxxx[.xxx]) or a calendar (x/x/x)
- * and a DateFormat preference convert it to an mjd and store it at *p.
+tle_sum (char *l)
+{
+	char *lastl = l + 68;
+	int sum;
+
+	for (sum = 0; l < lastl; ) {
+	    char c = *l++;
+	    if (c == '\0')
+		return (-1);
+	    if (isdigit(c))
+		sum += c - '0';
+	    else if (c == '-')
+		sum++;
+	}
+
+	return (*l - '0' == (sum%10) ? 0 : -1);
+}
+
+/* extract the given columns and return value.
+ * N.B. from and to are 1-based within l
+ */
+static double
+tle_fld (char *l, int from, int thru)
+{
+	char buf[32];
+
+	sprintf (buf, "%.*s", thru-from+1, l+from-1);
+	return (atod (buf));
+}
+
+/* extract the exponential value starting at the given column.
+ * N.B. start is 1-based within l
+ */
+static double
+tle_expfld (char *l, int start)
+{
+	char buf[32];
+	double v;
+
+	sprintf (buf, ".%.*s", 5, l+start);
+	v = atod (buf) * pow (10.0, tle_fld(l, start+6, start+7));
+	if (l[start-1] == '-')
+	    v = -v;
+	return (v);
+}
+
+static int
+crack_f (Obj *op, char *flds[MAXFLDS], int nf, char whynot[])
+{
+	char *sflds[MAXFLDS];
+	double tmp;
+	int nsf;
+
+	if (nf < 5 || nf > 7) {
+	    if (whynot)
+		sprintf (whynot, "%s: f needs 5-7 fields, not %d",enm(flds),nf);
+	    return (-1);
+	}
+
+	zero_mem ((void *)op, sizeof(ObjF));
+	op->o_type = FIXED;
+
+	nsf = get_fields(flds[1], SUBFLD, sflds);
+	if (nsf > 1) {
+	    switch (sflds[1][0]) {
+	    case 'A': case 'B': case 'C': case 'D': case 'F': case 'G':
+	    case 'H': case 'K': case 'J': case 'L': case 'M': case 'N':
+	    case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T':
+	    case 'U': case 'V': case 'Y':
+		op->f_class = sflds[1][0];
+		if (op->f_class == 'B')
+		    op->f_class = 'D';	/* merge B and D since BINARYSTAR */
+		break;
+	    default:
+		if (whynot)
+		    sprintf (whynot, "%s: Bad f class: %c", enm(flds),
+		    						sflds[1][0]);
+		return (-1);
+	    }
+	}
+	if (nsf > 2) {
+	    /* fill f_spect all the way */
+	    char buf[sizeof(op->f_spect)+1];
+	    memset (buf, 0, sizeof(buf));
+	    sprintf (buf, "%.*s", (int)sizeof(op->f_spect), sflds[2]);
+	    memcpy (op->f_spect, buf, (int)sizeof(op->f_spect));
+	}
+
+	nsf = get_fields(flds[2], SUBFLD, sflds);
+	f_scansexa (sflds[0], &tmp);
+	op->f_RA = (float) hrrad(tmp);
+	if (nsf > 1)
+	    op->f_pmRA = (float) 1.327e-11*atod(sflds[1]);/*mas/yr->rad/dy*/
+
+	nsf = get_fields(flds[3], SUBFLD, sflds);
+	f_scansexa (sflds[0], &tmp);
+	op->f_dec = (float) degrad(tmp);
+	if (nsf > 1)
+	    op->f_pmdec = (float)1.327e-11*atod(sflds[1]);/*mas/yr->rad/dy*/
+	if (fabs(op->f_dec) < PI/2)
+	    op->f_pmRA /= cos (op->f_dec);
+
+	set_fmag (op, atod(flds[4]));
+
+	if (nf > 5 && flds[5][0]) {
+	    tmp = op->f_epoch;
+	    crack_year (flds[5], &tmp);
+	    op->f_epoch = (float) tmp;
+	} else
+	    op->f_epoch = J2000;	/* default */
+
+	if (nf > 6) {
+	    op->f_size = (float) atod(flds[6]);
+
+	    /* optional minor axis and position angle subfields */
+	    nsf = get_fields(flds[6], SUBFLD, sflds);
+	    if (nsf == 3) {
+		set_ratio(op, op->s_size, atod(sflds[1]));
+		set_pa(op,degrad(atod(sflds[2])));
+	    } else {
+		set_ratio(op,1,1);	/* round */
+		set_pa(op,0.0);
+	    }
+	}
+
+	return (0);
+}
+
+static int
+crack_e (Obj *op, char *flds[MAXFLDS], int nf, char whynot[])
+{
+	if (nf != 13 && nf != 14) {
+	    if (whynot)
+		sprintf (whynot, "%s: e needs 13 or 14 fields, not %d",
+								enm(flds), nf);
+	    return (-1);
+	}
+
+	zero_mem ((void *)op, sizeof(ObjE));
+	op->o_type = ELLIPTICAL;
+
+	op->e_inc = (float) atod (flds[2]);
+	op->e_Om = (float) atod (flds[3]);
+	op->e_om = (float) atod (flds[4]);
+	op->e_a = (float) atod (flds[5]);
+	/* retired op->e_n = (float) atod (flds[6]); */
+	op->e_e = atod (flds[7]);
+	op->e_M = (float) atod (flds[8]);
+	crack_year (flds[9], &op->e_cepoch);
+	crack_okdates (flds[9], &op->e_startok, &op->e_endok);
+	crack_year (flds[10], &op->e_epoch);
+
+	/* magnitude model gk or HG(default). allow prefixes in either field */
+	op->e_mag.whichm = flds[11][0] == 'g' ? MAG_gk : MAG_HG;
+	if (isdigit(flds[11][0]))
+	    op->e_mag.m1 = (float) atod(&flds[11][0]);
+	else
+	    op->e_mag.m1 = (float) atod(&flds[11][1]);
+	if (isdigit(flds[12][0]))
+	    op->e_mag.m2 = (float) atod(&flds[12][0]);
+	else
+	    op->e_mag.m2 = (float) atod(&flds[12][1]);
+
+	if (nf == 14)
+	    op->e_size = (float) atod (flds[13]);
+
+	return (0);
+}
+
+static int
+crack_h (Obj *op, char *flds[MAXFLDS], int nf, char whynot[])
+{
+	if (nf != 11 && nf != 12) {
+	    if (whynot)
+		sprintf (whynot, "%s: h needs 11 or 12 fields, not %d",
+								enm(flds), nf);
+	    return (-1);
+	}
+
+	zero_mem ((void *)op, sizeof(ObjH));
+	op->o_type = HYPERBOLIC;
+
+	crack_year (flds[2], &op->h_ep);
+	crack_okdates (flds[2], &op->h_startok, &op->h_endok);
+	op->h_inc = (float) atod (flds[3]);
+	op->h_Om = (float) atod (flds[4]);
+	op->h_om = (float) atod (flds[5]);
+	op->h_e = (float) atod (flds[6]);
+	op->h_qp = (float) atod (flds[7]);
+	crack_year (flds[8], &op->h_epoch);
+	op->h_g = (float) atod (flds[9]);
+	op->h_k = (float) atod (flds[10]);
+
+	if (nf == 12)
+	    op->h_size = (float) atod (flds[11]);
+
+	return (0);
+}
+
+static int
+crack_p (Obj *op, char *flds[MAXFLDS], int nf, char whynot[])
+{
+	if (nf != 10 && nf != 11) {
+	    if (whynot)
+		sprintf (whynot, "%s: p needs 10 or 11 fields, not %d",	
+								enm(flds), nf);
+	    return (-1);
+	}
+
+	zero_mem ((void *)op, sizeof(ObjP));
+	op->o_type = PARABOLIC;
+
+	crack_year (flds[2], &op->p_ep);
+	crack_okdates (flds[2], &op->p_startok, &op->p_endok);
+	op->p_inc = (float) atod (flds[3]);
+	op->p_om = (float) atod (flds[4]);
+	op->p_qp = (float) atod (flds[5]);
+	op->p_Om = (float) atod (flds[6]);
+	crack_year (flds[7], &op->p_epoch);
+	op->p_g = (float) atod (flds[8]);
+	op->p_k = (float) atod (flds[9]);
+
+	if (nf == 11)
+	    op->p_size = (float) atod (flds[10]);
+
+	return (0);
+}
+
+static int
+crack_E (Obj *op, char *flds[MAXFLDS], int nf, char whynot[])
+{
+	if (nf != 11 && nf != 12) {
+	    if (whynot)
+		sprintf (whynot, "%s: E needs 11 or 12 fields, not %d",
+							    enm(flds), nf);
+	    return (-1);
+	}
+
+	zero_mem ((void *)op, sizeof(ObjES));
+	op->o_type = EARTHSAT;
+	crack_year (flds[2], &op->es_epoch);
+	crack_okdates (flds[2], &op->es_startok, &op->es_endok);
+	op->es_inc = (float) atod (flds[3]);
+	op->es_raan = (float) atod (flds[4]);
+	op->es_e = (float) atod (flds[5]);
+	op->es_ap = (float) atod (flds[6]);
+	op->es_M = (float) atod (flds[7]);
+	op->es_n = atod (flds[8]);
+	op->es_decay = (float) atod (flds[9]);
+	op->es_orbit = atoi (flds[10]);
+	if (nf == 12)
+	    op->es_drag = (float) atod (flds[11]);
+
+	return (0);
+}
+
+static int
+crack_P (Obj *op, char *flds[MAXFLDS], int nf, char whynot[])
+{
+	Obj *bi;
+	int nbi;
+	int i;
+
+	nbi = getBuiltInObjs (&bi);
+
+	for (i = 0; i < nbi; i++) {
+	    Obj *bop = bi + i;
+	    if (is_type(bop,PLANETM) && !strcmp (flds[0], bop->o_name)) {
+		memcpy ((void *)op, bop, sizeof(ObjPl));
+		return (0);
+	    }
+	}
+
+	if (whynot)
+	    sprintf (whynot, "%s: Unknown planet or moon", enm(flds));
+	return (-1);
+}
+
+static int
+crack_B (Obj *op, char *flds[MAXFLDS], int nf, char whynot[])
+{
+	char *sflds[MAXFLDS];
+	double tmp;
+	int nsf;
+
+	if (nf != 7) {
+	    if (whynot)
+		sprintf (whynot, "%s: B need 7 fields, not %d", enm(flds), nf);
+	    return (-1);
+	}
+
+	zero_mem ((void *)op, sizeof(ObjB));
+	op->o_type = BINARYSTAR;
+
+	nsf = get_fields(flds[1], SUBFLD, sflds);
+	if (nsf > 1) {
+	    switch (sflds[1][0]) {
+	    case 'a': case 'c': case 'e': case 'x': case 'y': case 'o':
+	    case 's': case 't': case 'u': case 'v': case 'b': case 'd':
+	    case 'q': case 'r': case 'p': case 'U': case 'V': case 'Y':
+		op->f_class = sflds[1][0];
+		break;
+	    default:
+		if (whynot)
+		    sprintf (whynot, "%s: Bad B class: %c", enm(flds),
+		    						sflds[1][0]);
+		return (-1);
+	    }
+	}
+	if (nsf > 2) {
+	    /* fill f_spect all the way */
+	    char buf[sizeof(op->f_spect)+1];
+	    memset (buf, 0, sizeof(buf));
+	    sprintf (buf, "%.*s", (int)sizeof(op->f_spect), sflds[2]);
+	    memcpy (op->f_spect, buf, (int)sizeof(op->f_spect));
+	}
+	if (nsf > 3) {
+	    /* fill b_2spect all the way */
+	    char buf[sizeof(op->b_2spect)+1];
+	    memset (buf, 0, sizeof(buf));
+	    sprintf (buf, "%.*s", (int)sizeof(op->b_2spect), sflds[3]);
+	    memcpy (op->b_2spect, buf, (int)sizeof(op->b_2spect));
+	}
+
+	nsf = get_fields(flds[2], SUBFLD, sflds);
+	f_scansexa (sflds[0], &tmp);
+	op->f_RA = (float) hrrad(tmp);
+	if (nsf > 1)
+	    op->f_pmRA = (float) 1.327e-11*atod(sflds[1]);/*mas/yr->rad/dy*/
+
+	nsf = get_fields(flds[3], SUBFLD, sflds);
+	f_scansexa (sflds[0], &tmp);
+	op->f_dec = (float) degrad(tmp);
+	if (nsf > 1)
+	    op->f_pmdec = (float)1.327e-11*atod(sflds[1]);/*mas/yr->rad/dy*/
+	if (fabs(op->f_dec) < PI/2)
+	    op->f_pmRA /= cos (op->f_dec);
+
+	nsf = get_fields(flds[4], SUBFLD, sflds);
+	if (nsf > 0)
+	    set_fmag (op, atod(sflds[0]));
+	if (nsf > 1)
+	    op->b_2mag = (short)floor((atod(sflds[1]))*MAGSCALE + 0.5);
+
+	if (flds[5][0]) {
+	    tmp = op->f_epoch;
+	    crack_year (flds[5], &tmp);
+	    op->f_epoch = (float) tmp;
+	} else
+	    op->f_epoch = J2000;	/* default */
+
+	nsf = get_fields(flds[6], SUBFLD, sflds);
+	if (nsf == 7) {
+	    int l;
+	    char c;
+
+	    op->b_bo.bo_a = atod(sflds[0]);
+	    op->b_bo.bo_i = atod(sflds[1]);
+	    op->b_bo.bo_O = atod(sflds[2]);
+	    op->b_bo.bo_e = atod(sflds[3]);
+	    op->b_bo.bo_T = atod(sflds[4]);
+	    op->b_bo.bo_o = atod(sflds[5]);
+	    op->b_bo.bo_P = atod(sflds[6]);
+
+	    /* reject some weird entries actually seen in real lists */
+	    if (op->b_bo.bo_a <= 0) {
+		if (whynot)
+		    sprintf (whynot, "%s: Bogus B semi major axis: %g",
+						    enm(flds), op->b_bo.bo_a);
+		return (-1);
+	    }
+	    if (op->b_bo.bo_P <= 0) {
+		if (whynot)
+		    sprintf (whynot, "%s: Bogus B period: %g", enm(flds),
+		    						op->b_bo.bo_P);
+		return (-1);
+	    }
+
+	    /* scale period */
+	    l = strlen (sflds[6]);
+	    c = sflds[6][l-1];
+	    switch (c) {
+	    case 'y': case 'Y':
+		break;
+	    case 'h': case 'H':
+		op->b_bo.bo_P /= (24.0*365.25);
+		break;
+	    case 'd': case 'D':
+		op->b_bo.bo_P /= 365.25;
+		break;
+	    default:
+		if (c != ' ' && !isdigit(c)) {
+		    if (whynot)
+			sprintf (whynot,"%s: B period suffix not Y, D or H: %c",
+								enm(flds), c);
+		    return (-1);
+		}
+	    }
+
+	} else if (nsf==3 || nsf==6 || nsf==9) {
+	    double yr;
+	    int i;
+
+	    op->b_nbp = nsf/3;
+	    for (i = 0; i < nsf; i += 3) {
+		tmp = 0;
+		crack_year (sflds[i+0], &tmp);
+		mjd_year (tmp, &yr);
+		op->b_bp[i/3].bp_ep = (float)yr;
+		op->b_bp[i/3].bp_sep = atod(sflds[i+1]);
+		op->b_bp[i/3].bp_pa = degrad(atod(sflds[i+2]));
+	    }
+	} else {
+	    if (whynot)
+		sprintf (whynot,
+			"%s: B needs 3,6 or 7 subfields in field 7, not %d",
+								enm(flds), nsf);
+	    return (-1);
+	}
+
+	return (0);
+}
+
+/* put all names in nm but load only the first into o_name */
+static int
+crack_name (Obj *op, char *flds[MAXFLDS], int nf, char nm[][MAXNM], int nnm)
+{
+	char *sflds[MAXFLDS];
+	int nsf;
+	int i;
+	
+	nsf = get_fields (flds[0], SUBFLD, sflds);
+	for (i = 0; nm && i < nsf && i < nnm; i++) {
+	    strncpy (nm[i], sflds[i], MAXNM);
+	    nm[i][MAXNM-1] = '\0';
+	}
+	strncpy (op->o_name, sflds[0], MAXNM-1);
+	return (nsf);
+}
+
+/* simple name cracker just for error messages */
+static char *
+enm (char *flds[MAXFLDS])
+{
+	char *sflds[MAXFLDS];
+	int nsf = get_fields (flds[0], SUBFLD, sflds);
+	return (nsf > 0 ? sflds[0] : "Unknown");
+}
+
+/* given either a decimal year (xxxx[.xxx]) or a calendar (x/x/x) date
+ * convert it to an mjd and store it at *p.
  */
 static void
-crack_year (bp, pref, p)
-char *bp;
-PrefDateFormat pref;
-double *p;
+crack_year (char *bp, double *p)
 {
 	int m, y;
@@ -747,270 +791,216 @@
 
 	mjd_cal (*p, &m, &d, &y);	/* init with current */
-	f_sscandate (bp, pref, &m, &d, &y);
+	f_sscandate (bp, PREF_MDY, &m, &d, &y);
 	cal_mjd (m, d, y, p);
 }
 
-/* given an *op and a field id, add it to the given text buffer bp.
- * return the number of characters added to bp.
+/* crack the startok and endok date fields found in several Obj types.
+ * set to 0 if blank or any problems.
+ */
+static void
+crack_okdates (char *fld, float *startok, float *endok)
+{
+	char *sflds[MAXFLDS];
+	double tmp;
+	int m, y;
+	double d;
+	int nsf;
+
+	*startok = *endok = 0;
+	nsf = get_fields(fld, SUBFLD, sflds);
+	if (nsf > 1) {
+	    d = m = y = 0;
+	    f_sscandate (sflds[1], PREF_MDY, &m, &d, &y);
+	    cal_mjd (m, d, y, &tmp);
+	    *startok = (float)tmp;
+	    if (nsf > 2) {
+		d = m = y = 0;
+		f_sscandate (sflds[2], PREF_MDY, &m, &d, &y);
+		cal_mjd (m, d, y, &tmp);
+		*endok = (float)tmp;
+	    }
+	}
+}
+
+/* add startok and endok to string at lp if non-zero.
+ * return number of characters added.
  */
 static int
-db_get_field (op, id, bp)
-Obj *op;
-int id;
-char *bp;
-{
-	char *bpsave = bp;
+get_okdates (char *lp, float *sp, float *ep)
+{
+	char *lp0 = lp;
+
+	if (*sp || *ep) {
+	    *lp++ = '|';
+	    if (*sp)
+		lp += fs_date (lp, *sp);
+	    if (*ep) {
+		*lp++ = '|';
+		lp += fs_date (lp, *ep);
+	    }
+	}
+
+	return (lp - lp0);
+}
+
+static void
+write_f (Obj *op, char lp[])
+{
 	double tmp;
 
-	/* include all the enums and in numeric order to give us the best
-	 * possible chance the compiler will implement this as a jump table.
-	 */
-	switch (id) {
-	case F_RA:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_sexa (bp, radhr(op->f_RA), 2, 36000);
-	    bp += strlen(bp);
-	    break;
-	case F_DEC:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_sexa (bp, raddeg(op->f_dec), 3, 3600);
-	    bp += strlen(bp);
-	    break;
-	case F_EPOCH:
-	    mjd_year (op->f_epoch, &tmp);
-	    sprintf (bp, ",%.6g", tmp); /* %.7g gives 2000.001 */
-	    bp += strlen(bp);
-	    break;
-	case F_MAG:
-	    sprintf (bp, ",%6.2f", get_mag(op));
-	    bp += strlen(bp);
-	    break;
-	case F_SIZE:
-	    sprintf (bp, ",%.7g", op->f_size);
-	    bp += strlen(bp);
-	    if (op->f_ratio || op->f_pa) {
-		sprintf (bp,"|%g|%g", op->f_size*get_ratio(op),
+	lp += sprintf (lp, "%s,f", op->o_name);
+	if (op->f_class)
+	    lp += sprintf (lp, "|%c", op->f_class);
+	if (op->f_spect[0])
+	    lp += sprintf (lp, "|%.*s", (int)sizeof(op->f_spect), op->f_spect);
+	*lp++ = ',';
+	lp += fs_sexa (lp, radhr(op->f_RA), 2, 36000);
+	if (op->f_pmRA)
+	    lp += sprintf (lp, "|%.6g",cos(op->f_dec)*op->f_pmRA/1.327e-11);
+	*lp++ = ',';
+	lp += fs_sexa (lp, raddeg(op->f_dec), 3, 3600);
+	if (op->f_pmdec)
+	    lp += sprintf (lp, "|%.6g", op->f_pmdec/1.327e-11);
+	lp += sprintf (lp, ",%.2f", get_mag(op));
+	mjd_year (op->f_epoch, &tmp);
+	lp += sprintf (lp, ",%.6g", tmp); /* %.7g gives 2000.001 */
+	lp += sprintf (lp, ",%.7g", op->f_size);
+	if (op->f_size && (op->f_ratio || op->f_pa))
+	    lp += sprintf (lp,"|%g|%g", op->f_size*get_ratio(op),
 							    raddeg(get_pa(op)));
-		bp += strlen(bp);
-	    }
-	    break;
-	case F_CLASS:
-	    if (op->f_class) {
-		sprintf (bp, "|%c", op->f_class);
-		bp += strlen(bp);
-	    }
-	    break;
-	case F_SPECT:
-	    if (op->f_spect[0] != '\0') {
-		sprintf (bp, "|%c", op->f_spect[0]);
-		bp += strlen(bp);
-		if (op->f_spect[1] != '\0') {
-		    sprintf (bp, "%c", op->f_spect[1]);
-		    bp += strlen(bp);
-		}
-	    }
-	    break;
-
-	case E_INC:
-	    sprintf (bp, ",%.7g", op->e_inc);
-	    bp += strlen(bp);
-	    break;
-	case E_LAN:
-	    sprintf (bp, ",%.7g", op->e_Om);
-	    bp += strlen(bp);
-	    break;
-	case E_AOP:
-	    sprintf (bp, ",%.7g", op->e_om);
-	    bp += strlen(bp);
-	    break;
-	case E_A:
-	    sprintf (bp, ",%.7g", op->e_a);
-	    bp += strlen(bp);
-	    break;
-	case E_N:
-	    /* retired */
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    break;
-	case E_E:
-	    sprintf (bp, ",%.7g", op->e_e);
-	    bp += strlen(bp);
-	    break;
-	case E_M:
-	    sprintf (bp, ",%.7g", op->e_M);
-	    bp += strlen(bp);
-	    break;
-	case E_CEPOCH:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_date (bp, op->e_cepoch);
-	    bp += strlen(bp);
-	    break;
-	case E_EPOCH:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_date (bp, op->e_epoch);
-	    bp += strlen(bp);
-	    break;
-	case E_M1:
-	    if (op->e_mag.whichm == MAG_gk) {
-		sprintf (bp, ",g%.7g", op->e_mag.m1);
-		bp += strlen(bp);
-	    } else if (op->e_mag.whichm == MAG_HG) {
-		sprintf (bp, ",H%.7g", op->e_mag.m1);
-		bp += strlen(bp);
-	    } else {
-		sprintf (bp, ",%.7g", op->e_mag.m1);
-		bp += strlen(bp);
-	    }
-	    break;
-	case E_M2:
-	    sprintf (bp, ",%.7g", op->e_mag.m2);
-	    bp += strlen(bp);
-	    break;
-	case E_SIZE:
-	    sprintf (bp, ",%.7g", op->e_size);
-	    bp += strlen(bp);
-	    break;
-
-	case H_EP:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_date (bp, op->h_ep);
-	    bp += strlen(bp);
-	    break;
-	case H_INC:
-	    sprintf (bp, ",%.7g", op->h_inc);
-	    bp += strlen(bp);
-	    break;
-	case H_LAN:
-	    sprintf (bp, ",%.7g", op->h_Om);
-	    bp += strlen(bp);
-	    break;
-	case H_AOP:
-	    sprintf (bp, ",%.7g", op->h_om);
-	    bp += strlen(bp);
-	    break;
-	case H_E:
-	    sprintf (bp, ",%.7g", op->h_e);
-	    bp += strlen(bp);
-	    break;
-	case H_QP:
-	    sprintf (bp, ",%.7g", op->h_qp);
-	    bp += strlen(bp);
-	    break;
-	case H_EPOCH:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_date (bp, op->h_epoch);
-	    bp += strlen(bp);
-	    break;
-	case H_G:
-	    sprintf (bp, ",%.7g", op->h_g);
-	    bp += strlen(bp);
-	    break;
-	case H_K:
-	    sprintf (bp, ",%.7g", op->h_k);
-	    bp += strlen(bp);
-	    break;
-	case H_SIZE:
-	    sprintf (bp, ",%.7g", op->h_size);
-	    bp += strlen(bp);
-	    break;
-
-	case P_EP:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_date (bp, op->p_ep);
-	    bp += strlen(bp);
-	    break;
-	case P_INC:
-	    sprintf (bp, ",%.7g", op->p_inc);
-	    bp += strlen(bp);
-	    break;
-	case P_AOP:
-	    sprintf (bp, ",%.7g", op->p_om);
-	    bp += strlen(bp);
-	    break;
-	case P_QP:
-	    sprintf (bp, ",%.7g", op->p_qp);
-	    bp += strlen(bp);
-	    break;
-	case P_LAN:
-	    sprintf (bp, ",%.7g", op->p_Om);
-	    bp += strlen(bp);
-	    break;
-	case P_EPOCH:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_date (bp, op->p_epoch);
-	    bp += strlen(bp);
-	    break;
-	case P_G:
-	    sprintf (bp, ",%.7g", op->p_g);
-	    bp += strlen(bp);
-	    break;
-	case P_K:
-	    sprintf (bp, ",%.7g", op->p_k);
-	    bp += strlen(bp);
-	    break;
-	case P_SIZE:
-	    sprintf (bp, ",%.7g", op->p_size);
-	    bp += strlen(bp);
-	    break;
-
-	case ES_EPOCH:
-	    sprintf (bp, ",");
-	    bp += strlen(bp);
-	    fs_date (bp, op->es_epoch);
-	    bp += strlen(bp);
-	    break;
-	case ES_INC:
-	    sprintf (bp, ",%.7g", op->es_inc);
-	    bp += strlen(bp);
-	    break;
-	case ES_RAAN:
-	    sprintf (bp, ",%.7g", op->es_raan);
-	    bp += strlen(bp);
-	    break;
-	case ES_E:
-	    sprintf (bp, ",%.7g", op->es_e);
-	    bp += strlen(bp);
-	    break;
-	case ES_AP:
-	    sprintf (bp, ",%.7g", op->es_ap);
-	    bp += strlen(bp);
-	    break;
-	case ES_M:
-	    sprintf (bp, ",%.7g", op->es_M);
-	    bp += strlen(bp);
-	    break;
-	case ES_N:
-	    sprintf (bp, ",%.7g", op->es_n);
-	    bp += strlen(bp);
-	    break;
-	case ES_DECAY:
-	    sprintf (bp, ",%.7g", op->es_decay);
-	    bp += strlen(bp);
-	    break;
-	case ES_ORBIT:
-	    sprintf (bp, ",%d", op->es_orbit);
-	    bp += strlen(bp);
-	    break;
-	case ES_DRAG:
-	    sprintf (bp, ",%.7g", op->es_drag);
-	    bp += strlen(bp);
-	    break;
-
-	default:
-	    printf ("BUG! db_set_field: bad id: %d\n", id);
-	    exit (1);
-	}
-
-	return (bp - bpsave);
+}
+
+static void
+write_e (Obj *op, char lp[])
+{
+	lp += sprintf (lp, "%s,e", op->o_name);
+	lp += sprintf (lp, ",%.7g", op->e_inc);
+	lp += sprintf (lp, ",%.7g", op->e_Om);
+	lp += sprintf (lp, ",%.7g", op->e_om);
+	lp += sprintf (lp, ",%.7g", op->e_a);
+	lp += sprintf (lp, ",%.7g", 0.0);		/* retired op->e_n */
+	lp += sprintf (lp, ",%.7g", op->e_e);
+	lp += sprintf (lp, ",%.7g", op->e_M);
+	*lp++ = ',';
+	lp += fs_date (lp, op->e_cepoch);
+	lp += get_okdates (lp, &op->e_startok, &op->e_endok);
+	*lp++ = ',';
+	lp += fs_date (lp, op->e_epoch);
+	if (op->e_mag.whichm == MAG_gk)
+	    lp += sprintf (lp, ",g%.7g", op->e_mag.m1);
+	else if (op->e_mag.whichm == MAG_HG)
+	    lp += sprintf (lp, ",H%.7g", op->e_mag.m1);
+	else
+	    lp += sprintf (lp, ",%.7g", op->e_mag.m1);
+	lp += sprintf (lp, ",%.7g", op->e_mag.m2);
+	lp += sprintf (lp, ",%.7g", op->e_size);
+}
+
+static void
+write_h (Obj *op, char lp[])
+{
+	lp += sprintf (lp, "%s,h", op->o_name);
+	*lp++ = ',';
+	lp += fs_date (lp, op->h_ep);
+	lp += get_okdates (lp, &op->h_startok, &op->h_endok);
+	lp += sprintf (lp, ",%.7g", op->h_inc);
+	lp += sprintf (lp, ",%.7g", op->h_Om);
+	lp += sprintf (lp, ",%.7g", op->h_om);
+	lp += sprintf (lp, ",%.7g", op->h_e);
+	lp += sprintf (lp, ",%.7g", op->h_qp);
+	*lp++ = ',';
+	lp += fs_date (lp, op->h_epoch);
+	lp += sprintf (lp, ",%.7g", op->h_g);
+	lp += sprintf (lp, ",%.7g", op->h_k);
+	lp += sprintf (lp, ",%.7g", op->h_size);
+}
+
+static void
+write_p (Obj *op, char lp[])
+{
+	lp += sprintf (lp, "%s,p", op->o_name);
+	*lp++ = ',';
+	lp += fs_date (lp, op->p_ep);
+	lp += get_okdates (lp, &op->p_startok, &op->p_endok);
+	lp += sprintf (lp, ",%.7g", op->p_inc);
+	lp += sprintf (lp, ",%.7g", op->p_om);
+	lp += sprintf (lp, ",%.7g", op->p_qp);
+	lp += sprintf (lp, ",%.7g", op->p_Om);
+	*lp++ = ',';
+	lp += fs_date (lp, op->p_epoch);
+	lp += sprintf (lp, ",%.7g", op->p_g);
+	lp += sprintf (lp, ",%.7g", op->p_k);
+	lp += sprintf (lp, ",%.7g", op->p_size);
+}
+
+static void
+write_E (Obj *op, char lp[])
+{
+	lp += sprintf (lp, "%s,E", op->o_name);
+	*lp++ = ',';
+	lp += fs_date (lp, op->es_epoch);
+	lp += get_okdates (lp, &op->es_startok, &op->es_endok);
+	lp += sprintf (lp, ",%.7g", op->es_inc);
+	lp += sprintf (lp, ",%.7g", op->es_raan);
+	lp += sprintf (lp, ",%.7g", op->es_e);
+	lp += sprintf (lp, ",%.7g", op->es_ap);
+	lp += sprintf (lp, ",%.7g", op->es_M);
+	lp += sprintf (lp, ",%.7g", op->es_n);
+	lp += sprintf (lp, ",%.7g", op->es_decay);
+	lp += sprintf (lp, ",%d", op->es_orbit);
+	lp += sprintf (lp, ",%.7g", op->es_drag);
+}
+
+static void
+write_B (Obj *op, char lp[])
+{
+	double tmp;
+
+	lp += sprintf (lp, "%s,B", op->o_name);
+	if (op->f_class)
+	    lp += sprintf (lp, "|%c", op->f_class);
+	if (op->f_spect[0])
+	    lp += sprintf (lp, "|%.*s", (int)sizeof(op->f_spect), op->f_spect);
+	if (op->b_2spect[0])
+	    lp += sprintf (lp, "|%.*s", (int)sizeof(op->b_2spect),op->b_2spect);
+	*lp++ = ',';
+	lp += fs_sexa (lp, radhr(op->f_RA), 2, 36000);
+	if (op->f_pmRA)
+	    lp += sprintf (lp, "|%.6g",cos(op->f_dec)*op->f_pmRA/1.327e-11);
+	*lp++ = ',';
+	lp += fs_sexa (lp, raddeg(op->f_dec), 3, 3600);
+	if (op->f_pmdec)
+	    lp += sprintf (lp, "|%.6g", op->f_pmdec/1.327e-11);
+	lp += sprintf (lp, ",%.2f", get_mag(op));
+	lp += sprintf (lp, "|%.2f", op->b_2mag/MAGSCALE);
+	mjd_year (op->f_epoch, &tmp);
+	lp += sprintf (lp, ",%.6g", tmp); /* %.7g gives 2000.001 */
+	if (op->b_nbp == 0) {
+	    lp += sprintf (lp, ",%.6g",  op->b_bo.bo_a);
+	    lp += sprintf (lp, "|%.6g",  op->b_bo.bo_i);
+	    lp += sprintf (lp, "|%.6g",  op->b_bo.bo_O);
+	    lp += sprintf (lp, "|%.6g",  op->b_bo.bo_e);
+	    lp += sprintf (lp, "|%.6g",  op->b_bo.bo_T);
+	    lp += sprintf (lp, "|%.6g",  op->b_bo.bo_o);
+	    lp += sprintf (lp, "|%.6gy", op->b_bo.bo_P);
+	} else {
+	    int i;
+
+	    for (i = 0; i < op->b_nbp; i++) {
+		BinPos *bp = &op->b_bp[i];
+		lp += sprintf (lp, "%c%.6g", i==0?',':'|', bp->bp_ep);
+		lp += sprintf (lp, "|%.6g", bp->bp_sep);
+		lp += sprintf (lp, "|%.6g", raddeg(bp->bp_pa));
+	    }
+	}
+}
+
+static void
+write_P (Obj *op, char lp[])
+{
+
+	lp += sprintf (lp, "%s,P", op->o_name);
 }
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: dbfmt.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: dbfmt.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/deep.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/deep.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/deep.c	(revision 2551)
@@ -788,3 +788,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: deep.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: deep.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/deepconst.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/deepconst.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/deepconst.h	(revision 2551)
@@ -2,5 +2,5 @@
 #define _CONST_H
 
-/* $Id: deepconst.h,v 1.2 2001-10-22 12:08:26 cmv Exp $ */
+/* $Id: deepconst.h,v 1.3 2004-06-15 16:52:38 cmv Exp $ */
 
 
@@ -31,4 +31,4 @@
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: deepconst.h,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: deepconst.h,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/deltat.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/deltat.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/deltat.c	(revision 2551)
@@ -29,10 +29,10 @@
  * in 2130.
  *
- * Input is mjd (modified julian date from MJD0 on). [stern]
- *  Note that xephem uses a different epoch for this "mjd" than the
+ * Input is mj (modified julian date from MJD0 on). [stern]
+ *  Note that xephem uses a different epoch for this "mj" than the
  *  normal value of JD=240000.5.
  * See AA page B4.
  *
- * Output double deltat(mjd) is ET-UT1 in seconds.
+ * Output double deltat(mj) is ET-UT1 in seconds.
  *
  *
@@ -67,5 +67,5 @@
  *   - adopted #include's for xephem
  *   - made dt[] static
- *   - made mjd the time argument [was: year Y].
+ *   - made mj the time argument [was: year Y].
  *   - updated observed and extrapolated data from tables at
  *	ftp://maia.usno.navy.mil/ser7/ -- data deviated by up to 0.8 s
@@ -74,9 +74,10 @@
  *   - replaced treatment after TABEND by linear extrapolation instead
  *	of second order version
- *   - installed lastmjd cache (made ans static)
+ *   - installed lastmj cache (made ans static)
  *
  *   - no changes to table interpolation scheme and past extrapolations */
 
-#include "P_.h"
+#include <math.h>
+
 #include "astro.h"
 
@@ -161,6 +162,5 @@
  * of the Earth rotation rate in the ET time scale.
  */
-double deltat(mjd)
-double mjd;
+double deltat(double mj)
 {
 	double Y;
@@ -168,14 +168,13 @@
 	int d[6];
 	int i, iy, k;
-	double floor();
 	static double ans;
-	static double lastmjd = -10000;
-
-	if (mjd == lastmjd) {
+	static double lastmj = -10000;
+
+	if (mj == lastmj) {
 	    return(ans);
 	}
-	lastmjd = mjd;
-
-	Y = 2000.0 + (mjd - J2000)/365.25;
+	lastmj = mj;
+
+	Y = 2000.0 + (mj - J2000)/365.25;
 
 	if( Y > TABEND  &&  Y < 2130.0 ) {
@@ -305,3 +304,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: deltat.c,v $ $Date: 2001-10-22 12:08:26 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: deltat.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/earthsat.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/earthsat.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/earthsat.c	(revision 2551)
@@ -23,12 +23,7 @@
 #include <math.h>
 #include <string.h>
-
-#if defined(__STDC__)
 #include <stdlib.h>
-#endif
-
-#include "P_.h"
+
 #include "astro.h"
-#include "circum.h"
 #include "preferences.h"
 
@@ -42,36 +37,37 @@
 typedef double MAT3x3[3][3];
 
-static void esat_prop P_((Now *np, Obj *op, double *SatX, double *SatY, double
-    *SatZ, double *SatVX, double *SatVY, double *SatVZ));
-static void GetSatelliteParams P_((Obj *op));
-static void GetSiteParams P_((Now *np));
-static double Kepler P_((double MeanAnomaly, double Eccentricity));
-static void GetSubSatPoint P_((double SatX, double SatY, double SatZ,
-    double T, double *Latitude, double *Longitude, double *Height));
-static void GetSatPosition P_((double EpochTime, double EpochRAAN,
+static int crazyOp (Now *np, Obj *op);
+static void esat_prop (Now *np, Obj *op, double *SatX, double *SatY, double
+    *SatZ, double *SatVX, double *SatVY, double *SatVZ);
+static void GetSatelliteParams (Obj *op);
+static void GetSiteParams (Now *np);
+static double Kepler (double MeanAnomaly, double Eccentricity);
+static void GetSubSatPoint (double SatX, double SatY, double SatZ,
+    double T, double *Latitude, double *Longitude, double *Height);
+static void GetSatPosition (double EpochTime, double EpochRAAN,
     double EpochArgPerigee, double SemiMajorAxis, double Inclination,
     double Eccentricity, double RAANPrecession, double PerigeePrecession,
     double T, double TrueAnomaly, double *X, double *Y, double *Z,
-    double *Radius, double *VX, double *VY, double *VZ));
-static void GetSitPosition P_((double SiteLat, double SiteLong,
+    double *Radius, double *VX, double *VY, double *VZ);
+static void GetSitPosition (double SiteLat, double SiteLong,
     double SiteElevation, double CrntTime, double *SiteX, double *SiteY,
-    double *SiteZ, double *SiteVX, double *SiteVY, MAT3x3 SiteMatrix));
-static void GetRange P_((double SiteX, double SiteY, double SiteZ,
+    double *SiteZ, double *SiteVX, double *SiteVY, MAT3x3 SiteMatrix);
+static void GetRange (double SiteX, double SiteY, double SiteZ,
     double SiteVX, double SiteVY, double SatX, double SatY, double SatZ,
     double SatVX, double SatVY, double SatVZ, double *Range,
-    double *RangeRate));
-static void GetTopocentric P_((double SatX, double SatY, double SatZ,
+    double *RangeRate);
+static void GetTopocentric (double SatX, double SatY, double SatZ,
     double SiteX, double SiteY, double SiteZ, MAT3x3 SiteMatrix, double *X,
-    double *Y, double *Z));
-static void GetBearings P_((double SatX, double SatY, double SatZ,
+    double *Y, double *Z);
+static void GetBearings (double SatX, double SatY, double SatZ,
     double SiteX, double SiteY, double SiteZ, MAT3x3 SiteMatrix,
-    double *Azimuth, double *Elevation));
-static int Eclipsed P_((double SatX, double SatY, double SatZ,
-    double SatRadius, double CrntTime));
-static void InitOrbitRoutines P_((double EpochDay, int AtEod));
+    double *Azimuth, double *Elevation);
+static int Eclipsed (double SatX, double SatY, double SatZ,
+    double SatRadius, double CrntTime);
+static void InitOrbitRoutines (double EpochDay, int AtEod);
 
 #ifdef USE_ORBIT_PROPAGATOR 
-static void GetPrecession P_((double SemiMajorAxis, double Eccentricity,
-    double Inclination, double *RAANPrecession, double *PerigeePrecession));
+static void GetPrecession (double SemiMajorAxis, double Eccentricity,
+    double Inclination, double *RAANPrecession, double *PerigeePrecession);
 #endif /* USE_ORBIT_PROPAGATOR */
 
@@ -135,7 +131,5 @@
  */
 int
-obj_earthsat (np, op)
-Now *np;
-Obj *op;
+obj_earthsat (Now *np, Obj *op)
 {
 	double Radius;              /* From geocenter                  */
@@ -267,9 +261,6 @@
  */
 static void
-esat_prop (np, op, SatX, SatY, SatZ, SatVX, SatVY, SatVZ)
-Now *np;
-Obj *op;
-double *SatX,*SatY,*SatZ;
-double *SatVX,*SatVY,*SatVZ;
+esat_prop (Now *np, Obj *op, double *SatX, double *SatY, double *SatZ,
+double *SatVX, double *SatVY, double *SatVZ)
 {
 #ifdef USE_ORBIT_PROPAGATOR
@@ -284,4 +275,9 @@
 	double Radius;
 	double CrntTime;
+
+	if (crazyOp (np, op)) {
+	    *SatX = *SatY = *SatZ = *SatVX = *SatVY = *SatVZ = 0;
+	    return;
+	}
 
 	SemiMajorAxis = 331.25 * exp(2*log(MinutesPerDay/epochMeanMotion)/3);
@@ -331,4 +327,9 @@
 	double dt;
 	int yr;
+
+	if (crazyOp (np, op)) {
+	    *SatX = *SatY = *SatZ = *SatVX = *SatVY = *SatVZ = 0;
+	    return;
+	}
 
 	/* init */
@@ -392,10 +393,16 @@
 }
 
+/* return 1 if op is crazy @ np */
+static int
+crazyOp (Now *np, Obj *op)
+{
+	/* figure its daft if long enough to decay 1 rev/day */
+	return (fabs(op->es_epoch - mjd) > 1/op->es_decay);
+}
 
 /* grab the xephem stuff from op and copy into orbit's globals.
  */
 static void
-GetSatelliteParams(op)
-Obj *op;
+GetSatelliteParams(Obj *op)
 {
 	/* the following are for the orbit functions */
@@ -429,6 +436,5 @@
  
 static void
-GetSiteParams(np)
-Now *np;
+GetSiteParams(Now *np)
 {
 	SiteLat = lat;
@@ -465,7 +471,5 @@
  
 static
-double Kepler(MeanAnomaly,Eccentricity)
-register double MeanAnomaly,Eccentricity;
- 
+double Kepler(double MeanAnomaly, double Eccentricity)
 {
 register double E;              /* Eccentric Anomaly                    */
@@ -494,7 +498,6 @@
  
 static void
-GetSubSatPoint(SatX,SatY,SatZ,T,Latitude,Longitude,Height)
-double SatX,SatY,SatZ,T;
-double *Latitude,*Longitude,*Height;
+GetSubSatPoint(double SatX, double SatY, double SatZ, double T,
+double *Latitude, double *Longitude, double *Height)
 {
     double r;
@@ -524,8 +527,6 @@
 #ifdef USE_ORBIT_PROPAGATOR
 static void
-GetPrecession(SemiMajorAxis,Eccentricity,Inclination,
-        RAANPrecession,PerigeePrecession)
-double SemiMajorAxis,Eccentricity,Inclination;
-double *RAANPrecession,*PerigeePrecession;
+GetPrecession(double SemiMajorAxis, double Eccentricity, double Inclination,
+double *RAANPrecession, double *PerigeePrecession)
 {
   *RAANPrecession = 9.95*pow(EarthRadius/SemiMajorAxis,3.5) * cos(Inclination)
@@ -544,12 +545,9 @@
 
 static void
-GetSatPosition(EpochTime,EpochRAAN,EpochArgPerigee,SemiMajorAxis,
-	Inclination,Eccentricity,RAANPrecession,PerigeePrecession,
-	T,TrueAnomaly,X,Y,Z,Radius,VX,VY,VZ)
- 
-double EpochTime,EpochRAAN,EpochArgPerigee;
-double SemiMajorAxis,Inclination,Eccentricity;
-double RAANPrecession,PerigeePrecession,T, TrueAnomaly;
-double *X,*Y,*Z,*Radius,*VX,*VY,*VZ;
+GetSatPosition(double EpochTime, double EpochRAAN, double EpochArgPerigee,
+double SemiMajorAxis, double Inclination, double Eccentricity,
+double RAANPrecession, double PerigeePrecession, double T,
+double TrueAnomaly, double *X, double *Y, double *Z, double *Radius,
+double *VX, double *VY, double *VZ)
 
 {
@@ -607,11 +605,7 @@
 
 static void
-GetSitPosition(SiteLat,SiteLong,SiteElevation,CrntTime,
-             SiteX,SiteY,SiteZ,SiteVX,SiteVY,SiteMatrix)
-
-double SiteLat,SiteLong,SiteElevation,CrntTime;
-double *SiteX,*SiteY,*SiteZ,*SiteVX,*SiteVY;
-MAT3x3 SiteMatrix;
-
+GetSitPosition(double SiteLat, double SiteLong, double SiteElevation,
+double CrntTime, double *SiteX, double *SiteY, double *SiteZ, double *SiteVX,
+double *SiteVY, MAT3x3 SiteMatrix)
 {
     static double G1,G2; /* Used to correct for flattening of the Earth */
@@ -663,10 +657,7 @@
 
 static void
-GetRange(SiteX,SiteY,SiteZ,SiteVX,SiteVY,
-	SatX,SatY,SatZ,SatVX,SatVY,SatVZ,Range,RangeRate)
-
-double SiteX,SiteY,SiteZ,SiteVX,SiteVY;
-double SatX,SatY,SatZ,SatVX,SatVY,SatVZ;
-double *Range,*RangeRate;
+GetRange(double SiteX, double SiteY, double SiteZ, double SiteVX,
+double SiteVY, double SatX, double SatY, double SatZ, double SatVX,
+double SatVY, double SatVZ, double *Range, double *RangeRate)
 {
     double DX,DY,DZ;
@@ -684,8 +675,7 @@
 
 static void
-GetTopocentric(SatX,SatY,SatZ,SiteX,SiteY,SiteZ,SiteMatrix,X,Y,Z)
-double SatX,SatY,SatZ,SiteX,SiteY,SiteZ;
-double *X,*Y,*Z;
-MAT3x3 SiteMatrix;
+GetTopocentric(double SatX, double SatY, double SatZ, double SiteX,
+double SiteY, double SiteZ, MAT3x3 SiteMatrix, double *X, double *Y,
+double *Z)
 {
     SatX -= SiteX;
@@ -702,8 +692,7 @@
 
 static void
-GetBearings(SatX,SatY,SatZ,SiteX,SiteY,SiteZ,SiteMatrix,Azimuth,Elevation)
-double SatX,SatY,SatZ,SiteX,SiteY,SiteZ;
-MAT3x3 SiteMatrix;
-double *Azimuth,*Elevation;
+GetBearings(double SatX, double SatY, double SatZ, double SiteX,
+double SiteY, double SiteZ, MAT3x3 SiteMatrix, double *Azimuth,
+double *Elevation)
 {
     double x,y,z;
@@ -720,6 +709,6 @@
 
 static int
-Eclipsed(SatX,SatY,SatZ,SatRadius,CrntTime)
-double SatX,SatY,SatZ,SatRadius,CrntTime;
+Eclipsed(double SatX, double SatY, double SatZ, double SatRadius,
+double CrntTime)
 {
     double MeanAnomaly,TrueAnomaly;
@@ -751,7 +740,5 @@
 
 static void
-InitOrbitRoutines(EpochDay, AtEod)
-double EpochDay;
-int AtEod;
+InitOrbitRoutines(double EpochDay, int AtEod)
 {
     double T,T2,T3,Omega;
@@ -797,3 +784,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: earthsat.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: earthsat.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/eq_ecl.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/eq_ecl.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/eq_ecl.c	(revision 2551)
@@ -2,9 +2,8 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
-static void ecleq_aux P_((int sw, double mjd, double x, double y,
-    double *p, double *q));
+static void ecleq_aux (int sw, double mj, double x, double y,
+    double *p, double *q);
 
 #define	EQtoECL	1
@@ -12,21 +11,18 @@
 
 
-/* given the modified Julian date, mjd, and an equitorial ra and dec, each in
- * radians, find the corresponding geocentric ecliptic latitude, *lat, and
- * longititude, *lng, also each in radians.
+/* given the modified Julian date, mj, and an equitorial ra and dec, each in
+ * radians, find the corresponding geocentric ecliptic latitude, *lt, and
+ * longititude, *lg, also each in radians.
  * correction for the effect on the angle of the obliquity due to nutation is
  * not included.
  */
 void
-eq_ecl (mjd, ra, dec, lat, lng)
-double mjd;
-double ra, dec;
-double *lat, *lng;
+eq_ecl (double mj, double ra, double dec, double *lt, double *lg)
 {
-	ecleq_aux (EQtoECL, mjd, ra, dec, lng, lat);
+	ecleq_aux (EQtoECL, mj, ra, dec, lg, lt);
 }
 
-/* given the modified Julian date, mjd, and a geocentric ecliptic latitude,
- * *lat, and longititude, *lng, each in radians, find the corresponding
+/* given the modified Julian date, mj, and a geocentric ecliptic latitude,
+ * *lt, and longititude, *lg, each in radians, find the corresponding
  * equitorial ra and dec, also each in radians.
  * correction for the effect on the angle of the obliquity due to nutation is
@@ -34,29 +30,26 @@
  */
 void
-ecl_eq (mjd, lat, lng, ra, dec)
-double mjd;
-double lat, lng;
-double *ra, *dec;
+ecl_eq (double mj, double lt, double lg, double *ra, double *dec)
 {
-	ecleq_aux (ECLtoEQ, mjd, lng, lat, ra, dec);
+	ecleq_aux (ECLtoEQ, mj, lg, lt, ra, dec);
 }
 
 static void
-ecleq_aux (sw, mjd, x, y, p, q)
-int sw;			/* +1 for eq to ecliptic, -1 for vv. */
-double mjd;
-double x, y;		/* sw==1: x==ra, y==dec.  sw==-1: x==lng, y==lat. */
-double *p, *q;		/* sw==1: p==lng, q==lat. sw==-1: p==ra, q==dec. */
+ecleq_aux (
+int sw,			/* +1 for eq to ecliptic, -1 for vv. */
+double mj,
+double x, double y,	/* sw==1: x==ra, y==dec.  sw==-1: x==lg, y==lt. */
+double *p, double *q)	/* sw==1: p==lg, q==lt. sw==-1: p==ra, q==dec. */
 {
-	static double lastmjd = -10000;	/* last mjd calculated */
+	static double lastmj = -10000;	/* last mj calculated */
 	static double seps, ceps;	/* sin and cos of mean obliquity */
 	double sx, cx, sy, cy, ty, sq;
 
-	if (mjd != lastmjd) {
+	if (mj != lastmj) {
 	    double eps;
-	    obliquity (mjd, &eps);		/* mean obliquity for date */
+	    obliquity (mj, &eps);		/* mean obliquity for date */
     	    seps = sin(eps);
 	    ceps = cos(eps);
-	    lastmjd = mjd;
+	    lastmj = mj;
 	}
 
@@ -77,3 +70,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: eq_ecl.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: eq_ecl.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/eq_gal.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/eq_gal.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/eq_gal.c	(revision 2551)
@@ -4,9 +4,8 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
-static void galeq_aux P_((int sw, double x, double y, double *p, double *q));
-static void galeq_init P_((void));
+static void galeq_aux (int sw, double x, double y, double *p, double *q);
+static void galeq_init (void);
 
 #define	EQtoGAL	1
@@ -18,40 +17,36 @@
 static double gpd = degrad(27.12825);   /* Dec of  " */
 static double cgpd, sgpd;		/* cos() and sin() of gpd */
-static double mjd2000;			/* mjd of 2000 */
+static double mj2000;			/* mj of 2000 */
 static int before;			/* whether these have been set yet */
 
 /* given ra and dec, each in radians, for the given epoch, find the
- * corresponding galactic latitude, *lat, and longititude, *lng, also each in
+ * corresponding galactic latitude, *lt, and longititude, *lg, also each in
  * radians.
  */
 void
-eq_gal (mjd, ra, dec, lat, lng)
-double mjd, ra, dec;
-double *lat, *lng;
+eq_gal (double mj, double ra, double dec, double *lt, double *lg)
 {
 	galeq_init();
-	precess (mjd, mjd2000, &ra, &dec);
-	galeq_aux (EQtoGAL, ra, dec, lng, lat);
+	precess (mj, mj2000, &ra, &dec);
+	galeq_aux (EQtoGAL, ra, dec, lg, lt);
 }
 
-/* given galactic latitude, lat, and longititude, lng, each in radians, find
+/* given galactic latitude, lt, and longititude, lg, each in radians, find
  * the corresponding equitorial ra and dec, also each in radians, at the 
  * given epoch.
  */
 void
-gal_eq (mjd, lat, lng, ra, dec)
-double mjd, lat, lng;
-double *ra, *dec;
+gal_eq (double mj, double lt, double lg, double *ra, double *dec)
 {
 	galeq_init();
-	galeq_aux (GALtoEQ, lng, lat, ra, dec);
-	precess (mjd2000, mjd, ra, dec);
+	galeq_aux (GALtoEQ, lg, lt, ra, dec);
+	precess (mj2000, mj, ra, dec);
 }
 
 static void
-galeq_aux (sw, x, y, p, q)
-int sw;			/* +1 for eq to gal, -1 for vv. */
-double x, y;		/* sw==1: x==ra, y==dec.  sw==-1: x==lng, y==lat. */
-double *p, *q;		/* sw==1: p==lng, q==lat. sw==-1: p==ra, q==dec. */
+galeq_aux (
+int sw,			/* +1 for eq to gal, -1 for vv. */
+double x, double y,	/* sw==1: x==ra, y==dec.  sw==-1: x==lg, y==lt. */
+double *p, double *q)	/* sw==1: p==lg, q==lt. sw==-1: p==ra, q==dec. */
 {
 	double sy, cy, a, ca, sa, b, sq, c, d; 
@@ -96,5 +91,5 @@
 	    cgpd = cos (gpd);
 	    sgpd = sin (gpd);
-	    mjd2000 = J2000;
+	    mj2000 = J2000;
 	    before = 1;
 	}
@@ -102,3 +97,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: eq_gal.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: eq_gal.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/formats.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/formats.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/formats.c	(revision 2551)
@@ -5,5 +5,4 @@
 #include <string.h>
 
-#include "P_.h"
 #include "astro.h"
 #include "preferences.h"
@@ -17,12 +16,10 @@
  *	600:	<w>:mm.m
  *	60:	<w>:mm
- */
-void
-fs_sexa (out, a, w, fracbase)
-char *out;
-double a;
-int w;
-int fracbase;
-{
+ * return number of characters written to out, not counting final '\0'.
+ */
+int
+fs_sexa (char *out, double a, int w, int fracbase)
+{
+	char *out0 = out;
 	unsigned long n;
 	int d;
@@ -44,8 +41,7 @@
 	/* form the whole part; "negative 0" is a special case */
 	if (isneg && d == 0)
-	    (void) sprintf (out, "%*s-0", w-2, "");
+	    out += sprintf (out, "%*s-0", w-2, "");
 	else
-	    (void) sprintf (out, "%*d", w, isneg ? -d : d);
-	out += w;
+	    out += sprintf (out, "%*d", w, isneg ? -d : d);
 
 	/* do the rest */
@@ -53,39 +49,41 @@
 	case 60:	/* dd:mm */
 	    m = f/(fracbase/60);
-	    (void) sprintf (out, ":%02d", m);
+	    out += sprintf (out, ":%02d", m);
 	    break;
 	case 600:	/* dd:mm.m */
-	    (void) sprintf (out, ":%02d.%1d", f/10, f%10);
+	    out += sprintf (out, ":%02d.%1d", f/10, f%10);
 	    break;
 	case 3600:	/* dd:mm:ss */
 	    m = f/(fracbase/60);
 	    s = f%(fracbase/60);
-	    (void) sprintf (out, ":%02d:%02d", m, s);
+	    out += sprintf (out, ":%02d:%02d", m, s);
 	    break;
 	case 36000:	/* dd:mm:ss.s*/
 	    m = f/(fracbase/60);
 	    s = f%(fracbase/60);
-	    (void) sprintf (out, ":%02d:%02d.%1d", m, s/10, s%10);
+	    out += sprintf (out, ":%02d:%02d.%1d", m, s/10, s%10);
 	    break;
 	case 360000:	/* dd:mm:ss.ss */
 	    m = f/(fracbase/60);
 	    s = f%(fracbase/60);
-	    (void) sprintf (out, ":%02d:%02d.%02d", m, s/100, s%100);
+	    out += sprintf (out, ":%02d:%02d.%02d", m, s/100, s%100);
 	    break;
 	default:
 	    printf ("fs_sexa: unknown fracbase: %d\n", fracbase);
-	    exit(1);
+	    abort();
 	}
+
+	return (out - out0);
 }
 
 /* put the given modified Julian date, jd, in out[] according to preference
  * format.
- */
-void
-fs_date (out, jd)
-char out[];
-double jd;
+ * return number of characters written to out, not counting final '\0'.
+ */
+int
+fs_date (char out[], double jd)
 {
 	int p = pref_get (PREF_DATE_FORMAT);
+	char *out0 = out;
 	int m, y;
 	double d;
@@ -100,81 +98,50 @@
 	switch (p) {
 	case PREF_YMD:
-	    (void) sprintf (out, "%4d/%02d/%02.6g", y, m, d);
+	    out += sprintf (out, "%4d/%02d/%02.6g", y, m, d);
 	    break;
 	case PREF_DMY:
-	    (void) sprintf (out, "%2.6g/%02d/%-4d", d, m, y);
+	    out += sprintf (out, "%2.6g/%02d/%-4d", d, m, y);
 	    break;
 	case PREF_MDY:
-	    (void) sprintf (out, "%2d/%02.6g/%-4d", m, d, y);
+	    out += sprintf (out, "%2d/%02.6g/%-4d", m, d, y);
 	    break;
 	default:
 	    printf ("fs_date: bad date pref: %d\n", p);
-	    exit (1);
+	    abort();
 	}
-}
-
-/* scan a sexagesimal string and update a double. the string is of the form
- *   H:M:S. a negative value may be indicated by a '-' char before any
- *   component. All components may be integral or real. In addition to ':' the
- *    separator may also be '/' or ';' or ',' or '-'.
- * any components not specified in bp[] are copied from old's.
- *   eg:  ::10	only changes S
- *        10    only changes H
- *        10:0  changes H and M
- */
-void
-f_scansex (o, bp, np)
-double o;	/* old value */
-char bp[];	/* input string */
-double *np;	/* new value */
-{
-	double oh, om, os;
-	double nh, nm, ns;
-	int nneg;
-	double tmp;
-	char c;
-
-	/* fast macro to scan each segment of bp */
-#define	SCANSEX(new,old)						\
-	if (*bp == '-') {nneg = 1; bp++;}				\
-	if (sscanf (bp, "%lf", &new) != 1) new = old;			\
-	while ((c=(*bp)) != '\0') {					\
-	    bp++;							\
-	    if (c==':' || c=='/' || c==';' || c==',' || c=='-')		\
-		break;							\
-	}
-
-	/* get h:m:s components of o in case bp[] defers.
-	 * and constrain to positive for now.
-	 */
-	if (o < 0.0)
-	    o = -o;
-        oh = floor(o);
-	tmp = (o - oh)*60.0;
-	om = floor(tmp);
-	os = (tmp - om)*60.0;
-	
-	/* round to small portion of a second to reduce differencing errors. */
-	if (os > 59.99999) {
-	    os = 0.0;
-	    if ((om += 1.0) >= 60.0) {
-		om = 0.0;
-		oh += 1.0;
-	    }
-	}
-
-	/* scan each component of the buffer */
-	while (*bp == ' ') bp++;
-	nneg = 0;
-	SCANSEX (nh, oh)
-	SCANSEX (nm, om)
-	SCANSEX (ns, os)
-
-	/* back to hours */
-	tmp = ns/3600.0 + nm/60.0 + nh;
-	if (nneg)
-	    tmp = -tmp;
-
-	*np = tmp;
+
+	return (out - out0);
+}
+
+
+/* convert sexagesimal string str AxBxC to double.
+ *   x can be anything non-numeric. Any missing A, B or C will be assumed 0.
+ *   optional - and + can be anywhere.
+ * return 0 if ok, -1 if can't find a thing.
+ */
+int
+f_scansexa (
+const char *str0,	/* input string */
+double *dp)		/* cracked value, if return 0 */
+{
+	double a = 0, b = 0, c = 0;
+	char str[128];
+	char *neg;
+	int r;
+
+	/* copy str0 so we can play with it */
+	strncpy (str, str0, sizeof(str)-1);
+	str[sizeof(str)-1] = '\0';
+
+	neg = strchr(str, '-');
+	if (neg)
+	    *neg = ' ';
+	r = sscanf (str, "%lf%*[^0-9]%lf%*[^0-9]%lf", &a, &b, &c);
+	if (r < 1)
+	    return (-1);
+	*dp = a + b/60 + c/3600;
+	if (neg)
+	    *dp *= -1;
+	return (0);
 }
 
@@ -182,126 +149,56 @@
  *   PREF_DATE_FORMAT preference into its components. allow the day to be a
  *   floating point number,
- * a lone component is always a year if it contains a decimal point or pref
- *   is MDY or DMY and it is not a reasonable month or day value, respectively.
- * leave any unspecified component unchanged.
- * actually, the slashes may be anything but digits or a decimal point.
+ * actually the slashes may be anything but digits.
+ * a lone component with a decimal point is considered a year.
  */
 void
-f_sscandate (bp, pref, m, d, y)
-char *bp;
-int pref;       /* one of PREF_X for PREF_DATE_FORMAT */
-int *m, *y;
-double *d;
-{
-        double comp[3]; /* the three components */
-        int set[3];     /* set[i] is 1 if component i is present */
-	int in;		/* scan state: 1 while we are in a component */
-	int ncomp;	/* incremented as each component is discovered */
-	int ndp;	/* number of decimal points in last component */
-        char *bp0 = NULL, c;
-
-	set[0] = set[1] = set[2] = 0;
-	ncomp = 0;
-	in = 0;
-	ndp = 0;
-
-	/* scan the input string.
-	 * '\0' counts as a component terminator too.
-	 */
-	do {
-	    /* here, *bp is the next character to be investigated */
-	    c = *bp;
-	    if (c == '.' || isdigit(c) || (c == '-' && !in)) {
-		/* found what passes for a floating point number */
-		if (in == 0) {
-		    /* save the beginning of it in bp0 and init ndp */
-		    bp0 = bp;
-		    in = 1;
-		    ndp = 0;
-		}
-		if (c == '.')
-		    ndp++;
-	    } else if (c != ' ') {
-		/* not in a number now ... */
-		if (in) {
-		    /* ... but we *were* in a number, so it counts */
-		    if (ncomp >= 3)
-			return;	/* too many components.. just bail */
-		    comp[ncomp] = atod (bp0);
-		    set[ncomp] = 1;
-		    in = 0;
-		}
-
-		/* regardless, a non-blank non-float means another component */
-		ncomp++;
+f_sscandate (
+char *bp,
+int pref,       /* one of PREF_X for PREF_DATE_FORMAT */
+int *m,
+double *d,
+int *y)
+{
+        double c[3]; /* the three components */
+	int n;
+
+	memset (c, 0, sizeof(c));
+	n = sscanf (bp, "%lf%*[^0-9]%lf%*[^0-9]%lf", &c[0], &c[1], &c[2]);
+	if (n == 1 && (strchr(bp, '.')
+			|| (pref == PREF_MDY && (c[0] < 1 || c[0] > 12))
+			|| (pref == PREF_DMY && (c[0] < 1 || c[0] > 31)))) {
+	    double Mjd;
+	    year_mjd (c[0], &Mjd);
+	    mjd_cal (Mjd, m, d, y);
+	} else {
+	    switch (pref) {
+	    case PREF_MDY:
+		if (n > 0 && c[0] != 0)
+		    *m = (int)c[0];
+		if (n > 1 && c[1] != 0)
+		    *d = c[1];
+		if (n > 2 && c[2] != 0)
+		    *y = (int)c[2];
+		break;
+	    case PREF_YMD:
+		if (n > 0 && c[0] != 0)
+		    *y = (int)c[0];
+		if (n > 1 && c[1] != 0)
+		    *m = (int)c[1];
+		if (n > 2 && c[2] != 0)
+		    *d = c[2];
+		break;
+	    case PREF_DMY:
+		if (n > 1 && c[0] != 0)
+		    *d = c[0];
+		if (n > 2 && c[1] != 0)
+		    *m = (int)c[1];
+		if (n > 3 && c[2] != 0)
+		    *y = (int)c[2];
+		break;
 	    }
-	    bp++;
-	} while (c);
-
-	/* it's a decimal year if there is exactly one component and
-	 *   it contains a decimal point
-	 *   or we are in MDY format and it's not in the range 1..12
-	 *   or we are in DMY format and it's not int the rangle 1..31
-	 */
-	if (ncomp == 1 &&
-		(ndp > 0
-		 || (pref == PREF_MDY && !(comp[0] >= 1 && comp[0] <= 12))
-		 || (pref == PREF_DMY && !(comp[0] >= 1 && comp[0] <= 31)))) {
-	    double Mjd;
-	    year_mjd (comp[0], &Mjd);
-	    mjd_cal (Mjd, m, d, y);
-	    return;
 	}
-
-        switch (pref) {
-        case PREF_MDY:
-            if (set[0]) *m = (int)comp[0];
-            if (set[1]) *d = comp[1];
-            if (set[2]) *y = (int)comp[2];
-            break;
-        case PREF_YMD:
-            if (set[0]) *y = (int)comp[0];
-            if (set[1]) *m = (int)comp[1];
-            if (set[2]) *d = comp[2];
-            break;
-        case PREF_DMY:
-            if (set[0]) *d = comp[0];
-            if (set[1]) *m = (int)comp[1];
-            if (set[2]) *y = (int)comp[2];
-            break;
-	}
-}
-
-/* given a string of the form xx:mm[:ss] or xx:mm.dd, convert it to a double at
- * *dp. actually, ':' may also be ';', '/' or ',' too. all components may be 
- * floats.
- * return -1 if trouble, else 0
- */
-int
-scansex (str, dp)
-char *str;
-double *dp;
-{
-	double x, m = 0.0, s = 0.0;
-	int isneg;
-	int nf;
-
-	while (isspace(*str))
-	    str++;
-	if (*str == '-') {
-	    isneg = 1;
-	    str++;
-	} else
-	    isneg = 0;
-
-	nf = sscanf (str, "%lf%*[:;/,]%lf%*[:;/,]%lf", &x, &m, &s);
-	if (nf < 1)
-	    return (-1);
-	*dp = x + m/60.0 + s/3600.0;
-	if (isneg)
-	    *dp = - *dp;
-	return (0);
 }
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: formats.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: formats.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/helio.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/helio.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/helio.c	(revision 2551)
@@ -3,5 +3,4 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
@@ -12,7 +11,5 @@
  */
 void
-heliocorr (jd, ra, dec, hcp)
-double jd, ra, dec;
-double *hcp;
+heliocorr (double jd, double ra, double dec, double *hcp)
 {
 	double e;	/* obliquity of ecliptic */
@@ -52,3 +49,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: helio.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: helio.c,v $ $Date: 2004-06-15 16:52:38 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/jupmoon.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/jupmoon.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/jupmoon.c	(revision 2551)
@@ -0,0 +1,342 @@
+/* jupiter moon info */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "astro.h"
+#include "bdl.h"
+
+static int use_bdl (double jd, char *dir, MoonData md[J_NMOONS]);
+static void meeus_jupiter (double d, double *cmlI, double *cmlII,
+    MoonData md[J_NMOONS]);
+static void moonradec (double jupsize, MoonData md[J_NMOONS]);
+static void moonSVis (Obj *eop, Obj *jop, MoonData md[J_NMOONS]);
+static void moonEVis (MoonData md[J_NMOONS]);
+
+/* moon table and a few other goodies and when it was last computed */
+static double mdmjd = -123456;
+static MoonData jmd[J_NMOONS] = {
+    {"Jupiter", NULL},
+    {"Io", "I"},
+    {"Europa", "II"},
+    {"Ganymede", "III"},
+    {"Callisto", "IV"}
+};
+static double sizemjd;	/* size at last mjd */
+static double cmlImjd;	/* central meridian long sys I, at last mjd */
+static double cmlIImjd;	/*    "                      II      " */
+
+/* file containing BDL coefficients */
+static char jbdlfn[] = "jupiter.9910";
+
+/* get jupiter info in md[0], moon info in md[1..J_NMOONS-1].
+ * if !dir always use meeus model.
+ * if !jop caller just wants md[] for names
+ * N.B. we assume eop and jop are updated.
+ */
+void
+jupiter_data (
+double Mjd,		/* mjd */
+char dir[],             /* dir in which to look for helper files */
+Obj *eop,               /* earth == Sun */
+Obj *jop,		/* jupiter */
+double *sizep,		/* jup angular diam, rads */
+double *cmlI, double *cmlII,	/* central meridian longitude, rads */
+MoonData md[J_NMOONS])	/* return info */
+{
+        double JD;
+
+	/* always copy back at least for name */
+	memcpy (md, jmd, sizeof(jmd));
+
+	/* nothing else if repeat call or just want names */
+	if (Mjd == mdmjd || !jop) {
+	    if (jop) {
+		*sizep = sizemjd;
+		*cmlI = cmlImjd;
+		*cmlII = cmlIImjd;
+	    }
+	    return;
+	}
+	JD = Mjd + MJD0;
+
+	/* planet in [0] */
+	md[0].ra = jop->s_ra;
+	md[0].dec = jop->s_dec;
+	md[0].mag = get_mag(jop);
+	md[0].x = 0;
+	md[0].y = 0;
+	md[0].z = 0;
+	md[0].evis = 1;
+	md[0].svis = 1;
+
+	/* size is straight from jop */
+	*sizep = degrad(jop->s_size/3600.0);
+
+	/* mags from JPL ephemeris */
+	md[1].mag = 5.7;
+	md[2].mag = 5.8;
+	md[3].mag = 5.3;
+	md[4].mag = 6.7;
+
+	/* get moon data from BDL if possible, else Meeus' model.
+	 * always use Meeus for cml
+	 */
+	if (dir && use_bdl (JD, dir, md) == 0)
+	    meeus_jupiter (Mjd, cmlI, cmlII, NULL);
+	else
+	    meeus_jupiter (Mjd, cmlI, cmlII, md);
+
+	/* set visibilities */
+	moonSVis (eop, jop, md);
+	moonEVis (md);
+
+	/* fill in moon ra and dec */
+	moonradec (*sizep, md);
+
+	/* save */
+	mdmjd = Mjd;
+	sizemjd = *sizep;
+	cmlImjd = *cmlI;
+	cmlIImjd = *cmlII;
+	memcpy (jmd, md, sizeof(jmd));
+}
+
+/* hunt for BDL file in dir[] and use if possible
+ * return 0 if ok, else -1
+ */
+static int
+use_bdl (
+double JD,		/* julian date */
+char dir[],		/* directory */
+MoonData md[J_NMOONS])	/* fill md[1..NM-1].x/y/z for each moon */
+{
+#define	JUPRAU	.0004769108	/* jupiter radius, AU */
+	double x[J_NMOONS], y[J_NMOONS], z[J_NMOONS];
+	char buf[1024];
+	FILE *fp;
+	int i;
+
+	/* only valid 1999 through 2010 */
+	if (JD < 2451179.50000 || JD >= 2455562.5)
+	    return (-1);
+
+	/* open */
+	(void) sprintf (buf, "%s/%s", dir, jbdlfn);
+	fp = fopen (buf, "r");
+	if (!fp)
+	    return (-1);
+
+	/* use it */
+	if ((i = read_bdl (fp, JD, x, y, z, buf)) < 0) {
+	    fprintf (stderr, "%s: %s\n", jbdlfn, buf);
+	    fclose (fp);
+	    return (-1);
+	}
+	if (i != J_NMOONS-1) {
+	    fprintf (stderr, "%s: BDL says %d moons, code expects %d", jbdlfn, 
+								i, J_NMOONS-1);
+	    fclose (fp);
+	    return (-1);
+	}
+
+	/* copy into md[1..NM-1] with our scale and sign conventions */
+	for (i = 1; i < J_NMOONS; i++) {
+	    md[i].x =  x[i-1]/JUPRAU;	/* we want jup radii +E */
+	    md[i].y = -y[i-1]/JUPRAU;	/* we want jup radii +S */
+	    md[i].z = -z[i-1]/JUPRAU;	/* we want jup radii +front */
+	}
+
+	/* ok */
+	fclose (fp);
+	return (0);
+}
+
+/* compute location of GRS and Galilean moons.
+ * if md == NULL, just to cml.
+ * from "Astronomical Formulae for Calculators", 2nd ed, by Jean Meeus,
+ *   Willmann-Bell, Richmond, Va., U.S.A. (c) 1982, chapters 35 and 36.
+ */
+static void
+meeus_jupiter(
+double d,
+double *cmlI, double *cmlII,	/* central meridian longitude, rads */
+MoonData md[J_NMOONS])	/* fill in md[1..NM-1].x/y/z for each moon.
+			 * N.B. md[0].ra/dec must already be set
+			 */
+{
+#define POLE_RA         degrad(268.05)  /* RA of Jupiter's north pole */
+#define POLE_DEC        degrad(64.50)   /* Dec of Jupiter's north pole */
+#define	dsin(x)	sin(degrad(x))
+#define	dcos(x)	cos(degrad(x))
+	double A, B, Del, J, K, M, N, R, V;
+	double cor_u1, cor_u2, cor_u3, cor_u4;
+	double solc, tmp, G, H, psi, r, r1, r2, r3, r4;
+	double u1, u2, u3, u4;
+	double lam, Ds;
+	double z1, z2, z3,  z4;
+	double De, dsinDe;
+	double theta, phi;
+	double tvc, pvc;
+	double salpha, calpha;
+	int i;
+
+	V = 134.63 + 0.00111587 * d;
+
+	M = (358.47583 + 0.98560003*d);
+	N = (225.32833 + 0.0830853*d) + 0.33 * dsin (V);
+
+	J = 221.647 + 0.9025179*d - 0.33 * dsin(V);
+
+	A = 1.916*dsin(M) + 0.02*dsin(2*M);
+	B = 5.552*dsin(N) + 0.167*dsin(2*N);
+	K = (J+A-B);
+	R = 1.00014 - 0.01672 * dcos(M) - 0.00014 * dcos(2*M);
+	r = 5.20867 - 0.25192 * dcos(N) - 0.00610 * dcos(2*N);
+	Del = sqrt (R*R + r*r - 2*R*r*dcos(K));
+	psi = raddeg (asin (R/Del*dsin(K)));
+
+	*cmlI  = degrad(268.28 + 877.8169088*(d - Del/173) + psi - B);
+	range (cmlI, 2*PI);
+	*cmlII = degrad(290.28 + 870.1869088*(d - Del/173) + psi - B);
+	range (cmlII, 2*PI);
+
+	/* that's it if don't want moon info too */
+	if (!md)
+	    return;
+
+	solc = (d - Del/173.);	/* speed of light correction */
+	tmp = psi - B;
+
+	u1 = 84.5506 + 203.4058630 * solc + tmp;
+	u2 = 41.5015 + 101.2916323 * solc + tmp;
+	u3 = 109.9770 + 50.2345169 * solc + tmp;
+	u4 = 176.3586 + 21.4879802 * solc + tmp;
+
+	G = 187.3 + 50.310674 * solc;
+	H = 311.1 + 21.569229 * solc;
+      
+	cor_u1 =  0.472 * dsin (2*(u1-u2));
+	cor_u2 =  1.073 * dsin (2*(u2-u3));
+	cor_u3 =  0.174 * dsin (G);
+	cor_u4 =  0.845 * dsin (H);
+      
+	r1 = 5.9061 - 0.0244 * dcos (2*(u1-u2));
+	r2 = 9.3972 - 0.0889 * dcos (2*(u2-u3));
+	r3 = 14.9894 - 0.0227 * dcos (G);
+	r4 = 26.3649 - 0.1944 * dcos (H);
+
+	md[1].x = -r1 * dsin (u1+cor_u1);
+	md[2].x = -r2 * dsin (u2+cor_u2);
+	md[3].x = -r3 * dsin (u3+cor_u3);
+	md[4].x = -r4 * dsin (u4+cor_u4);
+
+	lam = 238.05 + 0.083091*d + 0.33*dsin(V) + B;
+	Ds = 3.07*dsin(lam + 44.5);
+	De = Ds - 2.15*dsin(psi)*dcos(lam+24.)
+		- 1.31*(r-Del)/Del*dsin(lam-99.4);
+	dsinDe = dsin(De);
+
+	z1 = r1 * dcos(u1+cor_u1);
+	z2 = r2 * dcos(u2+cor_u2);
+	z3 = r3 * dcos(u3+cor_u3);
+	z4 = r4 * dcos(u4+cor_u4);
+
+	md[1].y = z1*dsinDe;
+	md[2].y = z2*dsinDe;
+	md[3].y = z3*dsinDe;
+	md[4].y = z4*dsinDe;
+
+	/* compute sky transformation angle as triple vector product */
+	tvc = PI/2.0 - md[0].dec;
+	pvc = md[0].ra;
+	theta = PI/2.0 - POLE_DEC;
+	phi = POLE_RA;
+	salpha = -sin(tvc)*sin(theta)*(cos(pvc)*sin(phi) - sin(pvc)*cos(phi));
+	calpha = sqrt (1.0 - salpha*salpha);
+
+	for (i = 0; i < J_NMOONS; i++) {
+	    double tx =  md[i].x*calpha + md[i].y*salpha;
+	    double ty = -md[i].x*salpha + md[i].y*calpha;
+	    md[i].x = tx;
+	    md[i].y = ty;
+	}
+
+	md[1].z = z1;
+	md[2].z = z2;
+	md[3].z = z3;
+	md[4].z = z4;
+}
+
+
+/* given jupiter loc in md[0].ra/dec and size, and location of each moon in 
+ * md[1..NM-1].x/y in jup radii, find ra/dec of each moon in md[1..NM-1].ra/dec.
+ */
+static void
+moonradec (
+double jupsize,		/* jup diameter, rads */
+MoonData md[J_NMOONS])	/* fill in RA and Dec */
+{
+	double juprad = jupsize/2;
+	double jupra = md[0].ra;
+	double jupdec = md[0].dec;
+	int i;
+
+	for (i = 1; i < J_NMOONS; i++) {
+	    double dra  = juprad * md[i].x;
+	    double ddec = juprad * md[i].y;
+	    md[i].ra  = jupra + dra;
+	    md[i].dec = jupdec - ddec;
+	}
+}
+
+/* set svis according to whether moon is in sun light */
+static void
+moonSVis(
+Obj *eop,		/* earth == SUN */
+Obj *jop,		/* jupiter */
+MoonData md[J_NMOONS])
+{
+	double esd = eop->s_edist;
+	double eod = jop->s_edist;
+	double sod = jop->s_sdist;
+	double soa = degrad(jop->s_elong);
+	double esa = asin(esd*sin(soa)/sod);
+	double   h = sod*jop->s_hlat;
+	double nod = h*(1./eod - 1./sod);
+	double sca = cos(esa), ssa = sin(esa);
+	int i;
+
+	for (i = 1; i < J_NMOONS; i++) {
+	    MoonData *mdp = &md[i];
+	    double xp =  sca*mdp->x + ssa*mdp->z;
+	    double yp =  mdp->y;
+	    double zp = -ssa*mdp->x + sca*mdp->z;
+	    double ca = cos(nod), sa = sin(nod);
+	    double xpp = xp;
+	    double ypp = ca*yp - sa*zp;
+	    double zpp = sa*yp + ca*zp;
+	    int outside = xpp*xpp + ypp*ypp > 1.0;
+	    int infront = zpp > 0.0;
+	    mdp->svis = outside || infront;
+	}
+}
+
+/* set evis according to whether moon is geometrically visible from earth */
+static void
+moonEVis (MoonData md[J_NMOONS])
+{
+	int i;
+
+	for (i = 1; i < J_NMOONS; i++) {
+	    MoonData *mdp = &md[i];
+	    int outside = mdp->x*mdp->x + mdp->y*mdp->y > 1.0;
+	    int infront = mdp->z > 0.0;
+	    mdp->evis = outside || infront;
+	}
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: jupmoon.c,v $ $Date: 2004-06-15 16:54:12 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/libration.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/libration.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/libration.c	(revision 2551)
@@ -35,5 +35,4 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
@@ -71,6 +70,5 @@
    answer in arc seconds.  */
 static double
-mods3600 (x)
-     double x;
+mods3600 (double x)
 {
   double y;
@@ -85,8 +83,5 @@
    n is the highest harmonic to compute.  */
 static int
-sscc (k, arg, n)
-     int k;
-     double arg;
-     int n;
+sscc (int k, double arg, int n)
 {
   double cu, su, cv, sv, s;
@@ -123,7 +118,5 @@
 
 static int
-dargs (J, plan)
-     double J;
-     struct plantbl *plan;
+dargs (double J, struct plantbl *plan)
 {
   double T2, w;
@@ -229,7 +222,5 @@
 
 static double
-gplan (J, plan)
-     double J;
-     struct plantbl *plan;
+gplan (double J, struct plantbl *plan)
 {
   double su, cu, sv, cv;
@@ -2213,18 +2204,15 @@
  */
 void
-llibration (JD, llatp, llonp)
-double JD;
-double *llatp;
-double *llonp;
+llibration (double JD, double *llatp, double *llonp)
 {
-	double lon, lat;	/* arc seconds */
+	double lg, lt;	/* arc seconds */
 	
-	lon = gplan (JD, &liblon);
-	lat = gplan (JD, &liblat);
-
-	*llonp = degrad (lon/3600.0);
-	*llatp = degrad (lat/3600.0);
+	lg = gplan (JD, &liblon);
+	lt = gplan (JD, &liblat);
+
+	*llonp = degrad (lg/3600.0);
+	*llatp = degrad (lt/3600.0);
 }
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: libration.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: libration.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/magdecl.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/magdecl.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/magdecl.c	(revision 2551)
@@ -0,0 +1,381 @@
+/* DoD NIMA World Magnetic Model.
+ * from http://www.ngdc.noaa.gov
+ *
+#define	TEST_MAIN
+ */
+
+
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include "astro.h"
+
+static char mfn[] = "wmm.cof";	/* file with model coefficients */
+
+static int geomag(FILE *wmmdat, int *maxdeg);
+static int geomg1(FILE *wmmdat, float alt, float glat, float glon,
+	float t, float *dec, float *mdp, float *ti, float *gv);
+
+/* compute magnetic declination for given location, elevation and time.
+ * sign is such that mag bearing = true az + mag deviation.
+ * return 0 if ok, -1 if no model file, -2 if time outside model range.
+ * fill err[] with excuse if return < 0.
+ */
+int
+magdecl (
+double l, double L,		/* geodesic lat, +N, long, +E, rads */
+double e,			/* elevation, m */
+double y,			/* time, decimal year */
+char *dir,			/* dir for model file */
+double *mdp,			/* magnetic deviation, rads E of N */
+char *err)			/* err message if return < 0 */
+{
+	float dlat = raddeg(l);
+	float dlon = raddeg(L);
+	float alt = e/1000.;
+	int maxdeg = 12;
+	float dec, dp, ti, gv;
+	char mfile[1024];
+	FILE *wmmdat;
+	int s;
+
+	/* open model file */
+	sprintf (mfile, "%s/%s", dir, mfn);
+	wmmdat = fopen (mfile, "r");
+	if (!wmmdat) {
+	    sprintf (err, "%s: %s", mfile, strerror(errno));
+	    return (-1);
+	}
+
+	/* compute deviation */
+	geomag(wmmdat, &maxdeg);
+	s = geomg1(wmmdat,alt,dlat,dlon,y,&dec,&dp,&ti,&gv);
+	fclose(wmmdat);
+	if (s < 0) {
+	    sprintf (err, "Magnetic model only available for %g .. %g. See http://www.ngdc.noaa.gov", ti, ti+5);
+	    return (-2);
+	}
+	*mdp = degrad(dec);
+	return (0);
+}
+
+#if defined(TEST_MAIN)
+
+int
+main(int ac, char *av[])
+{
+      char err[1024];
+      float altm, dlat, dlon;
+      float t;
+      double dec;
+
+    S1:
+      printf("\n\n\n ENTER LATITUDE IN DECIMAL DEGREES (+25.0)\n");
+      scanf("%f", &dlat);
+
+      printf(" ENTER LONGITUDE IN DECIMAL DEGREES (-100.0)\n");
+      scanf("%f", &dlon);
+
+      printf(" ENTER ALTITUDE IN METERS\n");
+      scanf("%f", &altm);
+
+      printf(" ENTER TIME IN DECIMAL YEAR\n");
+      scanf("%f",&t);
+
+      if (magdecl (degrad(dlat), degrad(dlon), altm, t, "auxil", &dec,
+								  err) < 0) {
+	  printf ("%s\n", err);
+	  return(1);
+      }
+
+      printf("\n LATITUDE:    = %-7.2f DEG",dlat);
+      printf("\n LONGITUDE:   = %-7.2f DEG\n",dlon);
+      printf("\n ALTITUDE     = %.2f  METERS",altm);
+      printf("\n DATE         = %-5.1f\n",t);
+
+      printf("\n\t\t\t      OUTPUT\n\t\t\t      ------");
+      
+      printf("\n DEC         = %-7.2f DEG", raddeg(dec));
+
+      printf("\n\n\n DO YOU NEED MORE POINT DATA? (y or n)\n");
+      scanf("%s", err);
+      if ((err[0] =='y')||(err[0] == 'Y')) goto S1;
+
+      return(0);
+}
+#endif	/* defined(TEST_MAIN) */
+
+/*************************************************************************
+ * return 0 if ok, -1 if time is out of range with base epoc in *ti
+ */
+
+static int E0000(FILE *wmmdat, int IENTRY, int *maxdeg, float alt,
+float glat, float glon, float t, float *dec, float *mdp, float *ti,
+float *gv)
+{
+     static int maxord,i,icomp,n,m,j,D1,D2,D3,D4;
+     static float c[13][13],cd[13][13],tc[13][13],dp[13][13],snorm[169],
+	  sp[13],cp[13],fn[13],fm[13],pp[13],k[13][13],pi,dtr,a,b,re,
+	  a2,b2,c2,a4,b4,c4,epoc,gnm,hnm,dgnm,dhnm,flnmj,otime,oalt,
+	  olat,olon,dt,rlon,rlat,srlon,srlat,crlon,crlat,srlat2,
+	  crlat2,q,q1,q2,ct,st,r2,r,d,ca,sa,aor,ar,br,bt,bp,bpp,
+	  par,temp1,temp2,parp,bx,by,bz,bh;
+     static char model[20], c_str[81], c_new[5];
+     static float *p = snorm;
+
+     switch(IENTRY){case 0: goto GEOMAG; case 1: goto GEOMG1;}
+
+GEOMAG:
+
+/* INITIALIZE CONSTANTS */
+      maxord = *maxdeg;
+      sp[0] = 0.0;
+      cp[0] = *p = pp[0] = 1.0;
+      dp[0][0] = 0.0;
+      a = 6378.137;
+      b = 6356.7523142;
+      re = 6371.2;
+      a2 = a*a;
+      b2 = b*b;
+      c2 = a2-b2;
+      a4 = a2*a2;
+      b4 = b2*b2;
+      c4 = a4 - b4;
+
+/* READ WORLD MAGNETIC MODEL SPHERICAL HARMONIC COEFFICIENTS */
+      c[0][0] = 0.0;
+      cd[0][0] = 0.0;
+      fgets(c_str, 80, wmmdat);
+      sscanf(c_str,"%f%s",&epoc,model);
+S3:
+      fgets(c_str, 80, wmmdat);
+/* CHECK FOR LAST LINE IN FILE */
+      for (i=0; i<4 && (c_str[i] != '\0'); i++)
+      {
+	c_new[i] = c_str[i];
+	c_new[i+1] = '\0';
+      }
+      icomp = strcmp("9999", c_new);
+      if (icomp == 0) goto S4;
+/* END OF FILE NOT ENCOUNTERED, GET VALUES */
+      sscanf(c_str,"%d%d%f%f%f%f",&n,&m,&gnm,&hnm,&dgnm,&dhnm);
+      if (m <= n)
+      {
+	c[m][n] = gnm;
+	cd[m][n] = dgnm;
+	if (m != 0) 
+	{
+	  c[n][m-1] = hnm;
+	  cd[n][m-1] = dhnm;
+	}
+      }
+      goto S3;
+
+/* CONVERT SCHMIDT NORMALIZED GAUSS COEFFICIENTS TO UNNORMALIZED */
+S4:
+      *snorm = 1.0;
+      for (n=1; n<=maxord; n++) 
+      {
+	*(snorm+n) = *(snorm+n-1)*(float)(2*n-1)/(float)n;
+	j = 2;
+	for (m=0,D1=1,D2=(n-m+D1)/D1; D2>0; D2--,m+=D1) 
+	{
+	  k[m][n] = (float)(((n-1)*(n-1))-(m*m))/(float)((2*n-1)*(2*n-3));
+	  if (m > 0) 
+	  {
+	    flnmj = (float)((n-m+1)*j)/(float)(n+m);
+	    *(snorm+n+m*13) = *(snorm+n+(m-1)*13)*sqrt(flnmj);
+	    j = 1;
+	    c[n][m-1] = *(snorm+n+m*13)*c[n][m-1];
+	    cd[n][m-1] = *(snorm+n+m*13)*cd[n][m-1];
+	  }
+	  c[m][n] = *(snorm+n+m*13)*c[m][n];
+	  cd[m][n] = *(snorm+n+m*13)*cd[m][n];
+	}
+	fn[n] = (float)(n+1);
+	fm[n] = (float)n;
+      }
+      k[1][1] = 0.0;
+
+      otime = oalt = olat = olon = -1000.0;
+      return (0);
+
+/*************************************************************************/
+
+GEOMG1:
+
+      dt = t - epoc;
+      if (otime < 0.0 && (dt < 0.0 || dt > 5.0)) {
+	  *ti = epoc;			/* pass back base time for diag msg */
+	  return (-1);
+      }
+
+      pi = 3.14159265359;
+      dtr = pi/180.0;
+      rlon = glon*dtr;
+      rlat = glat*dtr;
+      srlon = sin(rlon);
+      srlat = sin(rlat);
+      crlon = cos(rlon);
+      crlat = cos(rlat);
+      srlat2 = srlat*srlat;
+      crlat2 = crlat*crlat;
+      sp[1] = srlon;
+      cp[1] = crlon;
+
+/* CONVERT FROM GEODETIC COORDS. TO SPHERICAL COORDS. */
+      if (alt != oalt || glat != olat) 
+      {
+	q = sqrt(a2-c2*srlat2);
+	q1 = alt*q;
+	q2 = ((q1+a2)/(q1+b2))*((q1+a2)/(q1+b2));
+	ct = srlat/sqrt(q2*crlat2+srlat2);
+	st = sqrt(1.0-(ct*ct));
+	r2 = (alt*alt)+2.0*q1+(a4-c4*srlat2)/(q*q);
+	r = sqrt(r2);
+	d = sqrt(a2*crlat2+b2*srlat2);
+	ca = (alt+d)/r;
+	sa = c2*crlat*srlat/(r*d);
+      }
+      if (glon != olon) 
+      {
+	for (m=2; m<=maxord; m++) 
+	{
+	  sp[m] = sp[1]*cp[m-1]+cp[1]*sp[m-1];
+	  cp[m] = cp[1]*cp[m-1]-sp[1]*sp[m-1];
+	}
+      }
+      aor = re/r;
+      ar = aor*aor;
+      br = bt = bp = bpp = 0.0;
+      for (n=1; n<=maxord; n++) 
+      {
+	ar = ar*aor;
+	for (m=0,D3=1,D4=(n+m+D3)/D3; D4>0; D4--,m+=D3) 
+	{
+/*
+   COMPUTE UNNORMALIZED ASSOCIATED LEGENDRE POLYNOMIALS
+   AND DERIVATIVES VIA RECURSION RELATIONS
+*/
+	  if (alt != oalt || glat != olat) 
+	  {
+	    if (n == m) 
+	    {
+	      *(p+n+m*13) = st**(p+n-1+(m-1)*13);
+	      dp[m][n] = st*dp[m-1][n-1]+ct**(p+n-1+(m-1)*13);
+	      goto S50;
+	    }
+	    if (n == 1 && m == 0) 
+	    {
+	      *(p+n+m*13) = ct**(p+n-1+m*13);
+	      dp[m][n] = ct*dp[m][n-1]-st**(p+n-1+m*13);
+	      goto S50;
+	    }
+	    if (n > 1 && n != m) 
+	    {
+	      if (m > n-2) *(p+n-2+m*13) = 0.0;
+	      if (m > n-2) dp[m][n-2] = 0.0;
+	      *(p+n+m*13) = ct**(p+n-1+m*13)-k[m][n]**(p+n-2+m*13);
+	      dp[m][n] = ct*dp[m][n-1] - st**(p+n-1+m*13)-k[m][n]*dp[m][n-2];
+	     }
+	  }
+S50:
+/*
+    TIME ADJUST THE GAUSS COEFFICIENTS
+*/
+	  if (t != otime) 
+	  {
+	    tc[m][n] = c[m][n]+dt*cd[m][n];
+	    if (m != 0) tc[n][m-1] = c[n][m-1]+dt*cd[n][m-1];
+	  }
+/*
+    ACCUMULATE TERMS OF THE SPHERICAL HARMONIC EXPANSIONS
+*/
+	  par = ar**(p+n+m*13);
+	  if (m == 0) 
+	  {
+	    temp1 = tc[m][n]*cp[m];
+	    temp2 = tc[m][n]*sp[m];
+	  }
+	  else 
+	  {
+	    temp1 = tc[m][n]*cp[m]+tc[n][m-1]*sp[m];
+	    temp2 = tc[m][n]*sp[m]-tc[n][m-1]*cp[m];
+	  }
+	  bt = bt-ar*temp1*dp[m][n];
+	  bp += (fm[m]*temp2*par);
+	  br += (fn[n]*temp1*par);
+/*
+    SPECIAL CASE:  NORTH/SOUTH GEOGRAPHIC POLES
+*/
+	  if (st == 0.0 && m == 1) 
+	  {
+	    if (n == 1) pp[n] = pp[n-1];
+	    else pp[n] = ct*pp[n-1]-k[m][n]*pp[n-2];
+	    parp = ar*pp[n];
+	    bpp += (fm[m]*temp2*parp);
+	  }
+	}
+      }
+      if (st == 0.0) bp = bpp;
+      else bp /= st;
+/*
+    ROTATE MAGNETIC VECTOR COMPONENTS FROM SPHERICAL TO
+    GEODETIC COORDINATES
+*/
+      bx = -bt*ca-br*sa;
+      by = bp;
+      bz = bt*sa-br*ca;
+/*
+    COMPUTE DECLINATION (DEC), INCLINATION (DIP) AND
+    TOTAL INTENSITY (TI)
+*/
+      bh = sqrt((bx*bx)+(by*by));
+      *ti = sqrt((bh*bh)+(bz*bz));
+      *dec = atan2(by,bx)/dtr;
+      *mdp = atan2(bz,bh)/dtr;
+/*
+    COMPUTE MAGNETIC GRID VARIATION IF THE CURRENT
+    GEODETIC POSITION IS IN THE ARCTIC OR ANTARCTIC
+    (I.E. GLAT > +55 DEGREES OR GLAT < -55 DEGREES)
+
+    OTHERWISE, SET MAGNETIC GRID VARIATION TO -999.0
+*/
+      *gv = -999.0;
+      if (fabs(glat) >= 55.) 
+      {
+	if (glat > 0.0 && glon >= 0.0) *gv = *dec-glon;
+	if (glat > 0.0 && glon < 0.0) *gv = *dec+fabs(glon);
+	if (glat < 0.0 && glon >= 0.0) *gv = *dec+glon;
+	if (glat < 0.0 && glon < 0.0) *gv = *dec-fabs(glon);
+	if (*gv > +180.0) *gv -= 360.0;
+	if (*gv < -180.0) *gv += 360.0;
+      }
+      otime = t;
+      oalt = alt;
+      olat = glat;
+      olon = glon;
+      return (0);
+}
+
+/*************************************************************************/
+
+static int
+geomag(FILE *wmmdat, int *maxdeg)
+{
+     return (E0000(wmmdat,0,maxdeg,0.0,0.0,0.0,0.0,NULL,NULL,NULL,NULL));
+}
+
+/*************************************************************************/
+
+static int
+geomg1(FILE *wmmdat, float alt, float glat, float glon, float t,
+float *dec, float *mdp, float *ti, float *gv)
+{
+     return (E0000(wmmdat,1,NULL,alt,glat,glon,t,dec,mdp,ti,gv));
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: magdecl.c,v $ $Date: 2004-06-15 16:54:12 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/marsmoon.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/marsmoon.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/marsmoon.c	(revision 2551)
@@ -0,0 +1,213 @@
+/* mars moon info */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "astro.h"
+#include "bdl.h"
+
+static int use_bdl (double JD, char *dir, MoonData md[M_NMOONS]);
+static void moonradec (double msize, MoonData md[M_NMOONS]);
+static void moonSVis (Obj *eop, Obj *mop, MoonData md[M_NMOONS]);
+static void moonEVis (MoonData md[M_NMOONS]);
+
+/* moon table and a few other goodies and when it was last computed */
+static double mdmjd = -123456;
+static MoonData mmd[M_NMOONS] = {
+    {"Mars", NULL},
+    {"Phobos", "I"},
+    {"Deimos", "II"},
+};
+static double sizemjd;
+
+/* file containing BDL coefficients */
+static char mbdlfn[] = "mars.9910";
+
+/* get mars info in md[0], moon info in md[1..M_NMOONS-1].
+ * if !dir always use bruton model.
+ * if !mop caller just wants md[] for names
+ * N.B. we assume eop and mop are updated.
+ */
+void
+marsm_data (
+double Mjd,			/* mjd */
+char dir[],			/* dir in which to look for helper files */
+Obj *eop,			/* earth == Sun */
+Obj *mop,			/* mars */
+double *sizep,			/* mars's angular diam, rads */
+MoonData md[M_NMOONS])		/* return info */
+{
+	double JD, dmag;
+
+	/* always copy back at least for name */
+	memcpy (md, mmd, sizeof(mmd));
+
+	/* nothing else if repeat call or just want names */
+	if (Mjd == mdmjd || !mop) {
+	    if (mop) {
+		*sizep = sizemjd;
+	    }
+	    return;
+	}
+	JD = Mjd + MJD0;
+
+	/* planet in [0] */
+	md[0].ra = mop->s_ra;
+	md[0].dec = mop->s_dec;
+	md[0].mag = get_mag(mop);
+	md[0].x = 0;
+	md[0].y = 0;
+	md[0].z = 0;
+	md[0].evis = 1;
+	md[0].svis = 1;
+
+	/* size is straight from mop */
+	*sizep = degrad(mop->s_size/3600.0);
+
+	/* from Pasachoff/Menzel: brightest @ .6 AU */
+	dmag = 5.0*log10(mop->s_edist + 0.4);
+	md[1].mag = 11.8 + dmag;
+	md[2].mag = 12.9 + dmag;
+
+	/* get moon x,y,z from BDL if possible */
+	if (dir && use_bdl (JD, dir, md) < 0) {
+	    int i;
+	    for (i = 1; i < M_NMOONS; i++)
+		md[i].x = md[i].y = md[i].z = 0.0;
+	    fprintf (stderr, "No mars model available\n");
+	}
+
+	/* set visibilities */
+	moonSVis (eop, mop, md);
+	moonEVis (md);
+
+	/* fill in moon ra and dec */
+	moonradec (*sizep, md);
+
+	/* save */
+	mdmjd = Mjd;
+	sizemjd = *sizep;
+	memcpy (mmd, md, sizeof(mmd));
+}
+
+/* hunt for BDL file in dir[] and use if possible.
+ * return 0 if ok, else -1
+ */
+static int
+use_bdl (
+double JD,		/* julian date */
+char dir[],		/* directory */
+MoonData md[M_NMOONS])	/* fill md[1..NM-1].x/y/z for each moon */
+{
+#define MRAU    .00002269       /* Mars radius, AU */
+	double x[M_NMOONS], y[M_NMOONS], z[M_NMOONS];
+	char buf[1024];
+	FILE *fp;
+	int i;
+
+	/* only valid 1999 through 2010 */
+	if (JD < 2451179.50000 || JD >= 2455562.5)
+	    return (-1);
+
+	/* open */
+	(void) sprintf (buf, "%s/%s", dir, mbdlfn);
+	fp = fopen (buf, "r");
+	if (!fp)
+	    return (-1);
+
+	/* use it */
+	if ((i = read_bdl (fp, JD, x, y, z, buf)) < 0) {
+	    fprintf (stderr, "%s: %s\n", mbdlfn, buf);
+	    fclose (fp);
+	    return (-1);
+	}
+	if (i != M_NMOONS-1) {
+	    fprintf (stderr, "%s: BDL says %d moons, code expects %d", mbdlfn,
+								i, M_NMOONS-1);
+	    fclose (fp);
+	    return (-1);
+	}
+
+	/* copy into md[1..NM-1] with our scale and sign conventions */
+	for (i = 1; i < M_NMOONS; i++) {
+	    md[i].x =  x[i-1]/MRAU;	/* we want mars radii +E */
+	    md[i].y = -y[i-1]/MRAU;	/* we want mars radii +S */
+	    md[i].z = -z[i-1]/MRAU;	/* we want mars radii +front */
+	}
+
+	/* ok */
+	fclose (fp);
+	return (0);
+}
+
+/* given mars loc in md[0].ra/dec and size, and location of each moon in 
+ * md[1..NM-1].x/y in mars radii,find ra/dec of each moon in md[1..NM-1].ra/dec.
+ */
+static void
+moonradec (
+double msize,		/* mars diameter, rads */
+MoonData md[M_NMOONS])	/* fill in RA and Dec */
+{
+	double mrad = msize/2;
+	double mra = md[0].ra;
+	double mdec = md[0].dec;
+	int i;
+
+	for (i = 1; i < M_NMOONS; i++) {
+	    double dra  = mrad * md[i].x;
+	    double ddec = mrad * md[i].y;
+	    md[i].ra  = mra + dra;
+	    md[i].dec = mdec - ddec;
+	}
+}
+
+/* set svis according to whether moon is in sun light */
+static void
+moonSVis(
+Obj *eop,		/* earth == SUN */
+Obj *mop,		/* mars */
+MoonData md[M_NMOONS])
+{
+	double esd = eop->s_edist;
+	double eod = mop->s_edist;
+	double sod = mop->s_sdist;
+	double soa = degrad(mop->s_elong);
+	double esa = asin(esd*sin(soa)/sod);
+	double   h = sod*mop->s_hlat;
+	double nod = h*(1./eod - 1./sod);
+	double sca = cos(esa), ssa = sin(esa);
+	int i;
+
+	for (i = 1; i < M_NMOONS; i++) {
+	    MoonData *mdp = &md[i];
+	    double xp =  sca*mdp->x + ssa*mdp->z;
+	    double yp =  mdp->y;
+	    double zp = -ssa*mdp->x + sca*mdp->z;
+	    double ca = cos(nod), sa = sin(nod);
+	    double xpp = xp;
+	    double ypp = ca*yp - sa*zp;
+	    double zpp = sa*yp + ca*zp;
+	    int outside = xpp*xpp + ypp*ypp > 1.0;
+	    int infront = zpp > 0.0;
+	    mdp->svis = outside || infront;
+	}
+}
+
+/* set evis according to whether moon is geometrically visible from earth */
+static void
+moonEVis (MoonData md[M_NMOONS])
+{
+	int i;
+
+	for (i = 1; i < M_NMOONS; i++) {
+	    MoonData *mdp = &md[i];
+	    int outside = mdp->x*mdp->x + mdp->y*mdp->y > 1.0;
+	    int infront = mdp->z > 0.0;
+	    mdp->evis = outside || infront;
+	}
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: marsmoon.c,v $ $Date: 2004-06-15 16:54:12 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/misc.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/misc.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/misc.c	(revision 2551)
@@ -6,21 +6,12 @@
 #include <stdio.h>
 #include <math.h>
-
-#if defined(__STDC__)
 #include <stdlib.h>
 #include <string.h>
-#else
-extern double atof();
-#endif
-
-#include "P_.h"
+
 #include "astro.h"
-#include "circum.h"
 
 /* zero from loc for len bytes */
 void
-zero_mem (loc, len)
-void *loc;
-unsigned len;
+zero_mem (void *loc, unsigned len)
 {
 	(void) memset (loc, 0, len);
@@ -33,8 +24,5 @@
  */
 int
-tickmarks (min, max, numdiv, ticks)
-double min, max;
-int numdiv;
-double ticks[];
+tickmarks (double min, double max, int numdiv, double ticks[])
 {
         static int factor[] = { 1, 2, 5 };
@@ -47,5 +35,5 @@
         minscale = fabs(max - min);
         delta = minscale/numdiv;
-        for (n=0; n < sizeof(factor)/sizeof(factor[0]); n++) {
+        for (n=0; n < (int)(sizeof(factor)/sizeof(factor[0])); n++) {
 	    double scale;
 	    double x = delta/factor[n];
@@ -67,13 +55,15 @@
  */
 char *
-obj_description (op)
-Obj *op;
-{
-	static struct {
-	    char class;
+obj_description (Obj *op)
+{
+	typedef struct {
+	    char classcode;
 	    char *desc;
-	} fixed_class_map[] = {
+	} CC;
+
+#define	NFCM	((int)(sizeof(fixed_class_map)/sizeof(fixed_class_map[0])))
+	static CC fixed_class_map[] = {
 	    {'A', "Cluster of Galaxies"},
-	    {'B', "Binary Star"},
+	    {'B', "Binary System"},
 	    {'C', "Globular Cluster"},
 	    {'D', "Double Star"},
@@ -94,6 +84,25 @@
 	    {'U', "Cluster, with nebulosity"},
 	    {'V', "Variable Star"},
+	    {'Y', "Supernova"},
 	};
-#define	NFCM	(sizeof(fixed_class_map)/sizeof(fixed_class_map[0]))
+
+#define	NBCM	((int)(sizeof(binary_class_map)/sizeof(binary_class_map[0])))
+	static CC binary_class_map[] = {
+	    {'a', "Astrometric binary"},
+	    {'c', "Cataclysmic variable"},
+	    {'e', "Eclipsing binary"},
+	    {'x', "High-mass X-ray binary"},
+	    {'y', "Low-mass X-ray binary"},
+	    {'o', "Occultation binary"},
+	    {'s', "Spectroscopic binary"},
+	    {'t', "1-line spectral binary"},
+	    {'u', "2-line spectral binary"},
+	    {'v', "Spectrum binary"},
+	    {'b', "Visual binary"},
+	    {'d', "Visual binary, apparent"},
+	    {'q', "Visual binary, optical"},
+	    {'r', "Visual binary, physical"},
+	    {'p', "Exoplanet"},
+	};
 
 	switch (op->o_type) {
@@ -102,8 +111,8 @@
 		int i;
 		for (i = 0; i < NFCM; i++)
-		    if (fixed_class_map[i].class == op->f_class)
+		    if (fixed_class_map[i].classcode == op->f_class)
 			return (fixed_class_map[i].desc);
 	    }
-	    return (op->o_type == FIXED ? "Fixed" : "Field Star");
+	    return ("Fixed");
 	case PARABOLIC:
 	    return ("Solar - Parabolic");
@@ -112,11 +121,32 @@
 	case ELLIPTICAL:
 	    return ("Solar - Elliptical");
-	case PLANET:
-	    return ("Planet");
+	case BINARYSTAR:
+	    if (op->f_class) {
+		int i;
+		for (i = 0; i < NFCM; i++)
+		    if (binary_class_map[i].classcode == op->f_class)
+			return (binary_class_map[i].desc);
+	    }
+	    return ("Binary system");
+	case PLANET: {
+	    static char nsstr[16];
+	    static Obj *biop;
+
+	    if (op->pl_code == SUN)
+		return ("Star");
+	    if (op->pl_code == MOON)
+		return ("Moon of Earth");
+	    if (op->pl_moon == X_PLANET)
+		return ("Planet");
+	    if (!biop)
+		getBuiltInObjs (&biop);
+	    sprintf (nsstr, "Moon of %s", biop[op->pl_code].o_name);
+	    return (nsstr);
+	    }
 	case EARTHSAT:
 	    return ("Earth Sat");
 	default:
 	    printf ("obj_description: unknown type: 0x%x\n", op->o_type);
-	    exit (1);
+	    abort();
 	    return (NULL);	/* for lint */
 	}
@@ -126,7 +156,5 @@
  */
 void
-now_lst (np, lstp)
-Now *np;
-double *lstp;
+now_lst (Now *np, double *lstp)
 {
 	static double last_mjd = -23243, last_lng = 121212, last_lst;
@@ -156,8 +184,5 @@
  */
 void
-radec2ha (np, ra, dec, hap)
-Now *np;
-double ra, dec;
-double *hap;
+radec2ha (Now *np, double ra, double dec, double *hap)
 {
 	double ha, lst;
@@ -182,8 +207,8 @@
  */
 int
-lc (cx, cy, cw, x1, y1, x2, y2, sx1, sy1, sx2, sy2)
-int cx, cy, cw;			/* circle bounding box corner and width */
-int x1, y1, x2, y2;		/* line segment endpoints */
-int *sx1, *sy1, *sx2, *sy2;	/* segment inside the circle */
+lc (
+int cx, int cy, int cw,			/* circle bbox corner and width */
+int x1, int y1, int x2, int y2,		/* line segment endpoints */
+int *sx1, int *sy1, int *sx2, int *sy2)	/* segment inside the circle */
 {
 	int dx = x2 - x1;
@@ -240,10 +265,10 @@
  */
 void
-hg_mag (h, g, rp, rho, rsn, mp)
-double h, g;
-double rp;	/* sun-obj dist, AU */
-double rho;	/* earth-obj dist, AU */
-double rsn;	/* sun-earth dist, AU */
-double *mp;
+hg_mag (
+double h, double g,
+double rp,	/* sun-obj dist, AU */
+double rho,	/* earth-obj dist, AU */
+double rsn,	/* sun-earth dist, AU */
+double *mp)
 {
 	double psi_t, Psi_1, Psi_2, beta;
@@ -265,5 +290,6 @@
 	psi_t = pow (tb2, 1.22);
 	Psi_2 = exp(-1.87*psi_t);
-	*mp = h + 5.0*log10(rp*rho) - 2.5*log10((1-g)*Psi_1 + g*Psi_2);
+	*mp = h + 5.0*log10(rp*rho);
+	if (Psi_1 || Psi_2) *mp -= 2.5*log10((1-g)*Psi_1 + g*Psi_2);
 }
 
@@ -273,10 +299,10 @@
  */
 int
-magdiam (fmag, magstp, scale, mag, size)
-int fmag;	/* faintest mag */
-int magstp;	/* mag range per dot size */
-double scale;	/* rads per pixel */
-double mag;	/* magnitude */
-double size;	/* rads, or 0 */
+magdiam (
+int fmag,	/* faintest mag */
+int magstp,	/* mag range per dot size */
+double scale,	/* rads per pixel */
+double mag,	/* magnitude */
+double size)	/* rads, or 0 */
 {
 	int diam, sized;
@@ -295,9 +321,9 @@
  */
 void
-gk_mag (g, k, rp, rho, mp)
-double g, k;
-double rp;	/* sun-obj dist, AU */
-double rho;	/* earth-obj dist, AU */
-double *mp;
+gk_mag (
+double g, double k,
+double rp,	/* sun-obj dist, AU */
+double rho,	/* earth-obj dist, AU */
+double *mp)
 {
 	*mp = g + 5.0*log10(rho) + 2.5*k*log10(rp);
@@ -309,8 +335,7 @@
  */
 double
-atod (buf)
-char *buf;
-{
-	return (atof (buf));
+atod (char *buf)
+{
+	return (strtod (buf, NULL));
 }
 
@@ -331,11 +356,9 @@
  */
 void
-solve_sphere (A, b, cc, sc, cap, Bp)
-double A, b;
-double cc, sc;
-double *cap, *Bp;
+solve_sphere (double A, double b, double cc, double sc, double *cap, double *Bp)
 {
 	double cb = cos(b), sb = sin(b);
-	double cA = cos(A);
+	double sA, cA = cos(A);
+	double x, y;
 	double ca;
 	double B;
@@ -350,25 +373,8 @@
 	    return;
 
-	if (cc > .99999) {
-	    /* as c approaches 0, B approaches pi - A */
-	    B = PI - A;
-	} else if (cc < -.99999) {
-	    /* as c approaches PI, B approaches A */
-	    B = A;
-	} else {
-	    /* compute cB and sB and remove common factor of sa from quotient.
-	     * be careful where B causes atan to blow.
-	     */
-	    double sA = sin(A);
-	    double x, y;
-
-	    y = sA*sb*sc;
-	    x = cb - ca*cc;
-	
-	    if (fabs(x) < 1e-5)
-		B = y < 0 ? 3*PI/2 : PI/2;
-	    else
-		B = atan2 (y, x);
-	}
+	sA = sin(A);
+	y = sA*sb*sc;
+	x = cb - ca*cc;
+	B = y ? (x ? atan2(y,x) : (y>0 ? PI/2 : -PI/2)) : (x>=0 ? 0 : PI);
 
 	*Bp = B;
@@ -435,6 +441,5 @@
  */
 double
-delra (dra)
-double dra;
+delra (double dra)
 {
 	double fdra = fmod(fabs(dra), 2*PI);
@@ -449,6 +454,5 @@
  */
 int
-is_deepsky (op)
-Obj *op;
+is_deepsky (Obj *op)
 {
 	int deepsky = 0;
@@ -473,3 +477,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: misc.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: misc.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/mjd.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/mjd.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/mjd.c	(revision 2551)
@@ -4,5 +4,4 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
@@ -12,8 +11,5 @@
  */
 void
-cal_mjd (mn, dy, yr, mjd)
-int mn, yr;
-double dy;
-double *mjd;
+cal_mjd (int mn, double dy, int yr, double *mjp)
 {
 	static double last_mjd, last_dy;
@@ -23,5 +19,5 @@
 
 	if (mn == last_mn && yr == last_yr && dy == last_dy) {
-	    *mjd = last_mjd;
+	    *mjp = last_mjd;
 	    return;
 	}
@@ -49,22 +45,19 @@
 	d = (int)(30.6001*(m+1));
 
-	*mjd = b + c + d + dy - 0.5;
+	*mjp = b + c + d + dy - 0.5;
 
 	last_mn = mn;
 	last_dy = dy;
 	last_yr = yr;
-	last_mjd = *mjd;
+	last_mjd = *mjp;
 }
 
 /* given the modified Julian date (number of days elapsed since 1900 jan 0.5,),
- * mjd, return the calendar date in months, *mn, days, *dy, and years, *yr.
- */
-void
-mjd_cal (mjd, mn, dy, yr)
-double mjd;
-int *mn, *yr;
-double *dy;
-{
-	static double last_mjd, last_dy;
+ * mj, return the calendar date in months, *mn, days, *dy, and years, *yr.
+ */
+void
+mjd_cal (double mj, int *mn, double *dy, int *yr)
+{
+	static double last_mj, last_dy;
 	static int last_mn, last_yr;
 	double d, f;
@@ -74,5 +67,5 @@
 	 * 0 is noon the last day of 1899.
 	 */
-	if (mjd == 0.0) {
+	if (mj == 0.0) {
 	    *mn = 12;
 	    *dy = 31.5;
@@ -81,5 +74,5 @@
 	}
 
-	if (mjd == last_mjd) {
+	if (mj == last_mj) {
 	    *mn = last_mn;
 	    *yr = last_yr;
@@ -88,5 +81,5 @@
 	}
 
-	d = mjd + 0.5;
+	d = mj + 0.5;
 	i = floor(d);
 	f = d-i;
@@ -118,5 +111,5 @@
 	last_dy = *dy;
 	last_yr = *yr;
-	last_mjd = mjd;
+	last_mj = mj;
 }
 
@@ -126,7 +119,5 @@
  */
 int
-mjd_dow (mjd, dow)
-double mjd;
-int *dow;
+mjd_dow (double mj, int *dow)
 {
 	/* cal_mjd() uses Gregorian dates on or after Oct 15, 1582.
@@ -137,9 +128,9 @@
 	 * can not easily be accounted for from the cal_mjd() number...
 	 */
-	if (mjd < -53798.5) {
+	if (mj < -53798.5) {
 	    /* pre sept 14, 1752 too hard to correct |:-S */
 	    return (-1);
 	}
-	*dow = ((long)floor(mjd-.5) + 1) % 7;/* 1/1/1900 (mjd 0.5) is a Monday*/
+	*dow = ((long)floor(mj-.5) + 1) % 7;/* 1/1/1900 (mj 0.5) is a Monday*/
 	if (*dow < 0)
 	    *dow += 7;
@@ -149,6 +140,5 @@
 /* given a year, return whether it is a leap year */
 int
-isleapyear (y)
-int y;
+isleapyear (int y)
 {
 	return ((y%4==0 && y%100!=0) || y%400==0);
@@ -157,7 +147,5 @@
 /* given a mjd, return the the number of days in the month.  */
 void
-mjd_dpm (mjd, ndays)
-double mjd;
-int *ndays;
+mjd_dpm (double mj, int *ndays)
 {
 	static short dpm[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
@@ -165,5 +153,5 @@
 	double d;
 
-	mjd_cal (mjd, &m, &d, &y);
+	mjd_cal (mj, &m, &d, &y);
 	*ndays = (m==2 && isleapyear(y)) ? 29 : dpm[m-1];
 }
@@ -171,8 +159,5 @@
 /* given a mjd, return the year and number of days since 00:00 Jan 1 */
 void
-mjd_dayno (mjd, yr, dy)
-double mjd;
-int *yr;
-double *dy;
+mjd_dayno (double mj, int *yr, double *dy)
 {
 	double yrd;
@@ -180,5 +165,5 @@
 	int dpy;
 
-	mjd_year (mjd, &yrd);
+	mjd_year (mj, &yrd);
 	*yr = yri = (int)yrd;
 	dpy = isleapyear(yri) ? 366 : 365;
@@ -188,25 +173,23 @@
 /* given a mjd, return the year as a double. */
 void
-mjd_year (mjd, yr)
-double mjd;
-double *yr;
-{
-	static double last_mjd, last_yr;
+mjd_year (double mj, double *yr)
+{
+	static double last_mj, last_yr;
 	int m, y;
 	double d;
 	double e0, e1;	/* mjd of start of this year, start of next year */
 
-	if (mjd == last_mjd) {
+	if (mj == last_mj) {
 	    *yr = last_yr;
 	    return;
 	}
 
-	mjd_cal (mjd, &m, &d, &y);
+	mjd_cal (mj, &m, &d, &y);
 	if (y == -1) y = -2;
 	cal_mjd (1, 1.0, y, &e0);
 	cal_mjd (1, 1.0, y+1, &e1);
-	*yr = y + (mjd - e0)/(e1 - e0);
-
-	last_mjd = mjd;
+	*yr = y + (mj - e0)/(e1 - e0);
+
+	last_mj = mj;
 	last_yr = *yr;
 }
@@ -214,7 +197,5 @@
 /* given a decimal year, return mjd */
 void
-year_mjd (y, mjd)
-double y;
-double *mjd;
+year_mjd (double y, double *mjp)
 {
 	double e0, e1;	/* mjd of start of this year, start of next year */
@@ -224,11 +205,10 @@
 	cal_mjd (1, 1.0, yf, &e0);
 	cal_mjd (1, 1.0, yf+1, &e1);
-	*mjd = e0 + (y - yf)*(e1-e0);
+	*mjp = e0 + (y - yf)*(e1-e0);
 }
 
 /* round a time in days, *t, to the nearest second, IN PLACE. */
 void
-rnd_second (t)
-double *t;
+rnd_second (double *t)
 {
 	*t = floor(*t*SPD+0.5)/SPD;
@@ -237,16 +217,14 @@
 /* given an mjd, truncate it to the beginning of the whole day */
 double
-mjd_day(jd)
-double jd;
-{
-	return (floor(jd-0.5)+0.5);
+mjd_day(double mj)
+{
+	return (floor(mj-0.5)+0.5);
 }
 
 /* given an mjd, return the number of hours past midnight of the whole day */
 double
-mjd_hr(jd)
-double jd;
-{
-	return ((jd-mjd_day(jd))*24.0);
+mjd_hr(double mj)
+{
+	return ((mj-mjd_day(mj))*24.0);
 }
 
@@ -254,10 +232,25 @@
  */
 void
-range (v, r)
-double *v, r;
+range (double *v, double r)
 {
 	*v -= r*floor(*v/r);
 }
 
+/* insure 0 <= ra < 2PI and -PI/2 <= dec <= PI/2. if dec needs 
+ * complimenting, reflect ra too
+ */
+void
+radecrange (double *ra, double *dec)
+{
+	if (*dec < -PI/2) {
+	    *dec = -PI - *dec;
+	    *ra += PI;
+	} else if (*dec > PI/2) {
+	    *dec = PI - *dec;
+	    *ra += PI;
+	}
+	range (ra, 2*PI);
+}
+
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: mjd.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: mjd.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/moon.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/moon.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/moon.c	(revision 2551)
@@ -62,10 +62,8 @@
  */
 
+#include <stdlib.h>
+#include <stdio.h>
 #include <math.h>
-#if defined(__STDC__)
-#include <stdlib.h>
-#endif
-
-#include "P_.h"
+
 #include "astro.h"
 
@@ -86,11 +84,11 @@
 };
 
-static double mods3600 P_((double x));
-static void mean_elements P_((double JED));
-static int sscc P_((int k, double arg, int n));
-static int g2plan P_((double J, struct plantbl *plan, double *pobj, int flag));
-static double g1plan P_((double J, struct plantbl *plan));
-static int gecmoon P_((double J, struct plantbl *lrtab,
-	struct plantbl *lattab, double *pobj));
+static double mods3600 (double x);
+static void mean_elements (double JED);
+static int sscc (int k, double arg, int n);
+static int g2plan (double J, struct plantbl *plan, double *pobj, int flag);
+static double g1plan (double J, struct plantbl *plan);
+static int gecmoon (double J, struct plantbl *lrtab,
+	struct plantbl *lattab, double *pobj);
 
 /* time points */
@@ -103,5 +101,4 @@
 static double Args[NARGS];
 static double LP_equinox;
-static double NF_arcsec;
 static double Ea_arcsec;
 static double pA_precession;
@@ -2832,6 +2829,5 @@
    answer in arc seconds  */
 static double
-mods3600(x)
-     double x;
+mods3600(double x)
 {
   double y;
@@ -2848,6 +2844,5 @@
 
 static void
-mean_elements (JED)
-     double JED;
+mean_elements (double JED)
 {
   double x, T, T2;
@@ -2932,5 +2927,4 @@
 	      - 7.5311878482337989e-04) * T /* F, t^3 */
 	     - 1.3117809789650071e+01) * T2; /* F, t^2 */
-  NF_arcsec = x;
   Args[10] = x;
 
@@ -3008,8 +3002,5 @@
  */
 static int 
-sscc (k, arg, n)
-     int k;
-     double arg;
-     int n;
+sscc (int k, double arg, int n)
 {
   double cu, su, cv, sv, s;
@@ -3040,9 +3031,5 @@
    of the same list of arguments.  */
 static int 
-g2plan (J, plan, pobj, flag)
-     double J;
-     struct plantbl *plan;
-     double pobj[];
-     int flag;
+g2plan (double J, struct plantbl *plan, double pobj[], int flag)
 {
   int i, j, k, m, k1, ip, np, nt;
@@ -3168,7 +3155,5 @@
 
 static double
-g1plan (J, plan)
-     double J;
-     struct plantbl *plan;
+g1plan (double J, struct plantbl *plan)
 {
   int i, j, k, m, k1, ip, np, nt;
@@ -3271,8 +3256,5 @@
  */
 static int 
-gecmoon (J, lrtab, lattab, pobj)
-     double J;
-     struct plantbl *lrtab, *lattab;
-     double pobj[];
+gecmoon (double J, struct plantbl *lrtab, struct plantbl *lattab, double pobj[])
 {
   double x;
@@ -3294,6 +3276,6 @@
 /*********** end stephen moshier's moon code ****************/
 
-static void moon_fast P_((double mjd, double *lam, double *bet,
-	double *hp, double *msp, double *mdp));
+static void moon_fast (double mj, double *lam, double *bet,
+	double *hp, double *msp, double *mdp);
 
 /* previous version (elwood):
@@ -3309,8 +3291,6 @@
  */
 static void
-moon_fast (mjd, lam, bet, hp, msp, mdp)
-double mjd;
-double *lam, *bet, *hp;
-double *msp, *mdp;
+moon_fast (double mj, double *lam, double *bet, double *hp, double *msp,
+double *mdp)
 {
 	double t, t2;
@@ -3324,18 +3304,18 @@
 	double m1, m2, m3, m4, m5, m6;
 
-	t = mjd/36525.;
+	t = mj/36525.;
 	t2 = t*t;
 
-	m1 = mjd/27.32158213;
+	m1 = mj/27.32158213;
 	m1 = 360.0*(m1-(long)m1);
-	m2 = mjd/365.2596407;
+	m2 = mj/365.2596407;
 	m2 = 360.0*(m2-(long)m2);
-	m3 = mjd/27.55455094;
+	m3 = mj/27.55455094;
 	m3 = 360.0*(m3-(long)m3);
-	m4 = mjd/29.53058868;
+	m4 = mj/29.53058868;
 	m4 = 360.0*(m4-(long)m4);
-	m5 = mjd/27.21222039;
+	m5 = mj/27.21222039;
 	m5 = 360.0*(m5-(long)m5);
-	m6 = mjd/6798.363307;
+	m6 = mj/6798.363307;
 	m6 = 360.0*(m6-(long)m6);
 
@@ -3456,18 +3436,16 @@
  */
 void
-moon (mjd, lam, bet, rho, msp, mdp)
-double mjd;
-double *lam, *bet, *rho;
-double *msp, *mdp;
+moon (double mj, double *lam, double *bet, double *rho, double *msp,
+double *mdp)
 {
 	double pobj[3], dt;
 	double hp;
 
-	if (mjd >= MOSHIER_BEGIN && mjd <= MOSHIER_END) {
+	if (mj >= MOSHIER_BEGIN && mj <= MOSHIER_END) {
 		/* retard for light time */
-		moon_fast (mjd, lam, bet, &hp, msp, mdp);
+		moon_fast (mj, lam, bet, &hp, msp, mdp);
 		*rho = EarthRadius/AUKM/sin(hp);
 		dt = *rho * 5.7755183e-3;       /* speed of light in a.u/day */
-		gecmoon(mjd + MJD0 - dt, &moonlr, &moonlat, pobj);
+		gecmoon(mj + MJD0 - dt, &moonlr, &moonlat, pobj);
 
 		*lam = pobj[0];
@@ -3478,5 +3456,5 @@
 		*mdp = STR * Args[12];
 	} else {
-		moon_fast (mjd, lam, bet, &hp, msp, mdp);
+		moon_fast (mj, lam, bet, &hp, msp, mdp);
 		*rho = EarthRadius/AUKM/sin(hp);
 
@@ -3485,3 +3463,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: moon.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: moon.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/mooncolong.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/mooncolong.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/mooncolong.c	(revision 2551)
@@ -3,19 +3,16 @@
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <math.h>
-#if defined(__STDC__)
-#include <stdlib.h>
-#endif
-
-#include "P_.h"
+
 #include "astro.h"
 
-static void Librations P_((double RAD, double LAMH, double BH, double OM,
-    double F, double L, double L1, double *L0, double *B0));
-static void Moon P_((double RAD, double T, double T2, double LAM0, double R,
+static void Librations (double RAD, double LAMH, double BH, double OM,
+    double F, double L, double L1, double *L0, double *B0);
+static void Moon (double RAD, double T, double T2, double LAM0, double R,
     double M, double *F, double *L1, double *OM, double *LAM, double *B,
-    double *DR, double *LAMH, double *BH));
-static void Sun P_((double RAD, double T, double T2, double *L, double *M,
-    double *R, double *LAM0));
+    double *DR, double *LAMH, double *BH);
+static void Sun (double RAD, double T, double T2, double *L, double *M,
+    double *R, double *LAM0);
 
 /* given a Julian date and a lunar location, find selenographic colongitude of
@@ -26,11 +23,12 @@
  */
 void
-moon_colong (jd, lt, lg, cp, kp, ap, sp)
-double jd;	/* jd */
-double lt, lg;	/* lat/long of location on moon, rads +N +E */
-double *cp;	/* selenographic colongitude (-lng of rising sun), rads */
-double *kp;	/* illuminated fraction of surface from Earth */
-double *ap;	/* sun altitude at location, rads */
-double *sp;	/* lunar latitude of subsolar point, rads */
+moon_colong (
+double jd,	/* jd */
+double lt,	/* lat of location on moon, rads +N +E */
+double lg,	/* long of location on moon, rads +N +E */
+double *cp,	/* selenographic colongitude (-lng of rising sun), rads */
+double *kp,	/* illuminated fraction of surface from Earth */
+double *ap,	/* sun altitude at location, rads */
+double *sp)	/* lunar latitude of subsolar point, rads */
 {
 	double RAD = .0174533;
@@ -89,14 +87,6 @@
 
 static void
-Librations (RAD, LAMH, BH, OM, F, L, L1, L0, B0)
-double RAD;
-double LAMH;
-double BH;
-double OM;
-double F;
-double L;
-double L1;
-double *L0;
-double *B0;
+Librations (double RAD, double LAMH, double BH, double OM, double F,
+double L, double L1, double *L0, double *B0)
 { 
 	double I, PSI, W, NUM, DEN, A, TEMP;
@@ -123,19 +113,7 @@
 
 static void
-Moon (RAD, T, T2, LAM0, R, M, F, L1, OM, LAM, B, DR, LAMH, BH)
-double RAD;
-double T;
-double T2;
-double LAM0;
-double R;
-double M;
-double *F;
-double *L1;
-double *OM;
-double *LAM;
-double *B;
-double *DR;
-double *LAMH;
-double *BH;
+Moon (double RAD, double T, double T2, double LAM0, double R, double M,
+double *F, double *L1, double *OM, double *LAM, double *B, double *DR,
+double *LAMH, double *BH)
 {
 	double T3, M1, D2, SUMR, SUML, DIST;
@@ -175,12 +153,6 @@
 
 static void
-Sun (RAD, T, T2, L, M, R, LAM0)
-double RAD;
-double T;
-double T2;
-double *L;
-double *M;
-double *R;
-double *LAM0;
+Sun (double RAD, double T, double T2, double *L, double *M, double *R,
+double *LAM0)
 {
 	double T3, C, V, E, THETA, OM;
@@ -238,5 +210,5 @@
 	if (ac != 2) {
 	    fprintf (stderr, "%s: JD\n", av[0]);
-	    exit (1);
+	    abort();
 	}
 
@@ -262,3 +234,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: mooncolong.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: mooncolong.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/moonnf.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/moonnf.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/moonnf.c	(revision 2551)
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <math.h>
+
+#include "astro.h"
+
+static void m (double t, double k, double *mj);
+
+#define	unw(w,z)	((w)-floor((w)/(z))*(z))
+
+/* given a modified Julian date, mj, return the mjd of the new
+ * and full moons about then, mjn and mjf.
+ * TODO: exactly which ones does it find? eg:
+ *   5/28/1988 yields 5/15 and 5/31
+ *   5/29             6/14     6/29
+ */
+void
+moonnf (double mj, double *mjn, double *mjf)
+{
+	int mo, yr;
+	double dy;
+	double mj0;
+	double k, tn, tf, t;
+
+	mjd_cal (mj, &mo, &dy, &yr);
+	cal_mjd (1, 0., yr, &mj0);
+	k = (yr-1900+((mj-mj0)/365))*12.3685;
+	k = floor(k+0.5);
+	tn = k/1236.85;
+	tf = (k+0.5)/1236.85;
+	t = tn;
+	m (t, k, mjn);
+	t = tf;
+	k += 0.5;
+	m (t, k, mjf);
+}
+
+static void
+m (double t, double k, double *mj)
+{
+	double t2, a, a1, b, b1, c, ms, mm, f, ddjd;
+
+	t2 = t*t;
+	a = 29.53*k;
+	c = degrad(166.56+(132.87-9.173e-3*t)*t);
+	b = 5.8868e-4*k+(1.178e-4-1.55e-7*t)*t2+3.3e-4*sin(c)+7.5933E-1;
+	ms = 359.2242+360*unw(k/1.236886e1,1)-(3.33e-5+3.47e-6*t)*t2;
+	mm = 306.0253+360*unw(k/9.330851e-1,1)+(1.07306e-2+1.236e-5*t)*t2;
+	f = 21.2964+360*unw(k/9.214926e-1,1)-(1.6528e-3+2.39e-6*t)*t2;
+	ms = unw(ms,360);
+	mm = unw(mm,360);
+	f = unw(f,360);
+	ms = degrad(ms);
+	mm = degrad(mm);
+	f = degrad(f);
+	ddjd = (1.734e-1-3.93e-4*t)*sin(ms)+2.1e-3*sin(2*ms)
+		-4.068e-1*sin(mm)+1.61e-2*sin(2*mm)-4e-4*sin(3*mm)
+		+1.04e-2*sin(2*f)-5.1e-3*sin(ms+mm)-7.4e-3*sin(ms-mm)
+		+4e-4*sin(2*f+ms)-4e-4*sin(2*f-ms)-6e-4*sin(2*f+mm)
+		+1e-3*sin(2*f-mm)+5e-4*sin(ms+2*mm);
+	a1 = (long)a;
+	b = b+ddjd+(a-a1);
+	b1 = (long)b;
+	a = a1+b1;
+	b = b-b1;
+	*mj = a + b;
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: moonnf.c,v $ $Date: 2004-06-15 16:54:12 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/nutation.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/nutation.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/nutation.c	(revision 2551)
@@ -3,7 +3,7 @@
  * (given to 0.001") EXACTLY over 750 days (1995 and 1996)
  */
+#include <stdio.h>
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
@@ -268,14 +268,14 @@
 };
 
-/* given the modified JD, mjd, find the nutation in obliquity, *deps, and
+/* given the modified JD, mj, find the nutation in obliquity, *deps, and
  * the nutation in longitude, *dpsi, each in radians.
  */
 void
-nutation (mjd, deps, dpsi)
-double mjd;
-double *deps;	/* on input:  precision parameter in arc seconds */
-double *dpsi;
+nutation (
+double mj,
+double *deps,	/* on input:  precision parameter in arc seconds */
+double *dpsi)
 {
-	static double lastmjd = -10000, lastdeps, lastdpsi;
+	static double lastmj = -10000, lastdeps, lastdpsi;
 	double T, T2, T3, T10;			/* jul cent since J2000 */
 	double prec;				/* series precis in arc sec */
@@ -287,5 +287,5 @@
 			 */
 
-	if (mjd == lastmjd) {
+	if (mj == lastmj) {
 	    *deps = lastdeps;
 	    *dpsi = lastdpsi;
@@ -304,5 +304,5 @@
 	prec *= NUT_SCALE/10;
 
-	T = (mjd - J2000)/36525.;
+	T = (mj - J2000)/36525.;
 	T2 = T * T;
 	T3 = T2 * T;
@@ -362,26 +362,25 @@
 	lastdeps = degrad(lastdeps/3600./NUT_SCALE);
 
-	lastmjd = mjd;
+	lastmj = mj;
 	*deps = lastdeps;
 	*dpsi = lastdpsi;
 }
 
-/* given the modified JD, mjd, correct, IN PLACE, the right ascension *ra
+/* given the modified JD, mj, correct, IN PLACE, the right ascension *ra
  * and declination *dec (both in radians) for nutation.
  */
 void
-nut_eq (mjd, ra, dec)
-double mjd, *ra, *dec;
+nut_eq (double mj, double *ra, double *dec)
 {
-	static double lastmjd = -10000;
+	static double lastmj = -10000;
 	static double a[3][3];		/* rotation matrix */
 	double xold, yold, zold, x, y, z;
 
-	if (mjd != lastmjd) {
+	if (mj != lastmj) {
 	    double epsilon, dpsi, deps;
 	    double se, ce, sp, cp, sede, cede;
 
-	    obliquity(mjd, &epsilon);
-	    nutation(mjd, &deps, &dpsi);
+	    obliquity(mj, &epsilon);
+	    nutation(mj, &deps, &dpsi);
 
 	    /* the rotation matrix a applies the nutation correction to
@@ -428,5 +427,5 @@
 	    a[2][2] = sede*cp*se+cede*ce;
 
-	    lastmjd = mjd;
+	    lastmj = mj;
 	}
 
@@ -440,3 +439,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: nutation.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: nutation.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/obliq.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/obliq.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/obliq.c	(revision 2551)
@@ -1,8 +1,7 @@
 #include <stdio.h>
 
-#include "P_.h"
 #include "astro.h"
 
-/* given the modified Julian date, mjd, find the mean obliquity of the
+/* given the modified Julian date, mj, find the mean obliquity of the
  * ecliptic, *eps, in radians.
  *
@@ -10,17 +9,15 @@
  */
 void
-obliquity (mjd, eps)
-double mjd;
-double *eps;
+obliquity (double mj, double *eps)
 {
-	static double lastmjd = -16347, lasteps;
+	static double lastmj = -16347, lasteps;
 
-	if (mjd != lastmjd) {
-	    double t = (mjd - J2000)/36525.;	/* centuries from J2000 */
+	if (mj != lastmj) {
+	    double t = (mj - J2000)/36525.;	/* centuries from J2000 */
 	    lasteps = degrad(23.4392911 +	/* 23^ 26' 21".448 */
 			    t * (-46.8150 +
 			    t * ( -0.00059 +
 			    t * (  0.001813 )))/3600.0);
-	    lastmjd = mjd;
+	    lastmj = mj;
 	}
 	*eps = lasteps;
@@ -28,3 +25,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: obliq.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: obliq.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/parallactic.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/parallactic.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/parallactic.c	(revision 2551)
@@ -0,0 +1,54 @@
+/* compure parallactic angle: angle formed by N pole - Object - Zenith
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include "astro.h"
+
+/* compute parallactic angle given latitude, object dec and alt.
+ * all angles in rads.
+ * N.B. always return >= 0, caller must determine sign and degenerate cases at
+ *   pole or zenith.
+ */
+double
+parallacticLDA (double lt, double dec, double alt)
+{
+	double ca = sin(lt);
+	double cb = sin(dec);
+	double sb = cos(dec);
+	double cc = sin(alt);
+	double sc = cos(alt);
+	double cpa;
+
+	/* given three sides find an angle */
+	if (sb==0 || sc==0)
+	    return (0);
+	cpa = (ca - cb*cc)/(sb*sc);
+	if (cpa < -1) cpa = -1;
+	if (cpa >  1) cpa =  1;
+	return (acos (cpa));
+}
+
+/* compute parallactic angle given latitude, object HA and Dec.
+ * all angles in rads.
+ * return value is between -PI and PI, sign is like HA, ie +west
+ */
+double
+parallacticLHD (double lt, double ha, double dec)
+{
+	double A, b, cc, sc, B;
+
+	A = ha;
+	b = PI/2 - lt;
+	cc = sin(dec);
+	sc = cos(dec);
+	solve_sphere (A, b, cc, sc, NULL, &B);
+
+	if (B > PI)
+	    B -= 2*PI;
+	return (B);
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: parallactic.c,v $ $Date: 2004-06-15 16:54:12 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/parallax.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/parallax.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/parallax.c	(revision 2551)
@@ -2,5 +2,4 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
@@ -14,7 +13,6 @@
  */
 void
-ta_par (tha, tdec, phi, ht, rho, aha, adec)
-double tha, tdec, phi, ht, *rho;
-double *aha, *adec;
+ta_par (double tha, double tdec, double phi, double ht, double *rho,
+double *aha, double *adec)
 {
 	static double last_phi = 1000.0, last_ht = -1000.0, xobs, zobs;
@@ -42,3 +40,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: parallax.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: parallax.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/plans.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/plans.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/plans.c	(revision 2551)
@@ -5,12 +5,11 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 #include "vsop87.h"
 #include "chap95.h"
 
-static void pluto_ell P_((double mjd, double *ret));
-static void chap_trans P_((double mjd, double *ret));
-static void planpos P_((double mjd, int obj, double prec, double *ret));
+static void pluto_ell (double mj, double *ret);
+static void chap_trans (double mj, double *ret);
+static void planpos (double mj, int obj, double prec, double *ret);
 
 /* coordinate transformation
@@ -21,7 +20,7 @@
  */
 static void
-chap_trans (mjd, ret)
-double mjd;	/* destination epoch */
-double *ret;	/* vector to be transformed _IN PLACE_ */
+chap_trans (
+double mj,	/* destination epoch */
+double *ret)	/* vector to be transformed _IN PLACE_ */
 {
 	double ra, dec, r, eps;
@@ -29,6 +28,6 @@
 
 	cartsph(ret[0], ret[1], ret[2], &ra, &dec, &r);
-	precess(J2000, mjd, &ra, &dec);
-	obliquity(mjd, &eps);
+	precess(J2000, mj, &ra, &dec);
+	obliquity(mj, &eps);
 	sr = sin(ra); cr = cos(ra);
 	sd = sin(dec); cd = cos(dec);
@@ -43,7 +42,7 @@
  */
 static void
-pluto_ell (mjd, ret)
-double mjd;	/* epoch */
-double *ret;	/* ecliptic coordinates {l,b,r} at equinox of date */
+pluto_ell (
+double mj,	/* epoch */
+double *ret)	/* ecliptic coordinates {l,b,r} at equinox of date */
 {
 	/* mean orbital elements of Pluto.
@@ -55,6 +54,6 @@
 		Om0 = 110.307,			/* long asc node, deg */
 		omeg0 = 113.768,		/* arg of perihel, deg */
-		mjdp = 2448045.539 - MJD0,	/* epoch of perihel */
-		mjdeq = J2000,			/* equinox of elements */
+		mjp = 2448045.539 - MJD0,	/* epoch of perihel */
+		mjeq = J2000,			/* equinox of elements */
 		n = 144.9600/36525.;            /* daily motion, deg */
 
@@ -63,7 +62,7 @@
 	double lo, slo, clo;	/* longitude in orbit from asc node */
 
-	reduce_elements(mjdeq, mjd, degrad(inc0), degrad(omeg0), degrad(Om0),
+	reduce_elements(mjeq, mj, degrad(inc0), degrad(omeg0), degrad(Om0),
 				&inc, &omeg, &Om);
-	ma = degrad((mjd - mjdp) * n);
+	ma = degrad((mj - mjp) * n);
 	anomaly(ma, e, &nu, &ea);
 	ret[2] = a * (1.0 - e*cos(ea));			/* r */
@@ -81,22 +80,18 @@
  */
 static void
-planpos (mjd, obj, prec, ret)
-double mjd;
-int obj;
-double prec;
-double *ret;
-{
-	if (mjd >= CHAP_BEGIN && mjd <= CHAP_END) {
+planpos (double mj, int obj, double prec, double *ret)
+{
+	if (mj >= CHAP_BEGIN && mj <= CHAP_END) {
 	    if (obj >= JUPITER) {		/* prefer Chapront */
-		chap95(mjd, obj, prec, ret);
-		chap_trans (mjd, ret);
+		chap95(mj, obj, prec, ret);
+		chap_trans (mj, ret);
 	    } else {				/* VSOP for inner planets */
-		vsop87(mjd, obj, prec, ret);
+		vsop87(mj, obj, prec, ret);
 	    }
 	} else {				/* outside Chapront time: */
 	    if (obj != PLUTO) {			/* VSOP for all but Pluto */
-		vsop87(mjd, obj, prec, ret);
+		vsop87(mj, obj, prec, ret);
 	    } else {				/* Pluto mean elliptic orbit */
-		pluto_ell(mjd, ret);
+		pluto_ell(mj, ret);
 	    }
 	}
@@ -126,5 +121,5 @@
 };
 
-/* given a modified Julian date, mjd, and a planet, p, find:
+/* given a modified Julian date, mj, and a planet, p, find:
  *   lpd0: heliocentric longitude, 
  *   psi0: heliocentric latitude,
@@ -148,10 +143,8 @@
  */
 void
-plans (mjd, p, lpd0, psi0, rp0, rho0, lam, bet, dia, mag)
-double mjd;
-int p;
-double *lpd0, *psi0, *rp0, *rho0, *lam, *bet, *dia, *mag;
-{
-	static double lastmjd = -10000;
+plans (double mj, PLCode p, double *lpd0, double *psi0, double *rp0,
+double *rho0, double *lam, double *bet, double *dia, double *mag)
+{
+	static double lastmj = -10000;
 	static double lsn, bsn, rsn;	/* geocentric coords of sun */
 	static double xsn, ysn, zsn;	/* cartesian " */
@@ -163,12 +156,12 @@
 	int pass;
 
-	/* get sun cartesian; needed only once at mjd */
-	if (mjd != lastmjd) {
-	    sunpos (mjd, &lsn, &rsn, &bsn);
+	/* get sun cartesian; needed only once at mj */
+	if (mj != lastmj) {
+	    sunpos (mj, &lsn, &rsn, &bsn);
 	    sphcart (lsn, bsn, rsn, &xsn, &ysn, &zsn);
-            lastmjd = mjd;
+            lastmj = mj;
         }
 
-	/* first find the true position of the planet at mjd.
+	/* first find the true position of the planet at mj.
 	 * then repeat a second time for a slightly different time based
 	 * on the position found in the first pass to account for light-travel
@@ -183,5 +176,5 @@
 	     * alternative option:  vsop allows calculating rates.
 	     */
-	    planpos(mjd - dt, p, 0.0, ret);
+	    planpos(mj - dt, p, 0.0, ret);
 
 	    lp = ret[0];
@@ -225,5 +218,5 @@
 	if (p == SATURN) {
 	    double et, st, set;
-	    satrings (bp, lp, rp, lsn+PI, rsn, mjd+MJD0, &et, &st);
+	    satrings (bp, lp, rp, lsn+PI, rsn, mj+MJD0, &et, &st);
 	    set = sin(fabs(et));
 	    *mag += (-2.60 + 1.25*set)*set;
@@ -232,3 +225,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: plans.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: plans.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/plmoon.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/plmoon.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/plmoon.c	(revision 2551)
@@ -0,0 +1,294 @@
+/* compute Obj fields for natural satellites.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include "astro.h"
+
+/* private cache of planet ephemerides and when they were computed
+ * N.B. don't use ones in builtin[] -- they are the user's responsibility.
+ */
+static ObjPl plobj[NOBJ];
+static Now plnow[NOBJ];
+
+/* public builtin storage
+ */
+static Obj builtin[NBUILTIN];
+
+static char *moondir;
+
+static void setMoon (Now *np, Obj *moonop, Obj *planop, MoonData *mdp);
+static void init1BI (int idx, int pl, int moon, char *name);
+static void initPlobj(void);
+static void initDir(void);
+static void rotate (double a, double *x, double *y);
+
+/* directory in which to look for auxil moon data files.
+ * N.B. caller must supply persistent storage.
+ */
+void
+setMoonDir (char *dir)
+{
+	moondir = dir;
+}
+
+/* return set of builtin objects.
+ * caller can use this storage but should never try to free anything.
+ */
+int
+getBuiltInObjs (Obj **opp)
+{
+	if (!builtin[MERCURY].o_name[0]) {
+	    /* first time only */
+
+	    init1BI (MERCURY,   MERCURY, X_PLANET,    "Mercury");
+
+	    init1BI (VENUS,     VENUS,   X_PLANET,    "Venus");
+
+	    init1BI (MARS,      MARS,    X_PLANET,    "Mars");
+	    init1BI (PHOBOS,    MARS,    M_PHOBOS,    "Phobos");
+	    init1BI (DEIMOS,    MARS,    M_DEIMOS,    "Deimos");
+
+	    init1BI (JUPITER,   JUPITER, X_PLANET,    "Jupiter");
+	    init1BI (IO,        JUPITER, J_IO,        "Io");
+	    init1BI (EUROPA,    JUPITER, J_EUROPA,    "Europa");
+	    init1BI (GANYMEDE,  JUPITER, J_GANYMEDE,  "Ganymede");
+	    init1BI (CALLISTO,  JUPITER, J_CALLISTO,  "Callisto");
+
+	    init1BI (SATURN,    SATURN,  X_PLANET,    "Saturn");
+	    init1BI (MIMAS,     SATURN,  S_MIMAS,     "Mimas");
+	    init1BI (ENCELADUS, SATURN,  S_ENCELADUS, "Enceladus");
+	    init1BI (TETHYS,    SATURN,  S_TETHYS,    "Tethys");
+	    init1BI (DIONE,     SATURN,  S_DIONE,     "Dione");
+	    init1BI (RHEA,      SATURN,  S_RHEA,      "Rhea");
+	    init1BI (TITAN,     SATURN,  S_TITAN,     "Titan");
+	    init1BI (HYPERION,  SATURN,  S_HYPERION,  "Hyperion");
+	    init1BI (IAPETUS,   SATURN,  S_IAPETUS,   "Iapetus");
+
+	    init1BI (URANUS,    URANUS,  X_PLANET,    "Uranus");
+	    init1BI (ARIEL,     URANUS,  U_ARIEL,     "Ariel");
+	    init1BI (UMBRIEL,   URANUS,  U_UMBRIEL,   "Umbriel");
+	    init1BI (TITANIA,   URANUS,  U_TITANIA,   "Titania");
+	    init1BI (OBERON,    URANUS,  U_OBERON,    "Oberon");
+	    init1BI (MIRANDA,   URANUS,  U_MIRANDA,   "Miranda");
+
+	    init1BI (NEPTUNE,   NEPTUNE, X_PLANET,    "Neptune");
+
+	    init1BI (PLUTO,     PLUTO,   X_PLANET,    "Pluto");
+
+	    init1BI (SUN,       SUN,     X_PLANET,    "Sun");
+
+	    init1BI (MOON,      MOON,    X_PLANET,    "Moon");
+	}
+
+	*opp = builtin;
+	return (NBUILTIN);
+}
+
+static void
+init1BI (int idx, int pl, int moon, char *name)
+{
+	strcpy (builtin[idx].o_name, name);
+	builtin[idx].o_type = PLANET;
+	builtin[idx].pl_code = pl;
+	builtin[idx].pl_moon = moon;
+}
+
+/* find the circumstances for natural satellite object op at np.
+ * TODO: distances and helio coords just copied from parent planet.
+ */
+int
+plmoon_cir (Now *np, Obj *moonop)
+{
+	Obj *sunop = (Obj*)&plobj[SUN];
+	MoonData md[X_MAXNMOONS];
+	double sz, t1, t2;
+	MoonData *mdp;
+	Obj *planop;
+
+	/* init plobj[] */
+	if (!((Obj *)&plobj[0])->o_type) {
+	    initPlobj();
+	    initDir();
+	}
+
+	/* get sun @ np */
+	if (memcmp (&plnow[SUN], np, sizeof(Now))) {
+	    obj_cir (np, (Obj*)&plobj[SUN]);
+	    memcpy (&plnow[SUN], np, sizeof(Now));
+	}
+
+	/* get parent planet and moon info @ np */
+	switch (moonop->pl_code) {
+
+	case MARS:
+	case PHOBOS:
+	case DEIMOS:
+
+	    planop = (Obj*)&plobj[MARS];
+
+	    if (memcmp (&plnow[MARS], np, sizeof(Now))) {
+		obj_cir (np, planop);
+		memcpy (&plnow[MARS], np, sizeof(Now));
+	    }
+
+	    /* don't worry, this already caches based on same mjd */
+	    marsm_data (mjd, moondir, sunop, planop, &sz, md);
+	    mdp = &md[moonop->pl_moon];
+	    break;
+
+	case JUPITER:
+	case IO:
+	case EUROPA:
+	case GANYMEDE:
+	case CALLISTO:
+
+	    planop = (Obj*)&plobj[JUPITER];
+
+	    if (memcmp (&plnow[JUPITER], np, sizeof(Now))) {
+		obj_cir (np, planop);
+		memcpy (&plnow[JUPITER], np, sizeof(Now));
+	    }
+
+	    /* don't worry, this already caches based on same mjd */
+	    jupiter_data (mjd, moondir, sunop, planop, &sz, &t1, &t2, md);
+	    mdp = &md[moonop->pl_moon];
+	    moonop->pl_aux1 = t1;
+	    moonop->pl_aux2 = t2;
+	    break;
+
+	case SATURN:
+	case MIMAS:
+	case ENCELADUS:
+	case TETHYS:
+	case DIONE:
+	case RHEA:
+	case TITAN:
+	case HYPERION:
+	case IAPETUS:
+
+	    planop = (Obj*)&plobj[SATURN];
+
+	    if (memcmp (&plnow[SATURN], np, sizeof(Now))) {
+		obj_cir (np, planop);
+		memcpy (&plnow[SATURN], np, sizeof(Now));
+	    }
+
+	    /* don't worry, this already caches based on same mjd */
+	    saturn_data (mjd, moondir, sunop, planop, &sz, &t1, &t2, md);
+	    mdp = &md[moonop->pl_moon];
+	    moonop->pl_aux1 = t1;
+	    moonop->pl_aux2 = t2;
+	    break;
+
+	case URANUS:
+	case ARIEL:
+	case UMBRIEL:
+	case TITANIA:
+	case OBERON:
+	case MIRANDA:
+
+	    planop = (Obj*)&plobj[URANUS];
+
+	    if (memcmp (&plnow[URANUS], np, sizeof(Now))) {
+		obj_cir (np, planop);
+		memcpy (&plnow[URANUS], np, sizeof(Now));
+	    }
+
+	    /* don't worry, this already caches based on same mjd */
+	    uranus_data (mjd, moondir, sunop, planop, &sz, md);
+	    mdp = &md[moonop->pl_moon];
+	    break;
+
+	default:
+
+	    printf ("Called plmoon_cir with bad code: %d\n",moonop->pl_code);
+	    return (-1);
+
+	}
+
+	/* set moonop */
+	setMoon (np, moonop, planop, mdp);
+
+	return (0);
+}
+
+static void
+initPlobj()
+{
+	int i;
+
+	for (i = 0; i < NOBJ; i++) {
+	    ((Obj*)&plobj[i])->o_type = PLANET;
+	    ((Obj*)&plobj[i])->pl_code = i;
+	}
+}
+
+/* install a default if no moondir set yet */
+static void
+initDir()
+{
+	if (!moondir)
+	    moondir = ".";
+}
+
+/* set moonop->s_* fields.
+ * np is needed to get local parallactic angle.
+ */
+static void
+setMoon (Now *np, Obj *moonop, Obj *planop, MoonData *mdp)
+{
+	double pa, dra, ddec;
+
+	/* just copy most fields from planet for now */
+	moonop->s_gaera = planop->s_gaera;	/* TODO */
+	moonop->s_gaedec = planop->s_gaedec;	/* TODO */
+	moonop->s_elong = planop->s_elong;	/* TODO */
+	moonop->s_size = 0;			/* TODO */
+	moonop->s_sdist = planop->s_sdist;	/* TODO */
+	moonop->s_edist = planop->s_edist;	/* TODO */
+	moonop->s_hlat = planop->s_hlat;	/* TODO */
+	moonop->s_hlong = planop->s_hlong;	/* TODO */
+	moonop->s_phase = planop->s_phase;	/* TODO */
+
+	/* new ra/dec directly from mdp */
+	moonop->s_ra = mdp->ra;
+	moonop->s_dec = mdp->dec;
+
+	/* geoemtry info */
+	moonop->pl_x = mdp->x;
+	moonop->pl_y = mdp->y;
+	moonop->pl_z = mdp->z;
+	moonop->pl_evis = mdp->evis;
+	moonop->pl_svis = mdp->svis;
+
+	/* tweak alt/az by change in ra/dec rotated by pa */
+	pa = parallacticLDA (lat, planop->s_dec, planop->s_alt);
+	if (planop->s_az < PI)
+	    pa = -pa;			/* rotation radec to altaz */
+	dra = (moonop->s_ra - planop->s_ra)*cos(planop->s_dec);
+	ddec = moonop->s_dec - planop->s_dec;
+	rotate (pa, &dra, &ddec);
+	moonop->s_alt = planop->s_alt + ddec;
+	moonop->s_az = planop->s_az - dra/cos(planop->s_alt);
+
+	/* new mag directly from mdp */
+	set_smag (moonop, mdp->mag);
+
+	/* name */
+	strcpy (moonop->o_name, mdp->full);
+}
+
+/* rotate ccw by a */
+static void
+rotate (double a, double *x, double *y)
+{
+	double sa = sin(a);
+	double ca = cos(a);
+	double xp = (*x)*ca - (*y)*sa;
+	double yp = (*x)*sa + (*y)*ca;
+	*x = xp;
+	*y = yp;
+}
Index: /trunk/SophyaExt/XephemAstroLib/plshadow.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/plshadow.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/plshadow.c	(revision 2551)
@@ -0,0 +1,50 @@
+#include <math.h>
+
+#include "astro.h"
+
+#undef sqr
+#define	sqr(x)		((x)*(x))
+
+/* given a time, a planet, the sun, the planet's eq pole position and a
+ * position of a satellite (as eq x=+e y=+s z=front in planet radii) find x,y
+ * position of shadow.
+ * return 0 if ok else -1 if shadow not on planet
+ */
+int
+plshadow (Now *np, Obj *op, Obj *sop, double polera, double poledec, double x,
+double y, double z, double *sxp, double *syp)
+{
+	/* equatorial to ecliptic sky-plane rotation */
+	double sa = cos(op->s_dec) * cos(poledec) *
+			(cos(op->s_ra)*sin(polera) - sin(op->s_ra)*cos(polera));
+	double ca = sqrt (1.0 - sa*sa);
+
+	/* rotate moon from equatorial to ecliptic */
+	double ex =  x*ca + y*sa;
+	double ey = -x*sa + y*ca;
+
+	/* find angle subtended by earth-sun from planet */
+	double a = asin (sin(op->s_hlong - sop->s_hlong)/op->s_edist);
+	double b = asin (-sin(op->s_hlat)/op->s_edist);
+
+	/* find displacement in sky plane */
+	double x0 = ex - z*tan(a);
+	double y0 = ey - z*tan(b);
+
+	/* projection onto unit sphere */
+	double x1 = x0 + (ex-x0)/sqrt(sqr(ex-x0)+sqr(z));
+	double y1 = y0 + (ey-y0)/sqrt(sqr(ey-y0)+sqr(z));
+
+	/* check behind or off edge */
+	if (z < 0 || sqr(x1) + sqr(y1) > 1)
+	    return (-1);
+
+	/* rotate back to equatorial */
+	*sxp = x1*ca - y1*sa;
+	*syp = x1*sa + y1*ca;
+
+	return (0);
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: plshadow.c,v $ $Date: 2004-06-15 16:54:12 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/precess.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/precess.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/precess.c	(revision 2551)
@@ -2,9 +2,7 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
-static void precess_hiprec P_((double mjd1, double mjd2, double *ra,
-    double *dec));
+static void precess_hiprec (double mjd1, double mjd2, double *ra, double *dec);
 
 
@@ -19,7 +17,7 @@
  */
 void
-precess (mjd1, mjd2, ra, dec)
-double mjd1, mjd2;	/* initial and final epoch modified JDs */
-double *ra, *dec;	/* ra/dec for mjd1 in, for mjd2 out */
+precess (
+double mjd1, double mjd2,	/* initial and final epoch modified JDs */
+double *ra, double *dec)	/* ra/dec for mjd1 in, for mjd2 out */
 {
 	precess_hiprec (mjd1, mjd2, ra, dec);
@@ -42,7 +40,7 @@
  */
 static void
-precess_hiprec (mjd1, mjd2, ra, dec)
-double mjd1, mjd2;	/* initial and final epoch modified JDs */
-double *ra, *dec;	/* ra/dec for mjd1 in, for mjd2 out */
+precess_hiprec (
+double mjd1, double mjd2,	/* initial and final epoch modified JDs */
+double *ra, double *dec)	/* ra/dec for mjd1 in, for mjd2 out */
 {
 	static double last_mjd1 = -213.432, last_from;
@@ -130,7 +128,7 @@
 #if 0
 static void
-precess_fast (mjd1, mjd2, ra, dec)
-double mjd1, mjd2;	/* initial and final epoch modified JDs */
-double *ra, *dec;	/* ra/dec for mjd1 in, for mjd2 out */
+precess_fast (
+double mjd1, double mjd2,	/* initial and final epoch modified JDs */
+double *ra, double *dec)	/* ra/dec for mjd1 in, for mjd2 out */
 {
 #define	N	degrad (20.0468/3600.0)
@@ -146,3 +144,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: precess.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: precess.c,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/preferences.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/preferences.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/preferences.h	(revision 2551)
@@ -23,10 +23,10 @@
 typedef enum {PREF_SAT, PREF_SUN, PREF_MON} PrefWeekStart;
 
-extern int pref_get P_((Preferences p));
-extern int pref_set P_((Preferences p, int new));
+extern int pref_get (Preferences p);
+extern int pref_set (Preferences p, int newp);
 
 #endif /* _PREFERENCES_H */
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: preferences.h,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: preferences.h,v $ $Date: 2004-06-15 16:52:39 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/reduce.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/reduce.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/reduce.c	(revision 2551)
@@ -1,19 +1,20 @@
 #include <math.h>
 
-#include "P_.h"
+#include <stdio.h>
+
 #include "astro.h"
 
-/* convert those orbital elements that change from epoch mjd0 to epoch mjd.
+/* convert those orbital elements that change from epoch mj0 to epoch mj.
  */
 void
-reduce_elements (mjd0, mjd, inc0, ap0, om0, inc, ap, om)
-double mjd0;	/* initial epoch */
-double mjd;	/* desired epoch */
-double inc0;	/* initial inclination, rads */
-double ap0;	/* initial argument of perihelion, as an mjd */
-double om0;	/* initial long of ascending node, rads */
-double *inc;	/* desired inclination, rads */
-double *ap;	/* desired epoch of perihelion, as an mjd */
-double *om;	/* desired long of ascending node, rads */
+reduce_elements (
+double mj0,	/* initial epoch */
+double mj,	/* desired epoch */
+double inc0,	/* initial inclination, rads */
+double ap0,	/* initial argument of perihelion, as an mj */
+double om0,	/* initial long of ascending node, rads */
+double *inc,	/* resultant inclination, rads */
+double *ap,	/* resultant arg of perihelion, as an mj */
+double *om)	/* resultant long of ascending node, rads */
 {
 	double t0, t1;
@@ -26,5 +27,5 @@
 	double seta, ceta;
 
-	if (fabs(mjd - mjd0) < 1e-5) {
+	if (fabs(mj - mj0) < 1e-5) {
 	    /* sin(eta) blows for inc < 10 degrees -- anyway, no need */
 	    *inc = inc0;
@@ -34,6 +35,6 @@
 	}
 
-	t0 = mjd0/365250.0;
-	t1 = mjd/365250.0;
+	t0 = mj0/365250.0;
+	t1 = mj/365250.0;
 
 	tt = t1-t0;
@@ -75,3 +76,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: reduce.c,v $ $Date: 2001-10-22 12:08:27 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: reduce.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/refract.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/refract.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/refract.c	(revision 2551)
@@ -2,15 +2,11 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
-static void unrefractLT15 P_((double pr, double tr, double aa, double *ta));
-static void unrefractGE15 P_((double pr, double tr, double aa, double *ta));
+static void unrefractLT15 (double pr, double tr, double aa, double *ta);
+static void unrefractGE15 (double pr, double tr, double aa, double *ta);
 
 void
-unrefract (pr, tr, aa, ta)
-double pr, tr;
-double aa;
-double *ta;
+unrefract (double pr, double tr, double aa, double *ta)
 {
 #define	LTLIM	14.5
@@ -35,8 +31,5 @@
 
 static void
-unrefractGE15 (pr, tr, aa, ta)
-double pr, tr;
-double aa;
-double *ta;
+unrefractGE15 (double pr, double tr, double aa, double *ta)
 {
 	double r;
@@ -47,8 +40,5 @@
 
 static void
-unrefractLT15 (pr, tr, aa, ta)
-double pr, tr;
-double aa;
-double *ta;
+unrefractLT15 (double pr, double tr, double aa, double *ta)
 {
 	double aadeg = raddeg(aa);
@@ -67,8 +57,5 @@
  */
 void
-refract (pr, tr, ta, aa)
-double pr, tr;
-double ta;
-double *aa;
+refract (double pr, double tr, double ta, double *aa)
 {
 #define	MAXRERR	degrad(0.1/3600.)	/* desired accuracy, rads */
@@ -102,3 +89,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: refract.c,v $ $Date: 2002-02-07 09:27:06 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: refract.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.4 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/rings.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/rings.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/rings.c	(revision 2551)
@@ -1,11 +1,7 @@
 #include <stdio.h>
 #include <math.h>
-#if defined(__STDC__)
 #include <stdlib.h>
-#endif
 
-#include "P_.h"
 #include "astro.h"
-#include "circum.h"
 
 /*  RINGS OF SATURN by Olson, et al, BASIC Code from Sky & Telescope, May 1995.
@@ -14,9 +10,9 @@
  */
 void
-satrings (sb, sl, sr, el, er, JD, etiltp, stiltp)
-double sb, sl, sr;		/* Saturn hlat, hlong, sun dist */
-double el, er;			/* Earth hlong, sun dist */
-double JD;			/* Julian date */
-double *etiltp, *stiltp;	/* tilt from earth and sun, rads southward */
+satrings (
+double sb, double sl, double sr,	/* Saturn hlat, hlong, sun dist */
+double el, double er,			/* Earth hlong, sun dist */
+double JD,				/* Julian date */
+double *etiltp, double *stiltp)		/* tilt from earth and sun, rads south*/
 {
 	double t, i, om;
@@ -45,2 +41,5 @@
 	*stiltp = bp;
 }
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: rings.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/riset.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/riset.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/riset.c	(revision 2551)
@@ -2,9 +2,8 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 
 /* given the true geocentric ra and dec of an object, the observer's latitude,
- *   lat, and a horizon displacement correction, dis, all in radians, find the
+ *   lt, and a horizon displacement correction, dis, all in radians, find the
  *   local sidereal times and azimuths of rising and setting, lstr/s
  *   and azr/s, also all in radians, respectively.
@@ -25,10 +24,6 @@
  */
 void
-riset (ra, dec, lat, dis, lstr, lsts, azr, azs, status)
-double ra, dec;
-double lat, dis;
-double *lstr, *lsts;
-double *azr, *azs;
-int *status;
+riset (double ra, double dec, double lt, double dis, double *lstr,
+double *lsts, double *azr, double *azs, int *status)
 {
 #define	EPS	(1e-9)	/* math rounding fudge - always the way, eh? */
@@ -40,7 +35,7 @@
 	int shemi;		/* flag for southern hemisphere reflection */
 
-	/* reflect lat and dec if in southern hemisphere, then az back later */
-	if ((shemi= (lat < 0.)) != 0) {
-	    lat = -lat;
+	/* reflect lt and dec if in southern hemisphere, then az back later */
+	if ((shemi= (lt < 0.)) != 0) {
+	    lt = -lt;
 	    dec = -dec;
 	}
@@ -48,6 +43,6 @@
 	/* establish zenith angle, and its extrema */
 	z = (PI/2.) + dis;
-	zmin = fabs (dec - lat);
-	zmax = PI - fabs(dec + lat);
+	zmin = fabs (dec - lt);
+	zmax = PI - fabs(dec + lt);
 
 	/* first consider special cases.
@@ -64,5 +59,5 @@
 
 	/* compute rising hour angle -- beware found off */
-	cos_h = (cos(z)-sin(lat)*sin(dec))/(cos(lat)*cos(dec));
+	cos_h = (cos(z)-sin(lt)*sin(dec))/(cos(lt)*cos(dec));
 	if (cos_h >= 1.)
 	    h =  0.;
@@ -73,5 +68,5 @@
 
 	/* compute setting azimuth -- beware found off */
-	xaz = sin(dec)*cos(lat)-cos(dec)*cos(h)*sin(lat);
+	xaz = sin(dec)*cos(lt)-cos(dec)*cos(h)*sin(lt);
 	yaz = -1.*cos(dec)*sin(h);
 	if (xaz == 0.) {
@@ -103,3 +98,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: riset.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: riset.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/riset_cir.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/riset_cir.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/riset_cir.c	(revision 2551)
@@ -3,20 +3,16 @@
 #include <stdio.h>
 #include <math.h>
-#if defined(__STDC__)
 #include <stdlib.h>
 #include <string.h>
-#endif
-
-#include "P_.h"
+
 #include "astro.h"
-#include "circum.h"
 
 #define	TMACC	(10./3600./24.0)	/* convergence accuracy, days */
 
-static void e_riset_cir P_((Now *np, Obj *op, double dis, RiseSet *rp));
-static int find_0alt P_((double dt, double dis, Now *np, Obj *op));
-static int find_transit P_((double dt, Now *np, Obj *op));
-static int find_max P_((Now *np, Obj *op, double tr, double ts, double *tp,
-    double *alp));
+static void e_riset_cir (Now *np, Obj *op, double dis, RiseSet *rp);
+static int find_0alt (double dt, double dis, Now *np, Obj *op);
+static int find_transit (double dt, Now *np, Obj *op);
+static int find_max (Now *np, Obj *op, double tr, double ts, double *tp,
+    double *alp);
 
 /* find where and when an object, op, will rise and set and
@@ -26,9 +22,5 @@
  */
 void
-riset_cir (np, op, dis, rp)
-Now *np;
-Obj *op;
-double dis;
-RiseSet *rp;
+riset_cir (Now *np, Obj *op, double dis, RiseSet *rp)
 {
 	double mjdn;	/* mjd of local noon */
@@ -64,6 +56,6 @@
 	/* first approximation is to find rise/set times of a fixed object
 	 * at the current epoch in its position at local noon.
-	 * N.B. add typical refraction for initial go/no-go test. if it
-	 *   passes, real code does refraction rigorously.
+	 * N.B. add typical refraction if dis is above horizon for initial
+	 *   go/no-go test. if it passes, real code does refraction rigorously.
 	 */
 	n.n_mjd = mjdn;
@@ -73,5 +65,6 @@
 	}
 	ran = o.s_gaera;
-	riset (o.s_gaera, o.s_gaedec, lat, dis+.01, &lr, &ls, &ar, &as, &rss);
+	riset (o.s_gaera, o.s_gaedec, lat, dis+(dis>.01 ? 0 : .01), &lr, &ls,
+								&ar, &as, &rss);
 	switch (rss) {
 	case  0:  break;
@@ -133,15 +126,12 @@
  */
 void
-twilight_cir (np, dis, dawn, dusk, status)
-Now *np;
-double dis;
-double *dawn, *dusk;
-int *status;
+twilight_cir (Now *np, double dis, double *dawn, double *dusk, int *status)
 {
 	RiseSet rs;
 	Obj o;
 
+	memset (&o, 0, sizeof(o));
 	o.o_type = PLANET;
-	o.pl.pl_code = SUN;
+	o.pl_code = SUN;
 	(void) strcpy (o.o_name, "Sun");
 	riset_cir (np, &o, dis, &rs);
@@ -160,9 +150,5 @@
  */
 static void
-e_riset_cir (np, op, dis, rp)
-Now *np;
-Obj *op;
-double dis;
-RiseSet *rp;
+e_riset_cir (Now *np, Obj *op, double dis, RiseSet *rp)
 {
 #define	DEGSTEP	5		/* time step is about this many degrees */
@@ -272,9 +258,9 @@
  */
 static int
-find_0alt (dt, dis, np, op)
-double dt;	/* hours from noon to first guess at event */
-double dis;	/* horizon displacement, rads */
-Now *np;	/* working Now -- starts with mjd is noon, returns as answer */
-Obj *op;	/* working object -- returns as answer */
+find_0alt (
+double dt,	/* hours from noon to first guess at event */
+double dis,	/* horizon displacement, rads */
+Now *np,	/* working Now -- starts with mjd is noon, returns as answer */
+Obj *op)	/* working object -- returns as answer */
 {
 #define	MAXPASSES	20		/* max iterations to try */
@@ -286,8 +272,10 @@
 
 	/* insure initial guess is today -- if not, move by 24 hours */
-	if (dt < -12.0)
-	    dt += 24.0;
-	if (dt > 12.0)
-	    dt -= 24.0;
+	if (dt < -12.0 && !find_0alt (dt+24, dis, np, op))
+	    return (0);
+	mjd = mjdn;
+	if (dt > 12.0 && !find_0alt (dt-24, dis, np, op))
+	    return (0);
+	mjd = mjdn;
 	
 	/* convert dt to days for remainder of algorithm */
@@ -325,8 +313,5 @@
  */
 static int
-find_transit (dt, np, op)
-double dt;
-Now *np;
-Obj *op;
+find_transit (double dt, Now *np, Obj *op)
 {
 #define	MAXLOOPS	10
@@ -370,9 +355,9 @@
  */
 static int
-find_max (np, op, tr, ts, tp, alp)
-Now *np;
-Obj *op;
-double tr, ts;		/* times of rise and set */
-double *tp, *alp;	/* time of max altitude, and that altitude */
+find_max (
+Now *np,
+Obj *op,
+double tr, double ts,		/* times of rise and set */
+double *tp, double *alp)	/* time of max altitude, and that altitude */
 {
 	mjd = (ts + tr)/2;
@@ -385,3 +370,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: riset_cir.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: riset_cir.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/satlib.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/satlib.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/satlib.h	(revision 2551)
@@ -2,5 +2,5 @@
 #define __SATLIB_H
 
-/* $Id: satlib.h,v 1.2 2001-10-22 12:08:28 cmv Exp $ */
+/* $Id: satlib.h,v 1.3 2004-06-15 16:52:40 cmv Exp $ */
 
 typedef struct _SatElem {
@@ -203,4 +203,4 @@
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: satlib.h,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: satlib.h,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/satmoon.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/satmoon.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/satmoon.c	(revision 2551)
@@ -0,0 +1,458 @@
+/* saturn moon info */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "astro.h"
+#include "bdl.h"
+
+static int use_bdl (double JD, char *dir, MoonData md[S_NMOONS]);
+static void bruton_saturn (Obj *sop, double JD, MoonData md[S_NMOONS]);
+static void moonradec (double satsize, MoonData md[S_NMOONS]);
+static void moonSVis (Obj *eop, Obj *sop, MoonData md[S_NMOONS]);
+static void moonEVis (MoonData md[S_NMOONS]);
+
+/* moon table and a few other goodies and when it was last computed */
+static double mdmjd = -123456;
+static MoonData smd[S_NMOONS] = {
+    {"Saturn",	NULL},
+    {"Mimas",	"I"},
+    {"Enceladus","II"},
+    {"Tethys",	"III"},
+    {"Dione",	"IV"},
+    {"Rhea",	"V"},
+    {"Titan",	"VI"},
+    {"Hyperion","VII"},
+    {"Iapetus",	"VIII"},
+};
+static double sizemjd;
+static double etiltmjd;
+static double stiltmjd;
+
+/* file containing BDL coefficients */
+static char sbdlfn[] = "saturne.9910";
+
+/* get saturn info in md[0], moon info in md[1..S_NMOONS-1].
+ * if !dir always use bruton model.
+ * if !sop caller just wants md[] for names
+ * N.B. we assume eop and sop are updated.
+ */
+void
+saturn_data (
+double Mjd,			/* mjd */
+char dir[],			/* dir in which to look for helper files */
+Obj *eop,			/* earth == Sun */
+Obj *sop,			/* saturn */
+double *sizep,			/* saturn's angular diam, rads */
+double *etiltp, double *stiltp,	/* earth and sun tilts -- +S */
+MoonData md[S_NMOONS])		/* return info */
+{
+	double JD;
+
+	/* always copy back at least for name */
+	memcpy (md, smd, sizeof(smd));
+
+	/* nothing else if repeat call or just want names */
+	if (Mjd == mdmjd || !sop) {
+	    if (sop) {
+		*sizep = sizemjd;
+		*etiltp = etiltmjd;
+		*stiltp = stiltmjd;
+	    }
+	    return;
+	}
+	JD = Mjd + MJD0;
+
+	/* planet in [0] */
+	md[0].ra = sop->s_ra;
+	md[0].dec = sop->s_dec;
+	md[0].mag = get_mag(sop);
+	md[0].x = 0;
+	md[0].y = 0;
+	md[0].z = 0;
+	md[0].evis = 1;
+	md[0].svis = 1;
+
+	/* size is straight from sop */
+	*sizep = degrad(sop->s_size/3600.0);
+
+	/*  Visual Magnitude of the Satellites */
+
+	md[1].mag = 13; md[2].mag = 11.8; md[3].mag = 10.3; md[4].mag = 10.2;
+	md[5].mag = 9.8; md[6].mag = 8.4; md[7].mag = 14.3; md[8].mag = 11.2;
+
+	/* get tilts from sky and tel code */
+	satrings (sop->s_hlat, sop->s_hlong, sop->s_sdist, eop->s_hlong,
+					    eop->s_edist, JD, etiltp, stiltp);
+
+	/* get moon x,y,z from BDL if possible, else Bruton's model */
+	if (dir && use_bdl (JD, dir, md) < 0)
+	    bruton_saturn (sop, JD, md);
+
+	/* set visibilities */
+	moonSVis (eop, sop, md);
+	moonEVis (md);
+
+	/* fill in moon ra and dec */
+	moonradec (*sizep, md);
+
+	/* save */
+	mdmjd = Mjd;
+	etiltmjd = *etiltp;
+	stiltmjd = *stiltp;
+	sizemjd = *sizep;
+	memcpy (smd, md, sizeof(smd));
+}
+
+/* hunt for BDL file in dir[] and use if possible.
+ * return 0 if ok, else -1
+ */
+static int
+use_bdl (
+double JD,		/* julian date */
+char dir[],		/* directory */
+MoonData md[S_NMOONS])	/* fill md[1..NM-1].x/y/z for each moon */
+{
+#define	SATRAU	.0004014253	/* saturn radius, AU */
+	double x[S_NMOONS], y[S_NMOONS], z[S_NMOONS];
+	char buf[1024];
+	FILE *fp;
+	int i;
+
+	/* only valid 1999 through 2010 */
+	if (JD < 2451179.50000 || JD >= 2455562.5)
+	    return (-1);
+
+	/* open */
+	(void) sprintf (buf, "%s/%s", dir, sbdlfn);
+	fp = fopen (buf, "r");
+	if (!fp)
+	    return (-1);
+
+	/* use it */
+	if ((i = read_bdl (fp, JD, x, y, z, buf)) < 0) {
+	    fprintf (stderr, "%s: %s\n", sbdlfn, buf);
+	    fclose (fp);
+	    return (-1);
+	}
+	if (i != S_NMOONS-1) {
+	    fprintf (stderr, "%s: BDL says %d moons, code expects %d", sbdlfn,
+								i, S_NMOONS-1);
+	    fclose (fp);
+	    return (-1);
+	}
+
+	/* copy into md[1..NM-1] with our scale and sign conventions */
+	for (i = 1; i < S_NMOONS; i++) {
+	    md[i].x =  x[i-1]/SATRAU;	/* we want sat radii +E */
+	    md[i].y = -y[i-1]/SATRAU;	/* we want sat radii +S */
+	    md[i].z = -z[i-1]/SATRAU;	/* we want sat radii +front */
+	}
+
+	/* ok */
+	fclose (fp);
+	return (0);
+}
+
+/*  */
+/*     SS2TXT.BAS                     Dan Bruton, astro@tamu.edu */
+/*  */
+/*       This is a text version of SATSAT2.BAS.  It is smaller, */
+/*    making it easier to convert other languages (250 lines */
+/*    compared to 850 lines). */
+/*  */
+/*       This BASIC program computes and displays the locations */
+/*    of Saturn's Satellites for a given date and time.  See */
+/*    "Practical Astronomy with your Calculator" by Peter */
+/*    Duffett-Smith and the Astronomical Almanac for explanations */
+/*    of some of the calculations here.  The code is included so */
+/*    that users can make changes or convert to other languages. */
+/*    This code was made using QBASIC (comes with DOS 5.0). */
+/*  */
+/*    ECD: merged with Sky and Tel, below, for better earth and sun ring tilt */
+/*  */
+
+/* ECD: BASICeze */
+#define	FOR	for
+#define	IF	if
+#define	ELSE	else
+#define	COS	cos
+#define	SIN	sin
+#define	TAN	tan
+#define ATN	atan
+#define ABS	fabs
+#define SQR	sqrt
+
+/* find saturn moon data from Bruton's model */
+/* this originally computed +X:East +Y:North +Z:behind in [1..8] indeces.
+ * and +tilt:front south, rads
+ * then we adjust things in md[].x/y/z/mag to fit into our MoonData format.
+ */
+static void
+bruton_saturn (
+Obj *sop,		/* saturn */
+double JD,		/* julian date */
+MoonData md[S_NMOONS])	/* fill md[1..NM-1].x/y/z for each moon */
+{
+     /* ECD: code does not use [0].
+      * ECD and why 11 here? seems like 9 would do
+      */
+     double SMA[11], U[11], U0[11], PD[11];
+     double X[S_NMOONS], Y[S_NMOONS], Z[S_NMOONS];
+
+     double P,TP,TE,EP,EE,RE0,RP0,RS;
+     double JDE,LPE,LPP,LEE,LEP;
+     double NN,ME,MP,VE,VP;
+     double LE,LP,RE,RP,DT,II,F,F1;
+     double RA,DECL;
+     double TVA,PVA,TVC,PVC,DOT1,INC,TVB,PVB,DOT2,INCI;
+     double TRIP,GAM,TEMPX,TEMPY,TEMPZ;
+     int I;
+
+     /* saturn */
+     RA = sop->s_ra;
+     DECL = sop->s_dec;
+
+     /*  ******************************************************************** */
+     /*  *                                                                  * */
+     /*  *                        Constants                                 * */
+     /*  *                                                                  * */
+     /*  ******************************************************************** */
+     P = PI / 180;
+     /*  Orbital Rate of Saturn in Radians per Days */
+     TP = 2 * PI / (29.45771 * 365.2422);
+     /*  Orbital Rate of Earth in Radians per Day */
+     TE = 2 * PI / (1.00004 * 365.2422);
+     /*  Eccentricity of Saturn's Orbit */
+     EP = .0556155;
+     /*  Eccentricity of Earth's Orbit */
+     EE = .016718;
+     /*  Semimajor axis of Earth's and Saturn's orbit in Astronomical Units */
+     RE0 = 1; RP0 = 9.554747;
+     /*  Semimajor Axis of the Satellites' Orbit in Kilometers */
+     SMA[1] = 185600; SMA[2] = 238100; SMA[3] = 294700; SMA[4] = 377500;
+     SMA[5] = 527200; SMA[6] = 1221600; SMA[7] = 1483000; SMA[8] = 3560100;
+     /*  Eccentricity of Satellites' Orbit [Program uses 0] */
+     /*  Synodic Orbital Period of Moons in Days */
+     PD[1] = .9425049;
+     PD[2] = 1.3703731;
+     PD[3] = 1.8880926;
+     PD[4] = 2.7375218;
+     PD[5] = 4.5191631;
+     PD[6] = 15.9669028;
+     PD[7] = 21.3174647;
+     PD[8] = 79.9190206;	/* personal mail 1/14/95 */
+     RS = 60330; /*  Radius of planet in kilometers */
+    
+     /*  ******************************************************************** */
+     /*  *                                                                  * */
+     /*  *                      Epoch Information                           * */
+     /*  *                                                                  * */
+     /*  ******************************************************************** */
+     JDE = 2444238.5; /*  Epoch Jan 0.0 1980 = December 31,1979 0:0:0 UT */
+     LPE = 165.322242 * P; /*  Longitude of Saturn at Epoch */
+     LPP = 92.6653974 * P; /*  Longitude of Saturn`s Perihelion */
+     LEE = 98.83354 * P; /*  Longitude of Earth at Epoch */
+     LEP = 102.596403 * P; /*  Longitude of Earth's Perihelion */
+     /*  U0[I] = Angle from inferior geocentric conjuction */
+     /*          measured westward along the orbit at epoch */
+     U0[1] = 18.2919 * P;
+     U0[2] = 174.2135 * P;
+     U0[3] = 172.8546 * P;
+     U0[4] = 76.8438 * P;
+     U0[5] = 37.2555 * P;
+     U0[6] = 57.7005 * P;
+     U0[7] = 266.6977 * P;
+     U0[8] = 195.3513 * P;	/* from personal mail 1/14/1995 */
+    
+     /*  ******************************************************************** */
+     /*  *                                                                  * */
+     /*  *                    Orbit Calculations                            * */
+     /*  *                                                                  * */
+     /*  ******************************************************************** */
+     /*  ****************** FIND MOON ORBITAL ANGLES ************************ */
+     NN = JD - JDE; /*  NN = Number of days since epoch */
+     ME = ((TE * NN) + LEE - LEP); /*  Mean Anomoly of Earth */
+     MP = ((TP * NN) + LPE - LPP); /*  Mean Anomoly of Saturn */
+     VE = ME; VP = MP; /*  True Anomolies - Solve Kepler's Equation */
+     FOR (I = 1; I <= 3; I++) {
+	 VE = VE - (VE - (EE * SIN(VE)) - ME) / (1 - (EE * COS(VE)));
+	 VP = VP - (VP - (EP * SIN(VP)) - MP) / (1 - (EP * COS(VP)));
+     }
+     VE = 2 * ATN(SQR((1 + EE) / (1 - EE)) * TAN(VE / 2));
+     IF (VE < 0) VE = (2 * PI) + VE;
+     VP = 2 * ATN(SQR((1 + EP) / (1 - EP)) * TAN(VP / 2));
+     IF (VP < 0) VP = (2 * PI) + VP;
+     /*   Heliocentric Longitudes of Earth and Saturn */
+     LE = VE + LEP; IF (LE > (2 * PI)) LE = LE - (2 * PI);
+     LP = VP + LPP; IF (LP > (2 * PI)) LP = LP - (2 * PI);
+     /*   Distances of Earth and Saturn from the Sun in AU's */
+     RE = RE0 * (1 - EE * EE) / (1 + EE * COS(VE));
+     RP = RP0 * (1 - EP * EP) / (1 + EP * COS(VP));
+     /*   DT = Distance from Saturn to Earth in AU's - Law of Cosines */
+     DT = SQR((RE * RE) + (RP * RP) - (2 * RE * RP * COS(LE - LP)));
+     /*   II = Angle between Earth and Sun as seen from Saturn */
+     II = RE * SIN(LE - LP) / DT;
+     II = ATN(II / SQR(1 - II * II)); /*   ArcSIN and Law of Sines */
+     /*    F = NN - (Light Time to Earth in days) */
+     F = NN - (DT / 173.83);
+     F1 = II + MP - VP;
+     /*  U(I) = Angle from inferior geocentric conjuction measured westward */
+     FOR (I = 1; I < S_NMOONS; I++) {
+	U[I] = U0[I] + (F * 2 * PI / PD[I]) + F1;
+	U[I] = ((U[I] / (2 * PI)) - (int)(U[I] / (2 * PI))) * 2 * PI;
+
+     }
+
+     /*  **************** FIND INCLINATION OF RINGS ************************* */
+     /*  Use dot product of Earth-Saturn vector and Saturn's rotation axis */
+     TVA = (90 - 83.51) * P; /*  Theta coordinate of Saturn's axis */
+     PVA = 40.27 * P; /*  Phi coordinate of Saturn's axis */
+     TVC = (PI / 2) - DECL;
+     PVC = RA;
+     DOT1 = SIN(TVA) * COS(PVA) * SIN(TVC) * COS(PVC);
+     DOT1 = DOT1 + SIN(TVA) * SIN(PVA) * SIN(TVC) * SIN(PVC);
+     DOT1 = DOT1 + COS(TVA) * COS(TVC);
+     INC = ATN(SQR(1 - DOT1 * DOT1) / DOT1); /*    ArcCOS */
+     IF (INC > 0) INC = (PI / 2) - INC; ELSE INC = -(PI / 2) - INC;
+
+     /*  ************* FIND INCLINATION OF IAPETUS' ORBIT ******************* */
+     /*  Use dot product of Earth-Saturn vector and Iapetus' orbit axis */
+     /*  Vector B */
+     TVB = (90 - 75.6) * P; /*  Theta coordinate of Iapetus' orbit axis (estimate) */
+     PVB = 21.34 * 2 * PI / 24; /*  Phi coordinate of Iapetus' orbit axis (estimate) */
+     DOT2 = SIN(TVB) * COS(PVB) * SIN(TVC) * COS(PVC);
+     DOT2 = DOT2 + SIN(TVB) * SIN(PVB) * SIN(TVC) * SIN(PVC);
+     DOT2 = DOT2 + COS(TVB) * COS(TVC);
+     INCI = ATN(SQR(1 - DOT2 * DOT2) / DOT2); /*    ArcCOS */
+     IF (INCI > 0) INCI = (PI / 2) - INCI; ELSE INCI = -(PI / 2) - INCI;
+
+     /*  ************* FIND ROTATION ANGLE OF IAPETUS' ORBIT **************** */
+     /*  Use inclination of Iapetus' orbit with respect to ring plane */
+     /*  Triple Product */
+     TRIP = SIN(TVC) * COS(PVC) * SIN(TVA) * SIN(PVA) * COS(TVB);
+     TRIP = TRIP - SIN(TVC) * COS(PVC) * SIN(TVB) * SIN(PVB) * COS(TVA);
+     TRIP = TRIP + SIN(TVC) * SIN(PVC) * SIN(TVB) * COS(PVB) * COS(TVA);
+     TRIP = TRIP - SIN(TVC) * SIN(PVC) * SIN(TVA) * COS(PVA) * COS(TVB);
+     TRIP = TRIP + COS(TVC) * SIN(TVA) * COS(PVA) * SIN(TVB) * SIN(PVB);
+     TRIP = TRIP - COS(TVC) * SIN(TVB) * COS(PVB) * SIN(TVA) * SIN(PVA);
+     GAM = -1 * ATN(TRIP / SQR(1 - TRIP * TRIP)); /*  ArcSIN */
+    
+     /*  ******************************************************************** */
+     /*  *                                                                  * */
+     /*  *                     Compute Moon Positions                       * */
+     /*  *                                                                  * */
+     /*  ******************************************************************** */
+     FOR (I = 1; I < S_NMOONS - 1; I++) {
+	 X[I] = -1 * SMA[I] * SIN(U[I]) / RS;
+	 Z[I] = -1 * SMA[I] * COS(U[I]) / RS;	/* ECD */
+	 Y[I] = SMA[I] * COS(U[I]) * SIN(INC) / RS;
+     }
+     /*  ************************* Iapetus' Orbit *************************** */
+     TEMPX = -1 * SMA[8] * SIN(U[8]) / RS;
+     TEMPZ = -1 * SMA[8] * COS(U[8]) / RS;
+     TEMPY = SMA[8] * COS(U[8]) * SIN(INCI) / RS;
+     X[8] = TEMPX * COS(GAM) + TEMPY * SIN(GAM); /*       Rotation */
+     Z[8] = TEMPZ * COS(GAM) + TEMPY * SIN(GAM);
+     Y[8] = -1 * TEMPX * SIN(GAM) + TEMPY * COS(GAM);
+    
+#ifdef SHOWALL
+     /*  ******************************************************************** */
+     /*  *                                                                  * */
+     /*  *                          Show Results                            * */
+     /*  *                                                                  * */
+     /*  ******************************************************************** */
+     printf ("                           Julian Date : %g\n", JD);
+     printf ("             Right Ascension of Saturn : %g Hours\n", RA * 24 / (2 * PI));
+     printf ("                 Declination of Saturn : %g\n", DECL / P);
+     printf ("   Ring Inclination as seen from Earth : %g\n", -1 * INC / P);
+     printf ("      Heliocentric Longitude of Saturn : %g\n", LP / P);
+     printf ("       Heliocentric Longitude of Earth : %g\n", LE / P);
+     printf ("                Sun-Saturn-Earth Angle : %g\n", II / P);
+     printf ("     Distance between Saturn and Earth : %g AU = %g million miles\n", DT, (DT * 93));
+     printf ("       Light time from Saturn to Earth : %g minutes\n", DT * 8.28);
+     TEMP = 2 * ATN(TAN(165.6 * P / (2 * 3600)) / DT) * 3600 / P;
+     printf ("                Angular Size of Saturn : %g arcsec\n", TEMP);
+     printf ("  Major Angular Size of Saturn's Rings : %g arcsec\n", RS4 * TEMP / RS);
+     printf ("  Minor Angular Size of Saturn's Rings : %g arcsec\n", ABS(RS4 * TEMP * SIN(INC) / RS));
+#endif
+
+     /* copy into md[1..S_NMOONS-1] with our sign conventions */
+     for (I = 1; I < S_NMOONS; I++) {
+	md[I].x =  X[I];	/* we want +E */
+	md[I].y = -Y[I];	/* we want +S */
+	md[I].z = -Z[I];	/* we want +front */
+     }
+}
+
+/* given saturn loc in md[0].ra/dec and size, and location of each moon in 
+ * md[1..NM-1].x/y in sat radii, find ra/dec of each moon in md[1..NM-1].ra/dec.
+ */
+static void
+moonradec (
+double satsize,		/* sat diameter, rads */
+MoonData md[S_NMOONS])	/* fill in RA and Dec */
+{
+	double satrad = satsize/2;
+	double satra = md[0].ra;
+	double satdec = md[0].dec;
+	int i;
+
+	for (i = 1; i < S_NMOONS; i++) {
+	    double dra  = satrad * md[i].x;
+	    double ddec = satrad * md[i].y;
+	    md[i].ra  = satra + dra;
+	    md[i].dec = satdec - ddec;
+	}
+}
+
+/* set svis according to whether moon is in sun light */
+static void
+moonSVis(
+Obj *eop,		/* earth == SUN */
+Obj *sop,		/* saturn */
+MoonData md[S_NMOONS])
+{
+	double esd = eop->s_edist;
+	double eod = sop->s_edist;
+	double sod = sop->s_sdist;
+	double soa = degrad(sop->s_elong);
+	double esa = asin(esd*sin(soa)/sod);
+	double   h = sod*sop->s_hlat;
+	double nod = h*(1./eod - 1./sod);
+	double sca = cos(esa), ssa = sin(esa);
+	int i;
+
+	for (i = 1; i < S_NMOONS; i++) {
+	    MoonData *mdp = &md[i];
+	    double xp =  sca*mdp->x + ssa*mdp->z;
+	    double yp =  mdp->y;
+	    double zp = -ssa*mdp->x + sca*mdp->z;
+	    double ca = cos(nod), sa = sin(nod);
+	    double xpp = xp;
+	    double ypp = ca*yp - sa*zp;
+	    double zpp = sa*yp + ca*zp;
+	    int outside = xpp*xpp + ypp*ypp > 1.0;
+	    int infront = zpp > 0.0;
+	    mdp->svis = outside || infront;
+	}
+}
+
+/* set evis according to whether moon is geometrically visible from earth */
+static void
+moonEVis (MoonData md[S_NMOONS])
+{
+	int i;
+
+	for (i = 1; i < S_NMOONS; i++) {
+	    MoonData *mdp = &md[i];
+	    int outside = mdp->x*mdp->x + mdp->y*mdp->y > 1.0;
+	    int infront = mdp->z > 0.0;
+	    mdp->evis = outside || infront;
+	}
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: satmoon.c,v $ $Date: 2004-06-15 16:54:12 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/satspec.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/satspec.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/satspec.h	(revision 2551)
@@ -2,5 +2,5 @@
 #define __SATSPEC_H
 
-/* $Id: satspec.h,v 1.2 2001-10-22 12:08:28 cmv Exp $ */
+/* $Id: satspec.h,v 1.3 2004-06-15 16:52:40 cmv Exp $ */
 
 #include "sattypes.h"
@@ -40,4 +40,4 @@
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: satspec.h,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: satspec.h,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/sattypes.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/sattypes.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/sattypes.h	(revision 2551)
@@ -2,5 +2,5 @@
 #define __SATTYPES_H
 
-/* $Id: sattypes.h,v 1.2 2001-10-22 12:08:28 cmv Exp $ */
+/* $Id: sattypes.h,v 1.3 2004-06-15 16:52:40 cmv Exp $ */
 
 typedef struct _Vec3 {
@@ -25,4 +25,4 @@
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: sattypes.h,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: sattypes.h,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/sdp4.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/sdp4.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/sdp4.c	(revision 2551)
@@ -96,9 +96,5 @@
 
 void
-sdp4 (sat, pos, dpos, TSINCE)
-SatData *sat;
-Vec3 *pos;
-Vec3 *dpos;
-double TSINCE;
+sdp4 (SatData *sat, Vec3 *pos, Vec3 *dpos, double TSINCE)
 {
     int i;
@@ -109,8 +105,8 @@
 
     /* private temporary variables */
-    double A,AXN,AYN,AYNL,BETA,BETAL,CAPU,COS2U,COSEPW,
+    double A,AXN,AYN,AYNL,BETA,BETAL,CAPU,COS2U,COSEPW=0,
 	COSIK,COSNOK,COSU,COSUK,E,ECOSE,ELSQ,EM=0,EPW,ESINE,OMGADF,PL,
-	R,RDOT,RDOTK,RFDOT,RFDOTK,RK,SIN2U,SINEPW,SINIK,SINNOK,
-	SINU,SINUK,TEMP,TEMP1,TEMP2,TEMP3,TEMP4,TEMP5,TEMP6,TEMPA,
+	R,RDOT,RDOTK,RFDOT,RFDOTK,RK,SIN2U,SINEPW=0,SINIK,SINNOK,
+	SINU,SINUK,TEMP,TEMP1,TEMP2,TEMP3=0,TEMP4=0,TEMP5=0,TEMP6=0,TEMPA,
 	TEMPE,TEMPL,TSQ,U,UK,UX,UY,UZ,VX,VY,VZ,XINC=0,XINCK,XL,XLL,XLT,
 	XMAM,XMDF,XMX,XMY,XN,XNODDF,XNODE,XNODEK;
@@ -432,3 +428,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sdp4.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sdp4.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/sgp4.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/sgp4.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/sgp4.c	(revision 2551)
@@ -79,9 +79,5 @@
  */
 void
-sgp4(sat, pos, dpos, TSINCE)
-SatData *sat;
-Vec3 *pos;
-Vec3 *dpos;
-double TSINCE;
+sgp4(SatData *sat, Vec3 *pos, Vec3 *dpos, double TSINCE)
 {
     int i;
@@ -89,11 +85,11 @@
     double A1, A3OVK2, AO, BETAO, BETAO2, C1SQ, C2, C3, COEF, COEF1,
 	DEL1, DELO, EETA, EOSQ, ETASQ, PERIGE, PINVSQ, PSISQ, QOMS24,
-	S4, TEMP, TEMP1, TEMP2, TEMP3, THETA2, THETA4, TSI, X1M5TH,
+	S4, TEMP, TEMP1, TEMP2, TEMP3=0, THETA2, THETA4, TSI, X1M5TH,
 	XHDOT1;
 
-    double A, AXN, AYN, AYNL, BETA, BETAL, CAPU, COS2U, COSEPW, COSIK,
+    double A, AXN, AYN, AYNL, BETA, BETAL, CAPU, COS2U, COSEPW=0, COSIK,
 	COSNOK, COSU, COSUK, DELM, DELOMG, E, ECOSE, ELSQ, EPW, ESINE,
 	OMEGA, OMGADF, PL, R, RDOT, RDOTK, RFDOT, RFDOTK, RK, SIN2U,
-	SINEPW, SINIK, SINNOK, SINU, SINUK, TCUBE, TEMP4, TEMP5, TEMP6,
+	SINEPW=0, SINIK, SINNOK, SINU, SINUK, TCUBE, TEMP4=0, TEMP5=0, TEMP6=0,
 	TEMPA, TEMPE, TEMPL, TFOUR, TSQ, U, UK, UX, UY, UZ, VX, VY, VZ,
 	XINCK, XL, XLL, XLT, XMDF, XMP, XMX, XMY, XN, XNODDF, XNODE,
@@ -403,3 +399,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sgp4.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sgp4.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/sphcart.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/sphcart.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/sphcart.c	(revision 2551)
@@ -1,11 +1,12 @@
 #include <math.h>
-#include "P_.h"
+#include <stdio.h>
+
 #include "astro.h"
 
 /* transformation from spherical to cartesian coordinates */
 void
-sphcart (l, b, r, x, y, z)
-double l, b, r;		/* source: spherical coordinates */
-double *x, *y, *z;	/* result: rectangular coordinates */
+sphcart (
+double l, double b, double r,		/* source: spherical coordinates */
+double *x, double *y, double *z)	/* result: rectangular coordinates */
 {
 	double rcb = r * cos(b);
@@ -18,7 +19,7 @@
 /* transformation from cartesian to spherical coordinates */
 void
-cartsph (x, y, z, l, b, r)
-double x, y, z;		/* source: rectangular coordinates */
-double *l, *b, *r;	/* result: spherical coordinates */
+cartsph (
+double x, double y, double z,		/* source: rectangular coordinates */
+double *l, double *b, double *r)	/* result: spherical coordinates */
 {
 	double rho = x*x + y*y;
@@ -40,3 +41,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sphcart.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sphcart.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/sun.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/sun.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/sun.c	(revision 2551)
@@ -2,9 +2,8 @@
 #include <math.h>
 
-#include "P_.h"
 #include "astro.h"
 #include "vsop87.h"
 
-/* given the modified JD, mjd, return the true geocentric ecliptic longitude
+/* given the modified JD, mj, return the true geocentric ecliptic longitude
  *   of the sun for the mean equinox of the date, *lsn, in radians, the
  *   sun-earth distance, *rsn, in AU, and the latitude *bsn, in radians
@@ -17,12 +16,10 @@
  */
 void
-sunpos (mjd, lsn, rsn, bsn)
-double mjd;
-double *lsn, *rsn, *bsn;
+sunpos (double mj, double *lsn, double *rsn, double *bsn)
 {
-	static double last_mjd = -3691, last_lsn, last_rsn, last_bsn;
+	static double last_mj = -3691, last_lsn, last_rsn, last_bsn;
 	double ret[6];
 
-	if (mjd == last_mjd) {
+	if (mj == last_mj) {
 	    *lsn = last_lsn;
 	    *rsn = last_rsn;
@@ -31,5 +28,5 @@
 	}
 
-	vsop87(mjd, SUN, 0.0, ret);	/* full precision earth pos */
+	vsop87(mj, SUN, 0.0, ret);	/* full precision earth pos */
 
 	*lsn = ret[0] - PI;		/* revert to sun pos */
@@ -39,5 +36,5 @@
 	last_rsn = *rsn = ret[2];
 	last_bsn = -ret[1];
-	last_mjd = mjd;
+	last_mj = mj;
 
 	if (bsn) *bsn = last_bsn;	/* assign only if non-NULL pointer */
@@ -45,3 +42,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sun.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: sun.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/testxephem.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/testxephem.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/testxephem.c	(revision 2551)
@@ -4,5 +4,5 @@
 #include <math.h>
 #include <unistd.h>
-#include "P_.h"
+/* include "P_.h" */
 #include "astro.h"
 
@@ -11,19 +11,19 @@
 int main(int narg,char** arg)
 {
-  int year=1989,month=7,day=21; /* UTC*/
+ int year=1989,month=7,day=21; /* UTC*/
  double hour=12.5;
  int npnum=8, pnum[8]={MERCURY,VENUS,MARS,JUPITER,SATURN,URANUS,NEPTUNE,PLUTO};
  int i;
- double mjd,sunecl,sunecb,sundist,geodist,geoecl,geoecb,diamang,mag,msp,mdp;
+ double mymjd,sunecl,sunecb,sundist,geodist,geoecl,geoecb,diamang,mag,msp,mdp;
 
- cal_mjd(month,day+hour/24.,year,&mjd);
- printf("date %d/%d/%d %gh  -> mjd=%f\n",day,month,year,hour,mjd);
+ cal_mjd(month,day+hour/24.,year,&mymjd);
+ printf("date %d/%d/%d %gh  -> mjd=%f\n",day,month,year,hour,mymjd);
 
  /* Soleil */
- sunpos(mjd,&geoecl,&geodist,&geoecb);
+ sunpos(mymjd,&geoecl,&geodist,&geoecb);
  printf("Sun: geo ecl=%g ecb=%g dist=%g\n",geoecl*R2D,geoecb*R2D,geodist);
 
  /* Lune */
- moon(mjd,&geoecl,&geoecb,&geodist,&msp,&mdp);
+ moon(mymjd,&geoecl,&geoecb,&geodist,&msp,&mdp);
  printf("Moon: geo ecl=%g ecb=%g dist=%g\n",geoecl*R2D,geoecb*R2D,geodist);
 
@@ -31,5 +31,5 @@
  printf("--- Planets\n");
  for(i=0;i<npnum;i++) {
-   plans(mjd,pnum[i],&sunecl,&sunecb,&sundist,&geodist,&geoecl,&geoecb,&diamang,&mag);
+   plans(mymjd,pnum[i],&sunecl,&sunecb,&sundist,&geodist,&geoecl,&geoecb,&diamang,&mag);
    printf("pnum=%d: sun ecl=%g ecb=%g dist=%g,",pnum[i],sunecl*R2D,sunecb*R2D,sundist);
    printf(" geo ecl=%g ecb=%g dist=%g,",geoecl*R2D,geoecb*R2D,geodist);
Index: /trunk/SophyaExt/XephemAstroLib/thetag.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/thetag.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/thetag.c	(revision 2551)
@@ -3,5 +3,5 @@
 #include "deepconst.h"
 
-/* @(#) $Id: thetag.c,v 1.2 2001-10-22 12:08:28 cmv Exp $ */
+/* @(#) $Id: thetag.c,v 1.3 2004-06-15 16:52:40 cmv Exp $ */
 
 
@@ -88,3 +88,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: thetag.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: thetag.c,v $ $Date: 2004-06-15 16:52:40 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/twobody.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/twobody.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/twobody.c	(revision 2551)
@@ -22,8 +22,11 @@
  
 /* Constants used when solving Kepler's equation */
+#undef  EPSILON
 #define EPSILON   3E-8
+#undef  INFINITY
 #define INFINITY  1E+10
  
 /* Math constants */
+#undef  PI
 #define PI      3.14159265358979323846
 #define RADEG   ( 180.0 / PI )
@@ -125,5 +128,6 @@
  
  
-void vrc( double *v, double *r, double tp, double e, double q )
+/* return 0 if ok, else -1 */
+int vrc( double *v, double *r, double tp, double e, double q )
 /*
  * Elliptic, hyperbolic and near-parabolic orbits:
@@ -145,5 +149,5 @@
         *v = 0.0;
         *r = q;
-        return;
+        return 0;
     }
  
@@ -176,5 +180,5 @@
                 printf( "\nNear-parabolic orbit: inaccurate result."
                         "\n  e = %f, lambda = %f, w = %f", e, lambda, w );
-                exit(1);
+		return -1;
             }
             else
@@ -202,5 +206,5 @@
         *v = 2.0 * atand(w);
         *r = q * (1+w2) / ( 1.0 + w2*lambda );
-        return;  /* Near-parabolic orbit */
+        return 0;  /* Near-parabolic orbit */
     }
  
@@ -232,7 +236,8 @@
         *r = q * (1.0+e) / ( 1.0 + e*cosd(*v) );
     }
+    return 0;
  
 } /* vrc */
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: twobody.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: twobody.c,v $ $Date: 2004-06-15 16:52:41 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/umoon.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/umoon.c	(revision 2551)
+++ /trunk/SophyaExt/XephemAstroLib/umoon.c	(revision 2551)
@@ -0,0 +1,218 @@
+/* uranus moon info */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "astro.h"
+#include "bdl.h"
+
+static int use_bdl (double jd, char *dir, MoonData md[U_NMOONS]);
+static void moonradec (double usize, MoonData md[U_NMOONS]);
+static void moonSVis (Obj *eop, Obj *uop, MoonData md[U_NMOONS]);
+static void moonEVis (MoonData md[U_NMOONS]);
+
+/* moon table and a few other goodies and when it was last computed */
+static double mdmjd = -123456;
+static MoonData umd[U_NMOONS] = {
+    {"Uranus", NULL},
+    {"Ariel", "I"},
+    {"Umbriel", "II"},
+    {"Titania", "III"},
+    {"Oberon", "IV"},
+    {"Miranda", "V"},
+};
+static double sizemjd;	/* size at last mjd */
+
+/* file containing BDL coefficients */
+static char ubdlfn[] = "uranus.9910";
+
+/* get uranus info in md[0], moon info in md[1..U_NMOONS-1].
+ * if !uop caller just wants md[] for names
+ * N.B. we assume eop and uop are updated.
+ */
+void
+uranus_data (
+double Mjd,		/* mjd */
+char dir[],             /* dir in which to look for helper files */
+Obj *eop,               /* earth == Sun */
+Obj *uop,		/* uranus */
+double *sizep,		/* u angular diam, rads */
+MoonData md[U_NMOONS])	/* return info */
+{
+        double JD;
+
+	/* always copy back at least for name */
+	memcpy (md, umd, sizeof(umd));
+
+	/* nothing else if repeat call or just want names */
+	if (Mjd == mdmjd || !uop) {
+	    if (uop) {
+		*sizep = sizemjd;
+	    }
+	    return;
+	}
+	JD = Mjd + MJD0;
+
+	/* planet in [0] */
+	md[0].ra = uop->s_ra;
+	md[0].dec = uop->s_dec;
+	md[0].mag = get_mag(uop);
+	md[0].x = 0;
+	md[0].y = 0;
+	md[0].z = 0;
+	md[0].evis = 1;
+	md[0].svis = 1;
+
+	/* size is straight from uop */
+	*sizep = degrad(uop->s_size/3600.0);
+
+        /* from Pasachoff/Menzel */
+
+	md[1].mag = 14.2;
+	md[2].mag = 14.8;
+	md[3].mag = 13.7;
+	md[4].mag = 14.0;
+	md[5].mag = 16.3;
+
+	/* get moon x,y,z from BDL if possible */
+	if (dir && use_bdl (JD, dir, md) < 0) {
+	    int i;
+	    for (i = 1; i < U_NMOONS; i++)
+		md[i].x = md[i].y = md[i].z = 0.0;
+	    fprintf (stderr, "No mars model available\n");
+	}
+
+	/* set visibilities */
+	moonSVis (eop, uop, md);
+	moonEVis (md);
+
+	/* fill in moon ra and dec */
+	moonradec (*sizep, md);
+
+	/* save */
+	mdmjd = Mjd;
+	sizemjd = *sizep;
+	memcpy (umd, md, sizeof(umd));
+}
+
+/* hunt for BDL file in dir[] and use if possible
+ * return 0 if ok, else -1
+ */
+static int
+use_bdl (
+double JD,		/* julian date */
+char dir[],		/* directory */
+MoonData md[U_NMOONS])	/* fill md[1..NM-1].x/y/z for each moon */
+{
+#define URAU    .0001597        /* Uranus radius, AU */
+	double x[U_NMOONS], y[U_NMOONS], z[U_NMOONS];
+	char buf[1024];
+	FILE *fp;
+	int i;
+
+	/* only valid 1999 through 2010 */
+	if (JD < 2451179.50000 || JD >= 2455562.5)
+	    return (-1);
+
+	/* open */
+	(void) sprintf (buf, "%s/%s", dir, ubdlfn);
+	fp = fopen (buf, "r");
+	if (!fp)
+	    return (-1);
+
+	/* use it */
+	if ((i = read_bdl (fp, JD, x, y, z, buf)) < 0) {
+	    fprintf (stderr, "%s: %s\n", ubdlfn, buf);
+	    fclose (fp);
+	    return (-1);
+	}
+	if (i != U_NMOONS-1) {
+	    fprintf (stderr, "%s: BDL says %d moons, code expects %d", ubdlfn, 
+								i, U_NMOONS-1);
+	    fclose (fp);
+	    return (-1);
+	}
+
+	/* copy into md[1..NM-1] with our scale and sign conventions */
+	for (i = 1; i < U_NMOONS; i++) {
+	    md[i].x =  x[i-1]/URAU;	/* we want u radii +E */
+	    md[i].y = -y[i-1]/URAU;	/* we want u radii +S */
+	    md[i].z = -z[i-1]/URAU;	/* we want u radii +front */
+	}
+
+	/* ok */
+	fclose (fp);
+	return (0);
+}
+
+/* given uranus loc in md[0].ra/dec and size, and location of each moon in 
+ * md[1..NM-1].x/y in ura radii, find ra/dec of each moon in md[1..NM-1].ra/dec.
+ */
+static void
+moonradec (
+double usize,		/* ura diameter, rads */
+MoonData md[U_NMOONS])	/* fill in RA and Dec */
+{
+	double urad = usize/2;
+	double ura = md[0].ra;
+	double udec = md[0].dec;
+	int i;
+
+	for (i = 1; i < U_NMOONS; i++) {
+	    double dra  = urad * md[i].x;
+	    double ddec = urad * md[i].y;
+	    md[i].ra  = ura + dra;
+	    md[i].dec = udec - ddec;
+	}
+}
+
+/* set svis according to whether moon is in sun light */
+static void
+moonSVis(
+Obj *eop,		/* earth == SUN */
+Obj *uop,		/* uranus */
+MoonData md[U_NMOONS])
+{
+	double esd = eop->s_edist;
+	double eod = uop->s_edist;
+	double sod = uop->s_sdist;
+	double soa = degrad(uop->s_elong);
+	double esa = asin(esd*sin(soa)/sod);
+	double   h = sod*uop->s_hlat;
+	double nod = h*(1./eod - 1./sod);
+	double sca = cos(esa), ssa = sin(esa);
+	int i;
+
+	for (i = 1; i < U_NMOONS; i++) {
+	    MoonData *mdp = &md[i];
+	    double xp =  sca*mdp->x + ssa*mdp->z;
+	    double yp =  mdp->y;
+	    double zp = -ssa*mdp->x + sca*mdp->z;
+	    double ca = cos(nod), sa = sin(nod);
+	    double xpp = xp;
+	    double ypp = ca*yp - sa*zp;
+	    double zpp = sa*yp + ca*zp;
+	    int outside = xpp*xpp + ypp*ypp > 1.0;
+	    int infront = zpp > 0.0;
+	    mdp->svis = outside || infront;
+	}
+}
+
+/* set evis according to whether moon is geometrically visible from earth */
+static void
+moonEVis (MoonData md[U_NMOONS])
+{
+	int i;
+
+	for (i = 1; i < U_NMOONS; i++) {
+	    MoonData *mdp = &md[i];
+	    int outside = mdp->x*mdp->x + mdp->y*mdp->y > 1.0;
+	    int infront = mdp->z > 0.0;
+	    mdp->evis = outside || infront;
+	}
+}
+
+/* For RCS Only -- Do Not Edit */
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: umoon.c,v $ $Date: 2004-06-15 16:54:12 $ $Revision: 1.1 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/utc_gst.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/utc_gst.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/utc_gst.c	(revision 2551)
@@ -1,23 +1,19 @@
-#include "P_.h"
 #include "astro.h"
 
-static double gmst0 P_((double mjd));
+static double gmst0 (double mj);
 
-/* given a modified julian date, mjd, and a universally coordinated time, utc,
+/* given a modified julian date, mj, and a universally coordinated time, utc,
  * return greenwich mean siderial time, *gst.
- * N.B. mjd must be at the beginning of the day.
+ * N.B. mj must be at the beginning of the day.
  */
 void
-utc_gst (mjd, utc, gst)
-double mjd;
-double utc;
-double *gst;
+utc_gst (double mj, double utc, double *gst)
 {
-	static double lastmjd = -18981;
+	static double lastmj = -18981;
 	static double t0;
 
-	if (mjd != lastmjd) {
-	    t0 = gmst0(mjd);
-	    lastmjd = mjd;
+	if (mj != lastmj) {
+	    t0 = gmst0(mj);
+	    lastmj = mj;
 	}
 	*gst = (1.0/SIDRATE)*utc + t0;
@@ -25,20 +21,17 @@
 }
 
-/* given a modified julian date, mjd, and a greenwich mean siderial time, gst,
+/* given a modified julian date, mj, and a greenwich mean siderial time, gst,
  * return universally coordinated time, *utc.
- * N.B. mjd must be at the beginning of the day.
+ * N.B. mj must be at the beginning of the day.
  */
 void
-gst_utc (mjd, gst, utc)
-double mjd;
-double gst;
-double *utc;
+gst_utc (double mj, double gst, double *utc)
 {
-	static double lastmjd = -10000;
+	static double lastmj = -10000;
 	static double t0;
 
-	if (mjd != lastmjd) {
-	    t0 = gmst0 (mjd);
-	    lastmjd = mjd;
+	if (mj != lastmj) {
+	    t0 = gmst0 (mj);
+	    lastmj = mj;
 	}
 	*utc = gst - t0;
@@ -50,10 +43,10 @@
  */
 static double
-gmst0 (mjd)
-double mjd;	/* date at 0h UT in julian days since MJD0 */
+gmst0 (
+double mj)	/* date at 0h UT in julian days since MJD0 */
 {
 	double T, x;
 
-	T = ((int)(mjd - 0.5) + 0.5 - J2000)/36525.0;
+	T = ((int)(mj - 0.5) + 0.5 - J2000)/36525.0;
 	x = 24110.54841 +
 		(8640184.812866 + (0.093104 - 6.2e-6 * T) * T) * T;
@@ -67,16 +60,16 @@
 /* original routine by elwood; has a secular drift of 0.08s/cty */
 static double
-tnaught (mjd)
-double mjd;	/* julian days since 1900 jan 0.5 */
+tnaught (mj)
+double mj;	/* julian days since 1900 jan 0.5 */
 {
-	double dmjd;
+	double dmj;
 	int m, y;
 	double d;
 	double t, t0;
 
-	mjd_cal (mjd, &m, &d, &y);
-	cal_mjd (1, 0., y, &dmjd);
-	t = dmjd/36525;
-	t0 = 6.57098e-2 * (mjd - dmjd) - 
+	mjd_cal (mj, &m, &d, &y);
+	cal_mjd (1, 0., y, &dmj);
+	t = dmj/36525;
+	t0 = 6.57098e-2 * (mj - dmj) - 
 	     (24 - (6.6460656 + (5.1262e-2 + (t * 2.581e-5))*t) -
 		   (2400 * (t - (((double)y - 1900)/100))));
@@ -90,9 +83,9 @@
   char *argv[];
 {
-	double mjd, gst;
-	while (scanf("%lf", &mjd) == 1) {
-		mjd -= MJD0;
-		gst = tnaught(mjd);
-		printf("%17.9f %10.7f %10.7f\n", mjd + MJD0, gst, gmst0(mjd));
+	double mj, gst;
+	while (scanf("%lf", &mj) == 1) {
+		mj -= MJD0;
+		gst = tnaught(mj);
+		printf("%17.9f %10.7f %10.7f\n", mj + MJD0, gst, gmst0(mj));
 	}
 }
@@ -100,3 +93,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: utc_gst.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: utc_gst.c,v $ $Date: 2004-06-15 16:52:41 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/vector.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/vector.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/vector.h	(revision 2551)
@@ -2,5 +2,5 @@
 #define __SATVECTOR_H
 
-/* $Id: vector.h,v 1.2 2001-10-22 12:08:28 cmv Exp $ */
+/* $Id: vector.h,v 1.3 2004-06-15 16:52:41 cmv Exp $ */
 
 #define dotp(A,B) ((A).x*(B).x+(A).y*(B).y+(A).z*(B).z)
@@ -16,4 +16,4 @@
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: vector.h,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: vector.h,v $ $Date: 2004-06-15 16:52:41 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/vsop87.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/vsop87.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/vsop87.c	(revision 2551)
@@ -35,5 +35,5 @@
 
 #include <math.h>
-#include "P_.h"
+
 #include "astro.h"
 #include "vsop87.h"
@@ -51,5 +51,5 @@
  *    Input :
  *
- *    mjd      modified julian date, counted from J1900.0
+ *    mj       modified julian date, counted from J1900.0
  *             time scale : dynamical time TDB.
  *
@@ -98,9 +98,5 @@
  ******************************************************************/
 int
-vsop87 (mjd, obj, prec, ret)
-double mjd;
-int obj;
-double prec;
-double *ret;
+vsop87 (double mj, int obj, double prec, double *ret)
 {
     static double (*vx_map[])[3] = {		/* data tables */
@@ -134,5 +130,5 @@
     /* time and its powers */
     t[0] = 1.0;
-    t[1] = (mjd - J2000)/VSOP_A1000;
+    t[1] = (mj - J2000)/VSOP_A1000;
     for (i = 2; i <= VSOP_MAXALPHA; ++i) t[i] = t[i-1] * t[1];
     t_abs[0] = 1.0;
@@ -211,3 +207,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: vsop87.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: vsop87.c,v $ $Date: 2004-06-15 16:52:41 $ $Revision: 1.4 $ $Name: not supported by cvs2svn $"};
Index: /trunk/SophyaExt/XephemAstroLib/vsop87.h
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/vsop87.h	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/vsop87.h	(revision 2551)
@@ -86,8 +86,8 @@
 extern int vn_neptune[][3];
 
-extern int vsop87 P_((double mjd, int obj, double prec, double *ret));
+extern int vsop87 (double mj, int obj, double prec, double *ret);
 
 
 /* For RCS Only -- Do Not Edit
- * @(#) $RCSfile: vsop87.h,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $
+ * @(#) $RCSfile: vsop87.h,v $ $Date: 2004-06-15 16:52:41 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $
  */
Index: /trunk/SophyaExt/XephemAstroLib/vsop87_data.c
===================================================================
--- /trunk/SophyaExt/XephemAstroLib/vsop87_data.c	(revision 2550)
+++ /trunk/SophyaExt/XephemAstroLib/vsop87_data.c	(revision 2551)
@@ -6986,3 +6986,3 @@
 
 /* For RCS Only -- Do Not Edit */
-static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: vsop87_data.c,v $ $Date: 2001-10-22 12:08:28 $ $Revision: 1.2 $ $Name: not supported by cvs2svn $"};
+static char *rcsid[2] = {(char *)rcsid, "@(#) $RCSfile: vsop87_data.c,v $ $Date: 2004-06-15 16:52:41 $ $Revision: 1.3 $ $Name: not supported by cvs2svn $"};
