[RavenclawDev 378] [2040] trunk/Agents/SessionManager: 1) Use "safe" routines a la visual studio 2005
tk@edam.speech.cs.cmu.edu
tk at edam.speech.cs.cmu.edu
Sat Sep 15 22:41:01 EDT 2007
An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/ravenclaw-developers/attachments/20070915/a8ec42a2/attachment.html
-------------- next part --------------
Modified: trunk/Agents/SessionManager/SessionManager.cpp
===================================================================
--- trunk/Agents/SessionManager/SessionManager.cpp 2007-09-16 02:38:48 UTC (rev 2039)
+++ trunk/Agents/SessionManager/SessionManager.cpp 2007-09-16 02:41:01 UTC (rev 2040)
@@ -53,7 +53,7 @@
// D: display a message on the screen
inline void DisplayMessage(const char* lpszStream, const char* lpszMessage) {
static char lpszBuffer[16384];
- sprintf(lpszBuffer, "[%s@%s] %s\n", lpszStream, GetTimeAsString().c_str(),
+ sprintf_s(lpszBuffer, "[%s@%s] %s\n", lpszStream, GetTimeAsString().c_str(),
lpszMessage);
printf(lpszBuffer);
}
Modified: trunk/Agents/SessionManager/SessionManager.vcproj
===================================================================
--- trunk/Agents/SessionManager/SessionManager.vcproj 2007-09-16 02:38:48 UTC (rev 2039)
+++ trunk/Agents/SessionManager/SessionManager.vcproj 2007-09-16 02:41:01 UTC (rev 2040)
@@ -5,9 +5,6 @@
Name="SessionManager"
ProjectGUID="{DA610A10-C684-4C6C-9176-4865401B3A66}"
RootNamespace="SessionManager"
- SccProjectName=""$/CommonAgents/SessionManager", OCLCAAAA"
- SccLocalPath="."
- SccProvider="MSSCCI:Microsoft Visual SourceSafe"
Keyword="MFCProj"
>
<Platforms>
Modified: trunk/Agents/SessionManager/Utils.cpp
===================================================================
--- trunk/Agents/SessionManager/Utils.cpp 2007-09-16 02:38:48 UTC (rev 2039)
+++ trunk/Agents/SessionManager/Utils.cpp 2007-09-16 02:41:01 UTC (rev 2040)
@@ -71,7 +71,7 @@
va_start(pArgs, lpszFormat);
// print into the buffer
- _vsnprintf(szBuffer, STRING_MAX, lpszFormat, pArgs);
+ _vsnprintf_s(szBuffer, STRING_MAX, lpszFormat, pArgs);
// return a string object initialized from that buffer
return((string)szBuffer);
@@ -101,15 +101,15 @@
// D: make a string uppercase
string ToUpperCase(string sString) {
- strcpy(szBuffer, sString.c_str());
- _strupr(szBuffer);
+ strcpy_s(szBuffer, sString.c_str());
+ _strupr_s(szBuffer);
return (string)szBuffer;
}
// D: makes a string lowercase
string ToLowerCase(string sString) {
- strcpy(szBuffer, sString.c_str());
- _strlwr(szBuffer);
+ strcpy_s(szBuffer, sString.c_str());
+ _strlwr_s(szBuffer);
return (string)szBuffer;
}
@@ -356,10 +356,10 @@
// until the current time changes so that we can avoid as much as
// possible granularity effects
_timeb tTimeNow, tLastTime;
- _ftime(&tTimeNow);
+ _ftime64_s(&tTimeNow);
do {
tLastTime = tTimeNow;
- _ftime(&tTimeNow);
+ _ftime64_s(&tTimeNow);
} while(tTimeNow.millitm == tLastTime.millitm);
tStartUpTime = tTimeNow;
@@ -431,14 +431,14 @@
// D: transforms a time (as a _timeb structure) into a string
string TimeToString(_timeb time) {
- tm* tmTime;
+ tm tmTime;
string sResult;
// convert to local timezone
- tmTime = localtime(&time.time);
+ localtime_s(&tmTime, &time.time);
// and format it as a string and return it
- return FormatString("%02d:%02d:%02d.%03d", tmTime->tm_hour,
- tmTime->tm_min, tmTime->tm_sec, time.millitm);
+ return FormatString("%02d:%02d:%02d.%03d", tmTime.tm_hour,
+ tmTime.tm_min, tmTime.tm_sec, time.millitm);
}
// D: returns the time as a long int. Used mainly for logging purposes
More information about the Ravenclaw-developers
mailing list