⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 driver.c

📁 占星术4.0源码
💻 C
📖 第 1 页 / 共 4 页
字号:
/*
** Astrolog (Version 4.00) File: driver.c
**
** IMPORTANT NOTICE: the graphics database and chart display routines
** used in this program are Copyright (C) 1991-1993 by Walter D. Pullen
** (cruiser1@stein.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 12/31/1993.
*/

#include "astrolog.h"

char *filenamescreen = NULL, *filenameout, **extralines;
int prog = FALSE, extracount = 0;


/*
******************************************************************************
** Table Display Routines.
******************************************************************************
*/

/* A subprocedure of the credit displayed below, this prints out one line */
/* of credit information on the screen. Given a string, it's displayed    */
/* centered with left and right borders around it, in the given color.    */

#define CREDITWIDTH 74

void PrintW(string, col)
char *string;
int col;
{
  int i;

  if (!string) {

    /* Null string means print the top, bottom, or a separator row. */

    if (col < 0)
      AnsiColor(RED);
    printc(col ? (col > 0 ? BOXSW : BOXNW) : BOXJE);
    PrintTab(BOXH, CREDITWIDTH);
    printc(col ? (col > 0 ? BOXSE : BOXNE) : BOXJW);
  } else {
    i = StringLen(string);
    printc(BOXV);
    PrintTab(' ', (CREDITWIDTH-i)/2 + (i&1));
    AnsiColor(col);
    fprintf(S, "%s", string);
    PrintTab(' ', (CREDITWIDTH-i)/2);
    AnsiColor(RED);
    printc(BOXV);
  }
  printl();
}


/* Display a list of credits showing those who helped create the various  */
/* parts of Astrolog, as well as important copyright and version info, as */
/* displayed with the -Hc switch.                                         */

void DisplayCredits()
{
  char string[STRING];

  PrintW(NULL, -1);
  sprintf(string, "%s version %s", appname, VERSION);
  PrintW(string, WHITE);
  sprintf(string, "As of %s", DATE);
  PrintW(string, LTGRAY);
  PrintW("By Walter D. Pullen (cruiser1@stein.u.washington.edu)", CYAN);
  PrintW(NULL, 0);
  PrintW("Main planetary calculation formulas were converted from", GREEN);
  PrintW(
    "routines by James Neely, as listed in 'Manual of Computer Programming",
    GREEN);
  PrintW(
    "for Astrologers' by Michael Erlewine, available from Matrix Software.",
    GREEN);
  PrintW("PostScript graphics routines by Brian D. Willoughby", YELLOW);
  PrintW(
    "Extended ephemeris calculation and formulas are by Alois Treindl,",
    MAGENTA);
  PrintW(
    "as in the package 'Placalc', available from Astrodienst AG.", MAGENTA);
  PrintW(
    "IMPORTANT: Astrolog is 'freeware', but is copyrighted and not in public",
    LTGRAY);
  PrintW(
    "domain. Permission is granted to freely use and distribute these",
    LTGRAY);
  PrintW(
    "routines provided one does not sell, restrict, or profit from the",
    LTGRAY);
  PrintW(
    "program or its output in any way. Modification is allowed provided",
    LTGRAY);
  PrintW(
    "these exact notices remain with any altered or edited versions of the",
    LTGRAY);
  PrintW(
    "program. These conditions are true of both the program in whole and of",
    LTGRAY);
  PrintW(
    "all parts by any individual author. Violators are subject to copyright",
    LTGRAY);
  PrintW(
    "law penalties, and negative karmic debts to aforementioned contributors.",
    LTGRAY);
  PrintW(NULL, 0);
  PrintW(
    "Special thanks to all those unmentioned, seen and unseen, who have",
     BLUE);
  PrintW(
    "pointed out problems, suggested featues, and sent many positive vibes!",
    BLUE);
  PrintW(NULL, 1);
  AnsiColor(DEFAULT);
}


/* Print out a command switch or keypress info line to the screen, as done  */
/* with the -H switch or 'H' key in a graphic window. This is just printing */
/* out the string, except in Ansi mode we set the proper colors: Red for    */
/* header lines, Green for individual switches or keys, and White for the   */
/* rest of the line telling what it does. We also prefix each switch with   */
/* either Unix's '-' or PC's '/', whichever is appropriate for the system.  */

void Prints(string)
char *string;
{
  int dash;
  char c;

  dash = string[1];
  if (*string != ' ')
    AnsiColor(RED);
  else if (dash != ' ')
    AnsiColor(dash == 'P' || string[3] == ' ' || string[3] == ':' ?
      GREEN : DKGREEN);
  else
    AnsiColor(DEFAULT);
  while ((c = *string) && c != ':' &&
    (dash != 'P' || (c != ' ' || *(string+1) != 't'))) {
    if (c != '_')
      printc(c);
    else
      printc(DASH);
    string++;
  }
  if (*string)
    printc(*string++);
  AnsiColor(DEFAULT);
  while (c = *string) {
    if (c != '_')
      printc(c);
    else
      printc(DASH);
    string++;
  }
  printl();
}


