[Sphere-axis-commits] CVS: Axis Axis.txt,1.22,1.23 remoteconnection.cpp,1.15,1.16
Brought to you by:
pesterle
From: Philip E. <pes...@us...> - 2002-05-08 18:46:25
|
Update of /cvsroot/sphere-axis/Axis In directory usw-pr-cvs1:/tmp/cvs-serv32222 Modified Files: Axis.txt remoteconnection.cpp Log Message: updated checksum algorithm fixed crash bug with remote scripts and non-resource files Index: Axis.txt =================================================================== RCS file: /cvsroot/sphere-axis/Axis/Axis.txt,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** Axis.txt 8 May 2002 15:44:18 -0000 1.22 --- Axis.txt 8 May 2002 18:46:22 -0000 1.23 *************** *** 25,28 **** --- 25,32 ---- ============================================================================= Changes in version 0.13b (in development) + · Fixed a crash bug when Axis is reading remote scripts AND non-resource files. + · Fixed the checksum algorithm to ignore CR and LF chars, since different OSes + end lines differently, and if you don't convert for your filesystem, the + checksums will be different. · Minor UI tweaks (details can be found in patch tracker #553591, submitted by Piotr Banasik). Index: remoteconnection.cpp =================================================================== RCS file: /cvsroot/sphere-axis/Axis/remoteconnection.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -r1.15 -r1.16 *** remoteconnection.cpp 5 May 2002 01:49:16 -0000 1.15 --- remoteconnection.cpp 8 May 2002 18:46:22 -0000 1.16 *************** *** 36,39 **** --- 36,58 ---- #include "citem.h" + int fReadLine(FILE * pFile, char * pszBuf, int iSize) + { + memset(pszBuf, 0x00, iSize); + int iCount = 0; + char c = 0x00; + while (c != '\n' && iCount < (iSize - 1) && !feof(pFile)) + { + c = fgetc(pFile); + if (c != '\n' && c != -1) + { + *(pszBuf + iCount) = c; + iCount++; + } + } + if (feof(pFile) && iCount == 0) + return -1; + return iCount; + } + const char * pszFiles [] = { "graychar2", *************** *** 950,953 **** --- 969,974 ---- if ( csScpPath.GetLength() > 0 && ( csScpPath.GetAt(csScpPath.GetLength() - 1) == '\\' || csScpPath.GetAt(csScpPath.GetLength() -1) == '/' ) ) csScpPath.SetAt(csScpPath.GetLength() - 1, 0x00); + if ( csScpPath.GetLength() == 0 ) + csScpPath = "."; if ( !Main->m_pScripts->LoadFile(csFileName) ) { *************** *** 1040,1044 **** } } ! if ( Main->m_pScripts->m_tables.m_resources.GetSize() && !Main->m_dwResourcesOnly ) { CStringArray saFiles; --- 1061,1065 ---- } } ! if ( Main->m_pScripts->m_tables.m_resources.GetSize() && !Main->m_dwResourcesOnly ) { CStringArray saFiles; *************** *** 1096,1125 **** m_pDlg->SetPos(0); unsigned int chk = 0; ! if ( pszFilename == NULL ) return chk; CString csFilename = _T(pszFilename); csFilename.Replace(':', '!'); Main->m_log.Add("Computing checksum for file %s", csFilename); ! CStdioFile csfInput; ! if ( !csfInput.Open(csFilename, CFile::modeRead | CFile::shareDenyNone) ) return chk; ! CString csLine; int line = 0; ! BOOL bStatus = TRUE; ! while ( bStatus ) { ! bStatus = csfInput.ReadString(csLine); ! if ( !bStatus ) ! break; unsigned int linesum = 0; ! for ( int i = 0; i < (int) csLine.GetLength(); i++ ) { ! char c = csLine.GetAt(i); ! linesum += (unsigned int) c; } chk += (linesum & line); line++; } ! csfInput.Close(); return chk; } --- 1117,1146 ---- m_pDlg->SetPos(0); unsigned int chk = 0; ! if ( pszFilename == NULL || pszFilename[0] == 0x00) return chk; CString csFilename = _T(pszFilename); csFilename.Replace(':', '!'); Main->m_log.Add("Computing checksum for file %s", csFilename); ! // Use the same code from the server ! FILE * pFile; ! pFile = fopen( pszFilename, "r" ); ! if ( ! pFile ) return chk; ! char szLine[8192]; int line = 0; ! while ( !feof(pFile) ) { ! fReadLine(pFile, szLine, sizeof(szLine)); unsigned int linesum = 0; ! for ( int i = 0; i < (int) strlen(szLine); i++ ) { ! char c = szLine[i]; ! if ( c != 0x0d && c != 0x0a ) ! linesum += (unsigned int) c; } chk += (linesum & line); line++; } ! fclose(pFile); return chk; } |