[b7d3cc34] | 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 big hairy IRCd part of the project */ |
---|
| 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 FLOOD_SEND |
---|
| 36 | * Not yet enabled by default due to some problems. |
---|
| 37 | */ |
---|
| 38 | #define FLOOD_SEND_INTERVAL 30 |
---|
| 39 | #define FLOOD_SEND_BYTES (1024*10) |
---|
| 40 | #define FLOOD_SEND_MAXBUFFER (1024*20) |
---|
| 41 | |
---|
| 42 | #define UMODES "ais" |
---|
| 43 | #define CMODES "nt" |
---|
| 44 | #define CMODE "t" |
---|
| 45 | #define UMODE "s" |
---|
| 46 | |
---|
| 47 | typedef enum |
---|
| 48 | { |
---|
| 49 | USTATUS_OFFLINE, |
---|
| 50 | USTATUS_AUTHORIZED, |
---|
| 51 | USTATUS_LOGGED_IN, |
---|
| 52 | USTATUS_IDENTIFIED |
---|
| 53 | } irc_status_t; |
---|
| 54 | |
---|
| 55 | typedef struct channel |
---|
| 56 | { |
---|
| 57 | char *name; |
---|
| 58 | } channel_t; |
---|
| 59 | |
---|
| 60 | typedef struct irc |
---|
| 61 | { |
---|
| 62 | int fd; |
---|
| 63 | irc_status_t status; |
---|
| 64 | double last_pong; |
---|
| 65 | int pinging; |
---|
| 66 | char *sendbuffer; |
---|
| 67 | char *readbuffer; |
---|
| 68 | int quit; |
---|
| 69 | |
---|
| 70 | int sentbytes; |
---|
| 71 | time_t oldtime; |
---|
| 72 | |
---|
| 73 | char *nick; |
---|
| 74 | char *user; |
---|
| 75 | char *host; |
---|
| 76 | char *realname; |
---|
| 77 | char *password; |
---|
| 78 | |
---|
| 79 | char umode[8]; |
---|
| 80 | |
---|
| 81 | char *myhost; |
---|
| 82 | char *mynick; |
---|
| 83 | |
---|
| 84 | char *channel; |
---|
| 85 | int c_id; |
---|
| 86 | |
---|
| 87 | char is_private; /* Not too nice... */ |
---|
| 88 | char *last_target; |
---|
| 89 | |
---|
| 90 | struct query *queries; |
---|
| 91 | struct account *accounts; |
---|
| 92 | |
---|
| 93 | struct __USER *users; |
---|
| 94 | GHashTable *userhash; |
---|
| 95 | GHashTable *watches; |
---|
| 96 | struct __NICK *nicks; |
---|
| 97 | struct help *help; |
---|
| 98 | struct set *set; |
---|
| 99 | |
---|
| 100 | GIOChannel *io_channel; |
---|
| 101 | gint r_watch_source_id; |
---|
| 102 | gint w_watch_source_id; |
---|
| 103 | gint ping_source_id; |
---|
| 104 | } irc_t; |
---|
| 105 | |
---|
| 106 | #include "user.h" |
---|
| 107 | #include "nick.h" |
---|
| 108 | |
---|
| 109 | extern GSList *irc_connection_list; |
---|
| 110 | |
---|
| 111 | irc_t *irc_new( int fd ); |
---|
| 112 | void irc_free( irc_t *irc ); |
---|
| 113 | |
---|
| 114 | int irc_exec( irc_t *irc, char **cmd ); |
---|
| 115 | int irc_process( irc_t *irc ); |
---|
| 116 | int irc_process_line( irc_t *irc, char *line ); |
---|
| 117 | |
---|
| 118 | void irc_vawrite( irc_t *irc, char *format, va_list params ); |
---|
| 119 | void irc_write( irc_t *irc, char *format, ... ); |
---|
[22d41a2] | 120 | void irc_write_all( int now, char *format, ... ); |
---|
[b7d3cc34] | 121 | void irc_reply( irc_t *irc, int code, char *format, ... ); |
---|
| 122 | G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ); |
---|
| 123 | char **irc_tokenize( char *buffer ); |
---|
| 124 | |
---|
| 125 | void irc_login( irc_t *irc ); |
---|
| 126 | void irc_motd( irc_t *irc ); |
---|
| 127 | void irc_names( irc_t *irc, char *channel ); |
---|
| 128 | void irc_topic( irc_t *irc, char *channel ); |
---|
| 129 | void irc_umode_set( irc_t *irc, char *who, char *s ); |
---|
| 130 | void irc_who( irc_t *irc, char *channel ); |
---|
| 131 | void irc_spawn( irc_t *irc, user_t *u ); |
---|
| 132 | void irc_join( irc_t *irc, user_t *u, char *channel ); |
---|
| 133 | void irc_part( irc_t *irc, user_t *u, char *channel ); |
---|
| 134 | void irc_kick( irc_t *irc, user_t *u, char *channel, user_t *kicker ); |
---|
| 135 | void irc_kill( irc_t *irc, user_t *u ); |
---|
| 136 | void irc_invite( irc_t *irc, char *nick, char *channel ); |
---|
| 137 | void irc_whois( irc_t *irc, char *nick ); |
---|
| 138 | int irc_away( irc_t *irc, char *away ); |
---|
[7cad7b4] | 139 | void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */ |
---|
[b7d3cc34] | 140 | |
---|
| 141 | int irc_send( irc_t *irc, char *nick, char *s, int flags ); |
---|
| 142 | int irc_privmsg( irc_t *irc, user_t *u, char *type, char *to, char *prefix, char *msg ); |
---|
| 143 | int irc_msgfrom( irc_t *irc, char *nick, char *msg ); |
---|
| 144 | int irc_noticefrom( irc_t *irc, char *nick, char *msg ); |
---|
| 145 | |
---|
| 146 | int buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags ); |
---|
| 147 | |
---|
| 148 | #endif |
---|