summary refs log tree commit diff stats
path: root/src/common/ignore.c
blob: 1d1eaf200606290186f3c0bda84b94d8727376b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
/* X-Chat
 * Copyright (C) 1998 Peter Zelezny.
 *
 * 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 St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

#include "hexchat.h"
#include "ignore.h"
#include "cfgfiles.h"
#include "fe.h"
#include "text.h"
#include "util.h"
#include "hexchatc.h"
#include "typedef.h"


int ignored_ctcp = 0;			  /* keep a count of all we ignore */
int ignored_priv = 0;
int ignored_chan = 0;
int ignored_noti = 0;
int ignored_invi = 0;
static int ignored_total = 0;

/* ignore_exists ():
 * returns: struct ig, if this mask is in the ignore list already
 *          NULL, otherwise
 */
struct ignore *
ignore_exists (char *mask)
{
	struct ignore *ig = NULL;
	GSList *list;

	list = ignore_list;
	while (list)
	{
		ig = (struct ignore *) list->data;
		if (!rfc_casecmp (ig->mask, mask))
			return ig;
		list = list->next;
	}
	return NULL;

}

/* ignore_add(...)

 * returns:
 *            0 fail
 *            1 success
 *            2 success (old ignore has been changed)
 */

int
ignore_add (char *mask, int type, gboolean overwrite)
{
	struct ignore *ig = NULL;
	int change_only = FALSE;

	/* first check if it's already ignored */
	ig = ignore_exists (mask);
	if (ig)
		change_only = TRUE;

	if (!change_only)
		ig = g_new (struct ignore, 1);

	ig->mask = g_strdup (mask);

	if (!overwrite && change_only)
		ig->type |= type;
	else
		ig->type = type;

	if (!change_only)
		ignore_list = g_slist_prepend (ignore_list, ig);
	fe_ignore_update (1);

	if (change_only)
		return 2;

	return 1;
}

void
ignore_showlist (session *sess)
{
	struct ignore *ig;
	GSList *list = ignore_list;
	char tbuf[256];
	int i = 0;

	EMIT_SIGNAL (XP_TE_IGNOREHEADER, sess, 0, 0, 0, 0, 0);

	while (list)
	{
		ig = list->data;
		i++;

		g_snprintf (tbuf, sizeof (tbuf), " %-25s ", ig->mask);
		if (ig->type & IG_PRIV)
			strcat (tbuf, _("YES  "));
		else
			strcat (tbuf, _("NO   "));
		if (ig->type & IG_NOTI)
			strcat (tbuf, _("YES  "));
		else
			strcat (tbuf, _("NO   "));
		if (ig->type & IG_CHAN)
			strcat (tbuf, _("YES  "));
		else
			strcat (tbuf, _("NO   "));
		if (ig->type & IG_CTCP)
			strcat (tbuf, _("YES  "));
		else
			strcat (tbuf, _("NO   "));
		if (ig->type & IG_DCC)
			strcat (tbuf, _("YES  "));
		else
			strcat (tbuf, _("NO   "));
		if (ig->type & IG_INVI)
			strcat (tbuf, _("YES  "));
		else
			strcat (tbuf, _("NO   "));
		if (ig->type & IG_UNIG)
			strcat (tbuf, _("YES  "));
		else
			strcat (tbuf, _("NO   "));
		strcat (tbuf, "\n");
		PrintText (sess, tbuf);
		/*EMIT_SIGNAL (XP_TE_IGNORELIST, sess, ig->mask, 0, 0, 0, 0); */
		/* use this later, when TE's support 7 args */
		list = list->next;
	}

	if (!i)
		EMIT_SIGNAL (XP_TE_IGNOREEMPTY, sess, 0, 0, 0, 0, 0);

	EMIT_SIGNAL (XP_TE_IGNOREFOOTER, sess, 0, 0, 0, 0, 0);
}

/* ignore_del()

 * one of the args must be NULL, use mask OR *ig, not both
 *
 */

