ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
irc.h
Idź do dokumentacji tego pliku.
1 /*
2  * (C) Copyright 2004-2005 Michal 'GiM' Spadlinski <gim at skrzynka dot pl>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License Version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  */
17 
18 #ifndef __EKG_PLUGINS_IRC_IRC_H
19 #define __EKG_PLUGINS_IRC_IRC_H
20 
21 #define DOT(a,x,y,z,error) \
22  print_info("__status", z, a, session_name(z), x, y->hostname, y->address, \
23  itoa(y->port < 0 ? \
24  session_int_get(z, "port") < 0 ? DEFPORT : session_int_get(z, "port") : y->port), \
25  itoa(y->family), error ? strerror(error) : "")
26 
27 #include <ekg/dynstuff.h>
28 #include <ekg/plugins.h>
29 #include <ekg/protocol.h> /* XXX, protocol_uid() */
30 #include <ekg/sessions.h>
31 #include <ekg/windows.h>
32 
33 #include "irc-ssl.h"
34 
35 /* irc_private->sopt */
38 
39 /* irc_private_t->casemapping values */
41 
42 typedef struct _irc_private_t {
43  int fd; /* connection's fd */
44  int autoreconnecting; /* are we in reconnecting mode now? */
45  int resolving; /* count of resolver threads. */
48 
51 
52  char *nick; /* guess again ? ;> */
53  char *host_ident; /* ident+host */
54 
55 #ifdef IRC_HAVE_SSL
56  unsigned char using_ssl : 2;
57  SSL_SESSION ssl_session;
58  string_t ssl_buf;
59 #endif
60 
61  list_t people; /* list of people_t */
62  list_t channels; /* list of people_chan_t */
64 
65  char *sopt[SERVOPTS]; /* just a few options from
66  * www.irc.org/tech_docs/005.html
67  * server's response */
69 
71 
75 
76  void *conv_in;
77  void *conv_out;
79 
80 /* data for private->auto_guess_encoding */
81 typedef struct {
82  void *conv_in;
83  void *conv_out;
85 
86 /* data for private->out_recodes */
87 typedef struct {
88  char *name; /* encoding name */
89  void *conv_in;
90  void *conv_out;
92 
93 /* data for private->recoded_channels */
94 typedef struct {
95  char *name; /* channel or nick */
98 
99 typedef struct _irc_awaylog_t {
100  char *channame; /* channel name, (null if priv) */
101  char *uid; /* nickname who wrote to us */
102  char *msg; /* msg */
103  time_t t; /* time_t when we recv message */
104 } irc_awaylog_t;
105 
106 #define SOP(x) (j->sopt[x])
107 
108 /* data for private->people */
109 typedef struct {
110  char *nick;
111  char *realname;
112  char *host, *ident;
114 } people_t;
115 
116 /* data for private->channels */
117 typedef struct {
118  char *name;
119  int syncmode;
120  struct timeval syncstart;
121  int mode;
122  char *topic, *topicby, *mode_str;
125  char *nickpad_str;
126  int nickpad_len, nickpad_pos;
129  /* needed ?
130  list_t exclist;
131  list_t invlist; */
133 } channel_t;
134 
135 /* data for private->people->channels */
136 typedef struct {
137  int mode; /* bitfield */
138  char sign[2];
140 } people_chan_t;
141 
142 /* structure needed by resolver */
143 typedef struct {
145  char *hostname;
146  char *address;
147  int port;
148  int family;
149 } connector_t;
150 
151 typedef struct {
152  char *session;
154  int isbind;
156 
157 #define irc_private(s) ((irc_private_t*) session_private_get(s))
158 
159 /* DO NOT TOUCH THIS! */
160 #define IRC4 "irc:"
161 #define irc_uid(target) protocol_uid("irc", target)
162 
163 extern plugin_t irc_plugin;
164 
165 void irc_handle_disconnect(session_t *s, const char *reason, int type);
166 
167 /* checks if name is in format irc:something
168  * checkcon is one of:
169  * name is channel | nick
170  * IRC_GC_CHAN - channame | NULL
171  * IRC_GC_NOT_CHAN - NULL | nickname
172  * IRC_GC_ANY - name if it's in proper format [irc:something]
173  */
175 
176 #define irc_write(s, args...) watch_write((s && s->priv) ? irc_private(s)->send_watch : NULL, args);
177 
178 int irc_parse_line(session_t *s, char *buf, int fd); /* misc.c */
179 
181 
183 char *nickpad_string_apply(channel_t *chan, const char *str);
185 
186 char *clean_channel_names(session_t *session, char *channels);
187 
188 #endif /* __EKG_PLUGINS_IRC_IRC_H */
189 
190 /*
191  * Local Variables:
192  * mode: c
193  * c-file-style: "k&r"
194  * c-basic-offset: 8
195  * indent-tabs-mode: t
196  * End:
197  */