00001 /* 00002 * Util.h 00003 * 00004 * Copyright 2003, MobileSpear Inc. (www.mobilespear.com). All rights reserved. 00005 * Copyright 2003, David Resnick. All rights reserved. 00006 * 00007 * See the file doc\license.txt for the terms of usage and distribution. 00008 */ 00009 00010 #ifndef _BOGOTEL_UTIL_H 00011 #define _BOGOTEL_UTIL_H 00012 00013 #include <string> 00014 00015 #include <windows.h> // for u_short 00016 00017 #include <log4cpp/Portability.hh> 00018 #include <bogotel/Properties.h> 00019 #include <log4cpp/Priority.hh> 00020 #include <log4cpp/Category.hh> 00021 00022 namespace bogotel { 00023 00024 #define INVALID_INST_NUM -1 00025 #define INI_FILENAME "bogotel.properties" 00026 #define LOG_CAT_NAME "bogotel" 00027 00028 class CUtil 00029 { 00030 public: 00031 CUtil(); 00032 virtual ~CUtil(); 00033 void log(int iLevel, int iChan, char *szFmt, ...); 00034 int init(); 00035 std::string getInstanceNum(); 00036 00037 CProperties m_propIni; 00038 00039 protected: 00040 std::string m_strIniFilename; 00041 int m_iInstanceNum; 00042 00043 int setIniFilename(); 00044 int setInstanceNum(u_short usPort); 00045 int getStringParm(const char *szFilename, char *szName, char *szVal); 00046 00047 private: 00048 log4cpp::Priority::PriorityLevel logLevel2Priority(int iLevel); 00049 log4cpp::Category* m_pLogCat; 00050 std::string m_strIniFilePath; 00051 00052 static const std::string s_arrstrIniLocation[2]; 00053 }; 00054 00055 extern CUtil *g_util; 00056 00057 } 00058 00059 #endif // ! _BOGOTEL_UTIL_H 00060