int
ignore_del (char *mask, struct ignore *ig)
{
	if (!ig)
	{
		GSList *list = ignore_list;

		while (list)
		{
			ig = (struct ignore *) list->data;
			if (!rfc_casecmp (ig->mask, mask))
				break;
			list = list->next;
			ig = 0;
		}
	}
	if (ig)
	{
		ignore_list = g_slist_remove (ignore_list, ig);
		g_free (ig->mask);
		g_free (ig);
		fe_ignore_update (1);
		return TRUE;
	}
	return FALSE;
}

/* check if a msg should be ignored by browsing our ignore list */

int
ignore_check (char *host, int type)
{
	struct ignore *ig;
	GSList *list = ignore_list;

	/* check if there's an UNIGNORE first, they take precendance. */
	while (list)
	{
		ig = (struct ignore *) list->data;
		if (ig->type & IG_UNIG)
		{
			if (ig->type & type)
			{
				if (match (ig->mask, host))
					return FALSE;
			}
		}
		list = list->next;
	}

	list = ignore_list;
	while (list)
	{
		ig = (struct ignore *) list->data;

		if (ig->type & type)
		{
			if (match (ig->mask, host))
			{
				ignored_total++;
				if (type & IG_PRIV)
					ignored_priv++;
				if (type & IG_NOTI)
					ignored_noti++;
				if (type & IG_CHAN)
					ignored_chan++;
				if (type & IG_CTCP)
					ignored_ctcp++;
				if (type & IG_INVI)
					ignored_invi++;
				fe_ignore_update (2);
				return TRUE;
			}
		}
		list = list->next;
	}

	return FALSE;
}

static char *
ignore_read_next_entry (char *my_cfg, struct ignore *ignore)
{
	char tbuf[1024];

	/* Casting to char * done below just to satisfy compiler */

	if (my_cfg)
	{
		my_cfg = cfg_get_str (my_cfg, "mask", tbuf, sizeof (tbuf));
		if (!my_cfg)
			return NULL;
		ignore->mask = g_strdup (tbuf);
	}
	if (my_cfg)
	{
		my_cfg = cfg_get_str (my_cfg, "type", tbuf, sizeof (tbuf));
		ignore->type = atoi (tbuf);
	}
	return my_cfg;
}

void
ignore_load ()
{
	struct ignore *ignore;
	struct stat st;
	char *cfg, *my_cfg;
	int fh;

	fh = hexchat_open_file ("ignore.conf", O_RDONLY, 0, 0);
	if (fh != -1)
	{
		fstat (fh, &st);
		if (st.st_size)
		{
			cfg = g_malloc0 (st.st_size + 1);
			read (fh, cfg, st.st_size);
			my_cfg = cfg;
			while (my_cfg)
			{
				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
					g_free (ignore);
			}
			g_free (cfg);
		}
		close (fh);
	}
}

void
ignore_save ()
{
	char buf[1024];
	int fh;
	GSList *temp = ignore_list;
	struct ignore *ig;

	fh = hexchat_open_file ("ignore.conf", O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE);
	if (fh != -1)
	{
		while (temp)
		{
			ig = (struct ignore *) temp->data;
			if (!(ig->type & IG_NOSAVE))
			{
				g_snprintf (buf, sizeof (buf), "mask = %s\ntype = %u\n\n",
							 ig->mask, ig->type);
				write (fh, buf, strlen (buf));
			}
			temp = temp->next;
		}
		close (fh);
	}

}

static gboolean
flood_autodialog_timeout (gpointer data)
{
	prefs.hex_gui_autoopen_dialog = 1;
	return FALSE;
}

