MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / FOutputQuickFile

Function FOutputQuickFile

io.cpp:715–784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

713// format file, as indicated by the -oq switch.
714
715flag FOutputQuickFile(void)
716{
717 char sz[cchSzMax];
718 FILE *file = NULL;
719 real rOff, rDst, rLon, rLat;
720 int i, iMax, j, k, j2, k2, fSav1;
721 flag fRet = fFalse, fSav2;
722 CI *pci;
723
724 if (us.fNoWrite)
725 goto LDone;
726 file = fopen(is.szFileOut, "w"); // Create and open the file for output.
727 if (file == NULL) {
728 sprintf(sz, "Quick*Chart file '%s' can not be created.", is.szFileOut);
729 PrintError(sz);
730 goto LDone;
731 }
732
733 iMax = Max(is.cci, 1);
734 for (i = 0; i < iMax; i++) {
735 pci = iMax <= 1 ? &ciMain : &is.rgci[i];
736 if (!FBetween(pci->yea, -9999, 99999)) {
737 PrintWarning("Can't save this chart to Quick*Chart format because the "
738 "Year field is more than 5 characters long.");
739 goto LDone;
740 }
741
742 // Output line of 101 characters.
743 fprintf(file, "%-23.23s", pci->nam);
744 fprintf(file, "%c%c%c", szMonth[pci->mon][0],
745 ChCap(szMonth[pci->mon][1]), ChCap(szMonth[pci->mon][2]));
746 fSav1 = us.fAnsiChar; us.fAnsiChar = 4;
747 fSav2 = us.fSeconds; us.fSeconds = fTrue;
748 fprintf(file, "%3d,%5d%s", pci->day, pci->yea, SzTim(pci->tim));
749 us.fAnsiChar = fSav1; us.fSeconds = fSav2;
750 rDst = DstReal(pci->dst);
751 rOff = GetOffsetCI(pci);
752 if (pci->zon == zonLMT || pci->zon == zonLAT)
753 sprintf(sz, "LMT");
754 else {
755 sprintf(sz, " ");
756 // Search for the 3 character time zone string that best matches offset.
757 for (j = 0; j < cZone; j++)
758 if (FSameR(rZon[j], rOff) && CchSz(szZon[j]) == 3 &&
759 FZonDst(szZon[j]) == (rDst == 1.0)) {
760 sprintf(sz, "%s", szZon[j]);
761 break;
762 }
763 }
764 rLon = RSgn(pci->lon) * (RAbs(pci->lon) + rSmall);
765 rLat = RSgn(pci->lat) * (RAbs(pci->lat) + rSmall);
766 j = (int)(RFract(RAbs(rLon))*60.0);
767 k = (int)(RFract(RAbs(rLat))*60.0);
768 j2 = (int)(RFract(RAbs(rLon))*3600.0) % 60;
769 k2 = (int)(RFract(RAbs(rLat))*3600.0) % 60;
770 fprintf(file, " %s%c%02d:%02d", sz, rOff < 0.0 ? '-' : '+',
771 (int)RAbs(rOff), (int)(RFract(RAbs(rOff))*60.0+rRound/60.0));
772 fprintf(file, "%03d%c%02d'%02d", (int)RAbs(rLon), rLon < 0.0 ?

Callers 2

FOutputDataFunction · 0.85
DlgSaveChartFunction · 0.85

Calls 6

PrintErrorFunction · 0.85
PrintWarningFunction · 0.85
SzTimFunction · 0.85
GetOffsetCIFunction · 0.85
CchSzFunction · 0.85
RSgnFunction · 0.85

Tested by

no test coverage detected