Permalink
Browse files

Merge branch 'conversion'

  • Loading branch information...
Kyle Fuller
Kyle Fuller committed Aug 14, 2012
2 parents e54f423 + 67299eb commit 8e2de0d4979bee7c06cbc18a223941f8c513a678
View
@@ -49,15 +49,15 @@ class CBuffer : private std::deque<CBufLine> {
CBuffer(unsigned int uLineCount = 100);
~CBuffer();
- int AddLine(const CString& sFormat, const CString& sText = "", const timeval* ts = 0);
+ size_type AddLine(const CString& sFormat, const CString& sText = "", const timeval* ts = 0);
/// Same as AddLine, but replaces a line whose format string starts with sMatch if there is one.
- int UpdateLine(const CString& sMatch, const CString& sFormat, const CString& sText = "");
+ size_type UpdateLine(const CString& sMatch, const CString& sFormat, const CString& sText = "");
/// Same as UpdateLine, but does nothing if this exact line already exists.
/// We need this because "/version" sends us the 005 raws again
- int UpdateExactLine(const CString& sFormat, const CString& sText = "");
+ size_type UpdateExactLine(const CString& sFormat, const CString& sText = "");
const CBufLine& GetBufLine(unsigned int uIdx) const;
- CString GetLine(unsigned int uIdx, const CClient& Client, const MCString& msParams = MCString::EmptyMap) const;
- unsigned int Size() const { return size(); }
+ CString GetLine(size_type uIdx, const CClient& Client, const MCString& msParams = MCString::EmptyMap) const;
+ size_type Size() const { return size(); }
bool IsEmpty() const { return empty(); }
void Clear() { clear(); }
View
@@ -85,7 +85,7 @@ class CChan {
const CBuffer& GetBuffer() const { return m_Buffer; }
unsigned int GetBufferCount() const { return m_Buffer.GetLineCount(); }
bool SetBufferCount(unsigned int u, bool bForce = false) { return m_Buffer.SetLineCount(u, bForce); };
- int AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = NULL) { return m_Buffer.AddLine(sFormat, sText, ts); }
+ size_t AddBuffer(const CString& sFormat, const CString& sText = "", const timeval* ts = NULL) { return m_Buffer.AddLine(sFormat, sText, ts); }
void ClearBuffer() { m_Buffer.Clear(); }
void SendBuffer(CClient* pClient);
// !Buffer
@@ -127,10 +127,10 @@ class CChan {
const CString& GetKey() const { return m_sKey; }
const CString& GetTopic() const { return m_sTopic; }
const CString& GetTopicOwner() const { return m_sTopicOwner; }
- unsigned int GetTopicDate() const { return m_ulTopicDate; }
+ unsigned long GetTopicDate() const { return m_ulTopicDate; }
const CString& GetDefaultModes() const { return m_sDefaultModes; }
const std::map<CString,CNick>& GetNicks() const { return m_msNicks; }
- unsigned int GetNickCount() const { return m_msNicks.size(); }
+ size_t GetNickCount() const { return m_msNicks.size(); }
bool AutoClearChanBuffer() const { return m_bAutoClearChanBuffer; }
bool IsDetached() const { return m_bDetached; }
bool InConfig() const { return m_bInConfig; }
View
@@ -114,6 +114,16 @@ class CConfig {
return false;
}
+ bool FindUShortEntry(const CString& sName, unsigned short& uRes, unsigned short uDefault = 0) {
+ CString s;
+ if (FindStringEntry(sName, s)) {
+ uRes = s.ToUShort();
+ return true;
+ }
+ uRes = uDefault;
+ return false;
+ }
+
bool FindDoubleEntry(const CString& sName, double& fRes, double fDefault = 0) {
CString s;
if (FindStringEntry(sName, s)) {
View
@@ -100,11 +100,11 @@ class CFile {
bool Sync();
bool Open(const CString& sFileName, int iFlags = O_RDONLY, mode_t iMode = 0644);
bool Open(int iFlags = O_RDONLY, mode_t iMode = 0644);
- int Read(char *pszBuffer, int iBytes);
+ ssize_t Read(char *pszBuffer, int iBytes);
bool ReadLine(CString & sData, const CString & sDelimiter = "\n");
bool ReadFile(CString& sData, size_t iMaxSize = 512 * 1024);
- int Write(const char *pszBuffer, u_int iBytes);
- int Write(const CString & sData);
+ ssize_t Write(const char *pszBuffer, size_t iBytes);
+ ssize_t Write(const CString & sData);
void Close();
void ClearBuffer();
@@ -126,7 +126,7 @@ class CFile {
private:
// fcntl() locking wrapper
- bool Lock(int iType, bool bBlocking);
+ bool Lock(short iType, bool bBlocking);
CString m_sBuffer;
int m_iFD;
@@ -165,11 +165,11 @@ class CDir : public std::vector<CFile*> {
clear();
}
- int Fill(const CString& sDir) {
+ size_t Fill(const CString& sDir) {
return FillByWildcard(sDir, "*");
}
- int FillByWildcard(const CString& sDir, const CString& sWildcard) {
+ size_t FillByWildcard(const CString& sDir, const CString& sWildcard) {
CleanUp();
DIR* dir = opendir((sDir.empty()) ? "." : sDir.c_str());
View
@@ -74,14 +74,14 @@ class CHTTPSock : public CSocket {
CString GetRawParam(const CString& sName, bool bPost = true) const;
bool HasParam(const CString& sName, bool bPost = true) const;
const std::map<CString, VCString>& GetParams(bool bPost = true) const;
- unsigned int GetParamValues(const CString& sName, VCString& vsRet, bool bPost = true, const CString& sFilter = "\r\n") const;
- unsigned int GetParamValues(const CString& sName, std::set<CString>& ssRet, bool bPost = true, const CString& sFilter = "\r\n") const;
+ size_t GetParamValues(const CString& sName, VCString& vsRet, bool bPost = true, const CString& sFilter = "\r\n") const;
+ size_t GetParamValues(const CString& sName, std::set<CString>& ssRet, bool bPost = true, const CString& sFilter = "\r\n") const;
// !Parameter access
private:
static CString GetRawParam(const CString& sName, const std::map<CString, VCString>& msvsParams);
static CString GetParam(const CString& sName, const std::map<CString, VCString>& msvsParams, const CString& sFilter);
- static unsigned int GetParamValues(const CString& sName, VCString& vsRet, const std::map<CString, VCString>& msvsParams, const CString& sFilter);
- static unsigned int GetParamValues(const CString& sName, std::set<CString>& ssRet, const std::map<CString, VCString>& msvsParams, const CString& sFilter);
+ static size_t GetParamValues(const CString& sName, VCString& vsRet, const std::map<CString, VCString>& msvsParams, const CString& sFilter);
+ static size_t GetParamValues(const CString& sName, std::set<CString>& ssRet, const std::map<CString, VCString>& msvsParams, const CString& sFilter);
protected:
void PrintPage(const CString& sPage);
View
@@ -172,7 +172,7 @@ class CIRCNetwork {
bool m_bIRCConnectEnabled;
CString m_sIRCServer;
std::vector<CServer*> m_vServers;
- unsigned int m_uServerIdx; ///< Index in m_vServers of our current server + 1
+ size_t m_uServerIdx; ///< Index in m_vServers of our current server + 1
CNick m_IRCNick;
bool m_bIRCAway;
View
@@ -28,7 +28,7 @@ class CNick
void Reset();
void Parse(const CString& sNickMask);
CString GetHostMask() const;
- unsigned int GetCommonChans(std::vector<CChan*>& vChans, CIRCNetwork* pNetwork) const;
+ size_t GetCommonChans(std::vector<CChan*>& vChans, CIRCNetwork* pNetwork) const;
// Setters
void SetNetwork(CIRCNetwork* pNetwork);
View
@@ -44,19 +44,20 @@
// just defines these in inttypes.h which is also part of C99 and is supposed to
// include stdint.h. Solaris 9 is a weirdo. :(
#include <inttypes.h>
+#include <cstddef>
typedef struct {
- unsigned int tot_len;
- unsigned int len;
+ size_t tot_len;
+ size_t len;
unsigned char block[2 * SHA256_BLOCK_SIZE];
uint32_t h[8];
} sha256_ctx;
void sha256_init(sha256_ctx * ctx);
void sha256_update(sha256_ctx *ctx, const unsigned char *message,
- unsigned int len);
+ size_t len);
void sha256_final(sha256_ctx *ctx, unsigned char *digest);
-void sha256(const unsigned char *message, unsigned int len,
+void sha256(const unsigned char *message, size_t len,
unsigned char *digest);
#endif /* !SHA2_H */
View
@@ -88,7 +88,7 @@ class CTemplateLoopContext {
const CString& GetName() const { return m_sName; }
unsigned long GetFilePosition() const { return m_uFilePosition; }
unsigned int GetRowIndex() const { return m_uRowIndex; }
- unsigned int GetRowCount() { return m_pvRows->size(); }
+ size_t GetRowCount() { return m_pvRows->size(); }
std::vector<CTemplate*>* GetRows() { return m_pvRows; }
CTemplate* GetNextRow() { return GetRow(IncRowIndex()); }
CTemplate* GetCurRow() { return GetRow(m_uRowIndex); }
View
@@ -138,7 +138,7 @@ class CTable : protected std::vector<std::vector<CString> > {
* After calling this you can fill the row with content.
* @return The index of this row
*/
- unsigned int AddRow();
+ size_type AddRow();
/** Sets a given cell in the table to a value.
* @param sColumn The name of the column you want to fill.
@@ -147,7 +147,7 @@ class CTable : protected std::vector<std::vector<CString> > {
* If this is not given, the last row will be used.
* @return True if setting the cell was successful.
*/
- bool SetCell(const CString& sColumn, const CString& sValue, unsigned int uRowIdx = ~0);
+ bool SetCell(const CString& sColumn, const CString& sValue, size_type uRowIdx = ~0);
/** Get a line of the table's output
* @param uIdx The index of the line you want.
@@ -162,7 +162,7 @@ class CTable : protected std::vector<std::vector<CString> > {
* @param uIdx The index of the column you are interested in.
* @return The width of the column.
*/
- unsigned int GetColumnWidth(unsigned int uIdx) const;
+ CString::size_type GetColumnWidth(unsigned int uIdx) const;
/// Completely clear the table.
void Clear();
@@ -177,7 +177,7 @@ class CTable : protected std::vector<std::vector<CString> > {
protected:
std::vector<CString> m_vsHeaders;
- std::map<CString, unsigned int> m_msuWidths; // Used to cache the width of a column
+ std::map<CString, CString::size_type> m_msuWidths; // Used to cache the width of a column
};
View
@@ -210,12 +210,12 @@ class CString : public std::string {
* @param uCount The number of characters to keep.
* @return The resulting string.
*/
- CString Left(unsigned int uCount) const;
+ CString Left(size_type uCount) const;
/** Return the right part of the string.
* @param uCount The number of characters to keep.
* @return The resulting string.
*/
- CString Right(unsigned int uCount) const;
+ CString Right(size_type uCount) const;
/** Get the first line of this string.
* @return The first line of text.
@@ -237,17 +237,17 @@ class CString : public std::string {
* after it.
* @see Split() if you need a string split into all of its tokens.
*/
- CString Token(unsigned int uPos, bool bRest = false, const CString& sSep = " ", bool bAllowEmpty = false) const;
+ CString Token(size_t uPos, bool bRest = false, const CString& sSep = " ", bool bAllowEmpty = false) const;
/** Get a token out of this string. This function behaves much like the
* other Token() function in this class. The extra arguments are
* handled similarly to Split().
*/
- CString Token(unsigned int uPos, bool bRest, const CString& sSep, bool bAllowEmpty, const CString& sLeft, const CString& sRight, bool bTrimQuotes = true) const;
+ CString Token(size_t uPos, bool bRest, const CString& sSep, bool bAllowEmpty, const CString& sLeft, const CString& sRight, bool bTrimQuotes = true) const;
- unsigned int URLSplit(MCString& msRet) const;
- unsigned int OptionSplit(MCString& msRet, bool bUpperKeys = false) const;
- unsigned int QuoteSplit(VCString& vsRet) const;
+ size_type URLSplit(MCString& msRet) const;
+ size_type OptionSplit(MCString& msRet, bool bUpperKeys = false) const;
+ size_type QuoteSplit(VCString& vsRet) const;
/** Split up this string into tokens.
* Via sLeft and sRight you can define "markers" like with Replace().
@@ -264,15 +264,15 @@ class CString : public std::string {
* each token.
* @return The number of tokens found.
*/
- unsigned int Split(const CString& sDelim, VCString& vsRet, bool bAllowEmpty = true,
+ size_type Split(const CString& sDelim, VCString& vsRet, bool bAllowEmpty = true,
const CString& sLeft = "", const CString& sRight = "", bool bTrimQuotes = true,
bool bTrimWhiteSpace = false) const;
/** Split up this string into tokens.
* This function is identical to the other CString::Split(), except that
* the result is returned as a SCString instead of a VCString.
*/
- unsigned int Split(const CString& sDelim, SCString& ssRet, bool bAllowEmpty = true,
+ size_type Split(const CString& sDelim, SCString& ssRet, bool bAllowEmpty = true,
const CString& sLeft = "", const CString& sRight = "", bool bTrimQuotes = true,
bool bTrimWhiteSpace = false) const;
@@ -438,24 +438,24 @@ class CString : public std::string {
* @param uLen The number of characters to remove.
* @return true if this string was modified.
*/
- bool LeftChomp(unsigned int uLen = 1);
+ bool LeftChomp(size_type uLen = 1);
/** Remove characters from the end of this string.
* @param uLen The number of characters to remove.
* @return true if this string was modified.
*/
- bool RightChomp(unsigned int uLen = 1);
+ bool RightChomp(size_type uLen = 1);
/** Remove characters from the beginning of this string.
* This string object isn't modified.
* @param uLen The number of characters to remove.
* @return The result of the conversion.
*/
- CString LeftChomp_n(unsigned int uLen = 1) const;
+ CString LeftChomp_n(size_type uLen = 1) const;
/** Remove characters from the end of this string.
* This string object isn't modified.
* @param uLen The number of characters to remove.
* @return The result of the conversion.
*/
- CString RightChomp_n(unsigned int uLen = 1) const;
+ CString RightChomp_n(size_type uLen = 1) const;
private:
protected:
View
@@ -140,7 +140,7 @@ class CZNC {
// Listener yummy
CListener* FindListener(u_short uPort, const CString& BindHost, EAddrType eAddr);
bool AddListener(CListener*);
- bool AddListener(unsigned int uPort, const CString& sBindHost, bool bSSL,
+ bool AddListener(unsigned short uPort, const CString& sBindHost, bool bSSL,
EAddrType eAddr, CListener::EAcceptType eAccept, CString& sError);
bool DelListener(CListener*);
View
@@ -438,7 +438,7 @@ class CAdminMod : public CModule {
pNetwork->SetFloodRate(sValue.ToDouble());
PutModule("FloodRate = " + CString(pNetwork->GetFloodRate()));
} else if (sVar.Equals("floodburst")) {
- pNetwork->SetFloodBurst(sValue.ToUInt());
+ pNetwork->SetFloodBurst(sValue.ToUShort());
PutModule("FloodBurst = " + CString(pNetwork->GetFloodBurst()));
} else {
PutModule("Error: Unknown variable");
View
@@ -219,7 +219,7 @@ class CSSLClientCertMod : public CModule {
CString GetKey(Csock *pSock) {
CString sRes;
- int res = pSock->GetPeerFingerprint(sRes);
+ long int res = pSock->GetPeerFingerprint(sRes);
DEBUG("GetKey() returned status " << res << " with key " << sRes);
View
@@ -380,7 +380,7 @@ void CDCCSock::SendPacket() {
}
char szBuf[4096];
- int iLen = m_pFile->Read(szBuf, 4096);
+ ssize_t iLen = m_pFile->Read(szBuf, 4096);
if (iLen < 0) {
m_pModule->PutModule(((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Error reading from file.");
View
@@ -421,8 +421,8 @@ class CQModule : public CModule {
sPackedHex.clear();
- unsigned int len = sHex.length() / 2;
- for (unsigned int i = 0; i < len; i++) {
+ CString::size_type len = sHex.length() / 2;
+ for (CString::size_type i = 0; i < len; i++) {
unsigned int value;
int n = sscanf(&sHex[i*2], "%02x", &value);
if (n != 1 || value > 0xff)
@@ -441,7 +441,7 @@ class CQModule : public CModule {
sRealKey = sKey;
CString sOuterKey, sInnerKey;
- unsigned int iKeyLength = sRealKey.length();
+ CString::size_type iKeyLength = sRealKey.length();
for (unsigned int i = 0; i < 64; i++) {
int r = (i < iKeyLength ? sRealKey[i] : 0);
sOuterKey += r ^ 0x5c;
View
@@ -211,7 +211,7 @@ class CSASLMod : public CModule {
/* Decode base64 into (data, length) */
CString sData = sLine.Base64Decode_n();
const unsigned char *data = (const unsigned char*)sData.c_str();
- unsigned int length = sLine.size();
+ CString::size_type length = sLine.size();
DH *dh = DH_new();
@@ -289,7 +289,7 @@ class CSASLMod : public CModule {
}
/* Encrypt our sasl password with blowfish */
- int password_length = GetNV("password").size() + (8 - (GetNV("password").size() % 8));
+ CString::size_type password_length = GetNV("password").size() + (8 - (GetNV("password").size() % 8));
unsigned char *encrypted_password = (unsigned char *)malloc(password_length);
char *plaintext_password = (char *)malloc(password_length);
View
@@ -168,7 +168,7 @@ class CSaveBuff : public CModule
CString sFile = CRYPT_VERIFICATION_TOKEN;
- unsigned int uSize = Buffer.Size();
+ size_t uSize = Buffer.Size();
for (unsigned int uIdx = 0; uIdx < uSize; uIdx++) {
const CBufLine& Line = Buffer.GetBufLine(uIdx);
timeval ts = Line.GetTime();
@@ -285,7 +285,7 @@ class CSaveBuff : public CModule
}
virtual void OnQuit(const CNick& cNick, const CString& sMessage, const vector<CChan*>& vChans)
{
- for (u_int a = 0; a < vChans.size(); a++)
+ for (size_t a = 0; a < vChans.size(); a++)
{
AddBuffer(*vChans[a], SpoofChanMsg(vChans[a]->GetName(), cNick.GetNickMask() + " QUIT " + sMessage));
}
@@ -295,7 +295,7 @@ class CSaveBuff : public CModule
virtual void OnNick(const CNick& cNick, const CString& sNewNick, const vector<CChan*>& vChans)
{
- for (u_int a = 0; a < vChans.size(); a++)
+ for (size_t a = 0; a < vChans.size(); a++)
{
AddBuffer(*vChans[a], SpoofChanMsg(vChans[a]->GetName(), cNick.GetNickMask() + " NICK " + sNewNick));
}
View
@@ -171,7 +171,7 @@ class CWatcherMod : public CModule {
MCString msParams;
msParams["target"] = m_pNetwork->GetCurNick();
- unsigned int uSize = m_Buffer.Size();
+ size_t uSize = m_Buffer.Size();
for (unsigned int uIdx = 0; uIdx < uSize; uIdx++) {
PutUser(m_Buffer.GetLine(uIdx, *GetClient(), msParams));
}
Oops, something went wrong.

0 comments on commit 8e2de0d

Please sign in to comment.