/* Print a list of every command switch that can be passed to the program, */
/* and a description of what it does. This is what the -H switch prints.   */

void DisplaySwitches()
{
  char string[STRING];

  sprintf(string, "%s (version %s) command switches:", appname, VERSION);
  Prints(string);
  Prints(" _H: Display this help list.");
  Prints(" _Hc: Display program credits and copyrights.");
  Prints(" _H0: Display names of zodiac signs and houses.");
  Prints(" _O: Display available planets and other celestial objects.");
  Prints(" _O0: Like _O but ignore object restrictions.");
  Prints(" _A: Display available aspects, their angles, and present orbs.");
#ifdef INTERPRET
  Prints(" _I0: Display meanings of signs, houses, planets, and aspects.");
#endif
  Prints(" _Q: Prompt for more command switches after display finished.");
#ifdef SWITCHES
  Prints(" _Q0: Like _Q but prompt for additional switches on startup.");
#endif
  Prints("\nSwitches which determine the type of chart to display:");
  Prints(" _v: Display list of object positions (chosen by default).");
  Prints(" _v0: Like _v but express velocities relative to average speed.");
  Prints(" _w [<rows>]: Display chart in a graphic house wheel format.");
  Prints(" _w0 [..]: Like _w but reverse order of objects in houses 4..9.");
  Prints(" _g: Display aspect and midpoint grid among planets.");
  Prints(" _g0: Like _g but flag aspect configurations (e.g. Yod's) too.");
  Prints(" _g0: For comparison charts, show midpoints instead of aspects.");
  Prints(" _ga: Like _g but indicate applying instead of difference orbs.");
  Prints(" _m: Display all object midpoints in sorted zodiac order.");
  Prints(" _m0: Like _m but list aspects ordered by influence instead.");
  Prints(" _m[0]a: Like _m0 but indicate applying and separating orbs.");
  Prints(" _Z: Display planet locations with respect to the local horizon.");
#ifdef GRAPH
  Prints(" _Z0: For graphics charts, like _Z but have a polar center.");
#endif
  Prints(" _Zd: Search day for object local rising and setting times.");
  Prints(" _S: Display x,y,z coordinate positions of planets in space.");
  Prints(" _j: Display astrological influences of each object in chart.");
  Prints(" _j0: Like _j but include influences of each zodiac sign as well.");
  Prints(" _L [<step>]: Display astro-graph locations of planetary angles.");
  Prints(" _L0 [..]: Like _L but display list of latitude crossings too.");
  Prints(" _K: Display a calendar for given month.");
  Prints(" _Ky: Like _K but display a calendar for the entire year.");
  Prints(" _d: Print all aspects and changes occurring in a day.");
  Prints(" _dm: Like _d but print all aspects for the entire month.");
  Prints(" _dp <month> <year>: Print aspects within progressed chart.");
  Prints(" _dpy <year>: Like _dp but search for aspects within entire year.");
  Prints(" _D: Like _d but display aspects by influence instead of time.");
  Prints(" _E: Display planetary ephemeris for given month.");
  Prints(" _Ey: Display planetary ephemeris for the entire year.");
  Prints(" _e: Print all charts together (i.e. _v_w_g0_m_Z_S_j0_L0_K_d_D_E).");
  Prints(
    " _t <month> <year>: Compute all transits to natal planets in month.");
  Prints(
    " _tp <month> <year>: Compute progressions in month for chart.");
  Prints(" _t[p]y: <year>: Compute transits/progressions for entire year.");
#ifdef TIME
  Prints(" _t[py]n: Compute transits to natal planets for current time now.");
#endif
  Prints(" _T <month> <day> <year>: Display transits ordered by influence.");
  Prints(" _Tp <month> <day> <year>: Print progressions instead of transits.");
#ifdef TIME
  Prints(" _T[p]n: Display transits ordered by influence for current date.");
#endif
#ifdef INTERPRET
  Prints(" _I [<columns>]: Print interpretation of selected charts.");
#endif
  Prints("\nSwitches which affect how the chart parameters are obtained:");
#ifdef TIME
  Prints(" _n: Compute chart for this exact moment using current time.");
  Prints(" _n[d,m,y]: Compute chart for start of current day, month, year.");
#endif
  Prints(" _a <month> <date> <year> <time> <zone> <long> <lat>:");
  Prints("     Compute chart automatically given specified data.");
  Prints(" _z: Assume Daylight time (change default zone appropriately).");
  Prints(" _z <zone>: Change the default time zone (for _d_q_T_E options).");
  Prints(" _l <long> <lat>: Change the default longitude & latitude.");
  Prints(" _q <month> <date> <year> <time>: Compute chart with defaults.");
  Prints(" _qd <month> <date> <year>: Compute chart for noon on date.");
  Prints(" _qm <month> <year>: Compute chart for first of month.");
  Prints(" _qy <year>: Compute chart for first day of year.");
  Prints(" _qj <day>: Compute chart for time of specified Julian day.");
  Prints(" _i <file>: Compute chart based on info in file.");
  Prints(" _o <file> [..]: Write parameters of current chart to file.");
  Prints(" _o0 <file> [..]: Like _o but output planet/house positions.");
  Prints(" _os <file>: Redirect output of text charts to file.");
  Prints("\nSwitches which affect what information is used in a chart:");
  Prints(" _R [<obj1> [<obj2> ..]]: Restrict specific bodies from displays.");
  Prints(" _R0 [<obj1> ..]: Like _R but restrict everything first.");
  Prints(" _R1 [<obj1> ..]: Like _R0 but unrestrict and show all objects.");
  Prints(" _R[C,u,U]: Restrict all minor cusps, all uranians, or stars.");
  Prints(" _RT[0,1,C,u,U] [..]: Restrict transiting planets in _T lists.");
  Prints(" _C: Include non-angular house cusps in charts.");
  Prints(" _u: Include transneptunian/uranian bodies in charts.");
  Prints(" _U: Include locations of fixed background stars in charts.");
  Prints(" _U[z,l,n,b]: Order by azimuth, altitude, name, or brightness.");
  Prints(" _A <0-18>: Specify the number of aspects to use in charts.");
  Prints(" _Ao <aspect> <orb>: Specify maximum orb for an aspect.");
  Prints(" _Am <planet> <orb>: Specify maximum orb allowed to a planet.");
  Prints(" _Ad <planet> <orb>: Specify orb addition given to a planet.");
  Prints("\nSwitches which affect how a chart is computed:");
#ifdef PLACALC
  Prints(" _b: Use ephemeris files for more accurate location computations.");
  Prints(" _b0: Like _b but display locations to the nearest second too.");
#endif
  Prints(" _c <value>: Select a different default system of houses.");
  Prints("     (0 = Placidus, 1 = Koch, 2 = Equal, 3 = Campanus,");
  Prints("     4 = Meridian, 5 = Regiomontanus, 6 = Porphyry, 7 = Morinus,");
  Prints("     8 = Topocentric, 9 = None.)");
  Prints(" _s: Compute a sidereal instead of the normal tropical chart.");
  Prints(" _s0: Display locations as right ascension instead of degrees.");
  Prints(" _h [<objnum>]: Compute positions centered on specified object.");
  Prints(" _p <month> <day> <year>: Cast 2ndary progressed chart for date.");
  Prints(" _p0 <month> <day> <year>: Cast solar arc chart for date.");
#ifdef TIME
  Prints(" _p[0]n: Cast progressed chart based on current date now.");
#endif
  Prints(" _pd <days>: Set no. of days to progress / day (default 365.25).");
  Prints(" _x <1-360>: Cast harmonic chart based on specified factor.");
  Prints(" _1 [<objnum>]: Cast chart with specified object on Ascendant.");
  Prints(" _2 [<objnum>]: Cast chart with specified object on Midheaven.");
  Prints(" _3: Display objects in their zodiac decan positions.");
  Prints(" _f: Display houses as sign positions (flip them).");
  Prints(" _G: Compute houses based on geographic location only.");
  Prints(" _F <objnum> <sign> <deg>: Force object's position to be value.");
  Prints(" _+ [<days>]: Cast chart for specified no. of days in the future.");
  Prints(" _- [<days>]: Cast chart for specified no. of days in the past.");
  Prints(" _+[m,y] [<value>]: Cast chart for no. of months/years in future.");
  Prints("\nSwitches for relationship and comparison charts:");
  Prints(" _r <file1> <file2>: Compute a relationship synastry chart.");
  Prints(" _rc <file1> <file2>: Compute a composite chart.");
  Prints(" _rm <file1> <file2>: Compute a time space midpoint chart.");
  Prints(" _rd <file1> <file2>: Print time span between files' dates.");
#ifdef BIORHYTHM
  Prints(" _rb <file1> <file2>: Display biorhythm for file1 at time file2.");
#endif
  Prints(" _r0 <file1> <file2>: Keep the charts separate in comparison.");
  Prints(" _rp <file1> <file2>: Like _r0 but do file1 with progr. to file2.");
#ifdef TIME
  Prints(" _y <file>: Display current house transits for particular chart.");
#ifdef BIORHYTHM
  Prints(" _y[b,d,p] <file>: Print biorhythm/datediff for current time now.");
#endif
#endif /* TIME */
  Prints("\nSwitches to access graphics options:");
  Prints(" _k: Display text charts using Ansi characters and color.");
#ifdef MSG
  Prints(" _V: <25,43,50>: Start up with text mode set to number of rows.");
#endif

  /* If graphics features are compiled in, call an additional procedure to */
  /* display the command switches offered dealing with the graphics stuff. */

#ifdef GRAPH
  XDisplaySwitches();
#endif
}


