/* ** Astrolog (Version 4.40) File: astrolog.c ** ** IMPORTANT NOTICE: The graphics database and chart display routines ** used in this program are Copyright (C) 1991-1995 by Walter D. Pullen ** (astara@u.washington.edu). Permission is granted to freely use and ** distribute these routines provided one doesn't sell, restrict, or ** profit from them in any way. Modification is allowed provided these ** notices remain with any altered or edited versions of the program. ** ** The main planetary calculation routines used in this program have ** been Copyrighted and the core of this program is basically a ** conversion to C of the routines created by James Neely as listed in ** Michael Erlewine's 'Manual of Computer Programming for Astrologers', ** available from Matrix Software. The copyright gives us permission to ** use the routines for personal use but not to sell them or profit from ** them in any way. ** ** The PostScript code within the core graphics routines are programmed ** and Copyright (C) 1992-1993 by Brian D. Willoughby ** (brianw@sounds.wa.com). Conditions are identical to those above. ** ** The extended accurate ephemeris databases and formulas are from the ** calculation routines in the program "Placalc" and are programmed and ** Copyright (C) 1989,1991,1993 by Astrodienst AG and Alois Treindl ** (alois@azur.ch). The use of that source code is subject to ** regulations made by Astrodienst Zurich, and the code is not in the ** public domain. This copyright notice must not be changed or removed ** by any user of this program. ** ** Initial programming 8/28,30, 9/10,13,16,20,23, 10/3,6,7, 11/7,10,21/1991. ** X Window graphics initially programmed 10/23-29/1991. ** PostScript graphics initially programmed 11/29-30/1992. ** Last code change made 1/29/1995. */ #include "astrolog.h" /* ****************************************************************************** ** Program Dispatch Procedures. ****************************************************************************** */ /* Initialize the Ansi color arrays with the color to print each object in. */ void InitColors() { int i; kObjA[0] = kElemA[eEar]; for (i = 1; i <= 10; i++) kObjA[i] = kSignA(ruler1[i]); for (i = 11; i <= 15; i++) kObjA[i] = kMainA[8]; for (i = 16; i <= 20; i++) kObjA[i] = kMainA[6]; for (i = 1; i <= cSign; i++) kObjA[cuspLo+i-1] = kSignA(i); for (i = uranLo; i <= uranHi; i++) kObjA[i] = kRainbowA[7]; for (i = starLo; i <= starHi; i++) kObjA[i] = starbright[i-oNorm] < 1.0 ? kRainbowA[2] : kMainA[4]; } /* This is the dispatch procedure for the entire program. After all the */ /* command switches have been processed, this routine is called to */ /* actually call the various routines to generate and display the charts. */ void Action() { char sz[cchSzDef]; int i; is.fSzPersist = fFalse; is.cchRow = 0; AnsiColor(kDefault); InitColors(); if (fSouthNode) { szObjName[oSou] = "S.Node"; #ifdef INTERPRET szMindPart[oSou] = "karmic past, and area of experience but little growth"; #endif ruler1[oSou] = sLeo; } if (us.fParallel) { szAspectAbbrev[aCon] = "Par"; szAspectAbbrev[aOpp] = "CPr"; } /* First let's adjust the restriction status of the cusps, uranians, and */ /* fixed stars based on whether -C, -u, and -U switches are in effect. */ if (!us.fCusp) for (i = cuspLo; i <= cuspHi; i++) ignore[i] = ignore2[i] = fTrue; if (!us.fUranian) for (i = uranLo; i <= uranHi; i++) ignore[i] = ignore2[i] = fTrue; if (!us.nStar) for (i = starLo; i <= starHi; i++) ignore[i] = ignore2[i] = fTrue; /* If the -os switch is in effect, open a file and set a global to */ /* internally 'redirect' all screen output to. */ if (is.szFileScreen) { S = fopen(is.szFileScreen, "w"); if (S == NULL) { sprintf(sz, "File %s can not be created.", is.szFileScreen); PrintError(sz); S = stdout; } } else S = stdout; if (FPrintTables()) /* Print out any generic tables specified. */ return; /* If nothing else to do, we can exit right away. */ if (is.fMult) { PrintL2(); is.fMult = fFalse; } /* If -+ or -- switches in effect, then add the specified delta value to */ /* the date and use that as a new date before proceeding to make chart. */ if (us.dayDelta != 0) { is.JD = (real)MdyToJulian(MM, DD+us.dayDelta, YY); JulianToMdy(is.JD, &MM, &DD, &YY); } /* Here we either do a normal chart or some kind of relationship chart. */ if (!us.nRel) { /* If chart info not in memory yet, then prompt the user for it. */ if (!is.fHaveInfo && !FInputData(szTtyCore)) return; CastChart(fTrue); ciMain = ciCore; } else CastRelation(fTrue); ciSave = ciMain; #ifdef GRAPH if (us.fGraphics) /* If any of the X window switches in effect, */ FActionX(); /* then go make a graphics chart... */ else #endif PrintChart(is.fProgress); /* Otherwise print chart on text screen. */ if (us.fWriteFile) /* If -o switch in effect, then write */ FOutputData(); /* the chart information to a file. */ if (S != stdout) /* If we were internally directing chart display to a */ fclose(S); /* file as with the -os switch, close it here. */ if (grid) DeallocateFar(grid); } /* Reset a few variables to their default values they have upon startup of */ /* the program. We don't reset all variables, just the most volatile ones. */ /* This is called when in the -Q loop to reset things like which charts to */ /* display, but leave setups such as object restrictions and orbs alone. */ void InitVariables() { us.fInterpret = us.fProgress = is.fHaveInfo = is.fMult = fFalse; us.nRel = us.dayDelta = 0; is.szFileScreen = NULL; ClearB((lpbyte)&us.fListing, (int)((lpbyte)&us.fLoop - (lpbyte)&us.fListing)); } /* ****************************************************************************** ** Command Switch Procedures. ****************************************************************************** */ /* Given a string representing a command line (e.g. a macro string), go */ /* parse it into its various switches and parameters, then go process them */ /* and change program settings. Basically a wrapper for other functions. */ bool FProcessCommandLine(szLine) char *szLine; { char szCommandLine[cchSzMax], *rgsz[MAXSWITCHES]; int argc, cb, fT; if (szLine == NULL) return fTrue; if (Mon != -1) ciCore = ciMain; cb = CchSz(szLine)+1; CopyRgb((byte *)szLine, (byte *)szCommandLine, cb); argc = NParseCommandLine(szCommandLine, rgsz); fT = FProcessSwitches(argc, rgsz); ciMain = ciCore; return fT; } /* Given string representing a command line, convert it to an "argv" format */ /* of an array of strings, one for each switch or parameter, i.e. exactly */ /* like the format of the command line as given when the program starts. */ int NParseCommandLine(szLine, argv) char *szLine; char **argv; { int argc = 1, fSpace = fTrue, fQuote = fFalse; char *pch = szLine; /* Split the entered line up into its individual switch strings. */ while (*pch >= ' ' || *pch == chTab) { if (*pch == ' ' || *pch == chTab) { if (fSpace) /* Skip over the current run of spaces between strings. */ ; else { /* First space after a string, end parameter here. */ if (!fQuote) { *pch = chNull; fSpace = fTrue; } } } else { if (fSpace) { /* First character after run of spaces, begin parameter here. */ if (argc >= MAXSWITCHES-1) { PrintWarning("Too many items - rest of line ignored."); break; } fQuote = (*pch == '"'); argv[argc++] = pch + fQuote; fSpace = fFalse; } else /* Skip over the current string. */ if (fQuote && *pch == '"') { *pch = chNull; fSpace = fTrue; } } pch++; } argv[0] = szAppNameCore; argv[argc] = NULL; /* Set last string in switch array to Null. */ return argc; } /* This routine is called by the main program to interactively prompt the */ /* user for command switches and parameters, entered in the same format as */ /* they would be on a command line. This needs to be called with certain */ /* systems which don't allow passing of a command line to the program, */ /* or when -Q is in effect. The result of this routine is returned to the */ /* main program which then processes it as done with a real command line. */ int NPromptSwitches(line, argv) char *line, *argv[MAXSWITCHES]; { FILE *data; char sz[cchSzDef]; data = S; S = stdout; is.cchRow = 0; AnsiColor(kWhite); sprintf(sz, "** %s version %s ", szAppName, szVersionCore); PrintSz(sz); sprintf(sz, "(See '%cHc' switch for copyrights and credits.) **\n", chSwitch); PrintSz(sz); AnsiColor(kDefault); PrintSz("Enter all parameter options below. "); sprintf(sz, "(Enter '%cH' for help. Enter '.' to exit.)\n", chSwitch); PrintSz(sz); S = data; InputString("Input command line", line); PrintL(); return NParseCommandLine(line, argv); } /* This subprocedure is like FProcessSwitches() below, except that we only */ /* process one switch, which we know to be one of the obscure -Y types. */ int NProcessSwitchesRare(argc, argv, pos, fOr, fAnd, fNot) int argc, pos; bool fOr, fAnd, fNot; char **argv; { int darg = 0, i, j, k; real r; char ch1, ch2; OE oe; lpbyte lpb; int FAR *lpn; lpreal lpr; #ifdef INTERPRET char *sz; #endif ch1 = argv[0][pos+1]; ch2 = argv[0][pos+2]; switch (argv[0][pos]) { case chNull: SwitchF(us.fSwitchRare); break; case 'n': SwitchF(us.fTrueNode); break; case 'd': SwitchF(us.fEuroDate); break; case 't': SwitchF(us.fEuroTime); break; case 'C': SwitchF(us.fSmartCusp); break; case '8': SwitchF(us.fClip80); break; case 'Q': if (argc <= 1) { ErrorArgc("YQ"); return tcError; } i = atoi(argv[1]); if (i < 0) { ErrorValN("YQ", i); return tcError; } us.nScrollRow = i; darg++; break; case 'o': SwitchF(us.fWriteOld); break; #ifdef ARABIC case 'P': if (argc <= 1) { ErrorArgc("YP"); return tcError; } i = atoi(argv[1]); if (!FBetween(i, -1, 1)) { ErrorValN("YP", i); return tcError; } us.nArabicNight = i; darg++; break; #endif case 'E': if (argc <= 17) { ErrorArgc("YE"); return tcError; } i = NParseSz(argv[1], pmObject); if (!FHelio(i)) { ErrorValN("YE", i); return tcError; } oe.sma = atof(argv[2]); oe.ec0 = atof(argv[3]); oe.ec1 = atof(argv[4]); oe.ec2 = atof(argv[5]); oe.in0 = atof(argv[6]); oe.in1 = atof(argv[7]); oe.in2 = atof(argv[8]); oe.ap0 = atof(argv[9]); oe.ap1 = atof(argv[10]); oe.ap2 = atof(argv[11]); oe.an0 = atof(argv[12]); oe.an1 = atof(argv[13]); oe.an2 = atof(argv[14]); oe.ma0 = atof(argv[15]); oe.ma1 = atof(argv[16]); oe.ma2 = atof(argv[17]); rgoe[IoeFromObj(i)] = oe; darg += 17; break; case 'R': if (argc <= 2) { ErrorArgc("YR"); return tcError; } i = NParseSz(argv[1], pmObject); j = NParseSz(argv[2], pmObject); if (ch1 == '0') { ignore[0] = i != 0; ignore2[0] = j != 0; darg += 2; break; } if (!FItem(i)) { ErrorValN("YR", i); return tcError; } if (!FItem(j) || j < i) { ErrorValN("YR", j); return tcError; } if (argc <= 3+j-i) { ErrorArgc("YR"); return tcError; } lpb = ch1 == 'T' ? ignore2 : ignore; for (k = i; k <= j; k++) lpb[k] = atoi(argv[3+k-i]) != 0; darg += 3+j-i; break; case 'A': if (argc <= 2) { ErrorArgc("YA"); return tcError; } k = ch1 == 'm' || ch1 == 'd' ? pmObject : pmAspect; i = NParseSz(argv[1], k); j = NParseSz(argv[2], k); k = ch1 == 'm' || ch1 == 'd' ? cObj : cAspect; if (!FBetween(i, 1, k)) { ErrorValN("YA", i); return tcError; } if (!FBetween(j, 1, k) || j < i) { ErrorValN("YA", j); return tcError; } if (argc <= 3+j-i) { ErrorArgc("YA"); return tcError; } lpr = ch1 == 'm' ? planetorb : (ch1 == 'd' ? planetadd : aspectorb); for (k = i; k <= j; k++) lpr[k] = atof(argv[3+k-i]); darg += 3+j-i; break; case 'j': if (argc <= 2 + 2*(ch1 == '0')) { ErrorArgc("Yj"); return tcError; } if (ch1 == '0') { objectinf[oNorm+1] = atof(argv[1]); objectinf[oNorm+2] = atof(argv[2]); houseinf[cSign+1] = atof(argv[3]); houseinf[cSign+2] = atof(argv[4]); darg += 4; break; } k = ch1 == 'C' ? pmSign : (ch1 == 'A' ? pmAspect : pmObject); i = NParseSz(argv[1], k); j = NParseSz(argv[2], k); k = ch1 == 'C' ? cSign : (ch1 == 'A' ? cAspect : cObj); if (!FBetween(i, 1, k)) { ErrorValN("Yj", i); return tcError; } if (!FBetween(j, 1, k) || j < i) { ErrorValN("Yj", j); return tcError; } if (argc <= 3+j-i) { ErrorArgc("Yj"); return tcError; } lpr = ch1 == 'C' ? houseinf : (ch1 == 'A' ? aspectinf : (ch1 == 'T' ? transitinf : objectinf)); for (k = i; k <= j; k++) lpr[k] = atof(argv[3+k-i]); darg += 3+j-i; break; #ifdef INTERPRET case 'I': if (argc <= 2) { ErrorArgc("YI"); return tcError; } i = NParseSz(argv[1], ch1 == 'A' ? pmAspect : (ch1 == chNull ? pmObject : pmSign)); j = ch1 == 'A' ? cAspect : (ch1 == chNull ? oNorm : cSign); if (!FBetween(i, 1, j)) { ErrorValN("YI", i); return tcError; } if (ch1 == 'A' && ch2 == '0') ch1 = '0'; sz = SzPersist(argv[2]); switch (ch1) { case 'A': szInteract[i] = sz; break; case '0': szTherefore[i] = sz; break; case chNull: szMindPart[i] = sz; break; case 'C': szLifeArea[i] = sz; break; case 'v': szDesire[i] = sz; break; default: szDesc[i] = sz; } darg += 2; break; #endif case 'k': if (argc <= 2 + 2*(ch1 == 'C')) { ErrorArgc("Yk"); return tcError; } if (ch1 == 'C') { kElemA[eFir] = NParseSz(argv[1], pmColor) & 15; kElemA[eEar] = NParseSz(argv[2], pmColor) & 15; kElemA[eAir] = NParseSz(argv[3], pmColor) & 15; kElemA[eWat] = NParseSz(argv[4], pmColor) & 15; darg += 4; break; } k = ch1 == 'A' ? pmAspect : 0; i = NParseSz(argv[1], k); j = NParseSz(argv[2], k); k = ch1 == 'A' ? cAspect : (ch1 == '0' ? 7 : 8); if (!FBetween(i, ch1 != chNull, k)) { ErrorValN("Yk", i); return tcError; } if (!FBetween(j, ch1 != chNull, k) || j < i) { ErrorValN("Yk", j); return tcError; } if (argc <= 3+j-i) { ErrorArgc("Yk"); return tcError; } lpn = ch1 == 'A' ? kAspA : (ch1 == '0' ? kRainbowA : kMainA); for (k = i; k <= j; k++) lpn[k] = NParseSz(argv[3+k-i], pmColor) & 15; darg += 3+j-i; break; case 'F': if (argc <= 8) { ErrorArgc("YF"); return tcError; } i = NParseSz(argv[1], pmObject); if (!FItem(i)) { ErrorValN("YF", i); return tcError; } r = Mod((real)(atoi(argv[2]) + (NParseSz(argv[3], pmSign)-1)*30) + atof(argv[4])/60.0); if (!FCusp(i)) planet[i] = r; else { j = Mod12(i-(cuspLo-1)+6); if (FBetween(i, cuspLo-1+4, cuspLo-1+9)) { house[i-(cuspLo-1)] = r; house[j] = Mod(r + rDegHalf); } else { planet[i] = r; planet[cuspLo-1+j] = Mod(r + rDegHalf); } } j = atoi(argv[5]); r = (j < 0 ? -1.0 : 1.0)*((real)abs(j) + atof(argv[6])/60.0); planetalt[i] = Mod((r + rDegQuad) * 2.0) / 2.0 - rDegQuad; ret[i] = RFromD(atof(argv[7])); if (i <= oNorm) SphToRec(atof(argv[8]), planet[i], planetalt[i], &spacex[i], &spacey[i], &spacez[i]); MM = -1; darg += 8; break; #ifdef GRAPH case 'X': return NProcessSwitchesRareX(argc, argv, pos+1); #endif default: ErrorSwitch(argv[0]); return tcError; } return darg; /* Return the value to be added to argc. */ } /* Process a command switch line passed to the program. Read each entry in */ /* the argument list and set all the program modes and charts to display. */ bool FProcessSwitches(argc, argv) int argc; char **argv; { int ich, i, j; bool fNot, fOr, fAnd; real rT; char ch1, ch2, *pch; argc--; argv++; while (argc) { ch1 = argv[0][0]; fNot = fOr = fAnd = fFalse; switch (ch1) { case '=': fOr = fTrue; break; case '_': fAnd = fTrue; break; case ':': break; default: fNot = fTrue; break; } ich = 1 + FChSwitch(argv[0][0]); /* Leading dash? */ ch1 = argv[0][ich]; ch2 = ch1 == chNull ? chNull : argv[0][ich+1]; switch (argv[0][ich-1]) { case 'H': if (ch1 == 'c') SwitchF(us.fCredit); else if (ch1 == 'Y') SwitchF(us.fSwitchRare); #ifdef ISG else if (ch1 == 'X') SwitchF(us.fKeyGraph); #endif else if (ch1 == 'C') SwitchF(us.fSign); else if (ch1 == 'O') SwitchF(us.fObject); else if (ch1 == 'A') SwitchF(us.fAspect); else if (ch1 == 'F') SwitchF(us.fConstel); else if (ch1 == 'S') SwitchF(us.fOrbitData); else if (ch1 == 'I') SwitchF(us.fMeaning); else if (ch1 == 'e') { SwitchF(us.fCredit); SwitchF(us.fSwitch); SwitchF(us.fSwitchRare); SwitchF(us.fKeyGraph); SwitchF(us.fSign); SwitchF(us.fObject); SwitchF(us.fAspect); SwitchF(us.fConstel); SwitchF(us.fOrbitData); SwitchF(us.fMeaning); } else SwitchF(us.fSwitch); break; case 'Q': if (ch1 == '0') SwitchF(us.fLoopInit); SwitchF(us.fLoop); break; case 'M': i = (ch1 == '0'); if (argc <= 1+i) { ErrorArgc("M"); return fFalse; } j = atoi(argv[1]); if (!FValidMacro(j)) { ErrorValN("M", j); return fFalse; } j--; if (i) szMacro[j] = SzPersist(argv[2]); else FProcessCommandLine(szMacro[j]); argc -= 1+i; argv += 1+i; break; case 'Y': i = NProcessSwitchesRare(argc, argv, ich, fOr, fAnd, fNot); if (i < 0) return fFalse; argc -= i; argv += i; break; /* Switches which determine the type of chart to display: */ case 'v': if (ch1 == '0') SwitchF(us.fVelocity); SwitchF(us.fListing); break; case 'w': if (ch1 == '0') SwitchF(us.fWheelReverse); if (argc > 1 && (i = atoi(argv[1]))) { argc--; argv++; if (!FValidWheel(i)) { ErrorValN("w", i); return fFalse; } us.nWheelRows = i; } SwitchF(us.fWheel); break; case 'g': if (ch1 == '0' || ch2 == '0') SwitchF(us.fGridConfig); if (ch1 == 'a') SwitchF(us.fAppSep); else if (ch1 == 'p') SwitchF(us.fParallel); #ifdef X11 else if (ch1 == 'e') { if (argc <= 1) { ErrorArgc("geometry"); return fFalse; } gs.xWin = atoi(argv[1]); if (argc > 2 && (gs.yWin = atoi(argv[2]))) { argc--; argv++; } else gs.yWin = gs.xWin; if (!FValidGraphx(gs.xWin)) { ErrorValN("geometry", gs.xWin); return fFalse; } if (!FValidGraphy(gs.yWin)) { ErrorValN("geometry", gs.yWin); return fFalse; } argc--; argv++; break; } #endif SwitchF(us.fGrid); break; case 'a': SwitchF(us.fAspList); if (ch1 == '0') { SwitchF(us.fAspSummary); ch1 = ch2; } if (ch1 == 'a') SwitchF(us.fAppSep); else if (ch1 == 'p') SwitchF(us.fParallel); break; case 'm': if (ch1 == '0') SwitchF(us.fMidSummary); SwitchF(us.fMidpoint); break; case 'Z': if (ch1 == '0') SwitchF(us.fPrimeVert); else if (ch1 == 'd') SwitchF(us.fHorizonSearch); SwitchF(us.fHorizon); break; case 'S': SwitchF(us.fOrbit); break; case 'j': if (ch1 == '0') SwitchF(us.fInfluenceSign); SwitchF(us.fInfluence); break; case 'L': if (ch1 == '0') SwitchF(us.fLatitudeCross); if (argc > 1 && (i = atoi(argv[1]))) { argc--; argv++; if (i < 1 || 160%i > 0) { ErrorValN("L", i); return fFalse; } us.nAstroGraphStep = i; } SwitchF(us.fAstroGraph); break; case 'K': if (ch1 == 'y') SwitchF(us.fCalendarYear); SwitchF(us.fCalendar); break; case 'd': if (ch1 == 'p') { i = (ch2 == 'y') + 2*(ch2 == 'Y'); #ifdef TIME j = i < 2 && (argv[0][ich+i+1] == 'n'); #else j = fFalse; #endif if (!j && argc <= 2-(i&1)) { ErrorArgc("dp"); return fFalse; } is.fProgress = us.fInDayMonth = fTrue; Dst2 = us.dstDef; Zon2 = us.zonDef; Lon2 = us.lonDef; Lat2 = us.latDef; #ifdef TIME if (j) GetTimeNow(&Mon2, &Day2, &Yea2, &Tim2, Zon2-Dst2); #endif if (i) { Mon2 = 0; if (!j) Yea2 = NParseSz(argv[1], pmYea); us.nEphemYears = i == 2 ? atoi(argv[2]) : 1; } else { if (!j) { Mon2 = NParseSz(argv[1], pmMon); Yea2 = NParseSz(argv[2], pmYea); if (!FValidMon(Mon2)) { ErrorValN("dp", Mon2); return fFalse; } } } if (!FValidYea(Yea2)) { ErrorValN("dp", Yea2); return fFalse; } if (!j) { i = 2-(i&1); argc -= i; argv += i; } } else if (ch1 == 'm' || ch1 == 'y' || ch1 == 'Y') { if (ch1 == 'y') us.nEphemYears = 1; else if (ch1 == 'Y') { if (argc <= 1) { ErrorArgc("dY"); return fFalse; } i = atoi(argv[1]); if (i < 1) { ErrorValN("dY", i); return fFalse; } us.nEphemYears = i; } SwitchF(us.fInDayMonth); Mon2 = (ch1 == 'm'); } #ifdef X11 else if (ch1 == 'i') { /* -display switch for X */ if (argc <= 1) { ErrorArgc("display"); return fFalse; } gs.szDisplay = SzPersist(argv[1]); argc--; argv++; break; } #endif else if (argc > 1 && (i = atoi(argv[1]))) { if (!FValidDivision(i)) { ErrorValN("d", i); return fFalse; } us.nDivision = i; argc--; argv++; } SwitchF(us.fInDay); break; case 'D': SwitchF(us.fInDayInf); break; case 'E': if (ch1 == 'Y' && argc <= 1) { ErrorArgc("E"); return fFalse; } SwitchF(us.fEphemeris); if (ch1 == 'y') us.nEphemYears = us.fEphemeris ? 1 : 0; else if (ch1 == 'Y') { i = atoi(argv[1]); if (i < 1) { ErrorValN("EY", i); return fFalse; } us.nEphemYears = i; } break; case 'e': SwitchF(us.fListing); SwitchF(us.fWheel); SwitchF(us.fGrid); SwitchF(us.fAspList); SwitchF(us.fMidpoint); SwitchF(us.fHorizon); SwitchF(us.fOrbit); SwitchF(us.fAstroGraph); SwitchF(us.fInfluence); SwitchF(us.fCalendar); SwitchF(us.fInDay); SwitchF(us.fInDayInf); SwitchF(us.fEphemeris); SwitchF(us.fGridConfig); SwitchF(us.fInfluenceSign); SwitchF(us.fLatitudeCross); break; case 't': SwitchF(us.fTransit); Zon2 = us.zonDef; Dst2 = us.dstDef; Lon2 = us.lonDef; Lat2 = us.latDef; if (ch1 == 'p') { is.fProgress = fTrue; ch1 = argv[0][++ich]; } if (i = (ch1 == 'y') + 2*(ch1 == 'Y')) ch1 = argv[0][++ich]; #ifdef TIME if (ch1 == 'n') { GetTimeNow(&Mon2, &Day2, &Yea2, &Tim2, Zon2-Dst2); if (i == 1) Mon2 = 0; else if (i > 1) { Mon2 = -1; Day2 = NParseSz(argv[1], pmDay); } break; } #endif if (argc <= 2 - (i & 1)) { ErrorArgc("t"); return fFalse; } if (i) { if (i == 1) Mon2 = 0; else { Mon2 = -1; Day2 = NParseSz(argv[2], pmDay); } } else { Mon2 = NParseSz(argv[1], pmMon); if (!FValidMon(Mon2)) { ErrorValN("t", Mon2); return fFalse; } } Yea2 = NParseSz(argv[2 - (i > 0)], pmYea); argc -= 2 - (i & 1); argv += 2 - (i & 1); break; case 'T': SwitchF(us.fTransitInf); Zon2 = us.zonDef; Dst2 = us.dstDef; Lon2 = us.lonDef; Lat2 = us.latDef; if (ch1 == 'p') { is.fProgress = fTrue; ch1 = argv[0][++ich]; } #ifdef TIME if (ch1 == 'n') { GetTimeNow(&Mon2, &Day2, &Yea2, &Tim2, Zon2-Dst2); break; } #endif if (argc <= 3) { ErrorArgc("T"); return fFalse; } Mon2 = NParseSz(argv[1], pmMon); Day2 = NParseSz(argv[2], pmDay); Yea2 = NParseSz(argv[3], pmYea); if (!FValidMon(Mon2)) { ErrorValN("T", Mon2); return fFalse; } else if (!FValidDay(Day2, Mon2, Yea2)) { ErrorValN("T", Day2); return fFalse; } else if (!FValidYea(Yea2)) { ErrorValN("T", Yea2); return fFalse; } argc -= 3; argv += 3; break; #ifdef ARABIC case 'P': if (argc > 1 && (i = atoi(argv[1]))) { argc--; argv++; if (!FValidPart(i)) { ErrorValN("P", i); return fFalse; } us.nArabicParts = i; } if (ch1 == 'z' || ch1 == 'n' || ch1 == 'f') { us.nArabic = ch1; ch1 = ch2; } else SwitchF(us.nArabic); if (ch1 == '0') SwitchF(us.fArabicFlip); break; #endif #ifdef INTERPRET case 'I': if (argc > 1 && (i = atoi(argv[1]))) { argc--; argv++; if (!FValidScreen(i)) { ErrorValN("I", i); return fFalse; } us.nScreenWidth = i; } SwitchF(us.fInterpret); break; #endif /* Switches which affect how the chart parameters are obtained: */ #ifdef TIME case 'n': FInputData(szNowCore); if (ch1 == 'd') TT = 0.0; else if (ch1 == 'm') { DD = 1; TT = 0.0; } else if (ch1 == 'y') { MM = DD = 1; TT = 0.0; } break; #endif case 'z': if (ch1 == '0') { if (argc <= 1 || RParseSz(argv[1], pmZon) == rLarge) { i = us.dstDef != 0.0; SwitchF(i); SS = us.dstDef = i ? 1.0 : 0.0; } else { SS = us.dstDef = RParseSz(argv[1], pmZon); if (!FValidDst(us.dstDef)) { ErrorValR("z0", us.dstDef); return fFalse; } argc--; argv++; } break; } else if (ch1 == 'l') { if (argc <= 2) { ErrorArgc("zl"); return fFalse; } OO = us.lonDef = RParseSz(argv[1], pmLon); AA = us.latDef = RParseSz(argv[2], pmLat); if (!FValidLon(us.lonDef)) { ErrorValR("zl", us.lonDef); return fFalse; } else if (!FValidLat(us.latDef)) { ErrorValR("zl", us.latDef); return fFalse; } argc -= 2; argv += 2; break; } else if (ch1 == 't') { if (argc <= 1) { ErrorArgc("zt"); return fFalse; } TT = RParseSz(argv[1], pmTim); if (!FValidTim(TT)) { ErrorValR("zt", TT); return fFalse; } argc--; argv++; break; } else if (ch1 == 'd') { if (argc <= 1) { ErrorArgc("zd"); return fFalse; } DD = NParseSz(argv[1], pmDay); if (!FValidDay(DD, MM, YY)) { ErrorValN("zd", DD); return fFalse; } argc--; argv++; break; } else if (ch1 == 'i') { if (argc <= 2) { ErrorArgc("zi"); return fFalse; } ciCore.nam = SzPersist(argv[1]); ciCore.loc = SzPersist(argv[2]); argc -= 2; argv += 2; break; } if (argc <= 1 || RParseSz(argv[1], pmZon) == rLarge) ZZ -= 1.0; else { ZZ = us.zonDef = RParseSz(argv[1], pmZon); if (!FValidZon(us.zonDef)) { ErrorValR("z", us.zonDef); return fFalse; } argc--; argv++; } break; case 'q': i = (ch1 == 'y' || ch1 == 'j') + 2*(ch1 == 'm') + 3*Def = RParseSz1 a4*ch1 == chNull + 37*ch1 == 'a') + 38*ch1 == 'ab); if (argc <= 1) { ErrorArgc("Mq); return fFalse; } if.fHaveInfo = iTrue; f (ch1 == 'ij) { is.fD = (tof(argv[1]);+rRunds; TT = RPFact[is.JD,; rulianToMdy(is.JD,-TT &MM, &DD, &YY); } TT = RegQToDc(aT = 2.40); pppppS = uZ = u.0; OO = us.lonDef ;AA = us.latDef } else i MM = D > 1)? 1ParseSz(argv[1], pmMon);: 1; }D = Ni> 2 &?NParseSz(argv[2], pmDay);: 1; }YY= NParseSz(argv[3](i&<3)(i&<2), pmYea); T = Ri> 23&?NRarseSz(argv[4], pmCim);: (c < 13&?N00 : 1.20); pppppS = ui> 27&?NRarseSz(argv[45, pmDat);: (c <> 6&?N00 : 1s.dstDef); Z = u <> 6&?NRarseSz(argv[45+ 3c <> 7), pmZon) =:us.zonDef; LO = u <> 6&?NRarseSz(argv[46+ 3c <> 7), pmZLn) =:us.zlnDef; LA = u <> 6&?NRarseSz(argv[47+ 3c <> 7), pmZLat =:us.zltDef } if (!FValidMon(MoM) { ErrorValN("zq, MoM; return fFalse; } else if (!FValidLay(DD, MM, YY)) { ErrorValN("zq, DD); return fFalse; } else if (!FValidYea(Ye)) { ErrorValN("zq, DY); } T return fFalse; } else if (!FValidYim(TT)) { ErrorValR("zq, TT); return fFalse; } else if (!FValidLat(aSS) { ErrorValR("zq, TSS) return fFalse; } else if (!FValidLon(uZZ) { ErrorValR("za, TZZ) return fFalse; } else if (!FValidLan(uOO) { ErrorValR("za, TOO) return fFalse; } else if (!FValidLat(uAA) { ErrorValR("za, TAA; return fFalse; } } Yrgc -= i; argv += i; break; /ase 'qi: if (argc >= 1) { ErrorArgc("Ei); return fFalse; } if (iFInputData(srgv[1]))) return fFalse; }rgc--; argv++; }reak; /ase 'q>: ih1 = '0s' }* Fill therughb*/ case 'vo: if (argc >= 1) { ErrorArgc("Eo); return fFalse; } if (ih1 == 'is) { is.fzFileScreen = NzPersist(argv[1]); argc--; argv++; break; } else if (ch1 == 'i') SwitchF(us.fWhiteOost; SwitchF(us.fLriteFile) ; if.fzFileSutp= NzPersist(argv[1]); f (i .fSzPersist { is.fgsz)ommant l argv[ bo a Ergc--; argv++; b is.fcz)ommant +; } ehile (argc)> 1 && (!ChSwitch(argv[01[0]);) } break; c* Switches which affect hwat wnformation ts ?usd in tachart */ case 'vR: if (ch1 == '0A) { ihile (argc)> 1 && (( = NParseSz(argv[1], pmOspect);) Mf (iFIspect)i)) { E ErrorValN("zRA, i); return fFalse; } else { S aspectorb)i] = R-DegHalf) rrgc--; argv++; b i} break; } if (ah1 == 'T' { ch = c(har **)gnore2 ci1 = argv[0][++ich]; } else Sch = c(har **)gnore2 f (ch1 == 'i') Sor (i = 1; i <= cSbje i++) i Sch i] = fTrue; iiiiilse if (ch1 == 'i1 { or (i = 1; i <= cSbje i++) i Sch i] = fTalse; u.fCusp)= us.fEranian)= us.fStar)= fTrue; iiiii}else if (ch1 == 'C') Sor (i = cuspLo; i <= cuspHi; i++) iiiiiwitchF(uch i] ; else if (ch1 == 'du) Sor (i = cranLo; i <= uranHi; i++) iiiiiwitchF(uch i] ; else if (ch1 == 'dU) Sor (i = ctarLo; i <= starHi; i++) iiiiiwitchF(uch i] ; else if (crgc <= 1 || R(!ParseSz(argv[1], pmObject);) { or (i = 1oChi i <= soVes i++) iiiiiwitchF(uch i] ; e or (i = 1oLil i <= soEP i++) iiiiiwitchF(uch i] ; e ihile (argc)> 1 && (( = NParseSz(argv[1], pmObject);) } if (!FVtem(i)) { EEEEErrorValN("zR, i); return fFalse; } else { SSitchF(uch i] ; e argc--; argv++; } reak; /ase 'qC: SwitchF(us.fTusp); b reak; /ase 'qu: SwitchF(us.fTranian) b reak; /ase 'qU: if (ch1 == '0' || ch1 == 'fb || ch1 == 'f' || ch1 == 'nl) us.nEtar)= fh1; lse SwitchF(us.nAtar) b reak; /ase 'qA: if (ch1 == 0vo:&& ch2 == 0vm:&& ch2 == 0vd:&& ch2 == 0va) { if (argc <= 1) { ErrorArgc("zA); return fFalse; } is= NParseSz(argv[1], pmOspect); } if (!FValidMspect)i)) { ErrorValN("zA, i); return fFalse; } us.nAstp= i; argc--; argv++; } else { f (argc <= 2) { ErrorArgc("zA); return fFalse; } is= NParseSz(argv[1], ph1 == 'no || ch1 == 'na ? pmAspect : pmObject); i f (a < 1 || 1 <> (h1 == 'no || ch1 == 'na ? pAspect : (Norm) { ErrorValN("zA, i); return fFalse; } urT= RParseSz(argv[2], p0; i f (arT= DegHax] { ErrorValR("zA, irT; return fFalse; } if (!h1 == 'no iiiiispectorb)i] = RT; ccccccclse if (ch1 == 'm') i Scanetorb i] = RT; ccccccclse if (ch1 == 'md) i Scanetoddei] = RT; ccccccclse iiiiispectongelei] = RT; cccccccrgc -= 2; argv += 2; break; c* Switches which affect how tachart inscommutDd: */ # case 'qb: if (ch1 == '0') SwitchF(us.fLSeonvdt; ifdef TPLACALC SwitchF(us.fTPlaall); endif if.fLSeonvdt= us.fESeonvdt b reak; /ase 'qc: if (argc >= 1) { ErrorArgc("Ec); return fFalse; } if= NParseSz(argv[1], pmOSstems; if (!FValidMSstemsi)) { rrorValN("zc, i); eturn fFalse; } is.nAHuse[Sstems= i; rgc--; argv++; }reak; /ase 'qs: if (argc > 1 && (i(rT= Rtof(argv[1]);)!= 0.0;|| cFNumC(argv[01[0]);) { argc--; argv++; is.nrZodiacOffst = uT; ccccc if (ah1 == 'Tr) SwitchF(us.fLEqutofr; else if (ch1 == 'dh) us.nEegHFrm : 1; lse if (ch1 == 'md) i s.nEegHFrm : 12 lse if (ch1 == 'mz) i s.nEegHFrm : 10 lse SwitchF(us.nSigdrisa); break; case 'mh: if (argc > 1 && (i = aParseSz(argv[1], pmObject);) { rgc--; argv++; } else is= N1 f (i < 0 ?| 1 <= 'oMo m| 1!Fbject)i) {| 1 <> ranHi; { rrorValN("zh, i); eturn fFalse; } is.nbjeCntere= i; ch = szLbjeame,0]; f szLbjeame,0];= szLbjeame,0s.nbjeCntere; f szLbjeame,0s.nbjeCntere; pch f (is.nbjeCntere=<'oMo i s.nbjeCntere= i1-s.nbjeCntere break; case 'mp: if (aAnd, { us.nProgress = fTalse; }reak; } if (ah1 == 'T') { SwitchF(us.fASlatArgc) ci1 = a(rgv[0][++ich];) } is.nProgress = fTrue; ifdef TIME if (ch1 == 'n') { GetTimeNow(&Mon2 &Day2 &Yea2 &Tim2 us.zonDef)- (s.dstDef); s.JD,p= idy(tzThoulianT(on2 &ay2 &ea2 &im2 us.zstDef) us.zonDef); reak; } #endif if (ah1 == 'd') { if (argc <= 1) { ErrorArgc("zp"); return fFalse; } Ds.nrrogrDy = Stof(argv[1]); o f (is.nrrogrDy = 0.0; { ErrorValR("zpd, us.zrrogrDy ; return fFalse; } argc--; argv++; break; } if (argc >= 1) { ErrorArgc("Tp); return fFalse; } Mon2= NParseSz(argv[1], pmMon); Day2= NParseSz(argv[2], pmDay); Yea2= NParseSz(argv[3], pmYea); if (!FValidMon(Mon2) { rrorValN("z", Mon2; return fFalse; } else if (!FValidDay(Day2 Mon2 &ea2) { rrorValN("z", MDy ; eturn fFalse; } else if (!FValidYea(Yea2) { rrorValN("z", Mea); eturn fFalse; } if.fD,p= idy(tzThoulianT(on2 &ay2 &ea2 &.0; us.zstDef) us.zonDef); rgc -= 3; argv += 3; break; # base 'mx: if (argc >= 1) { ErrorArgc("Ex); return fFalse; } if= Ntoi(argv[1]); if (!FValidMHarmonici)) { rrorValN("zx, i); eturn fFalse; } is.nAHarmonic= i; rgc--; argv++; }reak; /ase 'q1: if (argc > 1 && (i = aParseSz(argv[1], pmObject);) { rgc--; argv++; } else is= NoSun if (!FVIemsi)) { rrorValN("z1, i); eturn fFalse; } is.nbjeOAstc= iAnd =?N0: ig }reak; /ase 'q2: if (argc > 1 && (i = aParseSz(argv[1], pmObject);) { rgc--; argv++; } else is= NoSun if (!FVIemsi)) { rrorValN("z2, i); eturn fFalse; } is.nbjeOAstc= iAnd =?N0: i-g }reak; /ase 'q3: SwitchF(us.fTDc(n) b reak; /ase 'qf: SwitchF(us.fTlip); break; # /ase 'qG: SwitchF(us.fTGedestc); ireak; # /ase 'qF: if (argc >= 1) { ErrorArgc("TF); return fFalse; } if= NParseSz(argv[1], pmObject); i f (!FVIemsi)) { rrorValN("zF, i); eturn fFalse; } ior cei] = R(ParseSz(argv[2], pmDign)-1)0)*(3.0;+Dc(ToDcg(tof(argv[3]);; i f (!or cei] =<0.0;|| cor cei] =>= DegHax] { rrorValR("zF, ior cei] ; eturn fFalse; } else or cei] =+= DegHax] rgc -= 3; argv += 3; break; # base 'm+: if (argc > 1 && (i = atoi(argv[1])))!= 0. { rgc--; argv++; } else is= N1 s.zsayDela == i;= 2ch1 == 'y' |? 365: (ch1 == '0' ? p3 : 1.); ireak; # /ase 'q-: ase chNull: S if (argc > 1 && (i = atoi(argv[1])))!= 0. { rgc--; argv++; } else is= N1 s.zsayDela =- i;= 2ch1 == 'y' |? 365: (ch1 == '0' ? p3 : 1.); ireak; # /* Switches wor (reltion shipand chmmuais)n2=harts */ # case 'qr: if (aAnd, { us.nnRel 0; ereak; } if 2 + 2*(cch1 == 'c')|| ch1 == 'n') +& ch2 == '0') ; if (argc >= 1) { ErrorArgc("Mr); return fFalse; } if (ih1 == 'ic) i s.nERel 0rcommos+teF lse if (ch1 == 'mm) i s.nERel 0rcidpoint) lse if (ch1 == 'md) i s.nERel 0rcDifecrnceS ifdef TBIORHYTHM lse if (ch1 == 'mb) i s.nERel 0rcBiorhythm; #endif else if (ch1 == 'C0) i s.nERel 0rcDual lse if (ch1 == 'mt) i s.nERel 0rcransitI lse if (ch1 == 'mp' { us.nnRel 0rcrogress ; us.nASlatArgc (ch2 == 'y') ; i else is.nnRel 0rcSynatroy; if.fzFileS= NzPersist(argv[1]); if.fzFileS2= SzPersist(argv[2]); f (i .fSzPnteract[ { if (!FVnputData(sf.fzFileS2) Meturn fFalse; }ciTwn = giCore.; if (!FVnputData(sf.fzFileS) Meturn fFalse; if (i =>2) { s.nnRtion1= atoi(argv[13 ; s.nnRtion2= atoi(argv[14); o f (is.nnRtion1= = s.nnRtion2 us.nERtion1= as.nnRtion2= a1 irgc -= i; argv += i; break; ifdef TIME case 'ny: if (argc >= 1) { ErrorArgc("Ey); return fFalse; } if (ih1 == 'id) i s.nERel 0rcDifecrnceS ifdef TBIORHYTHM lse if (ch1 == 'mb) i s.nERel 0rcBiorhythm; #endif else if (ch1 == 'Ct) i s.nERel 0rcransitI lse if (ch1 == 'mp' { us.nnRel 0rcrogress ; uf (ch1 == '0') S SwitchF(us.fASlatArgc) else is.nnRel 0rcDual f.fzFileS= NzPersist(argv[1]); if.fzFileS2= SzNowCore) rgc--; argv++; }reak; endif /* Switches wo arcess agaph)ics opion s */ # case 'qk: if (ch1 == '0') Ss.fArsit: 12 lse SwitchF(us.fArsit) break; ifdef TPCG # case 'qV: if (argc >= 1) { ErrorArgc("EV); return fFalse; } if= Ntoi(argv[1]); if (!FValidMTexroGwsi)) { rrorValN("zV, i); eturn fFalse; } is.snTexrows = i; }rgc--; argv++; }reak; endif ifdef GRAPH c case 'X': r i = NProcessSwitchesR(argc, argv, pch, fOr, fAnd, fNot); if (i < 0) return fFalse; awitchF(2us.fGriph)ics; rgc -= 3; argv += i; break; endif case 'z;: * Sher ; awitch fmanisbo n'tprogess ahe cesstof che cine .*/ eturn fFrue; case 'z@: * Sher ;@awitch fnscjut an sstems=flagin dictofr no-op.*/ reak; # /ase 'q.: b * S"-."ts ?usually?usd io aexitche c-Q loop.*/ Trmineate(tcFr ce) # /ase 'qB: b * SFfr no?usdfulrealsn2 &-B sunds a cbeep.*/ utDhartch1Bel); break; cefault: E ErrorSwitch(argv[0]); r return fFalse; rgc--; argv++; return dFrue; } #ifdef ARTARI * SAjotp=Abel PHILIPPE*/ ifdef TIME voi in it_tmeNonDe(voi ) { COOKIE*/onDe onDe=get_cookie('ZONE) ; f (ionDe tmeNonDe=-onDe->v.i0])*6; saylight=-onDe->v.i01]/6; } lse prnt)f("Waring): 1'ZONE) cookie notwornds. D n'tpusd -n opion \n); #endif endif /* ****************************************************************************** ** ainA Pogram. ****************************************************************************** * #ifdnef TNOMAIN /* ther minA rogram ,che ctarHing) oint)wor (stroGlog iorllws .thes ?rugtne t/ /* tbasictlly?onvist(sof ca loop pcvisdewhich aw cesd e command sine ,and c t/ /* tgoprogess ai, fbfore[arctually?ctllng) a?rugtne to di the pnet wstuff. */ #ifdef TSWITCHES voi iminAargc, argv, int argc; char **argv; { else voi iminAa) { int irgc; c char c*argv; {endif har cz)ommandLine([cchSMacx, p*gsz)[MAXSWITCHES] * Reta in tnfor fomDthe artroGlogzsa)woleS.*/ ProcessSwitcheileS(DEFAULT_INFOFILE, NULL); #ifdef ARTARI * SAjotp=Abel PHILIPPE*/ ifdef TIME n it_tmeNonDe(; endif endif LBegin: ifdef TPCG # f (is.snTexrows = 0) { ifdnef TRTARI * SAjotp=Abel PHILIPPE*/ PcStTiexrows is.snTexrows ; endif * SAjotp=Abel PHILIPPE*/ ncg(s.snTexrows ; } #endif f (is.nNotwitchesR { //////////////////////////* SGoprogmp)wor ( */ rgc - NProcmp)witches(az)ommandLine( irsz); /* Lsitches wf (w c */ rgcv 0rgz; bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb* Lo n'tphveIthe m.*/ rf.fzFPograme,= argv[0][; rf.fSzPersist = fTrue; if (iProcessSwitches(argc, argv) { f (!Fs.nNotwitchesR+& cu.fLoopInit);{ s.nNotwitchesR+ fTrue; iiiiigoo dLBegin ifdef TPCG # cf (is.snTexrows = 0) { ifdnef TRTARI * SAjotp=Abel PHILIPPE*/ PcStTiexrows is.snTexrows ; endif * SAjotp=Abel PHILIPPE*/ ncg(s.snTexrows ; } } #endif Acion () rf (is.nNoop);{ ////* SIfc-Q n tefect , looptbackand cgetawitch f/ Prnt)L2();bbbbbbbbbb* Lnformation tor (anoterechart to display:.*/ nit)Vaisabls(a; } }s.nNoop)= us.fEotwitchesR+ fTrue; iiigoo dLBegin rTrmineate(tcOK; /* Lher only?tardar)dScanceio aexitcstroGlogts ?eref */ } endif /* LNOMAIN*/ #* LrtroGlogzc*/