-
Notifications
You must be signed in to change notification settings - Fork 67
/
astrolog.cpp
3290 lines (3097 loc) · 96.8 KB
/
astrolog.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** Astrolog (Version 7.70) File: astrolog.cpp
**
** IMPORTANT NOTICE: Astrolog and all chart display routines and anything
** not enumerated below used in this program are Copyright (C) 1991-2024 by
** Walter D. Pullen ([email protected], http://www.astrolog.org/astrolog.htm).
** Permission is granted to freely use, modify, and distribute these
** routines provided these credits and notices remain unmodified with any
** altered or distributed versions of the program.
**
** The main ephemeris databases and calculation routines are from the
** library SWISS EPHEMERIS and are programmed and copyright 1997-2008 by
** Astrodienst AG. Use of that source code is subject to license for Swiss
** Ephemeris Free Edition at https://www.astro.com/swisseph/swephinfo_e.htm.
** This copyright notice must not be changed or removed by any user of this
** program.
**
** Additional 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 ([email protected]). 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.
**
** The original planetary calculation routines used in this program have
** been copyrighted and the initial core of this program was mostly a
** conversion to C of the routines created by James Neely as listed in
** 'Manual of Computer Programming for Astrologers', by Michael Erlewine,
** available from Matrix Software.
**
** Atlas composed using data from https://www.geonames.org/ licensed under a
** Creative Commons Attribution 4.0 License. Time zone changes composed using
** public domain TZ database: https://data.iana.org/time-zones/tz-link.html
**
** The PostScript code within the core graphics routines are programmed
** and Copyright (C) 1992-1993 by Brian D. Willoughby ([email protected]).
**
** More formally: This program is free software; you can redistribute it
** and/or modify it under the terms of the GNU General Public License as
** published by the Free Software Foundation; either version 2 of the
** License, or (at your option) any later version. This program is
** distributed in the hope that it will be useful and inspiring, but
** WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details, a copy of which is in the
** LICENSE.HTM file included with Astrolog, and at http://www.gnu.org
**
** Initial programming 8/28-30/1991.
** X Window graphics initially programmed 10/23-29/1991.
** PostScript graphics initially programmed 11/29-30/1992.
** Last code change made 4/22/2024.
*/
#include "astrolog.h"
/*
******************************************************************************
** Program Dispatch Procedures.
******************************************************************************
*/
// Initialize the Ansi color arrays with the color to print each object in.
void InitColors(void)
{
int *rgObjRuler = ruler1, i, k;
// Figure out which rulership set to use for "Element" color.
if (ignore7[rrStd]) {
if (!ignore7[rrExa]) rgObjRuler = exalt;
else if (!ignore7[rrEso]) rgObjRuler = rgObjEso1;
else if (!ignore7[rrHie]) rgObjRuler = rgObjHie1;
else if (!ignore7[rrRay]) rgObjRuler = NULL;
}
// Determine and assign the color of each planet.
for (i = 0; i <= oNorm; i++) {
k = kObjU[i];
if (k == kRay || rgObjRuler == NULL)
k = kRayA[rgObjRay[i]];
else if (k == kElement)
k = kElemA[(rgObjRuler[i]-1) & 3];
else if (k == kPlanet)
k = kObjA[!FBetween(i, cobLo, cobHi) ? ObjOrbit(i) :
oJup + (i - cobLo)] ^ 8;
kObjA[i] = k;
}
// Determine and assign the color of each star.
EnsureStarBright();
k = kObjU[starLo];
for (i = starLo; i <= starHi; i++)
kObjA[i] = (k >= kNull ? KStarA(rStarBright[i-starLo+1]) : k);
}
// 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(void)
{
char sz[cchSzMax];
int cSequenceLine = us.cSequenceLine, iList, iList2, iLine, i;
flag fDoList, fHTML, fHTMLClip;
// If the -os switch is in effect, open a file and set a global to
// internally 'redirect' all screen output to.
if (is.szFileScreen) {
is.S = fopen(is.szFileScreen, "w");
if (is.S == NULL) {
sprintf(sz, "File %s can not be created.", is.szFileScreen);
PrintError(sz);
is.S = stdout;
}
} else
is.S = stdout;
is.cchRow = is.cchCol = is.cchColMax = 0;
// If the -kh switch is in effect, start outputting a new HTML file.
fHTML = us.fTextHTML && !us.fGraphics && is.S != stdout;
if (fHTML) {
fHTMLClip = is.nHTML < 0;
is.nHTML = 2;
if (fHTMLClip)
PrintSz("Version:0.9\n"
"StartHTML:00000161\n"
"EndHTML:00010000\n"
"StartFragment:00000196\n"
"EndFragment:00010000\n");
sprintf(sz, "<html>\n<head><meta charset=\"UTF-8\"><title>Astrolog %s"
"</title></head>\n<body>", szVersionCore); PrintSz(sz);
if (fHTMLClip)
PrintSz("\n<!--StartFragment -->\n");
PrintSz("<font face=\"Courier\">");
is.nHTML = 3;
} else
is.nHTML = 0;
if (us.nCharsetOut == ccUTF8 && is.S != stdout)
fprintf(is.S, "%c%c%c", 0xef, 0xbb, 0xbf);
// If the -5e switch is in effect, loop over all charts in chart list.
fDoList = (us.nListAll > 0 && !us.fGraphics && is.cci > 0 &&
!(us.nListAll == 3 && is.cci < 2));
iList = (us.nListAll == 3); iList2 = 0;
LNextList:
if (fDoList) {
is.iciIndex1 = iList; is.iciIndex2 = iList2;
if (us.nListAll == 1)
ciCore = ciMain = is.rgci[iList];
else if (us.nListAll == 2)
ciTwin = is.rgci[iList];
else {
ciCore = ciMain = is.rgci[iList];
ciTwin = is.rgci[iList2];
}
}
iLine = 0;
LNextLine:
if (iLine < cSequenceLine && is.rgszLine[iLine] != NULL)
FProcessCommandLine(is.rgszLine[iLine]);
is.fMult = fFalse;
is.fNoEphFile = fFalse;
InitColors();
AnsiColor(kDefault);
// First adjust the restriction status of the cusps, Uranians, stars, and so
// on, 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.fDwarf)
for (i = dwarfLo; i <= dwarfHi; i++)
ignore[i] = ignore2[i] = fTrue;
if (!us.fMoons)
for (i = moonsLo; i <= moonsHi; i++)
ignore[i] = ignore2[i] = fTrue;
if (!us.fCOB)
for (i = cobLo; i <= cobHi; i++)
ignore[i] = ignore2[i] = fTrue;
if (!us.fStar)
for (i = starLo; i <= starHi; i++)
ignore[i] = ignore2[i] = fTrue;
if (FPrintTables()) // Print out any generic tables specified.
goto LDone; // If nothing else to do, then exit right away.
if (is.fMult) {
PrintL2();
is.fMult = fFalse;
}
// Here either do a normal chart or some kind of relationship chart.
if (!us.nRel) {
#ifndef WIN
// If chart info not in memory yet, then prompt the user for it.
if (!is.fHaveInfo && !FInputData(szTtyCore))
return;
ciMain = ciCore;
CastChart(1);
#else
ciMain = ciCore;
if (wi.fCast || cSequenceLine > 0 || fDoList) {
wi.fCast = fFalse;
CastChart(1);
}
#endif
} else {
ciMain = ciCore;
CastRelation();
}
#ifndef WIN
ciSave = ciMain;
#endif
#ifdef GRAPH
if (us.fGraphics) {
// If in -X graphics mode, go make a graphics chart.
FActionX();
iLine = cSequenceLine; // Once any graphics drawn, stop looping!
} else
#endif
{
// If not in graphics mode, print a text only chart on screen.
#ifdef GRAPH
if (gs.fInverse) {
SwapN(kBlackA, kWhiteA);
SwapN(kLtGrayA, kDkGrayA);
AnsiColor(kDefault);
}
#endif
#ifdef EXPRESS
// Notify AstroExpression a chart is about to be drawn.
if (!us.fExpOff && FSzSet(us.szExpDisp1))
ParseExpression(us.szExpDisp1);
#endif
PrintChart(is.fProgress);
#ifdef EXPRESS
// Notify AstroExpression a chart has just been drawn.
if (!us.fExpOff && FSzSet(us.szExpDisp2))
ParseExpression(us.szExpDisp2);
#endif
#ifdef GRAPH
if (gs.fInverse) {
SwapN(kBlackA, kWhiteA);
SwapN(kLtGrayA, kDkGrayA);
}
#endif
}
LDone:
iLine++;
if (iLine < cSequenceLine) {
if (!us.fGraphics)
PrintL2();
goto LNextLine;
}
if (fDoList) {
if (us.nListAll >= 3) {
iList2++;
if (iList2 < (us.nListAll >= 4 ? is.cci : iList)) {
PrintL2();
goto LNextList;
}
iList2 = 0;
}
iList++;
if (iList < is.cci) {
PrintL2();
goto LNextList;
}
is.iciIndex1 = is.iciIndex2 = -1;
}
if (fHTML) { // If -kh switch in effect, end the HTML file.
is.nHTML = 2;
PrintSz("</font>\n</font>");
if (fHTMLClip)
PrintSz("\n<!--EndFragment-->\n");
PrintSz("</body>\n</html>\n");
is.nHTML = 0;
}
if (us.fWriteFile) // If -o switch in effect, then write the chart
FOutputData(); // information to a file.
if (is.S != stdout) // If were internally directing chart display to a
fclose(is.S); // file as with the -os switch, close it here.
}
#ifndef WIN
// 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(void)
{
us.fInterpret = us.fProgress = is.fHaveInfo = is.fMult = fFalse;
us.nRel = rcNone;
FCloneSz(NULL, &is.szFileScreen);
ClearB((pbyte)&us.fListing, (int)((pbyte)&us.fLoop - (pbyte)&us.fListing));
}
#endif
/*
******************************************************************************
** 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.
flag FProcessCommandLine(CONST char *szLine)
{
char szCommandLine[cchSzLine], *rgsz[MAXSWITCHES];
int argc, cb;
flag fT = fFalse;
FILE *fileT;
if (szLine == NULL || *szLine == chNull)
return fTrue;
cb = CchSz(szLine)+1;
// Check for filename on command line.
if (!FChSwitch(szLine[0])) {
fileT = fopen(szLine, "r");
if (fileT != NULL) {
fclose(fileT);
sprintf(szCommandLine, "-i \"%s\"", szLine);
fT = fTrue;
}
}
// Parse and process the command line.
if (!fT)
CopyRgb((byte *)szLine, (byte *)szCommandLine, cb);
argc = NParseCommandLine(szCommandLine, rgsz);
fT = FProcessSwitches(argc, rgsz);
if (!fT) {
sprintf(szCommandLine, "Failed to parse command line: %s", szLine);
PrintWarning(szCommandLine);
}
return fT;
}
// Given a 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(char *szLine, char **argv)
{
int argc = 1, fSpace = fTrue;
char *pch = szLine, chQuote = chNull;
// Split the entered line up into its individual switch strings.
while ((uchar)*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 (chQuote == chNull) {
*pch = chNull;
fSpace = fTrue;
}
}
} else {
if (fSpace) {
// First character after run of spaces, begin parameter here.
if (argc >= MAXSWITCHES-1) {
PrintWarning("Too many parameters! Rest of line ignored.");
break;
}
chQuote = (*pch == '"' || *pch == '\'') ? *pch : chNull;
argv[argc++] = pch + (chQuote != chNull);
fSpace = fFalse;
} else {
// Skip over the current string.
if (chQuote != chNull && *pch == chQuote && pch[1] < '@') {
*pch = chNull;
fSpace = fTrue;
}
}
}
pch++;
}
argv[0] = (char *)szAppNameCore;
argv[argc] = NULL; // Set last string in switch array to Null.
return argc;
}
#ifndef WIN
// 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(char *line, char *argv[MAXSWITCHES])
{
FILE *fileSav;
char sz[cchSzDef];
fileSav = is.S; is.S = stdout;
is.cchRow = 0;
AnsiColor(kWhiteA);
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);
is.S = fileSav;
InputString("Input command line", line);
PrintL();
return NParseCommandLine(line, argv);
}
#endif
// This subprocedure is like FProcessSwitches() below, except that it only
// processes one switch, namely one of the obscure -Y types.
int NProcessSwitchesRare(int argc, char **argv, int pos,
flag fOr, flag fAnd, flag fNot)
{
int darg = 0, i, j, k, l;
real r;
char ch1, ch2 = chNull;
pbyte pb;
int *lpn;
real *lpr;
#ifdef MATRIX
OE oe;
#endif
#ifdef SWISS
char szName[cchSzDef], *pch;
#endif
ch1 = argv[0][pos+1];
if (ch1 != chNull)
ch2 = argv[0][pos+2];
switch (argv[0][pos]) {
case chNull:
SwitchF(us.fSwitchRare);
break;
case 'T':
SwitchF(us.fTruePos);
break;
case 'V':
SwitchF(us.fTopoPos);
break;
case 'f':
SwitchF(us.fRefract);
break;
case 'h':
SwitchF(us.fBarycenter);
break;
case 'm':
SwitchF(us.fMoonMove);
break;
case 's':
if (argc > 1 && (r = RParseSz(argv[1], pmOffset)) != rLarge) {
if (FErrorValR("Ys", !FValidOffset(r), r, 0))
return fFalse;
us.rZodiacOffsetAll = r;
darg++;
}
SwitchF(us.fSidereal2);
break;
case 'n':
if (ch1 == '0')
SwitchF(us.fNoNutation);
else if (ch1 == 'n')
SwitchF(us.fNaturalNode);
else
SwitchF(us.fTrueNode);
break;
case 'u':
if (ch1 == '0')
SwitchF(us.fEclipseAny);
SwitchF(us.fEclipse);
break;
case 'd':
SwitchF(us.fEuroDate);
break;
case 't':
SwitchF(us.fEuroTime);
break;
case 'v':
SwitchF(us.fEuroDist);
break;
case 'r':
SwitchF(us.fRound);
break;
case 'C':
SwitchF(us.fSmartCusp);
break;
case 'O':
SwitchF(us.fSmartSave);
break;
case '8':
SwitchF(us.fClip80);
break;
case 'a':
if (ch1 == 'o') {
i = (ch2 - '0');
if (!FBetween(i, 0, 3))
i = 0;
us.nCharsetOut = i;
} else {
i = (ch1 - '0');
if (!FBetween(i, 0, 3))
i = 0;
us.nCharset = i;
}
break;
case 'Q':
if (FErrorArgc("YQ", argc, 1))
return tcError;
i = NFromSz(argv[1]);
if (FErrorValN("YQ", i < 0, i, 0))
return tcError;
us.nScrollRow = i;
darg++;
break;
case 'q':
i = (ch1 - '0');
if (!FBetween(i, 0, 9))
i = 0;
if (FErrorArgc("Yq", argc, i))
return tcError;
us.cSequenceLine = i;
for (i = 0; i < us.cSequenceLine; i++)
FCloneSz(argv[i+1], &is.rgszLine[i]);
darg += i;
break;
case 'i':
if (FErrorArgc("Yi", argc, 1))
return tcError;
i = (ch1 - '0');
if (!FBetween(i, 0, 9))
i = 0;
FCloneSz(argv[1], &us.rgszPath[i]);
is.fSwissPathSet = fFalse;
darg++;
break;
case 'o':
SwitchF(us.fWriteOld);
break;
case 'c':
SwitchF(us.fHouseAngle);
for (i = 0; i < 4; i++)
FCloneSzCore(us.fHouseAngle ? szObjName[objMax + i] :
szObjName[oAsc + i*3], (char **)&szObjDisp[oAsc + i*3],
szObjDisp[oAsc + i*3] == szObjName[oAsc + i*3]);
break;
case 'p':
SwitchF(us.fPolarAsc);
break;
case 'z':
if (ch1 == '0' && fAnd) {
us.rDeltaT = rInvalid;
break;
}
if (FErrorArgc("Yz", argc, 1))
return tcError;
if (ch1 == '0')
us.rDeltaT = RFromSz(argv[1]);
else if (ch1 == 'O')
us.rObjAddition = RFromSz(argv[1]);
else if (ch1 == 'C')
us.rCuspAddition = RFromSz(argv[1]);
else
us.lTimeAddition = NFromSz(argv[1]);
darg++;
break;
case '1':
if (FErrorArgc("Y1", argc, 2))
return tcError;
i = NParseSz(argv[1], pmObject);
if (FErrorValN("Y1", !FItem(i), i, 1))
return tcError;
j = NParseSz(argv[2], pmObject);
if (FErrorValN("Y1", !FItem(j), j, 2))
return tcError;
us.fObjRotWhole = (ch1 == '0' && !fAnd);
us.objRot1 = i;
us.objRot2 = j;
darg += 2;
break;
case 'Z':
if (FErrorArgc("YZ", argc, 1))
return tcError;
i = NFromSz(argv[1]);
if (FErrorValN("YZ", !FBetween(i, 0, 7), i, 0))
return tcError;
us.nHorizon = i;
darg++;
break;
case 'l':
if (FErrorArgc("Yl", argc, 1))
return tcError;
i = NFromSz(argv[1]);
if (FErrorValN("Yl", !FSector(i), i, 0))
return tcError;
SwitchF(pluszone[i]);
darg++;
break;
#ifdef ARABIC
case 'P':
if (FErrorArgc("YP", argc, 1))
return tcError;
i = NFromSz(argv[1]);
if (FErrorValN("YP", !FBetween(i, -1, 1), i, 0))
return tcError;
us.nArabicNight = i;
darg++;
break;
#endif
case 'b':
if (FErrorArgc("Yb", argc, 1))
return tcError;
i = NFromSz(argv[1]);
if (FErrorValN("Yb", !FValidBioday(i), i, 0))
return tcError;
us.nBioday = i;
darg++;
break;
#ifdef SWISS
case 'e':
if (FErrorArgc("Ye", argc, 2))
return tcError;
i = NParseSz(argv[1], pmObject);
if (FErrorValN("Ye", !FCust(i), i, 1))
return tcError;
i -= custLo;
j = (ch1 == 'b') + (ch1 == 'O')*2 + (ch1 == 'm')*3 + (ch1 == 'j')*4;
if (j > 0)
ch1 = ch2;
k = (j == 2 ? NParseSz(argv[2], pmObject) : NFromSz(argv[2]));
if (FErrorValN("Ye", k <= 0 && j < 4, k, 2))
return tcError;
rgObjSwiss[i] = k;
rgTypSwiss[i] = j;
rgPntSwiss[i] =
(ch1 == 'n') + (ch1 == 's')*2 + (ch1 == 'p')*3 + (ch1 == 'a')*4;
rgFlgSwiss[i] = 0;
if (j <= 1)
SwissGetObjName(szName, j <= 0 ? -k : k);
else {
if (j == 3)
k = ObjMoons(k);
sprintf(szName, "%s", FItem(k) ? szObjName[k] : szObjUnknown);
}
k = rgPntSwiss[i];
if (k > 0) {
for (pch = szName; *pch; pch++)
;
sprintf(szName + Min(3, pch-szName), "%s",
k == 1 ? "Nor" : (k == 2 ? "Sou" : (k == 3 ? "Per" : "Api")));
}
FCloneSzCore(szName, (char **)&szObjDisp[i + custLo],
szObjDisp[i + custLo] == szObjName[i + custLo]);
#ifdef GRAPH
FCloneSzCore("t", (char **)&szDrawObject[i + custLo],
szDrawObject[i + custLo] == szDrawObjectDef[i + custLo]);
FCloneSzCore("", (char **)&szDrawObject2[i + custLo],
szDrawObject2[i + custLo] == szDrawObjectDef2[i + custLo]);
#endif
k = pos + 1;
do {
ch2 = argv[0][k++];
rgFlgSwiss[i] |= (ch2 == 'H') + (ch2 == 'S')*2 + (ch2 == 'B')*4 +
(ch2 == 'N')*8 + (ch2 == 'T')*16 + (ch2 == 'V')*32;
} while (ch2);
darg += 2;
break;
#endif
#ifdef MATRIX
case 'E':
if (FErrorArgc("YE", argc, 17))
return tcError;
i = NParseSz(argv[1], pmObject);
if (FErrorValN("YE", !FHelio(i), i, 1))
return tcError;
oe.sma = RFromSz(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;
#endif
case 'U':
if (ch1 == 'b') {
SwitchF(us.fStarMagDist);
if (ch2 == '0')
SwitchF(us.fStarMagAbs);
break;
} else if (ch1 == 'x') {
if (FErrorArgc("YUx", argc, 1))
return tcError;
FCloneSz(argv[1], &us.szExoList);
darg++;
break;
}
if (FErrorArgc("YU", argc, 2))
return tcError;
i = NParseSz(argv[1], pmObject);
if (FErrorValN("YU", !FStar(i), i, 1))
return tcError;
FCloneSz(argv[2], &szStarCustom[i-oNorm]);
rStarBrightDef[0] = -1.0; // Recompute brightness
darg += 2;
break;
case 'R':
if (ch1 == 'd') {
if (FErrorArgc("YRd", argc, 1))
return tcError;
us.nSignDiv = NFromSz(argv[1]);
darg++;
break;
} else if (ch1 == 'h') {
SwitchF(us.fIgnoreAuto);
break;
} else if (ch1 == 'U') {
if (FErrorArgc("YRU", argc, 1))
return tcError;
us.fStarsList = (ch2 == '0');
FCloneSz(argv[1], &us.szStarsList);
darg++;
break;
} else if (ch1 == 'o') {
CopyRgb(ignore, ignoreMem, sizeof(ignore));
CopyRgb(ignore2, ignore2Mem, sizeof(ignore2));
CopyRgb(ignorea, ignoreaMem, sizeof(ignorea));
CopyRgb(ignorez, ignorezMem, sizeof(ignorez));
CopyRgb(ignore7, ignore7Mem, sizeof(ignore7));
ignorefMem[0] = us.fIgnoreSign; ignorefMem[1] = us.fIgnoreDir;
ignorefMem[2] = us.fIgnoreDiralt; ignorefMem[3] = us.fIgnoreDirlen;
ignorefMem[4] = us.fIgnoreAlt0; ignorefMem[5] = us.fIgnoreDisequ;
break;
} else if (ch1 == 'i') {
CopyRgb(ignoreMem, ignore, sizeof(ignore));
CopyRgb(ignore2Mem, ignore2, sizeof(ignore2));
CopyRgb(ignoreaMem, ignorea, sizeof(ignorea));
CopyRgb(ignorezMem, ignorez, sizeof(ignorez));
CopyRgb(ignore7Mem, ignore7, sizeof(ignore7));
us.fIgnoreSign = ignorefMem[0]; us.fIgnoreDir = ignorefMem[1];
us.fIgnoreDiralt = ignorefMem[2]; us.fIgnoreDirlen = ignorefMem[3];
us.fIgnoreAlt0 = ignorefMem[4]; us.fIgnoreDisequ = ignorefMem[5];
AdjustRestrictions();
break;
}
if (FErrorArgc("YR", argc, 2 + (ch1 == 'Z')*2 + (ch1 == '7')*3))
return tcError;
i = NParseSz(argv[1], pmObject); j = NParseSz(argv[2], pmObject);
if (ch1 == '0') {
us.fIgnoreSign = i != 0;
us.fIgnoreDir = j != 0;
darg += 2;
break;
} else if (ch1 == '1') {
us.fIgnoreDiralt = i != 0;
us.fIgnoreDirlen = j != 0;
darg += 2;
break;
} else if (ch1 == '2') {
us.fIgnoreAlt0 = i != 0;
us.fIgnoreDisequ = j != 0;
darg += 2;
break;
} else if (ch1 == 'Z') {
ignorez[arAsc] = i != 0;
ignorez[arMC] = j != 0;
ignorez[arDes] = NFromSz(argv[3]) != 0;
ignorez[arIC] = NFromSz(argv[4]) != 0;
darg += 4;
break;
} else if (ch1 == '7') {
ignore7[rrStd] = i != 0;
ignore7[rrEso] = j != 0;
ignore7[rrHie] = NFromSz(argv[3]) != 0;
ignore7[rrExa] = NFromSz(argv[4]) != 0;
ignore7[rrRay] = NFromSz(argv[5]) != 0;
if (!ignore7[rrRay])
EnsureRay();
darg += 5;
break;
}
if (FErrorValN("YR", !FItem(i), i, 1))
return tcError;
if (FErrorValN("YR", !FItem(j) || j < i, j, 2))
return tcError;
if (FErrorArgc("YR", argc, 3+j-i))
return tcError;
pb = ch1 == 'T' ? ignore2 : ignore;
for (k = i; k <= j; k++)
pb[k] = NFromSz(argv[3+k-i]) != 0;
darg += 3+j-i;
RedoRestrictions();
break;
case 'A':
if (ch1 == 'D') {
if (FErrorArgc("YAD", argc, 4))
return tcError;
i = NParseSz(argv[1], pmAspect);
if (FErrorValN("YAD", !FAspect2(i), i, 1))
return tcError;
FCloneSzCore(CchSz(argv[2]) >= 3 ? argv[2] : szAspectName[i],
(char **)&szAspectDisp[i], szAspectDisp[i] == szAspectName[i]);
FCloneSzCore(CchSz(argv[3]) >= 3 ? argv[3] : szAspectAbbrev[i],
(char **)&szAspectAbbrevDisp[i],
szAspectAbbrevDisp[i] == szAspectAbbrev[i]);
FCloneSzCore(CchSz(argv[4]) >= 3 ? argv[4] : szAspectGlyph[i],
(char **)&szAspectGlyphDisp[i],
szAspectGlyphDisp[i] == szAspectGlyph[i]);
darg += 4;
break;
}
if (FErrorArgc("YA", argc, 2))
return tcError;
k = ch1 == 'm' || ch1 == 'd' ? pmObject : pmAspect;
i = NParseSz(argv[1], k); j = NParseSz(argv[2], k);
k = ch1 == 'm' || ch1 == 'd' ? oNorm+1 : cAspect;
if (FErrorValN("YA", !FBetween(i, (int)(ch1 == 'o' || ch1 == 'a'), k),
i, 1))
return tcError;
if (FErrorValN("YA", !FBetween(j, 0, k) || j < i, j, 2))
return tcError;
if (FErrorArgc("YA", argc, 3+j-i))
return tcError;
lpr = ch1 == 'o' ? rAspOrb : (ch1 == 'm' ? rObjOrb :
(ch1 == 'd' ? rObjAdd : rAspAngle));
for (k = i; k <= j; k++)
lpr[k] = RFromSz(argv[3+k-i]);
darg += 3+j-i;
break;
case 'j':
if (FErrorArgc("Yj", argc, 2 + 2*(ch1 == '0') + 4*(ch1 == '7')))
return tcError;
if (ch1 == '0') {
rObjInf[oNorm1+1] = RFromSz(argv[1]);
rObjInf[oNorm1+2] = RFromSz(argv[2]);
rHouseInf[cSign+1] = RFromSz(argv[3]);
rHouseInf[cSign+2] = RFromSz(argv[4]);
darg += 4;
break;
} else if (ch1 == '7') {
rObjInf[oNorm1+3] = RFromSz(argv[1]);
rObjInf[oNorm1+4] = RFromSz(argv[2]);
rObjInf[oNorm1+5] = RFromSz(argv[3]);
rHouseInf[cSign+3] = RFromSz(argv[4]);
rHouseInf[cSign+4] = RFromSz(argv[5]);
rHouseInf[cSign+5] = RFromSz(argv[6]);
darg += 6;
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 : oNorm1);
if (FErrorValN("Yj", !FBetween(i, 0, k), i, 1))
return tcError;
if (FErrorValN("Yj", !FBetween(j, 0, k) || j < i, j, 2))
return tcError;
if (FErrorArgc("Yj", argc, 3+j-i))
return tcError;
lpr = ch1 == 'C' ? rHouseInf : (ch1 == 'A' ? rAspInf :
(ch1 == 'T' ? rTransitInf : rObjInf));
for (k = i; k <= j; k++)
lpr[k] = RFromSz(argv[3+k-i]);
darg += 3+j-i;
break;
case 'J':
if (FErrorArgc("YJ", argc, 3 - (ch1 == '0')))
return tcError;
i = NParseSz(argv[1], pmObject);
if (FErrorValN("YJ", !FNorm(i), i, 1))
return tcError;
j = NParseSz(argv[2], pmSign);
if (FErrorValN("YJ", !FBetween(j, 0, cSign), j, 2))
return tcError;
if (ch1 != '0') {
k = NParseSz(argv[3], pmSign);
if (FErrorValN("YJ", !FBetween(k, 0, cSign), k, 3))
return tcError;
}
if (ch1 == chNull) {
ruler1[i] = j;
ruler2[i] = k;
if (FBetween(i, 1, oPlu)) {
if (j != 0)
rules[j] = i;
if (k != 0)
rules[k] = i;
}
} else if (ch1 == '0') {
exalt[i] = j;
} else if (ch2 != '0') {
rgObjEso1[i] = j;
rgObjEso2[i] = k;
if (FBetween(i, 0, oPlu) || i == oVul) {
if (j != 0)
rgSignEso1[j] = i;
if (k != 0)
rgSignEso1[k] = i;
}
} else {
rgObjHie1[i] = j;
rgObjHie2[i] = k;
if (FBetween(i, 0, oPlu) || i == oVul) {
if (j != 0)
rgSignHie1[j] = i;
if (k != 0)
rgSignHie1[k] = i;
}
}
darg += 3 - (ch1 == '0');
break;
case '7':
if (FErrorArgc("Y7", argc, 2))
return tcError;
k = ch1 == 'O' ? pmObject : (ch1 == 'C' ? pmSign : 0);
i = NParseSz(argv[1], k); j = NParseSz(argv[2], k);
k = ch1 == 'O' ? oNorm : (ch1 == 'C' ? cSign : 0);
if (FErrorValN("Y7", !FBetween(i, (int)(ch1 == 'C'), k), i, 1))
return tcError;
if (FErrorValN("Y7", !FBetween(j, (int)(ch1 == 'C'), k) || j < i, j, 2))
return tcError;
if (FErrorArgc("Y7", argc, 3+j-i))
return tcError;
lpn = ch1 == 'O' ? rgObjRay : (ch1 == 'C' ? rgSignRay : NULL);
for (k = i; k <= j; k++) {
l = NFromSz(argv[3+k-i]);
if (FErrorValN("Y7",
!FBetween(l, (int)(ch1 == 'C'), ch1 != 'C' ? 7 : 1234567), l, 3+k-i))
return tcError;
lpn[k] = l;
}
darg += 3+j-i;