aboutsummaryrefslogtreecommitdiffstats
path: root/irc.h
blob: eb70ad1cb69032ce99c4476b443468b084c0848e (plain)
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
  /********************************************************************\
  * BitlBee -- An IRC to other IM-networks gateway                     *
  *                                                                    *
  * Copyright 2002-2004 Wilmer van der Gaast and others                *
  \********************************************************************/

/* The big hairy IRCd part of the project                               */

/*
  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 with
  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef _IRC_H
#define _IRC_H

#define IRC_MAX_LINE 512
#define IRC_MAX_ARGS 8

#define IRC_LOGIN_TIMEOUT 60
#define IRC_PING_STRING "PinglBee"

#define UMODES "abisw"
#define UMODES_PRIV "Ro"
#define CMODES "nt"
#define CMODE "t"
#define UMODE "s"

typedef enum
{
	USTATUS_OFFLINE = 0,
	USTATUS_AUTHORIZED = 1,
	USTATUS_LOGGED_IN = 2,
	USTATUS_IDENTIFIED = 4,
	USTATUS_SHUTDOWN = 8
} irc_status_t;

typedef struct channel
{
	char *name;
} channel_t;

typedef struct irc
{
	int fd;
	irc_status_t status;
	double last_pong;
	int pinging;
	char *sendbuffer;
	char *readbuffer;

	int sentbytes;
	time_t oldtime;

	char *nick;
	char *user;
	char *host;
	char *realname;
	char *password;

	char umode[8];
	
	char *myhost;
	char *mynick;

	char *channel;
	int c_id;

	char is_private;		/* Not too nice... */
	char *last_target;
	
	struct query *queries;
	struct account *accounts;
	
	struct __USER *users;
	GHashTable *userhash;
	GHashTable *watches;
	struct __NICK *nicks;
	struct set *set;

	gint r_watch_source_id;
	gint w_watch_source_id;
	gint ping_source_id;
} irc_t;

#include "user.h"
// #include "nick.h"

extern GSList *irc_connection_list;

irc_t *irc_new( int fd );
void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 );
void irc_free( irc_t *irc );

void irc_exec( irc_t *irc, char **cmd );
void irc_process( irc_t *irc );
char **irc_parse_line( char *line );
char *irc_build_line( char **cmd );

void irc_vawrite( irc_t *irc, char *format, va_list params );
void irc_write( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
void irc_reply( irc_t *irc, int code, char *format, ... ) G_GNUC_PRINTF( 3, 4 );
G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
char **irc_tokenize( char *buffer );

void irc_login( irc_t *irc );
int irc_check_login( irc_t *irc );
void irc_motd( irc_t *irc );
void irc_names( irc_t *irc, char *channel );
void irc_topic( irc_t *irc, char *channel );
void irc_umode_set( irc_t *irc, char *s, int allow_priv );
void irc_who( irc_t *irc, char *channel );
void irc_spawn( irc_t *irc, user_t *u );
void irc_join( irc_t *irc, user_t *u, char *channel );
void irc_part( irc_t *irc, user_t *u, char *channel );
void irc_kick( irc_t *irc, user_t *u, char *channel, user_t *kicker );
void irc_kill( irc_t *irc, user_t *u );
void irc_invite( irc_t *irc, char *nick, char *channel );
void irc_whois( irc_t *irc, char *nick );
void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */

int irc_send( irc_t *irc, char *nick, char *s, int flags );
int irc_privmsg( irc_t *irc, user_t *u, char *type, char *to, char *prefix, char *msg );
int irc_msgfrom( irc_t *irc, char *nick, char *msg );
int irc_noticefrom( irc_t *irc, char *nick, char *msg );

void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags );
struct groupchat *irc_chat_by_channel( irc_t *irc, char *channel );

#endif
gt; <ircline nick="tux"> you: a bit chilly!</ircline> </ircexample> <para> If you'd rather chat with them in a separate window use the <emphasis>/msg</emphasis> or <emphasis>/query</emphasis> command, just like you would for a private message in IRC. If you want to have messages automatically come up in private messages rather than in the &amp;bitlbee channel, use the <emphasis>set private</emphasis> command: <emphasis>set private true</emphasis> (<emphasis>set private false</emphasis> to change back). </para> <para> You know the basics. If you want to get to know more about BitlBee, please type <emphasis>help quickstart6</emphasis>. </para> </sect1> <sect1 id="quickstart6"> <title>Further Resources</title> <para> <emphasis>So you want more than just chatting? Or maybe you're just looking for a feature?</emphasis> </para> <para> You can type <emphasis>help set</emphasis> to learn more about the possible BitlBee user settings. Among these user settings you will find options for common issues, such as changing the charset, HTML stripping and automatic connecting (simply type <emphasis>set</emphasis> to see current user settings). </para> <para> For more subjects (like groupchats and away states), please type <emphasis>help index</emphasis>. </para> <para> If you're still looking for something, please visit us in #bitlbee on the OFTC network (you can connect via irc.bitlbee.org), or mail us your problem/suggestion. Good luck and enjoy the Bee! </para> </sect1> </chapter>