/[cvs]/eggdrop1.9/src/dccutil.c
ViewVC logotype

Annotation of /eggdrop1.9/src/dccutil.c

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.55 - (hide annotations) (download) (as text)
Fri Sep 20 21:41:49 2002 UTC (17 years ago) by stdarg
Branch: MAIN
Changes since 1.54: +102 -18 lines
File MIME type: text/x-chdr
* Mo-Ize removed the botnet code, thanks

1 guppy 1.31 /*
2 tothwolf 1.51 * dccutil.c --
3 guppy 1.31 *
4 tothwolf 1.51 * lots of little functions to send formatted text to
5     * varying types of connections
6     * '.who', '.whom', and '.dccstat' code
7     * memory management for dcc structures
8     * timeout checking for dcc connections
9 segfault 1.1 */
10 guppy 1.31 /*
11     * Copyright (C) 1997 Robey Pointer
12 wcc 1.45 * Copyright (C) 1999, 2000, 2001, 2002 Eggheads Development Team
13 guppy 1.31 *
14 fabian 1.10 * This program is free software; you can redistribute it and/or
15     * modify it under the terms of the GNU General Public License
16     * as published by the Free Software Foundation; either version 2
17     * of the License, or (at your option) any later version.
18 guppy 1.31 *
19 fabian 1.10 * This program is distributed in the hope that it will be useful,
20     * but WITHOUT ANY WARRANTY; without even the implied warranty of
21     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22     * GNU General Public License for more details.
23 guppy 1.31 *
24 fabian 1.10 * You should have received a copy of the GNU General Public License
25     * along with this program; if not, write to the Free Software
26     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 segfault 1.1 */
28 tothwolf 1.51
29     #ifndef lint
30 stdarg 1.55 static const char rcsid[] = "$Id: dccutil.c,v 1.54 2002/05/26 08:34:13 stdarg Exp $";
31 tothwolf 1.51 #endif
32 segfault 1.1
33 fabian 1.17 #include <sys/stat.h>
34 segfault 1.1 #include "main.h"
35     #include <errno.h>
36     #include "chan.h"
37     #include "modules.h"
38 ite 1.43 #include "logfile.h"
39     #include "misc.h"
40 wingman 1.50 #include "cmdt.h" /* cmd_t */
41     #include "net.h" /* tputs, killsock */
42 stdarg 1.54 #include "core_binds.h" /* check_bind_chon, check_bind_chjn,
43     check_bind_chof, check_bind_away */
44 wingman 1.50 #include "dccutil.h" /* prototypes */
45 stdarg 1.55 #include "users.h" /* get_user_by_handle */
46 segfault 1.1
47 fabian 1.17 extern struct dcc_t *dcc;
48 stdarg 1.55 extern struct userrec *userlist;
49 fabian 1.17 extern int dcc_total, max_dcc, dcc_flood_thr, backgrd, MAXSOCKS;
50 stdarg 1.55 extern char spaces[], version[];
51 fabian 1.17 extern time_t now;
52     extern sock_list *socklist;
53 wingman 1.50
54     #ifndef MAKING_MODS
55     extern struct dcc_table DCC_CHAT, DCC_LOST;
56     #endif /* MAKING_MODS */
57 fabian 1.17
58 stdarg 1.55 char botnetnick[HANDLEN + 1] = "";
59 fabian 1.17 char motdfile[121] = "text/motd"; /* File where the motd is stored */
60     int connect_timeout = 15; /* How long to wait before a telnet
61     connection times out */
62 segfault 1.1
63 guppy 1.25 int reserved_port_min = 0;
64     int reserved_port_max = 0;
65 segfault 1.1
66 stdarg 1.48 void init_dcc_max(int newmax)
67 segfault 1.1 {
68     int osock = MAXSOCKS;
69    
70 stdarg 1.48 if (newmax < 1) newmax = 1;
71     dcc = realloc(dcc, sizeof(struct dcc_t) * newmax);
72     if (newmax > max_dcc) memset(dcc+max_dcc, 0, (newmax-max_dcc) * sizeof(*dcc));
73    
74     MAXSOCKS = newmax + 10;
75     socklist = (sock_list *)realloc(socklist, sizeof(sock_list) * MAXSOCKS);
76     if (newmax > max_dcc) memset(socklist+max_dcc+10, 0, (newmax-max_dcc) * sizeof(*socklist));
77    
78 segfault 1.1 for (; osock < MAXSOCKS; osock++)
79     socklist[osock].flags = SOCK_UNUSED;
80 stdarg 1.48
81     max_dcc = newmax;
82 segfault 1.1 }
83    
84    
85 fabian 1.17 /* Replace \n with \r\n */
86 segfault 1.1 char *add_cr(char *buf)
87     {
88     static char WBUF[1024];
89     char *p, *q;
90    
91     for (p = buf, q = WBUF; *p; p++, q++) {
92     if (*p == '\n')
93     *q++ = '\r';
94     *q = *p;
95     }
96     *q = *p;
97     return WBUF;
98     }
99    
100     extern void (*qserver) (int, char *, int);
101 fabian 1.7
102 fabian 1.5 void dprintf EGG_VARARGS_DEF(int, arg1)
103 segfault 1.1 {
104 guppy 1.28 static char buf[1024];
105 segfault 1.1 char *format;
106     int idx, len;
107 fabian 1.17 va_list va;
108 segfault 1.1
109 fabian 1.5 idx = EGG_VARARGS_START(int, arg1, va);
110 segfault 1.1 format = va_arg(va, char *);
111 stdarg 1.52 len = vsnprintf(buf, 1023, format, va);
112 segfault 1.1 va_end(va);
113 stdarg 1.52 if (len < 0 || len >= sizeof(buf)) len = sizeof(buf)-1;
114     buf[len] = 0;
115 guppy 1.28
116 segfault 1.1 if (idx < 0) {
117 guppy 1.28 tputs(-idx, buf, len);
118 segfault 1.1 } else if (idx > 0x7FF0) {
119     switch (idx) {
120     case DP_LOG:
121 guppy 1.28 putlog(LOG_MISC, "*", "%s", buf);
122 segfault 1.1 break;
123     case DP_STDOUT:
124 guppy 1.28 tputs(STDOUT, buf, len);
125 segfault 1.1 break;
126     case DP_STDERR:
127 guppy 1.28 tputs(STDERR, buf, len);
128 segfault 1.1 break;
129     case DP_SERVER:
130     case DP_HELP:
131     case DP_MODE:
132 fabian 1.8 case DP_MODE_NEXT:
133     case DP_SERVER_NEXT:
134     case DP_HELP_NEXT:
135 guppy 1.28 qserver(idx, buf, len);
136 segfault 1.1 break;
137     }
138     return;
139     } else {
140 fabian 1.17 if (len > 500) { /* Truncate to fit */
141 guppy 1.28 buf[500] = 0;
142     strcat(buf, "\n");
143 segfault 1.1 len = 501;
144     }
145     if (dcc[idx].type && ((long) (dcc[idx].type->output) == 1)) {
146 guppy 1.28 char *p = add_cr(buf);
147 segfault 1.1
148     tputs(dcc[idx].sock, p, strlen(p));
149     } else if (dcc[idx].type && dcc[idx].type->output) {
150 guppy 1.28 dcc[idx].type->output(idx, buf, dcc[idx].u.other);
151 segfault 1.1 } else
152 guppy 1.28 tputs(dcc[idx].sock, buf, len);
153 segfault 1.1 }
154     }
155    
156 fabian 1.5 void chatout EGG_VARARGS_DEF(char *, arg1)
157 segfault 1.1 {
158 guppy 1.28 int i, len;
159 segfault 1.1 char *format;
160     char s[601];
161 fabian 1.17 va_list va;
162 segfault 1.1
163 fabian 1.5 format = EGG_VARARGS_START(char *, arg1, va);
164 tothwolf 1.39 vsnprintf(s, 511, format, va);
165 guppy 1.28 va_end(va);
166     len = strlen(s);
167     if (len > 511)
168     len = 511;
169 guppy 1.31 s[len + 1] = 0;
170 guppy 1.28
171 segfault 1.1 for (i = 0; i < dcc_total; i++)
172     if (dcc[i].type == &DCC_CHAT)
173     if (dcc[i].u.chat->channel >= 0)
174 guppy 1.28 dprintf(i, "%s", s);
175 guppy 1.31
176 segfault 1.1 }
177    
178 fabian 1.17 /* Print to all on this channel but one.
179     */
180 fabian 1.5 void chanout_but EGG_VARARGS_DEF(int, arg1)
181 segfault 1.1 {
182 guppy 1.28 int i, x, chan, len;
183 segfault 1.1 char *format;
184     char s[601];
185 fabian 1.17 va_list va;
186 segfault 1.1
187 fabian 1.5 x = EGG_VARARGS_START(int, arg1, va);
188 segfault 1.1 chan = va_arg(va, int);
189     format = va_arg(va, char *);
190 tothwolf 1.39 vsnprintf(s, 511, format, va);
191 guppy 1.28 va_end(va);
192     len = strlen(s);
193     if (len > 511)
194     len = 511;
195 guppy 1.31 s[len + 1] = 0;
196    
197 segfault 1.1 for (i = 0; i < dcc_total; i++)
198     if ((dcc[i].type == &DCC_CHAT) && (i != x))
199     if (dcc[i].u.chat->channel == chan)
200 guppy 1.28 dprintf(i, "%s", s);
201 guppy 1.31
202 segfault 1.1 }
203    
204     void dcc_chatter(int idx)
205     {
206     int i, j;
207 fabian 1.17 struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
208 segfault 1.1
209     get_user_flagrec(dcc[idx].user, &fr, NULL);
210     show_motd(idx);
211     i = dcc[idx].u.chat->channel;
212     dcc[idx].u.chat->channel = 234567;
213     j = dcc[idx].sock;
214     strcpy(dcc[idx].u.chat->con_chan, "***");
215 stdarg 1.54 check_bind_chon(dcc[idx].nick, idx);
216 fabian 1.17 /* Still there? */
217 segfault 1.1 if ((idx >= dcc_total) || (dcc[idx].sock != j))
218 fabian 1.17 return; /* Nope */
219     /* Tcl script may have taken control */
220 segfault 1.1 if (dcc[idx].type == &DCC_CHAT) {
221     if (!strcmp(dcc[idx].u.chat->con_chan, "***"))
222     strcpy(dcc[idx].u.chat->con_chan, "*");
223     if (dcc[idx].u.chat->channel == 234567) {
224 fabian 1.17 /* If the chat channel has already been altered it's *highly*
225 segfault 1.1 * probably join/part messages have been broadcast everywhere,
226 fabian 1.17 * so dont bother sending them
227     */
228 segfault 1.1 if (i == -2)
229     i = 0;
230     dcc[idx].u.chat->channel = i;
231 stdarg 1.54 check_bind_chjn(botnetnick, dcc[idx].nick, dcc[idx].u.chat->channel,
232 ite 1.44 geticon(dcc[idx].user), dcc[idx].sock, dcc[idx].host);
233 segfault 1.1 }
234 fabian 1.17 /* But *do* bother with sending it locally */
235 guppy 1.24 if (!dcc[idx].u.chat->channel) {
236 segfault 1.1 chanout_but(-1, 0, "*** %s joined the party line.\n", dcc[idx].nick);
237     } else if (dcc[idx].u.chat->channel > 0) {
238     chanout_but(-1, dcc[idx].u.chat->channel,
239     "*** %s joined the channel.\n", dcc[idx].nick);
240     }
241     }
242     }
243    
244 fabian 1.14 /* Mark an entry as lost and deconstruct it's contents. It will be securely
245     * removed from the dcc list in the main loop.
246     */
247 segfault 1.1 void lostdcc(int n)
248     {
249 guppy 1.46 /* Make sure it's a valid dcc index. */
250     if (n < 0 || n >= max_dcc) return;
251    
252 fabian 1.14 if (dcc[n].type && dcc[n].type->kill)
253     dcc[n].type->kill(n, dcc[n].u.other);
254     else if (dcc[n].u.other)
255 tothwolf 1.37 free(dcc[n].u.other);
256     memset(&dcc[n], 0, sizeof(struct dcc_t));
257 fabian 1.14
258     dcc[n].sock = (-1);
259 fabian 1.11 dcc[n].type = &DCC_LOST;
260     }
261    
262     /* Remove entry from dcc list. Think twice before using this function,
263     * because it invalidates any variables that point to a specific dcc
264     * entry!
265 fabian 1.17 *
266     * Note: The entry will be deconstructed if it was not deconstructed
267     * already. This case should normally not occur.
268 fabian 1.11 */
269 ite 1.49 static void removedcc(int n)
270 fabian 1.11 {
271 segfault 1.1 if (dcc[n].type && dcc[n].type->kill)
272     dcc[n].type->kill(n, dcc[n].u.other);
273     else if (dcc[n].u.other)
274 tothwolf 1.37 free(dcc[n].u.other);
275 stdarg 1.40
276 ite 1.49 /* if we are removing the last entry let's decrease dcc_total */
277     if(n + 1 == dcc_total) dcc_total--;
278    
279 stdarg 1.40 memset(&dcc[n], 0, sizeof(struct dcc_t)); /* drummer */
280 fabian 1.12 }
281    
282     /* Clean up sockets that were just left for dead.
283     */
284     void dcc_remove_lost(void)
285     {
286     int i;
287    
288 ite 1.49
289     for (i = dcc_total; i > 0; --i) {
290 fabian 1.12 if (dcc[i].type == &DCC_LOST) {
291 fabian 1.14 dcc[i].type = NULL;
292 fabian 1.12 removedcc(i);
293     }
294     }
295 segfault 1.1 }
296    
297 fabian 1.17 /* Show list of current dcc's to a dcc-chatter
298     * positive value: idx given -- negative value: sock given
299     */
300 segfault 1.1 void tell_dcc(int zidx)
301     {
302     int i, j, k;
303     char other[160];
304    
305     spaces[HANDLEN - 9] = 0;
306 drummer 1.33 dprintf(zidx, "SOCK PORT NICK %s HOST TYPE\n"
307 segfault 1.1 ,spaces);
308 drummer 1.33 dprintf(zidx, "---- ----- ---------%s -------------------------- ----\n"
309 segfault 1.1 ,spaces);
310     spaces[HANDLEN - 9] = ' ';
311 fabian 1.17 /* Show server */
312 segfault 1.1 for (i = 0; i < dcc_total; i++) {
313 stdarg 1.40 if (!dcc[i].type) continue;
314 segfault 1.1 j = strlen(dcc[i].host);
315 drummer 1.33 if (j > 26)
316     j -= 26;
317 segfault 1.1 else
318     j = 0;
319     if (dcc[i].type && dcc[i].type->display)
320     dcc[i].type->display(i, other);
321     else {
322     sprintf(other, "?:%lX !! ERROR !!", (long) dcc[i].type);
323     break;
324     }
325     k = HANDLEN - strlen(dcc[i].nick);
326     spaces[k] = 0;
327 stdarg 1.40 dprintf(zidx, "%-4d %5d %s%s %-26s %s\n", i,
328 segfault 1.1 dcc[i].port, dcc[i].nick, spaces, dcc[i].host + j, other);
329     spaces[k] = ' ';
330     }
331     }
332    
333 fabian 1.17 /* Mark someone on dcc chat as no longer away
334     */
335 segfault 1.1 void not_away(int idx)
336     {
337     if (dcc[idx].u.chat->away == NULL) {
338     dprintf(idx, "You weren't away!\n");
339     return;
340     }
341     if (dcc[idx].u.chat->channel >= 0) {
342     chanout_but(-1, dcc[idx].u.chat->channel,
343     "*** %s is no longer away.\n", dcc[idx].nick);
344     }
345     dprintf(idx, "You're not away any more.\n");
346 tothwolf 1.37 free_null(dcc[idx].u.chat->away);
347 stdarg 1.54 check_bind_away(botnetnick, dcc[idx].sock, NULL);
348 segfault 1.1 }
349    
350     void set_away(int idx, char *s)
351     {
352     if (s == NULL) {
353     not_away(idx);
354     return;
355     }
356     if (!s[0]) {
357     not_away(idx);
358     return;
359     }
360     if (dcc[idx].u.chat->away != NULL)
361 tothwolf 1.37 free(dcc[idx].u.chat->away);
362 ite 1.42 dcc[idx].u.chat->away = strdup(s);
363 segfault 1.1 if (dcc[idx].u.chat->channel >= 0) {
364     chanout_but(-1, dcc[idx].u.chat->channel,
365     "*** %s is now away: %s\n", dcc[idx].nick, s);
366     }
367     dprintf(idx, "You are now away.\n");
368 stdarg 1.54 check_bind_away(botnetnick, dcc[idx].sock, s);
369 segfault 1.1 }
370    
371 fabian 1.17 /* Make a password, 10-15 random letters and digits
372     */
373 segfault 1.1 void makepass(char *s)
374     {
375 fabian 1.2 int i;
376 segfault 1.1
377     i = 10 + (random() % 6);
378 fabian 1.2 make_rand_str(s, i);
379 segfault 1.1 }
380    
381     void flush_lines(int idx, struct chat_info *ci)
382     {
383     int c = ci->line_count;
384     struct msgq *p = ci->buffer, *o;
385    
386     while (p && c < (ci->max_line)) {
387     ci->current_lines--;
388     tputs(dcc[idx].sock, p->msg, p->len);
389 tothwolf 1.37 free(p->msg);
390 segfault 1.1 o = p->next;
391 tothwolf 1.37 free(p);
392 segfault 1.1 p = o;
393     c++;
394     }
395     if (p != NULL) {
396     if (dcc[idx].status & STAT_TELNET)
397     tputs(dcc[idx].sock, "[More]: ", 8);
398     else
399     tputs(dcc[idx].sock, "[More]\n", 7);
400     }
401     ci->buffer = p;
402     ci->line_count = 0;
403     }
404    
405     int new_dcc(struct dcc_table *type, int xtra_size)
406     {
407     int i = dcc_total;
408    
409 stdarg 1.47 for (i = 0; i < dcc_total; i++)
410 stdarg 1.40 if (!dcc[i].type) break;
411 stdarg 1.47
412     if (i == max_dcc)
413     return -1;
414    
415     if (i == dcc_total)
416 stdarg 1.40 dcc_total++;
417     memset(&dcc[i], 0, sizeof(*dcc));
418 segfault 1.1
419     dcc[i].type = type;
420 tothwolf 1.37 if (xtra_size)
421 tothwolf 1.38 dcc[i].u.other = calloc(1, xtra_size);
422 segfault 1.1 return i;
423     }
424    
425 fabian 1.22 /* Changes the given dcc entry to another type.
426     */
427 fabian 1.3 void changeover_dcc(int i, struct dcc_table *type, int xtra_size)
428     {
429 fabian 1.22 /* Free old structure. */
430 fabian 1.3 if (dcc[i].type && dcc[i].type->kill)
431     dcc[i].type->kill(i, dcc[i].u.other);
432 tothwolf 1.37 else if (dcc[i].u.other)
433     free_null(dcc[i].u.other);
434 fabian 1.3
435     dcc[i].type = type;
436 tothwolf 1.37 if (xtra_size)
437 tothwolf 1.38 dcc[i].u.other = calloc(1, xtra_size);
438 fabian 1.3 }
439    
440 segfault 1.1 int detect_dcc_flood(time_t * timer, struct chat_info *chat, int idx)
441     {
442     time_t t;
443    
444 guppy 1.24 if (!dcc_flood_thr)
445 segfault 1.1 return 0;
446     t = now;
447     if (*timer != t) {
448     *timer = t;
449     chat->msgs_per_sec = 0;
450     } else {
451     chat->msgs_per_sec++;
452     if (chat->msgs_per_sec > dcc_flood_thr) {
453     /* FLOOD */
454 ite 1.34 dprintf(idx, "*** FLOOD: %s.\n", _("Goodbye"));
455 fabian 1.17 /* Evil assumption here that flags&DCT_CHAT implies chat type */
456 segfault 1.1 if ((dcc[idx].type->flags & DCT_CHAT) && chat &&
457     (chat->channel >= 0)) {
458     char x[1024];
459    
460 tothwolf 1.39 snprintf(x, sizeof x, _("%s has been forcibly removed for flooding.\n"), dcc[idx].nick);
461 segfault 1.1 chanout_but(idx, chat->channel, "*** %s", x);
462     }
463 stdarg 1.54 check_bind_chof(dcc[idx].nick, dcc[idx].sock);
464 segfault 1.1 if ((dcc[idx].sock != STDOUT) || backgrd) {
465     killsock(dcc[idx].sock);
466     lostdcc(idx);
467     } else {
468     dprintf(DP_STDOUT, "\n### SIMULATION RESET ###\n\n");
469     dcc_chatter(idx);
470     }
471     return 1; /* <- flood */
472     }
473     }
474     return 0;
475     }
476    
477 fabian 1.17 /* Handle someone being booted from dcc chat.
478     */
479 segfault 1.1 void do_boot(int idx, char *by, char *reason)
480     {
481     int files = (dcc[idx].type != &DCC_CHAT);
482    
483 ite 1.34 dprintf(idx, _("-=- poof -=-\n"));
484     dprintf(idx, _("Youve been booted from the %s by %s%s%s\n"), files ? "file section" : "bot",
485 fabian 1.23 by, reason[0] ? ": " : ".", reason);
486 fabian 1.17 /* If it's a partyliner (chatterer :) */
487     /* Horrible assumption that DCT_CHAT using structure uses same format
488 segfault 1.1 * as DCC_CHAT */
489     if ((dcc[idx].type->flags & DCT_CHAT) &&
490     (dcc[idx].u.chat->channel >= 0)) {
491     char x[1024];
492    
493 tothwolf 1.39 snprintf(x, sizeof x, _("%s booted %s from the party line%s%s\n"), by, dcc[idx].nick,
494 guppy 1.24 reason[0] ? ": " : "", reason);
495 segfault 1.1 chanout_but(idx, dcc[idx].u.chat->channel, "*** %s.\n", x);
496     }
497 stdarg 1.54 check_bind_chof(dcc[idx].nick, dcc[idx].sock);
498 segfault 1.1 if ((dcc[idx].sock != STDOUT) || backgrd) {
499     killsock(dcc[idx].sock);
500 fabian 1.11 lostdcc(idx);
501 fabian 1.17 /* Entry must remain in the table so it can be logged by the caller */
502 segfault 1.1 } else {
503     dprintf(DP_STDOUT, "\n### SIMULATION RESET\n\n");
504     dcc_chatter(idx);
505     }
506     return;
507 stdarg 1.55 }
508    
509     int add_note(char *to, char *from, char *msg, int idx, int echo)
510     {
511     int status, i, iaway, sock;
512     char ss[81], ssf[81];
513     struct userrec *u;
514    
515     if (strlen(msg) > 450)
516     msg[450] = 0; /* Notes have a limit */
517     /* note length + PRIVMSG header + nickname + date must be <512 */
518     /* Might be form "sock:nick" */
519     splitc(ssf, from, ':');
520     rmspace(ssf);
521     splitc(ss, to, ':');
522     rmspace(ss);
523     if (!ss[0])
524     sock = (-1);
525     else
526     sock = atoi(ss);
527     /* Don't process if there's a note binding for it */
528     if (idx != (-2)) { /* Notes from bots don't trigger it */
529     if (check_bind_note(from, to, msg)) {
530     if ((idx >= 0) && (echo))
531     dprintf(idx, "-> %s: %s\n", to, msg);
532     return NOTE_TCL;
533     }
534     }
535     if (!(u = get_user_by_handle(userlist, to))) {
536     if (idx >= 0)
537     dprintf(idx, _("I dont know anyone by that name.\n"));
538     return NOTE_ERROR;
539     }
540     if (is_bot(u)) {
541     if (idx >= 0)
542     dprintf(idx, _("Thats a bot. You cant leave notes for a bot.\n"));
543     return NOTE_ERROR;
544     }
545     if (match_noterej(u, from)) {
546     if (idx >= 0)
547     dprintf(idx, "%s %s\n", u->handle, "rejected your note.");
548     return NOTE_REJECT;
549     }
550     status = NOTE_STORED;
551     iaway = 0;
552     /* Online right now? */
553     for (i = 0; i < dcc_total; i++) {
554     if (dcc[i].type && (dcc[i].type->flags & DCT_GETNOTES) &&
555     ((sock == (-1)) || (sock == dcc[i].sock)) &&
556     (!strcasecmp(dcc[i].nick, to))) {
557     int aok = 1;
558    
559     if (dcc[i].type == &DCC_CHAT)
560     if ((dcc[i].u.chat->away != NULL) &&
561     (idx != (-2))) {
562     /* Only check away if it's not from a bot */
563     aok = 0;
564     if (idx >= 0)
565     dprintf(idx, "%s %s: %s\n", dcc[i].nick, _("is away"),
566     dcc[i].u.chat->away);
567     if (!iaway)
568     iaway = i;
569     status = NOTE_AWAY;
570     }
571     if (aok) {
572     char *p, *fr = from;
573     int l = 0;
574     char work[1024];
575    
576     while ((*msg == '<') || (*msg == '>')) {
577     p = newsplit(&msg);
578     if (*p == '<')
579     l += simple_sprintf(work + l, "via %s, ", p + 1);
580     else if (*from == '@')
581     fr = p + 1;
582     }
583     if (idx == -2 || (!strcasecmp(from, botnetnick)))
584     dprintf(i, "*** [%s] %s%s\n", fr, l ? work : "", msg);
585     else
586     dprintf(i, "%cNote [%s]: %s%s\n", 7, fr, l ? work : "", msg);
587     if ((idx >= 0) && (echo))
588     dprintf(idx, "-> %s: %s\n", to, msg);
589     return NOTE_OK;
590     }
591     }
592     }
593     if (idx == (-2))
594     return NOTE_OK; /* Error msg from a tandembot: don't store */
595     status = storenote(from, to, msg, idx, NULL, 0);
596     if (status < 0) status = NOTE_ERROR;
597     else if (status == NOTE_AWAY) {
598     /* User is away in all sessions -- just notify the user that a
599     * message arrived and was stored. (only oldest session is notified.)
600     */
601     dprintf(iaway, "*** %s.\n", _("Note arrived for you"));
602     }
603     return(status);
604 segfault 1.1 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23