mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-18 21:56:21 +00:00
@@ -63,6 +63,8 @@ if is_debug
|
||||
add_project_arguments([
|
||||
'-ggdb3',
|
||||
'-Wunused',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
], language: 'c')
|
||||
endif
|
||||
|
||||
|
||||
@@ -1767,7 +1767,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
||||
"/history", "/vercheck", "/privileges", "/wrap",
|
||||
"/carbons", "/slashguard", "/mam", "/silence" };
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices); i++) {
|
||||
result = autocomplete_param_with_func(input, boolean_choices[i], prefs_autocomplete_boolean_choice, previous, NULL);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -1784,7 +1784,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
||||
|
||||
// Remove quote character before and after names when doing autocomplete
|
||||
char* unquoted = strip_arg_quotes(input);
|
||||
for (int i = 0; i < ARRAY_SIZE(nick_choices); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(nick_choices); i++) {
|
||||
result = autocomplete_param_with_ac(unquoted, nick_choices[i], nick_ac, TRUE, previous);
|
||||
if (result) {
|
||||
free(unquoted);
|
||||
@@ -1799,7 +1799,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
||||
gchar* contact_choices[] = { "/msg", "/info" };
|
||||
// Remove quote character before and after names when doing autocomplete
|
||||
char* unquoted = strip_arg_quotes(input);
|
||||
for (int i = 0; i < ARRAY_SIZE(contact_choices); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(contact_choices); i++) {
|
||||
result = autocomplete_param_with_func(unquoted, contact_choices[i], roster_contact_autocomplete, previous, NULL);
|
||||
if (result) {
|
||||
free(unquoted);
|
||||
@@ -1814,7 +1814,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
||||
free(unquoted);
|
||||
|
||||
gchar* resource_choices[] = { "/caps", "/ping" };
|
||||
for (int i = 0; i < ARRAY_SIZE(resource_choices); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(resource_choices); i++) {
|
||||
result = autocomplete_param_with_func(input, resource_choices[i], roster_fulljid_autocomplete, previous, NULL);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -1823,7 +1823,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
||||
}
|
||||
|
||||
gchar* invite_choices[] = { "/join" };
|
||||
for (int i = 0; i < ARRAY_SIZE(invite_choices); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(invite_choices); i++) {
|
||||
result = autocomplete_param_with_func(input, invite_choices[i], muc_invites_find, previous, NULL);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -1843,7 +1843,7 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
||||
{ "/inputwin", winpos_ac },
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(ac_cmds); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(ac_cmds); i++) {
|
||||
result = autocomplete_param_with_ac(input, ac_cmds[i].cmd, ac_cmds[i].completer, TRUE, previous);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -1863,7 +1863,8 @@ _cmd_ac_complete_params(ProfWin* window, const char* const input, gboolean previ
|
||||
}
|
||||
parsed[i] = '\0';
|
||||
|
||||
char* (*ac_func)(ProfWin*, const char* const, gboolean) = g_hash_table_lookup(ac_funcs, parsed);
|
||||
char* (*ac_func)(ProfWin*, const char* const, gboolean) = (char* (*)(ProfWin*, const char* const, gboolean))g_hash_table_lookup(ac_funcs, parsed);
|
||||
|
||||
if (ac_func) {
|
||||
result = ac_func(window, input, previous);
|
||||
if (result) {
|
||||
@@ -1932,7 +1933,7 @@ _who_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
"/who chat", "/who away", "/who xa", "/who dnd", "/who available",
|
||||
"/who unavailable" };
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(group_commands); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(group_commands); i++) {
|
||||
result = autocomplete_param_with_func(input, group_commands[i], roster_group_autocomplete, previous, NULL);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -2254,7 +2255,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
|
||||
|
||||
gchar* boolean_choices1[] = { "/notify room current", "/notify chat current", "/notify typing current",
|
||||
"/notify room text", "/notify chat text", "/notify room offline" };
|
||||
for (int i = 0; i < ARRAY_SIZE(boolean_choices1); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices1); i++) {
|
||||
result = autocomplete_param_with_func(input, boolean_choices1[i], prefs_autocomplete_boolean_choice, previous, NULL);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -2287,7 +2288,7 @@ _notify_autocomplete(ProfWin* window, const char* const input, gboolean previous
|
||||
}
|
||||
|
||||
gchar* boolean_choices2[] = { "/notify invite", "/notify sub", "/notify mention", "/notify trigger" };
|
||||
for (int i = 0; i < ARRAY_SIZE(boolean_choices2); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(boolean_choices2); i++) {
|
||||
result = autocomplete_param_with_func(input, boolean_choices2[i], prefs_autocomplete_boolean_choice, previous, NULL);
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -3733,7 +3734,7 @@ _account_autocomplete(ProfWin* window, const char* const input, gboolean previou
|
||||
"/account disable", "/account rename", "/account clear", "/account remove",
|
||||
"/account default set" };
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(account_choice); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(account_choice); i++) {
|
||||
found = autocomplete_param_with_func(input, account_choice[i], accounts_find_all, previous, NULL);
|
||||
if (found) {
|
||||
return found;
|
||||
@@ -4274,7 +4275,7 @@ _vcard_autocomplete(ProfWin* window, const char* const input, gboolean previous)
|
||||
gboolean is_num = TRUE;
|
||||
|
||||
if (num_args >= 2) {
|
||||
for (int i = 0; i < strlen(args[1]); i++) {
|
||||
for (size_t i = 0; i < strlen(args[1]); i++) {
|
||||
if (!isdigit((int)args[1][i])) {
|
||||
is_num = FALSE;
|
||||
break;
|
||||
|
||||
@@ -2796,7 +2796,7 @@ _cmd_index(const Command* cmd)
|
||||
g_string_free(index_source, TRUE);
|
||||
|
||||
GString* index = g_string_new("");
|
||||
for (int i = 0; i < g_strv_length(tokens); i++) {
|
||||
for (guint i = 0; i < g_strv_length(tokens); i++) {
|
||||
index = g_string_append(index, tokens[i]);
|
||||
index = g_string_append(index, " ");
|
||||
}
|
||||
|
||||
@@ -1084,7 +1084,7 @@ _writecsv(int fd, const char* const str)
|
||||
|
||||
auto_char char* s = malloc(2 * len * sizeof(char));
|
||||
char* c = s;
|
||||
for (int i = 0; i < strlen(str); i++) {
|
||||
for (size_t i = 0; i < strlen(str); i++) {
|
||||
if (str[i] != '"')
|
||||
*c++ = str[i];
|
||||
else {
|
||||
@@ -1387,7 +1387,7 @@ cmd_close(ProfWin* window, const char* const command, gchar** args)
|
||||
gboolean is_num = TRUE;
|
||||
int index = 0;
|
||||
if (args[0] != NULL) {
|
||||
for (int i = 0; i < strlen(args[0]); i++) {
|
||||
for (size_t i = 0; i < strlen(args[0]); i++) {
|
||||
if (!isdigit((int)args[0][i])) {
|
||||
is_num = FALSE;
|
||||
break;
|
||||
@@ -1474,7 +1474,7 @@ gboolean
|
||||
cmd_win(ProfWin* window, const char* const command, gchar** args)
|
||||
{
|
||||
gboolean is_num = TRUE;
|
||||
for (int i = 0; i < strlen(args[0]); i++) {
|
||||
for (size_t i = 0; i < strlen(args[0]); i++) {
|
||||
if (!isdigit((int)args[0][i])) {
|
||||
is_num = FALSE;
|
||||
break;
|
||||
@@ -9983,7 +9983,7 @@ cmd_vcard_set(ProfWin* window, const char* const command, gchar** args)
|
||||
}
|
||||
|
||||
gboolean is_num = TRUE;
|
||||
for (int i = 0; i < strlen(key); i++) {
|
||||
for (size_t i = 0; i < strlen(key); i++) {
|
||||
if (!isdigit((int)key[i])) {
|
||||
is_num = FALSE;
|
||||
break;
|
||||
|
||||
@@ -344,7 +344,7 @@ color_distance(const struct color_def* a, const struct color_def* b)
|
||||
static int
|
||||
find_closest_col(int h, int s, int l)
|
||||
{
|
||||
struct color_def a = { h, s, l };
|
||||
struct color_def a = { h, s, l, NULL };
|
||||
int min = 0;
|
||||
int dmin = color_distance(&a, &color_names[0]);
|
||||
|
||||
@@ -369,7 +369,7 @@ find_col(const char* col_name, int n)
|
||||
* blue.
|
||||
*/
|
||||
|
||||
if (n >= sizeof(name)) {
|
||||
if (n >= (int)sizeof(name)) {
|
||||
/* truncate */
|
||||
log_error("Color: <%s,%d> bigger than %zu", col_name, n, sizeof(name));
|
||||
n = sizeof(name) - 1;
|
||||
|
||||
@@ -253,7 +253,7 @@ _prefs_load(void)
|
||||
gsize len = 0;
|
||||
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
autocomplete_add(room_trigger_ac, triggers[i]);
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,7 @@ prefs_message_get_triggers(const char* const message)
|
||||
gsize len = 0;
|
||||
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
auto_gchar gchar* trigger_lower = g_utf8_strdown(triggers[i], -1);
|
||||
if (g_strrstr(message_lower, trigger_lower)) {
|
||||
result = g_list_append(result, strdup(triggers[i]));
|
||||
@@ -1392,7 +1392,7 @@ prefs_get_room_notify_triggers(void)
|
||||
gsize len = 0;
|
||||
auto_gcharv gchar** triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
result = g_list_append(result, strdup(triggers[i]));
|
||||
}
|
||||
|
||||
@@ -1739,7 +1739,7 @@ prefs_get_aliases(void)
|
||||
gsize len;
|
||||
auto_gcharv gchar** keys = g_key_file_get_keys(prefs, PREF_GROUP_ALIAS, &len, NULL);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
char* name = keys[i];
|
||||
auto_gchar gchar* value = g_key_file_get_string(prefs, PREF_GROUP_ALIAS, name, NULL);
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ tlscerts_init(void)
|
||||
gsize len = 0;
|
||||
auto_gcharv gchar** groups = g_key_file_get_groups(tlscerts, &len);
|
||||
|
||||
for (int i = 0; i < g_strv_length(groups); i++) {
|
||||
for (guint i = 0; i < g_strv_length(groups); i++) {
|
||||
autocomplete_add(certs_ac, groups[i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ main(int argc, char** argv)
|
||||
|
||||
GOptionEntry entries[] = {
|
||||
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show version information", NULL },
|
||||
{ "account", 'a', 0, G_OPTION_ARG_STRING, &account_name, "Auto connect to an account on startup" },
|
||||
{ "account", 'a', 0, G_OPTION_ARG_STRING, &account_name, "Auto connect to an account on startup", NULL },
|
||||
{ "log", 'l', 0, G_OPTION_ARG_STRING, &log, "Set logging levels, DEBUG, INFO, WARN (default), ERROR", "LEVEL" },
|
||||
{ "config", 'c', 0, G_OPTION_ARG_STRING, &config_file, "Use an alternative configuration file", NULL },
|
||||
{ "logfile", 'f', 0, G_OPTION_ARG_STRING, &log_file, "Specify log file", NULL },
|
||||
|
||||
@@ -773,7 +773,7 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
||||
// <https://xmpp.org/extensions/xep-0384.html#encrypt>).
|
||||
// Yourself as recipients in case of MUC
|
||||
if (equals_our_barejid(recipients_iter->data)) {
|
||||
if (GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) {
|
||||
if ((uint32_t)GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) {
|
||||
log_debug("[OMEMO][SEND] Skipping %d (my device) ", GPOINTER_TO_INT(device_ids_iter->data));
|
||||
continue;
|
||||
}
|
||||
@@ -832,7 +832,7 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
|
||||
log_debug("[OMEMO][SEND][Sender] Sending to device %d for %s ", address.device_id, address.name);
|
||||
// Don't encrypt for this device (according to
|
||||
// <https://xmpp.org/extensions/xep-0384.html#encrypt>).
|
||||
if (address.device_id == omemo_ctx.device_id) {
|
||||
if ((uint32_t)address.device_id == omemo_ctx.device_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ omemo_format_fingerprint(const char* const fingerprint)
|
||||
{
|
||||
char* output = malloc(strlen(fingerprint) + strlen(fingerprint) / 8);
|
||||
|
||||
int i, j;
|
||||
size_t i, j;
|
||||
for (i = 0, j = 0; i < strlen(fingerprint); i++) {
|
||||
if (i > 0 && i % 8 == 0) {
|
||||
output[j++] = '-';
|
||||
@@ -1117,7 +1117,7 @@ omemo_is_trusted_identity(const char* const jid, const char* const fingerprint)
|
||||
static char*
|
||||
_omemo_fingerprint(ec_public_key* identity, gboolean formatted)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
signal_buffer* identity_public_key;
|
||||
|
||||
ec_public_key_serialize(&identity_public_key, identity);
|
||||
@@ -1161,8 +1161,8 @@ _omemo_fingerprint_decode(const char* const fingerprint, size_t* len)
|
||||
{
|
||||
unsigned char* output = malloc(strlen(fingerprint) / 2 + 1);
|
||||
|
||||
int i;
|
||||
int j;
|
||||
size_t i;
|
||||
size_t j;
|
||||
for (i = 0, j = 0; i < strlen(fingerprint);) {
|
||||
if (!g_ascii_isxdigit(fingerprint[i])) {
|
||||
i++;
|
||||
@@ -1724,7 +1724,7 @@ _bytes_from_hex(const char* hex, size_t hex_size,
|
||||
|
||||
memset(bytes, 0, bytes_size);
|
||||
|
||||
for (int i = 0; (i < hex_size) && (i / 2 < bytes_size); i += 2) {
|
||||
for (size_t i = 0; (i < hex_size) && (i / 2 < bytes_size); i += 2) {
|
||||
b0 = ((unsigned char)hex[i + 0] & 0x1f) ^ 0x10;
|
||||
b1 = ((unsigned char)hex[i + 1] & 0x1f) ^ 0x10;
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ _p_gpg_free_pubkeyid(ProfPGPPubKeyId* pubkeyid)
|
||||
free(pubkeyid);
|
||||
}
|
||||
|
||||
static gpgme_error_t*
|
||||
static gpgme_error_t
|
||||
_p_gpg_passphrase_cb(void* hook, const char* uid_hint, const char* passphrase_info, int prev_was_bad, int fd)
|
||||
{
|
||||
if (passphrase) {
|
||||
@@ -109,7 +109,7 @@ _p_gpg_passphrase_cb(void* hook, const char* uid_hint, const char* passphrase_in
|
||||
gpgme_io_write(fd, passphrase_attempt, strlen(passphrase_attempt));
|
||||
}
|
||||
|
||||
return 0;
|
||||
return GPG_ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -180,7 +180,7 @@ p_gpg_on_connect(const char* const barejid)
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
GError* gerr = NULL;
|
||||
gchar* jid = jids[i];
|
||||
auto_gchar gchar* keyid = g_key_file_get_string(pubkeyfile, jid, "keyid", &gerr);
|
||||
|
||||
@@ -126,7 +126,7 @@ plugins_init(void)
|
||||
if (!plugins_pref) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < g_strv_length(plugins_pref); i++) {
|
||||
for (guint i = 0; i < g_strv_length(plugins_pref); i++) {
|
||||
gboolean loaded = FALSE;
|
||||
gchar* filename = plugins_pref[i];
|
||||
#ifdef HAVE_PYTHON
|
||||
|
||||
@@ -1583,7 +1583,11 @@ static struct PyModuleDef profModule = {
|
||||
"prof",
|
||||
"",
|
||||
-1,
|
||||
apiMethods
|
||||
apiMethods,
|
||||
NULL, /* m_slots */
|
||||
NULL, /* m_traverse */
|
||||
NULL, /* m_clear */
|
||||
NULL /* m_free */
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ autocomplete_add(Autocomplete ac, const char* item)
|
||||
void
|
||||
autocomplete_add_all(Autocomplete ac, char** items)
|
||||
{
|
||||
for (int i = 0; i < g_strv_length(items); i++) {
|
||||
for (guint i = 0; i < g_strv_length(items); i++) {
|
||||
autocomplete_add(ac, items[i]);
|
||||
}
|
||||
}
|
||||
@@ -205,7 +205,7 @@ autocomplete_remove(Autocomplete ac, const char* const item)
|
||||
void
|
||||
autocomplete_remove_all(Autocomplete ac, char** items)
|
||||
{
|
||||
for (int i = 0; i < g_strv_length(items); i++) {
|
||||
for (guint i = 0; i < g_strv_length(items); i++) {
|
||||
autocomplete_remove(ac, items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ GHashTable*
|
||||
parse_options(gchar** args, gchar** opt_keys, gboolean* res)
|
||||
{
|
||||
GList* keys = NULL;
|
||||
for (int i = 0; i < g_strv_length(opt_keys); i++) {
|
||||
for (guint i = 0; i < g_strv_length(opt_keys); i++) {
|
||||
keys = g_list_append(keys, opt_keys[i]);
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ parse_options(gchar** args, gchar** opt_keys, gboolean* res)
|
||||
|
||||
// validate options
|
||||
GList* found_keys = NULL;
|
||||
for (int curr = 0; curr < g_strv_length(args); curr += 2) {
|
||||
for (guint curr = 0; curr < g_strv_length(args); curr += 2) {
|
||||
// check if option valid
|
||||
if (g_list_find_custom(keys, args[curr], (GCompareFunc)g_strcmp0) == NULL) {
|
||||
*res = FALSE;
|
||||
@@ -377,7 +377,7 @@ parse_options(gchar** args, gchar** opt_keys, gboolean* res)
|
||||
// create map
|
||||
options = g_hash_table_new(g_str_hash, g_str_equal);
|
||||
*res = TRUE;
|
||||
for (int curr = 0; curr < g_strv_length(args); curr += 2) {
|
||||
for (guint curr = 0; curr < g_strv_length(args); curr += 2) {
|
||||
g_hash_table_insert(options, args[curr], args[curr + 1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ cons_show_help(const char* const cmd, CommandHelp* help)
|
||||
cons_show("");
|
||||
win_println(console, THEME_HELP_HEADER, "-", "%s", &cmd[1]);
|
||||
win_print(console, THEME_HELP_HEADER, "-", "");
|
||||
int i;
|
||||
size_t i;
|
||||
for (i = 0; i < strlen(cmd) - 1; i++) {
|
||||
win_append(console, THEME_HELP_HEADER, "-");
|
||||
}
|
||||
@@ -131,7 +131,7 @@ cons_show_help(const char* const cmd, CommandHelp* help)
|
||||
win_println(console, THEME_HELP_HEADER, "-", "Description");
|
||||
win_println(console, THEME_DEFAULT, "-", "%s", help->desc);
|
||||
|
||||
int maxlen = 0;
|
||||
size_t maxlen = 0;
|
||||
for (i = 0; help->args[i][0] != NULL; i++) {
|
||||
if (strlen(help->args[i][0]) > maxlen)
|
||||
maxlen = strlen(help->args[i][0]);
|
||||
@@ -448,7 +448,7 @@ cons_show_wins(gboolean unread)
|
||||
|
||||
GSList* curr = window_strings;
|
||||
while (curr) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") != NULL) {
|
||||
win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data);
|
||||
} else {
|
||||
win_println(console, THEME_DEFAULT, "-", "%s", curr->data);
|
||||
@@ -469,7 +469,7 @@ cons_show_wins_attention(void)
|
||||
|
||||
GSList* curr = window_strings;
|
||||
while (curr) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") > 0) {
|
||||
if (g_strstr_len(curr->data, strlen(curr->data), " unread") != NULL) {
|
||||
win_println(console, THEME_CMD_WINS_UNREAD, "-", "%s", curr->data);
|
||||
} else {
|
||||
win_println(console, THEME_DEFAULT, "-", "%s", curr->data);
|
||||
@@ -823,7 +823,7 @@ cons_show_qrcode(const char* const text)
|
||||
static const size_t ZOOM_SIZE = 10;
|
||||
QRcode* qrcode = QRcode_encodeString(text, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
|
||||
|
||||
int width = (qrcode->width * ZOOM_SIZE);
|
||||
size_t width = (qrcode->width * ZOOM_SIZE);
|
||||
unsigned char* data = qrcode->data;
|
||||
|
||||
ProfWin* console = wins_get_console();
|
||||
@@ -835,7 +835,7 @@ cons_show_qrcode(const char* const text)
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
|
||||
for (size_t i = 0; i < width + 2 * ZOOM_SIZE; i += ZOOM_SIZE) {
|
||||
strcat(pad, "\u2588\u2588");
|
||||
}
|
||||
|
||||
@@ -2760,7 +2760,7 @@ cons_show_bookmarks_ignore(gchar** list, gsize len)
|
||||
cons_show("");
|
||||
cons_show("Ignored bookmarks:");
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (gsize i = 0; i < len; i++) {
|
||||
win_print(console, THEME_DEFAULT, "-", " %s", list[i]);
|
||||
win_newline(console);
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ _inp_write(char* line, int offset)
|
||||
if (line[i] == '\n') {
|
||||
c = retc;
|
||||
ch_len = wctomb(retc, L'\u23ce'); /* return symbol */
|
||||
if (ch_len == -1) { /* not representable */
|
||||
if (ch_len == (size_t)-1) { /* not representable */
|
||||
retc[0] = '\\';
|
||||
ch_len = 1;
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ _mucwin_print_triggers(ProfWin* window, const char* const message, GList* trigge
|
||||
}
|
||||
trigger_section[i] = '\0';
|
||||
|
||||
if (first_trigger_pos + first_trigger_len < strlen(message)) {
|
||||
if (first_trigger_pos + first_trigger_len < (int)strlen(message)) {
|
||||
win_append_highlight(window, THEME_ROOMTRIGGER_TERM, "%s", trigger_section);
|
||||
_mucwin_print_triggers(window, &message[first_trigger_pos + first_trigger_len], triggers);
|
||||
} else {
|
||||
|
||||
@@ -71,24 +71,24 @@ typedef struct _status_bar_t
|
||||
char* prompt;
|
||||
char* fulljid;
|
||||
GHashTable* tabs;
|
||||
int current_tab;
|
||||
guint current_tab;
|
||||
} StatusBar;
|
||||
|
||||
static GTimeZone* tz;
|
||||
static StatusBar* statusbar;
|
||||
static WINDOW* statusbar_win;
|
||||
|
||||
void _get_range_bounds(int* start, int* end, gboolean is_static);
|
||||
static int _status_bar_draw_time(int pos);
|
||||
static int _status_bar_draw_maintext(int pos);
|
||||
static int _status_bar_draw_bracket(gboolean current, int pos, const char* ch);
|
||||
static int _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static);
|
||||
static int _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets);
|
||||
static int _status_bar_draw_tabs(int pos);
|
||||
void _get_range_bounds(guint* start, guint* end, gboolean is_static);
|
||||
static guint _status_bar_draw_time(guint pos);
|
||||
static guint _status_bar_draw_maintext(guint pos);
|
||||
static guint _status_bar_draw_bracket(gboolean current, guint pos, const char* ch);
|
||||
static guint _status_bar_draw_extended_tabs(guint pos, gboolean prefix, guint start, guint end, gboolean is_static);
|
||||
static guint _status_bar_draw_tab(StatusBarTab* tab, guint pos, guint num, gboolean include_brackets);
|
||||
static guint _status_bar_draw_tabs(guint pos);
|
||||
static void _destroy_tab(StatusBarTab* tab);
|
||||
static int _tabs_width(int start, int end);
|
||||
static unsigned int _count_digits(int number);
|
||||
static unsigned int _count_digits_in_range(int start, int end);
|
||||
static guint _tabs_width(guint start, guint end);
|
||||
static guint _count_digits(guint number);
|
||||
static guint _count_digits_in_range(guint start, guint end);
|
||||
static char* _display_name(StatusBarTab* tab);
|
||||
static gboolean _tabmode_is_actlist(void);
|
||||
|
||||
@@ -161,7 +161,7 @@ status_bar_set_all_inactive(void)
|
||||
}
|
||||
|
||||
void
|
||||
status_bar_current(int i)
|
||||
status_bar_current(guint i)
|
||||
{
|
||||
if (i == 0) {
|
||||
statusbar->current_tab = 10;
|
||||
@@ -288,7 +288,7 @@ status_bar_draw(void)
|
||||
werase(statusbar_win);
|
||||
wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT));
|
||||
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
int pos = 1;
|
||||
|
||||
pos = _status_bar_draw_time(pos);
|
||||
@@ -300,24 +300,22 @@ status_bar_draw(void)
|
||||
inp_put_back();
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_tabs(int pos)
|
||||
static guint
|
||||
_status_bar_draw_tabs(guint pos)
|
||||
{
|
||||
auto_gchar gchar* tabmode = prefs_get_string(PREF_STATUSBAR_TABMODE);
|
||||
|
||||
if (g_strcmp0(tabmode, "actlist") != 0) {
|
||||
int start, end;
|
||||
guint start, end;
|
||||
gboolean is_static = g_strcmp0(tabmode, "dynamic") != 0;
|
||||
_get_range_bounds(&start, &end, is_static);
|
||||
|
||||
pos = getmaxx(stdscr) - _tabs_width(start, end);
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
// if the result of the calc is negative we take 0
|
||||
pos = MAX(0, (getmaxx(stdscr) - (int)_tabs_width(start, end)));
|
||||
|
||||
pos = _status_bar_draw_extended_tabs(pos, TRUE, start, end, is_static);
|
||||
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
pos = _status_bar_draw_tab(tab, pos, i, TRUE);
|
||||
@@ -365,9 +363,9 @@ _status_bar_draw_tabs(int pos)
|
||||
static gboolean
|
||||
_has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, int display_tabs_end)
|
||||
{
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
int tabs_count = g_hash_table_size(statusbar->tabs);
|
||||
if (tabs_count <= max_tabs) {
|
||||
if ((guint)tabs_count <= max_tabs) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -384,10 +382,10 @@ _has_new_msgs_beyond_range_on_side(gboolean left_side, int display_tabs_start, i
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gboolean is_static)
|
||||
static guint
|
||||
_status_bar_draw_extended_tabs(guint pos, gboolean prefix, guint start, guint end, gboolean is_static)
|
||||
{
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
if (max_tabs == 0) {
|
||||
return pos;
|
||||
}
|
||||
@@ -426,8 +424,8 @@ _status_bar_draw_extended_tabs(int pos, gboolean prefix, int start, int end, gbo
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brackets)
|
||||
static guint
|
||||
_status_bar_draw_tab(StatusBarTab* tab, guint pos, guint num, gboolean include_brackets)
|
||||
{
|
||||
gboolean is_current = num == statusbar->current_tab;
|
||||
|
||||
@@ -475,8 +473,8 @@ _status_bar_draw_tab(StatusBarTab* tab, int pos, int num, gboolean include_brack
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_bracket(gboolean current, int pos, const char* ch)
|
||||
static guint
|
||||
_status_bar_draw_bracket(gboolean current, guint pos, const char* ch)
|
||||
{
|
||||
int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET);
|
||||
wattron(statusbar_win, bracket_attrs);
|
||||
@@ -491,8 +489,8 @@ _status_bar_draw_bracket(gboolean current, int pos, const char* ch)
|
||||
return pos;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_time(int pos)
|
||||
static guint
|
||||
_status_bar_draw_time(guint pos)
|
||||
{
|
||||
auto_gchar gchar* time_pref = prefs_get_string(PREF_TIME_STATUSBAR);
|
||||
if (g_strcmp0(time_pref, "off") == 0) {
|
||||
@@ -536,8 +534,8 @@ _tabmode_is_actlist(void)
|
||||
return g_strcmp0(tabmode, "actlist") == 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_status_bar_draw_maintext(int pos)
|
||||
static guint
|
||||
_status_bar_draw_maintext(guint pos)
|
||||
{
|
||||
const char* maintext = NULL;
|
||||
auto_jid Jid* jidp = NULL;
|
||||
@@ -597,20 +595,20 @@ _destroy_tab(StatusBarTab* tab)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_tabs_width(int start, int end)
|
||||
static guint
|
||||
_tabs_width(guint start, guint end)
|
||||
{
|
||||
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
|
||||
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
|
||||
gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
|
||||
gint max_tabs = prefs_get_statusbartabs();
|
||||
guint max_tabs = prefs_get_statusbartabs();
|
||||
guint opened_tabs = g_hash_table_size(statusbar->tabs);
|
||||
|
||||
int width = start < 2 ? 1 : 4;
|
||||
width += end > opened_tabs - 1 ? 0 : 3;
|
||||
|
||||
if (show_name && show_number) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
gboolean is_current = i == statusbar->current_tab;
|
||||
@@ -627,7 +625,7 @@ _tabs_width(int start, int end)
|
||||
}
|
||||
|
||||
if (show_name && !show_number) {
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (guint i = start; i <= end; i++) {
|
||||
StatusBarTab* tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
|
||||
if (tab) {
|
||||
gboolean is_current = i == statusbar->current_tab;
|
||||
@@ -698,7 +696,7 @@ _display_name(StatusBarTab* tab)
|
||||
}
|
||||
|
||||
void
|
||||
_get_range_bounds(int* start, int* end, gboolean is_static)
|
||||
_get_range_bounds(guint* start, guint* end, gboolean is_static)
|
||||
{
|
||||
int current_tab = statusbar->current_tab;
|
||||
gint display_range = prefs_get_statusbartabs();
|
||||
@@ -721,12 +719,10 @@ _get_range_bounds(int* start, int* end, gboolean is_static)
|
||||
}
|
||||
|
||||
// Counts amount of digits in a number
|
||||
static unsigned int
|
||||
_count_digits(int number)
|
||||
static guint
|
||||
_count_digits(guint number)
|
||||
{
|
||||
unsigned int digits_count = 0;
|
||||
if (number < 0)
|
||||
number = -number;
|
||||
guint digits_count = 0;
|
||||
|
||||
do {
|
||||
number /= 10;
|
||||
@@ -738,12 +734,11 @@ _count_digits(int number)
|
||||
|
||||
// Counts the total number of digits in a range of numbers, inclusive.
|
||||
// Example: _count_digits_in_range(2, 3) returns 2, _count_digits_in_range(2, 922) returns 2657
|
||||
static unsigned int
|
||||
_count_digits_in_range(int start, int end)
|
||||
static guint
|
||||
_count_digits_in_range(guint start, guint end)
|
||||
{
|
||||
int total_digits = 0;
|
||||
|
||||
for (int i = start; i <= end; i++) {
|
||||
guint total_digits = 0;
|
||||
for (guint i = start; i <= end; i++) {
|
||||
total_digits += _count_digits(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,6 @@ void status_bar_set_prompt(const char* const prompt);
|
||||
void status_bar_clear_prompt(void);
|
||||
void status_bar_set_fulljid(const char* const fulljid);
|
||||
void status_bar_clear_fulljid(void);
|
||||
void status_bar_current(int i);
|
||||
void status_bar_current(guint i);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1871,7 +1871,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
curr_ch++;
|
||||
continue;
|
||||
}
|
||||
int offset = 0;
|
||||
size_t offset = 0;
|
||||
while (offset < ch_len) {
|
||||
word[wordi++] = curr_ch[offset++];
|
||||
}
|
||||
@@ -1880,9 +1880,9 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
word[wordi] = '\0';
|
||||
wordlen = utf8_display_len(word);
|
||||
|
||||
int curx = getcurx(win);
|
||||
size_t curx = (size_t)getcurx(win);
|
||||
int cury;
|
||||
int maxx = getmaxx(win);
|
||||
size_t maxx = getmaxx(win);
|
||||
|
||||
// wrap required
|
||||
if (curx + wordlen > maxx) {
|
||||
@@ -1892,7 +1892,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
if (wordlen > linelen) {
|
||||
gchar* word_ch = g_utf8_offset_to_pointer(word, 0);
|
||||
while (*word_ch != '\0') {
|
||||
curx = getcurx(win);
|
||||
curx = (size_t)getcurx(win);
|
||||
cury = getcury(win);
|
||||
gboolean firstline = cury == starty;
|
||||
|
||||
@@ -1913,7 +1913,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
// newline and print word
|
||||
} else {
|
||||
waddch(win, '\n');
|
||||
curx = getcurx(win);
|
||||
curx = (size_t)getcurx(win);
|
||||
cury = getcury(win);
|
||||
gboolean firstline = cury == starty;
|
||||
|
||||
@@ -1928,7 +1928,7 @@ _win_print_wrapped(WINDOW* win, const char* const message, size_t indent, int pa
|
||||
|
||||
// no wrap required
|
||||
} else {
|
||||
curx = getcurx(win);
|
||||
curx = (size_t)getcurx(win);
|
||||
cury = getcury(win);
|
||||
gboolean firstline = cury == starty;
|
||||
|
||||
|
||||
@@ -376,7 +376,7 @@ _caps_by_ver(const char* const ver)
|
||||
auto_gcharv gchar** features_list = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL);
|
||||
GSList* features = NULL;
|
||||
if (features_list && features_len > 0) {
|
||||
for (int i = 0; i < features_len; i++) {
|
||||
for (gsize i = 0; i < features_len; i++) {
|
||||
features = g_slist_append(features, features_list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,6 +248,12 @@ _iq_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* const us
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
_xmpp_stanza_release_destroy_notify(gpointer data)
|
||||
{
|
||||
xmpp_stanza_release((xmpp_stanza_t*)data);
|
||||
}
|
||||
|
||||
void
|
||||
iq_handlers_init(void)
|
||||
{
|
||||
@@ -264,7 +270,7 @@ iq_handlers_init(void)
|
||||
iq_handlers_clear();
|
||||
|
||||
id_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_iq_id_handler_free);
|
||||
rooms_cache = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)xmpp_stanza_release);
|
||||
rooms_cache = g_hash_table_new_full(g_str_hash, g_str_equal, free, _xmpp_stanza_release_destroy_notify);
|
||||
}
|
||||
|
||||
struct iq_win_finder
|
||||
@@ -302,7 +308,7 @@ _free_late_delivery_userdata(LateDeliveryUserdata* d)
|
||||
void
|
||||
iq_handlers_remove_win(ProfWin* window)
|
||||
{
|
||||
log_debug("Remove window %p of type %d", window, window ? window->type : -1);
|
||||
log_debug("Remove window %p of type %d", window, window ? window->type : (win_type_t)-1);
|
||||
if (!window)
|
||||
return;
|
||||
GSList *cur = late_delivery_windows, *next;
|
||||
@@ -394,7 +400,7 @@ iq_autoping_check(void)
|
||||
}
|
||||
|
||||
gdouble elapsed = g_timer_elapsed(autoping_time, NULL);
|
||||
unsigned long seconds_elapsed = elapsed * 1.0;
|
||||
gint seconds_elapsed = elapsed * 1.0;
|
||||
gint timeout = prefs_get_autoping_timeout();
|
||||
if (timeout > 0 && seconds_elapsed >= timeout) {
|
||||
cons_show("Autoping response timed out after %u seconds.", timeout);
|
||||
|
||||
@@ -427,7 +427,7 @@ muc_rooms(void)
|
||||
* Return current users nickname for the specified room
|
||||
* The nickname is owned by the chat room and should not be modified or freed
|
||||
*/
|
||||
const char* const
|
||||
const char*
|
||||
muc_nick(const char* const room)
|
||||
{
|
||||
ChatRoom* chat_room = g_hash_table_lookup(rooms, room);
|
||||
|
||||
@@ -93,7 +93,7 @@ GList* muc_rooms(void);
|
||||
|
||||
void muc_set_features(const char* const room, GSList* features);
|
||||
|
||||
const char* const muc_nick(const char* const room);
|
||||
const char* muc_nick(const char* const room);
|
||||
char* muc_password(const char* const room);
|
||||
|
||||
void muc_nick_change_start(const char* const room, const char* const new_nick);
|
||||
|
||||
@@ -424,8 +424,8 @@ session_check_autoaway(void)
|
||||
gboolean check = prefs_get_boolean(PREF_AUTOAWAY_CHECK);
|
||||
gint away_time = prefs_get_autoaway_time();
|
||||
gint xa_time = prefs_get_autoxa_time();
|
||||
int away_time_ms = away_time * 60000;
|
||||
int xa_time_ms = xa_time * 60000;
|
||||
unsigned long away_time_ms = away_time * 60000;
|
||||
unsigned long xa_time_ms = xa_time * 60000;
|
||||
|
||||
const char* account = session_get_account_name();
|
||||
resource_presence_t curr_presence = accounts_get_last_presence(account);
|
||||
|
||||
@@ -222,7 +222,7 @@ stanza_create_http_upload_request(xmpp_ctx_t* ctx, const char* const id,
|
||||
|
||||
auto_char char* filename_cpy = strdup(upload->filename);
|
||||
// strip spaces from filename (servers don't spaces)
|
||||
for (int i = 0; i < strlen(filename_cpy); i++) {
|
||||
for (size_t i = 0; i < strlen(filename_cpy); i++) {
|
||||
if (filename_cpy[i] == ' ') {
|
||||
filename_cpy[i] = '_';
|
||||
}
|
||||
@@ -1863,7 +1863,7 @@ stanza_get_error_message(xmpp_stanza_t* stanza)
|
||||
STANZA_NAME_UNEXPECTED_REQUEST
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(defined_conditions); i++) {
|
||||
for (size_t i = 0; i < ARRAY_SIZE(defined_conditions); i++) {
|
||||
xmpp_stanza_t* cond_stanza = xmpp_stanza_get_child_by_name(error_stanza, defined_conditions[i]);
|
||||
if (cond_stanza) {
|
||||
char* result = strdup(xmpp_stanza_get_name(cond_stanza));
|
||||
|
||||
Reference in New Issue
Block a user