/[cvs]/eggdrop1.4/src/flags.c
ViewVC logotype

Contents of /eggdrop1.4/src/flags.c

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


Revision 1.9 - (show annotations) (download) (as text)
Mon Jan 17 16:14:45 2000 UTC (19 years, 7 months ago) by per
Branch: MAIN
CVS Tags: eggdrop104030RC2, eggdrop10403RC1, eggdrop10402RC1, eggdrop10404, eggdrop10403, eggdrop10402, HEAD
Changes since 1.8: +2 -6 lines
File MIME type: text/x-chdr
relayfix, extern_cleanup

1 /*
2 * flags.c -- handles:
3 * all the flag matching/conversion functions in one neat package :)
4 *
5 * $Id: flags.c,v 1.8 2000/01/08 21:23:14 per Exp $
6 */
7 /*
8 * Copyright (C) 1997 Robey Pointer
9 * Copyright (C) 1999, 2000 Eggheads
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 */
25
26 #include "main.h"
27
28 extern int use_console_r, debug_output, require_p, noshare, allow_dk_cmds;
29 extern struct dcc_t *dcc;
30
31 int use_console_r = 0; /* allow users to set their console +r */
32
33 int logmodes(char *s)
34 {
35 int i;
36 int res = 0;
37
38 for (i = 0; i < strlen(s); i++)
39 switch (s[i]) {
40 case 'm':
41 case 'M':
42 res |= LOG_MSGS;
43 break;
44 case 'p':
45 case 'P':
46 res |= LOG_PUBLIC;
47 break;
48 case 'j':
49 case 'J':
50 res |= LOG_JOIN;
51 break;
52 case 'k':
53 case 'K':
54 res |= LOG_MODES;
55 break;
56 case 'c':
57 case 'C':
58 res |= LOG_CMDS;
59 break;
60 case 'o':
61 case 'O':
62 res |= LOG_MISC;
63 break;
64 case 'b':
65 case 'B':
66 res |= LOG_BOTS;
67 break;
68 case 'r':
69 case 'R':
70 res |= use_console_r ? LOG_RAW : 0;
71 break;
72 case 'w':
73 case 'W':
74 res |= LOG_WALL;
75 break;
76 case 'x':
77 case 'X':
78 res |= LOG_FILES;
79 break;
80 case 's':
81 case 'S':
82 res |= LOG_SERV;
83 break;
84 case 'd':
85 case 'D':
86 res |= LOG_DEBUG;
87 break;
88 case 'v':
89 case 'V':
90 res |= debug_output ? LOG_SRVOUT : 0;
91 break;
92 case 't':
93 case 'T':
94 res |= debug_output ? LOG_BOTNET : 0;
95 break;
96 case 'h':
97 case 'H':
98 res |= debug_output ? LOG_BOTSHARE : 0;
99 break;
100 case '1':
101 res |= LOG_LEV1;
102 break;
103 case '2':
104 res |= LOG_LEV2;
105 break;
106 case '3':
107 res |= LOG_LEV3;
108 break;
109 case '4':
110 res |= LOG_LEV4;
111 break;
112 case '5':
113 res |= LOG_LEV5;
114 break;
115 case '6':
116 res |= LOG_LEV6;
117 break;
118 case '7':
119 res |= LOG_LEV7;
120 break;
121 case '8':
122 res |= LOG_LEV8;
123 break;
124 case '*':
125 res |= LOG_ALL;
126 break;
127 }
128 return res;
129 }
130
131 char *masktype(int x)
132 {
133 static char s[24]; /* change this if you change the levels */
134 char *p = s;
135
136 if (x & LOG_MSGS)
137 *p++ = 'm';
138 if (x & LOG_PUBLIC)
139 *p++ = 'p';
140 if (x & LOG_JOIN)
141 *p++ = 'j';
142 if (x & LOG_MODES)
143 *p++ = 'k';
144 if (x & LOG_CMDS)
145 *p++ = 'c';
146 if (x & LOG_MISC)
147 *p++ = 'o';
148 if (x & LOG_BOTS)
149 *p++ = 'b';
150 if ((x & LOG_RAW) && use_console_r)
151 *p++ = 'r';
152 if (x & LOG_FILES)
153 *p++ = 'x';
154 if (x & LOG_SERV)
155 *p++ = 's';
156 if (x & LOG_DEBUG)
157 *p++ = 'd';
158 if (x & LOG_WALL)
159 *p++ = 'w';
160 if ((x & LOG_SRVOUT) && debug_output)
161 *p++ = 'v';
162 if ((x & LOG_BOTNET) && debug_output)
163 *p++ = 't';
164 if ((x & LOG_BOTSHARE) && debug_output)
165 *p++ = 'h';
166 if (x & LOG_LEV1)
167 *p++ = '1';
168 if (x & LOG_LEV2)
169 *p++ = '2';
170 if (x & LOG_LEV3)
171 *p++ = '3';
172 if (x & LOG_LEV4)
173 *p++ = '4';
174 if (x & LOG_LEV5)
175 *p++ = '5';
176 if (x & LOG_LEV6)
177 *p++ = '6';
178 if (x & LOG_LEV7)
179 *p++ = '7';
180 if (x & LOG_LEV8)
181 *p++ = '8';
182 if (p == s)
183 *p++ = '-';
184 *p = 0;
185 return s;
186 }
187
188 char *maskname(int x)
189 {
190 static char s[207]; /* change this if you change the levels */
191 int i = 0;
192
193 s[0] = 0;
194 if (x & LOG_MSGS)
195 i += my_strcpy(s, "msgs, ");
196 if (x & LOG_PUBLIC)
197 i += my_strcpy(s + i, "public, ");
198 if (x & LOG_JOIN)
199 i += my_strcpy(s + i, "joins, ");
200 if (x & LOG_MODES)
201 i += my_strcpy(s + i, "kicks/modes, ");
202 if (x & LOG_CMDS)
203 i += my_strcpy(s + i, "cmds, ");
204 if (x & LOG_MISC)
205 i += my_strcpy(s + i, "misc, ");
206 if (x & LOG_BOTS)
207 i += my_strcpy(s + i, "bots, ");
208 if ((x & LOG_RAW) && use_console_r)
209 i += my_strcpy(s + i, "raw, ");
210 if (x & LOG_FILES)
211 i += my_strcpy(s + i, "files, ");
212 if (x & LOG_SERV)
213 i += my_strcpy(s + i, "server, ");
214 if (x & LOG_DEBUG)
215 i += my_strcpy(s + i, "debug, ");
216 if (x & LOG_WALL)
217 i += my_strcpy(s + i, "wallops, ");
218 if ((x & LOG_SRVOUT) && debug_output)
219 i += my_strcpy(s + i, "server output, ");
220 if ((x & LOG_BOTNET) && debug_output)
221 i += my_strcpy(s + i, "botnet traffic, ");
222 if ((x & LOG_BOTSHARE) && debug_output)
223 i += my_strcpy(s + i, "share traffic, ");
224 if (x & LOG_LEV1)
225 i += my_strcpy(s + i, "level 1, ");
226 if (x & LOG_LEV2)
227 i += my_strcpy(s + i, "level 2, ");
228 if (x & LOG_LEV3)
229 i += my_strcpy(s + i, "level 3, ");
230 if (x & LOG_LEV4)
231 i += my_strcpy(s + i, "level 4, ");
232 if (x & LOG_LEV5)
233 i += my_strcpy(s + i, "level 5, ");
234 if (x & LOG_LEV6)
235 i += my_strcpy(s + i, "level 6, ");
236 if (x & LOG_LEV7)
237 i += my_strcpy(s + i, "level 7, ");
238 if (x & LOG_LEV8)
239 i += my_strcpy(s + i, "level 8, ");
240 if (i)
241 s[i - 2] = 0;
242 else
243 strcpy(s, "none");
244 return s;
245 }
246
247 /* some flags are mutually exclusive -- this roots them out */
248 int sanity_check(int atr)
249 {
250 if ((atr & USER_BOT) &&
251 (atr & (USER_PARTY | USER_MASTER | USER_COMMON | USER_OWNER)))
252 atr &= ~(USER_PARTY | USER_MASTER | USER_COMMON | USER_OWNER);
253 if ((atr & USER_OP) && (atr & USER_DEOP))
254 atr &= ~(USER_OP | USER_DEOP);
255 if ((atr & USER_AUTOOP) && (atr & USER_DEOP))
256 atr &= ~(USER_AUTOOP | USER_DEOP);
257 if ((atr & USER_VOICE) && (atr & USER_QUIET))
258 atr &= ~(USER_VOICE | USER_QUIET);
259 if ((atr & USER_GVOICE) && (atr & USER_QUIET))
260 atr &= ~(USER_GVOICE | USER_QUIET);
261 /* can't be owner without also being master */
262 if (atr & USER_OWNER)
263 atr |= USER_MASTER;
264 /* master implies botmaster, op, friend and janitor */
265 if (atr & USER_MASTER)
266 atr |= USER_BOTMAST | USER_OP | USER_FRIEND | USER_JANITOR;
267 /* can't be botnet master without party-line access */
268 if (atr & USER_BOTMAST)
269 atr |= USER_PARTY;
270 /* janitors can use the file area */
271 if (atr & USER_JANITOR)
272 atr |= USER_XFER;
273 return atr;
274 }
275
276 /* sanity check on channel attributes */
277 int chan_sanity_check(int chatr, int atr)
278 {
279 if ((chatr & USER_OP) && (chatr & USER_DEOP))
280 chatr &= ~(USER_OP | USER_DEOP);
281 if ((chatr & USER_AUTOOP) && (chatr & USER_DEOP))
282 chatr &= ~(USER_AUTOOP | USER_DEOP);
283 if ((chatr & USER_VOICE) && (chatr & USER_QUIET))
284 chatr &= ~(USER_VOICE | USER_QUIET);
285 if ((chatr & USER_GVOICE) && (chatr & USER_QUIET))
286 chatr &= ~(USER_GVOICE | USER_QUIET);
287 /* can't be channel owner without also being channel master */
288 if (chatr & USER_OWNER)
289 chatr |= USER_MASTER;
290 /* master implies friend & op */
291 if (chatr & USER_MASTER)
292 chatr |= USER_OP | USER_FRIEND;
293 /* can't be +s on chan unless you're a bot */
294 if (!(atr & USER_BOT))
295 chatr &= ~BOT_SHARE;
296 return chatr;
297 }
298
299 /* get icon symbol for a user (depending on access level)
300 * (*)owner on any channel
301 * (+)master on any channel
302 * (%) botnet master
303 * (@) op on any channel
304 * (-) other */
305 char geticon(int idx)
306 {
307 struct flag_record fr =
308 {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};
309
310 if (!dcc[idx].user)
311 return '-';
312 get_user_flagrec(dcc[idx].user, &fr, 0);
313 if (chan_owner(fr))
314 return '*';
315 if (chan_master(fr))
316 return '+';
317 if (glob_botmast(fr))
318 return '%';
319 if (chan_op(fr))
320 return '@';
321 return '-';
322 }
323
324 void break_down_flags(char *string, struct flag_record *plus,
325 struct flag_record *minus)
326 {
327 struct flag_record *which = plus;
328 int mode = 0; /* 0 = glob, 1 = chan, 2 = bot */
329 int flags = plus->match;
330
331 if (!(flags & FR_GLOBAL)) {
332 if (flags & FR_BOT)
333 mode = 2;
334 else if (flags & FR_CHAN)
335 mode = 1;
336 else
337 return; /* we dont actually want any..huh? */
338 }
339 bzero(plus, sizeof(struct flag_record));
340
341 if (minus)
342 bzero(minus, sizeof(struct flag_record));
343
344 plus->match = FR_OR; /* befault binding type OR */
345 while (*string) {
346 switch (*string) {
347 case '+':
348 which = plus;
349 break;
350 case '-':
351 which = minus ? minus : plus;
352 break;
353 case '|':
354 case '&':
355 if (mode == 0) {
356 if (*string == '|')
357 plus->match = FR_OR;
358 else
359 plus->match = FR_AND;
360 }
361 which = plus;
362 mode++;
363 if ((mode == 2) && !(flags & (FR_CHAN | FR_BOT)))
364 string = "";
365 else if (mode == 3)
366 mode = 1;
367 break;
368 default:
369 if ((*string >= 'a') && (*string <= 'z')) {
370 switch (mode) {
371 case 0:
372 which->global |=1 << (*string - 'a');
373
374 break;
375 case 1:
376 which->chan |= 1 << (*string - 'a');
377 break;
378 case 2:
379 which->bot |= 1 << (*string - 'a');
380 }
381 } else if ((*string >= 'A') && (*string <= 'Z')) {
382 switch (mode) {
383 case 0:
384 which->udef_global |= 1 << (*string - 'A');
385 break;
386 case 1:
387 which->udef_chan |= 1 << (*string - 'A');
388 break;
389 }
390 } else if ((*string >= '0') && (*string <= '9')) {
391 switch (mode) {
392 /* map 0->9 to A->K for glob/chan so they are not lost */
393 case 0:
394 which->udef_global |= 1 << (*string - '0');
395 break;
396 case 1:
397 which->udef_chan |= 1 << (*string - '0');
398 break;
399 case 2:
400 which->bot |= BOT_FLAG0 << (*string - '0');
401 break;
402 }
403 }
404 }
405 string++;
406 }
407 for (which = plus; which; which = (which == plus ? minus : 0)) {
408 which->global &=USER_VALID;
409
410 which->udef_global &= 0x03ffffff;
411 which->chan &= CHAN_VALID;
412 which->udef_chan &= 0x03ffffff;
413 which->bot &= BOT_VALID;
414 }
415 plus->match |= flags;
416 if (minus) {
417 minus->match |= flags;
418 if (!(plus->match & (FR_AND | FR_OR)))
419 plus->match |= FR_OR;
420 }
421 }
422
423 static int flag2str(char *string, int bot, int udef)
424 {
425 char x = 'a', *old = string;
426
427 while (bot && (x <= 'z')) {
428 if (bot & 1)
429 *string++ = x;
430 x++;
431 bot = bot >> 1;
432 }
433 x = 'A';
434 while (udef && (x <= 'Z')) {
435 if (udef & 1)
436 *string++ = x;
437 udef = udef >> 1;
438 x++;
439 }
440 if (string == old)
441 *string++ = '-';
442 return string - old;
443 }
444
445 static int bot2str(char *string, int bot)
446 {
447 char x = 'a', *old = string;
448
449 while (x < 'v') {
450 if (bot & 1)
451 *string++ = x;
452 x++;
453 bot >>= 1;
454 }
455 x = '0';
456 while (x <= '9') {
457 if (bot & 1)
458 *string++ = x;
459 x++;
460 bot >>= 1;
461 }
462 return string - old;
463 }
464
465 int build_flags(char *string, struct flag_record *plus,
466 struct flag_record *minus)
467 {
468 char *old = string;
469
470 if (plus->match & FR_GLOBAL) {
471 if (minus && (plus->global || plus->udef_global))
472 *string++ = '+';
473 string += flag2str(string, plus->global, plus->udef_global);
474
475 if (minus && (minus->global || minus->udef_global)) {
476 *string++ = '-';
477 string += flag2str(string, minus->global, minus->udef_global);
478 }
479 } else if (plus->match & FR_BOT) {
480 if (minus && plus->bot)
481 *string++ = '+';
482 string += bot2str(string, plus->bot);
483 if (minus && minus->bot) {
484 *string++ = '-';
485 string += bot2str(string, minus->bot);
486 }
487 }
488 if (plus->match & FR_CHAN) {
489 if (plus->match & (FR_GLOBAL | FR_BOT))
490 *string++ = (plus->match & FR_AND) ? '&' : '|';
491 if (minus && (plus->chan || plus->udef_chan))
492 *string++ = '+';
493 string += flag2str(string, plus->chan, plus->udef_chan);
494 if (minus && (minus->chan || minus->udef_chan)) {
495 *string++ = '-';
496 string += flag2str(string, minus->global, minus->udef_chan);
497 }
498 }
499 if ((plus->match & (FR_BOT | FR_CHAN)) == (FR_BOT | FR_CHAN)) {
500 *string++ = (plus->match & FR_AND) ? '&' : '|';
501 if (minus && plus->bot)
502 *string++ = '+';
503 string += bot2str(string, plus->bot);
504 if (minus && minus->bot) {
505 *string++ = '-';
506 string += bot2str(string, minus->bot);
507 }
508 }
509 if (string == old) {
510 *string++ = '-';
511 *string = 0;
512 return 0;
513 }
514 *string = 0;
515 return string - old;
516 }
517
518 int flagrec_ok(struct flag_record *req,
519 struct flag_record *have)
520 {
521 if (req->match & FR_AND) {
522 return flagrec_eq(req, have);
523 } else if (req->match & FR_OR) {
524 int hav = have->global;
525
526 /* exception 1 - global +d/+k cant use -|-, unless they are +p */
527 if (!req->chan && !req->global && !req->udef_global &&
528 !req->udef_chan) {
529 if (!allow_dk_cmds) {
530 if (glob_party(*have))
531 return 1;
532 if (glob_kick(*have) || chan_kick(*have))
533 return 0; /* +k cant use -|- commands */
534 if (glob_deop(*have) || chan_deop(*have))
535 return 0; /* neither can +d's */
536 }
537 return 1;
538 }
539 /* the +n/+m checks arent needed anymore since +n/+m
540 * automatically add lower flags */
541 if (!require_p && ((hav & USER_OP) || (have->chan & USER_OWNER)))
542 hav |= USER_PARTY;
543 if (hav & req->global)
544 return 1;
545 if (have->chan & req->chan)
546 return 1;
547 if (have->udef_global & req->udef_global)
548 return 1;
549 if (have->udef_chan & req->udef_chan)
550 return 1;
551 return 0;
552 }
553 return 0; /* fr0k3 binding, dont pass it */
554 }
555
556 int flagrec_eq(struct flag_record *req, struct flag_record *have)
557 {
558 if (req->match & FR_AND) {
559 if (req->match & FR_GLOBAL) {
560 if ((req->global &have->global) !=req->global)
561 return 0;
562 if ((req->udef_global & have->udef_global) != req->udef_global)
563 return 0;
564 }
565 if (req->match & FR_BOT)
566 if ((req->bot & have->bot) != req->bot)
567 return 0;
568 if (req->match & FR_CHAN) {
569 if ((req->chan & have->chan) != req->chan)
570 return 0;
571 if ((req->udef_chan & have->udef_chan) != req->udef_chan)
572 return 0;
573 }
574 return 1;
575 } else if (req->match & FR_OR) {
576 if (!req->chan && !req->global && !req->udef_chan &&
577 !req->udef_global && !req->bot)
578 return 1;
579 if (req->match & FR_GLOBAL) {
580 if (have->global &req->global)
581 return 1;
582 if (have->udef_global & req->udef_global)
583 return 1;
584 }
585 if (req->match & FR_BOT)
586 if (have->bot & req->bot)
587 return 1;
588 if (req->match & FR_CHAN) {
589 if (have->chan & req->chan)
590 return 1;
591 if (have->udef_chan & req->udef_chan)
592 return 1;
593 }
594 return 0;
595 }
596 return 0; /* fr0k3 binding, dont pass it */
597 }
598
599 void set_user_flagrec(struct userrec *u, struct flag_record *fr,
600 char *chname)
601 {
602 struct chanuserrec *cr = NULL;
603 int oldflags = fr->match;
604 char buffer[100];
605 struct chanset_t *ch;
606
607 if (!u)
608 return;
609 if (oldflags & FR_GLOBAL) {
610 u->flags = fr->global;
611
612 u->flags_udef = fr->udef_global;
613 if (!noshare && !(u->flags & USER_UNSHARED)) {
614 fr->match = FR_GLOBAL;
615 build_flags(buffer, fr, NULL);
616 shareout(NULL, "a %s %s\n", u->handle, buffer);
617 }
618 }
619 if ((oldflags & FR_BOT) && (u->flags & USER_BOT))
620 set_user(&USERENTRY_BOTFL, u, (void *) fr->bot);
621 /* dont share bot attrs */
622 if ((oldflags & FR_CHAN) && chname) {
623 for (cr = u->chanrec; cr; cr = cr->next)
624 if (!rfc_casecmp(chname, cr->channel))
625 break;
626 ch = findchan(chname);
627 if (!cr && ch) {
628 cr = user_malloc(sizeof(struct chanuserrec));
629 bzero(cr, sizeof(struct chanuserrec));
630
631 cr->next = u->chanrec;
632 u->chanrec = cr;
633 strncpy(cr->channel, chname, 80);
634 cr->channel[80] = 0;
635 }
636 if (cr && ch) {
637 cr->flags = fr->chan;
638 cr->flags_udef = fr->udef_chan;
639 if (!noshare && !(u->flags & USER_UNSHARED) && channel_shared(ch)) {
640 fr->match = FR_CHAN;
641 build_flags(buffer, fr, NULL);
642 shareout(ch, "a %s %s %s\n", u->handle, buffer, chname);
643 }
644 }
645 }
646 fr->match = oldflags;
647 }
648
649 void get_user_flagrec(struct userrec *u, struct flag_record *fr,
650 char *chname)
651 {
652 struct chanuserrec *cr = NULL;
653
654 if (!u) {
655 fr->global = fr->udef_global = fr->chan = fr->udef_chan = fr->bot = 0;
656
657 return;
658 }
659 if (fr->match & FR_GLOBAL) {
660 fr->global = u->flags;
661
662 fr->udef_global = u->flags_udef;
663 } else {
664 fr->global = 0;
665
666 fr->udef_global = 0;
667 }
668 if (fr->match & FR_BOT) {
669 fr->bot = (long) get_user(&USERENTRY_BOTFL, u);
670 } else
671 fr->bot = 0;
672 if (fr->match & FR_CHAN) {
673 if (fr->match & FR_ANYWH) {
674 fr->chan = u->flags;
675 fr->udef_chan = u->flags_udef;
676 for (cr = u->chanrec; cr; cr = cr->next)
677 if (findchan(cr->channel)) {
678 fr->chan |= cr->flags;
679 fr->udef_chan |= cr->flags_udef;
680 }
681 } else {
682 if (chname)
683 for (cr = u->chanrec; cr; cr = cr->next)
684 if (!rfc_casecmp(chname, cr->channel))
685 break;
686 if (chname && cr) {
687 fr->chan = cr->flags;
688 fr->udef_chan = cr->flags_udef;
689 } else {
690 fr->chan = 0;
691 fr->udef_chan = 0;
692 }
693 }
694 }
695 }
696
697 static int botfl_unpack(struct userrec *u, struct user_entry *e)
698 {
699 struct flag_record fr = {FR_BOT, 0, 0, 0, 0, 0};
700
701 Context;
702 Assert(e);
703 Assert(e->name);
704 break_down_flags(e->u.list->extra, &fr, NULL);
705 list_type_kill(e->u.list);
706 e->u.ulong = fr.bot;
707 return 1;
708 }
709
710 static int botfl_pack(struct userrec *u, struct user_entry *e)
711 {
712 char x[100];
713 struct flag_record fr = {FR_BOT, 0, 0, 0, 0, 0};
714
715 fr.bot = e->u.ulong;
716 e->u.list = user_malloc(sizeof(struct list_type));
717 e->u.list->next = NULL;
718 e->u.list->extra = user_malloc (build_flags (x, &fr, NULL) + 1);
719 strcpy(e->u.list->extra, x);
720 return 1;
721 }
722
723 static int botfl_kill(struct user_entry *e)
724 {
725 Context;
726 nfree(e);
727 return 1;
728 }
729
730 static int botfl_write_userfile(FILE * f, struct userrec *u, struct user_entry *e)
731 {
732 char x[100];
733 struct flag_record fr =
734 {FR_BOT, 0, 0, 0, 0, 0};
735
736 Context;
737 fr.bot = e->u.ulong;
738 build_flags(x, &fr, NULL);
739 if (fprintf(f, "--%s %s\n", e->type->name, x) == EOF)
740 return 0;
741 return 1;
742 }
743
744 static int botfl_set(struct userrec *u, struct user_entry *e, void *buf)
745 {
746 register long atr = ((long) buf & BOT_VALID);
747
748 Context;
749 if (!(u->flags & USER_BOT))
750 return 1; /* don't even bother trying to set the flags for a non-bot */
751 if ((atr & BOT_HUB) && (atr & BOT_ALT))
752 atr &= ~BOT_ALT;
753 if (atr & BOT_REJECT) {
754 if (atr & BOT_SHARE)
755 atr &= ~(BOT_SHARE | BOT_REJECT);
756 if (atr & BOT_HUB)
757 atr &= ~(BOT_HUB | BOT_REJECT);
758 if (atr & BOT_ALT)
759 atr &= ~(BOT_ALT | BOT_REJECT);
760 }
761 if (!(atr & BOT_SHARE))
762 atr &= ~BOT_GLOBAL;
763 e->u.ulong = atr;
764 Context;
765 return 1;
766 }
767
768 static int botfl_tcl_get(Tcl_Interp * interp, struct userrec *u,
769 struct user_entry *e, int argc, char **argv)
770 {
771 char x[100];
772 struct flag_record fr =
773 {FR_BOT, 0, 0, 0, 0, 0};
774
775 fr.bot = e->u.ulong;
776 build_flags(x, &fr, NULL);
777 Tcl_AppendResult(interp, x, NULL);
778 return TCL_OK;
779 }
780
781 static int botfl_tcl_set(Tcl_Interp * irp, struct userrec *u,
782 struct user_entry *e, int argc, char **argv)
783 {
784 struct flag_record fr = {FR_BOT, 0, 0, 0, 0, 0};
785
786 BADARGS(4, 4, " handle BOTFL flags");
787 if (u->flags & USER_BOT) {
788 /* silently ignore for users */
789 break_down_flags(argv[3], &fr, NULL);
790 botfl_set(u, e, (void *) fr.bot);
791 }
792 return TCL_OK;
793 }
794
795 static int botfl_expmem(struct user_entry *e)
796 {
797 Context;
798 return 0;
799 }
800
801 static void botfl_display(int idx, struct user_entry *e)
802 {
803 struct flag_record fr =
804 {FR_BOT, 0, 0, 0, 0, 0};
805 char x[100];
806
807 Context;
808 fr.bot = e->u.ulong;
809 build_flags(x, &fr, NULL);
810 dprintf(idx, " BOT FLAGS: %s\n", x);
811 }
812
813 struct user_entry_type USERENTRY_BOTFL =
814 {
815 0, /* always 0 ;) */
816 0,
817 def_dupuser,
818 botfl_unpack,
819 botfl_pack,
820 botfl_write_userfile,
821 botfl_kill,
822 def_get,
823 botfl_set,
824 botfl_tcl_get,
825 botfl_tcl_set,
826 botfl_expmem,
827 botfl_display,
828 "BOTFL"
829 };

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23