/[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.65 - (hide annotations) (download) (as text)
Wed Aug 6 18:01:00 2003 UTC (16 years, 2 months ago) by stdarg
Branch: MAIN
CVS Tags: HEAD
Changes since 1.64: +1 -1 lines
File MIME type: text/x-chdr
FILE REMOVED
*** empty log message ***

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 stdarg 1.65 static const char rcsid[] = "$Id: dccutil.c,v 1.64 2003/08/02 05:59:53 tothwolf 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 stdarg 1.62 extern int dcc_total, max_dcc, dcc_flood_thr, backgrd, MAXSOCKS;
49 wcc 1.61 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.58 }
253     }
254 segfault 1.1
255 fabian 1.14 /* Mark an entry as lost and deconstruct it's contents. It will be securely
256     * removed from the dcc list in the main loop.
257     */
258 segfault 1.1 void lostdcc(int n)
259     {
260 guppy 1.46 /* Make sure it's a valid dcc index. */
261     if (n < 0 || n >= max_dcc) return;
262    
263 fabian 1.14 if (dcc[n].type && dcc[n].type->kill)
264     dcc[n].type->kill(n, dcc[n].u.other);
265     else if (dcc[n].u.other)
266 tothwolf 1.37 free(dcc[n].u.other);
267     memset(&dcc[n], 0, sizeof(struct dcc_t));
268 fabian 1.14
269     dcc[n].sock = (-1);
270 fabian 1.11 dcc[n].type = &DCC_LOST;
271     }
272    
273     /* Remove entry from dcc list. Think twice before using this function,
274     * because it invalidates any variables that point to a specific dcc
275     * entry!
276 fabian 1.17 *
277     * Note: The entry will be deconstructed if it was not deconstructed
278     * already. This case should normally not occur.
279 fabian 1.11 */
280 ite 1.49 static void removedcc(int n)
281 fabian 1.11 {
282 segfault 1.1 if (dcc[n].type && dcc[n].type->kill)
283     dcc[n].type->kill(n, dcc[n].u.other);
284     else if (dcc[n].u.other)
285 tothwolf 1.37 free(dcc[n].u.other);
286 stdarg 1.40
287 ite 1.49 /* if we are removing the last entry let's decrease dcc_total */
288     if(n + 1 == dcc_total) dcc_total--;
289    
290 stdarg 1.40 memset(&dcc[n], 0, sizeof(struct dcc_t)); /* drummer */
291 fabian 1.12 }
292    
293     /* Clean up sockets that were just left for dead.
294     */
295     void dcc_remove_lost(void)
296     {
297     int i;
298    
299 ite 1.49
300     for (i = dcc_total; i > 0; --i) {
301 fabian 1.12 if (dcc[i].type == &DCC_LOST) {
302 fabian 1.14 dcc[i].type = NULL;
303 fabian 1.12 removedcc(i);
304     }
305     }
306 segfault 1.1 }
307    
308 fabian 1.17 /* Show list of current dcc's to a dcc-chatter
309     * positive value: idx given -- negative value: sock given
310     */
311 segfault 1.1 void tell_dcc(int zidx)
312     {
313     int i, j, k;
314     char other[160];
315    
316     spaces[HANDLEN - 9] = 0;
317 drummer 1.33 dprintf(zidx, "SOCK PORT NICK %s HOST TYPE\n"
318 segfault 1.1 ,spaces);
319 drummer 1.33 dprintf(zidx, "---- ----- ---------%s -------------------------- ----\n"
320 segfault 1.1 ,spaces);
321     spaces[HANDLEN - 9] = ' ';
322 fabian 1.17 /* Show server */
323 segfault 1.1 for (i = 0; i < dcc_total; i++) {
324 stdarg 1.40 if (!dcc[i].type) continue;
325 segfault 1.1 j = strlen(dcc[i].host);
326 drummer 1.33 if (j > 26)
327     j -= 26;
328 segfault 1.1 else
329     j = 0;
330     if (dcc[i].type && dcc[i].type->display)
331     dcc[i].type->display(i, other);
332     else {
333     sprintf(other, "?:%lX !! ERROR !!", (long) dcc[i].type);
334     break;
335     }
336     k = HANDLEN - strlen(dcc[i].nick);
337     spaces[k] = 0;
338 stdarg 1.40 dprintf(zidx, "%-4d %5d %s%s %-26s %s\n", i,
339 segfault 1.1 dcc[i].port, dcc[i].nick, spaces, dcc[i].host + j, other);
340     spaces[k] = ' ';
341     }
342     }
343    
344 fabian 1.17 /* Mark someone on dcc chat as no longer away
345     */
346 segfault 1.1 void not_away(int idx)
347     {
348     if (dcc[idx].u.chat->away == NULL) {
349     dprintf(idx, "You weren't away!\n");
350     return;
351     }
352     if (dcc[idx].u.chat->channel >= 0) {
353     chanout_but(-1, dcc[idx].u.chat->channel,
354     "*** %s is no longer away.\n", dcc[idx].nick);
355     }
356     dprintf(idx, "You're not away any more.\n");
357 tothwolf 1.37 free_null(dcc[idx].u.chat->away);
358 segfault 1.1 }
359    
360     void set_away(int idx, char *s)
361     {
362     if (s == NULL) {
363     not_away(idx);
364     return;
365     }
366     if (!s[0]) {
367     not_away(idx);
368     return;
369     }
370     if (dcc[idx].u.chat->away != NULL)
371 tothwolf 1.37 free(dcc[idx].u.chat->away);
372 ite 1.42 dcc[idx].u.chat->away = strdup(s);
373 segfault 1.1 if (dcc[idx].u.chat->channel >= 0) {
374     chanout_but(-1, dcc[idx].u.chat->channel,
375     "*** %s is now away: %s\n", dcc[idx].nick, s);
376     }
377     dprintf(idx, "You are now away.\n");
378     }
379    
380 fabian 1.17 /* Make a password, 10-15 random letters and digits
381     */
382 segfault 1.1 void makepass(char *s)
383     {
384 fabian 1.2 int i;
385 segfault 1.1
386     i = 10 + (random() % 6);
387 fabian 1.2 make_rand_str(s, i);
388 segfault 1.1 }
389    
390     void flush_lines(int idx, struct chat_info *ci)
391     {
392     int c = ci->line_count;
393     struct msgq *p = ci->buffer, *o;
394    
395     while (p && c < (ci->max_line)) {
396     ci->current_lines--;
397     tputs(dcc[idx].sock, p->msg, p->len);
398 tothwolf 1.37 free(p->msg);
399 segfault 1.1 o = p->next;
400 tothwolf 1.37 free(p);
401 segfault 1.1 p = o;
402     c++;
403     }
404     if (p != NULL) {
405     if (dcc[idx].status & STAT_TELNET)
406     tputs(dcc[idx].sock, "[More]: ", 8);
407     else
408     tputs(dcc[idx].sock, "[More]\n", 7);
409     }
410     ci->buffer = p;
411     ci->line_count = 0;
412     }
413    
414     int new_dcc(struct dcc_table *type, int xtra_size)
415     {
416     int i = dcc_total;
417    
418 stdarg 1.47 for (i = 0; i < dcc_total; i++)
419 stdarg 1.40 if (!dcc[i].type) break;
420 stdarg 1.47
421     if (i == max_dcc)
422     return -1;
423    
424     if (i == dcc_total)
425 stdarg 1.40 dcc_total++;
426     memset(&dcc[i], 0, sizeof(*dcc));
427 segfault 1.1
428     dcc[i].type = type;
429 tothwolf 1.37 if (xtra_size)
430 tothwolf 1.38 dcc[i].u.other = calloc(1, xtra_size);
431 segfault 1.1 return i;
432     }
433    
434 fabian 1.22 /* Changes the given dcc entry to another type.
435     */
436 fabian 1.3 void changeover_dcc(int i, struct dcc_table *type, int xtra_size)
437     {
438 fabian 1.22 /* Free old structure. */
439 fabian 1.3 if (dcc[i].type && dcc[i].type->kill)
440     dcc[i].type->kill(i, dcc[i].u.other);
441 tothwolf 1.37 else if (dcc[i].u.other)
442     free_null(dcc[i].u.other);
443 fabian 1.3
444     dcc[i].type = type;
445 tothwolf 1.37 if (xtra_size)
446 tothwolf 1.38 dcc[i].u.other = calloc(1, xtra_size);
447 fabian 1.3 }
448    
449 segfault 1.1 int detect_dcc_flood(time_t * timer, struct chat_info *chat, int idx)
450     {
451     time_t t;
452    
453 guppy 1.24 if (!dcc_flood_thr)
454 segfault 1.1 return 0;
455     t = now;
456     if (*timer != t) {
457     *timer = t;
458     chat->msgs_per_sec = 0;
459     } else {
460     chat->msgs_per_sec++;
461     if (chat->msgs_per_sec > dcc_flood_thr) {
462     /* FLOOD */
463 ite 1.34 dprintf(idx, "*** FLOOD: %s.\n", _("Goodbye"));
464 fabian 1.17 /* Evil assumption here that flags&DCT_CHAT implies chat type */
465 segfault 1.1 if ((dcc[idx].type->flags & DCT_CHAT) && chat &&
466     (chat->channel >= 0)) {
467     char x[1024];
468    
469 tothwolf 1.39 snprintf(x, sizeof x, _("%s has been forcibly removed for flooding.\n"), dcc[idx].nick);
470 segfault 1.1 chanout_but(idx, chat->channel, "*** %s", x);
471     }
472     if ((dcc[idx].sock != STDOUT) || backgrd) {
473     killsock(dcc[idx].sock);
474     lostdcc(idx);
475     } else {
476     dprintf(DP_STDOUT, "\n### SIMULATION RESET ###\n\n");
477     dcc_chatter(idx);
478     }
479     return 1; /* <- flood */
480     }
481     }
482     return 0;
483     }
484    
485 fabian 1.17 /* Handle someone being booted from dcc chat.
486     */
487 segfault 1.1 void do_boot(int idx, char *by, char *reason)
488     {
489     int files = (dcc[idx].type != &DCC_CHAT);
490    
491 ite 1.34 dprintf(idx, _("-=- poof -=-\n"));
492     dprintf(idx, _("Youve been booted from the %s by %s%s%s\n"), files ? "file section" : "bot",
493 fabian 1.23 by, reason[0] ? ": " : ".", reason);
494 fabian 1.17 /* If it's a partyliner (chatterer :) */
495     /* Horrible assumption that DCT_CHAT using structure uses same format
496 segfault 1.1 * as DCC_CHAT */
497     if ((dcc[idx].type->flags & DCT_CHAT) &&
498     (dcc[idx].u.chat->channel >= 0)) {
499     char x[1024];
500    
501 tothwolf 1.39 snprintf(x, sizeof x, _("%s booted %s from the party line%s%s\n"), by, dcc[idx].nick,
502 guppy 1.24 reason[0] ? ": " : "", reason);
503 segfault 1.1 chanout_but(idx, dcc[idx].u.chat->channel, "*** %s.\n", x);
504     }
505     if ((dcc[idx].sock != STDOUT) || backgrd) {
506     killsock(dcc[idx].sock);
507 fabian 1.11 lostdcc(idx);
508 fabian 1.17 /* Entry must remain in the table so it can be logged by the caller */
509 segfault 1.1 } else {
510     dprintf(DP_STDOUT, "\n### SIMULATION RESET\n\n");
511     dcc_chatter(idx);
512     }
513     return;
514 stdarg 1.55 }
515    
516 wcc 1.60 /* FIXME: botnet dependencies */
517 stdarg 1.55 int add_note(char *to, char *from, char *msg, int idx, int echo)
518     {
519     int status, i, iaway, sock;
520     char ss[81], ssf[81];
521     struct userrec *u;
522    
523     if (strlen(msg) > 450)
524     msg[450] = 0; /* Notes have a limit */
525     /* note length + PRIVMSG header + nickname + date must be <512 */
526     /* Might be form "sock:nick" */
527     splitc(ssf, from, ':');
528     rmspace(ssf);
529     splitc(ss, to, ':');
530     rmspace(ss);
531     if (!ss[0])
532     sock = (-1);
533     else
534     sock = atoi(ss);
535     /* Don't process if there's a note binding for it */
536     if (idx != (-2)) { /* Notes from bots don't trigger it */
537     }
538     if (!(u = get_user_by_handle(userlist, to))) {
539     if (idx >= 0)
540     dprintf(idx, _("I dont know anyone by that name.\n"));
541     return NOTE_ERROR;
542     }
543     if (is_bot(u)) {
544     if (idx >= 0)
545     dprintf(idx, _("Thats a bot. You cant leave notes for a bot.\n"));
546     return NOTE_ERROR;
547     }
548     if (match_noterej(u, from)) {
549     if (idx >= 0)
550     dprintf(idx, "%s %s\n", u->handle, "rejected your note.");
551     return NOTE_REJECT;
552     }
553     status = NOTE_STORED;
554     iaway = 0;
555     /* Online right now? */
556     for (i = 0; i < dcc_total; i++) {
557     if (dcc[i].type && (dcc[i].type->flags & DCT_GETNOTES) &&
558     ((sock == (-1)) || (sock == dcc[i].sock)) &&
559     (!strcasecmp(dcc[i].nick, to))) {
560     int aok = 1;
561    
562     if (dcc[i].type == &DCC_CHAT)
563     if ((dcc[i].u.chat->away != NULL) &&
564     (idx != (-2))) {
565     /* Only check away if it's not from a bot */
566     aok = 0;
567     if (idx >= 0)
568     dprintf(idx, "%s %s: %s\n", dcc[i].nick, _("is away"),
569     dcc[i].u.chat->away);
570     if (!iaway)
571     iaway = i;
572     status = NOTE_AWAY;
573     }
574     if (aok) {
575     char *p, *fr = from;
576     int l = 0;
577     char work[1024];
578    
579     while ((*msg == '<') || (*msg == '>')) {
580     p = newsplit(&msg);
581     if (*p == '<')
582     l += simple_sprintf(work + l, "via %s, ", p + 1);
583     else if (*from == '@')
584     fr = p + 1;
585     }
586 wcc 1.60 if (idx == -2 || (!strcasecmp(from, myname)))
587 stdarg 1.55 dprintf(i, "*** [%s] %s%s\n", fr, l ? work : "", msg);
588     else
589     dprintf(i, "%cNote [%s]: %s%s\n", 7, fr, l ? work : "", msg);
590     if ((idx >= 0) && (echo))
591     dprintf(idx, "-> %s: %s\n", to, msg);
592     return NOTE_OK;
593     }
594     }
595     }
596     if (idx == (-2))
597     return NOTE_OK; /* Error msg from a tandembot: don't store */
598     status = storenote(from, to, msg, idx, NULL, 0);
599     if (status < 0) status = NOTE_ERROR;
600     else if (status == NOTE_AWAY) {
601     /* User is away in all sessions -- just notify the user that a
602     * message arrived and was stored. (only oldest session is notified.)
603     */
604     dprintf(iaway, "*** %s.\n", _("Note arrived for you"));
605     }
606     return(status);
607 segfault 1.1 }

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23