int
flood_check (char *nick, char *ip, server *serv, session *sess, int what)	/*0=ctcp  1=priv */
{
	/*
	   serv
	   int ctcp_counter; 
	   time_t ctcp_last_time;
	   prefs
	   unsigned int ctcp_number_limit;
	   unsigned int ctcp_time_limit;
	 */
	char buf[512];
	char real_ip[132];
	int i;
	time_t current_time;
	current_time = time (NULL);

	if (what == 0)
	{
		if (serv->ctcp_last_time == 0)	/*first ctcp in this server */
		{
			serv->ctcp_last_time = time (NULL);
			serv->ctcp_counter++;
		} else
		{
			if (difftime (current_time, serv->ctcp_last_time) < prefs.hex_flood_ctcp_time)	/*if we got the ctcp in the seconds limit */
			{
				serv->ctcp_counter++;
				if (serv->ctcp_counter == prefs.hex_flood_ctcp_num)	/*if we reached the maximun numbers of ctcp in the seconds limits */
				{
					serv->ctcp_last_time = current_time;	/*we got the flood, restore all the vars for next one */
					serv->ctcp_counter = 0;
					for (i = 0; i < 128; i++)
						if (ip[i] == '@')
							break;
					g_snprintf (real_ip, sizeof (real_ip), "*!*%s", &ip[i]);

					g_snprintf (buf, sizeof (buf),
								 _("You are being CTCP flooded from %s, ignoring %s\n"),
								 nick, real_ip);
					PrintText (sess, buf);

					/* ignore CTCP */
					ignore_add (real_ip, IG_CTCP, FALSE);
					return 0;
				}
			}
		}
	} else
	{
		if (serv->msg_last_time == 0)
		{
			serv->msg_last_time = time (NULL);
			serv->ctcp_counter++;
		} else
		{
			if (difftime (current_time, serv->msg_last_time) <
				 prefs.hex_flood_msg_time)
			{
				serv->msg_counter++;
				if (serv->msg_counter == prefs.hex_flood_msg_num)	/*if we reached the maximun numbers of ctcp in the seconds limits */
				{
					g_snprintf (buf, sizeof (buf),
					 _("You are being MSG flooded from %s, setting gui_autoopen_dialog OFF.\n"),
								 ip);
					PrintText (sess, buf);
					serv->msg_last_time = current_time;	/*we got the flood, restore all the vars for next one */
					serv->msg_counter = 0;

					if (prefs.hex_gui_autoopen_dialog)
					{
						prefs.hex_gui_autoopen_dialog = 0;
						/* turn it back on in 30 secs */
						fe_timeout_add_seconds (30, flood_autodialog_timeout, NULL);
					}
					return 0;
				}
			}
		}
	}
	return 1;
}
span> char dcc_ip_str[DOMAINLEN + 1]; unsigned int tab_small; unsigned int tab_icons; unsigned int tab_sort; unsigned int mainwindow_save; unsigned int perc_color; unsigned int perc_ascii; unsigned int autodialog; unsigned int autoreconnect; unsigned int autoreconnectonfail; unsigned int invisible; unsigned int servernotice; unsigned int wallops; unsigned int skipmotd; unsigned int autorejoin; unsigned int autocopy_text; unsigned int autocopy_stamp; unsigned int autocopy_color; unsigned int colorednicks; unsigned int chanmodebuttons; unsigned int userlistbuttons; unsigned int showhostname_in_userlist; unsigned int nickcompletion; unsigned int completion_amount; unsigned int tabchannels; unsigned int paned_userlist; unsigned int autodccchat; unsigned int autodccsend; unsigned int autoresume; unsigned int autoopendccsendwindow; unsigned int autoopendccrecvwindow; unsigned int autoopendccchatwindow; unsigned int transparent; unsigned int text_stripcolor_msg; unsigned int text_stripcolor_replay; unsigned int text_stripcolor_topic; unsigned int timestamp; unsigned int fastdccsend; unsigned int dcc_send_fillspaces; unsigned int dcc_remove; unsigned int slist_fav; unsigned int slist_skip; unsigned int slist_select; unsigned int filterbeep; unsigned int input_balloon_chans; unsigned int input_balloon_hilight; unsigned int input_balloon_priv; unsigned int input_balloon_time; unsigned int input_beep_chans; unsigned int input_beep_hilight; unsigned int input_beep_priv; unsigned int input_flash_chans; unsigned int input_flash_hilight; unsigned int input_flash_priv; unsigned int input_tray_chans; unsigned int input_tray_hilight; unsigned int input_tray_priv; unsigned int truncchans; unsigned int privmsgtab; unsigned int irc_join_delay; unsigned int logging; unsigned int timestamp_logs; unsigned int newtabstofront; unsigned int dccwithnick; unsigned int hidever; unsigned int ip_from_server; unsigned int raw_modes; unsigned int show_away_once; unsigned int show_away_message; unsigned int auto_unmark_away; unsigned int away_track; unsigned int userhost; unsigned int irc_whois_front; unsigned int use_server_tab; unsigned int notices_tabs; unsigned int style_namelistgad; unsigned int style_inputbox; unsigned int windows_as_tabs; unsigned int indent_nicks; unsigned int text_replay; unsigned int show_marker; unsigned int show_separator; unsigned int thin_separator; unsigned int auto_indent; unsigned int wordwrap; unsigned int gui_input_spell; unsigned int gui_tray; unsigned int gui_tray_flags; unsigned int gui_tweaks; unsigned int _gui_ulist_left; unsigned int throttle; unsigned int topicbar; unsigned int hideuserlist; unsigned int hidemenu; unsigned int perlwarnings; unsigned int lagometer; unsigned int throttlemeter; unsigned int pingtimeout; unsigned int whois_on_notifyonline; unsigned int wait_on_exit; unsigned int confmode; unsigned int utf8_locale; #ifdef WIN32 unsigned int identd; unsigned int emoticons; #endif unsigned int ctcp_number_limit; /*flood */ unsigned int ctcp_time_limit; /*seconds of floods */ unsigned int msg_number_limit; /*same deal */ unsigned int msg_time_limit; unsigned int url_grabber; unsigned int url_grabber_limit; unsigned int url_logging; /* Tells us if we need to save, only when they've been edited. This is so that we continue using internal defaults (which can change in the next release) until the user edits them. */ unsigned int save_pevents:1; unsigned int text_search_case_match; unsigned int text_search_backward; unsigned int text_search_highlight_all; unsigned int text_search_follow; unsigned int text_search_regexp; }; /* Session types */ #define SESS_SERVER 1 #define SESS_CHANNEL 2 #define SESS_DIALOG 3 #define SESS_NOTICES 4 #define SESS_SNOTICES 5 /* Per-Channel Settings */ #define SET_OFF 0 #define SET_ON 1 #define SET_DEFAULT 2 /* use global setting */ /* Moved from fe-gtk for use in outbound.c as well -- */ typedef enum gtk_xtext_search_flags_e { case_match = 1, backward = 2, highlight = 4, follow = 8, regexp = 16 } gtk_xtext_search_flags; typedef struct session { /* Per-Channel Alerts */ /* use a byte, because we need a pointer to each element */ guint8 alert_beep; guint8 alert_taskbar; guint8 alert_tray; /* Per-Channel Settings */ guint8 text_hidejoinpart; guint8 text_logging; guint8 text_scrollback; struct server *server; void *usertree_alpha; /* pure alphabetical tree */ void *usertree; /* ordered with Ops first */ struct User *me; /* points to myself in the usertree */ char channel[CHANLEN]; char waitchannel[CHANLEN]; /* waiting to join channel (/join sent) */ char willjoinchannel[CHANLEN]; /* will issue /join for this channel */ char channelkey[64]; /* XXX correct max length? */ int limit; /* channel user limit */ int logfd; int scrollfd; /* scrollback filedes */ int scrollwritten; /* number of lines written */ char lastnick[NICKLEN]; /* last nick you /msg'ed */ struct history history; int ops; /* num. of ops in channel */ int hops; /* num. of half-oped users */ int voices; /* num. of voiced people */ int total; /* num. of users in channel */ char *quitreason; char *topic; char *current_modes; /* free() me */ int mode_timeout_tag; struct session *lastlog_sess; struct nbexec *running_exec; struct session_gui *gui; /* initialized by fe_new_window */ struct restore_gui *res; int type; /* SESS_* */ int new_data:1; /* new data avail? (purple tab) */ int nick_said:1; /* your nick mentioned? (blue tab) */ int msg_said:1; /* new msg available? (red tab) */ int ignore_date:1; int ignore_mode:1; int ignore_names:1; int end_of_names:1; int doing_who:1; /* /who sent on this channel */ int done_away_check:1; /* done checking for away status changes */ gtk_xtext_search_flags lastlog_flags; } session; struct msproxy_state_t { gint32 clientid; gint32 serverid; unsigned char seq_recv; /* seq number of last packet recv. */ unsigned char seq_sent; /* seq number of last packet sent. */ }; typedef struct server { /* server control operations (in server*.c) */ void (*connect)(struct server *, char *hostname, int port, int no_login); void (*disconnect)(struct session *, int sendquit, int err); int (*cleanup)(struct server *); void (*flush_queue)(struct server *); void (*auto_reconnect)(struct server *, int send_quit, int err); /* irc protocol functions (in proto*.c) */ void (*p_inline)(struct server *, char *buf, int len); void (*p_invite)(struct server *, char *channel, char *nick); void (*p_cycle)(struct server *, char *channel, char *key); void (*p_ctcp)(struct server *, char *to, char *msg); void (*p_nctcp)(struct server *, char *to, char *msg); void (*p_quit)(struct server *, char *reason); void (*p_kick)(struct server *, char *channel, char *nick, char *reason); void (*p_part)(struct server *, char *channel, char *reason); void (*p_ns_identify)(struct server *, char *pass); void (*p_ns_ghost)(struct server *, char *usname, char *pass); void (*p_join)(struct server *, char *channel, char *key); void (*p_join_list)(struct server *, GSList *channels, GSList *keys); void (*p_login)(struct server *, char *user, char *realname); void (*p_join_info)(struct server *, char *channel); void (*p_mode)(struct server *, char *target, char *mode); void (*p_user_list)(struct server *, char *channel); void (*p_away_status)(struct server *, char *channel); void (*p_whois)(struct server *, char *nicks); void (*p_get_ip)(struct server *, char *nick); void (*p_get_ip_uh)(struct server *, char *nick); void (*p_set_back)(struct server *); void (*p_set_away)(struct server *, char *reason); void (*p_message)(struct server *, char *channel, char *text); void (*p_action)(struct server *, char *channel, char *act); void (*p_notice)(struct server *, char *channel, char *text); void (*p_topic)(struct server *, char *channel, char *topic); void (*p_list_channels)(struct server *, char *arg, int min_users); void (*p_change_nick)(struct server *, char *new_nick); void (*p_names)(struct server *, char *channel); void (*p_ping)(struct server *, char *to, char *timestring); /* void (*p_set_away)(struct server *);*/ int (*p_raw)(struct server *, char *raw); int (*p_cmp)(const char *s1, const char *s2); int port; int sok; /* is equal to sok4 or sok6 (the one we are using) */ int sok4; /* tcp4 socket */ int sok6; /* tcp6 socket */ int proxy_type; int proxy_sok; /* Additional information for MS Proxy beast */ int proxy_sok4; int proxy_sok6; struct msproxy_state_t msp_state; int id; /* unique ID number (for plugin API) */ #ifdef USE_OPENSSL SSL *ssl; int ssl_do_connect_tag; #else void *ssl; #endif int childread; int childwrite; int childpid; int iotag; int recondelay_tag; /* reconnect delay timeout */ int joindelay_tag; /* waiting before we send JOIN */ char hostname[128]; /* real ip number */ char servername[128]; /* what the server says is its name */ char password[86]; char nick[NICKLEN]; char linebuf[2048]; /* RFC says 512 chars including \r\n */ char *last_away_reason; int pos; /* current position in linebuf */ int nickcount; int nickservtype; /* 0=/MSG nickserv 1=/NICKSERV 2=/NS */ char *chantypes; /* for 005 numeric - free me */ char *chanmodes; /* for 005 numeric - free me */ char *nick_prefixes; /* e.g. "*@%+" */ char *nick_modes; /* e.g. "aohv" */ char *bad_nick_prefixes; /* for ircd that doesn't give the modes */ int modes_per_line; /* 6 on undernet, 4 on efnet etc... */ void *network; /* points to entry in servlist.c or NULL! */ GSList *outbound_queue; time_t next_send; /* cptr->since in ircu */ time_t prev_now; /* previous now-time */ int sendq_len; /* queue size */ int lag; /* milliseconds */ struct session *front_session; /* front-most window/tab */ struct session *server_session; /* server window/tab */ struct server_gui *gui; /* initialized by fe_new_server */ unsigned int ctcp_counter; /*flood */ time_t ctcp_last_time; unsigned int msg_counter; /*counts the msg tab opened in a certain time */ time_t msg_last_time; /*time_t connect_time;*/ /* when did it connect? */ time_t lag_sent; time_t ping_recv; /* when we last got a ping reply */ time_t away_time; /* when we were marked away */ char *encoding; /* NULL for system */ char *autojoin; /* list of channels & keys to join */ unsigned int motd_skipped:1; unsigned int connected:1; unsigned int connecting:1; unsigned int no_login:1; unsigned int skip_next_userhost:1;/* used for "get my ip from server" */ unsigned int skip_next_whois:1; /* hide whois output */ unsigned int inside_whois:1; unsigned int doing_dns:1; /* /dns has been done */ unsigned int end_of_motd:1; /* end of motd reached (logged in) */ unsigned int sent_quit:1; /* sent a QUIT already? */ unsigned int use_listargs:1; /* undernet and dalnet need /list >0,<10000 */ unsigned int is_away:1; unsigned int reconnect_away:1; /* whether to reconnect in is_away state */ unsigned int dont_use_proxy:1; /* to proxy or not to proxy */ unsigned int supports_watch:1; /* supports the WATCH command */ unsigned int bad_prefix:1; /* gave us a bad PREFIX= 005 number */ unsigned int have_namesx:1; /* 005 tokens NAMESX and UHNAMES */ unsigned int have_uhnames:1; unsigned int have_whox:1; /* have undernet's WHOX features */ unsigned int have_capab:1; /* supports CAPAB (005 tells us) */ unsigned int have_idmsg:1; /* freenode's IDENTIFY-MSG */ unsigned int have_except:1; /* ban exemptions +e */ unsigned int using_cp1255:1; /* encoding is CP1255/WINDOWS-1255? */ unsigned int using_irc:1; /* encoding is "IRC" (CP1252/UTF-8 hybrid)? */ unsigned int use_who:1; /* whether to use WHO command to get dcc_ip */ #ifdef USE_OPENSSL unsigned int use_ssl:1; /* is server SSL capable? */ unsigned int accept_invalid_cert:1;/* ignore result of server's cert. verify */ #endif } server; typedef int (*cmd_callback) (struct session * sess, char *tbuf, char *word[], char *word_eol[]); struct commands { char *name; cmd_callback callback; char needserver; char needchannel; gint16 handle_quotes; char *help; }; struct away_msg { struct server *server; char nick[NICKLEN]; char *message; }; /* not just for popups, but used for usercommands, ctcp replies, userlist buttons etc */ struct popup { char *cmd; char *name; }; /* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */ #define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n))) #ifdef WIN32 #define xchat_filename_from_utf8 g_locale_from_utf8 #define xchat_filename_to_utf8 g_locale_to_utf8 #else #define xchat_filename_from_utf8 g_filename_from_utf8 #define xchat_filename_to_utf8 g_filename_to_utf8 #endif #endif