[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 | |
---|
[aefa533e] | 35 | #define UMODES "abisw" |
---|
[238f828] | 36 | #define UMODES_PRIV "Ro" |
---|
[b7d3cc34] | 37 | #define CMODES "nt" |
---|
| 38 | #define CMODE "t" |
---|
| 39 | #define UMODE "s" |
---|
[39f93f0] | 40 | #define CTYPES "&#" |
---|
[b7d3cc34] | 41 | |
---|
| 42 | typedef enum |
---|
| 43 | { |
---|
[bd9b00f] | 44 | USTATUS_OFFLINE = 0, |
---|
[79e826a] | 45 | USTATUS_AUTHORIZED = 1, |
---|
| 46 | USTATUS_LOGGED_IN = 2, |
---|
| 47 | USTATUS_IDENTIFIED = 4, |
---|
| 48 | USTATUS_SHUTDOWN = 8 |
---|
[b7d3cc34] | 49 | } irc_status_t; |
---|
| 50 | |
---|
| 51 | typedef struct irc |
---|
| 52 | { |
---|
| 53 | int fd; |
---|
| 54 | irc_status_t status; |
---|
| 55 | double last_pong; |
---|
| 56 | int pinging; |
---|
| 57 | char *sendbuffer; |
---|
| 58 | char *readbuffer; |
---|
[f9756bd] | 59 | GIConv iconv, oconv; |
---|
[b7d3cc34] | 60 | |
---|
| 61 | int sentbytes; |
---|
| 62 | time_t oldtime; |
---|
| 63 | |
---|
| 64 | char *nick; |
---|
| 65 | char *user; |
---|
| 66 | char *host; |
---|
| 67 | char *realname; |
---|
[a199d33] | 68 | char *password; /* HACK: Used to save the user's password, but before |
---|
| 69 | logging in, this may contain a password we should |
---|
| 70 | send to identify after USER/NICK are received. */ |
---|
[b7d3cc34] | 71 | |
---|
| 72 | char umode[8]; |
---|
| 73 | |
---|
| 74 | char *myhost; |
---|
| 75 | char *mynick; |
---|
| 76 | |
---|
| 77 | char *channel; |
---|
| 78 | int c_id; |
---|
| 79 | |
---|
| 80 | char is_private; /* Not too nice... */ |
---|
| 81 | char *last_target; |
---|
| 82 | |
---|
| 83 | struct query *queries; |
---|
| 84 | struct account *accounts; |
---|
[ad9feec] | 85 | struct chat *chatrooms; |
---|
[b7d3cc34] | 86 | |
---|
| 87 | struct __USER *users; |
---|
| 88 | GHashTable *userhash; |
---|
| 89 | GHashTable *watches; |
---|
| 90 | struct __NICK *nicks; |
---|
| 91 | struct set *set; |
---|
| 92 | |
---|
| 93 | gint r_watch_source_id; |
---|
| 94 | gint w_watch_source_id; |
---|
| 95 | gint ping_source_id; |
---|
| 96 | } irc_t; |
---|
| 97 | |
---|
| 98 | #include "user.h" |
---|
| 99 | |
---|
| 100 | extern GSList *irc_connection_list; |
---|
| 101 | |
---|
| 102 | irc_t *irc_new( int fd ); |
---|
[a9ca7dd] | 103 | void irc_abort( irc_t *irc, int immed, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); |
---|
[b7d3cc34] | 104 | void irc_free( irc_t *irc ); |
---|
| 105 | |
---|
[f73b969] | 106 | void irc_exec( irc_t *irc, char **cmd ); |
---|
| 107 | void irc_process( irc_t *irc ); |
---|
[0431ea1] | 108 | char **irc_parse_line( char *line ); |
---|
[74c119d] | 109 | char *irc_build_line( char **cmd ); |
---|
[b7d3cc34] | 110 | |
---|
| 111 | void irc_vawrite( irc_t *irc, char *format, va_list params ); |
---|
[a9ca7dd] | 112 | void irc_write( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); |
---|
| 113 | void irc_write_all( int now, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); |
---|
| 114 | void irc_reply( irc_t *irc, int code, char *format, ... ) G_GNUC_PRINTF( 3, 4 ); |
---|
| 115 | G_MODULE_EXPORT int irc_usermsg( irc_t *irc, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); |
---|
[b7d3cc34] | 116 | char **irc_tokenize( char *buffer ); |
---|
| 117 | |
---|
| 118 | void irc_login( irc_t *irc ); |
---|
[edf9657] | 119 | int irc_check_login( irc_t *irc ); |
---|
[b7d3cc34] | 120 | void irc_motd( irc_t *irc ); |
---|
| 121 | void irc_names( irc_t *irc, char *channel ); |
---|
| 122 | void irc_topic( irc_t *irc, char *channel ); |
---|
[238f828] | 123 | void irc_umode_set( irc_t *irc, char *s, int allow_priv ); |
---|
[b7d3cc34] | 124 | void irc_who( irc_t *irc, char *channel ); |
---|
| 125 | void irc_spawn( irc_t *irc, user_t *u ); |
---|
| 126 | void irc_join( irc_t *irc, user_t *u, char *channel ); |
---|
| 127 | void irc_part( irc_t *irc, user_t *u, char *channel ); |
---|
| 128 | void irc_kick( irc_t *irc, user_t *u, char *channel, user_t *kicker ); |
---|
| 129 | void irc_kill( irc_t *irc, user_t *u ); |
---|
| 130 | void irc_invite( irc_t *irc, char *nick, char *channel ); |
---|
| 131 | void irc_whois( irc_t *irc, char *nick ); |
---|
[7cad7b4] | 132 | void irc_setpass( irc_t *irc, const char *pass ); /* USE WITH CAUTION! */ |
---|
[b7d3cc34] | 133 | |
---|
| 134 | int irc_send( irc_t *irc, char *nick, char *s, int flags ); |
---|
| 135 | int irc_privmsg( irc_t *irc, user_t *u, char *type, char *to, char *prefix, char *msg ); |
---|
| 136 | int irc_msgfrom( irc_t *irc, char *nick, char *msg ); |
---|
| 137 | int irc_noticefrom( irc_t *irc, char *nick, char *msg ); |
---|
| 138 | |
---|
[f73b969] | 139 | void buddy_send_handler( irc_t *irc, user_t *u, char *msg, int flags ); |
---|
[0e7ab64] | 140 | struct groupchat *irc_chat_by_channel( irc_t *irc, char *channel ); |
---|
[b7d3cc34] | 141 | |
---|
| 142 | #endif |
---|