Index: ext/libicpf/libicpf.vc71.sln
===================================================================
diff -u -ree851c181bb121b5e7062107c51016ed97e75611 -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/libicpf.vc71.sln (.../libicpf.vc71.sln) (revision ee851c181bb121b5e7062107c51016ed97e75611)
+++ ext/libicpf/libicpf.vc71.sln (.../libicpf.vc71.sln) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -4,15 +4,26 @@
EndProjectSection
EndProject
Global
+ GlobalSection(DPCodeReviewSolutionGUID) = preSolution
+ DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000}
+ EndGlobalSection
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
+ Debug-Unicode = Debug-Unicode
Release = Release
+ Release-Unicode = Release-Unicode
EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{5510B933-046F-4F75-8B46-5E8279C8CCDE}.Debug.ActiveCfg = Debug|Win32
{5510B933-046F-4F75-8B46-5E8279C8CCDE}.Debug.Build.0 = Debug|Win32
+ {5510B933-046F-4F75-8B46-5E8279C8CCDE}.Debug-Unicode.ActiveCfg = Debug-Unicode|Win32
+ {5510B933-046F-4F75-8B46-5E8279C8CCDE}.Debug-Unicode.Build.0 = Debug-Unicode|Win32
{5510B933-046F-4F75-8B46-5E8279C8CCDE}.Release.ActiveCfg = Release|Win32
{5510B933-046F-4F75-8B46-5E8279C8CCDE}.Release.Build.0 = Release|Win32
+ {5510B933-046F-4F75-8B46-5E8279C8CCDE}.Release-Unicode.ActiveCfg = Release-Unicode|Win32
+ {5510B933-046F-4F75-8B46-5E8279C8CCDE}.Release-Unicode.Build.0 = Release-Unicode|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
Index: ext/libicpf/libicpf.vc71.vcproj
===================================================================
diff -u -r771dac1fbb7608aa92942c6cab7c5c8b0cccb791 -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/libicpf.vc71.vcproj (.../libicpf.vc71.vcproj) (revision 771dac1fbb7608aa92942c6cab7c5c8b0cccb791)
+++ ext/libicpf/libicpf.vc71.vcproj (.../libicpf.vc71.vcproj) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -24,6 +24,8 @@
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
@@ -71,6 +73,8 @@
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBICPF_EXPORTS"
RuntimeLibrary="0"
+ TreatWChar_tAsBuiltInType="TRUE"
+ ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
@@ -109,6 +113,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -139,9 +245,6 @@
RelativePath=".\src\crc32.cpp">
-
-
-
-
-
-
-
-
-
-
@@ -210,9 +301,6 @@
RelativePath=".\src\crc32.h">
-
-
-
-
-
-
-
-
-
-
Index: ext/libicpf/src/cfg.cpp
===================================================================
diff -u -r0d9a4d94a98872815d5840d1bcc4d394d455307c -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/cfg.cpp (.../cfg.cpp) (revision 0d9a4d94a98872815d5840d1bcc4d394d455307c)
+++ ext/libicpf/src/cfg.cpp (.../cfg.cpp) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -149,7 +149,7 @@
*
* \param[in] pszPath - path to a file to be read
*/
-void config::read(const char_t* pszPath)
+void config::read(const tchar_t* pszPath)
{
m_lock.lock();
try
@@ -173,7 +173,7 @@
*
* \param[in] pszPath - path to a file to write the properties to
*/
-void config::write(const char_t* pszPath)
+void config::write(const tchar_t* pszPath)
{
m_lock.lock();
Index: ext/libicpf/src/cfg_xml.cpp
===================================================================
diff -u -r0d9a4d94a98872815d5840d1bcc4d394d455307c -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/cfg_xml.cpp (.../cfg_xml.cpp) (revision 0d9a4d94a98872815d5840d1bcc4d394d455307c)
+++ ext/libicpf/src/cfg_xml.cpp (.../cfg_xml.cpp) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -84,7 +84,7 @@
* \param[in] name - name of the tag being processed
* \param[in] attrs - array of pointers to strings with attributes and their values
*/
-void XMLCALL element_start(void *userData, const XML_Char *name, const XML_Char **attrs)
+void XMLCALL element_start(void *userData, const tchar_t *name, const tchar_t **attrs)
{
XMLSTATE* pState=(XMLSTATE*)userData;
@@ -230,7 +230,7 @@
xml_node* pNode=(xml_node*)pNodePtr;
// parse the name
- tchar_t* pSign=_tcschr(pszName, _t('/'));
+ const tchar_t* pSign=_tcschr(pszName, _t('/'));
if (pSign)
{
// locate the xml_node associated with the name
@@ -299,7 +299,7 @@
{
xml_node* pNode=(xml_node*)pNodePtr;
- tchar_t* pszSign=_tcschr(pszName, _t('/'));
+ const tchar_t* pszSign=_tcschr(pszName, _t('/'));
if (pszSign != NULL)
{
xml_storage::iterator it=pNode->m_mNodes.find(tstring(pszName, pszSign-pszName));
@@ -347,7 +347,7 @@
xml_node* pNode=(xml_node*)pNodePtr;
// parse the name
- tchar_t* pSign=_tcschr(pszName, _t('/'));
+ const tchar_t* pSign=_tcschr(pszName, _t('/'));
if (pSign)
{
// locate the xml_node associated with the name
Index: ext/libicpf/src/dumpctx.cpp
===================================================================
diff -u -r2446443341715955423610c01b43fe7841a10e3e -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/dumpctx.cpp (.../dumpctx.cpp) (revision 2446443341715955423610c01b43fe7841a10e3e)
+++ ext/libicpf/src/dumpctx.cpp (.../dumpctx.cpp) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -26,50 +26,50 @@
BEGIN_ICPF_NAMESPACE
-#ifdef _WIN32
- #define snprintf _snprintf
-#endif
+/// Helper definition for faster access
+#define m_pBuffer ((tstring_t*)m_hBuffer)
/** Constructor stores the passed data in the internal members.
* \param[in] uiType - type of dump (one of the DCX_*)
* \param[in] pParam - additional param - the type of theis param depends on the ulType
*/
dumpctx::dumpctx(uint_t uiType, ptr_t pParam) :
m_lock(),
- m_strBuffer(),
+ m_hBuffer((ptr_t)new tstring_t),
m_szBuffer(),
m_uiType(uiType),
m_pParam(pParam)
-
{
m_uiType=uiType;
- if (uiType == DCX_FILE)
+ if (uiType == type_file)
{
- size_t tLen=strlen((const char_t*)pParam);
- m_pParam=(ptr_t)new char_t[tLen+1];
- strcpy((char_t*)m_pParam, (const char_t*)pParam);
+ size_t tLen=_tcslen((const tchar_t*)pParam);
+ m_pParam=(ptr_t)new tchar_t[tLen+1];
+ _tcscpy((tchar_t*)m_pParam, (const tchar_t*)pParam);
}
+ else
+ m_pParam=pParam;
}
/** Destructor frees the internal data if needed
*/
dumpctx::~dumpctx()
{
- if (m_uiType == DCX_FILE)
- delete [] (char_t*)m_pParam;
+ if (m_uiType == type_file)
+ delete [] (tchar_t*)m_pParam;
else
- m_pParam=NULL; // we won't have a leak here, since we don't alloc memory for case m_uiType != DCX_FILE
+ m_pParam=NULL; // we won't have a leak here, since we don't alloc memory for case m_uiType != type_file
}
/** Function opens the dump. It means initializing the internal string
* that will contain the dump result and locking the class (using mutex).
* \note Always call the close() member if you have opened the dump.
*/
-void dumpctx::open(const char_t* pszObject)
+void dumpctx::open(const tchar_t* pszObject)
{
MLOCK(m_lock);
- m_strBuffer=pszObject;
- m_strBuffer+="\n";
+ *m_pBuffer=pszObject;
+ *m_pBuffer+=_t("\n");
}
/** Closes the dump. Depending on the type specified in the constructor the
@@ -81,184 +81,184 @@
// perform a dump - depending on the type of a dest object
switch(m_uiType)
{
- case DCX_STD:
+ case type_std:
{
- printf(m_strBuffer);
+ _tprintf(TSTRFMT, m_pBuffer->c_str());
break;
}
- case DCX_FILE:
+ case type_file:
{
- FILE* pFile=fopen((const char_t*)m_pParam, "a");
+ FILE* pFile=_tfopen((const tchar_t*)m_pParam, _t("a"));
if (pFile != NULL)
{
- fprintf(pFile, m_strBuffer);
+ _ftprintf(pFile, TSTRFMT, m_pBuffer->c_str());
fclose(pFile);
}
break;
}
- case DCX_FILEHANDLE:
+ case type_filehandle:
{
- fprintf((FILE*)m_pParam, m_strBuffer);
+ _ftprintf((FILE*)m_pParam, TSTRFMT, m_pBuffer->c_str());
break;
}
- case DCX_LOG:
+ case type_log:
{
- ((log_file*)m_pParam)->logd(m_strBuffer);
+ ((log_file*)m_pParam)->logd(TSTRFMT, m_pBuffer->c_str());
break;
}
default:
break;
}
// clean the internal buffer
- m_strBuffer.clear();
+ m_pBuffer->clear();
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the given ansi string.
- * Strings longer than MAX_DUMP characters will be truncated.
+ * Strings longer than max_dump characters will be truncated.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] pszValue - an ansi string - the value of a given member
*/
-void dumpctx::dump(const char_t* pszName, const char_t* pszValue)
+void dumpctx::dump(const tchar_t* pszName, const tchar_t* pszValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (string):\n\t" PTRFMT " (\"" STRFMT "\")\n", pszName, pszValue, pszValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, TSTRFMT _t(" (tstring):\n\t") PTRFMT _t(" (\"") TSTRFMT _t("\")\n"), pszName, pszValue, pszValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the given unicode string.
- * Strings longer than MAX_DUMP characters will be truncated.
+ * Strings longer than max_dump characters will be truncated.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] pszValue - an unicode string - the value of a given member
*/
-void dumpctx::dump(const char_t* pszName, const wchar_t* pszValue)
+/*void dumpctx::dump(const tchar_t* pszName, const wchar_t* pszValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (wide string):\n\t" PTRFMT " (\"" WSTRFMT "\")\n", pszName, pszValue, pszValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (wide string):\n\t") PTRFMT _t(" (\"") WSTRFMT _t("\")\n"), pszName, pszValue, pszValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
-}
+}*/
/** Function dumps (stores in the internal string object) the given character.
* \param[in] pszName - name of the member variable of the dumped object
- * \param[in] cValue - a character (signed char_t) value
+ * \param[in] cValue - a character (signed tchar_t) value
*/
-void dumpctx::dump(const char_t* pszName, const char_t cValue)
+void dumpctx::dump(const tchar_t* pszName, const tchar_t cValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (char_t):\n\t'" CHARFMT "' (hex: " CXFMT " / dec: " CFMT ")\n", pszName, cValue, (short_t)cValue, (short_t)cValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (tchar_t):\n\t'") CHARFMT _t("' (hex: ") CXFMT _t(" / dec: ") CFMT _t(")\n"), pszName, cValue, (short_t)cValue, (short_t)cValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the given short_t.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] sValue - a short_t value to dump
*/
-void dumpctx::dump(const char_t* pszName, const short_t sValue)
+void dumpctx::dump(const tchar_t* pszName, const short_t sValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (short_t):\n\t" SFMT " (hex: " SXFMT ")\n", pszName, sValue, sValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (short_t):\n\t") SFMT _t(" (hex: ") SXFMT _t(")\n"), pszName, sValue, sValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the given int_t.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] iValue - a int_t value to dump
*/
-void dumpctx::dump(const char_t* pszName, const int_t iValue)
+void dumpctx::dump(const tchar_t* pszName, const int_t iValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (int_t):\n\t" LFMT " (hex: " LXFMT ")\n", pszName, iValue, iValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (int_t):\n\t") LFMT _t(" (hex: ") LXFMT _t(")\n"), pszName, iValue, iValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the given uchar_t.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] ucValue - an uchar_t value to dump
*/
-void dumpctx::dump(const char_t* pszName, const uchar_t ucValue)
+void dumpctx::dump(const tchar_t* pszName, const uchar_t ucValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (uchar_t):\n\t'" UCHARFMT "' (hex: " UCXFMT " / dec: " UCFMT ")\n", pszName, ucValue, (ushort_t)ucValue, (ushort_t)ucValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (uchar_t):\n\t'") UCHARFMT _t("' (hex: ") UCXFMT _t(" / dec: ") UCFMT _t(")\n"), pszName, ucValue, (ushort_t)ucValue, (ushort_t)ucValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the given ushort_t.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] usValue - an ushort_t value to dump
*/
-void dumpctx::dump(const char_t* pszName, const ushort_t usValue)
+void dumpctx::dump(const tchar_t* pszName, const ushort_t usValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (ushort_t):\n\t" USFMT " (hex: " USXFMT ")\n", pszName, usValue, usValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (ushort_t):\n\t") USFMT _t(" (hex: ") USXFMT _t(")\n"), pszName, usValue, usValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the given uint_t.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] uiValue - an uint_t value to dump
*/
-void dumpctx::dump(const char_t* pszName, const uint_t uiValue)
+void dumpctx::dump(const tchar_t* pszName, const uint_t uiValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (uint_t):\n\t" ULFMT " (hex: " ULXFMT ")\n", pszName, uiValue, uiValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (uint_t):\n\t") ULFMT _t(" (hex: ") ULXFMT _t(")\n"), pszName, uiValue, uiValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the longlong_t.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] llValue - a longlong_t value to dump
*/
-void dumpctx::dump(const char_t* pszName, const longlong_t llValue)
+void dumpctx::dump(const tchar_t* pszName, const longlong_t llValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (longlong_t):\n\t" LLFMT " (hex: " LLXFMT ")\n", pszName, llValue, llValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (longlong_t):\n\t") LLFMT _t(" (hex: ") LLXFMT _t(")\n"), pszName, llValue, llValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the ulonglong_t.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] ullValue - an ulonglong_t value to dump
*/
-void dumpctx::dump(const char_t* pszName, const ulonglong_t ullValue)
+void dumpctx::dump(const tchar_t* pszName, const ulonglong_t ullValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (ulonglong_t):\n\t" ULLFMT " (hex: " ULLXFMT ")\n", pszName, ullValue, ullValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (ulonglong_t):\n\t") ULLFMT _t(" (hex: ") ULLXFMT _t(")\n"), pszName, ullValue, ullValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
/** Function dumps (stores in the internal string object) the untyped pointer.
* \param[in] pszName - name of the member variable of the dumped object
* \param[in] pValue - an untyped pointer value to dump
*/
-void dumpctx::dump(const char_t* pszName, const ptr_t pValue)
+void dumpctx::dump(const tchar_t* pszName, const ptr_t pValue)
{
- snprintf(m_szBuffer, MAX_DUMP, STRFMT " (ptr_t):\n\t" PTRFMT "\n", pszName, pValue);
- m_szBuffer[MAX_DUMP-1]='\0';
+ _sntprintf(m_szBuffer, max_dump, STRFMT _t(" (ptr_t):\n\t") PTRFMT _t("\n"), pszName, pValue);
+ m_szBuffer[max_dump-1]=_t('\0');
MLOCK(m_lock);
- m_strBuffer+=m_szBuffer;
+ *m_pBuffer+=m_szBuffer;
MUNLOCK(m_lock);
}
Index: ext/libicpf/src/dumpctx.h
===================================================================
diff -u -r2446443341715955423610c01b43fe7841a10e3e -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/dumpctx.h (.../dumpctx.h) (revision 2446443341715955423610c01b43fe7841a10e3e)
+++ ext/libicpf/src/dumpctx.h (.../dumpctx.h) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -26,24 +26,24 @@
#include "mutex.h"
#include "gen_types.h"
-#include "str.h"
+//#include "str.h"
BEGIN_ICPF_NAMESPACE
/// Maximum size of a single variable dump (ie. string)
-#define MAX_DUMP 4096
+//#define MAX_DUMP 4096
// dump type flags
/// Std out; pParam is NULL
-#define DCX_STD 0x00000000
-/// File object; pParam is const char_t* with file path
+/*#define DCX_STD 0x00000000
+/// File object; pParam is const tchar_t* with file path
#define DCX_FILE 0x00000001
/// File object; pParam is FILE* - handle to a file opened in write mode
#define DCX_FILEHANDLE 0x00000002
/// Log file; pParam is log_file* with the given log (dump's will be logged as LT_DEBUG)
#define DCX_LOG 0x00000003
+*/
-
/** \brief Class used as dump context (debugging purposes).
*
* Class should be used to perform dump's of any object's internal state.
@@ -55,39 +55,51 @@
*/
class LIBICPF_API dumpctx
{
+ /// Dump types available
+ enum dump_types
+ {
+ type_std, /// Reporting to the console
+ type_file, /// Reporting to the file
+ type_filehandle, /// Reporting to the file handle
+ type_log /// Reporting to a log file
+ };
+
+ /// Internal buffer size to use
+ enum buf_sizes { max_dump=4096 };
public:
/** \name Construction/destruction */
/**@{*/
- explicit dumpctx(uint_t ulType, ptr_t pParam=NULL); ///< Standard constructor
+ explicit dumpctx(uint_t uiType, ptr_t pParam=NULL); ///< Standard constructor
~dumpctx(); ///< Standard destructor
/**@}*/
/** \name Opening/closing dump process */
/**@{*/
- void open(const char_t* pszObject); ///< Begins the specified object dump
+ void open(const tchar_t* pszObject); ///< Begins the specified object dump
void close(); ///< Ends the object dump
/**@}*/
/** \name Dumping functions
* Operations to be executed between calls to open() and close()
*/
/**@{*/
- void dump(const char_t* pszName, const char_t* pszValue); ///< Ansi string dump
- void dump(const char_t* pszName, const wchar_t* pszValue); ///< Unicode string dump
- void dump(const char_t* pszName, const char_t cValue); ///< char_t dump
- void dump(const char_t* pszName, const short_t sValue); ///< short_t dump
- void dump(const char_t* pszName, const int_t iValue); ///< int_t dump
- void dump(const char_t* pszName, const uchar_t ucValue); ///< uchar_t dump
- void dump(const char_t* pszName, const ushort_t usValue); ///< ushort_t dump
- void dump(const char_t* pszName, const uint_t uiValue); ///< uint_t dump
- void dump(const char_t* pszName, const longlong_t llValue); ///< longlong_t dump
- void dump(const char_t* pszName, const ulonglong_t ullValue); ///< ulonglong_t dump
- void dump(const char_t* pszName, const ptr_t pValue); ///< pointer dump
+ void dump(const tchar_t* pszName, const tchar_t* pszValue); ///< Ansi string dump
+// void dump(const tchar_t* pszName, const wchar_t* pszValue); ///< Unicode string dump
+ void dump(const tchar_t* pszName, const tchar_t cValue); ///< tchar_t dump
+ void dump(const tchar_t* pszName, const short_t sValue); ///< short_t dump
+ void dump(const tchar_t* pszName, const int_t iValue); ///< int_t dump
+ void dump(const tchar_t* pszName, const uchar_t ucValue); ///< uchar_t dump
+ void dump(const tchar_t* pszName, const ushort_t usValue); ///< ushort_t dump
+ void dump(const tchar_t* pszName, const uint_t uiValue); ///< uint_t dump
+ void dump(const tchar_t* pszName, const longlong_t llValue); ///< longlong_t dump
+ void dump(const tchar_t* pszName, const ulonglong_t ullValue); ///< ulonglong_t dump
+ void dump(const tchar_t* pszName, const ptr_t pValue); ///< pointer dump
/**@}*/
protected:
mutex m_lock; ///< A mutex or d_mutex class cast to void* because of the circular dependencies problem
- string m_strBuffer; ///< String object that will gather information about dump
- char_t m_szBuffer[MAX_DUMP]; ///< Buffer used in formatting output data
+// string m_strBuffer; ///< String object that will gather information about dump
+ ptr_t m_hBuffer; ///< Internal buffer handle
+ tchar_t m_szBuffer[max_dump]; ///< Buffer used in formatting output data
uint_t m_uiType; ///< Type of dump (as passed to constructor)
ptr_t m_pParam; ///< Parameter - the real type depends on the m_ulType field
};
Index: ext/libicpf/src/exception.cpp
===================================================================
diff -u -raba7605f4821e4a65dd64cb5118f4f44d65155eb -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/exception.cpp (.../exception.cpp) (revision aba7605f4821e4a65dd64cb5118f4f44d65155eb)
+++ ext/libicpf/src/exception.cpp (.../exception.cpp) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -139,7 +139,7 @@
// alloc some space - no more than MAX_EXCEPTION chracters
tchar_t* psz=new tchar_t[(size_t)MAX_EXCEPTION];
- _vsnprintf(psz, (size_t)MAX_EXCEPTION, pszFormat, vl);
+ _vsntprintf(psz, (size_t)MAX_EXCEPTION, pszFormat, vl);
psz[MAX_EXCEPTION-1]=_t('\0');
return psz;
}
Index: ext/libicpf/src/file.cpp
===================================================================
diff -u -r2446443341715955423610c01b43fe7841a10e3e -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/file.cpp (.../file.cpp) (revision 2446443341715955423610c01b43fe7841a10e3e)
+++ ext/libicpf/src/file.cpp (.../file.cpp) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -25,7 +25,6 @@
#include
#include "macros.h"
#include "err_codes.h"
-#include "crypt.h"
#ifndef _WIN32
#include
@@ -34,14 +33,8 @@
#include
#endif
-//#include "stdio.h" // TEMP: only for temporary printf support
-
BEGIN_ICPF_NAMESPACE
-#ifdef USE_ENCRYPTION
- #include "crypt.h"
-#endif
-
#include
/// Serialization buffer increment value
@@ -81,9 +74,6 @@
m_uiSerialBufferSize(0),
m_uiSerialBufferPos(0),
m_uiDataBlockFlags(BF_NONE)
-#ifdef USE_ENCRYPTION
- , m_strPassword()
-#endif
{
}
@@ -97,20 +87,19 @@
{
close();
}
- catch(exception* e)
+ catch(exception&)
{
- e->del();
}
}
/** Opens a filesystem object (a file) with a given flags and (if needed) with
- * some buffer size used in internal buffering. In case of error throws a ch::exception*
+ * some buffer size used in internal buffering. In case of error throws an icpf::exception
* with the error description.
* \param[in] pszPath - path to a file to open
* \param[in] uiFlags - flags that determine the type of access to a file (FA_*)
* \param[in] uiBufSize - buffer size that will be used for internal buffering (if enabled)
*/
-void file::open(const char_t* pszPath, uint_t uiFlags, uint_t uiBufSize)
+void file::open(const tchar_t* pszPath, uint_t uiFlags, uint_t uiBufSize)
{
// check if this object is ready to open a file
if (m_hFile)
@@ -173,13 +162,13 @@
if (m_hFile == INVALID_HANDLE_VALUE)
{
m_hFile=FNULL;
- THROW(exception::format("[file] Cannot open the file " STRFMT " with flags " ULXFMT, pszPath, uiFlags), FERR_OPEN, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("[file] Cannot open the file ") STRFMT _t(" with flags ") ULXFMT, pszPath, uiFlags), FERR_OPEN, CURRENT_LAST_ERROR, 0);
}
else
{
// remember the path of this file
- m_pszPath=new char_t[strlen(pszPath)+1];
- strcpy(m_pszPath, pszPath);
+ m_pszPath=new tchar_t[_tcslen(pszPath)+1];
+ _tcscpy(m_pszPath, pszPath);
// remember the mode
m_uiFlags=uiFlags;
@@ -223,10 +212,6 @@
m_uiSerialBufferPos=0;
m_uiDataBlockFlags=0;
-#ifdef USE_ENCRYPTION
- m_strPassword.clear();
-#endif
-
m_bRememberedState=false;
// close the file
@@ -235,7 +220,7 @@
#else
if (::close(m_hFile) == -1)
#endif
- THROW(exception::format("[file] Cannot close the handle associated with a file " STRFMT, m_pszPath), FERR_CLOSE, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("[file] Cannot close the handle associated with a file ") STRFMT, m_pszPath), FERR_CLOSE, CURRENT_LAST_ERROR, 0);
else
m_hFile=FNULL;
}
@@ -295,7 +280,7 @@
int_t rd=0;
if ((rd=::read(m_hFile, pBuffer, ulSize)) < 0)
#endif
- THROW(exception::format("Cannot read data from file " STRFMT, m_pszPath), FERR_READ, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("Cannot read data from file ") STRFMT, m_pszPath), FERR_READ, CURRENT_LAST_ERROR, 0);
return rd; // if 0 - eof (not treated as exception)
}
@@ -352,7 +337,7 @@
int_t wr;
if ((wr=::write(m_hFile, pBuffer, ulSize) == -1))
#endif
- THROW(exception::format("[file] Cannot write data to a file", m_pszPath), FERR_WRITE, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("[file] Cannot write data to a file"), m_pszPath), FERR_WRITE, CURRENT_LAST_ERROR, 0);
return (ulong_t)wr;
}
@@ -389,7 +374,7 @@
* \param[in] uiMaxLen - size of the string buffer
* \return If the line has been succesfully read.
*/
-bool file::read_line(char_t* pszStr, uint_t uiMaxLen)
+bool file::read_line(tchar_t* pszStr, uint_t uiMaxLen)
{
// for unbuffered operations enable buffering for this op
if (m_bBuffered)
@@ -410,7 +395,7 @@
* copy and appends a \\r\\n to this text.
* \param[in] pszString - string to store
*/
-void file::write_line(char_t* pszString)
+void file::write_line(tchar_t* pszString)
{
assert(m_hFile);
@@ -422,13 +407,13 @@
// make new string with \r\n at the end - cannot use old buffer - unknown size
// NOTE: \r\n added for windoze compat; when reading file function properly handles unix style line endings
- uint_t uiLen=(uint_t)strlen(pszString);
+ uint_t uiLen=(uint_t)_tcslen(pszString);
- char_t *pszData=new char_t[uiLen+3];
- strcpy(pszData, pszString);
- pszData[uiLen]='\r';
- pszData[uiLen+1]='\n';
- pszData[uiLen+2]='\0';
+ tchar_t *pszData=new tchar_t[uiLen+3];
+ _tcscpy(pszData, pszString);
+ pszData[uiLen]=_t('\r');
+ pszData[uiLen+1]=_t('\n');
+ pszData[uiLen+2]=_t('\0');
try
{
@@ -466,7 +451,7 @@
int_t wr;
if ((wr=::write(m_hFile, pszData, uiLen+2)) == -1)
#endif
- THROW(exception::format("Cannot write data to a file " STRFMT, m_pszPath), FERR_WRITE, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("Cannot write data to a file ") STRFMT, m_pszPath), FERR_WRITE, CURRENT_LAST_ERROR, 0);
}
}
catch(...)
@@ -518,7 +503,7 @@
#else
if (::ftruncate(m_hFile, getpos()) == -1)
#endif
- THROW(exception::format("[file] Cannot truncate the file " STRFMT, m_pszPath), FERR_SETEOF, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("[file] Cannot truncate the file ") STRFMT, m_pszPath), FERR_SETEOF, CURRENT_LAST_ERROR, 0);
}
/** Returns a size of the file.
@@ -537,7 +522,7 @@
struct stat st;
if (fstat(m_hFile, &st) == -1)
#endif
- THROW(exception::format("[file] Cannot get the size of the file " STRFMT, m_pszPath), FERR_GETSIZE, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("[file] Cannot get the size of the file ") STRFMT, m_pszPath), FERR_GETSIZE, CURRENT_LAST_ERROR, 0);
#ifdef _WIN32
return li.QuadPart;
@@ -613,21 +598,6 @@
}
}
-#ifdef USE_ENCRYPTION
-/** Function sets the password used for symmetric encryption/decryption
- * of some serialization blocks.
- * \param[in] pszPass - passphrase used for encryption/decryption
- */
-void file::set_password(const char_t* pszPass)
-{
- // generate the SHA256 from this password
- char_t szPass[64+1];
- str2key256(pszPass, szPass);
- m_strPassword=szPass;
-}
-
-#endif
-
/** Begins the serialization data block. Each block can have it's
* own flags. Each block have to be ended with datablock_end before
* beginning another one. If the access is read then function tries to read
@@ -647,7 +617,7 @@
// check flags
if ((m_uiFlags & FA_READ) && (m_uiFlags & FA_WRITE))
- THROW(exception::format("[file] Tried to begin a data block with file " STRFMT " opened for both read and write.", m_pszPath), FERR_SERIALIZE, 0, 0);
+ THROW(exception::format(_t("[file] Tried to begin a data block with file ") STRFMT _t(" opened for both read and write."), m_pszPath), FERR_SERIALIZE, 0, 0);
// action
if (m_uiFlags & FA_WRITE)
@@ -661,7 +631,7 @@
if (read(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)) != sizeof(SERIALIZEINFOHEADER))
{
_clear_serialization();
- THROW(exception::format("[file] Cannot read the specified amount of data from a file (reading serialization header).", m_pszPath), FERR_SERIALIZE, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("[file] Cannot read the specified amount of data from a file (reading serialization header)."), m_pszPath), FERR_SERIALIZE, CURRENT_LAST_ERROR, 0);
}
// move forward
@@ -676,7 +646,7 @@
if (uihc != psih->uiHeaderCRC32)
{
_clear_serialization();
- THROW(exception::format("[file] Block contained in file " STRFMT " is corrupted. Header CRC check failed.", m_pszPath), FERR_SERIALIZE, 0, 0);
+ THROW(exception::format(_t("[file] Block contained in file ") STRFMT _t(" is corrupted. Header CRC check failed."), m_pszPath), FERR_SERIALIZE, 0, 0);
}
// resize the buffer
@@ -689,27 +659,16 @@
if (read(m_pbySerialBuffer+m_uiSerialBufferPos, uiSize) != (int_t)uiSize)
{
_clear_serialization();
- THROW(exception::format("Cannot read specified amount of data from a file " STRFMT " (reading the after-header data).", m_pszPath), FERR_SERIALIZE, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("Cannot read specified amount of data from a file ") STRFMT _t(" (reading the after-header data)."), m_pszPath), FERR_SERIALIZE, CURRENT_LAST_ERROR, 0);
}
-#ifdef USE_ENCRYPTION
- // decrypt the data
- if (uiFlags & BF_ENCRYPTED && !m_strPassword.is_empty())
- {
- if (decrypt_aes256(m_pbySerialBuffer+m_uiSerialBufferPos, uiSize, m_strPassword, m_pbySerialBuffer+m_uiSerialBufferPos) < 0)
- {
- _clear_serialization();
- THROW(exception::format("Cannot decrypt the data read from the serialization file " STRFMT ".", m_pszPath), FERR_CRYPT, 0, 0);
- }
- }
-#endif
// NOTE: do not update the position - we need ptr at the beginning of data
// now we are almost ready to retrieve data - only the crc check for the data
uint_t uiCRC=crc32(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), psih->iDataSize-sizeof(SERIALIZEINFOHEADER));
if (psih->uiCRC32 != uiCRC)
{
_clear_serialization();
- THROW(exception::format("CRC check of the data read from file " STRFMT " failed.", m_pszPath), FERR_SERIALIZE, 0, 0);
+ THROW(exception::format(_t("CRC check of the data read from file ") STRFMT _t(" failed."), m_pszPath), FERR_SERIALIZE, 0, 0);
}
}
@@ -729,7 +688,7 @@
// check the operation type
if ((m_uiFlags & FA_READ) && (m_uiFlags & FA_WRITE))
- THROW(exception::format("[file] Tried to end a data block with file " STRFMT " opened for both read and write.", m_pszPath), FERR_SERIALIZE, 0, 0);
+ THROW(exception::format(_t("[file] Tried to end a data block with file ") STRFMT _t(" opened for both read and write."), m_pszPath), FERR_SERIALIZE, 0, 0);
// when writing - make a header, ...; when reading - do nothing important
if (m_uiFlags & FA_WRITE)
@@ -743,29 +702,9 @@
psih->iDataSize=m_uiSerialBufferPos;
psih->uiCRC32=crc32(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER), m_uiSerialBufferPos-sizeof(SERIALIZEINFOHEADER));
-#ifdef USE_ENCRYPTION
- // we could encrypt the data here if needed
- if (m_uiDataBlockFlags & BF_ENCRYPTED && !m_strPassword.is_empty())
- {
- int_t iRes=crypt_aes256((ptr_t)(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER)), m_uiSerialBufferPos-sizeof(SERIALIZEINFOHEADER), m_strPassword, (ptr_t)(m_pbySerialBuffer+sizeof(SERIALIZEINFOHEADER)));
- if (iRes < 0)
- {
- _clear_serialization();
- THROW("Cannot encrypt the data to store.", FERR_CRYPT, 0, 0);
- }
+ // the rest of header
+ psih->iRealSize=m_uiSerialBufferPos;
- // fill the header
- psih->iRealSize=iRes+sizeof(SERIALIZEINFOHEADER);
- }
- else
- {
-#endif
- // the rest of header
- psih->iRealSize=m_uiSerialBufferPos;
-#ifdef USE_ENCRYPTION
- }
-#endif
-
// calc the header crc
psih->uiHeaderCRC32=crc32(m_pbySerialBuffer, sizeof(SERIALIZEINFOHEADER)-sizeof(uint_t));
@@ -826,7 +765,7 @@
* \param[in] val - value to be stored in a file
* \return Reference to this file object.
*/
-file& file::operator<<(char_t val)
+file& file::operator<<(tchar_t val)
{
swrite(&val, sizeof(val));
return *this;
@@ -837,7 +776,7 @@
* \param[in] val - reference to a variable to receive data
* \return Reference to this file object.
*/
-file& file::operator>>(char_t& val)
+file& file::operator>>(tchar_t& val)
{
sread(&val, sizeof(val));
return *this;
@@ -997,93 +936,6 @@
return *this;
}
-/** Stores a string object in the file.
- * \param[in] str - reference to the string object to store.
- * \return Reference to this object.
- */
-file& file::operator<<(string& str)
-{
-#ifdef ALLOW_UNICODE
- if (str.is_unicode())
- {
- // get the internal buffer with at least 1 character (NULL)
- wchar_t* psz=str.get_bufferu(1);
- int_t iLen=(int_t)(str.bytelen());
-
- // store len
- swrite(&iLen, sizeof(int_t));
-
- // an unicode flag
- bool bUnicode=str.is_unicode();
- swrite(&bUnicode, sizeof(bool));
-
- // and the buffer itself
- swrite(psz, iLen);
- }
- else
- {
-#endif
- // internal buffer
- char_t* psz=str.get_buffera(1);
- int_t iLen=(int_t)(str.bytelen());
-
- // write the length
- swrite(&iLen, sizeof(int_t));
-
- // write the unicode flag - for compatibility with unicode version of the code
- bool bUnicode=false;
- swrite(&bUnicode, sizeof(bool));
-
- // write the data
- swrite(psz, iLen);
-#ifdef ALLOW_UNICODE
- }
-#endif
-
- return *this;
-}
-
-/** Reads a string object from this file.
- * \param[in] str - reference to the string object to receive the string.
- * \return Reference to this object.
- */
-file& file::operator>>(string& str)
-{
- // read the length
- int_t iLen=0;
- sread(&iLen, sizeof(int_t));
-
- // read the unicode flag
- bool bUnicode=false;
- sread(&bUnicode, sizeof(bool));
-
- if (bUnicode)
- {
-#ifdef ALLOW_UNICODE
- str.clear();
- str.make_unicode();
- wchar_t* psz=str.get_bufferu(iLen);
-
- sread(psz, iLen);
- str.release_buffer();
-#else
- THROW("Cannot read an unicode string from a file. This library was not built with unicode support.", FERR_UNICODE, 0, 0);
-#endif
- }
- else
- {
- // ansi string
- str.clear();
- str.make_ansi();
- char_t* psz=str.get_buffera(iLen);
-
- sread(psz, iLen);
- str.release_buffer();
- }
-
- return *this;
-}
-
/** Cancels the serialization process and removes all the traces of data being serialized
* (it includes deleting the serialization buffer).
*/
@@ -1113,7 +965,7 @@
int_t rd;
if ((rd=::read(m_hFile, m_pbyBuffer, m_uiBufferSize)) == -1)
#endif
- THROW(exception::format("[file] Cannot read data from a file " STRFMT ".", m_pszPath), FERR_READ, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("[file] Cannot read data from a file ") STRFMT _t("."), m_pszPath), FERR_READ, CURRENT_LAST_ERROR, 0);
// reset internal members
m_uiDataCount=rd;
@@ -1138,7 +990,7 @@
if ((wr=::write(m_hFile, m_pbyBuffer, m_uiDataCount)) == -1)
#endif
{
- THROW(exception::format("Cannot write data to a file " STRFMT ".", m_pszPath), FERR_WRITE, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("Cannot write data to a file ") STRFMT _t("."), m_pszPath), FERR_WRITE, CURRENT_LAST_ERROR, 0);
}
// reset internal members
@@ -1161,7 +1013,7 @@
if (m_uiSerialBufferPos+uiLen > m_uiSerialBufferSize)
{
// throw an exception - read beyond the data range in a given object
- THROW(exception::format("[file] Trying to read the serialization data beyond the range (file " STRFMT ").", m_pszPath), FERR_MEMORY, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("[file] Trying to read the serialization data beyond the range (file ") STRFMT _t(")."), m_pszPath), FERR_MEMORY, CURRENT_LAST_ERROR, 0);
}
// read the data
@@ -1228,9 +1080,9 @@
* \param[in] uiMaxLen - size of the string buffer
* \return Bool value that states if the string has been read.
*/
-bool file::_read_string(char_t* pszStr, uint_t uiMaxLen)
+bool file::_read_string(tchar_t* pszStr, uint_t uiMaxLen)
{
- assert(m_hFile); // file wasn't opened - error opening or you've forgotten to do so ?
+ assert(m_hFile); // file wasn_t('t opened - error opening or you')ve forgotten to do so ?
assert(m_pbyBuffer != NULL);
// last time was writing - free buffer
@@ -1241,20 +1093,20 @@
}
// zero all the string
- memset(pszStr, 0, uiMaxLen*sizeof(char_t));
+ memset(pszStr, 0, uiMaxLen*sizeof(tchar_t));
// additional vars
uint_t uiStrPos=0; // current pos in external buffer
- bool bSecondPass=false; // if there is need to check data for 0x0a char_t
+ bool bSecondPass=false; // if there is need to check data for 0x0a tchar_t
- // copy each char_t into pszString
+ // copy each tchar_t into pszString
for (;;)
{
// if buffer is empty - fill it
if (m_uiDataCount == 0 || m_uiCurrentPos == m_uiDataCount)
{
if (_read_packet() == 0)
- return strlen(pszStr) != 0;
+ return _tcslen(pszStr) != 0;
}
// skipping 0x0a in second pass
@@ -1306,7 +1158,7 @@
int_t lRes;
if ((lRes=lseek(m_hFile, llOffset, uiFrom)) == -1)
#endif
- THROW(exception::format("Seek error in file " STRFMT ".", m_pszPath), FERR_SEEK, CURRENT_LAST_ERROR, 0);
+ THROW(exception::format(_t("Seek error in file ") STRFMT _t("."), m_pszPath), FERR_SEEK, CURRENT_LAST_ERROR, 0);
#ifdef _WIN32
return li.QuadPart;
Index: ext/libicpf/src/file.h
===================================================================
diff -u -r2446443341715955423610c01b43fe7841a10e3e -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/file.h (.../file.h) (revision 2446443341715955423610c01b43fe7841a10e3e)
+++ ext/libicpf/src/file.h (.../file.h) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -29,7 +29,7 @@
#include "exception.h"
#include "libicpf.h"
-#include "str.h"
+//#include "str.h"
#ifdef _WIN32
#include "windows.h"
#endif
@@ -54,10 +54,6 @@
// begin data block flags
/// Standard flag - cannot be combined with others
#define BF_NONE 0x00
-#ifdef USE_ENCRYPTION
-/// The block should be encrypted
-#define BF_ENCRYPTED 0x01
-#endif
// seek constants
#ifdef _WIN32
@@ -114,16 +110,16 @@
*/
/**@{*/
// open/close the file
- void open(const char_t* pszPath, uint_t uiFlags, uint_t uiBufSize=4096); ///< Opens a file with a given path
+ void open(const tchar_t* pszPath, uint_t uiFlags, uint_t uiBufSize=4096); ///< Opens a file with a given path
void close(); ///< Closes the currently opened file
// reads or writes the data from/to a file (uses buffering for these operations if enabled)
ulong_t read(ptr_t pBuffer, ulong_t ulSize); ///< Reads some data from a file
ulong_t write(ptr_t pBuffer, ulong_t ulSize); ///< Writes some data to a file
// handling the lines of text in a file (autodetecting the windows/unix style of line ending)
- bool read_line(char_t* pszStr, uint_t uiMaxLen); ///< Reads a line of text from a file
- void write_line(char_t* pszString); ///< Writes a line of text to a file
+ bool read_line(tchar_t* pszStr, uint_t uiMaxLen); ///< Reads a line of text from a file
+ void write_line(tchar_t* pszString); ///< Writes a line of text to a file
// position related functions
void seek(longlong_t llOffset, uint_t uiFrom); ///< Moves a file pointer in a file
@@ -162,10 +158,6 @@
void datablock_begin(uint_t dwFlags=BF_NONE); ///< Begins the serialization data block
void datablock_end(); ///< Ends the serialization data block
-#ifdef USE_ENCRYPTION
- void set_password(const char_t* pszPass); ///< Sets encryption/decryption password for serialization
-#endif
-
// serialization stuff
void swrite(ptr_t pData, uint_t dwSize); ///< Appends some data to the serialialization buffer
void sread(ptr_t pData, uint_t dwSize); ///< Reads some data from serialization buffer
@@ -179,8 +171,8 @@
// storing&reading data
file& operator<<(bool val); ///< Stores a given 'val' parameter in the file
file& operator>>(bool& val); ///< Reads a value of a given type from the file
- file& operator<<(char_t val); ///< Stores a given 'val' parameter in the file
- file& operator>>(char_t& val); ///< Reads a value of a given type from the file
+ file& operator<<(tchar_t val); ///< Stores a given 'val' parameter in the file
+ file& operator>>(tchar_t& val); ///< Reads a value of a given type from the file
file& operator<<(uchar_t val); ///< Stores a given 'val' parameter in the file
file& operator>>(uchar_t& val); ///< Reads a value of a given type from the file
file& operator<<(short_t val); ///< Stores a given 'val' parameter in the file
@@ -202,8 +194,8 @@
template file& operator>>(T& tData) { sread(&tData, sizeof(T)); return *this; };*/
// specialized serialization stuff
- file& operator<<(icpf::string& str); ///< Stores a CString object in this file (only usable when used in an MFC program)
- file& operator>>(icpf::string& str); ///< Reads a CString object from this file (only usable when used in an mfc program)
+// file& operator<<(icpf::string& str); ///< Stores a CString object in this file (only usable when used in an MFC program)
+// file& operator>>(icpf::string& str); ///< Reads a CString object from this file (only usable when used in an mfc program)
/**@}*/
protected:
@@ -217,7 +209,7 @@
uint_t _read_packet(); ///< Reads next packet of data into the internal buffer
uint_t _write_packet(); ///< Writes next packet of data into a file
- bool _read_string(char_t* pszStr, uint_t dwMaxLen); ///< Reads a string from an internal buffer
+ bool _read_string(tchar_t* pszStr, uint_t dwMaxLen); ///< Reads a string from an internal buffer
longlong_t _seek(longlong_t llOffset, uint_t uiFrom); ///< A standard seek command done wo any flushing
protected:
@@ -226,7 +218,7 @@
#else
intptr_t m_hFile; ///< Handle to a real file
#endif
- char_t* m_pszPath; ///< Path to the opened file as passed to file::open()
+ tchar_t* m_pszPath; ///< Path to the opened file as passed to file::open()
uint_t m_uiFlags; ///< File flags as passed to file::open()
bool m_bLastOperation; ///< States the last operation performed - false=>READ, true=>WRITE
@@ -247,12 +239,6 @@
uint_t m_uiSerialBufferSize; ///< Current size of the serialization buffer
uint_t m_uiSerialBufferPos; ///< Current position in the serialization buffer
uint_t m_uiDataBlockFlags; ///< Flags of the current serialization block
-
-
-#ifdef USE_ENCRYPTION
- // encryption related
- string m_strPassword; ///< Password used for encryption/decryption of serialization data
-#endif
};
END_ICPF_NAMESPACE
Index: ext/libicpf/src/gen_types.h
===================================================================
diff -u -r715fea7874b61921a42db6e8925029a69f678b89 -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/gen_types.h (.../gen_types.h) (revision 715fea7874b61921a42db6e8925029a69f678b89)
+++ ext/libicpf/src/gen_types.h (.../gen_types.h) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -37,6 +37,8 @@
#include
#endif
+#include
+
// standard types and formats used throughout the library
// exactly 1 byte
/// Byte type (8bit unsigned int)
@@ -52,15 +54,20 @@
#if (defined(_WIN32) || defined(_WIN64)) && defined(_UNICODE)
/// System/configuration dependent character (either wide char or normal one)
typedef wchar_t tchar_t;
+ typedef std::wstring tstring_t;
/// Macro to be appended to each text in code to be either composed of wide characters or normal ones
- #define _t(text) L(text)
+ #define __t(text) L##text
+ #define _t(text) __t(text)
/// String formatting string - depending on configuration could display wide char string or normal one.
#define TSTRFMT WSTRFMT
+ #define TCHRFMT CHRFMT
#else
// description as above
typedef char_t tchar_t;
+ typedef std::string tstring_t;
#define _t(text) text
#define TSTRFMT STRFMT
+ #define TCHRFMT CHRFMT
#endif
// 16-bit integers
Index: ext/libicpf/src/log.cpp
===================================================================
diff -u -r2446443341715955423610c01b43fe7841a10e3e -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/log.cpp (.../log.cpp) (revision 2446443341715955423610c01b43fe7841a10e3e)
+++ ext/libicpf/src/log.cpp (.../log.cpp) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -21,52 +21,37 @@
* \brief Contains the implamentation of a log class.
*/
#include "log.h"
+#include "exception.h"
#include
#include
#include
#include
#include "macros.h"
-#ifdef WIN32
+#if defined(_WIN32) || defined(_WIN64)
#include
#include
#include
#else
#include
#endif
-#ifdef WIN32
- #undef vsnprintf
- #define vsnprintf _vsnprintf
- #undef snprintf
- #define snprintf _snprintf
-#endif
-
BEGIN_ICPF_NAMESPACE
/// Table of strings representing the log message types
-const char_t* __logtype_str[] = { "debug", "info", "warning", "error" };
+const tchar_t* __logtype_str[] = { _t("debug"), _t("info"), _t("warning"), _t("error") };
-/// Global variable initialized when constructing log_file object
-log_file* __g_log=NULL;
-
/** Constructs a log_file object.
* \param[in] bGlobal - states if this should be treates as a global instance of the log_file.
* Only one global log_file instance could exist in the application.
*/
-log_file::log_file(bool bGlobal) :
+log_file::log_file() :
m_pszPath(NULL),
m_iMaxSize(262144),
m_bLogStd(false),
- m_iLogLevel(LT_DEBUG),
- m_bGlobal(bGlobal),
+ m_iLogLevel(level_debug),
m_lock()
{
- if (m_bGlobal)
- {
- assert(__g_log == NULL); // there is another instance of a global log running
- __g_log=this;
- }
#ifdef WIN32
_fmode=_O_BINARY;
#endif
@@ -76,58 +61,33 @@
*/
log_file::~log_file()
{
- if (m_bGlobal)
- __g_log=NULL;
delete [] m_pszPath;
}
-/** Creates a global instance of a log file.
- * \param[in] pszPath - path to a log file to write to
- * \param[in] iMaxSize - maximum size of a log file
- * \param[in] iLogLevel - minimum log level of the messages to log
- * \param[in] bLogStd - log the messages also to stdout/stderr
- * \param[in] bClean - cleans the log file upon opening
- * \return True if the log file has been successfully initialized or false if not.
- */
-bool log_file::create_log(const char_t* pszPath, int_t iMaxSize, int_t iLogLevel, bool bLogStd, bool bClean)
-{
- assert(__g_log == NULL);
-
- __g_log=new log_file(true);
- if (!__g_log->init(pszPath, iMaxSize, iLogLevel, bLogStd, bClean))
- {
- delete __g_log;
- __g_log=NULL;
- return false;
- }
-
- return true;
-}
-
/** Initializes the constructed log file.
* \param[in] pszPath - path to a log file to write to
* \param[in] iMaxSize - maximum size of a log file
* \param[in] iLogLevel - minimum log level of the messages to log
* \param[in] bLogStd - log the messages also to stdout/stderr
* \param[in] bClean - cleans the log file upon opening
- * \return True if the log file has been successfully initialized or false if not.
*/
-bool log_file::init(const char_t* pszPath, int_t iMaxSize, int_t iLogLevel, bool bLogStd, bool bClean)
+void log_file::init(const tchar_t* pszPath, int_t iMaxSize, int_t iLogLevel, bool bLogStd, bool bClean)
{
+ // store the path and other params
delete [] m_pszPath;
- m_pszPath=new char_t[strlen(pszPath)+1];
- strcpy(m_pszPath, pszPath);
+ m_pszPath=new tchar_t[_tcslen(pszPath)+1];
+ _tcscpy(m_pszPath, pszPath);
m_iMaxSize=iMaxSize;
m_bLogStd=bLogStd;
m_iLogLevel=iLogLevel;
- FILE* pFile=fopen(pszPath, bClean ? "w" : "a");
+ // try to open a file
+ FILE* pFile=_tfopen(pszPath, bClean ? _t("w") : _t("a"));
if (pFile == NULL)
- return false;
+ THROW(exception::format(_t("[log_file::init()] Could not open the specified file (") TSTRFMT _t(")")), 0, 0, 0);
fclose(pFile);
- return true;
}
/** Retrieves the current size of a log file.
@@ -139,7 +99,7 @@
assert(m_pszPath);
int_t iSize=-1;
- FILE* pFile=fopen(m_pszPath, "r");
+ FILE* pFile=_tfopen(m_pszPath, _t("r"));
if (pFile != NULL)
{
if (fseek(pFile, 0, SEEK_END) == 0)
@@ -171,7 +131,7 @@
return false;
// establish the new file size (1/3rd of the current size or max_size-add_size)
- int_t iNewSize=minval((int_t)(iSize*0.66), m_iMaxSize-iAdd);
+ int_t iNewSize=minval((int_t)(iSize*0.66), m_iMaxSize-iAdd) & ~1;
#ifdef _WIN32
// win32 does not have the ftruncate function, so we have to make some API calls
@@ -183,22 +143,23 @@
{
// read the string to the eol
DWORD dwRD;
- char_t szBuffer[4096];
+ tchar_t szBuffer[4096/sizeof(tchar_t)];
if (ReadFile(hFile, szBuffer, 4096, &dwRD, NULL))
{
- szBuffer[(dwRD > 0) ? dwRD-1 : 0]='\0';
+ dwRD/=sizeof(tchar_t);
+ szBuffer[(dwRD > 0) ? dwRD-1 : 0]=_t('\0');
// replace the /r and /n in the log to the \0
for (DWORD i=0;i LT_DEBUG)
+ if (m_iLogLevel > level_debug)
return;
va_list va;
va_start(va, pszStr);
- logv(LT_DEBUG, false, pszStr, va);
+ logv(level_debug, false, pszStr, va);
va_end(va);
}
/** Logs a formatted debug message to a log file(also outputs to stdout).
* \param[in] pszStr - format string for the given parameters
*/
-void log_file::logds(const char_t* pszStr, ...)
+void log_file::logds(const tchar_t* pszStr, ...)
{
- if (m_iLogLevel > LT_DEBUG)
+ if (m_iLogLevel > level_debug)
return;
va_list va;
va_start(va, pszStr);
- logv(LT_DEBUG, true, pszStr, va);
+ logv(level_debug, true, pszStr, va);
va_end(va);
}
#else
-void log_file::logd(const char_t* pszStr, ...)
+void log_file::logd(const tchar_t* /*pszStr*/, ...)
{
}
-void log_file::logds(const char_t* pszStr, ...)
+void log_file::logds(const tchar_t* /*pszStr*/, ...)
{
}
#endif
-#if _LOG_LEVEL <= LT_INFO
+#ifdef SKIP_LEVEL_INFO
/** Logs a formatted informational message to a log file.
* \param[in] pszStr - format string for the given parameters
*/
-void log_file::logi(const char_t* pszStr, ...)
+void log_file::logi(const tchar_t* pszStr, ...)
{
- if (m_iLogLevel > LT_INFO)
+ if (m_iLogLevel > level_info)
return;
va_list va;
va_start(va, pszStr);
- logv(LT_INFO, false, pszStr, va);
+ logv(level_info, false, pszStr, va);
va_end(va);
}
/** Logs a formatted informational message to a log file(also outputs to stdout).
* \param[in] pszStr - format string for the given parameters
*/
-void log_file::logis(const char_t* pszStr, ...)
+void log_file::logis(const tchar_t* pszStr, ...)
{
- if (m_iLogLevel > LT_INFO)
+ if (m_iLogLevel > level_info)
return;
va_list va;
va_start(va, pszStr);
- logv(LT_INFO, true, pszStr, va);
+ logv(level_info, true, pszStr, va);
va_end(va);
}
#else
-void log_file::logi(const char_t* pszStr, ...)
+void log_file::logi(const tchar_t* /*pszStr*/, ...)
{
}
-void log_file::logis(const char_t* pszStr, ...)
+void log_file::logis(const tchar_t* /*pszStr*/, ...)
{
}
#endif
-#if _LOG_LEVEL <= LT_WARNING
+#ifndef SKIP_LEVEL_WARNING
/** Logs a formatted warning message to a log file.
* \param[in] pszStr - format string for the given parameters
*/
-void log_file::logw(const char_t* pszStr, ...)
+void log_file::logw(const tchar_t* pszStr, ...)
{
- if (m_iLogLevel > LT_WARNING)
+ if (m_iLogLevel > level_warning)
return;
va_list va;
va_start(va, pszStr);
- logv(LT_WARNING, false, pszStr, va);
+ logv(level_warning, false, pszStr, va);
va_end(va);
}
/** Logs a formatted warning message to a log file(also outputs to stdout).
* \param[in] pszStr - format string for the given parameters
*/
-void log_file::logws(const char_t* pszStr, ...)
+void log_file::logws(const tchar_t* pszStr, ...)
{
- if (m_iLogLevel > LT_WARNING)
+ if (m_iLogLevel > level_warning)
return;
va_list va;
va_start(va, pszStr);
- logv(LT_WARNING, true, pszStr, va);
+ logv(level_warning, true, pszStr, va);
va_end(va);
}
#else
-void log_file::logw(const char_t* pszStr, ...)
+void log_file::logw(const tchar_t* /*pszStr*/, ...)
{
}
-void log_file::logws(const char_t* pszStr, ...)
+void log_file::logws(const tchar_t* /*pszStr*/, ...)
{
}
@@ -516,22 +465,22 @@
/** Logs a formatted error message to a log file.
* \param[in] pszStr - format string for the given parameters
*/
-void log_file::loge(const char_t* pszStr, ...)
+void log_file::loge(const tchar_t* pszStr, ...)
{
va_list va;
va_start(va, pszStr);
- logv(LT_ERROR, false, pszStr, va);
+ logv(level_error, false, pszStr, va);
va_end(va);
}
/** Logs a formatted error message to a log file(also outputs to stderr).
* \param[in] pszStr - format string for the given parameters
*/
-void log_file::loges(const char_t* pszStr, ...)
+void log_file::loges(const tchar_t* pszStr, ...)
{
va_list va;
va_start(va, pszStr);
- logv(LT_ERROR, true, pszStr, va);
+ logv(level_error, true, pszStr, va);
va_end(va);
}
@@ -541,21 +490,21 @@
* \param[in] pszStr - format string for the given parameters
* \param[in] iSysErr - system error to be shown
*/
-void log_file::logerr(const char_t* pszStr, int iSysErr, ...)
+void log_file::logerr(const tchar_t* pszStr, int iSysErr, ...)
{
- char_t szNewFmt[2048];
+ tchar_t szNewFmt[2048];
if (prepare_fmt(pszStr, iSysErr, szNewFmt))
{
va_list va;
va_start(va, iSysErr);
- logv(LT_ERROR, false, szNewFmt, va);
+ logv(level_error, false, szNewFmt, va);
va_end(va);
}
else
{
va_list va;
va_start(va, iSysErr);
- logv(LT_ERROR, false, pszStr, va);
+ logv(level_error, false, pszStr, va);
va_end(va);
}
}
@@ -568,21 +517,21 @@
* \param[in] pszStr - format string for the given parameters
* \param[in] iSysErr - system error to be shown
*/
-void log_file::logerrs(const char_t* pszStr, int iSysErr, ...)
+void log_file::logerrs(const tchar_t* pszStr, int iSysErr, ...)
{
- char_t szNewFmt[2048];
+ tchar_t szNewFmt[2048];
if (prepare_fmt(pszStr, iSysErr, szNewFmt))
{
va_list va;
va_start(va, iSysErr);
- logv(LT_ERROR, true, szNewFmt, va);
+ logv(level_error, true, szNewFmt, va);
va_end(va);
}
else
{
va_list va;
va_start(va, iSysErr);
- logv(LT_ERROR, true, pszStr, va);
+ logv(level_error, true, pszStr, va);
va_end(va);
}
}
@@ -594,31 +543,31 @@
* \param[out] pszOut - pointer to a buffer that will receive the data (must be 2048 bytes in size)
* \return If the %err string was found and replaced within a given format string.
*/
-bool log_file::prepare_fmt(const char_t* pszStr, int iSysErr, char_t* pszOut) const
+bool log_file::prepare_fmt(const tchar_t* pszStr, int iSysErr, tchar_t* pszOut) const
{
// find the %err in pszStr
- const char_t* pszFnd=strstr(pszStr, "%err");
+ const tchar_t* pszFnd=_tcsstr(pszStr, _t("%err"));
if (pszFnd)
{
// find an error description for the error
- char_t* pszErrDesc=NULL;
+ tchar_t* pszErrDesc=NULL;
#ifdef _WIN32
- char_t szErrDesc[512];
+ tchar_t szErrDesc[512];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, (DWORD)iSysErr, 0, szErrDesc, 512, NULL);
pszErrDesc=szErrDesc;
#else
pszErrDesc=strerror(iSysErr);
#endif
// format a string with err no and desc
- char_t szError[1024];
- snprintf(szError, 1024, "0x%lx (%s)", iSysErr, pszErrDesc);
+ tchar_t szError[1024];
+ _sntprintf(szError, 1024, _t("0x%lx (%s)"), iSysErr, pszErrDesc);
// replace %err with the new data
- pszOut[0]='\0';
- strncat(pszOut, pszStr, (size_t)(pszFnd-pszStr));
- strcat(pszOut, szError);
- strcat(pszOut, pszFnd+4);
+ pszOut[0]=_t('\0');
+ _tcsncat(pszOut, pszStr, (size_t)(pszFnd-pszStr));
+ _tcscat(pszOut, szError);
+ _tcscat(pszOut, pszFnd+4);
return true;
}
Index: ext/libicpf/src/log.h
===================================================================
diff -u -r2446443341715955423610c01b43fe7841a10e3e -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/log.h (.../log.h) (revision 2446443341715955423610c01b43fe7841a10e3e)
+++ ext/libicpf/src/log.h (.../log.h) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -30,129 +30,59 @@
BEGIN_ICPF_NAMESPACE
-/// Log message type - debug
-#define LT_DEBUG 0x00
-/// Log message type - informational
-#define LT_INFO 0x01
-/// Log message type - warning
-#define LT_WARNING 0x02
-/// Log message type - error
-#define LT_ERROR 0x03
-
-class log_file;
-
-extern log_file* __g_log;
-
-#ifndef _LOG_LEVEL
-/** \brief Specifies the log level used by program.
- *
- * All the log messages used in code will be checked against this log level
- * and if below then they will be removed from the code (probably).
- */
-#define _LOG_LEVEL LT_DEBUG
-#endif
-
-/// Logs a message using the global instance of the log class.
-#define LOG\
- __g_log->log
-
-/// Logs a debug message using the global instance of the log class.
-#define LOGD\
- __g_log->logd
-/// Logs a debug message (with outputting it to stdout) using the global instance of the log class.
-#define LOGDS\
- __g_log->logds
-
-/// Logs an informational message using the global instance of the log class.
-#define LOGI\
- __g_log->logi
-/// Logs an informational message (with outputting it to stdout) using the global instance of the log class.
-#define LOGIS\
- __g_log->logis
-
-/// Logs a warning message using the global instance of the log class.
-#define LOGW\
- __g_log->logw
-/// Logs a warning (with outputting it to stdout) message using the global instance of the log class.
-#define LOGWS\
- __g_log->logws
-
-/// Logs an error message using the global instance of the log class.
-#define LOGE\
- __g_log->loge
-/// Logs an error message (with outputting it to stdout) using the global instance of the log class.
-#define LOGES\
- __g_log->loges
-
/** \brief Class provides the message logging capability.
*
* Class used to perform message logging to the external file. Provides a possibility
* of limiting the max size of a file and to cut the log message types below a specific
- * level. When constructed, class makes a global variable accessed by the friend function
- * get_log() . As a helpers there has been some macros introduced (LOGXXX) that makes usage
- * of the global variable.
- * Usage: either construct a log_file object and init() it, or call a friend create_log()
- * and delete_log() when finished using the class.
+ * level.
* Class is thread safe.
*/
class LIBICPF_API log_file
{
public:
+ /// Supported log levels
+ enum log_levels
+ {
+ level_debug, /// Debug level (the most detailed one)
+ level_info, /// Informational level
+ level_warning, /// Warning level
+ level_error /// Error level (the least detailed one)
+ };
+
+public:
/** \name Construction/destruction */
/**@{*/
- explicit log_file(bool bGlobal=false); ///< Standard constructor
+ explicit log_file(); ///< Standard constructor
~log_file(); ///< Standard destructor
/**@}*/
/** \name Initialization */
/**@{*/
- bool init(const char_t* pszPath, int_t iMaxSize, int_t iLogLevel, bool bLogStd, bool bClean); ///< Initializes the logging object
+ void init(const tchar_t* pszPath, int_t iMaxSize, int_t iLogLevel, bool bLogStd, bool bClean); ///< Initializes the logging object
/**@}*/
/** \name Logging functions */
/**@{*/
- void logs(int_t iType, bool bStd, const char_t* pszStr); ///< Logs a string without formatting
- void log(int_t iType, bool bStd, const char_t* pszStr, ...); ///< Logs a string with formatting
- void logv(int_t iType, bool bStd, const char_t* pszStr, va_list va); ///< Logs a string using va_list
+ void logs(int_t iType, bool bStd, const tchar_t* pszStr); ///< Logs a string without formatting
+ void log(int_t iType, bool bStd, const tchar_t* pszStr, ...); ///< Logs a string with formatting
+ void logv(int_t iType, bool bStd, const tchar_t* pszStr, va_list va); ///< Logs a string using va_list
-#if _LOG_LEVEL <= LT_DEBUG
- void logd(const char_t* pszStr, ...); ///< Logs a debug message with formatting
- void logds(const char_t* pszStr, ...); ///< Logs a debug message with formatting (also prints to stdout)
-#else
- void logd(const char_t* pszStr, ...);
- void logds(const char_t* pszStr, ...);
-#endif
+ void logd(const tchar_t* pszStr, ...); ///< Logs a debug message with formatting
+ void logds(const tchar_t* pszStr, ...); ///< Logs a debug message with formatting (also prints to stdout)
-#if _LOG_LEVEL <= LT_INFO
- void logi(const char_t* pszStr, ...); ///< Logs an informational message with formatting
- void logis(const char_t* pszStr, ...); ///< Logs an informational message with formatting(also prints to stdout)
-#else
- void logi(const char_t* pszStr, ...);
- void logis(const char_t* pszStr, ...);
-#endif
+ void logi(const tchar_t* pszStr, ...); ///< Logs an informational message with formatting
+ void logis(const tchar_t* pszStr, ...); ///< Logs an informational message with formatting(also prints to stdout)
-#if _LOG_LEVEL <= LT_WARNING
- void logw(const char_t* pszStr, ...); ///< Logs a warning message with formatting
- void logws(const char_t* pszStr, ...); ///< Logs a warning message with formatting(also prints to stdout)
-#else
- void logw(const char_t* pszStr, ...);
- void logws(const char_t* pszStr, ...);
-#endif
+ void logw(const tchar_t* pszStr, ...); ///< Logs a warning message with formatting
+ void logws(const tchar_t* pszStr, ...); ///< Logs a warning message with formatting(also prints to stdout)
- void loge(const char_t* pszStr, ...); ///< Logs an error message with formatting
- void loges(const char_t* pszStr, ...); ///< Logs an error message with formatting(also prints to stderr)
+ void loge(const tchar_t* pszStr, ...); ///< Logs an error message with formatting
+ void loges(const tchar_t* pszStr, ...); ///< Logs an error message with formatting(also prints to stderr)
- void logerr(const char_t* pszStr, int iSysErr, ...); ///< Logs an error message with system error number and error description
- void logerrs(const char_t* pszStr, int iSysErr, ...); ///< Logs an error message with system error number and error description (also prints to stderr)
+ void logerr(const tchar_t* pszStr, int_t iSysErr, ...); ///< Logs an error message with system error number and error description
+ void logerrs(const tchar_t* pszStr, int_t iSysErr, ...); ///< Logs an error message with system error number and error description (also prints to stderr)
/**@}*/
- /// Gets the global instance of the log file
- static log_file* get_log() { return __g_log; };
- /// Creates a global instance of a log file
- static bool create_log(const char_t* pszPath, int_t iMaxSize, int_t iLogLevel, bool bLogStd, bool bClean);
- /// Deletes a global instance of a log dile
- static void delete_log() { delete __g_log; };
-
protected:
/// Truncates a log file not to exceed the max file size
bool truncate(int_t iAdd) const;
@@ -161,14 +91,13 @@
private:
/// Prepares a new format string for logerr(s) functions
- bool prepare_fmt(const char_t* pszStr, int iSysErr, char_t* pszOut) const;
+ bool prepare_fmt(const tchar_t* pszStr, int_t iSysErr, tchar_t* pszOut) const;
protected:
- char_t* m_pszPath; ///< Path to the log file
+ tchar_t* m_pszPath; ///< Path to the log file
int_t m_iMaxSize; ///< Maximum size of the log file
bool m_bLogStd; ///< Log also to stdout/stderr
int_t m_iLogLevel; ///< Log level (similar to the _LOG_LEVEL, but change'able after compilation)
- bool m_bGlobal; ///< Is this the global instance of app log ? (so the LOG* macros would use it)
protected:
mutex m_lock; ///< Lock for making the class thread safe
Index: ext/libicpf/src/module.cpp
===================================================================
diff -u -re553b1c870c6974c1bbab69390b6e720eaf89e55 -r6dae57f5e7aeeb965bc018024d8360069f6e15c1
--- ext/libicpf/src/module.cpp (.../module.cpp) (revision e553b1c870c6974c1bbab69390b6e720eaf89e55)
+++ ext/libicpf/src/module.cpp (.../module.cpp) (revision 6dae57f5e7aeeb965bc018024d8360069f6e15c1)
@@ -386,7 +386,7 @@
///** Function opens the external file as the program module. After successful
// * file opening this function loads all exports from the module (using load_exports()
// * function) and caches the module information in the internal member if all goes ok.
-// * If something goes wrong the exception* is thrown. All information (excluding exceptions
+// * If something goes wrong the exception is thrown. All information (excluding exceptions
// * are logged to the log file (MODULE_INITDATA)).
// * \param[in] pszPath - full path to the module that is about to be loaded
// */
@@ -426,7 +426,7 @@
///** Closes the external module. At first it uninitializes the module that is about to
// * be unloaded and then closes the module and resets all(except the module info) the
// * internal data. Function is safe to be called more than once. If any problem occur
-// * there is the exception* thrown.
+// * there is the exception thrown.
// * \param[in] bFullDestruct - should be true only in destructor. Means deleting the path string
// * before uninitialization (and not after as with false).
// */
@@ -532,7 +532,7 @@
// * of the derived classes (internal modules). For external modules this function calls the
// * module's init() function. This function is safe to be called multiple times - the real
// * initialization functions will be called only once. On error either false value can be returned
-// * or exception* will be thrown.
+// * or exception will be thrown.
// * \note For internal modules - this function at first should check if the module has been
// * initialized (by checking the MF_INITIALIZED flag - it must be set). If it is not then
// * no uninitialization should be done.
@@ -590,7 +590,7 @@
//// called to load all exported functions (must be called for any derived load_exports())
///** Loads the exports associated with a given type of module. This should be the first function
// * to be called in load_exports() of derived classes. If a specified exports does not
-// * exist in a module an exception* is thrown.
+// * exist in a module an exception is thrown.
// * \note Use the MAP_EXPORT macro here to assign together the function name to the
// * function address.
// */
@@ -642,7 +642,7 @@
// {
// remove_all(true);
// }
-// catch(exception* e)
+// catch(exception& e)
// {
// LOG_EXCEPTION(e, m_pmid->plog);
// e->del();
@@ -720,7 +720,7 @@
// else
// delete pmod; // also calls module::close(), but does not throw an exception
// }
-// catch(exception* e)
+// catch(exception e)
// {
// m_pmid->plog->logw("[module_list] Caught an exception while trying to open a module (path=" STRFMT ").Ignoring module.", sz);
// LOG_EXCEPTION(e, m_pmid->plog);
@@ -1033,7 +1033,7 @@
// {
// remove(--it, bForce);
// }
-// catch(exception* e)
+// catch(exception& e)
// {
// m_pmid->plog->logd("[module_list] Caught an exception in module_list::remove_all() while removing module from a list.Ignoring.");
// LOG_EXCEPTION(e, m_pmid->plog);
@@ -1085,7 +1085,7 @@
// m_pmid->plog->logw("[module_list] Removing module (id=" MODIDXFMT ") knowing that module uninit proc failed", tid);
// }
// }
-// catch(exception* e)
+// catch(exception& e)
// {
// if (!bForce)
// throw; // rethrow the exception - will be reported by some other func
@@ -1102,7 +1102,7 @@
// {
// mod->close();
// }
-// catch(exception* e)
+// catch(exception& e)
// {
// if (!bForce)
// throw;