plugins/irc/irc.h

Go to the documentation of this file.
00001 /*
00002  *  (C) Copyright 2004-2005 Michal 'GiM' Spadlinski <gim at skrzynka dot pl>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License Version 2 as
00006  *  published by the Free Software Foundation.
00007  *
00008  *  This program is distributed in the hope that it will be useful,
00009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *  GNU General Public License for more details.
00012  *
00013  *  You should have received a copy of the GNU General Public License
00014  *  along with this program; if not, write to the Free Software
00015  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00016  */
00017 
00018 #ifndef __EKG_PLUGINS_IRC_IRC_H
00019 #define __EKG_PLUGINS_IRC_IRC_H
00020 
00021 #define DOT(a,x,y,z,error) \
00022         print_info("__status", z, a, session_name(z), x, y->hostname, y->address, \
00023                         itoa(y->port < 0 ? \
00024                                 session_int_get(z, "port") < 0 ? DEFPORT : session_int_get(z, "port") : y->port), \
00025                         itoa(y->family), error ? strerror(error) : "")
00026 
00027 #include <ekg/dynstuff.h>
00028 #include <ekg/plugins.h>
00029 #include <ekg/protocol.h>       /* XXX, protocol_uid() */
00030 #include <ekg/sessions.h>
00031 #include <ekg/windows.h>
00032 
00033 /* irc_private->sopt */
00034 enum { USERMODES=0, CHANMODES, _005_PREFIX, _005_CHANTYPES,
00035         _005_CHANMODES, _005_MODES, _005_CHANLIMIT, _005_NICKLEN, _005_IDCHAN, SERVOPTS };
00036 
00037 /* irc_private_t->casemapping values */
00038 enum { IRC_CASEMAPPING_ASCII, IRC_CASEMAPPING_RFC1459, IRC_CASEMAPPING_RFC1459_STRICT, IRC_CASEMAPPING_COUNT };
00039 
00040 typedef struct _irc_private_t {
00041         int fd;                         /* connection's fd */
00042         int autoreconnecting;           /* are we in reconnecting mode now? */
00043         int resolving;                  /* count of resolver threads. */
00044         list_t bindlist, bindtmplist;
00045         list_t connlist, conntmplist;
00046 
00047         watch_t *recv_watch;
00048         watch_t *send_watch;
00049 
00050         char *nick;                     /* guess again ? ;> */
00051         char *host_ident;               /* ident+host */
00052 
00053         list_t people;                  /* list of people_t */
00054         list_t channels;                /* list of people_chan_t */
00055         list_t hilights;
00056 
00057         char *sopt[SERVOPTS];           /* just a few options from
00058                                          * www.irc.org/tech_docs/005.html
00059                                          * server's response */
00060         int casemapping;
00061 
00062         list_t awaylog;
00063 
00064         list_t auto_guess_encoding;
00065         list_t out_recodes;
00066         list_t recoded_channels;
00067 
00068         void *conv_in;
00069         void *conv_out;
00070 } irc_private_t;
00071 
00072 /* data for private->auto_guess_encoding */
00073 typedef struct {
00074         void *conv_in;
00075         void *conv_out;
00076 } conv_in_out_t;
00077 
00078 /* data for private->out_recodes */
00079 typedef struct {
00080         char *name;     /* encoding name */
00081         void *conv_in;
00082         void *conv_out;
00083 } out_recodes_t;
00084 
00085 /* data for private->recoded_channels */
00086 typedef struct {
00087         char *name;     /* channel or nick */
00088         out_recodes_t *recode;
00089 } recoded_channels_t;
00090 
00091 typedef struct _irc_awaylog_t {
00092         char *channame; /* channel name, (null if priv) */
00093         char *uid;      /* nickname who wrote to us     */
00094         char *msg;      /* msg                          */
00095         time_t t;       /* time_t when we recv message  */
00096 } irc_awaylog_t;
00097 
00098 #define SOP(x) (j->sopt[x])
00099 
00100 /* data for private->people */
00101 typedef struct {
00102         char *nick;
00103         char *realname;
00104         char *host, *ident;
00105         list_t channels;
00106 } people_t;
00107 
00108 /* data for private->channels */
00109 typedef struct {
00110         char            *name;
00111         int             syncmode;
00112         struct timeval  syncstart;
00113         int             mode;
00114         char            *topic, *topicby, *mode_str;
00115         window_t        *window;
00116         list_t          onchan;
00117         char            *nickpad_str;
00118         int             nickpad_len, nickpad_pos;
00119         int             longest_nick;
00120         list_t          banlist;
00121         /* needed ?
00122         list_t exclist;
00123         list_t invlist; */
00124         list_t          acclist;
00125 } channel_t;
00126 
00127 /* data for private->people->channels */
00128 typedef struct {
00129         int mode; /* bitfield  */
00130         char sign[2];
00131         channel_t *chanp;
00132 } people_chan_t;
00133 
00134 /* structure needed by resolver */
00135 typedef struct {
00136         session_t *session;
00137         char *hostname;
00138         char *address;
00139         int port;
00140         int family;
00141 } connector_t;
00142 
00143 typedef struct {
00144         char *session;
00145         list_t *plist;
00146         int isbind;
00147 } irc_resolver_t;
00148 
00149 #define irc_private(s) ((irc_private_t*) session_private_get(s))
00150 
00151 /* DO NOT TOUCH THIS! */
00152 #define IRC4 "irc:"
00153 #define irc_uid(target) protocol_uid("irc", target)
00154 
00155 extern plugin_t irc_plugin;
00156 
00157 void irc_handle_disconnect(session_t *s, const char *reason, int type);
00158 
00159 /* checks if name is in format irc:something
00160  * checkcon is one of:
00161  *   name is               channel   |  nick 
00162  *   IRC_GC_CHAN        -  channame  |  NULL
00163  *   IRC_GC_NOT_CHAN    -  NULL      | nickname
00164  *   IRC_GC_ANY         -  name if it's in proper format [irc:something]
00165  */
00166 enum { IRC_GC_CHAN=0, IRC_GC_NOT_CHAN, IRC_GC_ANY };
00167 
00168 #define irc_write(s, args...) watch_write((s && s->priv) ? irc_private(s)->send_watch : NULL, args);
00169 
00170 int irc_parse_line(session_t *s, char *buf, int fd);    /* misc.c */
00171 
00172 extern int irc_config_experimental_chan_name_clean;
00173 
00174 char *nickpad_string_create(channel_t *chan);
00175 char *nickpad_string_apply(channel_t *chan, char *str);
00176 char *nickpad_string_restore(channel_t *chan);
00177 
00178 #endif /* __EKG_PLUGINS_IRC_IRC_H */
00179 
00180 /*
00181  * Local Variables:
00182  * mode: c
00183  * c-file-style: "k&r"
00184  * c-basic-offset: 8
00185  * indent-tabs-mode: t
00186  * End:
00187  */

Generated on Mon Jan 5 22:30:49 2009 for ekg2 by  doxygen 1.5.1