Compare commits

...
Sign in to create a new pull request.

7 commits

30 changed files with 130 additions and 105 deletions

View file

@ -443,24 +443,24 @@ if (NOT WIN32)
endif()
if (CPPUNIT_FOUND)
message("tests : yes")
message("Tests : yes")
include_directories(${CPPUNIT_INCLUDE_DIR})
else()
if(ENABLE_TESTS)
message("tests : no (install CPPUnit)")
message("Tests : no (install CPPUnit)")
else(ENABLE_TESTS)
message("tests : no (user disabled)")
message("Tests : no (user disabled)")
endif()
endif()
if(DOXYGEN_FOUND)
message("Docs : yes")
message("Documentation : yes")
ADD_SUBDIRECTORY(docs)
else(DOXYGEN_FOUND)
if(ENABLE_DOCS)
message("Docs : no (install doxygen)")
message("Documentation : no (install doxygen)")
else(ENABLE_DOCS)
message("Docs : no (user disabled)")
message("Documentation : no (user disabled)")
endif()
endif(DOXYGEN_FOUND)

View file

@ -18,6 +18,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include <string.h>
#include "frotz.h"
extern void stream_char (zchar);

View file

@ -21,6 +21,7 @@
#include "frotz.h"
extern int save_undo (void);
extern int os_read_mouse (void);
extern zchar stream_read_key (zword, zword, bool);
extern zchar stream_read_input (int, zchar *, zword, zword, bool, bool);

View file

@ -32,9 +32,12 @@
#define cdecl
#endif
extern void interpret (void);
extern void init_memory (void);
extern void init_undo (void);
extern void init_sound (void);
extern void init_buffer (void);
extern void init_process (void);
extern void interpret (void);
extern void reset_memory (void);
/* Story file name, id number and size */

View file

