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

Function FProcessSFTextFile

io.cpp:972–1090  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

970// name or a file handle.
971
972flag FProcessSFTextFile(CONST char *szFile, FILE *file)
973{
974 char szLine[cchSzLine], *pch, *pch2;
975 int nState = -1, cch;
976 flag fHaveFile, fRet = fFalse;
977
978 fHaveFile = (file != NULL);
979 if (!fHaveFile) {
980 file = FileOpen(szFile, 0, NULL);
981 if (file == NULL)
982 goto LDone;
983 }
984 is.fileIn = file;
985 loop {
986
987 fgets(szLine, cchSzMax, file);
988 if (feof(file))
989 break;
990 for (pch = szLine; *pch; pch++)
991 ;
992 while (pch > szLine && pch[-1] <= ' ')
993 *(--pch) = chNull;
994
995 if (nState <= 0) {
996 if (*szLine == chNull)
997 continue;
998 if (nState < 0 && FMatchSz("Charts from Solar Fire", szLine))
999 continue;
1000 if (nState < 0 && FMatchSz("Created by Esoteric Technologies", szLine)) {
1001 nState = 0;
1002 continue;
1003 }
1004 if (nState == 0)
1005 nState = 1;
1006 else
1007 break;
1008 }
1009 if (nState == 1) {
1010 for (pch = szLine; *pch; pch++)
1011 ;
1012 cch = pch - szLine;
1013 if (cch > 14 && FEqRgch(pch - 14, " - Natal Chart", 14, fFalse))
1014 pch[-14] = chNull;
1015 else if (cch > 13 && FEqRgch(pch - 13, " - Male Chart", 13, fFalse))
1016 pch[-13] = chNull;
1017 else if (cch > 15 && FEqRgch(pch - 15, " - Female Chart", 15, fFalse))
1018 pch[-15] = chNull;
1019 ciCore.nam = SzClone(szLine);
1020 nState = 2;
1021 } else if (nState == 2) {
1022 for (pch = szLine; *pch && *pch <= ' '; pch++)
1023 ;
1024 while (*pch > ' ')
1025 pch++;
1026 if (*pch == ' ')
1027 *pch++ = chNull;
1028 MM = NParseSz(szLine, pmMon);
1029 while (*pch && *pch <= ' ')

Callers 1

FInputDataFunction · 0.85

Calls 8

FileOpenFunction · 0.85
FMatchSzFunction · 0.85
FEqRgchFunction · 0.85
SzCloneFunction · 0.85
NParseSzFunction · 0.85
RParseSzFunction · 0.85
PrintWarningFunction · 0.85
FAppendCIListFunction · 0.85

Tested by

no test coverage detected