void skipBlankLines( fstream& s ) { char line[256]; line[0] = 0; while (line[0] == 0) strcpy(line,getLine(s)); unGetLine(line); }
TParagraph *readParagraph( fstream& textFile, int& offset, TCrossRefNode *&xRefs ) { State state; Boolean flag; char line[MAXSTRSIZE]; TParagraph *p; ofs = 0; state = undefined; strcpy(line, getLine(textFile)); while (strlen(line) == 0) { flag = (state == wrapping)? True: False; addToBuffer(line, flag); strcpy(line, getLine(textFile)); } if (isEndParagraph(state) == True) { unGetLine(line); return(0); } while (isEndParagraph(state) == False) { if (state == undefined ) if (line[0] == ' ') state = notWrapping; else state = wrapping; scanForCrossRefs(line, offset, xRefs); flag = (state == wrapping)? True: False; addToBuffer(line, flag); strcpy(line, getLine(textFile)); } unGetLine(line); p = new TParagraph; p->size = ofs; p->wrap = (state == wrapping)? True: False; p->text = new char[ofs]; memmove(p->text, buffer, ofs); p->next = 0; offset += ofs; return(p); }
/** * \brief Converts the .log file to .xls file * * Converts the .log file to .xls file */ HRESULT CLogToExcel::bConvert() { HRESULT hRetVal = S_OK; //open log file in read mode m_pLogFile.open(m_strLogFileName.c_str(), fstream::in); if(!m_pLogFile.is_open()) { //log file could not be opened hRetVal = ERR_EXPORTTOEXCEL_LOGFILEOPENERROR; //MessageBox(NULL,EXPORTTOEXCEL_LOGFILEOPENERROR,APPLICATION_NAME,MB_OK); m_bFilesOpened = FALSE; } else { //open Excel file in write m_pExcelFile.open(m_strExcelFileName.c_str(), fstream::out); if(!m_pExcelFile.is_open()) { //Excel file could not be opened hRetVal = ERR_EXPORTTOEXCEL_CSVFILEOPENERROR; //MessageBox(NULL,EXPORTTOEXCEL_CSVFILEOPENERROR,APPLICATION_NAME,MB_OK); m_bFilesOpened = FALSE; } else { m_bFilesOpened = TRUE; } } if(m_bFilesOpened == TRUE) { m_pExcelFile << "<HTML><HEAD></HEAD><BODY>" << endl; m_pExcelFile << _("<FONT COLOR =\"GREEN\"><CENTER><B>BUSMASTER - Exported Log File Report</B></CENTER>"); m_pExcelFile << "<BR><BR>"; m_pExcelFile << "<TABLE BORDER COLOR=\"BLACK\"><TR>"; // write column headers for( UINT unIndex = 0; unIndex < m_unNumOfFields; unIndex++) if(unSelectedField[unIndex]!=-1) { m_pExcelFile << "<TD><FONT COLOR=\"Green\"><B> " << m_pacFields[unIndex] << " </B></TD>"; } m_pExcelFile << "</TR>"; // write each column while(!unGetLine()) { vPrintFields(); m_strBuffer.clear(); } m_pExcelFile << "</TABLE></BODY></HTML>" << endl; //close file m_pExcelFile.close(); m_pLogFile.close(); hRetVal =S_OK; } else { if(m_pLogFile.is_open()) { m_pLogFile.close(); } if(m_pExcelFile.is_open()) { m_pExcelFile.close(); } } return hRetVal; }