downey@cs.umn.edu@dimed1.UUCP (08/31/90)
Posting-number: Volume 14, Issue 81 Submitted-by: downey@cs.umn.edu@dimed1.UUCP Archive-name: ephem-4.21/part06 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 6 (of 6)." # Contents: main.c sel_fld.c # Wrapped by allbery@uunet on Thu Aug 30 20:46:38 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'main.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'main.c'\" else echo shar: Extracting \"'main.c'\" \(24745 characters\) sed "s/^X//" >'main.c' <<'END_OF_FILE' X/* main "ephem" program. X * ------------------------------------------------------------------- X * Copyright (c) 1990 by Elwood Charles Downey X * X * Permission is granted to make and distribute copies of this program X * free of charge, provided the copyright notice and this permission X * notice are preserved on all copies. All other rights reserved. X * ------------------------------------------------------------------- X * set options. X * init screen and circumstances. X * enter infinite loop updating screen and allowing operator input. X */ X X#include <stdio.h> X#include <signal.h> X#include <setjmp.h> X#include <math.h> X#ifdef VMS X#include <stdlib.h> X#endif X#include "astro.h" X#include "circum.h" X#include "screen.h" X Xextern char *strncpy(); Xextern char *getenv(); X X/* shorthands for fields of a Now structure, now. X * first undo the ones for a Now pointer from circum.h. X */ X#undef mjd X#undef lat X#undef lng X#undef tz X#undef temp X#undef pressure X#undef height X#undef epoch X#undef tznm X X#define mjd now.n_mjd X#define lat now.n_lat X#define lng now.n_lng X#define tz now.n_tz X#define temp now.n_temp X#define pressure now.n_pressure X#define height now.n_height X#define epoch now.n_epoch X#define tznm now.n_tznm X Xstatic jmp_buf fpe_err_jmp; /* used to recover from SIGFPE */ Xstatic char *cfgfile; /* !0 if -c used */ Xstatic char cfgdef[] = "ephem.cfg"; /* default configuration file name */ Xstatic Now now; /* where when and how, right now */ Xstatic double tminc; /* hrs to inc time by each loop; RTC means use clock */ Xstatic int nstep; /* steps to go before stopping */ Xstatic int spause; /* secs to pause between steps */ Xstatic int optwi; /* set when want to display dawn/dusk/len-of-night */ Xstatic int oppl; /* mask of (1<<planet) bits; set when want to show it */ X Xmain (ac, av) Xint ac; Xchar *av[]; X{ X void bye(); X void on_fpe(); X static char freerun[] = X "Running... press any key to stop to make changes."; X static char prmpt[] = X"Move to another field, RETURN to change this field, ? for help, or q to run"; X static char hlp[] = X "arrow keys move to field; any key stops running; ^d exits; ^l redraws"; X int curr = R_NSTEP, curc = C_NSTEPV; /* must start somewhere */ X int sflag = 0; /* not silent, by default */ X int one = 1; /* use a variable so optimizer doesn't get disabled */ X int srchdone = 0; /* true when search funcs say so */ X int newcir = 2; /* set when circumstances change - means don't tminc */ X X while ((--ac > 0) && (**++av == '-')) { X char *s; X for (s = *av+1; *s != '\0'; s++) X switch (*s) { X case 's': /* no credits "silent" (don't publish this) */ X sflag++; X break; X case 'c': /* set name of config file to use */ X if (--ac <= 0) usage("-c but no config file"); X cfgfile = *++av; X break; X case 'd': /* set alternate database file name */ X if (--ac <= 0) usage("-d but no database file"); X obj_setdbfilename (*++av); X break; X default: X usage("Bad - option"); X } X } X X if (!sflag) X credits(); X X /* fresh screen. X * crack config file, THEN args so args may override. X */ X c_erase(); X read_cfgfile (); X read_fieldargs (ac, av); X X /* set up to clean up screen and tty if interrupted. X * also set up to stop if get floating error. X */ X (void) signal (SIGINT, bye); X (void) signal (SIGFPE, on_fpe); X X /* update screen forever (until QUIT) */ X while (one) { X X /* if get a floating error, longjmp() here and stop looping */ X if (setjmp (fpe_err_jmp)) X nstep = 0; X else { X nstep -= 1; X X /* recalculate everything and update all the fields */ X redraw_screen (newcir); X mm_newcir (0); X X /* let searching functions change tminc and check for done */ X srchdone = srch_eval (mjd, &tminc) < 0; X print_tminc(0); /* to show possibly new search increment */ X X /* update plot and listing files, now that all fields are up X * to date and search function has been evaluated. X */ X plot(); X listing(); X X /* handle spause if we are really looping */ X if (nstep > 0) X slp_sync(); X } X X /* stop loop to allow op to change parameters: X * if a search evaluation converges (or errors out), X * or if steps are done, X * or if op hits any key. X */ X newcir = 0; X if (srchdone || nstep <= 0 || (chk_char()==0 && read_char()!=0)) { X int fld; X X /* update screen with the current stuff if stopped during X * unattended plotting or listing since last redraw_screen() X * didn't. X */ X if ((plot_ison() || listing_ison()) && nstep > 0) X redraw_screen (1); X X /* return nstep to default of 1 */ X if (nstep <= 0) { X nstep = 1; X print_nstep (0); X } X X /* change fields until END. X * update all time fields if any are changed X * and print NEW CIRCUMSTANCES if any have changed. X * QUIT causes bye() to be called and we never return. X */ X while(fld = sel_fld(curr,curc,alt_menumask()|F_CHG,prmpt,hlp)) { X if (chg_fld ((char *)0, fld)) { X mm_now (&now, 1); X mm_newcir(1); X newcir = 1; X } X curr = unpackr (fld); X curc = unpackc (fld); X } X if (nstep > 1) X f_prompt (freerun); X } X X /* increment time only if op didn't change cirumstances */ X if (!newcir) X inc_mjd (&now, tminc); X } X X return (0); X} X X/* read in ephem's configuration file, if any. X * if errors in file, call usage() (which exits). X * if use -d, require it; else try $EPHEMCFG and ephem.cfg but don't X * complain if can't find these since, after all, one is not required. X * skip blank lines and lines that begin with '#', '*', ' ' or '\t'. X */ Xstatic Xread_cfgfile() X{ X char buf[128]; X FILE *fp; X char *fn; X X /* open the config file. X * only REQUIRED if used -d option. X * if succcessful, fn points to file name. X */ X if (cfgfile) { X fn = cfgfile; X fp = fopen (fn, "r"); X if (!fp) { X (void) sprintf (buf, "Can not open %s", fn); X usage (buf); /* does not return */ X } X } else { X fn = getenv ("EPHEMCFG"); X if (!fn) X fn = cfgdef; X } X fp = fopen (fn, "r"); X if (!fp) X return; /* oh well; after all, it's not required */ X X while (fgets (buf, sizeof(buf), fp)) { X switch (buf[0]) { X case '#': case '*': case ' ': case '\t': case '\n': X continue; X } X buf[strlen(buf)-1] = '\0'; /* discard trailing \n */ X if (crack_fieldset (buf) < 0) { X char why[NC]; X (void) sprintf (why, "Bad field spec in %s: %s\n", fn, buf); X usage (why); X } X } X (void) fclose (fp); X} X X X/* draw all the stuff on the screen, using the current menu. X * if how_much == 0 then just update fields that need it; X * if how_much == 1 then redraw all fields; X * if how_much == 2 then erase the screen and redraw EVERYTHING. X */ Xredraw_screen (how_much) Xint how_much; X{ X if (how_much == 2) X c_erase(); X X /* print the single-step message if this is the last loop */ X if (nstep < 1) X print_updating(); X X if (how_much == 2) { X mm_borders(); X mm_labels(); X srch_prstate(1); X plot_prstate(1); X listing_prstate(1); X alt_labels(); X } X X /* if just updating changed fields while plotting or listing X * unattended then suppress most screen updates except X * always show nstep to show plot loops to go and X * always show tminc to show search convergence progress. X */ X print_nstep(how_much); X print_tminc(how_much); X print_spause(how_much); X if (how_much == 0 && (plot_ison() || listing_ison()) && nstep > 0) X f_off(); X X /* print all the time-related fields */ X mm_now (&now, how_much); X X if (optwi) X mm_twilight (&now, how_much); X X /* print solar system body info */ X print_bodies (how_much); X X f_on(); X} X X/* clean up and exit. X */ Xvoid Xbye() X{ X c_erase(); X byetty(); X exit (0); X} X X/* this gets called when a floating point error occurs. X * we force a jump back into main() with looping terminated. X */ Xstatic Xvoid Xon_fpe() X{ X (void) signal (SIGFPE, on_fpe); X f_msg ("Floating point error has occurred - computations aborted."); X longjmp (fpe_err_jmp, 1); X} X Xusage(why) Xchar *why; X{ X /* don't advertise -s (silent) option */ X c_erase(); X f_string (1, 1, why); X f_string (2, 1, X "usage: [-c <configfile>] [-d <database>] [field=value ...]\r\n"); X byetty(); X exit (1); X} X X/* process the field specs from the command line. X * if trouble call usage() (which exits). X */ Xstatic Xread_fieldargs (ac, av) Xint ac; /* number of such specs */ Xchar *av[]; /* array of strings in form <field_name value> */ X{ X while (--ac >= 0) { X char *fs = *av++; X if (crack_fieldset (fs) < 0) { X char why[NC]; X (void) sprintf (why, "Bad command line spec: %.*s", X sizeof(why)-26, fs); X usage (why); X } X } X} X X/* process a field spec in buf, either from config file or argv. X * return 0 if recognized ok, else -1. X */ Xstatic Xcrack_fieldset (buf) Xchar *buf; X{ X if (strncmp ("LAT", buf, 3) == 0) X (void) chg_fld (buf+4, rcfpack (R_LAT,C_LATV,0)); X else if (strncmp ("LONG", buf, 4) == 0) X (void) chg_fld (buf+5, rcfpack (R_LONG,C_LONGV,0)); X else if (strncmp ("UT", buf, 2) == 0) X (void) chg_fld (buf+3, rcfpack (R_UT,C_UTV,0)); X else if (strncmp ("UD", buf, 2) == 0) X (void) chg_fld (buf+3, rcfpack (R_UD,C_UD,0)); X else if (strncmp ("TZONE", buf, 5) == 0) X (void) chg_fld (buf+6, rcfpack (R_TZONE,C_TZONEV,0)); X else if (strncmp ("TZNAME", buf, 6) == 0) X (void) chg_fld (buf+7, rcfpack (R_TZN,C_TZN,0)); X else if (strncmp ("HEIGHT", buf, 6) == 0) X (void) chg_fld (buf+7, rcfpack (R_HEIGHT,C_HEIGHTV,0)); X else if (strncmp ("NSTEP", buf, 5) == 0) X (void) chg_fld (buf+6, rcfpack (R_NSTEP,C_NSTEPV,0)); X else if (strncmp ("PAUSE", buf, 5) == 0) X (void) chg_fld (buf+6, rcfpack (R_PAUSE,C_PAUSEV,0)); X else if (strncmp ("STPSZ", buf, 5) == 0) X (void) chg_fld (buf+6, rcfpack (R_STPSZ,C_STPSZV,0)); X else if (strncmp ("TEMP", buf, 4) == 0) X (void) chg_fld (buf+5, rcfpack (R_TEMP,C_TEMPV,0)); X else if (strncmp ("PRES", buf, 4) == 0) X (void) chg_fld (buf+5, rcfpack (R_PRES,C_PRESV,0)); X else if (strncmp ("EPOCH", buf, 5) == 0) X (void) chg_fld (buf+6, rcfpack (R_EPOCH,C_EPOCHV,0)); X else if (strncmp ("JD", buf, 2) == 0) X (void) chg_fld (buf+3, rcfpack (R_JD,C_JDV,0)); X else if (strncmp ("OBJX", buf, 4) == 0) X obj_filelookup (OBJX, buf+5); X else if (strncmp ("OBJY", buf, 4) == 0) X obj_filelookup (OBJY, buf+5); X else if (strncmp ("PROPTS", buf, 6) == 0) { X char *bp = buf+7; X if (buf[6] != '+') X optwi = oppl = 0; X while (*bp) X switch (*bp++) { X case 'T': optwi = 1; break; X case 'S': oppl |= (1<<SUN); break; X case 'M': oppl |= (1<<MOON); break; X case 'e': oppl |= (1<<MERCURY); break; X case 'v': oppl |= (1<<VENUS); break; X case 'm': oppl |= (1<<MARS); break; X case 'j': oppl |= (1<<JUPITER); break; X case 's': oppl |= (1<<SATURN); break; X case 'u': oppl |= (1<<URANUS); break; X case 'n': oppl |= (1<<NEPTUNE); break; X case 'p': oppl |= (1<<PLUTO); break; X case 'x': oppl |= (1<<OBJX); obj_on(OBJX); break; X case 'y': oppl |= (1<<OBJY); obj_on(OBJY); break; X } X } else if (strncmp ("MENU", buf, 4) == 0) { X if (strncmp (buf+5, "DATA", 4) == 0) X altmenu_init (F_MNU1); X else if (strncmp (buf+5, "RISET", 5) == 0) X altmenu_init (F_MNU2); X else if (strncmp (buf+5, "SEP", 3) == 0) X altmenu_init (F_MNU3); X } else X return (-1); X return (0); X} X X/* change the field at rcpk according to the optional string input at bp. X * if bp is != 0 use it, else issue read_line() and use buffer. X * then sscanf the buffer and update the corresponding (global) variable(s) X * or do whatever a pick at that field should do. X * return 1 if we change a field that invalidates any of the times or X * to update all related fields. X */ Xstatic Xchg_fld (bp, rcpk) Xchar *bp; Xint rcpk; X{ X char buf[NC]; X int deghrs = 0, mins = 0, secs = 0; X int new = 0; X X /* switch on just the row/col portion */ X switch (unpackrc(rcpk)) { X case rcfpack (R_ALTM, C_ALTM, 0): X if (altmenu_setup() == 0) { X print_updating(); X alt_nolabels(); X clrall_bodies(); X alt_labels(); X print_bodies(1); X } X break; X case rcfpack (R_JD, C_JDV, 0): X if (!bp) { X static char p[] = "Julian Date (or n for Now): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X if (bp[0] == 'n' || bp[0] == 'N') X time_fromsys (&now); X else X mjd = atof(bp) - 2415020L; X set_t0 (&now); X new = 1; X break; X case rcfpack (R_UD, C_UD, 0): X if (!bp) { X static char p[] = "utc date (m/d/y, or year.d, or n for Now): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X if (bp[0] == 'n' || bp[0] == 'N') X time_fromsys (&now); X else { X if (decimal_year(bp)) { X double y = atof (bp); X year_mjd (y, &mjd); X } else { X double day, newmjd0; X int month, year; X mjd_cal (mjd, &month, &day, &year); /* init with now */ X f_sscandate (bp, &month, &day, &year); X cal_mjd (month, day, year, &newmjd0); X /* if don't give a fractional part to days X * then retain current hours. X */ X if ((long)day == day) X mjd = newmjd0 + mjd_hr(mjd)/24.0; X else X mjd = newmjd0; X } X } X set_t0 (&now); X new = 1; X break; X case rcfpack (R_UT, C_UTV, 0): X if (!bp) { X static char p[] = "utc time (h:m:s, or n for Now): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X if (bp[0] == 'n' || bp[0] == 'N') X time_fromsys (&now); X else { X double newutc = (mjd-mjd_day(mjd)) * 24.0; X f_dec_sexsign (newutc, °hrs, &mins, &secs); X f_sscansex (bp, °hrs, &mins, &secs); X sex_dec (deghrs, mins, secs, &newutc); X mjd = mjd_day(mjd) + newutc/24.0; X } X set_t0 (&now); X new = 1; X break; X case rcfpack (R_LD, C_LD, 0): X if (!bp) { X static char p[] = "local date (m/d/y, or year.d, n for Now): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X if (bp[0] == 'n' || bp[0] == 'N') X time_fromsys (&now); X else { X if (decimal_year(bp)) { X double y = atof (bp); X year_mjd (y, &mjd); X mjd += tz/24.0; X } else { X double day, newlmjd0; X int month, year; X mjd_cal (mjd-tz/24.0, &month, &day, &year); /* now */ X f_sscandate (bp, &month, &day, &year); X cal_mjd (month, day, year, &newlmjd0); X /* if don't give a fractional part to days X * then retain current hours. X */ X if ((long)day == day) X mjd = newlmjd0 + mjd_hr(mjd-tz/24.0)/24.0; X else X mjd = newlmjd0; X mjd += tz/24.0; X } X } X set_t0 (&now); X new = 1; X break; X case rcfpack (R_LT, C_LT, 0): X if (!bp) { X static char p[] = "local time (h:m:s, or n for Now): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X if (bp[0] == 'n' || bp[0] == 'N') X time_fromsys (&now); X else { X double newlt = (mjd-mjd_day(mjd)) * 24.0 - tz; X range (&newlt, 24.0); X f_dec_sexsign (newlt, °hrs, &mins, &secs); X f_sscansex (bp, °hrs, &mins, &secs); X sex_dec (deghrs, mins, secs, &newlt); X mjd = mjd_day(mjd-tz/24.0) + (newlt + tz)/24.0; X } X set_t0 (&now); X new = 1; X break; X case rcfpack (R_LST, C_LSTV, 0): X if (!bp) { X static char p[] = "local sidereal time (h:m:s, or n for Now): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X if (bp[0] == 'n' || bp[0] == 'N') X time_fromsys (&now); X else { X double lst, utc; X now_lst (&now, &lst); X f_dec_sexsign (lst, °hrs, &mins, &secs); X f_sscansex (bp, °hrs, &mins, &secs); X sex_dec (deghrs, mins, secs, &lst); X lst -= radhr(lng); /* convert to gst */ X range (&lst, 24.0); X gst_utc (mjd_day(mjd), lst, &utc); X mjd = mjd_day(mjd) + utc/24.0; X } X set_t0 (&now); X new = 1; X break; X case rcfpack (R_TZN, C_TZN, 0): X if (!bp) { X static char p[] = "timezone abbreviation (3 char max): "; X f_prompt (p); X if (read_line (buf, 3) <= 0) X break; X bp = buf; X } X (void) strncpy (tznm, bp, sizeof(tznm)-1); X new = 1; X break; X case rcfpack (R_TZONE, C_TZONEV, 0): X if (!bp) { X static char p[] = "hours behind utc: "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X f_dec_sexsign (tz, °hrs, &mins, &secs); X f_sscansex (bp, °hrs, &mins, &secs); X sex_dec (deghrs, mins, secs, &tz); X new = 1; X break; X case rcfpack (R_LONG, C_LONGV, 0): X if (!bp) { X static char p[] = "longitude (+ west) (d:m:s): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X f_dec_sexsign (-raddeg(lng), °hrs, &mins, &secs); X f_sscansex (bp, °hrs, &mins, &secs); X sex_dec (deghrs, mins, secs, &lng); X lng = degrad (-lng); /* want - radians west */ X new = 1; X break; X case rcfpack (R_LAT, C_LATV, 0): X if (!bp) { X static char p[] = "latitude (+ north) (d:m:s): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X f_dec_sexsign (raddeg(lat), °hrs, &mins, &secs); X f_sscansex (bp, °hrs, &mins, &secs); X sex_dec (deghrs, mins, secs, &lat); X lat = degrad (lat); X new = 1; X break; X case rcfpack (R_HEIGHT, C_HEIGHTV, 0): X if (!bp) { X static char p[] = "height above sea level (ft): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X (void) sscanf (bp, "%lf", &height); X height /= 2.093e7; /* convert ft to earth radii above sea level */ X new = 1; X break; X case rcfpack (R_NSTEP, C_NSTEPV, 0): X if (!bp) { X static char p[] = "number of steps to run: "; X f_prompt (p); X if (read_line (buf, 8) <= 0) X break; X bp = buf; X } X (void) sscanf (bp, "%d", &nstep); X print_nstep (0); X break; X case rcfpack (R_PAUSE, C_PAUSEV, 0): X if (!bp) { X static char p[] = "seconds to pause between steps: "; X f_prompt (p); X if (read_line (buf, 8) <= 0) X break; X bp = buf; X } X (void) sscanf (bp, "%d", &spause); X print_spause (0); X break; X case rcfpack (R_TEMP, C_TEMPV, 0): X if (!bp) { X static char p[] = "temperature (deg.F): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X (void) sscanf (bp, "%lf", &temp); X temp = 5./9.*(temp - 32.0); /* want degs C */ X new = 1; X break; X case rcfpack (R_PRES, C_PRESV, 0): X if (!bp) { X static char p[] = X "atmos pressure (in. Hg; 0 for no refraction correction): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X (void) sscanf (bp, "%lf", &pressure); X pressure *= 33.86; /* want mBar */ X new = 1; X break; X case rcfpack (R_EPOCH, C_EPOCHV, 0): X if (!bp) { X static char p[] = "epoch (year, or e for Equinox of Date): "; X f_prompt (p); X if (read_line (buf, PW-strlen(p)) <= 0) X break; X bp = buf; X } X if (bp[0] == 'e' || bp[0] == 'E') X epoch = EOD; X else { X double e; X e = atof(bp); X year_mjd (e, &epoch); X } X new = 1; X break; X case rcfpack (R_STPSZ, C_STPSZV, 0): X if (!bp) { X static char p[] = X "step size increment (h:m:s, or <x>d for x days, or r for RTC): "; X f_prompt (p); X if (read_line (buf, PW-sizeof(p)) <= 0) X break; X bp = buf; X } X if (bp[0] == 'r' || bp[0] == 'R') X tminc = RTC; X else { X int last = strlen (bp) - 1; X if (bp[last] == 'd') { X /* ends in d so treat as a number of days */ X double x; X (void) sscanf (bp, "%lf", &x); X tminc = x * 24.0; X } else { X if (tminc == RTC) X deghrs = mins = secs = 0; X else X f_dec_sexsign (tminc, °hrs, &mins, &secs); X f_sscansex (bp, °hrs, &mins, &secs); X sex_dec (deghrs, mins, secs, &tminc); X } X } X print_tminc(0); X set_t0 (&now); X break; X case rcfpack (R_PLOT, C_PLOT, 0): X plot_setup(); X if (plot_ison()) X new = 1; X break; X case rcfpack (R_LISTING, C_LISTING, 0): X listing_setup(); X if (listing_ison()) X new = 1; X break; X case rcfpack (R_WATCH, C_WATCH, 0): X watch (&now, tminc, oppl); X /* set new reference time to what watch left it. X * no need to set new since watch just did a redraw. X */ X set_t0 (&now); X break; X case rcfpack (R_DAWN, C_DAWN, 0): X case rcfpack (R_DUSK, C_DUSK, 0): X case rcfpack (R_LON, C_LON, 0): X if (optwi ^= 1) { X print_updating(); X mm_twilight (&now, 1); X } else { X f_blanks (R_DAWN, C_DAWNV, 5); X f_blanks (R_DUSK, C_DUSKV, 5); X f_blanks (R_LON, C_LONV, 5); X } X break; X case rcfpack (R_SRCH, C_SRCH, 0): X srch_setup(); X if (srch_ison()) X new = 1; X break; X case rcfpack (R_SUN, C_OBJ, 0): X if ((oppl ^= (1<<SUN)) & (1<<SUN)) { X print_updating(); X alt_body (SUN, 1, &now); X } else X alt_nobody (SUN); X break; X case rcfpack (R_MOON, C_OBJ, 0): X if ((oppl ^= (1<<MOON)) & (1<<MOON)) { X print_updating(); X alt_body (MOON, 1, &now); X } else X alt_nobody (MOON); X break; X case rcfpack (R_MERCURY, C_OBJ, 0): X if ((oppl ^= (1<<MERCURY)) & (1<<MERCURY)) { X print_updating(); X alt_body (MERCURY, 1, &now); X } else X alt_nobody (MERCURY); X break; X case rcfpack (R_VENUS, C_OBJ, 0): X if ((oppl ^= (1<<VENUS)) & (1<<VENUS)) { X print_updating(); X alt_body (VENUS, 1, &now); X } else X alt_nobody (VENUS); X break; X case rcfpack (R_MARS, C_OBJ, 0): X if ((oppl ^= (1<<MARS)) & (1<<MARS)) { X print_updating(); X alt_body (MARS, 1, &now); X } else X alt_nobody (MARS); X break; X case rcfpack (R_JUPITER, C_OBJ, 0): X if ((oppl ^= (1<<JUPITER)) & (1<<JUPITER)) { X print_updating(); X alt_body (JUPITER, 1, &now); X } else X alt_nobody (JUPITER); X break; X case rcfpack (R_SATURN, C_OBJ, 0): X if ((oppl ^= (1<<SATURN)) & (1<<SATURN)) { X print_updating(); X alt_body (SATURN, 1, &now); X } else X alt_nobody (SATURN); X break; X case rcfpack (R_URANUS, C_OBJ, 0): X if ((oppl ^= (1<<URANUS)) & (1<<URANUS)) { X print_updating(); X alt_body (URANUS, 1, &now); X } else X alt_nobody (URANUS); X break; X case rcfpack (R_NEPTUNE, C_OBJ, 0): X if ((oppl ^= (1<<NEPTUNE)) & (1<<NEPTUNE)) { X print_updating(); X alt_body (NEPTUNE, 1, &now); X } else X alt_nobody (NEPTUNE); X break; X case rcfpack (R_PLUTO, C_OBJ, 0): X if ((oppl ^= (1<<PLUTO)) & (1<<PLUTO)) { X print_updating(); X alt_body (PLUTO, 1, &now); X } else X alt_nobody (PLUTO); X break; X case rcfpack (R_OBJX, C_OBJ, 0): X /* this might change which columns are used so erase all when X * returns and redraw if still on. X */ X obj_setup (OBJX); X alt_nobody (OBJX); X if (obj_ison (OBJX)) { X oppl |= 1 << OBJX; X print_updating(); X alt_body (OBJX, 1, &now); X } else X oppl &= ~(1 << OBJX); /* already erased; just clear flag */ X break; X case rcfpack (R_OBJY, C_OBJ, 0): X /* this might change which columns are used so erase all when X * returns and redraw if still on. X */ X obj_setup (OBJY); X alt_nobody (OBJY); X if (obj_ison (OBJY)) { X oppl |= 1 << OBJY; X print_updating(); X alt_body (OBJY, 1, &now); X } else X oppl &= ~(1 << OBJY); /* already erased; just clear flag */ X break; X } X X return (new); X} X Xstatic Xprint_tminc(force) Xint force; X{ X static double last = -123.456; /* anything unlikely */ X X if (force || tminc != last) { X if (tminc == RTC) X f_string (R_STPSZ, C_STPSZV, " RT CLOCK"); X else if (fabs(tminc) >= 24.0) X f_double (R_STPSZ, C_STPSZV, "%6.4g dy", tminc/24.0); X else X f_signtime (R_STPSZ, C_STPSZV, tminc); X last = tminc; X } X} X Xstatic Xprint_bodies (force) Xint force; X{ X int p; X X for (p = nxtbody(-1); p != -1; p = nxtbody(p)) X if (oppl & (1<<p)) X alt_body (p, force, &now); X} X Xstatic Xclrall_bodies () X{ X int p; X X for (p = nxtbody(-1); p != -1; p = nxtbody(p)) X if (oppl & (1<<p)) X alt_nobody (p); X} X Xprint_updating() X{ X f_prompt ("Updating..."); X} X Xstatic Xprint_nstep(force) Xint force; X{ X static int last; X X if (force || nstep != last) { X char buf[16]; X (void) sprintf (buf, "%8d", nstep); X f_string (R_NSTEP, C_NSTEPV, buf); X last = nstep; X } X} X Xstatic Xprint_spause(force) Xint force; X{ X static int last; X X if (force || spause != last) { X char buf[16]; X (void) sprintf (buf, "%8d", spause); X f_string (R_PAUSE, C_PAUSEV, buf); X last = spause; X } X} X X/* if not plotting or searching then sleep spause seconds. X * if time is being based on the real-time clock, sync on the next X * integral multiple of spause seconds after the minute. X * check for keyboard action once each second to let it break out early. X */ Xslp_sync() X{ X if (spause > 0 && !plot_ison() && !srch_ison()) { X extern long time(); X int n= (tminc == RTC) ? spause - (time((long *)0)%spause) : spause; X while (--n >= 0) X if (chk_char() == 0) X break; X else X (void) sleep (1); X } X} END_OF_FILE if test 24745 -ne `wc -c <'main.c'`; then echo shar: \"'main.c'\" unpacked with wrong size! fi # end of 'main.c' fi if test -f 'sel_fld.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sel_fld.c'\" else echo shar: Extracting \"'sel_fld.c'\" \(24029 characters\) sed "s/^X//" >'sel_fld.c' <<'END_OF_FILE' X#include <stdio.h> X#include "screen.h" X X/* define BANG if and only if your system supports the system() function. X */ X#define BANG X X/* table of the fields, with flags indicating which menu(s) they are on and X * whether pickable for changing or plotting. X * N.B. type must be long enough to hold 16 bits. X */ Xstatic int fields[] = { X rcfpack (R_ALTM, C_ALTM, F_MMNU|F_CHG), X rcfpack (R_DAWN, C_DAWN, F_MMNU|F_CHG), X rcfpack (R_DAWN, C_DAWNV, F_MMNU|F_PLT), X rcfpack (R_DUSK, C_DUSK, F_MMNU|F_CHG), X rcfpack (R_DUSK, C_DUSKV, F_MMNU|F_PLT), X rcfpack (R_EPOCH, C_EPOCHV, F_MMNU|F_CHG), X rcfpack (R_HEIGHT, C_HEIGHTV, F_MMNU|F_CHG|F_PLT), X rcfpack (R_JD, C_JDV, F_MMNU|F_CHG|F_PLT), X rcfpack (R_JUPITER, C_ALT, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_AZ, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_DEC, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_MAG, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_MARS, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_MOON, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_JUPITER, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_RA, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_JUPITER, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_JUPITER, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_JUPITER, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_JUPITER, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_JUPITER, C_SUN, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_JUPITER, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_JUPITER, C_TUP, F_MNU2|F_PLT), X rcfpack (R_JUPITER, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_JUPITER, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_LAT, C_LATV, F_MMNU|F_CHG|F_PLT), X rcfpack (R_LD, C_LD, F_MMNU|F_PLT|F_CHG), X rcfpack (R_LISTING, C_LISTING, F_MMNU|F_CHG), X rcfpack (R_LON, C_LON, F_MMNU|F_CHG), X rcfpack (R_LON, C_LONV, F_MMNU|F_PLT), X rcfpack (R_LONG, C_LONGV, F_MMNU|F_CHG|F_PLT), X rcfpack (R_LST, C_LSTV, F_MMNU|F_CHG|F_PLT), X rcfpack (R_LT, C_LT, F_MMNU|F_CHG|F_PLT), X rcfpack (R_MARS, C_ALT, F_MNU1|F_PLT), X rcfpack (R_MARS, C_AZ, F_MNU1|F_PLT), X rcfpack (R_MARS, C_DEC, F_MNU1|F_PLT), X rcfpack (R_MARS, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_MARS, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_MARS, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_MARS, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_MARS, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_MARS, C_MAG, F_MNU1|F_PLT), X rcfpack (R_MARS, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_MARS, C_MOON, F_MNU3|F_PLT), X rcfpack (R_MARS, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_MARS, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_MARS, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_MARS, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_MARS, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_MARS, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_MARS, C_RA, F_MNU1|F_PLT), X rcfpack (R_MARS, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_MARS, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_MARS, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_MARS, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_MARS, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_MARS, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_MARS, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_MARS, C_SUN, F_MNU3|F_PLT), X rcfpack (R_MARS, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_MARS, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_MARS, C_TUP, F_MNU2|F_PLT), X rcfpack (R_MARS, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_MARS, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_ALT, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_AZ, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_DEC, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_MAG, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_MARS, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_MOON, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_MERCURY, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_RA, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_MERCURY, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_MERCURY, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_MERCURY, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_MERCURY, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_MERCURY, C_SUN, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_MERCURY, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_MERCURY, C_TUP, F_MNU2|F_PLT), X rcfpack (R_MERCURY, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_MERCURY, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_MOON, C_ALT, F_MNU1|F_PLT), X rcfpack (R_MOON, C_AZ, F_MNU1|F_PLT), X rcfpack (R_MOON, C_DEC, F_MNU1|F_PLT), X rcfpack (R_MOON, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_MOON, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_MOON, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_MOON, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_MOON, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_MOON, C_MAG, F_MNU1|F_PLT), X rcfpack (R_MOON, C_MARS, F_MNU3|F_PLT), X rcfpack (R_MOON, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_MOON, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_MOON, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_MOON, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_MOON, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_MOON, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_MOON, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_MOON, C_RA, F_MNU1|F_PLT), X rcfpack (R_MOON, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_MOON, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_MOON, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_MOON, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_MOON, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_MOON, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_MOON, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_MOON, C_SUN, F_MNU3|F_PLT), X rcfpack (R_MOON, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_MOON, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_MOON, C_TUP, F_MNU2|F_PLT), X rcfpack (R_MOON, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_MOON, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_ALT, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_AZ, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_DEC, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_MAG, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_MARS, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_MOON, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_NEPTUNE, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_RA, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_NEPTUNE, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_NEPTUNE, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_NEPTUNE, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_NEPTUNE, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_NEPTUNE, C_SUN, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_NEPTUNE, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_NEPTUNE, C_TUP, F_MNU2|F_PLT), X rcfpack (R_NEPTUNE, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_NEPTUNE, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_NSTEP, C_NSTEPV, F_MMNU|F_CHG), X rcfpack (R_OBJX, C_ALT, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_AZ, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_DEC, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_MAG, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_MARS, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_MOON, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_OBJX, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_RA, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_OBJX, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_OBJX, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_OBJX, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_OBJX, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_OBJX, C_SUN, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_OBJX, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_OBJX, C_TUP, F_MNU2|F_PLT), X rcfpack (R_OBJX, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_OBJX, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_ALT, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_AZ, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_DEC, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_MAG, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_MARS, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_MOON, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_OBJY, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_RA, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_OBJY, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_OBJY, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_OBJY, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_OBJY, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_OBJY, C_SUN, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_OBJY, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_OBJY, C_TUP, F_MNU2|F_PLT), X rcfpack (R_OBJY, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_OBJY, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_PAUSE, C_PAUSEV, F_MMNU|F_CHG), X rcfpack (R_PLOT, C_PLOT, F_MMNU|F_CHG), X rcfpack (R_PLUTO, C_ALT, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_AZ, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_DEC, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_MAG, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_MARS, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_MOON, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_PLUTO, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_RA, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_PLUTO, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_PLUTO, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_PLUTO, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_PLUTO, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_PLUTO, C_SUN, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_PLUTO, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_PLUTO, C_TUP, F_MNU2|F_PLT), X rcfpack (R_PLUTO, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_PLUTO, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_PRES, C_PRESV, F_MMNU|F_CHG|F_PLT), X rcfpack (R_SATURN, C_ALT, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_AZ, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_DEC, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_MAG, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_MARS, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_MOON, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_SATURN, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_RA, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_SATURN, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_SATURN, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_SATURN, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_SATURN, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_SATURN, C_SUN, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_SATURN, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_SATURN, C_TUP, F_MNU2|F_PLT), X rcfpack (R_SATURN, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_SATURN, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_SRCH, C_SRCH, F_MMNU|F_CHG|F_PLT), X rcfpack (R_STPSZ, C_STPSZV, F_MMNU|F_CHG), X rcfpack (R_SUN, C_ALT, F_MNU1|F_PLT), X rcfpack (R_SUN, C_AZ, F_MNU1|F_PLT), X rcfpack (R_SUN, C_DEC, F_MNU1|F_PLT), X rcfpack (R_SUN, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_SUN, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_SUN, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_SUN, C_MAG, F_MNU1|F_PLT), X rcfpack (R_SUN, C_MARS, F_MNU3|F_PLT), X rcfpack (R_SUN, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_SUN, C_MOON, F_MNU3|F_PLT), X rcfpack (R_SUN, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_SUN, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_SUN, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_SUN, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_SUN, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_SUN, C_RA, F_MNU1|F_PLT), X rcfpack (R_SUN, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_SUN, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_SUN, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_SUN, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_SUN, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_SUN, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_SUN, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_SUN, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_SUN, C_TUP, F_MNU2|F_PLT), X rcfpack (R_SUN, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_SUN, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_TEMP, C_TEMPV, F_MMNU|F_CHG|F_PLT), X rcfpack (R_TZN, C_TZN, F_MMNU|F_CHG), X rcfpack (R_TZONE, C_TZONEV, F_MMNU|F_CHG), X rcfpack (R_UD, C_UD, F_MMNU|F_PLT|F_CHG), X rcfpack (R_URANUS, C_ALT, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_AZ, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_DEC, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_MAG, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_MARS, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_MOON, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_URANUS, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_RA, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_URANUS, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_URANUS, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_URANUS, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_URANUS, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_URANUS, C_SUN, F_MNU3|F_PLT), X rcfpack (R_URANUS, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_URANUS, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_URANUS, C_TUP, F_MNU2|F_PLT), X rcfpack (R_URANUS, C_VENUS, F_MNU3|F_PLT), X rcfpack (R_UT, C_UTV, F_MMNU|F_PLT|F_CHG), X rcfpack (R_VENUS, C_ALT, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_AZ, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_DEC, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_EDIST, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_ELONG, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_HLAT, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_HLONG, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_JUPITER, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_MAG, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_MARS, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_MERCURY, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_MOON, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_NEPTUNE, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_OBJ, F_MMNU|F_CHG), X rcfpack (R_VENUS, C_OBJX, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_OBJY, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_PHASE, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_PLUTO, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_RA, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_RISEAZ, F_MNU2|F_PLT), X rcfpack (R_VENUS, C_RISETM, F_MNU2|F_PLT), X rcfpack (R_VENUS, C_SATURN, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_SDIST, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_SETAZ, F_MNU2|F_PLT), X rcfpack (R_VENUS, C_SETTM, F_MNU2|F_PLT), X rcfpack (R_VENUS, C_SIZE, F_MNU1|F_PLT), X rcfpack (R_VENUS, C_SUN, F_MNU3|F_PLT), X rcfpack (R_VENUS, C_TRANSALT, F_MNU2|F_PLT), X rcfpack (R_VENUS, C_TRANSTM, F_MNU2|F_PLT), X rcfpack (R_VENUS, C_TUP, F_MNU2|F_PLT), X rcfpack (R_VENUS, C_URANUS, F_MNU3|F_PLT), X rcfpack (R_WATCH, C_WATCH, F_MMNU|F_CHG), X}; X#define NFIELDS (sizeof(fields)/sizeof(fields[0])) X X/* let op select a field by moving around and hitting RETURN, or until see END. X * also allow moving directly to a planet row using its name. X * only allow fields with the given flag mask. X * return the rcfpack()'d field, or 0 if typed END. X * N.B. we might also exit() entirely by calling bye() if op types QUIT. X */ Xsel_fld (r, c, flag, prmpt, help) Xint r, c; /* inial row, col */ Xint flag; Xchar *prmpt, *help; X{ X extern void bye(); X char *lastp; X int ch; X X lastp = 0; X while (1) { X if (lastp != prmpt) { X lastp = prmpt; X f_prompt (lastp); X } X c_pos (r, c); X switch (ch = read_char()) { X case REDRAW: X redraw_screen(2); /* redraw all from scratch */ X lastp = 0; X break; X case VERSION: X version(); X lastp = 0; X break; X case HELP: X f_msg (help); X lastp = 0; X break; X case QUIT: X f_prompt ("Exit ephem? (y) "); X if (read_char() == 'y') X bye(); /* never returns */ X lastp = 0; X break; X#ifdef BANG X case '!': { X char buf[NC]; X f_prompt ("!"); X if (read_line (buf, sizeof(buf)-2) > 0) { X c_erase(); X byetty(); X (void) system (buf); X printf ("\nHit any key to resume ephem..."); X (void) read_char(); X redraw_screen(2); /* redraw all from scratch */ X } X lastp = 0; X } X break; X#endif X case END: X return (0); X case '\r': X return (rcfpack (r, c, 0)); X default: X move_cur (ch, flag, &r, &c); X break; X } X } X} X X/* move cursor to next field in given direction: hjkl, or directly to a X * field, and set *rp and *cp. X * limit eligible fields to those with given flag mask. X */ Xstatic Xmove_cur (dirchar, flag, rp, cp) Xchar dirchar; Xint flag; Xint *rp, *cp; X{ X int curr = *rp, curc = *cp; X int f, newf, *fp; X int d, newd; X X wrapped: X newf = 0; X newd = 1000; X X switch (dirchar) { X case 'h': /* left */ X /* go to next field to the left, or wrap. */ X for (fp = fields+NFIELDS; --fp >= fields; ) { X f = *fp; X if (tstpackf(f,flag) && unpackr(f) == curr) { X d = curc - unpackc(f); X if (d > 0 && d < newd) { X newf = f; X newd = d; X } X } X } X if (!newf) { X curc = NC; X goto wrapped; X } X break; X X case 'j': /* down */ X /* go to closest field on next row down with anything on it, X * or wrap. X */ X for (fp = fields+NFIELDS; --fp >= fields; ) { X f = *fp; X if (tstpackf(f,flag)) { X d = unpackr(f) - curr; X if (d > 0 && d < newd) { X newf = f; X newd = d; X } X } X } X if (newf) { X /* now find the field closest to current col on that row */ X newf = nearestfld (unpackr(newf), curc, flag); X } else { X curr = 0; X goto wrapped; X } X break; X X case 'k': /* up */ X /* go to closest field on next row up with anything on it, X * or wrap. X */ X for (fp = fields+NFIELDS; --fp >= fields; ) { X f = *fp; X if (tstpackf(f,flag)) { X d = curr - unpackr(f); X if (d > 0 && d < newd) { X newf = f; X newd = d; X } X } X } X if (newf) { X /* now find the field closest to current col on that row */ X newf = nearestfld (unpackr(newf), curc, flag); X } else { X curr = NR+1; X goto wrapped; X } X break; X X case 'l': /* right */ X /* go to next field to the right, or wrap. */ X for (fp = fields+NFIELDS; --fp >= fields; ) { X f = *fp; X if (tstpackf(f,flag) && unpackr(f) == curr) { X d = unpackc(f) - curc; X if (d > 0 && d < newd) { X newf = f; X newd = d; X } X } X } X if (!newf) { X curc = 0; X goto wrapped; X } X break; X X /* handy shorthands directly to a given spot. X * calling nearestfld() automatically allows for which menu X * is up now and what is pickable. you can use rcfpack() X * directly for top half fields that are always up. X * N.B. using nearestfld() can be too aggressive. it will try X * other fields entirely if one you intend is not eligible. X */ X case 'S': newf = nearestfld (R_SUN, 1, flag); break; X case 'M': newf = nearestfld (R_MOON, 1, flag); break; X case 'e': newf = nearestfld (R_MERCURY, 1, flag); break; X case 'v': newf = nearestfld (R_VENUS, 1, flag); break; X case 'm': newf = nearestfld (R_MARS, 1, flag); break; X case cntrl('j'): newf = nearestfld (R_JUPITER, 1, flag); break; X case 's': newf = nearestfld (R_SATURN, 1, flag); break; X case 'u': newf = nearestfld (R_URANUS, 1, flag); break; X case 'n': newf = nearestfld (R_NEPTUNE, 1, flag); break; X case 'p': newf = nearestfld (R_PLUTO, 1, flag); break; X case 'x': newf = nearestfld (R_OBJX, 1, flag); break; X case 'y': newf = nearestfld (R_OBJY, 1, flag); break; X case 'c': newf = rcfpack (R_ALTM, C_ALTM, 0); break; X case 'd': newf = rcfpack (R_UD, C_UD, 0); break; X case 'o': newf = rcfpack (R_EPOCH, C_EPOCHV, 0); break; X case 'z': newf = rcfpack (R_STPSZ, C_STPSZV, 0); break; X case 'w': newf = rcfpack (R_WATCH, C_WATCH, 0); break; X case 'L': newf = rcfpack (R_LISTING, C_LISTING, 0); break; X } X X if (newf > 0) { X *rp = unpackr(newf); X *cp = unpackc(newf); X } X} X X/* return the nearest field with given flag mask, either way, on this row, X * else -1 if none. X */ Xstatic int Xnearestfld (r, c, flag) Xint r, c, flag; X{ X int nf, f, *fp; X int d, d0; X X nf = 0; X d0 = 1000; X X for (fp = fields+NFIELDS; --fp >= fields; ) { X f = *fp; X if (tstpackf(f,flag) && unpackr(f) == r) { X d = abs(c - unpackc(f)); X if (d < d0) { X nf = f; X d0 = d; X } X } X } X return (nf ? nf : -1); X} END_OF_FILE if test 24029 -ne `wc -c <'sel_fld.c'`; then echo shar: \"'sel_fld.c'\" unpacked with wrong size! fi # end of 'sel_fld.c' fi echo shar: End of archive 6 \(of 6\). cp /dev/null ark6isdone MISSING="" for I in 1 2 3 4 5 6 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 6 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0