| 22 |
|
|
| 23 |
|
/*! \file watch.c |
| 24 |
|
* \brief File including functions for WATCH support |
| 25 |
< |
* \version $Id: watch.c 801 2006-08-30 16:54:25Z adx $ |
| 25 |
> |
* \version $Id$ |
| 26 |
|
*/ |
| 27 |
|
|
| 28 |
|
#include "stdinc.h" |
| 29 |
< |
#include "tools.h" |
| 29 |
> |
#include "list.h" |
| 30 |
> |
#include "balloc.h" |
| 31 |
|
#include "s_user.h" |
| 32 |
|
#include "s_misc.h" |
| 33 |
|
#include "client.h" |
| 33 |
– |
#include "common.h" |
| 34 |
|
#include "hash.h" |
| 35 |
|
#include "irc_string.h" |
| 36 |
|
#include "sprintf_irc.h" |
| 37 |
|
#include "ircd.h" |
| 38 |
– |
#include "list.h" |
| 39 |
– |
#include "listener.h" |
| 40 |
– |
#include "motd.h" |
| 38 |
|
#include "numeric.h" |
| 39 |
< |
#include "s_conf.h" |
| 43 |
< |
#include "s_log.h" |
| 39 |
> |
#include "conf.h" |
| 40 |
|
#include "s_serv.h" |
| 45 |
– |
#include "s_stats.h" |
| 41 |
|
#include "send.h" |
| 42 |
|
#include "supported.h" |
| 43 |
|
#include "whowas.h" |
| 44 |
|
#include "memory.h" |
| 45 |
|
#include "packet.h" |
| 51 |
– |
#include "s_misc.h" |
| 52 |
– |
#include "msg.h" |
| 46 |
|
#include "watch.h" |
| 47 |
|
|
| 48 |
|
#define WATCH_HEAP_SIZE 32 |
| 56 |
|
void |
| 57 |
|
watch_init(void) |
| 58 |
|
{ |
| 66 |
– |
memset(watchTable, 0, sizeof(watchTable)); |
| 67 |
– |
|
| 59 |
|
watch_heap = BlockHeapCreate("watch", sizeof(struct Watch), WATCH_HEAP_SIZE); |
| 60 |
|
} |
| 61 |
|
|
| 75 |
|
/*! \brief Counts up memory used by watch list headers |
| 76 |
|
*/ |
| 77 |
|
void |
| 78 |
< |
watch_count_memory(unsigned int *const count, size_t *const memory) |
| 78 |
> |
watch_count_memory(unsigned int *const count, uint64_t *const memory) |
| 79 |
|
{ |
| 80 |
|
unsigned int idx; |
| 81 |
|
|
| 97 |
|
dlink_node *ptr = NULL; |
| 98 |
|
assert(IsClient(client_p)); |
| 99 |
|
if ((anptr = watch_find_hash(client_p->name)) == NULL) |
| 100 |
< |
return; // This nick isn't on watch |
| 100 |
> |
return; /* This nick isn't on watch */ |
| 101 |
|
|
| 102 |
< |
// Update the time of last change to item |
| 102 |
> |
/* Update the time of last change to item */ |
| 103 |
|
anptr->lasttime = CurrentTime; |
| 104 |
|
|
| 105 |
< |
// Send notifies out to everybody on the list in header |
| 105 |
> |
/* Send notifies out to everybody on the list in header */ |
| 106 |
|
DLINK_FOREACH(ptr, anptr->watched_by.head) |
| 107 |
|
{ |
| 108 |
|
struct Client *target_p = ptr->data; |
| 143 |
|
struct Watch *anptr = NULL; |
| 144 |
|
dlink_node *ptr = NULL; |
| 145 |
|
|
| 146 |
< |
// If found NULL (no header for this nick), make one... |
| 146 |
> |
/* If found NULL (no header for this nick), make one... */ |
| 147 |
|
if ((anptr = watch_find_hash(nick)) == NULL) |
| 148 |
|
{ |
| 149 |
|
anptr = BlockHeapAlloc(watch_heap); |
| 154 |
|
} |
| 155 |
|
else |
| 156 |
|
{ |
| 157 |
< |
// Is this client already on the watch-list? |
| 157 |
> |
/* Is this client already on the watch-list? */ |
| 158 |
|
ptr = dlinkFind(&anptr->watched_by, client_p); |
| 159 |
|
} |
| 160 |
|
|
| 161 |
|
if (ptr == NULL) |
| 162 |
|
{ |
| 163 |
< |
// No it isn't, so add it in the bucket and client addint it |
| 163 |
> |
/* No it isn't, so add it in the bucket and client addint it */ |
| 164 |
|
dlinkAdd(client_p, make_dlink_node(), &anptr->watched_by); |
| 165 |
|
dlinkAdd(anptr, make_dlink_node(), &client_p->localClient->watches); |
| 166 |
|
} |
| 177 |
|
dlink_node *ptr = NULL; |
| 178 |
|
|
| 179 |
|
if ((anptr = watch_find_hash(nick)) == NULL) |
| 180 |
< |
return; // No header found for that nick. i.e. it's not being watched |
| 180 |
> |
return; /* No header found for that nick. i.e. it's not being watched */ |
| 181 |
|
|
| 182 |
|
if ((ptr = dlinkFind(&anptr->watched_by, client_p)) == NULL) |
| 183 |
< |
return; // This nick isn't being watched by client_p |
| 183 |
> |
return; /* This nick isn't being watched by client_p */ |
| 184 |
|
|
| 185 |
|
dlinkDelete(ptr, &anptr->watched_by); |
| 186 |
|
free_dlink_node(ptr); |
| 188 |
|
if ((ptr = dlinkFindDelete(&client_p->localClient->watches, anptr))) |
| 189 |
|
free_dlink_node(ptr); |
| 190 |
|
|
| 191 |
< |
// In case this header is now empty of notices, remove it |
| 191 |
> |
/* In case this header is now empty of notices, remove it */ |
| 192 |
|
if (anptr->watched_by.head == NULL) |
| 193 |
|
{ |
| 194 |
|
assert(dlinkFind(&watchTable[strhash(nick)], anptr) != NULL); |
| 217 |
|
if ((tmp = dlinkFindDelete(&anptr->watched_by, client_p))) |
| 218 |
|
free_dlink_node(tmp); |
| 219 |
|
|
| 220 |
< |
// If this leaves a header without notifies, remove it. |
| 220 |
> |
/* If this leaves a header without notifies, remove it. */ |
| 221 |
|
if (anptr->watched_by.head == NULL) |
| 222 |
|
{ |
| 223 |
|
assert(dlinkFind(&watchTable[strhash(anptr->nick)], anptr) != NULL); |