diff options
Diffstat (limited to 'src/common/ignore.c')
-rw-r--r-- | src/common/ignore.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/common/ignore.c b/src/common/ignore.c index 045224ba..6085b657 100644 --- a/src/common/ignore.c +++ b/src/common/ignore.c @@ -53,7 +53,7 @@ static int ignored_total = 0; struct ignore * ignore_exists (char *mask) { - struct ignore *ig = 0; + struct ignore *ig = NULL; GSList *list; list = ignore_list; @@ -79,7 +79,7 @@ ignore_exists (char *mask) int ignore_add (char *mask, int type, gboolean overwrite) { - struct ignore *ig = 0; + struct ignore *ig = NULL; int change_only = FALSE; /* first check if it's already ignored */ @@ -88,12 +88,9 @@ ignore_add (char *mask, int type, gboolean overwrite) change_only = TRUE; if (!change_only) - ig = malloc (sizeof (struct ignore)); + ig = g_new (struct ignore, 1); - if (!ig) - return 0; - - ig->mask = strdup (mask); + ig->mask = g_strdup (mask); if (!overwrite && change_only) ig->type |= type; @@ -125,7 +122,7 @@ ignore_showlist (session *sess) ig = list->data; i++; - snprintf (tbuf, sizeof (tbuf), " %-25s ", ig->mask); + g_snprintf (tbuf, sizeof (tbuf), " %-25s ", ig->mask); if (ig->type & IG_PRIV) strcat (tbuf, _("YES ")); else @@ -192,8 +189,8 @@ ignore_del (char *mask, struct ignore *ig) if (ig) { ignore_list = g_slist_remove (ignore_list, ig); - free (ig->mask); - free (ig); + g_free (ig->mask); + g_free (ig); fe_ignore_update (1); return TRUE; } @@ -265,7 +262,7 @@ ignore_read_next_entry (char *my_cfg, struct ignore *ignore) my_cfg = cfg_get_str (my_cfg, "mask", tbuf, sizeof (tbuf)); if (!my_cfg) return NULL; - ignore->mask = strdup (tbuf); + ignore->mask = g_strdup (tbuf); } if (my_cfg) { @@ -281,7 +278,7 @@ ignore_load () struct ignore *ignore; struct stat st; char *cfg, *my_cfg; - int fh, i; + int fh; fh = hexchat_open_file ("ignore.conf", O_RDONLY, 0, 0); if (fh != -1) @@ -289,22 +286,18 @@ ignore_load () fstat (fh, &st); if (st.st_size) { - cfg = malloc (st.st_size + 1); - cfg[0] = '\0'; - i = read (fh, cfg, st.st_size); - if (i >= 0) - cfg[i] = '\0'; + cfg = g_malloc0 (st.st_size + 1); + read (fh, cfg, st.st_size); my_cfg = cfg; while (my_cfg) { - ignore = malloc (sizeof (struct ignore)); - memset (ignore, 0, sizeof (struct ignore)); + ignore = g_new0 (struct ignore, 1); if ((my_cfg = ignore_read_next_entry (my_cfg, ignore))) ignore_list = g_slist_prepend (ignore_list, ignore); else - free (ignore); + g_free (ignore); } - free (cfg); + g_free (cfg); } close (fh); } @@ -326,7 +319,7 @@ ignore_save () ig = (struct ignore *) temp->data; if (!(ig->type & IG_NOSAVE)) { - snprintf (buf, sizeof (buf), "mask = %s\ntype = %u\n\n", + g_snprintf (buf, sizeof (buf), "mask = %s\ntype = %u\n\n", ig->mask, ig->type); write (fh, buf, strlen (buf)); } @@ -379,9 +372,9 @@ flood_check (char *nick, char *ip, server *serv, session *sess, int what) /*0=ct for (i = 0; i < 128; i++) if (ip[i] == '@') break; - snprintf (real_ip, sizeof (real_ip), "*!*%s", &ip[i]); + g_snprintf (real_ip, sizeof (real_ip), "*!*%s", &ip[i]); - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), _("You are being CTCP flooded from %s, ignoring %s\n"), nick, real_ip); PrintText (sess, buf); @@ -406,7 +399,7 @@ flood_check (char *nick, char *ip, server *serv, session *sess, int what) /*0=ct serv->msg_counter++; if (serv->msg_counter == prefs.hex_flood_msg_num) /*if we reached the maximun numbers of ctcp in the seconds limits */ { - snprintf (buf, sizeof (buf), + g_snprintf (buf, sizeof (buf), _("You are being MSG flooded from %s, setting gui_autoopen_dialog OFF.\n"), ip); PrintText (sess, buf); |