5 #include <time.h> /* need time_t */
10 #define N_(String) (String)
14 #define malloc(n) xchat_malloc(n, __FILE__, __LINE__)
15 #define realloc(n, m) xchat_realloc(n, m, __FILE__, __LINE__)
16 #define free(n) xchat_dfree(n, __FILE__, __LINE__)
17 #define strdup(n) xchat_strdup(n, __FILE__, __LINE__)
18 void *xchat_malloc (int size
, char *file
, int line
);
19 void *xchat_strdup (char *str
, char *file
, int line
);
20 void xchat_dfree (void *buf
, char *file
, int line
);
21 void *xchat_realloc (char *old
, int len
, char *file
, int line
);
24 #include <openssl/ssl.h> /* SSL_() */
26 /* force a 32bit CMP.L */
27 #define CMPL(a, c0, c1, c2, c3) (a == (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24)))
28 #define WORDL(c0, c1, c2, c3) (guint32)(c0 | (c1 << 8) | (c2 << 16) | (c3 << 24))
29 #define WORDW(c0, c1) (guint16)(c0 | (c1 << 8))
33 #define FONTNAMELEN 127
36 #define NICKLEN 64 /* including the NULL, so 63 really */
39 #define USERNAMELEN 10
40 #define HIDDEN_CHAR 8 /* invisible character for xtext */
46 int tochannel
; /* making this int keeps the struct 4-byte aligned */
60 char nick_suffix
[4]; /* Only ever holds a one-character string. */
64 char font_normal
[FONTNAMELEN
+ 1];
65 char doubleclickuser
[256];
66 char sounddir
[PATHLEN
+ 1];
67 char soundcmd
[PATHLEN
+ 1];
68 char background
[PATHLEN
+ 1];
69 char dccdir
[PATHLEN
+ 1];
70 char dcc_completed_dir
[PATHLEN
+ 1];
71 char irc_extra_hilight
[300];
72 char irc_no_hilight
[300];
73 char irc_nick_hilight
[300];
78 char stamp_format
[64];
79 char timestamp_log_format
[64];
80 char irc_id_ytext
[64];
81 char irc_id_ntext
[64];
85 int proxy_type
; /* 0=disabled, 1=wingate 2=socks4, 3=socks5, 4=http */
86 int proxy_use
; /* 0=all 1=IRC_ONLY 2=DCC_ONLY */
87 unsigned int proxy_auth
;
91 int first_dcc_send_port
;
92 int last_dcc_send_port
;
101 int gui_pane_left_size
;
102 int gui_pane_right_size
;
115 int dcc_global_max_get_cps
;
116 int dcc_global_max_send_cps
;
118 int dcc_max_send_cps
;
121 int mainwindow_width
;
122 int mainwindow_height
;
139 char dcc_ip_str
[DOMAINLEN
+ 1];
141 unsigned int tab_small
;
142 unsigned int tab_sort
;
143 unsigned int mainwindow_save
;
144 unsigned int perc_color
;
145 unsigned int perc_ascii
;
146 unsigned int autosave
;
147 unsigned int autodialog
;
148 unsigned int autosave_url
;
149 unsigned int autoreconnect
;
150 unsigned int autoreconnectonfail
;
151 unsigned int invisible
;
152 unsigned int servernotice
;
153 unsigned int wallops
;
154 unsigned int skipmotd
;
155 unsigned int autorejoin
;
156 unsigned int colorednicks
;
157 unsigned int chanmodebuttons
;
158 unsigned int userlistbuttons
;
159 unsigned int showhostname_in_userlist
;
160 unsigned int nickcompletion
;
161 unsigned int completion_amount
;
162 unsigned int tabchannels
;
163 unsigned int paned_userlist
;
164 unsigned int autodccchat
;
165 unsigned int autodccsend
;
166 unsigned int autoresume
;
167 unsigned int autoopendccsendwindow
;
168 unsigned int autoopendccrecvwindow
;
169 unsigned int autoopendccchatwindow
;
170 unsigned int transparent
;
171 unsigned int stripcolor
;
172 unsigned int timestamp
;
173 unsigned int fastdccsend
;
174 unsigned int dcc_send_fillspaces
;
175 unsigned int dcc_remove
;
176 unsigned int slist_fav
;
177 unsigned int slist_skip
;
178 unsigned int slist_select
;
179 unsigned int filterbeep
;
181 unsigned int input_balloon_chans
;
182 unsigned int input_balloon_hilight
;
183 unsigned int input_balloon_priv
;
184 unsigned int input_balloon_time
;
186 unsigned int input_beep_chans
;
187 unsigned int input_beep_hilight
;
188 unsigned int input_beep_priv
;
190 unsigned int input_flash_chans
;
191 unsigned int input_flash_hilight
;
192 unsigned int input_flash_priv
;
194 unsigned int input_tray_chans
;
195 unsigned int input_tray_hilight
;
196 unsigned int input_tray_priv
;
198 unsigned int truncchans
;
199 unsigned int privmsgtab
;
200 unsigned int irc_join_delay
;
201 unsigned int logging
;
202 unsigned int timestamp_logs
;
203 unsigned int newtabstofront
;
204 unsigned int dccwithnick
;
205 unsigned int hidever
;
206 unsigned int ip_from_server
;
207 unsigned int raw_modes
;
208 unsigned int show_away_once
;
209 unsigned int show_away_message
;
210 unsigned int auto_unmark_away
;
211 unsigned int away_track
;
212 unsigned int userhost
;
213 unsigned int irc_whois_front
;
214 unsigned int use_server_tab
;
215 unsigned int notices_tabs
;
216 unsigned int style_namelistgad
;
217 unsigned int style_inputbox
;
218 unsigned int windows_as_tabs
;
219 unsigned int indent_nicks
;
220 unsigned int text_replay
;
221 unsigned int show_marker
;
222 unsigned int show_separator
;
223 unsigned int thin_separator
;
224 unsigned int auto_indent
;
225 unsigned int wordwrap
;
226 unsigned int gui_input_spell
;
227 unsigned int gui_tray
;
228 unsigned int gui_tray_flags
;
229 unsigned int gui_tweaks
;
230 unsigned int _gui_ulist_left
;
231 unsigned int throttle
;
232 unsigned int topicbar
;
233 unsigned int hideuserlist
;
234 unsigned int hidemenu
;
235 unsigned int perlwarnings
;
236 unsigned int lagometer
;
237 unsigned int throttlemeter
;
238 unsigned int pingtimeout
;
239 unsigned int whois_on_notifyonline
;
240 unsigned int wait_on_exit
;
241 unsigned int confmode
;
242 unsigned int utf8_locale
;
245 unsigned int ctcp_number_limit
; /*flood */
246 unsigned int ctcp_time_limit
; /*seconds of floods */
248 unsigned int msg_number_limit
; /*same deal */
249 unsigned int msg_time_limit
;
251 unsigned int url_grabber
;
252 unsigned int url_grabber_limit
;
253 /* Tells us if we need to save, only when they've been edited.
254 This is so that we continue using internal defaults (which can
255 change in the next release) until the user edits them. */
256 unsigned int save_pevents
:1;
260 #define SESS_SERVER 1
261 #define SESS_CHANNEL 2
262 #define SESS_DIALOG 3
263 #define SESS_NOTICES 4
264 #define SESS_SNOTICES 5
266 /* Per-Channel Settings */
269 #define SET_DEFAULT 2 /* use global setting */
271 typedef struct session
273 /* Per-Channel Alerts */
274 /* use a byte, because we need a pointer to each element */
276 guint8 alert_taskbar
;
279 /* Per-Channel Settings */
280 guint8 text_hidejoinpart
;
282 guint8 text_scrollback
;
284 struct server
*server
;
285 void *usertree_alpha
; /* pure alphabetical tree */
286 void *usertree
; /* ordered with Ops first */
287 struct User
*me
; /* points to myself in the usertree */
288 char channel
[CHANLEN
];
289 char waitchannel
[CHANLEN
]; /* waiting to join channel (/join sent) */
290 char willjoinchannel
[CHANLEN
]; /* will issue /join for this channel */
291 char channelkey
[64]; /* XXX correct max length? */
292 int limit
; /* channel user limit */
294 int scrollfd
; /* scrollback filedes */
295 int scrollwritten
; /* number of lines written */
297 char lastnick
[NICKLEN
]; /* last nick you /msg'ed */
299 struct history history
;
301 int ops
; /* num. of ops in channel */
302 int hops
; /* num. of half-oped users */
303 int voices
; /* num. of voiced people */
304 int total
; /* num. of users in channel */
308 char *current_modes
; /* free() me */
310 int mode_timeout_tag
;
312 struct session
*lastlog_sess
;
313 struct nbexec
*running_exec
;
315 struct session_gui
*gui
; /* initialized by fe_new_window */
316 struct restore_gui
*res
;
318 int type
; /* SESS_* */
320 int new_data
:1; /* new data avail? (purple tab) */
321 int nick_said
:1; /* your nick mentioned? (blue tab) */
322 int msg_said
:1; /* new msg available? (red tab) */
328 int doing_who
:1; /* /who sent on this channel */
329 int done_away_check
:1; /* done checking for away status changes */
330 unsigned int lastlog_regexp
:1; /* this is a lastlog and using regexp */
333 struct msproxy_state_t
337 unsigned char seq_recv
; /* seq number of last packet recv. */
338 unsigned char seq_sent
; /* seq number of last packet sent. */
341 typedef struct server
343 /* server control operations (in server*.c) */
344 void (*connect
)(struct server
*, char *hostname
, int port
, int no_login
);
345 void (*disconnect
)(struct session
*, int sendquit
, int err
);
346 int (*cleanup
)(struct server
*);
347 void (*flush_queue
)(struct server
*);
348 void (*auto_reconnect
)(struct server
*, int send_quit
, int err
);
349 /* irc protocol functions (in proto*.c) */
350 void (*p_inline
)(struct server
*, char *buf
, int len
);
351 void (*p_invite
)(struct server
*, char *channel
, char *nick
);
352 void (*p_cycle
)(struct server
*, char *channel
, char *key
);
353 void (*p_ctcp
)(struct server
*, char *to
, char *msg
);
354 void (*p_nctcp
)(struct server
*, char *to
, char *msg
);
355 void (*p_quit
)(struct server
*, char *reason
);
356 void (*p_kick
)(struct server
*, char *channel
, char *nick
, char *reason
);
357 void (*p_part
)(struct server
*, char *channel
, char *reason
);
358 void (*p_ns_identify
)(struct server
*, char *pass
);
359 void (*p_ns_ghost
)(struct server
*, char *usname
, char *pass
);
360 void (*p_join
)(struct server
*, char *channel
, char *key
);
361 void (*p_join_list
)(struct server
*, GSList
*channels
, GSList
*keys
);
362 void (*p_login
)(struct server
*, char *user
, char *realname
);
363 void (*p_join_info
)(struct server
*, char *channel
);
364 void (*p_mode
)(struct server
*, char *target
, char *mode
);
365 void (*p_user_list
)(struct server
*, char *channel
);
366 void (*p_away_status
)(struct server
*, char *channel
);
367 void (*p_whois
)(struct server
*, char *nicks
);
368 void (*p_get_ip
)(struct server
*, char *nick
);
369 void (*p_get_ip_uh
)(struct server
*, char *nick
);
370 void (*p_set_back
)(struct server
*);
371 void (*p_set_away
)(struct server
*, char *reason
);
372 void (*p_message
)(struct server
*, char *channel
, char *text
);
373 void (*p_action
)(struct server
*, char *channel
, char *act
);
374 void (*p_notice
)(struct server
*, char *channel
, char *text
);
375 void (*p_topic
)(struct server
*, char *channel
, char *topic
);
376 void (*p_list_channels
)(struct server
*, char *arg
, int min_users
);
377 void (*p_change_nick
)(struct server
*, char *new_nick
);
378 void (*p_names
)(struct server
*, char *channel
);
379 void (*p_ping
)(struct server
*, char *to
, char *timestring
);
380 /* void (*p_set_away)(struct server *);*/
381 int (*p_raw
)(struct server
*, char *raw
);
382 int (*p_cmp
)(const char *s1
, const char *s2
);
385 int sok
; /* is equal to sok4 or sok6 (the one we are using) */
386 int sok4
; /* tcp4 socket */
387 int sok6
; /* tcp6 socket */
389 int proxy_sok
; /* Additional information for MS Proxy beast */
392 struct msproxy_state_t msp_state
;
393 int id
; /* unique ID number (for plugin API) */
396 int ssl_do_connect_tag
;
404 int recondelay_tag
; /* reconnect delay timeout */
405 int joindelay_tag
; /* waiting before we send JOIN */
406 char hostname
[128]; /* real ip number */
407 char servername
[128]; /* what the server says is its name */
411 char linebuf
[2048]; /* RFC says 512 chars including \r\n */
412 char *last_away_reason
;
413 int pos
; /* current position in linebuf */
415 int loginmethod
; /* see login_types[] */
417 char *chantypes
; /* for 005 numeric - free me */
418 char *chanmodes
; /* for 005 numeric - free me */
419 char *nick_prefixes
; /* e.g. "*@%+" */
420 char *nick_modes
; /* e.g. "aohv" */
421 char *bad_nick_prefixes
; /* for ircd that doesn't give the modes */
422 int modes_per_line
; /* 6 on undernet, 4 on efnet etc... */
424 void *network
; /* points to entry in servlist.c or NULL! */
426 GSList
*outbound_queue
;
427 time_t next_send
; /* cptr->since in ircu */
428 time_t prev_now
; /* previous now-time */
429 int sendq_len
; /* queue size */
430 int lag
; /* milliseconds */
432 struct session
*front_session
; /* front-most window/tab */
433 struct session
*server_session
; /* server window/tab */
435 struct server_gui
*gui
; /* initialized by fe_new_server */
437 unsigned int ctcp_counter
; /*flood */
438 time_t ctcp_last_time
;
440 unsigned int msg_counter
; /*counts the msg tab opened in a certain time */
441 time_t msg_last_time
;
443 /*time_t connect_time;*/ /* when did it connect? */
445 time_t ping_recv
; /* when we last got a ping reply */
446 time_t away_time
; /* when we were marked away */
448 char *encoding
; /* NULL for system */
449 char *autojoin
; /* list of channels & keys to join */
451 unsigned int motd_skipped
:1;
452 unsigned int connected
:1;
453 unsigned int connecting
:1;
454 unsigned int no_login
:1;
455 unsigned int skip_next_userhost
:1;/* used for "get my ip from server" */
456 unsigned int skip_next_whois
:1; /* hide whois output */
457 unsigned int inside_whois
:1;
458 unsigned int doing_dns
:1; /* /dns has been done */
459 unsigned int end_of_motd
:1; /* end of motd reached (logged in) */
460 unsigned int sent_quit
:1; /* sent a QUIT already? */
461 unsigned int use_listargs
:1; /* undernet and dalnet need /list >0,<10000 */
462 unsigned int is_away
:1;
463 unsigned int reconnect_away
:1; /* whether to reconnect in is_away state */
464 unsigned int dont_use_proxy
:1; /* to proxy or not to proxy */
465 unsigned int supports_watch
:1; /* supports the WATCH command */
466 unsigned int supports_monitor
:1; /* supports the MONITOR command */
467 unsigned int bad_prefix
:1; /* gave us a bad PREFIX= 005 number */
468 unsigned int have_namesx
:1; /* 005 tokens NAMESX and UHNAMES */
469 unsigned int have_awaynotify
:1;
470 unsigned int have_uhnames
:1;
471 unsigned int have_whox
:1; /* have undernet's WHOX features */
472 unsigned int have_idmsg
:1; /* freenode's IDENTIFY-MSG */
473 unsigned int have_accnotify
:1; /* cap account-notify */
474 unsigned int have_extjoin
:1; /* cap extended-join */
475 unsigned int have_sasl
:1; /* SASL capability */
476 unsigned int have_except
:1; /* ban exemptions +e */
477 unsigned int using_cp1255
:1; /* encoding is CP1255/WINDOWS-1255? */
478 unsigned int using_irc
:1; /* encoding is "IRC" (CP1252/UTF-8 hybrid)? */
479 unsigned int use_who
:1; /* whether to use WHO command to get dcc_ip */
480 unsigned int use_ssl
:1; /* is server SSL capable? */
481 unsigned int accept_invalid_cert
:1;/* ignore result of server's cert. verify */
484 typedef int (*cmd_callback
) (struct session
* sess
, char *tbuf
, char *word
[],
490 cmd_callback callback
;
493 gint16 handle_quotes
;
499 struct server
*server
;
504 /* not just for popups, but used for usercommands, ctcp replies,
505 userlist buttons etc */
513 /* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */
514 #define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n)))
516 #define xchat_filename_from_utf8 g_locale_from_utf8
517 #define xchat_filename_to_utf8 g_locale_to_utf8