DOS_TIME CloseReadFile( UINT *pcline ) { assert(Frb.fOpen); assert(Frb.pf != NULL); assert(Frb.pszFile != NULL); if (Frb.fMakefile && DEBUG_4) { BuildError("Closing file\n"); } if (Frb.cNull > 1) { BuildError("%hu null bytes in file\n", Frb.cNull); } fclose(Frb.pf); Frb.fOpen = FALSE; Frb.pf = NULL; FreeString(&Frb.pszFile, MT_FRBSTRING); if (Frb.pfrbNext != NULL) { FILEREADBUF *pfrb; FreeMem((VOID **) &Frb.pbBuffer, MT_IOBUFFER); pfrb = Frb.pfrbNext; if (pfrb->DateTime.value < Frb.DateTime.value) { pfrb->DateTime = Frb.DateTime; // propagate subordinate timestamp } memcpy(&Frb, pfrb, sizeof(*pfrb)); FreeMem((VOID **) &pfrb, MT_FILEREADBUF); } if (pcline != NULL) { *pcline = Frb.cLine; } return(Frb.DateTime); }
void* ship_system::GetPointerByString(char *query) { ship_object* query_object; int len=0; for (int i=0; i < (int)strlen(query); i++) { if (query[i]==':') { len = i; break; } } if (len){ char buf[1000]; for (int i=0;i<len;i++) { buf[i]=query[i]; } buf[len] = '\0';; query_object=GetSystemByName(buf); if (query_object) return query_object->GetComponent(query+len+1); BuildError(1); return NULL;//requested a component of a non existent object } query_object=GetSystemByName(query);//not a component search, just the object maybe? if (query_object) return query_object; BuildError(1); return NULL; }
VOID AllocMem(UINT cb, VOID **ppv, MemType mt) { *ppv = malloc(cb + CBHEADER + CBTAIL); if (*ppv == NULL) { BuildError("(Fatal Error) malloc(%u) failed\n", cb); exit(16); } #if DBG { MEMTAB *pmt; MEMHEADER *pmh; pmh = *ppv; *ppv = GetBlock(pmh); if (mt >= MT_MAX) { mt = MT_UNKNOWN; } pmt = &MemTab[MT_TOTALS]; if (pmt->cAllocTotal == 0) { InitMem(); } pmt->cAlloc++; pmt->cAllocTotal++; pmt->cbAlloc += cb; pmt->cbAllocTotal += cb; if (cbAllocMax < pmt->cbAlloc) { cbAllocMax = pmt->cbAlloc; } if (cAllocMax < pmt->cAlloc) { cAllocMax = pmt->cAlloc; } pmt = &MemTab[mt]; pmt->cAlloc++; pmt->cAllocTotal++; pmt->cbAlloc += cb; pmt->cbAllocTotal += cb; pmh->mt = mt; pmh->cbRequest = cb; pmh->pmhNext = pmt->mh.pmhNext; pmt->mh.pmhNext = pmh; pmh->pmhPrev = pmh->pmhNext->pmhPrev; pmh->pmhNext->pmhPrev = pmh; FillTailBusy((char *) *ppv + cb); if (DEBUG_4 && DEBUG_1) { BuildError("AllocMem(%d, mt=%s) -> %lx\n", cb, pmt->pszType, *ppv); } } #endif }
BOOL ReadBuf(FILE *pf) { LPSTR p, p2; assert(pf == Frb.pf); assert(!Frb.fEof); Frb.pbNext = Frb.pbBuffer; Frb.cbBuf = fread(Frb.pbBuffer, 1, Frb.cbBuffer - 1, Frb.pf); if (Frb.cbBuf == 0) { Frb.fEof = TRUE; // no more to read return(FALSE); } if (Frb.cbTotal == 0 && Frb.cbBuf > sizeof(achzeros) && memcmp(Frb.pbBuffer, achzeros, sizeof(achzeros)) == 0) { BuildError("ignoring binary file\n"); Frb.fEof = TRUE; return(FALSE); } p = &Frb.pbBuffer[Frb.cbBuf - 1]; if (Frb.cbTotal + Frb.cbBuf < Frb.cbFile) { do { while (p > Frb.pbBuffer && *p != '\n') { p--; } p2 = p; // save end of last complete line if (p > Frb.pbBuffer && *p == '\n') { p--; if (p > Frb.pbBuffer && *p == '\r') { p--; } while (p > Frb.pbBuffer && (*p == '\t' || *p == ' ')) { p--; } } } while (*p == '\\'); if (p == Frb.pbBuffer) { BuildError("(Fatal Error) too many continuation lines\n"); exit(8); } p = p2; // restore end of last complete line Frb.cbBuf = (UINT)(p - Frb.pbBuffer + 1); } else { Frb.fEof = TRUE; // no more to read } p[1] = '\0'; Frb.cbTotal += Frb.cbBuf; return(TRUE); }
void clSSHChannel::Open() { if(IsOpen()) { return; } if(!m_ssh) { throw clException("ssh session is not opened"); } m_channel = ssh_channel_new(m_ssh->GetSession()); if(!m_channel) { throw clException(BuildError("Failed to allocte ssh channel")); } int rc = ssh_channel_open_session(m_channel); if(rc != SSH_OK) { ssh_channel_free(m_channel); m_channel = NULL; throw clException(BuildError("Failed to open ssh channel")); } }
void* h_crew::GetComponent(char *component_name) { if (!strnicmp (component_name, "NUMBER", 6)) return (void*)&number; BuildError(2); //no such component return NULL; }
VOID AssertPathString(LPSTR pszPath) { LPSTR p = pszPath; while (*p != '\0') { #if PLATFORM_UNIX if ((*p >= 'A' && *p <= 'Z')) { #else if ((*p >= 'A' && *p <= 'Z') || *p == '/') { #endif BuildError("Bad Path string: '%s'\n", pszPath); assert(FALSE); } p++; } } #endif //+--------------------------------------------------------------------------- // // Function: CopyString // //---------------------------------------------------------------------------- LPSTR CopyString( LPSTR Destination, LPSTR Source, BOOL fPath) { UCHAR ch; LPSTR Result; Result = Destination; while ((ch = *Source++) != '\0') { #if !FEATURE_CASE_SENSITIVE_FILESYSTEM if (fPath) { if (ch >= 'A' && ch <= 'Z') { ch -= (UCHAR) ('A' - 'a'); } else { #if PLATFORM_WIN32 if (ch == '/') { ch = '\\'; } #endif // PLATFORM_WIN32 } } #endif // !FEATURE_CASE_SENSITIVE_FILESYSTEM *Destination++ = ch; } *Destination = ch; return(Result); }
void* h_Radiator::GetComponent(char *component_name) { if (!strnicmp (component_name, "TEMP", 4)) return (void*)&Temp; if (!strnicmp (component_name, "RAD", 3)) return (void*)&rad; BuildError(2); return NULL; }
void* h_MixingPipe::GetComponent(char *component_name) { if (Compare(component_name,"PUMP")) return (void*)&h_pump; if (Compare(component_name,"RATIO")) return (void*)∶ BuildError(2); return NULL; }
void* h_Tank::GetComponent(char *component_name) { if (!strnicmp (component_name, "OUT2", 4)) {//talks about the out valve if (strlen(component_name) == 4) return &OUT2_valve;//the valve is all it wants //or maybe something else return OUT2_valve.GetComponent(component_name + 5); }; if (!strnicmp (component_name, "OUT", 3)) {//talks about the out valve if (strlen(component_name) == 3) return &OUT_valve;//the valve is all it wants //or maybe something else return OUT_valve.GetComponent(component_name + 4); }; if (!strnicmp (component_name, "IN", 2)) { if (strlen(component_name) == 2) return &IN_valve;//the valve is all it wants //or maybe something else return IN_valve.GetComponent(component_name + 3); }; if (!strnicmp (component_name, "LEAK", 4)) { if (strlen(component_name) == 4) return &LEAK_valve;//the valve is all it wants //or maybe something else return LEAK_valve.GetComponent(component_name + 5); }; if (!strnicmp (component_name, "TEMP",4 )) return &(space.Temp); if (!strnicmp (component_name, "MASS",4 )) return &(space.total_mass); if (!strnicmp (component_name, "PRESS",5 )) return &(space.Press); if (!strnicmp (component_name, "VOLUME",6 )) return &(space.Volume); if (!strnicmp (component_name, "O2_PPRESS",9 )) return &(space.composition[0].p_press); if (!strnicmp (component_name, "H2_PPRESS",9 )) return &(space.composition[1].p_press); if (!strnicmp (component_name, "N2_PPRESS",9 )) return &(space.composition[3].p_press); if (!strnicmp (component_name, "CO2_PPRESS",10 )) return &(space.composition[4].p_press); if (!strnicmp (component_name, "H2O_PPRESS",10 )) return &(space.composition[2].p_press); if (!strnicmp (component_name, "H2_VAPORMASS", 12)) return &(space.composition[1].vapor_mass); if (!strnicmp (component_name, "O2_VAPORMASS", 12)) return &(space.composition[0].vapor_mass); if (!strnicmp (component_name, "H2O_MASS", 8)) return &(space.composition[2].mass); BuildError(2); return NULL; }
void clSSHChannel::Execute(const wxString& command, wxEvtHandler* sink) { // Sanity if(m_readerThread) { throw clException("Channel is busy"); } if(!IsOpen()) { throw clException("Channel is not opened"); } int rc = ssh_channel_request_exec(m_channel, command.mb_str(wxConvUTF8).data()); if(rc != SSH_OK) { Close(); throw clException(BuildError("Execute failed")); } m_readerThread = new clSSHChannelReader(sink, m_channel); m_readerThread->Start(); }
void* h_Pipe::GetComponent(char *component_name) { if (!strnicmp (component_name, "FLOWMAX", 7)) return (void*)&flowMax; if (!strnicmp (component_name, "FLOW", 4)) return (void*)&flow; if (!strnicmp (component_name, "PRESSMAX", 8)) return (void*)&P_max; if (!strnicmp (component_name, "PRESSMIN", 8)) return (void*)&P_min; BuildError(2); //no such component return NULL; }
void* h_Evaporator::GetComponent(char *component_name) { if (Compare(component_name,"PUMP")) return (void*)&h_pump; if (Compare(component_name,"VALVE")) return (void*)&h_valve; if (Compare(component_name,"THROTTLE")) return (void*)&throttle; if (Compare(component_name,"STEAMPRESSURE")) return (void*)&steamPressure; BuildError(2); return NULL; }
void* h_Valve::GetComponent(char *component_name) { if (!strnicmp (component_name, "OPEN", 4))//handle to open it return (void*)&h_open; if (!strnicmp (component_name, "PZ", 2)) //moving flag return (void*)&pz; if (!strnicmp (component_name, "ISOPEN", 6)) //on/off return (void*)&open; if (!strnicmp (component_name, "SIZE", 4)) //size return (void*)&size; BuildError(2); //no such component return NULL; }
VOID FreeMem(VOID **ppv, MemType mt) { assert(*ppv != NULL); #if DBG { MEMTAB *pmt; MEMHEADER *pmh; pmh = GetHeader(*ppv); if (mt == MT_DIRDB || mt == MT_FILEDB || mt == MT_INCLUDEDB || mt == MT_SOURCEDB) { SigCheck(assert(((DIRREC *) (*ppv))->Sig == 0)); } if (mt >= MT_MAX) { mt = MT_UNKNOWN; } pmt = &MemTab[MT_TOTALS]; pmt->cAlloc--; pmt->cbAlloc -= pmh->cbRequest; pmt = &MemTab[mt]; pmt->cAlloc--; pmt->cbAlloc -= pmh->cbRequest; if (DEBUG_4 && DEBUG_1) { BuildError( "FreeMem(%d, mt=%s) <- %lx\n", pmh->cbRequest, pmt->pszType, *ppv); } assert(CheckTail((char *) *ppv + pmh->cbRequest)); FillTailFree((char *) *ppv + pmh->cbRequest); assert(mt == pmh->mt); pmh->pmhNext->pmhPrev = pmh->pmhPrev; pmh->pmhPrev->pmhNext = pmh->pmhNext; pmh->pmhNext = pmh->pmhPrev = NULL; pmh->mt = MT_INVALID; *ppv = pmh; } #endif free(*ppv); *ppv = NULL; }
void* h_HeatExchanger::GetComponent(char *component_name) { if (Compare(component_name,"PUMP")) return (void*)&h_pump; if (Compare(component_name,"POWER")) return (void*)&power; if (Compare(component_name,"LENGTH")) return (void*)&length; if (Compare(component_name,"TEMPMIN")) return (void*)&tempMin; if (Compare(component_name,"TEMPMAX")) return (void*)&tempMax; BuildError(2); return NULL; }
void BuildBase::FailBuild(const String& message) { if (buildFailed_) { LOGERRORF("BuildBase::FailBuild - Attempt to fail already failed build: %s", message.CString()); return; } buildFailed_ = true; BuildError(message); BuildSystem* buildSystem = GetSubsystem<BuildSystem>(); buildSystem->BuildComplete(platformID_, buildPath_, false, message); }
DOS_TIME DateTimeFile2( LPSTR DirName, LPSTR FileName ) { char path[ DB_MAX_PATH_LENGTH ]; WIN32_FILE_ATTRIBUTE_DATA FileData; DOS_TIME FileDateTime; BOOL rc; if (DirName == NULL || DirName[0] == '\0') { strcpy( path, FileName ); } else { sprintf( path, "%s" PATH_SEPARATOR "%s", DirName, FileName ); } rc = (*pGetFileAttributesExA) (path, GetFileExInfoStandard, (LPVOID)&FileData); if (!rc) { FileDateTime.value = 0; } else { FILETIME ftSystemTime; unsigned __int64 ui64Local, ui64File; GetSystemTimeAsFileTime(&ftSystemTime); ui64Local = (((unsigned __int64) ftSystemTime.dwHighDateTime) << 32) + (unsigned __int64) ftSystemTime.dwLowDateTime; ui64File = (((unsigned __int64) FileData.ftLastWriteTime.dwHighDateTime) << 32) + (unsigned __int64) FileData.ftLastWriteTime.dwLowDateTime; // Take into account that file times may have two second intervals (0x989680 = 1 second) // for FAT drives. if (ui64File > (ui64Local + (0x989680*2))) { BuildError("ERROR - \"%s\" file time is in the future.\n", path); } FileDateTime.value = 0L; FileTimeToDosDateTime( &FileData.ftLastWriteTime, &FileDateTime.time.wDate, &FileDateTime.time.wTime ); } return( FileDateTime ); }
VOID ReportMemoryUsage(VOID) { #if DBG MEMTAB *pmt; if (DEBUG_1) { BuildErrorRaw( "Maximum memory usage: %5lx bytes in %4lx blocks\n", cbAllocMax, cAllocMax); for (pmt = MemTab; pmt < &MemTab[MT_MAX]; pmt++) { BuildErrorRaw( "%5lx bytes in %4lx blocks, %5lx bytes in %4lx blocks Total (%s)\n", pmt->cbAlloc, pmt->cAlloc, pmt->cbAllocTotal, pmt->cAllocTotal, pmt->pszType); } } FreeMem(&BigBuf, MT_IOBUFFER); if (fDebug & 8) { PrintAllDirs(); } FreeAllDirs(); if (DEBUG_1 || MemTab[MT_TOTALS].cbAlloc != 0) { BuildErrorRaw(szNewLine); if (MemTab[MT_TOTALS].cbAlloc != 0) { BuildError("Internal memory leaks detected:\n"); } for (pmt = MemTab; pmt < &MemTab[MT_MAX]; pmt++) { BuildErrorRaw( "%5lx bytes in %4lx blocks, %5lx bytes in %4lx blocks Total (%s)\n", pmt->cbAlloc, pmt->cAlloc, pmt->cbAllocTotal, pmt->cAllocTotal, pmt->pszType); } } #endif }
BOOL MyOpenFile( LPSTR DirName, LPSTR FileName, LPSTR Access, FILE **ppf, BOOL BufferedIO) { char path[ DB_MAX_PATH_LENGTH * 2 + 1]; // ensure we have enough space for "DirName" + "\\" + "FileName" strcpy(path, DirName); if (path[0] != '\0') { strcat(path, PATH_SEPARATOR); } strcat(path, FileName); *ppf = fopen( path, Access ); if (*ppf == NULL) { if (*Access == 'w') { BuildError("%s: create file failed\n", path); } return(FALSE); } return(TRUE); }
BOOL SetupReadFile( LPSTR pszdir, LPSTR pszfile, LPSTR pszCommentToEOL, FILE **ppf ) { char path[DB_MAX_PATH_LENGTH]; assert(!Frb.fOpen); assert(Frb.pf == NULL); assert(Frb.pszFile == NULL); Frb.fMakefile = strcmp(pszCommentToEOL, "#") == 0; Frb.DateTime.value = 0; strcpy(path, pszdir); if (Frb.pfrbNext != NULL) { // if a nested open LPSTR p; if (Frb.fMakefile && !IsFullPath(pszfile)) { // nmake handles relative includes in makefiles by // attempting to locate the file relative to each makefile // in the complete include chain. FILEREADBUF *pfrb; for (pfrb = Frb.pfrbNext; pfrb != NULL; pfrb = pfrb->pfrbNext) { assert(pfrb->pszFile != NULL); strcpy(path, pfrb->pszFile); p = FindLastPathSeparator(path); if (p != NULL) { *p = '\0'; } if (ProbeFile(path, pszfile) != -1) { break; } } if (pfrb == NULL) { // Unable to find file anywhere along path. return FALSE; } } else { p = FindLastPathSeparator(path); if (p != NULL) { *p = '\0'; } } } if (!MyOpenFile(path, pszfile, "rb", ppf, TRUE)) { *ppf = NULL; return(FALSE); } if (Frb.fMakefile) { Frb.DateTime = (*pDateTimeFile)(path, pszfile); } Frb.cLine = 0; Frb.cNull = 0; Frb.cbTotal = 0; Frb.pf = *ppf; Frb.fEof = FALSE; Frb.pszCommentToEOL = pszCommentToEOL; Frb.cbCommentToEOL = strlen(pszCommentToEOL); if (fseek(Frb.pf, 0L, SEEK_END) != -1) { Frb.cbFile = ftell(Frb.pf); if (fseek(Frb.pf, 0L, SEEK_SET) == -1) { Frb.cbFile = 0; } } else { Frb.cbFile = 0; } Frb.cbBuffer = BigBufSize; if (Frb.pfrbNext != NULL) { if (Frb.cbBuffer > Frb.cbFile + 1) { Frb.cbBuffer = Frb.cbFile + 1; } AllocMem(Frb.cbBuffer, (VOID **) &Frb.pbBuffer, MT_IOBUFFER); } else { Frb.pbBuffer = BigBuf; } if (!ReadBuf(Frb.pf)) { fclose(Frb.pf); Frb.pf = *ppf = NULL; if (Frb.pfrbNext != NULL) { FreeMem((VOID **) &Frb.pbBuffer, MT_IOBUFFER); } return(FALSE); // zero byte file } if (path[0] != '\0') { strcat(path, PATH_SEPARATOR); } strcat(path, pszfile); MakeString(&Frb.pszFile, path, TRUE, MT_FRBSTRING); Frb.fOpen = TRUE; if (Frb.fMakefile && DEBUG_4) { BuildError( "Opening file: cbFile=%lu cbBuf=%lu\n", Frb.cbTotal, Frb.cbBuffer); } return(TRUE); }
BOOL CanonicalizePathName( LPSTR SourcePath, UINT Action, LPSTR FullPath ) { char PathBuffer[DB_MAX_PATH_LENGTH] = {0}, *FilePart; char *psz; DWORD attr; if (!GetFullPathName( SourcePath, sizeof(PathBuffer), PathBuffer, &FilePart)) { BuildError( "CanonicalizePathName: GetFullPathName(%s) failed - rc = %d.\n", SourcePath, GetLastError()); return( FALSE ); } CopyString(FullPath, PathBuffer, TRUE); if (Action == CANONICALIZE_ONLY) { return( TRUE ); } if ((attr = GetFileAttributes( PathBuffer )) == -1) { UINT rc = GetLastError(); if (DEBUG_1 || (rc != ERROR_FILE_NOT_FOUND && rc != ERROR_PATH_NOT_FOUND)) { BuildError( "CanonicalizePathName: GetFileAttributes(%s --> %s) failed - rc = %d.\n", SourcePath, PathBuffer, rc); } return( FALSE ); } if (Action == CANONICALIZE_DIR) { if ((attr & FILE_ATTRIBUTE_DIRECTORY) != 0) { return(TRUE); } psz = "directory"; } else { if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0) { return(TRUE); } psz = "file"; } BuildError( "CanonicalizePathName: %s --> %s is not a %s\n", SourcePath, PathBuffer, psz); return(FALSE); }
void H_system::Create_h_Tank(char *line) { char name[100], valvename[100]; h_Tank *new_one; vector3 pos; double volume,isol=0; float size = 0; int open; h_Valve *valve; sscanf (line+6, " %s <%lf %lf %lf> %lf %lf", name, &pos.x, &pos.y, &pos.z, &volume, &isol); new_one=(h_Tank*)AddSystem(new h_Tank(name,pos, volume)); h_substance loaded_sub; new_one->space.Void(); //empty the space while (strnicmp(line,"</TANK>",7)) { if (!strnicmp (line, "CHM",3 )) { sscanf (line+3, " %i %lf %lf %lf", &loaded_sub.subst_type, &loaded_sub.mass, &loaded_sub.vapor_mass, &loaded_sub.Q); new_one->space+=loaded_sub; } else if (!strnicmp (line, "VALVE", 5)) { sscanf (line + 5, " %s %i %f", valvename, &open, &size); valve = 0; if (!strnicmp (valvename, "IN", 2)) { valve = &(new_one->IN_valve); } else if (!strnicmp (valvename, "OUT2", 4)) { valve = &(new_one->OUT2_valve); } else if (!strnicmp (valvename, "OUT", 3)) { valve = &(new_one->OUT_valve); } else if (!strnicmp (valvename, "LEAK", 4)) { valve = &(new_one->LEAK_valve); } else { BuildError(2); //no such component } if (valve) { valve->open = open; valve->size = size; } } do { line = ReadConfigLine(); } while (line == NULL); } new_one->mass=new_one->space.GetMass();//get all the mass,etc.. new_one->space.GetMaxSub();//recompute sub_number; new_one->energy=new_one->space.GetQ();//sum up Qs new_one->Original_volume=volume; P_thermal->AddThermalObject(new_one); if (isol) new_one->isolation=isol; else new_one->isolation=1.0; new_one->Area=pow(3.0/4.0*PI*volume/1000,0.3333); //radius of tank new_one->Area=2*PI*new_one->Area*new_one->Area;//projection circle ois 2*PI*R new_one->parent=this; }
LPSTR ReadLine(FILE *pf) { LPSTR p, pend, pline; LPSTR pcont; LPSTR pcomment; UCHAR chComment0 = Frb.pszCommentToEOL[0]; BOOL fInComment, fWhiteSpace; assert(pf == Frb.pf || (pf != NULL && Frb.pfrbNext != NULL)); if (Frb.cbBuf == 0) { if (Frb.fEof) { return(ReadFilePop()); } if (fseek(Frb.pf, Frb.cbTotal, SEEK_SET) == -1) { return(ReadFilePop()); } if (!ReadBuf(Frb.pf)) { return(ReadFilePop()); } } pline = p = Frb.pbNext; pend = &p[Frb.cbBuf]; pcont = NULL; pcomment = NULL; // scan through line forward fInComment = FALSE; while (p < pend) { switch (*p) { case ' ': case '\t': case '\r': *p = ' '; break; case '\\': pcont = p; // remember continuation character break; case '\n': // Are we at an end of line? case '\0': if (*p == '\n') { Frb.cLine++; } if (fInComment) { memset(pcomment, ' ', p-pcomment-1); fInComment = FALSE; } if (pcont == NULL) { goto eol; // bail out if single line } // else combine multiple lines... *pcont = ' '; // remove continuation char pcont = NULL; // eat only one line per continuation *p = ' '; // join the lines with blanks break; default: // See if the character we're examining begins the // comment-to-EOL string. if (*p == chComment0 && !strncmp(p, Frb.pszCommentToEOL, Frb.cbCommentToEOL) && !fInComment) { fInComment = TRUE; pcomment = p; } pcont = NULL; // not a continuation character break; } p++; } eol: assert(Frb.cbBuf >= (UINT) (p - Frb.pbNext)); Frb.cbBuf -= (UINT)(p - Frb.pbNext); Frb.pbNext = p; if (pcont != NULL) { *pcont = ' '; // file ended with backslash... } assert(*p == '\0' || *p == '\n'); if (p < pend) { if (*p == '\0') { if (Frb.cNull++ == 0) { BuildError("null byte at offset %lx\n", Frb.cbTotal - Frb.cbBuf + p - Frb.pbNext); } } *p = '\0'; // terminate line assert(Frb.cbBuf >= 1); Frb.cbBuf--; // account for newline (or null) Frb.pbNext++; } else { assert(p == pend && *p == '\0'); if (*pline == 'Z' - 64 && p == &pline[1] && Frb.cbBuf == 0) { pline = NULL; // found CTL-Z at end of file } else { // BuildError( "last line incomplete\n"); } } fWhiteSpace = FALSE; if (pline != NULL) { while (*pline == ' ') { pline++; // skip leading whitespace fWhiteSpace = TRUE; } if (*p != '\0') { BuildError( "\"*p != '\\0'\" at offset %lx\n", Frb.cbTotal - Frb.cbBuf + p - Frb.pbNext); BuildError( "pline=%x(%s) p=%x(%s)\n", pline, pline, p, p, Frb.cbTotal - Frb.cbBuf + p - Frb.pbNext); } assert(*p == '\0'); while (p > pline && *--p == ' ') { *p = '\0'; // truncate trailing whitespace } } if (pline == NULL) { return(ReadFilePop()); } if (Frb.fMakefile && !fWhiteSpace && *pline == '!') { p = IsNmakeInclude(pline + 1); if (p != NULL) { if (Frb.fMakefile && DEBUG_4) { BuildError("!include(%s)\n", p); } pline = ReadFilePush(p); FreeMem((VOID **) &p, MT_DIRSTRING); } } return(pline); }