source: irc.h @ b95932e

Last change on this file since b95932e was b95932e, checked in by Wilmer van der Gaast <wilmer@…>, at 2010-03-27T03:39:23Z

Added WHOIS command.

  • Property mode set to 100644
File size: 4.5 KB
Line 
1  /********************************************************************\
2  * BitlBee -- An IRC to other IM-networks gateway                     *
3  *                                                                    *
4  * Copyright 2002-2004 Wilmer van der Gaast and others                *
5  \********************************************************************/
6
7/* The IRC-based UI (for now the only one)                              */
8
9/*
10  This program is free software; you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 2 of the License, or
13  (at your option) any later version.
14
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License with
21  the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL;
22  if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23  Suite 330, Boston, MA  02111-1307  USA
24*/
25
26#ifndef _IRC_H
27#define _IRC_H
28
29#define IRC_MAX_LINE 512
30#define IRC_MAX_ARGS 8
31
32#define IRC_LOGIN_TIMEOUT 60
33#define IRC_PING_STRING "PinglBee"
34
35#define UMODES "abisw"
36#define UMODES_PRIV "Ro"
37#define CMODES "nt"
38#define CMODE "t"
39#define UMODE "s"
40#define CTYPES "&#"
41
42typedef enum
43{
44        USTATUS_OFFLINE = 0,
45        USTATUS_AUTHORIZED = 1,
46        USTATUS_LOGGED_IN = 2,
47        USTATUS_IDENTIFIED = 4,
48        USTATUS_SHUTDOWN = 8
49} irc_status_t;
50
51struct irc_user;
52
53typedef struct irc
54{
55        int fd;
56        irc_status_t status;
57        double last_pong;
58        int pinging;
59        char *sendbuffer;
60        char *readbuffer;
61        GIConv iconv, oconv;
62
63        struct irc_user *root;
64        struct irc_user *user;
65
66        char *password; /* HACK: Used to save the user's password, but before
67                           logging in, this may contain a password we should
68                           send to identify after USER/NICK are received. */
69
70        char umode[8];
71       
72        struct query *queries;
73        struct account *accounts;
74        GSList *file_transfers;
75       
76        GSList *users, *channels;
77        GHashTable *nick_user_hash;
78        GHashTable *watches;
79
80        gint r_watch_source_id;
81        gint w_watch_source_id;
82        gint ping_source_id;
83       
84        struct bee *b;
85} irc_t;
86
87typedef struct irc_user
88{
89        irc_t *irc;
90       
91        char *nick;
92        char *user;
93        char *host;
94        char *fullname;
95       
96        /* Nickname in lowercase for case sensitive searches */
97        char *key;
98       
99        char is_private;
100       
101        char *sendbuf;
102        int sendbuf_len;
103        guint sendbuf_timer;
104        int sendbuf_flags;
105       
106        //struct user *b;
107} irc_user_t;
108
109typedef enum
110{
111        IRC_CHANNEL_JOINED = 1,
112} irc_channel_flags_t;
113
114typedef struct irc_channel
115{
116        irc_t *irc;
117        int flags;
118        char *name;
119        char *topic;
120        char mode[8];
121        GSList *users;
122        struct set *set;
123} irc_channel_t;
124
125#include "user.h"
126
127/* irc.c */
128extern GSList *irc_connection_list;
129
130irc_t *irc_new( int fd );
131void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 );
132void irc_free( irc_t *irc );
133
134void irc_process( irc_t *irc );
135char **irc_parse_line( char *line );
136char *irc_build_line( char **cmd );
137
138void irc_write( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
139void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 );
140void irc_vawrite( irc_t *irc, char *format, va_list params );
141
142int irc_check_login( irc_t *irc );
143
144/* irc_channel.c */
145irc_channel_t *irc_channel_new( irc_t *irc, const char *name );
146irc_channel_t *irc_channel_by_name( irc_t *irc, const char *name );
147int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu );
148int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu );
149int irc_channel_set_topic( irc_channel_t *ic, const char *topic );
150
151/* irc_commands.c */
152void irc_exec( irc_t *irc, char **cmd );
153
154/* irc_send.c */
155void irc_send_num( irc_t *irc, int code, char *format, ... ) G_GNUC_PRINTF( 3, 4 );
156void irc_send_login( irc_t *irc );
157void irc_send_motd( irc_t *irc );
158void irc_usermsg( irc_t *irc, char *format, ... );
159void irc_send_join( irc_channel_t *ic, irc_user_t *iu );
160void irc_send_part( irc_channel_t *ic, irc_user_t *iu, const char *reason );
161void irc_send_names( irc_channel_t *ic );
162void irc_send_topic( irc_channel_t *ic );
163void irc_send_whois( irc_user_t *iu );
164
165/* irc_user.c */
166irc_user_t *irc_user_new( irc_t *irc, const char *nick );
167int irc_user_free( irc_t *irc, const char *nick );
168irc_user_t *irc_user_find( irc_t *irc, const char *nick );
169int irc_user_rename( irc_t *irc, const char *old, const char *new );
170gint irc_user_cmp( gconstpointer a_, gconstpointer b_ );
171
172#endif
Note: See TracBrowser for help on using the repository browser.