/* Print out a list of the various objects - planets, asteroids, house     */
/* cusps, stars - recognized by the program, and their index values. This  */
/* is displayed when the -O switch is invoked. For some objects, display   */
/* additional information, e.g. ruling signs for planets, brightnesses and */
/* positions in the sky for fixed stars, etc.                              */

void PrintObjects(all)
int all;
{
  int i, j;
  real Off;

  if (!(operation & DASHC))
    for (i = C_LO; i <= C_HI; i++)    /* Set up restrictions properly: Minor */
      ignore[i] = TRUE;               /* cusps and uranians included only if */
  if (!(operation & DASHu))           /* -C and -u switches are in effect.   */
    for (i = U_LO; i <= U_HI; i++)
      ignore[i] = TRUE;
  fprintf(S, "%s planets and objects:\n", appname);
  fprintf(S, "No. Name       Rule Co-Rule Fall Co-Fall Exalt Debilitate\n\n");
  for (i = 1; i <= BASE; i++) if (all || !ignore[i]) {
    AnsiColor(objectansi[i]);
    fprintf(S, "%2d %-12s", i, objectname[i]);
    if (i <= OBJECTS) {                      /* Print rulerships, etc */
      if (ruler1[i]) {                       /* for the planets.      */
        j = ruler2[i];
        fprintf(S, "%c%c%c  %c%c%c     ", SIGNAM(ruler1[i]),
          j ? signname[j][0] : ' ', j ? signname[j][1] : ' ',
          j ? signname[j][2] : ' ');
        fprintf(S, "%c%c%c  %c%c%c     ", SIGNAM(Mod12(ruler1[i]+6)),
          j ? signname[Mod12(j+6)][0] : ' ',
          j ? signname[Mod12(j+6)][1] : ' ',
          j ? signname[Mod12(j+6)][2] : ' ');
        fprintf(S, "%c%c%c   %c%c%c", SIGNAM(exalt[i]),
          SIGNAM(Mod12(exalt[i]+6)));
      }
    } else {
      if (ruler1[i]) {
        fprintf(S, "%c%c%c          %c%c%c", SIGNAM(ruler1[i]),
          SIGNAM(Mod12(ruler1[i]+6)));
        fprintf(S, "          %c%c%c   %c%c%c", SIGNAM(exalt[i]),
          SIGNAM(Mod12(exalt[i]+6)));
      }
      if (i <= C_HI)
        fprintf(S, "  Minor House Cusp #%d", i-OBJECTS);
      else
        fprintf(S, "  Uranian #%d", i-U_LO+1);
    }
    printl();
  }

  /* Now, if -U in effect, read in and display stars in specified order. */

  if (all || universe) {
    Off = ProcessInput(TRUE);
    ComputeStars(operation & DASHs ? 0.0 : -Off);
    for (i = S_LO; i <= S_HI; i++) if (all | !ignore[i]) {
      j = BASE+starname[i-BASE];
      AnsiColor(objectansi[j]);
      fprintf(S, "%2d %-12s", i, objectname[j]);
      fprintf(S, "Star #%2d   ", i-BASE);
      PrintZodiac(planet[j]);
      fprintf(S, "    ");
      PrintAltitude(planetalt[j]);
      fprintf(S, " %5.2f\n", starbright[j-BASE]);
    }
  }
  AnsiColor(DEFAULT);
}


/* Print out a list of all the aspects recognized by the program, and info  */
/* about them: their names, index numbers, degree angles, present orbs, and */
/* the description of their glyph. This gets displayed when the -A switch   */
/* is invoked (without any argument).                                       */

void PrintAspects()
{
  int i;

  fprintf(S, "%s aspects:\nNo. Name         Abbrev. Angle    Orb", appname);
  fprintf(S, "          Description of glyph\n\n");
  for (i = 1; i <= ASPECTS; i++) {
    AnsiColor(aspectansi[i]);
    fprintf(S, "%2d %-15s(%s) %6.2f +/- %1.0f degrees - %s\n",
      i, aspectname[i], aspectabbrev[i],
      aspectangle[i], aspectorb[i], aspectglyph[i]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -