/[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.61 - (hide annotations) (download) (as text)
Mon Feb 10 00:09:08 2003 UTC (16 years, 8 months ago) by wcc
Branch: MAIN
Changes since 1.60: +11 -8 lines
File MIME type: text/x-chdr
* Synch 1.6: transfer-cleanups, filesys-move, delbancrash, plsbot_cosmetic,
             stricthostfix, opreverselogic, dontdelfile

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23