@ -64,7 +64,7 @@ static int zoptopt = 0;
static char *zoptarg = NULL;
static int zgetopt (int argc, char *argv[], const char *options)
{
static pos = 1;
static int pos = 1;
const char *p;
if (zoptind >= argc || argv[zoptind][0] != '-' || argv[zoptind][1] == 0)
return EOF;
@ -76,7 +76,7 @@ static int zgetopt (int argc, char *argv[], const char *options)
if (zoptopt == ':' || p == NULL) {
fputs ("illegal option -- ", stderr);
goto error;
} else if (p[1] == ':')
} else if (p[1] == ':') {
if (zoptind >= argc) {
fputs ("option requires an argument -- ", stderr);
goto error;
@ -86,6 +86,7 @@ static int zgetopt (int argc, char *argv[], const char *options)
zoptarg += pos;
pos = 1; zoptind++;
}
}
return zoptopt;
error:
fputc (zoptopt, stderr);
@ -201,8 +202,6 @@ void os_fatal (const char *s)
FILE *os_path_open(const char *name, const char *mode)
{
FILE *fp;
char buf[FILENAME_MAX + 1];
char *p;
/* Let's see if the file is in the currect directory */
/* or if the user gave us a full path. */

View file

@ -248,7 +248,7 @@ static bool dumb_read_line(char *s, char *prompt, bool show_cursor,
if (type != INPUT_LINE_CONTINUED)
fprintf(stderr, "DUMB-FROTZ: No input to discard\n");
else {
dumb_discard_old_input(strlen(continued_line_chars));
dumb_discard_old_input(strlen((char *) continued_line_chars));
continued_line_chars[0] = '\0';
type = INPUT_LINE;
}
@ -262,7 +262,7 @@ static bool dumb_read_line(char *s, char *prompt, bool show_cursor,
int i;
for (i = 0; (i < h_screen_rows - 2) && *next_page; i++)
next_page = strchr(next_page, '\n') + 1;
printf("%.*s", next_page - current_page, current_page);
printf("%.*s", (int) (next_page - current_page), current_page);
current_page = next_page;
if (!*current_page)
break;
@ -369,7 +369,7 @@ zchar os_read_line (int max, zchar *buf, int timeout, int width, int continued)
dumb_display_user_input(read_line_buffer);
/* copy to the buffer and save the rest for next time. */
strcat(buf, read_line_buffer);
strcat((char *) buf, read_line_buffer);
p = read_line_buffer + strlen(read_line_buffer) + 1;
memmove(read_line_buffer, p, strlen(p) + 1);
@ -385,7 +385,6 @@ zchar os_read_line (int max, zchar *buf, int timeout, int width, int continued)
int os_read_file_name (char *file_name, const char *default_name, int flag)
{
char buf[INPUT_BUFFER_SIZE], prompt[INPUT_BUFFER_SIZE];
FILE *fp;
sprintf(prompt, "Please enter a filename [%s]: ", default_name);
dumb_read_misc_line(buf, prompt);
@ -397,6 +396,7 @@ int os_read_file_name (char *file_name, const char *default_name, int flag)
strcpy (file_name, buf[0] ? buf : default_name);
/* Warn if overwriting a file. */
// FILE *fp;
// if ((flag == FILE_SAVE || flag == FILE_SAVE_AUX || flag == FILE_RECORD)
// && ((fp = fopen(file_name, "rb")) != NULL)) {
// fclose (fp);
@ -427,4 +427,6 @@ void dumb_init_input(void)
zword os_read_mouse(void)
{
/* NOT IMPLEMENTED */
return 0;
}

View file

@ -132,7 +132,7 @@ void os_set_text_style(int x)
static void dumb_display_char(char c)
{
dumb_set_cell(cursor_row, cursor_col, make_cell(current_style, c));
if (++cursor_col == h_screen_cols)
if (++cursor_col == h_screen_cols) {
if (cursor_row == h_screen_rows - 1)
cursor_col--;
else {
@ -140,6 +140,7 @@ static void dumb_display_char(char c)
cursor_col = 0;
}
}
}
void dumb_display_user_input(char *s)
{
@ -192,7 +193,7 @@ void os_display_string (const zchar *s)
else if (c == ZC_NEW_STYLE)
os_set_text_style(*s++);
else {
os_display_char (c);
os_display_char (c);
}
}
@ -267,8 +268,12 @@ static bool will_print_blank(cell c)
static void show_line_prefix(int row, char c)
{
if (show_line_numbers)
printf((row == -1) ? ".." : "%02d", (row + 1) % 100);
if (show_line_numbers) {
if (row == -1)
printf("..");
else
printf("%02d", (row + 1) % 100);
}
if (show_line_types)
putchar(c);
/* Add a separator char (unless there's nothing to separate). */
@ -329,7 +334,7 @@ static bool is_blank(cell c)
void dumb_show_screen(bool show_cursor)
{
int r, c, first, last;
char changed_rows[0x100];
char changed_rows[0x100];
/* Easy case */
if (compression_mode == COMPRESSION_NONE) {
@ -342,7 +347,7 @@ void dumb_show_screen(bool show_cursor)
/* Check which rows changed, and where the first and last change is. */
first = last = -1;
memset(changed_rows, 0, h_screen_rows);
for (r = hide_lines; r < h_screen_rows; r++) {
for (r = hide_lines; r < h_screen_rows; r++) {
for (c = 0; c < h_screen_cols; c++)
if (dumb_changes_row(r)[c] && !is_blank(dumb_row(r)[c]))
break;
@ -367,7 +372,7 @@ void dumb_show_screen(bool show_cursor)
/* Display the appropriate rows. */
if (compression_mode == COMPRESSION_MAX) {
for (r = first; r <= last; r++)
for (r = first; r <= last; r++)
if (changed_rows[r])
show_row(r);
} else {

View file

@ -1440,6 +1440,8 @@ struct Dis {
std::string protocol;
};
// currently unused
#if 0
static gboolean disconnectMe(void *data) {
Dis *d = (Dis *) data;
PurpleAccount *account = purple_accounts_find_wrapped(d->name.c_str(), d->protocol.c_str());
@ -1450,6 +1452,7 @@ static gboolean disconnectMe(void *data) {
}
return FALSE;
}
#endif
static gboolean pingTimeout(void *data) {
np->checkPing();
@ -2300,10 +2303,10 @@ int main(int argc, char **argv) {
purple_timeout_add_seconds_wrapped(30, pingTimeout, NULL);
np = new SpectrumNetworkPlugin();
bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";
GMainLoop *m_loop;
#ifdef WITH_LIBEVENT
bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";
if (!libev) {
m_loop = g_main_loop_new(NULL, FALSE);
}

View file

@ -207,6 +207,9 @@ class SwiftenPlugin : public NetworkPlugin, Swift::XMPPParserClient {
case Swift::ClientError::InvalidCertificateSignatureError: message = ("Invalid certificate signature"); break;
case Swift::ClientError::InvalidCAError: message = ("Invalid Certificate Authority"); break;
case Swift::ClientError::InvalidServerIdentityError: message = ("Certificate does not match the host identity"); break;
case Swift::ClientError::CertificateCardRemoved: message = ("Certificate card has been removed"); break;
case Swift::ClientError::RevokedError: message = ("Certificate has been revoked"); break;
case Swift::ClientError::RevocationCheckFailedError: message = ("Certificate revocation check has failed"); break;
}
}
LOG4CXX_INFO(logger, user << ": Disconnected " << message);

View file

@ -23,7 +23,7 @@ void FetchFriends::run()
req.init();
req.setProxy(twitObj->getProxyServerIp(), twitObj->getProxyServerPort(), twitObj->getProxyUserName(), twitObj->getProxyPassword());
for(int i=0 ; i<friends.size() ; i++) {
for(unsigned i=0 ; i<friends.size() ; i++) {
std::string img;
friendAvatars.push_back("");
if(req.GET(friends[i].getProfileImgURL(), img)) friendAvatars[i] = img;

View file

@ -213,7 +213,7 @@ void TwitterPlugin::handleMessageSendRequest(const std::string &user, const std:
std::string cmd = "", data = "";
/** Parsing the message - Assuming message format to be <cmd>[ ]*<data>**/
int i;
unsigned i;
for(i=0 ; i<message.size() && message[i] != ' '; i++) cmd += message[i];
while(i<message.size() && message[i] == ' ') i++;
data = message.substr(i);
@ -652,7 +652,7 @@ void TwitterPlugin::populateRoster(std::string &user, std::vector<User> &friends
{
if(errMsg.getMessage().length() == 0)
{
for(int i=0 ; i<friends.size() ; i++) {
for(unsigned i=0 ; i<friends.size() ; i++) {
userdb[user].buddies.insert(friends[i].getScreenName());
userdb[user].buddiesInfo[friends[i].getScreenName()] = friends[i];
userdb[user].buddiesImgs[friends[i].getScreenName()] = friendAvatars[i];
@ -691,7 +691,7 @@ void TwitterPlugin::displayFriendlist(std::string &user, std::vector<User> &frie
if(errMsg.getMessage().length() == 0)
{
std::string userlist = "\n***************USER LIST****************\n";
for(int i=0 ; i < friends.size() ; i++) {
for(unsigned i=0 ; i < friends.size() ; i++) {
userlist += " - " + friends[i].getUserName() + " (" + friends[i].getScreenName() + ")\n";
}
userlist += "***************************************\n";
@ -788,7 +788,7 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
std::string msgID = getMostRecentDMID(user);
std::string maxID = msgID;
for(int i=0 ; i < messages.size() ; i++) {
for(unsigned i=0 ; i < messages.size() ; i++) {
if(cmp(msgID, messages[i].getID()) == -1) {
msglist += " - " + messages[i].getSenderData().getScreenName() + ": " + messages[i].getMessage() + "\n";
if(cmp(maxID, messages[i].getID()) == -1) maxID = messages[i].getID();
@ -803,7 +803,7 @@ void TwitterPlugin::directMessageResponse(std::string &user, std::string &userna
std::string msgID = getMostRecentDMID(user);
std::string maxID = msgID;
for(int i=0 ; i < messages.size() ; i++) {
for(unsigned i=0 ; i < messages.size() ; i++) {
if(cmp(msgID, messages[i].getID()) == -1) {
if(userdb[user].twitterMode == MULTIPLECONTACT)
handleMessage(user, messages[i].getSenderData().getScreenName(), messages[i].getMessage(), "");

View file

@ -10,7 +10,7 @@ DEFINE_LOGGER(logger, "TwitterResponseParser")
static std::string tolowercase(std::string inp)
{
std::string out = inp;
for(int i=0 ; i<out.size() ; i++) out[i] = tolower(out[i]);
for(unsigned i=0 ; i<out.size() ; i++) out[i] = tolower(out[i]);
return out;
}
@ -246,7 +246,7 @@ std::vector<std::string> getIDs(std::string &json)
const rapidjson::Value & ids = rootElement[TwitterReponseTypes::ids.c_str()];
for(int i=0 ; i<ids.Size() ; i++) {
for(unsigned i=0 ; i<ids.Size() ; i++) {
IDs.push_back(stringOf( ids[i].GetInt64()) );
}
return IDs;

View file

@ -1,18 +1,18 @@
/*
* Swift compatibility
*
*
* Copyright (c) 2016, Vladimir Matena <vlada.matena@gmail.com>
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -36,10 +36,12 @@
*/
#if (SWIFTEN_VERSION >= 0x040000)
#define SWIFTEN_UNIQUE_PTR std::unique_ptr
#define SWIFTEN_SHRPTR_NAMESPACE std
#define SWIFTEN_SIGNAL_NAMESPACE boost::signals2
#define SWIFT_HOSTADDRESS(x) *(Swift::HostAddress::fromString(x))
#else
#define SWIFTEN_UNIQUE_PTR std::auto_ptr
#define SWIFTEN_SHRPTR_NAMESPACE boost
#define SWIFTEN_SIGNAL_NAMESPACE boost::signals
#define SWIFT_HOSTADDRESS(x) Swift::HostAddress(x)

View file

@ -127,9 +127,9 @@ class MySQLBackend : public StorageBackend
MYSQL *m_conn;
std::vector<MYSQL_BIND> m_params;
std::vector<MYSQL_BIND> m_results;
int m_resultOffset;
int m_offset;
int m_error;
unsigned m_resultOffset;
unsigned m_offset;
std::string m_string;
};

View file

@ -45,13 +45,13 @@ namespace utf8
}
else if (cp < 0x10000) { // three octets
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
*(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f | 0x80);
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else { // four octets
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
*(result++) = static_cast<uint8_t>((cp >> 12)& 0x3f | 0x80);
*(result++) = static_cast<uint8_t>((cp >> 6) & 0x3f | 0x80);
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
return result;

View file

@ -41,6 +41,8 @@ namespace Transport {
DEFINE_LOGGER(logger, "AdminInterface");
// currently unused
#if 0
static std::string getArg(const std::string &body) {
std::string ret;
if (body.find(" ") == std::string::npos)
@ -48,10 +50,11 @@ static std::string getArg(const std::string &body) {
return body.substr(body.find(" ") + 1);
}
#endif
class StatusCommand : public AdminInterfaceCommand {
public:
StatusCommand(NetworkPluginServer *server, UserManager *userManager) :
AdminInterfaceCommand("status",
AdminInterfaceCommand::General,
@ -82,7 +85,7 @@ class StatusCommand : public AdminInterfaceCommand {
class UptimeCommand : public AdminInterfaceCommand {
public:
UptimeCommand() : AdminInterfaceCommand("uptime",
AdminInterfaceCommand::General,
AdminInterfaceCommand::GlobalContext,
@ -107,7 +110,7 @@ class UptimeCommand : public AdminInterfaceCommand {
class OnlineUsersCommand : public AdminInterfaceCommand {
public:
OnlineUsersCommand(UserManager *userManager) : AdminInterfaceCommand("online_users",
AdminInterfaceCommand::Users,
AdminInterfaceCommand::GlobalContext,
@ -141,7 +144,7 @@ class OnlineUsersCommand : public AdminInterfaceCommand {
class OnlineUsersCountCommand : public AdminInterfaceCommand {
public:
OnlineUsersCountCommand(UserManager *userManager) : AdminInterfaceCommand("online_users_count",
AdminInterfaceCommand::Users,
AdminInterfaceCommand::GlobalContext,
@ -167,7 +170,7 @@ class OnlineUsersCountCommand : public AdminInterfaceCommand {
class OnlineUsersPerBackendCommand : public AdminInterfaceCommand {
public:
OnlineUsersPerBackendCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("online_users_per_backend",
AdminInterfaceCommand::General,
@ -208,6 +211,8 @@ class OnlineUsersPerBackendCommand : public AdminInterfaceCommand {
}
id++;
}
return lst;
}
private:
@ -216,7 +221,7 @@ class OnlineUsersPerBackendCommand : public AdminInterfaceCommand {
class BackendsCountCommand : public AdminInterfaceCommand {
public:
BackendsCountCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("backends_count",
AdminInterfaceCommand::Backends,
@ -243,7 +248,7 @@ class BackendsCountCommand : public AdminInterfaceCommand {
class ReloadCommand : public AdminInterfaceCommand {
public:
ReloadCommand(Component *component) : AdminInterfaceCommand("reload",
AdminInterfaceCommand::General,
AdminInterfaceCommand::GlobalContext,
@ -275,7 +280,7 @@ class ReloadCommand : public AdminInterfaceCommand {
class HasOnlineUserCommand : public AdminInterfaceCommand {
public:
HasOnlineUserCommand(UserManager *userManager) : AdminInterfaceCommand("has_online_user",
AdminInterfaceCommand::Users,
AdminInterfaceCommand::GlobalContext,
@ -306,7 +311,7 @@ class HasOnlineUserCommand : public AdminInterfaceCommand {
class ResMemoryCommand : public AdminInterfaceCommand {
public:
ResMemoryCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("res_memory",
AdminInterfaceCommand::Memory,
@ -340,7 +345,7 @@ class ResMemoryCommand : public AdminInterfaceCommand {
class ShrMemoryCommand : public AdminInterfaceCommand {
public:
ShrMemoryCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("shr_memory",
AdminInterfaceCommand::Memory,
@ -374,7 +379,7 @@ class ShrMemoryCommand : public AdminInterfaceCommand {
class UsedMemoryCommand : public AdminInterfaceCommand {
public:
UsedMemoryCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("used_memory",
AdminInterfaceCommand::Memory,
@ -410,7 +415,7 @@ class UsedMemoryCommand : public AdminInterfaceCommand {
class AverageMemoryPerUserCommand : public AdminInterfaceCommand {
public:
AverageMemoryPerUserCommand(NetworkPluginServer *server, UserManager *userManager) :
AdminInterfaceCommand("average_memory_per_user",
AdminInterfaceCommand::Memory,
@ -451,7 +456,7 @@ class AverageMemoryPerUserCommand : public AdminInterfaceCommand {
class ResMemoryPerBackendCommand : public AdminInterfaceCommand {
public:
ResMemoryPerBackendCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("res_memory_per_backend",
AdminInterfaceCommand::Memory,
@ -485,7 +490,7 @@ class ResMemoryPerBackendCommand : public AdminInterfaceCommand {
class ShrMemoryPerBackendCommand : public AdminInterfaceCommand {
public:
ShrMemoryPerBackendCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("shr_memory_per_backend",
AdminInterfaceCommand::Memory,
@ -519,7 +524,7 @@ class ShrMemoryPerBackendCommand : public AdminInterfaceCommand {
class UsedMemoryPerBackendCommand : public AdminInterfaceCommand {
public:
UsedMemoryPerBackendCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("used_memory_per_backend",
AdminInterfaceCommand::Memory,
@ -553,7 +558,7 @@ class UsedMemoryPerBackendCommand : public AdminInterfaceCommand {
class AverageMemoryPerUserPerBackendCommand : public AdminInterfaceCommand {
public:
AverageMemoryPerUserPerBackendCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("average_memory_per_user_per_backend",
AdminInterfaceCommand::Memory,
@ -592,7 +597,7 @@ class AverageMemoryPerUserPerBackendCommand : public AdminInterfaceCommand {
class CrashedBackendsCountCommand : public AdminInterfaceCommand {
public:
CrashedBackendsCountCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("crashed_backends_count",
AdminInterfaceCommand::Backends,
@ -618,7 +623,7 @@ class CrashedBackendsCountCommand : public AdminInterfaceCommand {
class CrashedBackendsCommand : public AdminInterfaceCommand {
public:
CrashedBackendsCommand(NetworkPluginServer *server) :
AdminInterfaceCommand("crashed_backends",
AdminInterfaceCommand::Backends,
@ -649,7 +654,7 @@ class CrashedBackendsCommand : public AdminInterfaceCommand {
class MessagesFromXMPPCommand : public AdminInterfaceCommand {
public:
MessagesFromXMPPCommand(UserManager *userManager) : AdminInterfaceCommand("messages_from_xmpp",
AdminInterfaceCommand::Messages,
AdminInterfaceCommand::GlobalContext,
@ -675,7 +680,7 @@ class MessagesFromXMPPCommand : public AdminInterfaceCommand {
class MessagesToXMPPCommand : public AdminInterfaceCommand {
public:
MessagesToXMPPCommand(UserManager *userManager) : AdminInterfaceCommand("messages_to_xmpp",
AdminInterfaceCommand::Messages,
AdminInterfaceCommand::GlobalContext,
@ -759,7 +764,7 @@ class RegisterCommand : public AdminInterfaceCommand {
class UnregisterCommand : public AdminInterfaceCommand {
public:
UnregisterCommand(UserRegistration *userRegistration, Component *component) : AdminInterfaceCommand("unregister",
AdminInterfaceCommand::Users,
AdminInterfaceCommand::UserContext,
@ -795,7 +800,7 @@ class UnregisterCommand : public AdminInterfaceCommand {
class SetOAuth2CodeCommand : public AdminInterfaceCommand {
public:
SetOAuth2CodeCommand(Component *component) : AdminInterfaceCommand("set_oauth2_code",
AdminInterfaceCommand::Frontend,
AdminInterfaceCommand::GlobalContext,
@ -818,7 +823,7 @@ class SetOAuth2CodeCommand : public AdminInterfaceCommand {
ret = m_component->getFrontend()->setOAuth2Code(args[0], args[1]);
if (ret.empty()) {
return ret;
}
return "OAuth2 code and state set.";
}
@ -829,7 +834,7 @@ class SetOAuth2CodeCommand : public AdminInterfaceCommand {
class GetOAuth2URLCommand : public AdminInterfaceCommand {
public:
GetOAuth2URLCommand(Component *component) : AdminInterfaceCommand("get_oauth2_url",
AdminInterfaceCommand::Frontend,
AdminInterfaceCommand::GlobalContext,
@ -865,7 +870,7 @@ class GetOAuth2URLCommand : public AdminInterfaceCommand {
class HelpCommand : public AdminInterfaceCommand {
public:
HelpCommand(std::map<std::string, AdminInterfaceCommand *> *commands) : AdminInterfaceCommand("help",
AdminInterfaceCommand::General,
AdminInterfaceCommand::GlobalContext,
@ -920,7 +925,7 @@ class HelpCommand : public AdminInterfaceCommand {
class CommandsCommand : public AdminInterfaceCommand {
public:
CommandsCommand(std::map<std::string, AdminInterfaceCommand *> *commands) : AdminInterfaceCommand("commands",
AdminInterfaceCommand::General,
AdminInterfaceCommand::GlobalContext,
@ -979,7 +984,7 @@ class CommandsCommand : public AdminInterfaceCommand {
class VariablesCommand : public AdminInterfaceCommand {
public:
VariablesCommand(std::map<std::string, AdminInterfaceCommand *> *commands) : AdminInterfaceCommand("variables",
AdminInterfaceCommand::General,
AdminInterfaceCommand::GlobalContext,
@ -1044,7 +1049,7 @@ class VariablesCommand : public AdminInterfaceCommand {
class ArgsCommand : public AdminInterfaceCommand {
public:
ArgsCommand(std::map<std::string, AdminInterfaceCommand *> *commands) : AdminInterfaceCommand("args",
AdminInterfaceCommand::General,
AdminInterfaceCommand::GlobalContext,
@ -1235,9 +1240,9 @@ void AdminInterface::handleMessageReceived(Swift::Message::ref message) {
if (std::find(x.begin(), x.end(), message->getFrom().toBare().toString()) == x.end()) {
LOG4CXX_WARN(logger, "Message not from admin user, but from " << message->getFrom().toBare().toString());
return;
}
// Ignore empty messages
#if HAVE_SWIFTEN_3
if (message->getBody().get_value_or("").empty()) {

View file

@ -86,7 +86,7 @@ void LocalBuddy::setAlias(const std::string &alias) {
void LocalBuddy::setGroups(const std::vector<std::string> &groups) {
bool changed = m_groups.size() != groups.size();
if (!changed) {
for (int i = 0; i != m_groups.size(); i++) {
for (unsigned i = 0; i != m_groups.size(); i++) {
if (m_groups[i] != groups[i]) {
changed = true;
break;

View file

@ -102,7 +102,7 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
return;
}
for (int i = 0; i < format.length() && m_resultOffset == -1; i++) {
for (unsigned i = 0; i < format.length() && m_resultOffset == -1; i++) {
switch (format.at(i)) {
case 's':
m_params.resize(m_params.size() + 1);
@ -138,7 +138,7 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
}
}
for (int i = m_resultOffset; i >= 0 && i < format.length(); i++) {
for (unsigned i = m_resultOffset; i >= 0 && i < format.length(); i++) {
switch (format.at(i)) {
case 's':
m_results.resize(m_results.size() + 1);
@ -186,11 +186,11 @@ MySQLBackend::Statement::Statement(MYSQL *conn, const std::string &format, const
}
MySQLBackend::Statement::~Statement() {
for (int i = 0; i < m_params.size(); i++) {
for (unsigned i = 0; i < m_params.size(); i++) {
free(m_params[i].buffer);
free(m_params[i].length);
}
for (int i = 0; i < m_results.size(); i++) {
for (unsigned i = 0; i < m_results.size(); i++) {
free(m_results[i].buffer);
free(m_results[i].length);
}

View file

@ -1317,7 +1317,7 @@ void NetworkPluginServer::pingTimeout() {
// reconnect them to long-running backend, where they can idle hapilly till the end of ages.
time_t now = time(NULL);
std::vector<User *> usersToMove;
unsigned long diff = CONFIG_INT(m_config, "service.idle_reconnect_time");
long diff = CONFIG_INT(m_config, "service.idle_reconnect_time");
if (diff != 0) {
for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
// Users from long-running backends can't be moved
@ -2060,7 +2060,7 @@ static void __unblock_signals ( void )
NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient(bool acceptUsers, bool longRun, bool check) {
NetworkPluginServer::Backend *c = NULL;
unsigned long diff = CONFIG_INT(m_config, "service.login_delay");
long diff = CONFIG_INT(m_config, "service.login_delay");
time_t now = time(NULL);
if (diff && (now - m_lastLogin < diff)) {
m_loginTimer->stop();
@ -2077,11 +2077,11 @@ NetworkPluginServer::Backend *NetworkPluginServer::getFreeClient(bool acceptUser
// Check all backends and find free one
for (std::list<Backend *>::const_iterator it = m_clients.begin(); it != m_clients.end(); it++) {
if ((*it)->willDie == false && (*it)->acceptUsers == acceptUsers && (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection && (*it)->longRun == longRun) {
if ((*it)->willDie == false && (*it)->acceptUsers == acceptUsers && (int) (*it)->users.size() < CONFIG_INT(m_config, "service.users_per_backend") && (*it)->connection && (*it)->longRun == longRun) {
c = *it;
// if we're not reusing all backends and backend is full, stop accepting new users on this backend
if (!CONFIG_BOOL(m_config, "service.reuse_old_backends")) {
if (!check && c->users.size() + 1 >= CONFIG_INT(m_config, "service.users_per_backend")) {
if (!check && (int) c->users.size() + 1 >= CONFIG_INT(m_config, "service.users_per_backend")) {
c->acceptUsers = false;
}
}

View file

@ -52,7 +52,7 @@ StorageBackend *StorageBackend::createBackend(Config *config, std::string &error
std::string StorageBackend::encryptPassword(const std::string &password, const std::string &key) {
std::string encrypted;
encrypted.resize(password.size());
for (int i = 0; i < password.size(); i++) {
for (unsigned i = 0; i < password.size(); i++) {
char c = password[i];
char keychar = key[i % key.size()];
c += keychar;
@ -67,7 +67,7 @@ std::string StorageBackend::decryptPassword(std::string &encrypted, const std::s
encrypted = Swift::byteArrayToString(Swift::Base64::decode(encrypted));
std::string password;
password.resize(encrypted.size());
for (int i = 0; i < encrypted.size(); i++) {
for (unsigned i = 0; i < encrypted.size(); i++) {
char c = encrypted[i];
char keychar = key[i % key.size()];
c -= keychar;

View file

@ -183,7 +183,7 @@ std::string SlackAPI::getOwnerId(HTTPRequest *req, bool ok, rapidjson::Document
return "";
}
for (int i = 0; i < members.Size(); i++) {
for (unsigned i = 0; i < members.Size(); i++) {
if (!members[i].IsObject()) {
continue;
}
@ -231,7 +231,7 @@ void SlackAPI::getSlackChannelInfo(HTTPRequest *req, bool ok, rapidjson::Documen
info.name = name;
rapidjson::Value &members = channel["members"];
for (int y = 0; members.IsArray() && y < members.Size(); y++) {
for (unsigned y = 0; members.IsArray() && y < members.Size(); y++) {
if (!members[y].IsString()) {
continue;
}
@ -244,7 +244,7 @@ void SlackAPI::getSlackChannelInfo(HTTPRequest *req, bool ok, rapidjson::Documen
return;
}
for (int i = 0; i < channels.Size(); i++) {
for (unsigned i = 0; i < channels.Size(); i++) {
if (!channels[i].IsObject()) {
continue;
}
@ -258,7 +258,7 @@ void SlackAPI::getSlackChannelInfo(HTTPRequest *req, bool ok, rapidjson::Documen
info.name = name;
rapidjson::Value &members = channels[i]["members"];
for (int y = 0; members.IsArray() && y < members.Size(); y++) {
for (unsigned y = 0; members.IsArray() && y < members.Size(); y++) {
if (!members[y].IsString()) {
continue;
}
@ -280,7 +280,7 @@ void SlackAPI::getSlackImInfo(HTTPRequest *req, bool ok, rapidjson::Document &re
GET_ARRAY(resp, ims);
for (int i = 0; i < ims.Size(); i++) {
for (unsigned i = 0; i < ims.Size(); i++) {
if (!ims[i].IsObject()) {
continue;
}
@ -308,7 +308,7 @@ void SlackAPI::getSlackUserInfo(HTTPRequest *req, bool ok, rapidjson::Document &
GET_ARRAY(resp, users);
for (int i = 0; i < users.Size(); i++) {
for (unsigned i = 0; i < users.Size(); i++) {
if (!users[i].IsObject()) {
continue;
}
@ -337,7 +337,7 @@ void SlackAPI::getSlackUserInfo(HTTPRequest *req, bool ok, rapidjson::Document &
GET_ARRAY(resp, bots);
for (int i = 0; i < bots.Size(); i++) {
for (unsigned i = 0; i < bots.Size(); i++) {
if (!bots[i].IsObject()) {
continue;
}

View file

@ -119,7 +119,7 @@ void SlackRTM::handlePayloadReceived(const std::string &payload) {
rapidjson::Value &attachments = d["attachments"];
if (attachments.IsArray()) {
for (int i = 0; i < attachments.Size(); i++) {
for (unsigned i = 0; i < attachments.Size(); i++) {
STORE_STRING_OPTIONAL(attachments[i], fallback);
if (!fallback.empty()) {
text += fallback;

View file

@ -60,7 +60,7 @@ void DiscoItemsResponder::addAdHocCommand(const std::string &node, const std::st
}
void DiscoItemsResponder::addRoom(const std::string &node, const std::string &name) {
if (m_rooms->getItems().size() > CONFIG_INT(m_component->getConfig(), "service.max_room_list_size")) {
if ((int) m_rooms->getItems().size() > CONFIG_INT(m_component->getConfig(), "service.max_room_list_size")) {
return;
}
m_rooms->addItem(DiscoItems::Item(name, node));

View file

@ -2,6 +2,7 @@
#include <boost/optional.hpp>
#include "Swiften/SwiftenCompat.h"
#include "Swiften/Elements/PrivateStorage.h"
#include "Swiften/Parser/GenericPayloadParser.h"
@ -18,6 +19,6 @@ namespace Transport {
private:
int level;
std::auto_ptr<Swift::PayloadParser> currentPayloadParser;
SWIFTEN_UNIQUE_PTR<Swift::PayloadParser> currentPayloadParser;
};
}

View file

@ -78,12 +78,15 @@ BOOL spectrum_control_handler( DWORD fdwCtrlType ) {
}
#endif
// currently unused
#if 0
static void removeOldIcons(std::string iconDir) {
std::vector<std::string> dirs;
dirs.push_back(iconDir);
boost::thread thread(boost::bind(Util::removeEverythingOlderThan, dirs, time(NULL) - 3600*24*14));
}
#endif
#ifndef WIN32
static void daemonize(const char *cwd, const char *lock_file) {

View file

@ -242,7 +242,6 @@ void APIServer::serve_instances_register(Server *server, Server::session *sessio
response = server->send_command(instance, "register " + jid + " " + uin + " " + password);
if (!response.empty()) {
std::string value = jid;
int type = (int) TYPE_STRING;
m_storage->updateUserSetting(info.id, instance, value);
send_ack(conn, false, response);
}

View file

@ -156,7 +156,6 @@ int main(int argc, char **argv)
float elapsed = 0;
gettimeofday(&td_start, NULL);
time_t started = time(NULL);
while(get_response().empty()) {
eventLoop.runUntilEvents();
}

View file

@ -43,7 +43,7 @@ std::string searchForBinary(const std::string &binary) {
if (env_path != NULL) {
std::string buffer = "";
for (int s = 0; s < strlen(env_path); s++) {
for (unsigned s = 0; s < strlen(env_path); s++) {
if (env_path[s] == ':') {
path_list.insert(path_list.end(), std::string(buffer));
buffer = "";
@ -619,7 +619,6 @@ std::vector<std::string> show_list(ManagerConfig *config, bool show) {
return list;
}
bool found = false;
directory_iterator end_itr;
for (directory_iterator itr(p); itr != end_itr; ++itr) {
if (is_regular(itr->path()) && extension(itr->path()) == ".cfg") {

View file

@ -287,7 +287,7 @@ void Server::print_html(struct mg_connection *conn, struct http_message *hm, con
mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Content-Length: %d\r\n" // Always set Content-Length
"Content-Length: %zu\r\n" // Always set Content-Length
"\r\n"
"%s%s%s",
(int) html.size() + m_header.size() + m_footer.size(), m_header.c_str(), html.c_str(), m_footer.c_str());
@ -299,13 +299,12 @@ std::string Server::send_command(const std::string &jid, const std::string &cmd,
try {
ask_local_server(m_config, networkFactories, jid, cmd);
struct timeval td_start,td_end;
float elapsed = 0;
struct timeval td_start, td_end;
gettimeofday(&td_start, NULL);
gettimeofday(&td_end, NULL);
time_t started = time(NULL);
while(get_response().empty() && td_end.tv_sec - td_start.tv_sec < timeout) {
while (get_response().empty() && td_end.tv_sec - td_start.tv_sec < timeout) {
gettimeofday(&td_end, NULL);
eventLoop.runOnce();
}
@ -400,7 +399,7 @@ void Server::serve_logout(struct mg_connection *conn, struct http_message *hm) {
host += std::string(host_hdr->p, host_hdr->len);
}
Server:session *session = get_session(hm);
Server::session *session = get_session(hm);
mg_printf(conn, "HTTP/1.1 302 Found\r\n"
"Set-Cookie: session=%s; max-age=0\r\n"
"Set-Cookie: admin=%s; max-age=0\r\n"
@ -425,7 +424,7 @@ void Server::serve_oauth2(struct mg_connection *conn, struct http_message *hm) {
boost::split(args, response, boost::is_any_of(" "));
std::cerr << "set_oauth2_code response size " << args.size() << "\n";
if (args.size() == 3) {
Server:session *session = get_session(hm);
Server::session *session = get_session(hm);
UserInfo info;
m_storage->getUser(session->user, info);
std::string username = "";

View file

@ -35,7 +35,7 @@ class ConfigTest : public CPPUNIT_NS :: TestFixture{
}
void setStringTwice() {
char *argv[3] = {"binary", "--service.jids=localhost", NULL};
const char *argv[3] = {"binary", "--service.jids=localhost", NULL};
Config cfg(2, argv);
std::istringstream ifs("service.jids = irc.freenode.org\n");
cfg.load(ifs);
@ -43,7 +43,7 @@ class ConfigTest : public CPPUNIT_NS :: TestFixture{
}
void setUnknownBool() {
char *argv[3] = {"binary", "--service.jids=localhost", NULL};
const char *argv[3] = {"binary", "--service.jids=localhost", NULL};
Config cfg(2, argv);
std::istringstream ifs("service.irc_send_pass = 1\npurple.group-chat-open=0\n");
cfg.load(ifs);
@ -52,7 +52,7 @@ class ConfigTest : public CPPUNIT_NS :: TestFixture{
}
void enumerateConfigSection() {
char *argv[3] = {"binary", "--service.jids=localhost", NULL};
const char *argv[3] = {"binary", "--service.jids=localhost", NULL};
Config cfg(2, argv);
std::istringstream ifs("purple.irc_send_pass=1\npurple.group-chat-open=false\npurple.test=passed");
cfg.load(ifs);