/[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.1.1.1 - (show annotations) (download) (as text) (vendor branch)
Wed Jun 23 19:51:28 1999 UTC (22 years, 4 months ago) by segfault
Branch: eggdev
CVS Tags: start
Changes since 1.1: +0 -0 lines
File MIME type: text/x-chdr
Eggdrop 1.3.28 CVS Code

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

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23