| 45 |
|
|
| 46 |
|
static BlockHeap *userhost_heap = NULL; |
| 47 |
|
static BlockHeap *namehost_heap = NULL; |
| 48 |
– |
static struct UserHost *find_or_add_userhost(const char *); |
| 48 |
|
|
| 49 |
|
static unsigned int hashf_xor_key = 0; |
| 50 |
|
|
| 606 |
|
} |
| 607 |
|
} |
| 608 |
|
|
| 609 |
+ |
/* find_or_add_userhost() |
| 610 |
+ |
* |
| 611 |
+ |
* inputs - host name |
| 612 |
+ |
* output - none |
| 613 |
+ |
* side effects - find UserHost * for given host name |
| 614 |
+ |
*/ |
| 615 |
+ |
static struct UserHost * |
| 616 |
+ |
find_or_add_userhost(const char *host) |
| 617 |
+ |
{ |
| 618 |
+ |
struct UserHost *userhost; |
| 619 |
+ |
|
| 620 |
+ |
if ((userhost = hash_find_userhost(host)) != NULL) |
| 621 |
+ |
return userhost; |
| 622 |
+ |
|
| 623 |
+ |
userhost = BlockHeapAlloc(userhost_heap); |
| 624 |
+ |
strlcpy(userhost->host, host, sizeof(userhost->host)); |
| 625 |
+ |
hash_add_userhost(userhost); |
| 626 |
+ |
|
| 627 |
+ |
return userhost; |
| 628 |
+ |
} |
| 629 |
+ |
|
| 630 |
|
/* add_user_host() |
| 631 |
|
* |
| 632 |
|
* inputs - user name |
| 659 |
|
if (!irccmp(user, nameh->name)) |
| 660 |
|
{ |
| 661 |
|
nameh->gcount++; |
| 662 |
+ |
|
| 663 |
|
if (!global) |
| 664 |
|
{ |
| 665 |
< |
if (hasident) |
| 666 |
< |
nameh->icount++; |
| 667 |
< |
nameh->lcount++; |
| 665 |
> |
if (hasident) |
| 666 |
> |
nameh->icount++; |
| 667 |
> |
nameh->lcount++; |
| 668 |
|
} |
| 669 |
+ |
|
| 670 |
|
return; |
| 671 |
|
} |
| 672 |
|
} |
| 675 |
|
strlcpy(nameh->name, user, sizeof(nameh->name)); |
| 676 |
|
|
| 677 |
|
nameh->gcount = 1; |
| 678 |
+ |
|
| 679 |
|
if (!global) |
| 680 |
|
{ |
| 681 |
|
if (hasident) |
| 721 |
|
nameh->gcount--; |
| 722 |
|
if (!global) |
| 723 |
|
{ |
| 724 |
< |
if (nameh->lcount > 0) |
| 725 |
< |
nameh->lcount--; |
| 726 |
< |
if (hasident && nameh->icount > 0) |
| 727 |
< |
nameh->icount--; |
| 724 |
> |
if (nameh->lcount > 0) |
| 725 |
> |
nameh->lcount--; |
| 726 |
> |
if (hasident && nameh->icount > 0) |
| 727 |
> |
nameh->icount--; |
| 728 |
|
} |
| 729 |
|
|
| 730 |
|
if (nameh->gcount == 0 && nameh->lcount == 0) |
| 731 |
|
{ |
| 732 |
< |
dlinkDelete(&nameh->node, &found_userhost->list); |
| 733 |
< |
BlockHeapFree(namehost_heap, nameh); |
| 732 |
> |
dlinkDelete(&nameh->node, &found_userhost->list); |
| 733 |
> |
BlockHeapFree(namehost_heap, nameh); |
| 734 |
|
} |
| 735 |
|
|
| 736 |
|
if (dlink_list_length(&found_userhost->list) == 0) |
| 737 |
|
{ |
| 738 |
< |
hash_del_userhost(found_userhost); |
| 739 |
< |
BlockHeapFree(userhost_heap, found_userhost); |
| 738 |
> |
hash_del_userhost(found_userhost); |
| 739 |
> |
BlockHeapFree(userhost_heap, found_userhost); |
| 740 |
|
} |
| 741 |
|
|
| 742 |
|
return; |
| 744 |
|
} |
| 745 |
|
} |
| 746 |
|
|
| 724 |
– |
/* find_or_add_userhost() |
| 725 |
– |
* |
| 726 |
– |
* inputs - host name |
| 727 |
– |
* output - none |
| 728 |
– |
* side effects - find UserHost * for given host name |
| 729 |
– |
*/ |
| 730 |
– |
static struct UserHost * |
| 731 |
– |
find_or_add_userhost(const char *host) |
| 732 |
– |
{ |
| 733 |
– |
struct UserHost *userhost; |
| 734 |
– |
|
| 735 |
– |
if ((userhost = hash_find_userhost(host)) != NULL) |
| 736 |
– |
return userhost; |
| 737 |
– |
|
| 738 |
– |
userhost = BlockHeapAlloc(userhost_heap); |
| 739 |
– |
strlcpy(userhost->host, host, sizeof(userhost->host)); |
| 740 |
– |
hash_add_userhost(userhost); |
| 741 |
– |
|
| 742 |
– |
return userhost; |
| 743 |
– |
} |
| 744 |
– |
|
| 747 |
|
/* |
| 748 |
|
* Safe list code. |
| 749 |
|
* |