1
0
mirror of https://github.com/anope/anope.git synced 2026-07-08 01:43:14 +02:00

Fixed bug #1349 (m_sqlite compiles without error under FreeBSD), as well as use C99's stdint.h (or cstdint if available) to get (u)intX_t types instead of our stupid typedefs. pstdint.h included in case there is no cstdint or stdint.h available.

This commit is contained in:
Naram Qashat
2011-10-24 16:32:29 -04:00
parent d0513d6506
commit 377a7a968b
24 changed files with 221 additions and 298 deletions
+3 -12
View File
@@ -248,7 +248,7 @@ else(MSVC)
if(UNIX) if(UNIX)
set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic") set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CXXFLAGS "${CXXFLAGS} -fno-leading-underscore") set(CXXFLAGS "${CXXFLAGS} -Wno-long-long -fno-leading-underscore")
endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# If we aren't on a *nix system, we are using MinGW # If we aren't on a *nix system, we are using MinGW
else(UNIX) else(UNIX)
@@ -329,7 +329,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINF
endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
# Check for the existance of the following include files # Check for the existance of the following include files
check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(cstdint HAVE_CSTDINT)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(strings.h HAVE_STRINGS_H) check_include_file(strings.h HAVE_STRINGS_H)
# Check for the existance of the following functions # Check for the existance of the following functions
@@ -341,16 +342,6 @@ check_function_exists(epoll_wait HAVE_EPOLL)
check_function_exists(poll HAVE_POLL) check_function_exists(poll HAVE_POLL)
check_function_exists(kqueue HAVE_KQUEUE) check_function_exists(kqueue HAVE_KQUEUE)
# Check for the existance of the following types
check_type_size(uint8_t UINT8_T)
check_type_size(u_int8_t U_INT8_T)
check_type_size(int16_t INT16_T)
check_type_size(uint16_t UINT16_T)
check_type_size(u_int16_t U_INT16_T)
check_type_size(int32_t INT32_T)
check_type_size(uint32_t UINT32_T)
check_type_size(u_int32_t U_INT32_T)
# Check if eventfd works # Check if eventfd works
try_run(EVENTFD_TEST_RUN_RESULT EVENTFD_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR} ${Anope_SOURCE_DIR}/cmake/eventfd_test.cpp) try_run(EVENTFD_TEST_RUN_RESULT EVENTFD_TEST_COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR} ${Anope_SOURCE_DIR}/cmake/eventfd_test.cpp)
set(HAVE_EVENTFD FALSE) set(HAVE_EVENTFD FALSE)
+1 -1
View File
@@ -158,7 +158,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
Oper *o; Oper *o;
/* Unsaved data */ /* Unsaved data */
uint16 channelcount; /* Number of channels currently registered */ uint16_t channelcount; /* Number of channels currently registered */
time_t lastmail; /* Last time this nick record got a mail */ time_t lastmail; /* Last time this nick record got a mail */
std::list<NickAlias *> aliases; /* List of aliases */ std::list<NickAlias *> aliases; /* List of aliases */
+1 -1
View File
@@ -35,7 +35,7 @@ static const Anope::string BotFlagString[] = { "BEGIN", "CORE", "PRIVATE", "CONF
class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Serializable<BotInfo> class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Serializable<BotInfo>
{ {
public: public:
uint32 chancount; uint32_t chancount;
time_t created; /* Birth date ;) */ time_t created; /* Birth date ;) */
time_t lastmsg; /* Last time we said something */ time_t lastmsg; /* Last time we said something */
typedef Anope::insensitive_map<CommandInfo> command_map; typedef Anope::insensitive_map<CommandInfo> command_map;
+3 -3
View File
@@ -68,9 +68,9 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
time_t server_modetime; /* Time of last server MODE */ time_t server_modetime; /* Time of last server MODE */
time_t chanserv_modetime; /* Time of last check_modes() */ time_t chanserv_modetime; /* Time of last check_modes() */
int16 server_modecount; /* Number of server MODEs this second */ int16_t server_modecount; /* Number of server MODEs this second */
int16 chanserv_modecount; /* Number of check_mode()'s this sec */ int16_t chanserv_modecount; /* Number of check_mode()'s this sec */
int16 bouncy_modes; /* Did we fail to set modes here? */ int16_t bouncy_modes; /* Did we fail to set modes here? */
/** Call if we need to unset all modes and clear all user status (internally). /** Call if we need to unset all modes and clear all user status (internally).
* Only useful if we get a SJOIN with a TS older than what we have here * Only useful if we get a SJOIN with a TS older than what we have here
+6 -6
View File
@@ -171,8 +171,8 @@ E bool nickIsServices(const Anope::string &nick, bool bot);
E void add_entropy_userkeys(); E void add_entropy_userkeys();
E void rand_init(); E void rand_init();
E unsigned char getrandom8(); E unsigned char getrandom8();
E uint16 getrandom16(); E uint16_t getrandom16();
E uint32 getrandom32(); E uint32_t getrandom32();
E std::list<Anope::string> BuildStringList(const Anope::string &, char = ' '); E std::list<Anope::string> BuildStringList(const Anope::string &, char = ' ');
E std::vector<Anope::string> BuildStringVector(const Anope::string &, char = ' '); E std::vector<Anope::string> BuildStringVector(const Anope::string &, char = ' ');
@@ -208,14 +208,14 @@ E void notice_server(const Anope::string &source, const Server *s, const char *f
/**** sockets.cpp ****/ /**** sockets.cpp ****/
E int32 TotalRead; E int32_t TotalRead;
E int32 TotalWritten; E int32_t TotalWritten;
E SocketIO normalSocketIO; E SocketIO normalSocketIO;
/**** users.c ****/ /**** users.c ****/
E int32 opcnt; E int32_t opcnt;
E uint32 maxusercnt, usercnt; E uint32_t maxusercnt, usercnt;
E time_t maxusertime; E time_t maxusertime;
E User *finduser(const Anope::string &nick); E User *finduser(const Anope::string &nick);
+1 -1
View File
@@ -594,7 +594,7 @@ class CoreExport Module : public Extensible
* @param priv The privilege changed * @param priv The privilege changed
* @param what The new level * @param what The new level
*/ */
virtual void OnLevelChange(User *u, ChannelInfo *ci, const Anope::string &priv, int16 what) { } virtual void OnLevelChange(User *u, ChannelInfo *ci, const Anope::string &priv, int16_t what) { }
/** Called when a channel is dropped /** Called when a channel is dropped
* @param chname The channel name * @param chname The channel name
+8 -8
View File
@@ -152,7 +152,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
std::vector<ChanAccess *> access; /* List of authorized users */ std::vector<ChanAccess *> access; /* List of authorized users */
std::vector<AutoKick *> akick; /* List of users to kickban */ std::vector<AutoKick *> akick; /* List of users to kickban */
std::vector<BadWord *> badwords; /* List of badwords */ std::vector<BadWord *> badwords; /* List of badwords */
std::map<Anope::string, int16> levels; std::map<Anope::string, int16_t> levels;
public: public:
typedef std::multimap<ChannelModeName, ModeLock> ModeList; typedef std::multimap<ChannelModeName, ModeLock> ModeList;
@@ -184,7 +184,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
Anope::string last_topic_setter; /* Setter */ Anope::string last_topic_setter; /* Setter */
time_t last_topic_time; /* Time */ time_t last_topic_time; /* Time */
int16 bantype; int16_t bantype;
MemoInfo memos; MemoInfo memos;
@@ -193,11 +193,11 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
/* For BotServ */ /* For BotServ */
BotInfo *bi; /* Bot used on this channel */ BotInfo *bi; /* Bot used on this channel */
Flags<BotServFlag> botflags; Flags<BotServFlag> botflags;
int16 ttb[TTB_SIZE]; /* Times to ban for each kicker */ int16_t ttb[TTB_SIZE]; /* Times to ban for each kicker */
int16 capsmin, capspercent; /* For CAPS kicker */ int16_t capsmin, capspercent; /* For CAPS kicker */
int16 floodlines, floodsecs; /* For FLOOD kicker */ int16_t floodlines, floodsecs; /* For FLOOD kicker */
int16 repeattimes; /* For REPEAT kicker */ int16_t repeattimes; /* For REPEAT kicker */
serialized_data serialize(); serialized_data serialize();
static void unserialize(serialized_data &); static void unserialize(serialized_data &);
@@ -404,13 +404,13 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
* @return the level * @return the level
* @throws CoreException if priv is not a valid privilege * @throws CoreException if priv is not a valid privilege
*/ */
int16 GetLevel(const Anope::string &priv); int16_t GetLevel(const Anope::string &priv);
/** Set the level for a privilege /** Set the level for a privilege
* @param priv The privilege priv * @param priv The privilege priv
* @param level The new level * @param level The new level
*/ */
void SetLevel(const Anope::string &priv, int16 level); void SetLevel(const Anope::string &priv, int16_t level);
/** Remove a privilege from the channel /** Remove a privilege from the channel
* @param priv The privilege * @param priv The privilege
+1 -1
View File
@@ -551,7 +551,7 @@ class CoreExport Memo : public Flags<MemoFlag>, public Serializable<Memo>
struct CoreExport MemoInfo struct CoreExport MemoInfo
{ {
int16 memomax; int16_t memomax;
std::vector<Memo *> memos; std::vector<Memo *> memos;
std::vector<Anope::string> ignores; std::vector<Anope::string> ignores;
+9 -77
View File
@@ -4,7 +4,7 @@
#cmakedefine DEBUG_BUILD #cmakedefine DEBUG_BUILD
#cmakedefine DEFUMASK @DEFUMASK@ #cmakedefine DEFUMASK @DEFUMASK@
#cmakedefine HAVE_SYS_TYPES_H 1 #cmakedefine HAVE_CSTDINT 1
#cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_STDINT_H 1
#cmakedefine HAVE_STDDEF_H 1 #cmakedefine HAVE_STDDEF_H 1
#cmakedefine HAVE_SETGRENT 1 #cmakedefine HAVE_SETGRENT 1
@@ -18,87 +18,19 @@
#cmakedefine GETTEXT_FOUND 1 #cmakedefine GETTEXT_FOUND 1
#cmakedefine RUNGROUP "@RUNGROUP@" #cmakedefine RUNGROUP "@RUNGROUP@"
#cmakedefine HAVE_UINT8_T 1 #ifdef HAVE_CSTDINT
#cmakedefine HAVE_U_INT8_T 1 # include <cstdint>
#cmakedefine HAVE_INT16_T 1 #else
#cmakedefine HAVE_UINT16_T 1 # ifdef HAVE_STDINT_H
#cmakedefine HAVE_U_INT16_T 1 # include <stdint.h>
#cmakedefine HAVE_INT32_T 1 # else
#cmakedefine HAVE_UINT32_T 1 # include "pstdint.h"
#cmakedefine HAVE_U_INT32_T 1 # endif
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif #endif
#ifdef HAVE_STDDEF_H #ifdef HAVE_STDDEF_H
# include <stddef.h> # include <stddef.h>
#endif #endif
#ifdef HAVE_UINT8_T
typedef uint8_t uint8;
#else
# ifdef HAVE_U_INT8_T
typedef u_int8_t uint8;
# else
# ifdef _WIN32
typedef unsigned __int8 uint8;
# else
typedef unsigned short uint8;
# endif
# endif
#endif
#ifdef HAVE_INT16_T
typedef int16_t int16;
#else
# ifdef _WIN32
typedef signed __int16 int16;
# else
typedef int int16;
# endif
#endif
#ifdef HAVE_UINT16_T
typedef uint16_t uint16;
#else
# ifdef HAVE_U_INT16_T
typedef u_int16_t uint16;
# else
# ifdef _WIN32
typedef unsigned __int16 uint16;
# else
typedef unsigned int uint16;
# endif
# endif
#endif
#ifdef HAVE_INT32_T
typedef int32_t int32;
#else
# ifdef _WIN32
typedef signed __int32 int32;
# else
typedef long int32;
# endif
#endif
#ifdef HAVE_UINT32_T
typedef uint32_t uint32;
#else
# ifdef HAVE_U_INT32_T
typedef u_int32_t uint32;
# else
# ifdef _WIN32
typedef unsigned __int32 uint32;
# else
typedef unsigned long uint32;
# endif
# endif
#endif
#ifdef _WIN32 #ifdef _WIN32
# define popen _popen # define popen _popen
# define pclose _pclose # define pclose _pclose
+18 -18
View File
@@ -58,7 +58,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_BADWORDS] = convertTo<int16>(ttb); ci->ttb[TTB_BADWORDS] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_BADWORDS] < 0) if (ci->ttb[TTB_BADWORDS] < 0)
throw ConvertException(); throw ConvertException();
} }
@@ -96,7 +96,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_BOLDS] = convertTo<int16>(ttb); ci->ttb[TTB_BOLDS] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_BOLDS] < 0) if (ci->ttb[TTB_BOLDS] < 0)
throw ConvertException(); throw ConvertException();
} }
@@ -132,7 +132,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_CAPS] = convertTo<int16>(ttb); ci->ttb[TTB_CAPS] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_CAPS] < 0) if (ci->ttb[TTB_CAPS] < 0)
throw ConvertException(); throw ConvertException();
} }
@@ -149,7 +149,7 @@ class CommandBSKick : public Command
ci->capsmin = 10; ci->capsmin = 10;
try try
{ {
ci->capsmin = convertTo<int16>(min); ci->capsmin = convertTo<int16_t>(min);
} }
catch (const ConvertException &) { } catch (const ConvertException &) { }
if (ci->capsmin < 1) if (ci->capsmin < 1)
@@ -158,7 +158,7 @@ class CommandBSKick : public Command
ci->capspercent = 25; ci->capspercent = 25;
try try
{ {
ci->capspercent = convertTo<int16>(percent); ci->capspercent = convertTo<int16_t>(percent);
} }
catch (const ConvertException &) { } catch (const ConvertException &) { }
if (ci->capspercent < 1 || ci->capspercent > 100) if (ci->capspercent < 1 || ci->capspercent > 100)
@@ -187,7 +187,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_COLORS] = convertTo<int16>(ttb); ci->ttb[TTB_COLORS] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_COLORS] < 1) if (ci->ttb[TTB_COLORS] < 1)
throw ConvertException(); throw ConvertException();
} }
@@ -224,7 +224,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_FLOOD] = convertTo<int16>(ttb); ci->ttb[TTB_FLOOD] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_FLOOD] < 1) if (ci->ttb[TTB_FLOOD] < 1)
throw ConvertException(); throw ConvertException();
} }
@@ -241,7 +241,7 @@ class CommandBSKick : public Command
ci->floodlines = 6; ci->floodlines = 6;
try try
{ {
ci->floodlines = convertTo<int16>(lines); ci->floodlines = convertTo<int16_t>(lines);
} }
catch (const ConvertException &) { } catch (const ConvertException &) { }
if (ci->floodlines < 2) if (ci->floodlines < 2)
@@ -250,7 +250,7 @@ class CommandBSKick : public Command
ci->floodsecs = 10; ci->floodsecs = 10;
try try
{ {
ci->floodsecs = convertTo<int16>(secs); ci->floodsecs = convertTo<int16_t>(secs);
} }
catch (const ConvertException &) { } catch (const ConvertException &) { }
if (ci->floodsecs < 1) if (ci->floodsecs < 1)
@@ -280,7 +280,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_REPEAT] = convertTo<int16>(ttb); ci->ttb[TTB_REPEAT] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_REPEAT] < 0) if (ci->ttb[TTB_REPEAT] < 0)
throw ConvertException(); throw ConvertException();
} }
@@ -297,7 +297,7 @@ class CommandBSKick : public Command
ci->repeattimes = 3; ci->repeattimes = 3;
try try
{ {
ci->repeattimes = convertTo<int16>(times); ci->repeattimes = convertTo<int16_t>(times);
} }
catch (const ConvertException &) { } catch (const ConvertException &) { }
if (ci->repeattimes < 2) if (ci->repeattimes < 2)
@@ -326,7 +326,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_REVERSES] = convertTo<int16>(ttb); ci->ttb[TTB_REVERSES] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_REVERSES] < 0) if (ci->ttb[TTB_REVERSES] < 0)
throw ConvertException(); throw ConvertException();
} }
@@ -359,7 +359,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_UNDERLINES] = convertTo<int16>(ttb); ci->ttb[TTB_UNDERLINES] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_REVERSES] < 0) if (ci->ttb[TTB_REVERSES] < 0)
throw ConvertException(); throw ConvertException();
} }
@@ -393,7 +393,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_ITALICS] = convertTo<int16>(ttb); ci->ttb[TTB_ITALICS] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_ITALICS] < 0) if (ci->ttb[TTB_ITALICS] < 0)
throw ConvertException(); throw ConvertException();
} }
@@ -427,7 +427,7 @@ class CommandBSKick : public Command
{ {
try try
{ {
ci->ttb[TTB_AMSGS] = convertTo<int16>(ttb); ci->ttb[TTB_AMSGS] = convertTo<int16_t>(ttb);
if (ci->ttb[TTB_AMSGS] < 0) if (ci->ttb[TTB_AMSGS] < 0)
throw ConvertException(); throw ConvertException();
} }
@@ -583,7 +583,7 @@ struct BanData : public ExtensibleItem
{ {
Anope::string mask; Anope::string mask;
time_t last_use; time_t last_use;
int16 ttb[TTB_SIZE]; int16_t ttb[TTB_SIZE];
Data() Data()
{ {
@@ -648,13 +648,13 @@ struct UserData : public ExtensibleItem
time_t last_use; time_t last_use;
/* for flood kicker */ /* for flood kicker */
int16 lines; int16_t lines;
time_t last_start; time_t last_start;
/* for repeat kicker */ /* for repeat kicker */
Anope::string lastline; Anope::string lastline;
Anope::string lasttarget; Anope::string lasttarget;
int16 times; int16_t times;
void OnDelete() void OnDelete()
{ {
+4 -4
View File
@@ -19,12 +19,12 @@ enum
ACCESS_FOUNDER = 10001 ACCESS_FOUNDER = 10001
}; };
static std::map<Anope::string, int16, std::less<ci::string> > defaultLevels; static std::map<Anope::string, int16_t, std::less<ci::string> > defaultLevels;
static void reset_levels(ChannelInfo *ci) static void reset_levels(ChannelInfo *ci)
{ {
ci->ClearLevels(); ci->ClearLevels();
for (std::map<Anope::string, int16, std::less<ci::string> >::iterator it = defaultLevels.begin(), it_end = defaultLevels.end(); it != it_end; ++it) for (std::map<Anope::string, int16_t, std::less<ci::string> >::iterator it = defaultLevels.begin(), it_end = defaultLevels.end(); it != it_end; ++it)
ci->SetLevel(it->first, it->second); ci->SetLevel(it->first, it->second);
} }
@@ -736,7 +736,7 @@ class CommandCSLevels : public Command
for (unsigned i = 0; i < privs.size(); ++i) for (unsigned i = 0; i < privs.size(); ++i)
{ {
const Privilege &p = privs[i]; const Privilege &p = privs[i];
int16 j = ci->GetLevel(p.name); int16_t j = ci->GetLevel(p.name);
if (j == ACCESS_INVALID) if (j == ACCESS_INVALID)
source.Reply(_(" %-*s (disabled)"), levelinfo_maxwidth, p.name.c_str()); source.Reply(_(" %-*s (disabled)"), levelinfo_maxwidth, p.name.c_str());
@@ -918,7 +918,7 @@ class CSAccess : public Module
if (group->ci == NULL) if (group->ci == NULL)
return EVENT_CONTINUE; return EVENT_CONTINUE;
/* Special case. Allows a level of < 0 to match anyone, and a level of 0 to match anyone identified. */ /* Special case. Allows a level of < 0 to match anyone, and a level of 0 to match anyone identified. */
int16 level = group->ci->GetLevel(priv); int16_t level = group->ci->GetLevel(priv);
if (level < 0) if (level < 0)
return EVENT_ALLOW; return EVENT_ALLOW;
else if (level == 0 && group->nc) else if (level == 0 && group->nc)
+1 -1
View File
@@ -40,7 +40,7 @@ class CommandCSSetBanType : public Command
try try
{ {
int16 new_type = convertTo<int16>(params[1]); int16_t new_type = convertTo<int16_t>(params[1]);
if (new_type < 0 || new_type > 3) if (new_type < 0 || new_type > 3)
throw ConvertException("Invalid range"); throw ConvertException("Invalid range");
ci->bantype = new_type; ci->bantype = new_type;
+3 -3
View File
@@ -75,7 +75,7 @@ class CommandMSSet : public Command
Anope::string p2 = params.size() > 2 ? params[2] : ""; Anope::string p2 = params.size() > 2 ? params[2] : "";
Anope::string p3 = params.size() > 3 ? params[3] : ""; Anope::string p3 = params.size() > 3 ? params[3] : "";
Anope::string user, chan; Anope::string user, chan;
int16 limit; int16_t limit;
NickCore *nc = u->Account(); NickCore *nc = u->Account();
ChannelInfo *ci = NULL; ChannelInfo *ci = NULL;
bool is_servadmin = u->HasPriv("memoserv/set-limit"); bool is_servadmin = u->HasPriv("memoserv/set-limit");
@@ -136,7 +136,7 @@ class CommandMSSet : public Command
limit = -1; limit = -1;
try try
{ {
limit = convertTo<int16>(p1); limit = convertTo<int16_t>(p1);
} }
catch (const ConvertException &) { } catch (const ConvertException &) { }
} }
@@ -160,7 +160,7 @@ class CommandMSSet : public Command
limit = -1; limit = -1;
try try
{ {
limit = convertTo<int16>(p1); limit = convertTo<int16_t>(p1);
} }
catch (const ConvertException &) { } catch (const ConvertException &) { }
/* The first character is a digit, but we could still go negative /* The first character is a digit, but we could still go negative
+44 -44
View File
@@ -295,7 +295,7 @@ void close_db(dbFILE *f)
delete f; delete f;
} }
static int read_int16(int16 *ret, dbFILE *f) static int read_int16(int16_t *ret, dbFILE *f)
{ {
int c1, c2; int c1, c2;
@@ -309,7 +309,7 @@ static int read_int16(int16 *ret, dbFILE *f)
return 0; return 0;
} }
static int read_uint16(uint16 *ret, dbFILE *f) static int read_uint16(uint16_t *ret, dbFILE *f)
{ {
int c1, c2; int c1, c2;
@@ -326,7 +326,7 @@ static int read_uint16(uint16 *ret, dbFILE *f)
static int read_string(Anope::string &str, dbFILE *f) static int read_string(Anope::string &str, dbFILE *f)
{ {
str.clear(); str.clear();
uint16 len; uint16_t len;
if (read_uint16(&len, f) < 0) if (read_uint16(&len, f) < 0)
return -1; return -1;
@@ -343,7 +343,7 @@ static int read_string(Anope::string &str, dbFILE *f)
return 0; return 0;
} }
static int read_uint32(uint32 *ret, dbFILE *f) static int read_uint32(uint32_t *ret, dbFILE *f)
{ {
int c1, c2, c3, c4; int c1, c2, c3, c4;
@@ -359,7 +359,7 @@ static int read_uint32(uint32 *ret, dbFILE *f)
return 0; return 0;
} }
int read_int32(int32 *ret, dbFILE *f) int read_int32(int32_t *ret, dbFILE *f)
{ {
int c1, c2, c3, c4; int c1, c2, c3, c4;
@@ -402,7 +402,7 @@ static void LoadNicks()
READ(read_string(buffer, f)); READ(read_string(buffer, f));
nc->greet = buffer; nc->greet = buffer;
uint32 uint; uint32_t uint;
READ(read_uint32(&uint, f)); READ(read_uint32(&uint, f));
//nc->icq = uint; //nc->icq = uint;
@@ -445,7 +445,7 @@ static void LoadNicks()
if (uint & OLD_NI_NOEXPIRE) if (uint & OLD_NI_NOEXPIRE)
nc->Extend("noexpire", NULL); nc->Extend("noexpire", NULL);
uint16 u16; uint16_t u16;
READ(read_uint16(&u16, f)); READ(read_uint16(&u16, f));
switch (u16) switch (u16)
{ {
@@ -494,22 +494,22 @@ static void LoadNicks()
} }
READ(read_uint16(&u16, f)); READ(read_uint16(&u16, f));
for (uint16 j = 0; j < u16; ++j) for (uint16_t j = 0; j < u16; ++j)
{ {
READ(read_string(buffer, f)); READ(read_string(buffer, f));
nc->access.push_back(buffer); nc->access.push_back(buffer);
} }
int16 i16; int16_t i16;
READ(read_int16(&i16, f)); READ(read_int16(&i16, f));
READ(read_int16(&nc->memos.memomax, f)); READ(read_int16(&nc->memos.memomax, f));
for (int16 j = 0; j < i16; ++j) for (int16_t j = 0; j < i16; ++j)
{ {
Memo *m = new Memo; Memo *m = new Memo;
READ(read_uint32(&uint, f)); READ(read_uint32(&uint, f));
uint16 flags; uint16_t flags;
READ(read_uint16(&flags, f)); READ(read_uint16(&flags, f));
int32 tmp32; int32_t tmp32;
READ(read_int32(&tmp32, f)); READ(read_int32(&tmp32, f));
m->time = tmp32; m->time = tmp32;
char sbuf[32]; char sbuf[32];
@@ -535,13 +535,13 @@ static void LoadNicks()
READ(read_string(last_realname, f)); READ(read_string(last_realname, f));
READ(read_string(last_quit, f)); READ(read_string(last_quit, f));
int32 tmp32; int32_t tmp32;
READ(read_int32(&tmp32, f)); READ(read_int32(&tmp32, f));
time_registered = tmp32; time_registered = tmp32;
READ(read_int32(&tmp32, f)); READ(read_int32(&tmp32, f));
last_seen = tmp32; last_seen = tmp32;
uint16 tmpu16; uint16_t tmpu16;
READ(read_uint16(&tmpu16, f)); READ(read_uint16(&tmpu16, f));
Anope::string core; Anope::string core;
READ(read_string(core, f)); READ(read_string(core, f));
@@ -576,7 +576,7 @@ static void LoadVHosts()
for (int c; (c = getc_db(f)) == 1;) for (int c; (c = getc_db(f)) == 1;)
{ {
Anope::string nick, ident, host, creator; Anope::string nick, ident, host, creator;
int32 vtime; int32_t vtime;
READ(read_string(nick, f)); READ(read_string(nick, f));
READ(read_string(ident, f)); READ(read_string(ident, f));
@@ -608,8 +608,8 @@ static void LoadBots()
for (int c; (c = getc_db(f)) == 1;) for (int c; (c = getc_db(f)) == 1;)
{ {
Anope::string nick, user, host, real; Anope::string nick, user, host, real;
int16 flags, chancount; int16_t flags, chancount;
int32 created; int32_t created;
READ(read_string(nick, f)); READ(read_string(nick, f));
READ(read_string(user, f)); READ(read_string(user, f));
@@ -659,7 +659,7 @@ static void LoadChannels()
READ(read_string(buffer, f)); READ(read_string(buffer, f));
READ(read_string(buffer, f)); READ(read_string(buffer, f));
int32 tmp32; int32_t tmp32;
READ(read_int32(&tmp32, f)); READ(read_int32(&tmp32, f));
ci->time_registered = tmp32; ci->time_registered = tmp32;
@@ -674,7 +674,7 @@ static void LoadChannels()
READ(read_int32(&tmp32, f)); READ(read_int32(&tmp32, f));
ci->last_topic_time = tmp32; ci->last_topic_time = tmp32;
uint32 tmpu32; uint32_t tmpu32;
READ(read_uint32(&tmpu32, f)); READ(read_uint32(&tmpu32, f));
// Temporary flags cleanup // Temporary flags cleanup
tmpu32 &= ~0x80000000; tmpu32 &= ~0x80000000;
@@ -708,26 +708,26 @@ static void LoadChannels()
READ(read_string(buffer, f)); READ(read_string(buffer, f));
READ(read_string(buffer, f)); READ(read_string(buffer, f));
int16 tmp16; int16_t tmp16;
READ(read_int16(&tmp16, f)); READ(read_int16(&tmp16, f));
ci->bantype = tmp16; ci->bantype = tmp16;
READ(read_int16(&tmp16, f)); READ(read_int16(&tmp16, f));
if (tmp16 > 36) if (tmp16 > 36)
tmp16 = 36; tmp16 = 36;
for (int16 j = 0; j < tmp16; ++j) for (int16_t j = 0; j < tmp16; ++j)
{ {
int16 level; int16_t level;
READ(read_int16(&level, f)); READ(read_int16(&level, f));
ci->SetLevel(GetLevelName(j), level); ci->SetLevel(GetLevelName(j), level);
} }
uint16 tmpu16; uint16_t tmpu16;
READ(read_uint16(&tmpu16, f)); READ(read_uint16(&tmpu16, f));
for (uint16 j = 0; j < tmpu16; ++j) for (uint16_t j = 0; j < tmpu16; ++j)
{ {
uint16 in_use; uint16_t in_use;
READ(read_uint16(&in_use, f)); READ(read_uint16(&in_use, f));
if (in_use) if (in_use)
{ {
@@ -738,7 +738,7 @@ static void LoadChannels()
ChanAccess *access = provider->Create(); ChanAccess *access = provider->Create();
access->ci = ci; access->ci = ci;
int16 level; int16_t level;
READ(read_int16(&level, f)); READ(read_int16(&level, f));
access->Unserialize(stringify(level)); access->Unserialize(stringify(level));
@@ -756,9 +756,9 @@ static void LoadChannels()
} }
READ(read_uint16(&tmpu16, f)); READ(read_uint16(&tmpu16, f));
for (uint16 j = 0; j < tmpu16; ++j) for (uint16_t j = 0; j < tmpu16; ++j)
{ {
uint16 flags; uint16_t flags;
READ(read_uint16(&flags, f)); READ(read_uint16(&flags, f));
if (flags & 0x0001) if (flags & 0x0001)
{ {
@@ -781,7 +781,7 @@ static void LoadChannels()
READ(read_int16(&tmp16, f)); READ(read_int16(&tmp16, f));
READ(read_int16(&ci->memos.memomax, f)); READ(read_int16(&ci->memos.memomax, f));
for (int16 j = 0; j < tmp16; ++j) for (int16_t j = 0; j < tmp16; ++j)
{ {
READ(read_uint32(&tmpu32, f)); READ(read_uint32(&tmpu32, f));
READ(read_uint16(&tmpu16, f)); READ(read_uint16(&tmpu16, f));
@@ -829,9 +829,9 @@ static void LoadChannels()
ci->botflags.SetFlag(BS_KICK_REPEAT); ci->botflags.SetFlag(BS_KICK_REPEAT);
READ(read_int16(&tmp16, f)); READ(read_int16(&tmp16, f));
for (int16 j = 0; j < tmp16; ++j) for (int16_t j = 0; j < tmp16; ++j)
{ {
int16 ttb; int16_t ttb;
READ(read_int16(&ttb, f)); READ(read_int16(&ttb, f));
if (j < TTB_SIZE) if (j < TTB_SIZE)
ci->ttb[j] = ttb; ci->ttb[j] = ttb;
@@ -849,14 +849,14 @@ static void LoadChannels()
ci->repeattimes = tmp16; ci->repeattimes = tmp16;
READ(read_uint16(&tmpu16, f)); READ(read_uint16(&tmpu16, f));
for (uint16 j = 0; j < tmpu16; ++j) for (uint16_t j = 0; j < tmpu16; ++j)
{ {
uint16 in_use; uint16_t in_use;
READ(read_uint16(&in_use, f)); READ(read_uint16(&in_use, f));
if (in_use) if (in_use)
{ {
READ(read_string(buffer, f)); READ(read_string(buffer, f));
uint16 type; uint16_t type;
READ(read_uint16(&type, f)); READ(read_uint16(&type, f));
BadWordType bwtype = BW_ANY; BadWordType bwtype = BW_ANY;
@@ -899,16 +899,16 @@ static void LoadOper()
szline = xl; szline = xl;
} }
int32 tmp32; int32_t tmp32;
READ(read_int32(&tmp32, f)); READ(read_int32(&tmp32, f));
READ(read_int32(&tmp32, f)); READ(read_int32(&tmp32, f));
int16 capacity; int16_t capacity;
read_int16(&capacity, f); // AKill count read_int16(&capacity, f); // AKill count
for (int16 i = 0; i < capacity; ++i) for (int16_t i = 0; i < capacity; ++i)
{ {
Anope::string user, host, by, reason; Anope::string user, host, by, reason;
int32 seton, expires; int32_t seton, expires;
READ(read_string(user, f)); READ(read_string(user, f));
READ(read_string(host, f)); READ(read_string(host, f));
@@ -926,10 +926,10 @@ static void LoadOper()
} }
read_int16(&capacity, f); // SNLines read_int16(&capacity, f); // SNLines
for (int16 i = 0; i < capacity; ++i) for (int16_t i = 0; i < capacity; ++i)
{ {
Anope::string mask, by, reason; Anope::string mask, by, reason;
int32 seton, expires; int32_t seton, expires;
READ(read_string(mask, f)); READ(read_string(mask, f));
READ(read_string(by, f)); READ(read_string(by, f));
@@ -946,10 +946,10 @@ static void LoadOper()
} }
read_int16(&capacity, f); // SQLines read_int16(&capacity, f); // SQLines
for (int16 i = 0; i < capacity; ++i) for (int16_t i = 0; i < capacity; ++i)
{ {
Anope::string mask, by, reason; Anope::string mask, by, reason;
int32 seton, expires; int32_t seton, expires;
READ(read_string(mask, f)); READ(read_string(mask, f));
READ(read_string(by, f)); READ(read_string(by, f));
@@ -966,10 +966,10 @@ static void LoadOper()
} }
read_int16(&capacity, f); // SZLines read_int16(&capacity, f); // SZLines
for (int16 i = 0; i < capacity; ++i) for (int16_t i = 0; i < capacity; ++i)
{ {
Anope::string mask, by, reason; Anope::string mask, by, reason;
int32 seton, expires; int32_t seton, expires;
READ(read_string(mask, f)); READ(read_string(mask, f));
READ(read_string(by, f)); READ(read_string(by, f));
+21 -21
View File
@@ -68,7 +68,7 @@ EventReturn OnDatabaseReadMetadata(NickCore *nc, const Anope::string &key, const
if (key.equals_ci("LANGUAGE")) if (key.equals_ci("LANGUAGE"))
nc->language = params[0]; nc->language = params[0];
else if (key.equals_ci("MEMOMAX")) else if (key.equals_ci("MEMOMAX"))
nc->memos.memomax = params[0].is_pos_number_only() ? convertTo<int16>(params[0]) : -1; nc->memos.memomax = params[0].is_pos_number_only() ? convertTo<int16_t>(params[0]) : -1;
else if (key.equals_ci("EMAIL")) else if (key.equals_ci("EMAIL"))
nc->email = params[0]; nc->email = params[0];
else if (key.equals_ci("GREET")) else if (key.equals_ci("GREET"))
@@ -134,9 +134,9 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
try try
{ {
if (key.equals_ci("BANTYPE")) if (key.equals_ci("BANTYPE"))
ci->bantype = params[0].is_pos_number_only() ? convertTo<int16>(params[0]) : Config->CSDefBantype; ci->bantype = params[0].is_pos_number_only() ? convertTo<int16_t>(params[0]) : Config->CSDefBantype;
else if (key.equals_ci("MEMOMAX")) else if (key.equals_ci("MEMOMAX"))
ci->memos.memomax = params[0].is_pos_number_only() ? convertTo<int16>(params[0]) : -1; ci->memos.memomax = params[0].is_pos_number_only() ? convertTo<int16_t>(params[0]) : -1;
else if (key.equals_ci("FOUNDER")) else if (key.equals_ci("FOUNDER"))
ci->SetFounder(findcore(params[0])); ci->SetFounder(findcore(params[0]));
else if (key.equals_ci("SUCCESSOR")) else if (key.equals_ci("SUCCESSOR"))
@@ -148,7 +148,7 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
Privilege *p = PrivilegeManager::FindPrivilege(params[j]); Privilege *p = PrivilegeManager::FindPrivilege(params[j]);
if (p == NULL) if (p == NULL)
continue; continue;
ci->SetLevel(p->name, params[j + 1].is_number_only() ? convertTo<int16>(params[j + 1]) : 0); ci->SetLevel(p->name, params[j + 1].is_number_only() ? convertTo<int16_t>(params[j + 1]) : 0);
} }
} }
else if (key.equals_ci("FLAGS")) else if (key.equals_ci("FLAGS"))
@@ -276,37 +276,37 @@ EventReturn OnDatabaseReadMetadata(ChannelInfo *ci, const Anope::string &key, co
for (unsigned j = 1, end = params.size(); j < end; j += 2) for (unsigned j = 1, end = params.size(); j < end; j += 2)
{ {
if (params[j].equals_ci("BOLDS")) if (params[j].equals_ci("BOLDS"))
ci->ttb[0] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[0] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("COLORS")) else if (params[j].equals_ci("COLORS"))
ci->ttb[1] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[1] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("REVERSES")) else if (params[j].equals_ci("REVERSES"))
ci->ttb[2] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[2] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("UNDERLINES")) else if (params[j].equals_ci("UNDERLINES"))
ci->ttb[3] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[3] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("BADWORDS")) else if (params[j].equals_ci("BADWORDS"))
ci->ttb[4] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[4] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("CAPS")) else if (params[j].equals_ci("CAPS"))
ci->ttb[5] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[5] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("FLOOD")) else if (params[j].equals_ci("FLOOD"))
ci->ttb[6] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[6] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("REPEAT")) else if (params[j].equals_ci("REPEAT"))
ci->ttb[7] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[7] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("ITALICS")) else if (params[j].equals_ci("ITALICS"))
ci->ttb[8] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[8] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
else if (params[j].equals_ci("AMSGS")) else if (params[j].equals_ci("AMSGS"))
ci->ttb[9] = params[j + 1].is_pos_number_only() ? convertTo<int16>(params[j + 1]) : 0; ci->ttb[9] = params[j + 1].is_pos_number_only() ? convertTo<int16_t>(params[j + 1]) : 0;
} }
} }
else if (params[0].equals_ci("CAPSMIN")) else if (params[0].equals_ci("CAPSMIN"))
ci->capsmin = params[1].is_pos_number_only() ? convertTo<int16>(params[1]) : 0; ci->capsmin = params[1].is_pos_number_only() ? convertTo<int16_t>(params[1]) : 0;
else if (params[0].equals_ci("CAPSPERCENT")) else if (params[0].equals_ci("CAPSPERCENT"))
ci->capspercent = params[1].is_pos_number_only() ? convertTo<int16>(params[1]) : 0; ci->capspercent = params[1].is_pos_number_only() ? convertTo<int16_t>(params[1]) : 0;
else if (params[0].equals_ci("FLOODLINES")) else if (params[0].equals_ci("FLOODLINES"))
ci->floodlines = params[1].is_pos_number_only() ? convertTo<int16>(params[1]) : 0; ci->floodlines = params[1].is_pos_number_only() ? convertTo<int16_t>(params[1]) : 0;
else if (params[0].equals_ci("FLOODSECS")) else if (params[0].equals_ci("FLOODSECS"))
ci->floodsecs = params[1].is_pos_number_only() ? convertTo<int16>(params[1]) : 0; ci->floodsecs = params[1].is_pos_number_only() ? convertTo<int16_t>(params[1]) : 0;
else if (params[0].equals_ci("REPEATTIMES")) else if (params[0].equals_ci("REPEATTIMES"))
ci->repeattimes = params[1].is_pos_number_only() ? convertTo<int16>(params[1]) : 0; ci->repeattimes = params[1].is_pos_number_only() ? convertTo<int16_t>(params[1]) : 0;
else if (params[0].equals_ci("BADWORD")) else if (params[0].equals_ci("BADWORD"))
{ {
BadWordType Type; BadWordType Type;
@@ -505,7 +505,7 @@ static void LoadBotInfo(const std::vector<Anope::string> &params)
bi = new BotInfo(params[0], params[1], params[2]); bi = new BotInfo(params[0], params[1], params[2]);
bi->created = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : 0; bi->created = params[3].is_pos_number_only() ? convertTo<time_t>(params[3]) : 0;
bi->chancount = params[4].is_pos_number_only() ? convertTo<uint32>(params[4]) : 0; bi->chancount = params[4].is_pos_number_only() ? convertTo<uint32_t>(params[4]) : 0;
bi->realname = params[5]; bi->realname = params[5];
Log(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick; Log(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick;
@@ -531,7 +531,7 @@ static void LoadOperInfo(const std::vector<Anope::string> &params)
{ {
if (params[0].equals_ci("STATS")) if (params[0].equals_ci("STATS"))
{ {
maxusercnt = params[1].is_pos_number_only() ? convertTo<uint32>(params[1]) : 0; maxusercnt = params[1].is_pos_number_only() ? convertTo<uint32_t>(params[1]) : 0;
maxusertime = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0; maxusertime = params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0;
} }
else if (params[0].equals_ci("SXLINE")) else if (params[0].equals_ci("SXLINE"))
+1 -1
View File
@@ -303,7 +303,7 @@ class DBMySQL : public Module
this->OnAccessDel(ci, NULL, ci->GetAccess(i)); this->OnAccessDel(ci, NULL, ci->GetAccess(i));
} }
void OnLevelChange(User *u, ChannelInfo *ci, const Anope::string &priv, int16 what) void OnLevelChange(User *u, ChannelInfo *ci, const Anope::string &priv, int16_t what)
{ {
this->Insert(ci->serialize_name(), ci->serialize()); this->Insert(ci->serialize_name(), ci->serialize());
} }
+5 -5
View File
@@ -63,11 +63,11 @@ static void ChanInfoUpdate(const Anope::string &name, const SQLResult &res)
bi->Assign(NULL, ci); bi->Assign(NULL, ci);
} }
ci->capsmin = convertTo<int16>(res.Get(0, "capsmin")); ci->capsmin = convertTo<int16_t>(res.Get(0, "capsmin"));
ci->capspercent = convertTo<int16>(res.Get(0, "capspercent")); ci->capspercent = convertTo<int16_t>(res.Get(0, "capspercent"));
ci->floodlines = convertTo<int16>(res.Get(0, "floodlines")); ci->floodlines = convertTo<int16_t>(res.Get(0, "floodlines"));
ci->floodsecs = convertTo<int16>(res.Get(0, "floodsecs")); ci->floodsecs = convertTo<int16_t>(res.Get(0, "floodsecs"));
ci->repeattimes = convertTo<int16>(res.Get(0, "repeattimes")); ci->repeattimes = convertTo<int16_t>(res.Get(0, "repeattimes"));
if (ci->c) if (ci->c)
check_modes(ci->c); check_modes(ci->c);
+18 -18
View File
@@ -18,27 +18,27 @@ A million repetitions of "a"
struct SHA1_CTX struct SHA1_CTX
{ {
uint32 state[5]; uint32_t state[5];
uint32 count[2]; uint32_t count[2];
unsigned char buffer[64]; unsigned char buffer[64];
}; };
void SHA1Transform(uint32 state[5], const unsigned char buffer[64]); void SHA1Transform(uint32_t state[5], const unsigned char buffer[64]);
void SHA1Init(SHA1_CTX *context); void SHA1Init(SHA1_CTX *context);
void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32 len); void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32_t len);
void SHA1Final(unsigned char digest[20], SHA1_CTX *context); void SHA1Final(unsigned char digest[20], SHA1_CTX *context);
inline static uint32 rol(uint32 value, uint32 bits) { return (value << bits) | (value >> (32 - bits)); } inline static uint32_t rol(uint32_t value, uint32_t bits) { return (value << bits) | (value >> (32 - bits)); }
union CHAR64LONG16 union CHAR64LONG16
{ {
unsigned char c[64]; unsigned char c[64];
uint32 l[16]; uint32_t l[16];
}; };
/* blk0() and blk() perform the initial expand. */ /* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */ /* I got the idea of expanding during the round function from SSLeay */
inline static uint32 blk0(CHAR64LONG16 *block, uint32 i) inline static uint32_t blk0(CHAR64LONG16 *block, uint32_t i)
{ {
#ifdef LITTLE_ENDIAN #ifdef LITTLE_ENDIAN
return block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | (rol(block->l[i], 8) & 0x00FF00FF); return block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | (rol(block->l[i], 8) & 0x00FF00FF);
@@ -46,20 +46,20 @@ inline static uint32 blk0(CHAR64LONG16 *block, uint32 i)
return block->l[i]; return block->l[i];
#endif #endif
} }
inline static uint32 blk(CHAR64LONG16 *block, uint32 i) { return block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ block->l[(i + 8) & 15] ^ block->l[(i + 2) & 15] ^ block->l[i & 15],1); } inline static uint32_t blk(CHAR64LONG16 *block, uint32_t i) { return block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ block->l[(i + 8) & 15] ^ block->l[(i + 2) & 15] ^ block->l[i & 15],1); }
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
inline static void R0(CHAR64LONG16 *block, uint32 v, uint32 &w, uint32 x, uint32 y, uint32 &z, uint32 i) { z += ((w & (x ^ y)) ^ y) + blk0(block, i) + 0x5A827999 + rol(v, 5); w = rol(w, 30); } inline static void R0(CHAR64LONG16 *block, uint32_t v, uint32_t &w, uint32_t x, uint32_t y, uint32_t &z, uint32_t i) { z += ((w & (x ^ y)) ^ y) + blk0(block, i) + 0x5A827999 + rol(v, 5); w = rol(w, 30); }
inline static void R1(CHAR64LONG16 *block, uint32 v, uint32 &w, uint32 x, uint32 y, uint32 &z, uint32 i) { z += ((w & (x ^ y)) ^ y) + blk(block, i) + 0x5A827999 + rol(v, 5); w = rol(w, 30); } inline static void R1(CHAR64LONG16 *block, uint32_t v, uint32_t &w, uint32_t x, uint32_t y, uint32_t &z, uint32_t i) { z += ((w & (x ^ y)) ^ y) + blk(block, i) + 0x5A827999 + rol(v, 5); w = rol(w, 30); }
inline static void R2(CHAR64LONG16 *block, uint32 v, uint32 &w, uint32 x, uint32 y, uint32 &z, uint32 i) { z += (w ^ x ^ y) + blk(block, i) + 0x6ED9EBA1 + rol(v, 5); w = rol(w, 30); } inline static void R2(CHAR64LONG16 *block, uint32_t v, uint32_t &w, uint32_t x, uint32_t y, uint32_t &z, uint32_t i) { z += (w ^ x ^ y) + blk(block, i) + 0x6ED9EBA1 + rol(v, 5); w = rol(w, 30); }
inline static void R3(CHAR64LONG16 *block, uint32 v, uint32 &w, uint32 x, uint32 y, uint32 &z, uint32 i) { z += (((w | x) & y) | (w & x)) + blk(block, i) + 0x8F1BBCDC + rol(v, 5); w = rol(w, 30); } inline static void R3(CHAR64LONG16 *block, uint32_t v, uint32_t &w, uint32_t x, uint32_t y, uint32_t &z, uint32_t i) { z += (((w | x) & y) | (w & x)) + blk(block, i) + 0x8F1BBCDC + rol(v, 5); w = rol(w, 30); }
inline static void R4(CHAR64LONG16 *block, uint32 v, uint32 &w, uint32 x, uint32 y, uint32 &z, uint32 i) { z += (w ^ x ^ y) + blk(block, i) + 0xCA62C1D6 + rol(v, 5); w = rol(w, 30); } inline static void R4(CHAR64LONG16 *block, uint32_t v, uint32_t &w, uint32_t x, uint32_t y, uint32_t &z, uint32_t i) { z += (w ^ x ^ y) + blk(block, i) + 0xCA62C1D6 + rol(v, 5); w = rol(w, 30); }
/* Hash a single 512-bit block. This is the core of the algorithm. */ /* Hash a single 512-bit block. This is the core of the algorithm. */
void SHA1Transform(uint32 state[5], const unsigned char buffer[64]) void SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
{ {
uint32 a, b, c, d, e; uint32_t a, b, c, d, e;
static unsigned char workspace[64]; static unsigned char workspace[64];
CHAR64LONG16 *block = reinterpret_cast<CHAR64LONG16 *>(workspace); CHAR64LONG16 *block = reinterpret_cast<CHAR64LONG16 *>(workspace);
memcpy(block, buffer, 64); memcpy(block, buffer, 64);
@@ -115,9 +115,9 @@ void SHA1Init(SHA1_CTX *context)
/* Run your data through this. */ /* Run your data through this. */
void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32 len) void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32_t len)
{ {
uint32 i, j; uint32_t i, j;
j = (context->count[0] >> 3) & 63; j = (context->count[0] >> 3) & 63;
if ((context->count[0] += len << 3) < (len << 3)) if ((context->count[0] += len << 3) < (len << 3))
@@ -140,7 +140,7 @@ void SHA1Update(SHA1_CTX *context, const unsigned char *data, uint32 len)
void SHA1Final(unsigned char digest[21], SHA1_CTX *context) void SHA1Final(unsigned char digest[21], SHA1_CTX *context)
{ {
uint32 i; uint32_t i;
unsigned char finalcount[8]; unsigned char finalcount[8];
for (i = 0; i < 8; ++i) for (i = 0; i < 8; ++i)
+21 -21
View File
@@ -65,41 +65,41 @@ class SHA256Context
unsigned tot_len; unsigned tot_len;
unsigned len; unsigned len;
unsigned char block[2 * SHA256_BLOCK_SIZE]; unsigned char block[2 * SHA256_BLOCK_SIZE];
uint32 h[8]; uint32_t h[8];
}; };
inline static uint32 SHFR(uint32 x, uint32 n) { return x >> n; } inline static uint32_t SHFR(uint32_t x, uint32_t n) { return x >> n; }
inline static uint32 ROTR(uint32 x, uint32 n) { return (x >> n) | (x << ((sizeof(x) << 3) - n)); } inline static uint32_t ROTR(uint32_t x, uint32_t n) { return (x >> n) | (x << ((sizeof(x) << 3) - n)); }
inline static uint32 ROTL(uint32 x, uint32 n) { return (x << n) | (x >> ((sizeof(x) << 3) - n)); } inline static uint32_t ROTL(uint32_t x, uint32_t n) { return (x << n) | (x >> ((sizeof(x) << 3) - n)); }
inline static uint32 CH(uint32 x, uint32 y, uint32 z) { return (x & y) ^ (~x & z); } inline static uint32_t CH(uint32_t x, uint32_t y, uint32_t z) { return (x & y) ^ (~x & z); }
inline static uint32 MAJ(uint32 x, uint32 y, uint32 z) { return (x & y) ^ (x & z) ^ (y & z); } inline static uint32_t MAJ(uint32_t x, uint32_t y, uint32_t z) { return (x & y) ^ (x & z) ^ (y & z); }
inline static uint32 SHA256_F1(uint32 x) { return ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22); } inline static uint32_t SHA256_F1(uint32_t x) { return ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22); }
inline static uint32 SHA256_F2(uint32 x) { return ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25); } inline static uint32_t SHA256_F2(uint32_t x) { return ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25); }
inline static uint32 SHA256_F3(uint32 x) { return ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3); } inline static uint32_t SHA256_F3(uint32_t x) { return ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3); }
inline static uint32 SHA256_F4(uint32 x) { return ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10); } inline static uint32_t SHA256_F4(uint32_t x) { return ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10); }
inline static void UNPACK32(unsigned x, unsigned char *str) inline static void UNPACK32(unsigned x, unsigned char *str)
{ {
str[3] = static_cast<uint8>(x); str[3] = static_cast<uint8_t>(x);
str[2] = static_cast<uint8>(x >> 8); str[2] = static_cast<uint8_t>(x >> 8);
str[1] = static_cast<uint8>(x >> 16); str[1] = static_cast<uint8_t>(x >> 16);
str[0] = static_cast<uint8>(x >> 24); str[0] = static_cast<uint8_t>(x >> 24);
} }
inline static void PACK32(unsigned char *str, uint32 &x) inline static void PACK32(unsigned char *str, uint32_t &x)
{ {
x = static_cast<uint32>(str[3]) | static_cast<uint32>(str[2]) << 8 | static_cast<uint32>(str[1]) << 16 | static_cast<uint32>(str[0]) << 24; x = static_cast<uint32_t>(str[3]) | static_cast<uint32_t>(str[2]) << 8 | static_cast<uint32_t>(str[1]) << 16 | static_cast<uint32_t>(str[0]) << 24;
} }
/* Macros used for loops unrolling */ /* Macros used for loops unrolling */
inline static void SHA256_SCR(uint32 w[64], int i) inline static void SHA256_SCR(uint32_t w[64], int i)
{ {
w[i] = SHA256_F4(w[i - 2]) + w[i - 7] + SHA256_F3(w[i - 15]) + w[i - 16]; w[i] = SHA256_F4(w[i - 2]) + w[i - 7] + SHA256_F3(w[i - 15]) + w[i - 16];
} }
uint32 sha256_k[64] = uint32_t sha256_k[64] =
{ {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
@@ -163,7 +163,7 @@ class ESHA256 : public Module
void SHA256Transform(SHA256Context *ctx, unsigned char *message, unsigned block_nb) void SHA256Transform(SHA256Context *ctx, unsigned char *message, unsigned block_nb)
{ {
uint32 w[64], wv[8]; uint32_t w[64], wv[8];
unsigned char *sub_block; unsigned char *sub_block;
for (unsigned i = 1; i <= block_nb; ++i) for (unsigned i = 1; i <= block_nb; ++i)
{ {
@@ -178,8 +178,8 @@ class ESHA256 : public Module
wv[j] = ctx->h[j]; wv[j] = ctx->h[j];
for (j = 0; j < 64; ++j) for (j = 0; j < 64; ++j)
{ {
uint32 t1 = wv[7] + SHA256_F2(wv[4]) + CH(wv[4], wv[5], wv[6]) + sha256_k[j] + w[j]; uint32_t t1 = wv[7] + SHA256_F2(wv[4]) + CH(wv[4], wv[5], wv[6]) + sha256_k[j] + w[j];
uint32 t2 = SHA256_F1(wv[0]) + MAJ(wv[0], wv[1], wv[2]); uint32_t t2 = SHA256_F1(wv[0]) + MAJ(wv[0], wv[1], wv[2]);
wv[7] = wv[6]; wv[7] = wv[6];
wv[6] = wv[5]; wv[6] = wv[5];
wv[5] = wv[4]; wv[5] = wv[4];
+8 -8
View File
@@ -29,9 +29,9 @@ void ExtensibleItem::OnDelete()
struct arc4_stream struct arc4_stream
{ {
uint8 i; uint8_t i;
uint8 j; uint8_t j;
uint8 s[256]; uint8_t s[256];
} rs; } rs;
/*************************************************************************/ /*************************************************************************/
@@ -459,7 +459,7 @@ static void arc4_addrandom(void *dat, int datlen)
for (int n = 0; n < 256; ++n) for (int n = 0; n < 256; ++n)
{ {
++rs.i; ++rs.i;
uint8 si = rs.s[rs.i]; uint8_t si = rs.s[rs.i];
rs.j = rs.j + si + (static_cast<unsigned char *>(dat))[n % datlen]; rs.j = rs.j + si + (static_cast<unsigned char *>(dat))[n % datlen];
rs.s[rs.i] = rs.s[rs.j]; rs.s[rs.i] = rs.s[rs.j];
rs.s[rs.j] = si; rs.s[rs.j] = si;
@@ -545,9 +545,9 @@ unsigned char getrandom8()
* Get the random numbers 16 byte deep * Get the random numbers 16 byte deep
* @return char * @return char
*/ */
uint16 getrandom16() uint16_t getrandom16()
{ {
uint16 val = getrandom8() << 8; uint16_t val = getrandom8() << 8;
val |= getrandom8(); val |= getrandom8();
return val; return val;
} }
@@ -558,9 +558,9 @@ uint16 getrandom16()
* Get the random numbers 32 byte deep * Get the random numbers 32 byte deep
* @return char * @return char
*/ */
uint32 getrandom32() uint32_t getrandom32()
{ {
uint32 val = getrandom8() << 24; uint32_t val = getrandom8() << 24;
val |= getrandom8() << 16; val |= getrandom8() << 16;
val |= getrandom8() << 8; val |= getrandom8() << 8;
val |= getrandom8(); val |= getrandom8();
+4 -4
View File
@@ -282,7 +282,7 @@ SerializableBase::serialized_data ChannelInfo::serialize()
data["botflags"] << this->botflags.ToString(); data["botflags"] << this->botflags.ToString();
{ {
Anope::string levels_buffer; Anope::string levels_buffer;
for (std::map<Anope::string, int16>::iterator it = this->levels.begin(), it_end = this->levels.end(); it != it_end; ++it) for (std::map<Anope::string, int16_t>::iterator it = this->levels.begin(), it_end = this->levels.end(); it != it_end; ++it)
levels_buffer += it->first + " " + stringify(it->second) + " "; levels_buffer += it->first + " " + stringify(it->second) + " ";
data["levels"] << levels_buffer; data["levels"] << levels_buffer;
} }
@@ -321,7 +321,7 @@ void ChannelInfo::unserialize(SerializableBase::serialized_data &data)
{ {
std::vector<Anope::string> v = BuildStringVector(data["levels"].astr()); std::vector<Anope::string> v = BuildStringVector(data["levels"].astr());
for (unsigned i = 0; i + 1 < v.size(); i += 2) for (unsigned i = 0; i + 1 < v.size(); i += 2)
ci->levels[v[i]] = convertTo<int16>(v[i + 1]); ci->levels[v[i]] = convertTo<int16_t>(v[i + 1]);
} }
if (data.count("bi") > 0) if (data.count("bi") > 0)
ci->bi = findbot(data["bi"].astr()); ci->bi = findbot(data["bi"].astr());
@@ -989,7 +989,7 @@ void ChannelInfo::RestoreTopic()
} }
} }
int16 ChannelInfo::GetLevel(const Anope::string &priv) int16_t ChannelInfo::GetLevel(const Anope::string &priv)
{ {
if (PrivilegeManager::FindPrivilege(priv) == NULL) if (PrivilegeManager::FindPrivilege(priv) == NULL)
throw CoreException("Unknown privilege " + priv); throw CoreException("Unknown privilege " + priv);
@@ -999,7 +999,7 @@ int16 ChannelInfo::GetLevel(const Anope::string &priv)
return this->levels[priv]; return this->levels[priv];
} }
void ChannelInfo::SetLevel(const Anope::string &priv, int16 level) void ChannelInfo::SetLevel(const Anope::string &priv, int16_t level)
{ {
this->levels[priv] = level; this->levels[priv] = level;
} }
+2 -2
View File
@@ -2,8 +2,8 @@
std::map<int, Socket *> SocketEngine::Sockets; std::map<int, Socket *> SocketEngine::Sockets;
int32 TotalRead = 0; int32_t TotalRead = 0;
int32 TotalWritten = 0; int32_t TotalWritten = 0;
SocketIO normalSocketIO; SocketIO normalSocketIO;
+2 -2
View File
@@ -15,8 +15,8 @@
Anope::insensitive_map<User *> UserListByNick; Anope::insensitive_map<User *> UserListByNick;
Anope::map<User *> UserListByUID; Anope::map<User *> UserListByUID;
int32 opcnt = 0; int32_t opcnt = 0;
uint32 usercnt = 0, maxusercnt = 0; uint32_t usercnt = 0, maxusercnt = 0;
time_t maxusertime; time_t maxusertime;
/*************************************************************************/ /*************************************************************************/