ccount@ATHENA.MIT.EDU (03/16/90)
Posting-number: Volume 11, Issue 39 Submitted-by: ccount@ATHENA.MIT.EDU Archive-name: starchart/part11 #! /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 11 (of 32)." # Contents: dataconv/sif_to_text.c observe/main.c PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'dataconv/sif_to_text.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'dataconv/sif_to_text.c'\" else echo shar: Extracting \"'dataconv/sif_to_text.c'\" \(18386 characters\) sed "s/^X//" >'dataconv/sif_to_text.c' <<'END_OF_FILE' X/* X * sif_to_text -- Produce plain text discriptions X * from `sif' format starchart data. X * X * Copyright (c) 1990 by Craig Counterman. All rights reserved. X * X * This software may be redistributed freely, not sold. X * This copyright notice and disclaimer of warranty must remain X * unchanged. X * X * No representation is made about the suitability of this X * software for any purpose. It is provided "as is" without express or X * implied warranty, to the extent permitted by applicable law. X * X * DISCLAIMER OF WARRANTY X * ---------------------- X * The author disclaims all warranties with regard to this software to X * the extent permitted by applicable law, including all implied X * warranties of merchantability and fitness. In no event shall the X * author be liable for any special, indirect or consequential damages or X * any damages whatsoever resulting from loss of use, data or profits, X * whether in an action of contract, negligence or other tortious action, X * arising out of or in connection with the use or performance of this X * software. X * X */ X Xstatic char rcsid[]="$Header: sif_to_text.c,v 2.6 90/02/19 16:59:29 ccount Exp $"; X X X X#include <stdio.h> X#include <math.h> X#include <ctype.h> X X#define SEPCHAR ';' X X#define LINELEN 82 X#define MAX(a,b) ((a)>(b)?(a):(b)) X#define MIN(a,b) ((a)<(b)?(a):(b)) X#define FALSE 0 X#define TRUE 1 X X X/* variables for data, filled by readstar and readsif */ Xdouble obj_lat, obj_lon, obj_mag; Xchar obj_type[] ="SS", obj_color[3], obj_label[3]; Xchar obj_constell[4], obj_name[LINELEN]; Xchar *obj_commnt; X X/* Special for readsif in this program */ Xint line_no=0; X Xchar *usage = X"%s: [-i infile] [-sc]\n"; X Xint to_consindx(); X Xmain(argc, argv) X int argc; X char *argv[]; X{ X char *inname = ""; X FILE *infile = stdin; X char sepchar = SEPCHAR; X int i; X X i = 0; X while (i < argc) X if (argv[i][0] != '-') i++; X else switch (argv[i][1]) { X case 'i': X inname = argv[i+1]; X i += 2; X break; X case 's': X if (argv[i][2]) sepchar = argv[i][2]; X i++; X break; X default: X fprintf(stderr, usage, argv[0]); X exit(4); X } X X if (inname[0]) X if ((infile = fopen(inname, "r")) == NULL) { X fprintf(stderr, "%s: Can't open input file %s\n", argv[0], inname); X exit(6); X } X X for (;;) { X if (readsif(infile, sepchar)) break; X check_data(); X write_text(); X } X X exit(0); X} X X X/* readsif reads standard starchart interchange format files, X extracting the same data as readstar, if possible, and loading X the same variables */ Xreadsif(file, sepchar) XFILE *file; Xchar sepchar; X{ X static char inp_line[10*LINELEN]; X int i; X char *cp; X char *parsed_line[9]; X int num_parsed; X double ra_h, ra_m, ra_s, de_d, de_m, de_s; X X /* Get line */ X if (fgets(inp_line, 10*LINELEN, file) == NULL) return TRUE; X line_no++; X X /* Remove newline */ X inp_line[strlen(inp_line)-1] = '\0'; X X /* split line into tokens */ X for (i = 0; i < 9; i++) parsed_line[i] = ""; X X i = 0; X cp = inp_line; X parsed_line[i++] = cp; X while (*cp) X if (*cp != sepchar) cp++; X else if (i < 9) { X *cp++ = '\0'; X parsed_line[i++] = cp; X }; X num_parsed = i; X X /* parse ra and dec */ X ra_h = ra_m = ra_s = 0.0; X de_d = de_m = de_s = 0.0; X sscanf(parsed_line[0], "%lf %lf %lf", &ra_h, &ra_m, &ra_s); X sscanf(parsed_line[1], "%lf %lf %lf", &de_d, &de_m, &de_s); X X /* set obj_ values */ X obj_lon = ra_h * 15.0 + ra_m / 4.0 + ra_s / (4.0 * 60.0); X obj_lat = fabs(de_d) + de_m / 60.0 + de_s / 3600.0; X X /* In order to assign the sign properly if de_d == 0, X we must see if there is a negative sign before the first digit */ X if (de_d < 0.0) obj_lat = -obj_lat; X else if (de_d == 0.0) { X i = 0; X while ((parsed_line[1][i] != '-') && (!isdigit(parsed_line[1][i]))) i++; X if (parsed_line[1][i] == '-') obj_lat = -obj_lat; X }; X X sscanf(parsed_line[2], "%lf", &obj_mag); X X if (sscanf(parsed_line[3], "%2s", obj_type) == EOF) strcpy(obj_type, "SS"); X if (sscanf(parsed_line[4], "%2s", obj_color) == EOF) strcpy(obj_color, " "); X if (sscanf(parsed_line[5], "%2s", obj_label) == EOF) strcpy(obj_label, " "); X if (sscanf(parsed_line[6], "%3s", obj_constell) == EOF) X strcpy(obj_constell, " "); X X if (!obj_type[1]) obj_type[1] = ' '; X if (!obj_color[1]) obj_color[1] = ' '; X if (!obj_label[1]) obj_label[1] = ' '; X if (!obj_constell[1]) obj_constell[1] = ' '; X if (!obj_constell[2]) obj_constell[2] = ' '; X X obj_type[2] = '\0'; X obj_color[2] = '\0'; X obj_label[2] = '\0'; X obj_constell[3] = '\0'; X X/* Magic for label: X type and color should be left justified, constellation is 3 chars if valid, X but label could be " X" or "X " with equal validity. X If the label field is exactly two characters long including whitespace, X and both characters are printable, use it verbatum. */ X if ((strlen(parsed_line[5]) == 2) && isprint(parsed_line[5][0]) && X isprint(parsed_line[5][1])) strcpy(obj_label, parsed_line[5]); X X /* Trim whitespace before and after name */ X while ((*parsed_line[7] == ' ') || (*parsed_line[7] == '\t')) X parsed_line[7]++; X i = strlen(parsed_line[7]) -1 ; X while ((parsed_line[7][i] == ' ') || (parsed_line[7][i] == '\t')) X parsed_line[7][i] = '\0'; X if (!parsed_line[7][0]) strcpy(obj_name,""); X else strcpy(obj_name,parsed_line[7]); X X obj_commnt = parsed_line[8]; X X if (to_consindx(obj_constell) == -1) strcpy(obj_constell," "); X X /* Commas should not appear in name field */ X i = 0; X while (obj_name[i]) X if (obj_name[i++] == ',') X fprintf(stderr, "Warning: comma in name field:\"%s\"\n", obj_name); X X return FALSE; X} X X X/* write text discription of object */ Xwrite_text() X{ X int ra_h, ra_m, ra_s; X int de_d, de_m, de_s; X char dsign; X X char *starid(), *objid(); X X ra_h = obj_lon/15.0; X ra_m = ((obj_lon/15.0) - ra_h) * 60 + (0.5 / 60); X ra_s = ((((obj_lon/15.0) - ra_h) * 60) - ra_m) * 60 + 0.5; X X if (ra_s >= 60) {ra_s -= 60; ra_m++;}; X if (ra_m >= 60) {ra_m -= 60; ra_h++;}; X X X if (obj_lat < 0.0) { X obj_lat = -obj_lat; X dsign = '-'; X } else dsign = '+'; X X de_d = obj_lat; X de_m = (obj_lat - de_d) * 60 + (0.5 / 60); X de_s = (((obj_lat - de_d) * 60) - de_m) * 60 + 0.5; X X if (de_s >= 60) {de_s -= 60; de_m++;}; X if (de_m >= 60) {de_m -= 60; de_d++;}; X X X if ((obj_type[0] == 'S') || (obj_type[0] == 'I')) X printf("%70s ", starid()); X /* starid supplies label, constellation, subtype, and name */ X else X printf("%70s ", objid()); X /* objid supplies constellation, type, size, and name */ X X printf("%2dh%2dm%2ds %c%02dd%2dm%2ds %5.2f %s", X ra_h, ra_m, ra_s, dsign, de_d, de_m, de_s, obj_mag, obj_color); X X X if (obj_commnt[0]) X printf(" %s", obj_commnt); X X printf("\n"); X} X Xstruct { X char *abbrev; X char *name; X char *genetive; X} constellations[] = { X {"AND", "Andromeda", "Andromedae"}, X {"ANT", "Antlia", "Antliae"}, X {"APS", "Apus", "Apodis"}, X {"AQL", "Aquila", "Aquilae"}, X {"AQR", "Aquarius", "Aquarii"}, X {"ARA", "Ara", "Arae"}, X {"ARI", "Aries", "Arietis"}, X {"AUR", "Auriga", "Aurigae"}, X {"BOO", "Bootes", "Bootis"}, X {"CAE", "Caelum", "Caeli"}, X {"CAM", "Camelopardalis", "Camelopardalis"}, X {"CAP", "Capricornus", "Capricorni"}, X {"CAR", "Carina", "Carinae"}, X {"CAS", "Cassiopeia", "Cassiopeiae"}, X {"CEN", "Centaurus", "Centauri"}, X {"CEP", "Cepheus", "Cephei"}, X {"CET", "Cetus", "Ceti"}, X {"CHA", "Chamaeleon", "Chamaeleonis"}, X {"CIR", "Circinus", "Circini"}, X {"CMA", "Canis Major", "Canis Majoris"}, X {"CMI", "Canis Minor", "Canis Minoris"}, X {"CNC", "Cancer", "Cancri"}, X {"COL", "Columba", "Columbae"}, X {"COM", "Coma Berenices", "Comae Berenices"}, X {"CRA", "Corona Australis", "Coronae Australis"}, X {"CRB", "Corona Borealis", "Corona Borealis"}, X {"CRT", "Crater", "Crateris"}, X {"CRU", "Crux", "Cruxis"}, X {"CRV", "Corvus", "Corvi"}, X {"CVN", "Canes Venatici", "Canum Venaticorum"}, X {"CYG", "Cygnus", "Cygni"}, X {"DEL", "Delphinus", "Delphini"}, X {"DOR", "Dorado", "Doradus"}, X {"DRA", "Draco", "Draconis"}, X {"EQU", "Equuleus", "Equulei"}, X {"ERI", "Eridanus", "Eridani"}, X {"FOR", "Fornax", "Fornacis"}, X {"GEM", "Gemini", "Geminorum"}, X {"GRU", "Grus", "Gruis"}, X {"HER", "Hercules", "Herculis"}, X {"HOR", "Horologium", "Horologii"}, X {"HYA", "Hydra", "Hydrae"}, X {"HYI", "Hydrus", "Hydri"}, X {"IND", "Indus", "Indi"}, X {"LAC", "Lacerta", "Lacertae"}, X {"LEO", "Leo", "Leonis"}, X {"LEP", "Lepus", "Leporis"}, X {"LIB", "Libra", "Librae"}, X {"LMI", "Leo Minor", "Leonis Minoris"}, X {"LUP", "Lupus", "Lupi"}, X {"LYN", "Lynx", "Lyncis"}, X {"LYR", "Lyra", "Lyrae"}, X {"MEN", "Mensa", "Mensae"}, X {"MIC", "Microscopium", "Microscopii"}, X {"MON", "Monoceros", "Monocerotis"}, X {"MUS", "Musca", "Muscae"}, X {"NOR", "Norma", "Normae"}, X {"OCT", "Octans", "Octantis"}, X {"OPH", "Ophiuchus", "Ophiuchi"}, X {"ORI", "Orion", "Orionis"}, X {"PAV", "Pavo", "Pavonis"}, X {"PEG", "Pegasus", "Pegasi"}, X {"PER", "Perseus", "Persei"}, X {"PHE", "Phoenix", "Phoenicis"}, X {"PIC", "Pictor", "Pictoris"}, X {"PSA", "Piscis Astrinus", "Piscis Austrini"}, X {"PSC", "Pisces", "Piscium"}, X {"PUP", "Puppis", "Puppis"}, X {"PYX", "Pyxis", "Pyxidis"}, X {"RET", "Reticulum", "Reticuli"}, X {"SCL", "Sculptor", "Sculptoris"}, X {"SCO", "Scorpius", "Scorpii"}, X {"SCT", "Scutum", "Scuti"}, X {"SER", "Serpens", "Serpentis"}, X {"SEX", "Sextans", "Sextantis"}, X {"SGE", "Sagitta", "Sagittae"}, X {"SGR", "Sagittarius", "Sagittarii"}, X {"TAU", "Taurus", "Tauri"}, X {"TEL", "Telescopium", "Telescopii"}, X {"TRA", "Triangulum Astrale", "Trianguli Astralis"}, X {"TRI", "Triangulum", "Trianguli"}, X {"TUC", "Tucana", "Tucanae"}, X {"UMA", "Ursa Major", "Ursae Majoris"}, X {"UMI", "Ursa Minor", "Ursae Minoris"}, X {"VEL", "Vela", "Velorum"}, X {"VIR", "Virgo", "Virginis"}, X {"VOL", "Volans", "Volantis"}, X {"VUL", "Vulpecula", "Vulpeculae"}, X {" ", "", ""}, X {"", "", ""} X}; X Xint to_consindx(cons) Xchar *cons; X{ X int i; X X if (!cons[0]) return -1; X X i = -1; X while (constellations[++i].abbrev[0]) X if (!strcmp(cons, constellations[i].abbrev)) break; X X return (constellations[i].abbrev[0] ? i : 0); X} X X Xchar ret_star[100]; X X/* return pointer to ret_star, which contains the label and constellation, X name, and subtype */ Xchar *starid() X{ X char *grk_str; X char *to_greek(); X X grk_str = to_greek(obj_label); X X if (grk_str[0]) X if ((obj_type[1] != 'S') && (obj_type[1] != ' ')) X sprintf(ret_star, "%8s %-18s (%c) %-35.35s", X grk_str, X constellations[to_consindx(obj_constell)].genetive, X obj_type[1], X obj_name); X else X sprintf(ret_star, "%8s %-18s %-35.-35s", grk_str, X constellations[to_consindx(obj_constell)].genetive, X obj_name); X else X if ((obj_type[1] != 'S') && (obj_type[1] != ' ')) X sprintf(ret_star, " %-18s (%c) %35.35s", X constellations[to_consindx(obj_constell)].name, X obj_type[1], X obj_name); X else X sprintf(ret_star, " %-18s %35.35s", X constellations[to_consindx(obj_constell)].name, X obj_name); X if (obj_type[0] == 'I') strcat(ret_star, "I "); X else strcat(ret_star, " "); X X return ret_star; X} X Xstruct { X char roman; X char *greek_name; X} grk_tr_tab[] = { X {'a', "Alpha"}, X {'b', "Beta"}, X {'g', "Gamma"}, X {'d', "Delta"}, X {'e', "Epsilon"}, X {'z', "Zeta"}, X {'h', "Eta"}, X {'q', "Theta"}, X {'i', "Iota"}, X {'k', "Kappa"}, X {'l', "Lambda"}, X {'m', "Mu"}, X {'n', "Nu"}, X {'x', "Xi"}, X {'o', "Omicron"}, X {'p', "Pi"}, X {'r', "Rho"}, X {'s', "Sigma"}, X {'t', "Tau"}, X {'u', "Upsilon"}, X {'f', "Phi"}, X {'j', "Phi"}, X {'c', "Chi"}, X {'y', "Psi"}, X {'w', "Omega"}, X {' ', ""} X}; X Xchar grk_ret[12]; X Xchar *to_greek(label) Xchar *label; X{ X int i; X X if (isgreek(label[0]) && (isdigit(label[1]) || (label[1] == ' '))) { X /* Greek if first character is greek encoded, X and the second is space or a digit */ X i = 0; X while ((grk_tr_tab[i].greek_name[0]) X && (grk_tr_tab[i].roman != label[0])) i++; X if (grk_tr_tab[i].greek_name[0]) X sprintf(grk_ret, "%s%c", grk_tr_tab[i].greek_name, label[1]); X else { /* Error */ X fprintf(stderr, "Report bug in greek coding\n"); X exit(1); X } X } else { /* Not greek */ X if ((label[0] != ' ') || (label[1] != ' ')) X sprintf(grk_ret, "%s", label); X else X grk_ret[0] = '\0'; X } X X return grk_ret; X} X X X Xisgreek(c) Xchar c; X{ X char *cp; X X cp = "abgdezhqiklmnxoprstufcywj"; X X while (*cp && (*cp != c)) cp++; X return (*cp != '\0'); /* True if letter was in greek string */ X} X X X X X X Xchar ret_obj[100]; X X/* return pointer to ret_obj, which contains the constellation, X type, size and name */ Xchar *objid() X{ X long int size_obj(); X long int sze; X char *obj_ty(); X char sze_str[10]; X X sze = size_obj(obj_label); X if (sze > 4800) X sprintf(sze_str, "%.2fd", sze/3600.0); X else if (sze > 120) X sprintf(sze_str, "%.2fm", sze/60.0); X else X sprintf(sze_str, "%ds", sze); X X if (sze != -1) X sprintf(ret_obj, "%-18s %-19.19s %-24s %6s", X constellations[to_consindx(obj_constell)].name, X obj_name, X obj_ty(obj_type), X sze_str); X else X sprintf(ret_obj, "%-18s %-19.19s %-24s ", X constellations[to_consindx(obj_constell)].name, X obj_name, X obj_ty(obj_type)); X X return ret_obj; X} X X X X/* Translate two digit encoded size string */ X/* Maximum parsed: 89000 secs of arc = 24.666 degrees */ X/* Warning, should use 32 bit integers to allow this value */ Xlong size_obj(size_str) X char *size_str; X{ X char chr1, chr2; X X chr1 = islower(size_str[0]) ? toupper(size_str[0]) : size_str[0]; X chr2 = islower(size_str[1]) ? toupper(size_str[1]) : size_str[1]; X X if ((chr1 == ' ') && (chr2 == ' ')) return -1; X if (chr1 == ' ') return chr2 - '0'; X if (isdigit(chr1)) return ((chr1-'0')*10L + (chr2-'0')); X if (chr1 < 'J') return ((chr1-'A'+1)*100L + (chr2-'0')*10L); X if (chr1 < 'S') return ((chr1-'I')*1000L + (chr2-'0')*100L); X if (chr1 <= 'Z') return ((chr1-'R')*10000L + (chr2-'0')*1000L); X return -1; X} X X/* XExamples: X X" " -1 X" 6" 6 X"09" 9 X"73" 73 X"A0" 100 X"C3" 330 X"D5" 450 X"I6" 960 X"J2" 1200 X"R3" 9300 X"S6" 16000 X"Z0" 80000 X"Z9" 89000 X*/ X X X Xstruct subtytab { X char ch; X char *str; X}; X Xstruct tytab { X char ch; X char *str; X struct subtytab *subtab; X}; X Xstruct subtytab st_subty[] = { X {'S', "Single"}, X {'D', "Double"}, X {'V', "Variable"}, X {'?', ""} X}; X Xstruct subtytab pl_subty[] = { X {'M', "Mercury"}, X {'V', "Venus"}, X {'m', "Mars"}, X {'J', "Jupiter"}, X {'s', "Saturn"}, X {'U', "Uranus"}, X {'N', "Neptune"}, X {'P', "Pluto"}, X {'A', "Asteroid"}, X {'C', "Comet"}, X {'S', "Sun"}, X {'L', "Moon"}, X {'?', ""} X}; X Xstruct subtytab cl_subty[] = { X {'O', "Open Cluster"}, X {'G', "Globular"}, X {'?', ""} X}; X Xstruct subtytab nb_subty[] = { X {'D', "Diffuse Nebula"}, X {'P', "Planetary Nebula"}, X {'?', ""} X}; X Xstruct subtytab gx_subty[] = { X {'a', "Spiral Galaxy Sa"}, X {'b', "Spiral Galaxy Sb"}, X {'c', "Spiral Galaxy Sc"}, X {'d', "Spiral Galaxy Sd"}, X {'p', "Spiral Galaxy Sp"}, X {'Z', "Spiral Galaxy S0"}, X {'s', "Spiral Galaxy"}, X {'A', "Barred Spiral Galaxy SBa"}, X {'B', "Barred Spiral Galaxy SBb"}, X {'C', "Barred Spiral Galaxy SBc"}, X {'D', "Barred Spiral Galaxy SBd"}, X {'P', "Barred Spiral Galaxy SBp"}, X {'S', "Barred Spiral Galaxy"}, X {'0', "Elliptical Galaxy E0"}, X {'1', "Elliptical Galaxy E1"}, X {'2', "Elliptical Galaxy E2"}, X {'3', "Elliptical Galaxy E3"}, X {'4', "Elliptical Galaxy E4"}, X {'5', "Elliptical Galaxy E5"}, X {'6', "Elliptical Galaxy E6"}, X {'7', "Elliptical Galaxy E7"}, X {'E', "Elliptical Galaxy"}, X {'I', "Irregular Galaxy"}, X {'Q', "Quasar"}, X {'U', "Unknown Galaxy"}, X {'!', "Pecular Galaxy"}, X {'?', ""} X}; X Xstruct subtytab ve_subty[] = { X {'M', "Vector Move to"}, X {'S', "Solid Line"}, X {'D', "Dotted Line"}, X {'H', "Dashed Line"}, X {'?', ""} X}; X Xstruct subtytab ar_subty[] = { X {'M', "Area move to"}, X {'A', "Area border"}, X {'F', "Area fill"}, X {'?', ""} X}; X X Xstruct subtytab nul_subty[] = { X {'?', ""} X}; X X X Xstruct tytab tytop[] = { X {'S', "? Star", st_subty}, X {'P', "? Planet", pl_subty}, X {'C', "? Cluster", cl_subty}, X {'N', "? Nebula", nb_subty}, X {'G', "? Galaxy", gx_subty}, X {'V', "ERROR Vector", ve_subty}, X {'O', "Other", nul_subty}, X {'U', "Unknown", nul_subty}, X {'I', "Invisible", nul_subty}, X {'#', "Comment", nul_subty}, X {'A', "ERROR Area", ar_subty}, X {'U', "Unknown", nul_subty}, X {'?', "", nul_subty} X}; X X X Xchar ty_ret[100]; Xchar *obj_ty(typ) Xchar *typ; X{ X int i, j; X X X i = 0; X while ((tytop[i].str[0]) && (tytop[i].ch != typ[0])) i++; X if (tytop[i].str[0]) { X j = 0; X while ((tytop[i].subtab[j].str[0]) X && (tytop[i].subtab[j].ch != typ[1])) j++; X if (tytop[i].subtab[j].str[0]) X sprintf(ty_ret, "%s", tytop[i].subtab[j].str); X else X sprintf(ty_ret, "%s", tytop[i].str); X } else X sprintf(ty_ret, "%s", "Unknown Type"); X X return ty_ret; X} X X Xcheck_data() X{ X int i, j; X X if ((obj_lon < 0.0) || (obj_lon > 360.0)) X fprintf(stderr, "Warning: RA out of range: line %d: %f\n", X line_no, obj_lon); X X if ((obj_lat < -90.0) || (obj_lat > 90.0)) X fprintf(stderr, "Warning: declination out of range: line %d: %f\n", X line_no, obj_lat); X X if ((obj_mag < -30.0) || (obj_mag > 30.0)) X fprintf(stderr, "Warning: abnormal magnitude: line %d: %f\n", X line_no, obj_mag); X X i = 0; X while ((tytop[i].str[0]) && (tytop[i].ch != obj_type[0])) i++; X if (tytop[i].str[0]) { X j = 0; X while ((tytop[i].subtab[j].str[0]) X && (tytop[i].subtab[j].ch != obj_type[1])) j++; X if ((!tytop[i].subtab[j].str[0]) X && (obj_type[1] != ' ')) X fprintf(stderr, X "Warning: unknown subtype: line %d: type %c subtype %c\n", X line_no, obj_type[0], obj_type[1]); X } else X fprintf(stderr, "Warning: unknown type: line %d: %c\n", X line_no, obj_type[0]); X X if (obj_type[0] == 'S') { X if ((!isgreek(obj_label[0])) /* letter is not greek, */ X && islower(obj_label[0]) /* but is lowercase */ X && (isdigit(obj_label[1]) || (obj_label[1] == ' '))) X /* and is followed by space or digit */ X fprintf(stderr, "Warning: not greek encoding: line %d: %s\n", X line_no, obj_label); X } X X if (to_consindx(obj_constell) == -1) X fprintf(stderr, "Warning: unknown constellation: line %d: %s\n", X line_no, obj_constell); X X X} END_OF_FILE if test 18386 -ne `wc -c <'dataconv/sif_to_text.c'`; then echo shar: \"'dataconv/sif_to_text.c'\" unpacked with wrong size! fi # end of 'dataconv/sif_to_text.c' fi if test -f 'observe/main.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'observe/main.c'\" else echo shar: Extracting \"'observe/main.c'\" \(21792 characters\) sed "s/^X//" >'observe/main.c' <<'END_OF_FILE' X/* X * main.c X * main() for combined planet, precession, ephemeris, asteroid, comet program X * X * Copyright (c) 1990 by Craig Counterman. All rights reserved. X * X * This software may be redistributed freely, not sold. X * This copyright notice and disclaimer of warranty must remain X * unchanged. X * X * No representation is made about the suitability of this X * software for any purpose. It is provided "as is" without express or X * implied warranty, to the extent permitted by applicable law. X * X * DISCLAIMER OF WARRANTY X * ---------------------- X * The author disclaims all warranties with regard to this software to X * the extent permitted by applicable law, including all implied X * warranties of merchantability and fitness. In no event shall the X * author be liable for any special, indirect or consequential damages or X * any damages whatsoever resulting from loss of use, data or profits, X * whether in an action of contract, negligence or other tortious action, X * arising out of or in connection with the use or performance of this X * software. X * X * email: ccount@athena.mit.edu X */ X X#ifndef lint Xstatic char rcsid[] = X "$Header: main.c,v 1.13 90/02/23 18:44:16 ccount Exp $"; X#endif X X X#include <stdio.h> X#include <math.h> X#ifndef SYSV X#include <strings.h> X#else X#include <string.h> X#endif X#include <ctype.h> X X#include <time.h> X#ifndef ATARI_ST X#include <sys/types.h> X#include <sys/timeb.h> X#else X#include <types.h> X#include <time.h> X#endif X X#include "observe.h" X#include "date.h" X X X#ifndef FALSE X#define FALSE 0 X#endif X#ifndef TRUE X#define TRUE 1 X#endif X#ifndef MAXPATHLEN X#define MAXPATHLEN 1025 X#endif X X Xvoid parse_command(); X X X Xchar *progname; X X/* Time */ Xdouble start_date; /* JD of start */ Xint start_month, start_year; Xdouble start_day; Xdouble end_date; /* JD of end */ Xint end_month, end_year; Xdouble end_day; Xdouble interval_days = 1.0; X X/* Place */ Xdouble obs_lon = -71.0; Xdouble obs_lat = 42.0; Xdouble obs_zone = -4.0; Xdouble obs_height = 50.0; /* Meters */ X X/* files */ Xchar *outfile_root = "planet"; XFILE *o_sif, *o_star, *o_eph, *o_obs, *o_sat, *o_sat_PS, *o_altaz; Xint do_sif = TRUE, do_star = TRUE, do_eph = TRUE, do_obs = TRUE, X do_altaz = TRUE; X X/* input file Formats */ X Xint file_input = FALSE; Xfformat_t tr_format(); Xchar *infile_name = ""; XFILE *infile; Xfformat_t in_type; X X X X/* objects */ Xint planet_list[] = { X FALSE, /* Mercury */ X FALSE, /* Venus */ X FALSE, /* Mars */ X FALSE, /* Jupiter */ X FALSE, /* Saturn */ X FALSE, /* Uranus */ X FALSE /* Neptune */ X}; X Xchar *obj_name = ""; X X#ifndef MAXOBJECTS X#define MAXOBJECTS 1500 X#endif X X Xplanet_data_t planets[7]; X#ifndef ATARI_ST Xwanderer_data_t bodies[MAXOBJECTS]; X#else Xwanderer_data_t *bodies; X#endif X Xint nbodies; Xsun_data_t sun_data; Xmoon_data_t moon_data; X X#ifndef ATARI_ST Xobj_data_t objects[MAXOBJECTS]; X#else Xobj_data_t *objects; X#endif Xint nobjects; X X X/* (7 planets + objects) each rise rise20 rise30 transit set30 set20 set X + sunrise sunset moonrise moonset and twilights */ X#define EVENTSSIZE ((7+MAXOBJECTS)*MAXEVENTS+6) Xobserve_t events[EVENTSSIZE]; Xint nevents; X Xint index_events[EVENTSSIZE]; Xdouble event_times[EVENTSSIZE]; X X/* Controls */ Xint satellites = FALSE; Xint invert_sats = FALSE; X Xdouble morntwil(), evetwil(), sunrise(), sunset(), moonrise(), moonset(), X objrise(), objset(), objrise20(), objset20(), objrise30(), objset30(); X Xmain(argc, argv) X int argc; X char **argv; X{ X int i; X char filename[MAXPATHLEN]; X double jd; X char datestr[15]; X int one_day; X X#ifdef ATARI_ST X if ((bodies = (wanderer_data_t *) X lmalloc((long)MAXOBJECTS * (long)sizeof(wanderer_data_t)) X ) == (wanderer_data_t *)0) X { X perror("malloc"); X exit(1); X } X if ((objects = (obj_data_t *) X lmalloc((long)MAXOBJECTS * (long)sizeof(obj_data_t)) X ) == (wanderer_data_t *)0) X { X perror("malloc"); X exit(1); X } X#endif X X X get_time(); X obs_zone = now_zone(); X jd_to_cal(start_date, &start_day, &start_month, &start_year); X end_date = start_date; X end_day = start_day; X end_month = start_month; X end_year = start_year; X X parse_command(argc, argv); X X X one_day = (start_date == end_date); X X jd_to_str(start_date, datestr); X X if (file_input) { X if ((infile = fopen(infile_name, "r")) == NULL) { X fprintf(stderr, "%s: could not open file %s for reading\n", X progname, infile_name); X exit(1); X }; X X /* input data from infile */ X switch (in_type) { X case emp: X case empb: X case aa: X case st: X case iau: X read_table(infile, in_type); X nbodies = 1; X bodies[0].name = obj_name; X bodies[0].orbit_type = tabulated; X break; X case ell_e: X read_elliptical(infile, bodies, &nbodies, MAXOBJECTS); X break; X case par_e: X read_parabolic(infile, bodies, &nbodies, MAXOBJECTS); X break; X case obj: X read_objects(infile, objects, &nobjects, MAXOBJECTS); X break; X default: X break; X }; X }; X X /* open output files */ X strncpy(filename, outfile_root, MAXPATHLEN-5); X#ifndef ATARI_ST X strcat(filename, ".star"); X#else X strcat(filename, ".str"); X#endif X if (do_star) X if ((o_star = fopen(filename, "w")) == NULL) { X fprintf(stderr, "%s: could not open file %s for writing\n", X progname, filename); X exit(1); X }; X strncpy(filename, outfile_root, MAXPATHLEN-5); X strcat(filename, ".sif"); X if (do_sif) X if ((o_sif = fopen(filename, "w")) == NULL) { X fprintf(stderr, "%s: could not open file %s for writing\n", X progname, filename); X exit(1); X }; X strncpy(filename, outfile_root, MAXPATHLEN-5); X strcat(filename, ".eph"); X if (do_eph) X if ((o_eph = fopen(filename, "w")) == NULL) { X fprintf(stderr, "%s: could not open file %s for writing\n", X progname, filename); X exit(1); X }; X strncpy(filename, outfile_root, MAXPATHLEN-5); X strcat(filename, ".obs"); X if (do_obs) X if ((o_obs = fopen(filename, "w")) == NULL) { X fprintf(stderr, "%s: could not open file %s for writing\n", X progname, filename); X exit(1); X }; X strncpy(filename, outfile_root, MAXPATHLEN-5); X#ifndef ATARI_ST X strcat(filename, ".altaz"); X#else X strcat(filename, ".alt"); X#endif X if (do_altaz) X if ((o_altaz = fopen(filename, "w")) == NULL) { X fprintf(stderr, "%s: could not open file %s for writing\n", X progname, filename); X exit(1); X }; X if (satellites) { X strncpy(filename, outfile_root, MAXPATHLEN-5); X strcat(filename, ".sat"); X if ((o_sat = fopen(filename, "w")) == NULL) { X fprintf(stderr, "%s: could not open file %s for writing\n", X progname, filename); X exit(1); X }; X strncpy(filename, outfile_root, MAXPATHLEN-7); X#ifdef MSDOS X strcat(filename, ".sPS"); X#else X#ifdef ATARI_ST X strcat(filename, ".sps"); X#else X strcat(filename, ".sat_PS"); X#endif /* Atari */ X#endif /* msdos */ X X if ((o_sat_PS = fopen(filename, "w")) == NULL) { X fprintf(stderr, "%s: could not open file %s for writing\n", X progname, filename); X exit(1); X }; X }; X X X /* for each time */ X for (jd = start_date; jd <= end_date; jd += interval_days) { X /* Calculate sun position, moon position */ X sun_pos(jd, &sun_data); X moon_pos(jd, sun_data, &moon_data); X X /* Calculate special events in the day */ X sun_data.rise_hour = X events[0].hour = sunrise(jd, obs_lon, obs_lat, obs_zone, obs_height, X sun_data); X events[0].object = "sun"; X events[0].event = rise; X events[0].special = rise_special; X sun_data.transit_hour = X suntransit(jd, obs_lon, obs_lat, obs_zone, obs_height, sun_data); X sun_data.set_hour = X events[1].hour = sunset(jd, obs_lon, obs_lat, obs_zone, obs_height, X sun_data); X events[1].object = "sun"; X events[1].event = set; X events[1].special = set_special; X events[2].hour = morntwil(jd, obs_lon, obs_lat, obs_zone, obs_height, X sun_data); X events[2].object = "morning twilight"; X events[2].event = special; X events[2].special = morning_twilight; X events[3].hour = evetwil(jd, obs_lon, obs_lat, obs_zone, obs_height, X sun_data); X events[3].object = "evening twilight"; X events[3].event = special; X events[3].special = evening_twilight; X X moon_data.rise_hour = X events[4].hour = moonrise(jd, obs_lon, obs_lat, obs_zone, obs_height, X moon_data); X events[4].object = "moon"; X events[4].event = rise; X events[4].special = rise_special; X moon_data.transit_hour = X moontransit(jd, obs_lon, obs_lat, obs_zone, obs_height, moon_data); X moon_data.set_hour = X events[5].hour = moonset(jd, obs_lon, obs_lat, obs_zone, obs_height, X moon_data); X events[5].object = "moon"; X events[5].event = set; X events[5].special = set_special; X nevents = 6; X X /* for each planet, calculate position and events */ X for (i = 0; i < 7; i++) X if (planet_list[i]) { X planet_pos(jd, sun_data, i, &planets[i]); X calc_events(planets[i].eventlist, X &planets[i].rise_hour, &planets[i].transit_hour, X &planets[i].set_hour, X jd, obs_lon, obs_lat, obs_zone, obs_height, X planets[i].name, planets[i].alpha, planets[i].delta); X add_events(events, &nevents, planets[i].eventlist); X } else { X planets[i].name = ""; X }; X X /* for each object, calculate position and events */ X for (i = 0; i < nobjects; i++) { X obj_pos(jd, &objects[i]); /* calculates alpha and delta X alpha2000 and delta2000 */ X calc_events(objects[i].eventlist, X &objects[i].rise_hour, &objects[i].transit_hour, X &objects[i].set_hour, X jd, obs_lon, obs_lat, obs_zone, obs_height, X objects[i].name, objects[i].alpha, objects[i].delta); X add_events(events, &nevents, objects[i].eventlist); X }; X X /* for each body, calculate position and events */ X for (i = 0; i < nbodies; i++) { X if (bodies[i].orbit_type == elliptical_orbit) X elliptical_pos(jd, sun_data, &bodies[i]); X else if (bodies[i].orbit_type == parabolic_orbit) X parabolic_pos(jd, sun_data, &bodies[i]); X else if (bodies[i].orbit_type == tabulated) X tabulated_pos(jd, sun_data, &bodies[i]); X X calc_events(bodies[i].eventlist, X &bodies[i].rise_hour, &bodies[i].transit_hour, X &bodies[i].set_hour, X jd, obs_lon, obs_lat, obs_zone, obs_height, X bodies[i].name, bodies[i].alpha, bodies[i].delta); X add_events(events, &nevents, bodies[i].eventlist); X }; X X /* Sort event list */ X for (i = 0; i < nevents; i++) X if (events[i].hour > 12.0) X event_times[i] = events[i].hour; X else { X events[i].hour += 3.94 / 60; /* add a day */ X event_times[i] = events[i].hour + 24; X }; X HeapSort0(event_times, index_events, nevents); X X if (do_sif || do_star) X out_sif(o_sif, o_star, do_sif, do_star, one_day, X sun_data, moon_data, X planets, bodies, nbodies, objects, nobjects); X /* Output .sif and .star files for object(s) */ X X if (do_obs) X out_obs(o_obs, one_day, jd, events, index_events, nevents); X /* Output observability file for object(s) */ X X if (do_eph) X out_eph(o_eph, one_day, jd, X sun_data, moon_data, X planets, bodies, nbodies, objects, nobjects); X /* Output ephemeris file for object(s) */ X X if (do_altaz) X out_altaz(o_altaz, one_day, jd, X obs_lon, obs_lat, obs_zone, obs_height, X sun_data, moon_data, X planets, bodies, nbodies, objects, nobjects); X /* Output altaz file for object(s) */ X X if (satellites) X if (one_day) X out_sat(o_sat, o_sat_PS, one_day, invert_sats, jd, moon_data, planets); X /* Output satellite, .PS file for satellites */ X }; X if (!one_day) { /* need to calculate moving objects for each X object for each day */ X /* Sun */ X for (jd = start_date; jd <= end_date; jd += interval_days) { X /* Calculate sun position, moon position */ X sun_pos(jd, &sun_data); X if (do_sif || do_star) X out_sif_sun(o_sif, o_star, do_sif, do_star, one_day, X sun_data, jd); X /* Output .sif and .star files for sun */ X }; X /* Moon */ X for (jd = start_date; jd <= end_date; jd += interval_days) { X /* Calculate sun position, moon position */ X sun_pos(jd, &sun_data); X moon_pos(jd, sun_data, &moon_data); X if (do_sif || do_star) X out_sif_moon(o_sif, o_star, do_sif, do_star, one_day, X moon_data, jd); X /* Output .sif and .star files for moon */ X }; X X X /* for each planet, calculate position and events */ X for (i = 0; i < 7; i++) X if (planet_list[i]) { X for (jd = start_date; jd <= end_date; jd += interval_days) { X /* Calculate sun position */ X sun_pos(jd, &sun_data); X X planet_pos(jd, sun_data, i, &planets[i]); X /* Output .sif and .star files for planet */ X if (do_sif || do_star) X out_sif_planet(o_sif, o_star, do_sif, do_star, one_day, X planets[i], jd); X } X }; X X /* Output satellite positions for each day */ X if (satellites) { X /* Jupiter */ X for (jd = start_date; jd <= end_date; jd += interval_days) { X sun_pos(jd, &sun_data); X moon_pos(jd, sun_data, &moon_data); X planet_pos(jd, sun_data, 3, &planets[3]); X out_sat(o_sat, o_sat_PS, one_day, invert_sats, jd, X moon_data, planets); X /* Output satellite, .PS file for satellites */ X }; X X /* Saturn */ X for (jd = start_date; jd <= end_date; jd += interval_days) { X sun_pos(jd, &sun_data); X moon_pos(jd, sun_data, &moon_data); X planet_pos(jd, sun_data, 4, &planets[4]); X out_sat(o_sat, o_sat_PS, one_day, invert_sats, jd, X moon_data, planets); X /* Output satellite, .PS file for satellites */ X }; X out_sat_end(o_sat, o_sat_PS, invert_sats, start_date, interval_days); X /* Close the postscript (showpage) */ X }; X X /* for each body, calculate position and events */ X for (i = 0; i < nbodies; i++) { X for (jd = start_date; jd <= end_date; jd += interval_days) { X /* Calculate sun position */ X sun_pos(jd, &sun_data); X X if (bodies[i].orbit_type == elliptical_orbit) X elliptical_pos(jd, sun_data, &bodies[i]); X else if (bodies[i].orbit_type == parabolic_orbit) X parabolic_pos(jd, sun_data, &bodies[i]); X else if (bodies[i].orbit_type == tabulated) X tabulated_pos(jd, sun_data, &bodies[i]); X X if (do_sif || do_star) X out_sif_body(o_sif, o_star, do_sif, do_star, one_day, X bodies[i], jd); X /* Output .sif and .star files for planet */ X }; X }; X }; X exit(0); X} X X X#define GMT1970 2440587.5 X/* X Get current time X set start_date, start_day, start_month, start_year, start_hour; X*/ Xvoid get_time() X{ X time_t timeofday; /* time_t is usually "long" */ X#ifndef ATARI_ST X struct timeb tp; X X ftime(&tp); X X timeofday = tp.time; X#else X time(&timeofday); X#endif X X start_date = timeofday / 86400.0 + 2440587.5; /* this is now the true JD */ X} X X X X/* rather system dependent */ X X/* Method 1 subtract local time from gmt */ Xdouble now_zone() X{ X time_t timeofday; X struct timeb tp; X struct tm *localtm, *gmttm; X double local_hour, gmt_hour; X ftime(&tp); X X timeofday = tp.time; X X localtm = localtime(&timeofday); X local_hour = localtm->tm_sec/3600.0 + localtm->tm_min/60.0 X + localtm->tm_hour; X gmttm = gmtime(&timeofday); X gmt_hour = gmttm->tm_sec/3600.0 + gmttm->tm_min/60.0 X + gmttm->tm_hour; X X return (local_hour - gmt_hour); X} X X/* Method 2, for SYSV? Xdouble now_zone() X{ X extern long timezone; X X return (-timezone/3600.0); X} X*/ X/* Method 3, for non SYSV? Xdouble now_zone() X{ X struct timeval tp; X struct timezone tzp; X X gettimeofday(&tp, &tzp); X X return (-tzp.tz_minuteswest/60.0 + tzp.tz_dsttime); X} X*/ X/* For ATARI_ST */ X/*double now_zone() X{ X extern long timezone; X tm_t *tp; X localtime(&tp); X X return (-timezone/3600.0); X} X*/ X X Xint now_year() X{ X time_t timeofday; /* time_t is usually "long" */ X#ifndef ATARI_ST X struct timeb tp; X double jd; X double day; X int month, year; X X ftime(&tp); X X timeofday = tp.time; X X jd = timeofday / 86400.0 + 2440587.5; /* this is now the true JD */ X X jd_to_cal(jd, &day, &month, &year); X#else /* Atari */ X int year; X tm_t *tp; X time(&timeofday); X tp=localtime(&timeofday); X year=tp->tm_year; X#endif X return year; X} X X X/* is not an argument switch, i.e. not "-[a-Z]" */ Xint notarg(s) Xchar *s; X{ X return (!((s[0] == '-') && (isalpha(s[1])))); X} X Xvoid usage() X{ X fprintf(stderr, X "%s: -o[aeios] outfile_root -p [MVmJsUN] -s[i] -n name -f filename filetype\n\ X -d \"start date\" \"end date\" -z time_zone_value -l latitude -m meridian\n", X progname); X} X Xvoid parse_command(argc, argv) Xint argc; Xchar **argv; X{ X int i, j; X char *cp1; X int mo, yr; X double dy; X X progname = argv[0]; X X for (i = 1; i < argc; i++) X if (argv[i][0] == '-') X switch (argv[i][1]) { X case 'm': X /* Meridian */ X /* One to three arguments, floating point */ X if (((i+1) < argc) && (notarg(argv[i+1]))) { X obs_lon = atof(argv[i+1]); X i++; X if (((i+1) < argc) && (notarg(argv[i+1]))) { X if (obs_lon > 0) X obs_lon += atof(argv[i+1]) / 60.0; X else X obs_lon -= atof(argv[i+1]) / 60.0; X i++; X if (((i+1) < argc) && (notarg(argv[i+1]))) { X if (obs_lon > 0) X obs_lon += atof(argv[i+1]) / 3600.0; X else X obs_lon -= atof(argv[i+1]) / 3600.0; X i++; X }; X }; X }; X break; X case 'l': X /* Latitude */ X /* One to three arguments, floating point */ X if (((i+1) < argc) && (notarg(argv[i+1]))) { X obs_lat = atof(argv[i+1]); X i++; X if (((i+1) < argc) && (notarg(argv[i+1]))) { X if (obs_lat > 0) X obs_lat += atof(argv[i+1]) / 60.0; X else X obs_lat -= atof(argv[i+1]) / 60.0; X i++; X if (((i+1) < argc) && (notarg(argv[i+1]))) { X if (obs_lat > 0) X obs_lat += atof(argv[i+1]) / 3600.0; X else X obs_lat -= atof(argv[i+1]) / 3600.0; X i++; X }; X }; X }; X break; X case 'z': /* time Zone */ X if (((i+1) < argc) && (notarg(argv[i+1]))) { X i++; X obs_zone = atof(argv[i]); X }; X break; X case 'a': /* altitude, meters */ X if (((i+1) < argc) && (notarg(argv[i+1]))) { X i++; X obs_height = atof(argv[i]); X }; X break; X case 'd': X /* start_day [end_day [interval]] */ X if (((i+1) < argc) && (notarg(argv[i+1]))) { X str_to_cal(argv[i+1], &dy, &mo, &yr); X if (yr == 0) yr = start_year; X start_day = dy; X start_month = mo; X start_year = yr; X cal_to_jd(start_day, start_month, start_year, &start_date); X i++; X if (((i+1) < argc) && (notarg(argv[i+1]))) { X str_to_cal(argv[i+1], &dy, &mo, &yr); X if (yr == 0) yr = end_year; X end_day = dy; X end_month = mo; X end_year = yr; X cal_to_jd(end_day, end_month, end_year, &end_date); X i++; X if (((i+1) < argc) && (notarg(argv[i+1]))) { X interval_days = atof(argv[i+1]); X i++; X }; X } else { X end_date = start_date; X end_day = start_day; X end_month = start_month; X end_year = start_year; X }; X }; X break; X case 'o': X cp1 = &argv[i][2]; X if (*cp1) { X /* Select output files */ X do_sif = do_star = do_eph = do_obs = do_altaz = FALSE; X while (*cp1) X switch (*cp1++) { X case 'a': X do_altaz = TRUE; X break; X case 'e': X do_eph = TRUE; X break; X case 'i': X do_sif = TRUE; X break; X case 'o': X do_obs = TRUE; X break; X case 's': X do_star = TRUE; X break; X default: X break; X }; X } else X do_sif = do_star = do_eph = do_obs = do_altaz = TRUE; X X /* outfile_root */ X if (((i+1) < argc) && (notarg(argv[i+1]))) { X outfile_root = argv[i+1]; X i++; X }; X break; X case 'p': X /* [planetlist_string] */ X if (((i+1) < argc) && (notarg(argv[i+1]))) { X j = 0; X i++; X#ifdef SYSV X if (strchr(argv[i], 'M')) planet_list[0] = TRUE; X if (strchr(argv[i], 'V')) planet_list[1] = TRUE; X if (strchr(argv[i], 'm')) planet_list[2] = TRUE; X if (strchr(argv[i], 'J')) planet_list[3] = TRUE; X if (strchr(argv[i], 's')) planet_list[4] = TRUE; X if (strchr(argv[i], 'U')) planet_list[5] = TRUE; X if (strchr(argv[i], 'N')) planet_list[6] = TRUE; X#else X if (index(argv[i], 'M')) planet_list[0] = TRUE; X if (index(argv[i], 'V')) planet_list[1] = TRUE; X if (index(argv[i], 'm')) planet_list[2] = TRUE; X if (index(argv[i], 'J')) planet_list[3] = TRUE; X if (index(argv[i], 's')) planet_list[4] = TRUE; X if (index(argv[i], 'U')) planet_list[5] = TRUE; X if (index(argv[i], 'N')) planet_list[6] = TRUE; X#endif X } else { X for (j = 0; j < 7; j++) X planet_list[j] = TRUE; X }; X break; X case 's': X /* either -s or -si */ X satellites = TRUE; X for (j = 0; j < 7; j++) X planet_list[j] = TRUE; X if (argv[i][2] == 'i') X invert_sats = TRUE; X break; X case 'n': X if (((i+1) < argc) && (notarg(argv[i+1]))) { X i++; X obj_name = argv[i]; X }; X /* name */ X break; X case 'f': X /* file format */ X if (((i+2) < argc) && (notarg(argv[i+1])) && (notarg(argv[i+2]))) { X infile_name = argv[i+1]; X in_type = tr_format(argv[i+2]); X if (in_type == no_format) { X fprintf(stderr, "%s: format %s not recognized.\n", progname, X argv[i+2]); X exit(1); X }; X i += 2; X file_input = TRUE; X }; X break; X case 'h': X usage(); X break; X default: X fprintf(stderr, "%s: error, unrecognized command line argument %s\n", X progname, argv[i]); X usage(); X break; X }; X} X X X/* translate string to format */ Xfformat_t tr_format(s) Xchar *s; X{ X int i = -1; X while (s[++i]) if (isupper(s[i])) s[i] = tolower(s[i]); X X if (!strcmp(s, "emp")) return emp; X else if (!strcmp(s, "empb")) return empb; X else if (!strcmp(s, "aa")) return aa; X else if (!strcmp(s, "st")) return st; X else if (!strcmp(s, "iau")) return iau; X else if (!strcmp(s, "ell_e")) return ell_e; X else if (!strcmp(s, "par_e")) return par_e; X else if (!strcmp(s, "obj")) return obj; X else return no_format; X} X END_OF_FILE if test 21792 -ne `wc -c <'observe/main.c'`; then echo shar: \"'observe/main.c'\" unpacked with wrong size! fi # end of 'observe/main.c' fi echo shar: End of archive 11 \(of 32\). cp /dev/null ark11isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 32 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0