1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088
|
/*
* ignore.c: handles the ingore command for irc
*
* Written By Michael Sandrof
*
* Copyright(c) 1990
*
* See the COPYRIGHT file, or do a HELP IRCII COPYRIGHT
*/
#include "irc.h"
static char cvsrevision[] = "$Id: ignore.c,v 1.1.1.1 2003/04/11 01:09:07 dan Exp $";
CVS_REVISION(ignore_c)
#include "struct.h"
#include "ignore.h"
#include "ircaux.h"
#include "list.h"
#include "input.h"
#include "screen.h"
#include "misc.h"
#include "vars.h"
#include "output.h"
#define MAIN_SOURCE
#include "modval.h"
int ignore_usernames = 0;
char *highlight_char = NULL;
static int remove_ignore (char *);
static void ignore_list (char *);
static char *cut_n_fix_glob ( char *);
/* ignored_nicks: pointer to the head of the ignore list */
Ignore *ignored_nicks = NULL;
#define IGNORE_REMOVE 1
#define IGNORE_DONT 2
#define IGNORE_HIGH -1
#define IGNORE_CGREP -2
static Ignore *new_ignore = NULL;
void add_channel_grep(char *channel, char *what, int flag)
{
Ignore *new;
int count;
char *chan, *ptr;
char *new_str, *p;
while (channel)
{
new_str = p = m_strdup(what);
if ((ptr = strchr(channel, ',')) != NULL)
*ptr = '\0';
chan = make_channel(channel);
if (chan && !(new = (Ignore *) list_lookup((List **) &ignored_nicks, chan, !USE_WILDCARDS, !REMOVE_FROM_LIST)))
{
Ignore *tmp, *old;
char *s;
if ((new = (Ignore *) remove_from_list((List **) &ignored_nicks, channel)) != NULL)
{
new_free(&(new->nick));
for (tmp = new->except; tmp; tmp = old)
{
old = tmp->next;
new_free(&(tmp->nick));
new_free(&(tmp));
}
for (tmp = new->looking; tmp; tmp = old)
{
old = tmp->next;
new_free(&(tmp->nick));
new_free(&(tmp));
}
new_free((char **)&new);
}
new = (Ignore *) new_malloc(sizeof(Ignore));
new->nick = m_strdup(chan);
while ((s = new_next_arg(new_str, &new_str)))
{
tmp = (Ignore *) new_malloc(sizeof(Ignore));
tmp->nick = m_strdup(s);
add_to_list((List **)&new->looking, (List *)tmp);
}
add_to_list((List **) &ignored_nicks, (List *) new);
new->cgrep = flag;
}
if (ptr)
*(ptr++) = ',';
channel = ptr;
new_free(&p);
}
for (new = ignored_nicks, count = 1; new; new = new->next, count++)
new->num = count;
if (*what)
*what = 0;
}
/*
* ignore_nickname: adds nick to the ignore list, using type as the type of
* ignoring to take place.
*/
void ignore_nickname(char *nick, long type, int flag)
{
Ignore *new, *newc;
char *msg,
*ptr;
char *new_nick = NULL;
char buffer[BIG_BUFFER_SIZE + 1];
int count;
if (type == -1)
return;
while (nick)
{
if ((ptr = strchr(nick, ',')) != NULL)
*ptr = '\0';
if (*nick)
{
new_nick = is_channel(nick) ? m_strdup(nick) : cut_n_fix_glob(nick);
if (!(new = (Ignore *) list_lookup((List **) &ignored_nicks, new_nick, !USE_WILDCARDS, !REMOVE_FROM_LIST)))
{
if (flag == IGNORE_REMOVE)
{
say("%s is not on the ignore list", nick);
if (ptr)
*(ptr++) = ',';
nick = ptr;
continue;
}
else
{
if ((new = (Ignore *) remove_from_list((List **) &ignored_nicks, nick)) != NULL)
{
Ignore *tmp, *old;
new_free(&(new->nick));
new_free(&new->looking);
for (tmp = new->except; tmp; tmp = old)
{
old = tmp->next;
new_free(&(tmp->nick));
new_free(&(tmp));
}
for (tmp = new->looking; tmp; tmp = old)
{
old = tmp->next;
new_free(&(tmp->nick));
new_free(&(tmp));
}
new_free((char **)&new);
}
new = (Ignore *) new_malloc(sizeof(Ignore));
new->nick = new_nick;
add_to_list((List **) &ignored_nicks, (List *) new);
}
for (newc = ignored_nicks, count = 1; newc; newc = newc->next, count++)
newc->num = count;
}
new_ignore = new;
switch (flag)
{
case IGNORE_REMOVE:
new->type &= (~type);
new->high &= (~type);
new->dont &= (~type);
new->cgrep &= (~type);
msg = "Not ignoring";
break;
case IGNORE_DONT:
new->dont |= type;
new->type &= (~type);
new->high &= (~type);
new->cgrep &= (~type);
msg = "Never ignoring";
break;
case IGNORE_HIGH:
new->high |= type;
new->type &= (~type);
new->dont &= (~type);
new->cgrep &= (~type);
msg = "Highlighting";
break;
case IGNORE_CGREP:
new->cgrep |= type;
new->high &= (~type);
new->type &= (~type);
new->dont &= (~type);
msg = "Channel Grep";
break;
default:
new->type |= type;
new->high &= (~type);
new->dont &= (~type);
new->cgrep &= (~type);
msg = "Ignoring";
break;
}
if (type == IGNORE_ALL)
{
switch (flag)
{
case IGNORE_REMOVE:
remove_ignore(new->nick);
break;
case IGNORE_HIGH:
say("Highlighting ALL messages from %s", new->nick);
break;
case IGNORE_CGREP:
say("Grepping ALL messages from %s", new->nick);
break;
case IGNORE_DONT:
say("Never ignoring messages from %s", new->nick);
break;
default:
say("Ignoring ALL messages from %s", new->nick);
break;
}
return;
}
else if (type)
{
strcpy(buffer, msg);
if (type & IGNORE_MSGS)
strcat(buffer, " MSGS");
if (type & IGNORE_PUBLIC)
strcat(buffer, " PUBLIC");
if (type & IGNORE_WALLS)
strcat(buffer, " WALLS");
if (type & IGNORE_WALLOPS)
strcat(buffer, " WALLOPS");
if (type & IGNORE_INVITES)
strcat(buffer, " INVITES");
if (type & IGNORE_NOTICES)
strcat(buffer, " NOTICES");
if (type & IGNORE_NOTES)
strcat(buffer, " NOTES");
if (type & IGNORE_CTCPS)
strcat(buffer, " CTCPS");
if (type & IGNORE_CRAP)
strcat(buffer, " CRAP");
if (type & IGNORE_CDCC)
strcat(buffer, " CDCC");
if (type & IGNORE_KICKS)
strcat(buffer, " KICKS");
if (type & IGNORE_MODES)
strcat(buffer, " MODES");
if (type & IGNORE_SMODES)
strcat(buffer, " SMODES");
if (type & IGNORE_JOINS)
strcat(buffer, " JOINS");
if (type & IGNORE_TOPICS)
strcat(buffer, " TOPICS");
if (type & IGNORE_QUITS)
strcat(buffer, " QUITS");
if (type & IGNORE_PARTS)
strcat(buffer, " PARTS");
if (type & IGNORE_NICKS)
strcat(buffer, " NICKS");
if (type & IGNORE_PONGS)
strcat(buffer, " PONGS");
if (type & IGNORE_SPLITS)
strcat(buffer, " SPLITS");
say("%s from %s", buffer, new->nick);
}
}
if (ptr)
*(ptr++) = ',';
nick = ptr;
}
}
/*
* remove_ignore: removes the given nick from the ignore list and returns 0.
* If the nick wasn't in the ignore list to begin with, 1 is returned.
*/
static int remove_ignore(char *nick)
{
Ignore *tmp, *new, *old;
char *new_nick = NULL;
int count = 0;
new_nick = (is_channel(nick) ? m_strdup(nick) : cut_n_fix_glob(nick));
/*
* Look for an exact match first.
*/
if ((tmp = (Ignore *) list_lookup((List **)&ignored_nicks, new_nick, !USE_WILDCARDS, REMOVE_FROM_LIST)) != NULL)
{
say("%s removed from ignore list", tmp->nick);
new_free(&(tmp->nick));
for (new = tmp->except; new; new = old)
{
old = new->next;
new_free(&(new->nick));
new_free(&(new));
}
for (new = tmp->looking; new; new = old)
{
old = new->next;
new_free(&(new->nick));
new_free(&(new));
}
new_free((char **)&tmp);
count++;
}
/*
* Otherwise clear everything that matches.
*/
else while ((tmp = (Ignore *)list_lookup((List **)&ignored_nicks, new_nick, USE_WILDCARDS, REMOVE_FROM_LIST)) != NULL)
{
say("%s removed from ignore list", tmp->nick);
new_free(&(tmp->nick));
for (new = tmp->except; new; new = old)
{
old = new->next;
new_free(&(new->nick));
new_free(&(new));
}
for (new = tmp->looking; new; new = old)
{
old = new->next;
new_free(&(new->nick));
new_free(&(new));
}
new_free((char **)&tmp);
count++;
}
if (!count)
say("%s is not in the ignore list!", new_nick);
new_free(&new_nick);
return count;
}
/*
* is_ignored: checks to see if nick is being ignored (poor nick). Checks
* against type to see if ignoring is to take place. If nick is marked as
* IGNORE_ALL or ignorace types match, 1 is returned, otherwise 0 is
* returned.
*/
int is_ignored(char *nick, long type)
{
Ignore *tmp;
if (ignored_nicks)
{
if ((tmp = (Ignore *) list_lookup((List **) &ignored_nicks, nick, USE_WILDCARDS, !REMOVE_FROM_LIST)) != NULL)
{
if (tmp->dont & type)
return (DONT_IGNORE);
if (tmp->type & type)
return (IGNORED);
if (tmp->high & type)
return (HIGHLIGHTED);
if (tmp->high & type)
return (CHANNEL_GREP);
}
}
return (0);
}
int check_is_ignored(char *nick)
{
Ignore *tmp;
if (ignored_nicks)
{
if ((tmp = (Ignore *) list_lookup((List **) &ignored_nicks, nick, USE_WILDCARDS, !REMOVE_FROM_LIST)) != NULL)
return 1;
}
return 0;
}
/* ignore_list: shows the entired ignore list */
static void ignore_list(char *nick)
{
Ignore *tmp;
int len = 0;
char buffer[BIG_BUFFER_SIZE + 1];
if (ignored_nicks)
{
say("Ignore List:");
if (nick)
len = strlen(nick);
for (tmp = ignored_nicks; tmp; tmp = tmp->next)
{
if (nick)
{
if (strncmp(nick, tmp->nick, len))
continue;
}
*buffer = 0;
if (tmp->type == IGNORE_ALL)
strmopencat(buffer, BIG_BUFFER_SIZE, " ALL", NULL);
else if (tmp->high == IGNORE_ALL)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "ALL", highlight_char, NULL);
else if (tmp->dont == IGNORE_ALL)
strmopencat(buffer, BIG_BUFFER_SIZE, " DONT-ALL", NULL);
else
{
if (tmp->type & IGNORE_PUBLIC)
strmcat(buffer, " PUBLIC", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_PUBLIC)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "PUBLIC", highlight_char, NULL);
else if (tmp->dont & IGNORE_PUBLIC)
strmcat(buffer, " DONT-PUBLIC", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_MSGS)
strmcat(buffer, " MSGS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_MSGS)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "MSG", highlight_char, NULL);
else if (tmp->dont & IGNORE_MSGS)
strmcat(buffer, " DONT-MSGS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_WALLS)
strmcat(buffer, " WALLS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_WALLS)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "WALL", highlight_char, NULL);
else if (tmp->dont & IGNORE_WALLS)
strmcat(buffer, " DONT-WALLS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_WALLOPS)
strmcat(buffer, " WALLOPS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_WALLOPS)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "WALLOPS", highlight_char, NULL);
else if (tmp->dont & IGNORE_WALLOPS)
strmcat(buffer, " DONT-WALLOPS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_INVITES)
strmcat(buffer, " INVITES", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_INVITES)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "INVITES", highlight_char, NULL);
else if (tmp->dont & IGNORE_INVITES)
strmcat(buffer, " DONT-INVITES", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_NOTICES)
strmcat(buffer, " NOTICES", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_NOTICES)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "NOTICES", highlight_char, NULL);
else if (tmp->dont & IGNORE_NOTICES)
strmcat(buffer, " DONT-NOTICES", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_NOTES)
strmcat(buffer, " NOTES", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_NOTES)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "NOTES", highlight_char, NULL);
else if (tmp->dont & IGNORE_NOTES)
strmcat(buffer, " DONT-NOTES", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_CTCPS)
strmcat(buffer, " CTCPS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_CTCPS)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "CTCPS", highlight_char, NULL);
else if (tmp->dont & IGNORE_CTCPS)
strmcat(buffer, " DONT-CTCPS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_CDCC)
strmcat(buffer, " CDCC", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_CDCC)
strmopencat(buffer, BIG_BUFFER_SIZE,space, highlight_char, "CDCC", highlight_char, NULL);
else if (tmp->dont & IGNORE_CDCC)
strmcat(buffer, " DONT-CDCC", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_KICKS)
strmcat(buffer, " KICKS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_KICKS)
strmopencat(buffer, BIG_BUFFER_SIZE,space, highlight_char, "KICKS", highlight_char, NULL);
else if (tmp->dont & IGNORE_KICKS)
strmcat(buffer, " DONT-KICKS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_MODES)
strmcat(buffer, " MODES", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_MODES)
strmopencat(buffer, BIG_BUFFER_SIZE,space, highlight_char, "MODES", highlight_char, NULL);
else if (tmp->dont & IGNORE_MODES)
strmcat(buffer, " DONT-MODES", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_SMODES)
strmcat(buffer, " SMODES", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_SMODES)
strmopencat(buffer, BIG_BUFFER_SIZE,space, highlight_char, "SMODES", highlight_char, NULL);
else if (tmp->dont & IGNORE_SMODES)
strmcat(buffer, " DONT-SMODES", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_JOINS)
strmcat(buffer, " JOINS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_JOINS)
strmopencat(buffer, BIG_BUFFER_SIZE,space, highlight_char, "JOINS", highlight_char, NULL);
else if (tmp->dont & IGNORE_JOINS)
strmcat(buffer, " DONT-JOINS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_TOPICS)
strmcat(buffer, " TOPICS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_TOPICS)
strmopencat(buffer, BIG_BUFFER_SIZE,space, highlight_char, "TOPICS", highlight_char, NULL);
else if (tmp->dont & IGNORE_TOPICS)
strmcat(buffer, " DONT-TOPICS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_QUITS)
strmcat(buffer, " QUITS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_QUITS)
strmopencat(buffer, BIG_BUFFER_SIZE,space, highlight_char, "QUITS", highlight_char, NULL);
else if (tmp->dont & IGNORE_QUITS)
strmcat(buffer, " DONT-QUITS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_PARTS)
strmcat(buffer, " PARTS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_PARTS)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "PARTS", highlight_char, NULL);
else if (tmp->dont & IGNORE_PARTS)
strmcat(buffer, " DONT-PARTS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_NICKS)
strmcat(buffer, " NICKS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_NICKS)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "NICKS", highlight_char, NULL);
else if (tmp->dont & IGNORE_NICKS)
strmcat(buffer, " DONT-NICKS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_PONGS)
strmcat(buffer, " PONGS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_PONGS)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "PONGS", highlight_char, NULL);
else if (tmp->dont & IGNORE_PONGS)
strmcat(buffer, " DONT-PONGS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_SPLITS)
strmcat(buffer, " SPLITS", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_SPLITS)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "SPLITS", highlight_char, NULL);
else if (tmp->dont & IGNORE_SPLITS)
strmcat(buffer, " DONT-SPLITS", BIG_BUFFER_SIZE);
if (tmp->type & IGNORE_CRAP)
strmcat(buffer, " CRAP", BIG_BUFFER_SIZE);
else if (tmp->high & IGNORE_CRAP)
strmopencat(buffer, BIG_BUFFER_SIZE, space, highlight_char, "CRAP", highlight_char, NULL);
else if (tmp->dont & IGNORE_CRAP)
strmcat(buffer, " DONT-CRAP", BIG_BUFFER_SIZE);
}
if (tmp->except)
{
Ignore *new;
strmcat(buffer, " EXCEPT ", BIG_BUFFER_SIZE);
for (new = tmp->except; new; new = new->next)
strmopencat(buffer, BIG_BUFFER_SIZE, new->nick, space, NULL);
}
if (tmp->looking && tmp->cgrep)
{
Ignore *new;
strmcat(buffer, " CGREP ", BIG_BUFFER_SIZE);
for (new = tmp->looking; new; new = new->next)
strmopencat(buffer, BIG_BUFFER_SIZE, "[", new->nick, "] ", NULL);
}
put_it("%s", convert_output_format(" %K[%G$[-2]0%K] %C$[-25]1%W:%n $2-", "%d %s %s", tmp->num, tmp->nick, buffer));
}
}
else
bitchsay("There are no nicknames or channels being ignored");
}
long ignore_type (char *type, int len)
{
long ret = -1;
if (!type || !*type)
return -1;
if (!strncmp(type, "ALL", len))
ret = IGNORE_ALL;
else if (!strncmp(type, "MSGS", len))
ret = IGNORE_MSGS;
else if (!strncmp(type, "PUBLIC", len))
ret = IGNORE_PUBLIC;
else if (!strncmp(type, "WALLS", len))
ret = IGNORE_WALLS;
else if (!strncmp(type, "WALLOPS", len))
ret = IGNORE_WALLOPS;
else if (!strncmp(type, "INVITES", len))
ret = IGNORE_INVITES;
else if (!strncmp(type, "NOTICES", len))
ret = IGNORE_NOTICES;
else if (!strncmp(type, "NOTES", len))
ret = IGNORE_NOTES;
else if (!strncmp(type, "CTCPS", len))
ret = IGNORE_CTCPS;
else if (!strncmp(type, "CDCC", len))
ret = IGNORE_CDCC;
else if (!strncmp(type, "KICKS", len))
ret = IGNORE_KICKS;
else if (!strncmp(type, "MODES", len))
ret = IGNORE_MODES;
else if (!strncmp(type, "SMODES", len))
ret = IGNORE_SMODES;
else if (!strncmp(type, "JOINS", len))
ret = IGNORE_JOINS;
else if (!strncmp(type, "TOPICS", len))
ret = IGNORE_TOPICS;
else if (!strncmp(type, "QUITS", len))
ret = IGNORE_QUITS;
else if (!strncmp(type, "CRAP", len))
ret = IGNORE_CRAP;
else if (!strncmp(type, "PARTS", len))
ret = IGNORE_PARTS;
else if (!strncmp(type, "NICKS", len))
ret = IGNORE_NICKS;
else if (!strncmp(type, "PONGS", len))
ret = IGNORE_PONGS;
else if (!strncmp(type, "SPLITS", len))
ret = IGNORE_SPLITS;
else if (!strncmp(type, "NONE", len))
ret = 0;
return ret;
}
#define HANDLE_TYPE(x, y) \
if ((tmp->dont & x) == x) \
strmcat(buffer, " DONT-" y, BIG_BUFFER_SIZE); \
else if ((tmp->type & x) == x) \
strmcat(buffer, " " y, BIG_BUFFER_SIZE); \
else if ((tmp->high & x) == x) \
strmopencat(buffer, BIG_BUFFER_SIZE, space, high, y, high, NULL);
char *get_ignore_types (Ignore *tmp)
{
static char buffer[BIG_BUFFER_SIZE + 1];
char *high = highlight_char;
*buffer = 0;
HANDLE_TYPE(IGNORE_ALL, "ALL")
else
{
HANDLE_TYPE(IGNORE_MSGS, "MSGS")
HANDLE_TYPE(IGNORE_PUBLIC, "PUBLIC")
HANDLE_TYPE(IGNORE_WALLS, "WALLS")
HANDLE_TYPE(IGNORE_WALLOPS, "WALLOPS")
HANDLE_TYPE(IGNORE_INVITES, "INVITES")
HANDLE_TYPE(IGNORE_NOTICES, "NOTICES")
HANDLE_TYPE(IGNORE_NOTES, "NOTES")
HANDLE_TYPE(IGNORE_CTCPS, "CTCPS")
HANDLE_TYPE(IGNORE_TOPICS, "TOPICS")
HANDLE_TYPE(IGNORE_NICKS, "NICKS")
HANDLE_TYPE(IGNORE_JOINS, "JOINS")
HANDLE_TYPE(IGNORE_CRAP, "CRAP")
}
return buffer;
}
int ignore_exception(Ignore *old, char *args)
{
Ignore *new = NULL;
int flag = 0;
if (args && !(new = (Ignore *)list_lookup((List **)&old->except, args, !USE_WILDCARDS, !REMOVE_FROM_LIST)))
{
new = new_malloc(sizeof(Ignore));
malloc_strcpy(&new->nick, args);
add_to_list((List **)&old->except, (List *)new);
flag = DONT_IGNORE;
bitchsay(" EXCEPT %s", new->nick);
}
return flag;
}
/*
* ignore: does the /IGNORE command. Figures out what type of ignoring the
* user wants to do and calls the proper ignore command to do it.
*/
BUILT_IN_COMMAND(ignore)
{
char *nick,
*type;
int len,
flag,
no_flags;
long ret;
if ((nick = next_arg(args, &args)) != NULL)
{
no_flags = 1;
while ((type = next_arg(args, &args)) != NULL)
{
no_flags = 0;
upper(type);
switch (*type)
{
case '^':
flag = IGNORE_DONT;
type++;
break;
case '-':
flag = IGNORE_REMOVE;
type++;
break;
case '+':
flag = IGNORE_HIGH;
type++;
break;
case '%':
flag = IGNORE_CGREP;
type++;
break;
default:
flag = 0;
break;
}
if (!(len = strlen(type)))
{
say("You must specify one of the following:");
say("\tALL MSGS PUBLIC WALLS WALLOPS INVITES \
NOTICES NOTES CTCPS CDCC KICKS MODES SMODES JOINS TOPICS QUITS PARTS NICKS PONGS SQUITS CRAP NONE");
return;
}
if (!strncmp(type, "NONE", len))
{
char *ptr;
while (nick)
{
if ((ptr = strchr(nick, ',')) != NULL)
*ptr = 0;
if (*nick)
remove_ignore(nick);
if (ptr)
*(ptr++) = ',';
nick = ptr;
}
}
else if (!strncmp(type, "EXCEPT", len) && new_ignore)
{
while ((nick = next_arg(args, &args)))
flag = ignore_exception(new_ignore, nick);
}
else if ((flag == IGNORE_CGREP) && ((ret = ignore_type(type, len)) != -1))
add_channel_grep(nick, args, ret);
else if ((ret = ignore_type(type, len)) != -1)
ignore_nickname(nick, ret, flag);
else
{
bitchsay("You must specify one of the following:");
say("\tALL MSGS PUBLIC WALLS WALLOPS INVITES \
NOTICES NOTES CTCPS CDCC KICKS MODES SMODES JOINS TOPICS QUITS PARTS NICKS PONGS SQUITS CRAP NONE");
}
}
if (no_flags)
ignore_list(nick);
new_ignore = NULL;
} else
ignore_list(NULL);
}
/*
* set_highlight_char: what the name says.. the character to use
* for highlighting.. either BOLD, INVERSE, or UNDERLINE..
*/
void set_highlight_char(Window *win, char *s, int unused)
{
int len = strlen(s);
if (!my_strnicmp(s, "BOLD", len))
malloc_strcpy(&highlight_char, BOLD_TOG_STR);
else if (!my_strnicmp(s, "INVERSE", len))
malloc_strcpy(&highlight_char, REV_TOG_STR);
else if (!my_strnicmp(s, "UNDERLINE", len))
malloc_strcpy(&highlight_char, UND_TOG_STR);
else
malloc_strcpy(&highlight_char, s);
}
/* check_ignore -- replaces the old double_ignore
* Why did i change the name?
* * double_ignore isnt really applicable any more becuase it doesnt
* do two ignore lookups, it only does one.
* * This function doesnt look anything like the old double_ignore
* * This function works for the new *!*@* patterns stored by
* ignore instead of the old nick and userhost patterns.
* (jfn may 1995)
*/
int check_ignore (char *nick, char *userhost, char *channel, long type, char *str)
{
char *nickuserhost = NULL;
Ignore *tmp;
malloc_sprintf(&nickuserhost, "%s!%s", nick ? nick : "*", userhost ? userhost : "*");
if (ignored_nicks)
{
if ((tmp = (Ignore *) list_lookup((List **)&ignored_nicks, nickuserhost, USE_WILDCARDS, !REMOVE_FROM_LIST)))
{
if (tmp->except && list_lookup((List **)&tmp->except, nickuserhost, USE_WILDCARDS, !REMOVE_FROM_LIST))
{
new_free(&nickuserhost);
return(DONT_IGNORE);
}
new_free(&nickuserhost);
if (tmp->dont & type)
return(DONT_IGNORE);
if (tmp->type & type)
return (IGNORED);
if (tmp->high & type)
return (HIGHLIGHTED);
}
new_free(&nickuserhost);
if (channel && is_channel(channel) && (tmp = (Ignore *) list_lookup((List **)&ignored_nicks, channel, USE_WILDCARDS, !REMOVE_FROM_LIST)))
{
if (tmp->dont & type)
return(DONT_IGNORE);
if (tmp->type & type)
return (IGNORED);
if (tmp->high & type)
return (HIGHLIGHTED);
if ((tmp->cgrep & type) && str)
{
Ignore *t;
for (t = tmp->looking; t; t = t->next)
{
if (stristr(str, t->nick))
return DONT_IGNORE;
}
return IGNORED;
}
}
}
new_free(&nickuserhost);
return (DONT_IGNORE);
}
/* Written by hop in April 1995 -- taken from SIRP */
/* MALLOCED */
static char *cut_n_fix_glob ( char *nickuserhost )
{
char *nick, *userhost = NULL,
*user = NULL, *host = NULL;
char *copy = NULL;
/* patch by texaco makes this work right */
copy = LOCAL_COPY(nickuserhost);
nick = copy;
if ((userhost = strchr(copy, '!')))
{
/* NICK IS CORRECT HERE */
*userhost++ = 0;
/* doh! */
user = userhost;
if ((host = sindex(userhost, "@")))
/* USER IS CORRECT HERE */
*host++ = 0;
else if (sindex(userhost, "."))
{
user = "*";
host = userhost;
}
/* fixed by sheik */
if (!user)
user = "*";
if (!host)
host = "*";
}
else
{
user = copy;
if ((host = sindex(user, "@")))
{
nick = "*";
*host++ = 0;
}
else
{
if (sindex(user, "."))
{
nick = "*";
host = user;
user = "*";
}
else
{
nick = user;
user = "*";
host = "*";
}
}
}
return m_opendup(nick, "!", user, "@", host, NULL);
}
void tremove_ignore (char *stuff, char *line)
{
int count = 0;
Ignore *new, *newc, *ex;
char *p;
int except = 0;
if (!line || !*line)
return;
while ((p = next_arg(line, &line)))
{
for (new = ignored_nicks; new; new = newc)
{
newc = new->next;
if (matchmcommand(p, new->num) || !my_stricmp(new->nick, p))
{
for (ex = new->except; ex; ex = ex->next)
except++;
remove_ignore(new->nick);
count++;
}
}
}
if (count)
bitchsay("Removed %d ignores and %d exceptions", count, except);
else
bitchsay("No matching ignore");
for (new = ignored_nicks, count = 1; new; new = new->next, count++)
new->num = count;
}
BUILT_IN_COMMAND(tignore)
{
ignore_list(NULL);
if (ignored_nicks)
{
if (args && *args)
tremove_ignore(NULL, args);
else
add_wait_prompt("Which ignore to delete (-2, 2-5, ...) ? ", tremove_ignore, args, WAIT_PROMPT_LINE, 1);
}
}
/*
* get_ignores_by_pattern: Get all the ignores that match the pattern
* If "covered" is 0, then return all ignores matched by patterns
* If "covered" is 1, then return all ignores that would activate on patterns
* MALLOCED
*/
char *get_ignores_by_pattern (char *patterns, int covered)
{
Ignore *tmp;
char *pattern;
char *retval = NULL;
while ((pattern = new_next_arg(patterns, &patterns)))
{
for (tmp = ignored_nicks; tmp; tmp = tmp->next)
{
if (covered ? wild_match(tmp->nick, pattern)
: wild_match(pattern, tmp->nick))
m_s3cat(&retval, space, tmp->nick);
}
}
return retval ? retval : m_strdup(empty_string);
}
int get_type_by_desc (char *type, int *do_mask, int *dont_mask)
{
char *l1, *l2;
int len;
int *mask = NULL;
*do_mask = *dont_mask = 0;
while (type && *type)
{
l1 = new_next_arg(type, &type);
while (l1 && *l1)
{
l2 = l1;
if ((l1 = strchr(l1, ',')))
*l1++ = 0;
if (*l2 == '!')
{
l2++;
mask = dont_mask;
}
else
mask = do_mask;
if (!(len = strlen(l2)))
continue;
if (!strncmp(l2, "ALL", len))
*mask |= IGNORE_ALL;
else if (!strncmp(l2, "MSGS", len))
*mask |= IGNORE_MSGS;
else if (!strncmp(l2, "PUBLIC", len))
*mask |= IGNORE_PUBLIC;
else if (!strncmp(l2, "WALLS", len))
*mask |= IGNORE_WALLS;
else if (!strncmp(l2, "WALLOPS", len))
*mask |= IGNORE_WALLOPS;
else if (!strncmp(l2, "INVITES", len))
*mask |= IGNORE_INVITES;
else if (!strncmp(l2, "NOTICES", len))
*mask |= IGNORE_NOTICES;
else if (!strncmp(l2, "NOTES", len))
*mask |= IGNORE_NOTES;
else if (!strncmp(l2, "CTCPS", len))
*mask |= IGNORE_CTCPS;
else if (!strncmp(l2, "TOPICS", len))
*mask |= IGNORE_TOPICS;
else if (!strncmp(l2, "NICKS", len))
*mask |= IGNORE_NICKS;
else if (!strncmp(l2, "JOINS", len))
*mask |= IGNORE_JOINS;
else if (!strncmp(l2, "CRAP", len))
*mask |= IGNORE_CRAP;
}
}
return 0;
}
/*
* This is nasty and should be done in a more generalized way, but until
* then, this function just does what has to be done. Please note that
* if you go to the pains to re-write the ignore handling, please do fix
* this to work the right way, please? =)
*/
char *get_ignore_types_by_pattern (char *pattern)
{
Ignore *tmp;
upper(pattern);
for (tmp = ignored_nicks; tmp; tmp = tmp->next)
{
if (!strcmp(tmp->nick, pattern))
return get_ignore_types(tmp);
}
return empty_string;
}
char *get_ignore_patterns_by_type (char *ctype)
{
Ignore *tmp;
int do_mask = 0, dont_mask = 0;
char *result = NULL;
/*
* Convert the user's input into something we can use.
* If the user doesnt specify anything useful, then we
* just punt right here.
*/
upper(ctype);
get_type_by_desc(ctype, &do_mask, &dont_mask);
if (do_mask == 0 && dont_mask == 0)
return m_strdup(empty_string);
for (tmp = ignored_nicks; tmp; tmp = tmp->next)
{
/*
* Any "negative ignore" bits, if any, must be present.
*/
if ((tmp->dont & dont_mask) != dont_mask)
continue;
/*
* Any "positive ignore" bits, if any, must be present,
* but there must not be a corresponding "negative ignore"
* bit for the levels as well. That is to say, the
* negative ignore bits "turn off" any corresponding bits
* in the positive ignore set.
*/
if (((tmp->type & ~tmp->dont) & do_mask) != do_mask)
continue;
/* Add it to the fray */
m_s3cat(&result, space, tmp->nick);
}
return result;
}
|