| 79 |
|
* \param reply Numeric to send. Either RPL_LOGON or RPL_LOGOFF |
| 80 |
|
*/ |
| 81 |
|
void |
| 82 |
< |
watch_check_hash(struct Client *client_p, const enum irc_numerics reply) |
| 82 |
> |
watch_check_hash(const struct Client *client_p, const enum irc_numerics reply) |
| 83 |
|
{ |
| 84 |
< |
struct Watch *anptr = NULL; |
| 85 |
< |
dlink_node *ptr = NULL; |
| 84 |
> |
struct Watch *watch = NULL; |
| 85 |
> |
dlink_node *node = NULL; |
| 86 |
|
|
| 87 |
|
assert(IsClient(client_p)); |
| 88 |
|
|
| 89 |
< |
if ((anptr = watch_find_hash(client_p->name)) == NULL) |
| 89 |
> |
if ((watch = watch_find_hash(client_p->name)) == NULL) |
| 90 |
|
return; /* This nick isn't on watch */ |
| 91 |
|
|
| 92 |
|
/* Update the time of last change to item */ |
| 93 |
< |
anptr->lasttime = CurrentTime; |
| 93 |
> |
watch->lasttime = CurrentTime; |
| 94 |
|
|
| 95 |
|
/* Send notifies out to everybody on the list in header */ |
| 96 |
< |
DLINK_FOREACH(ptr, anptr->watched_by.head) |
| 97 |
< |
sendto_one_numeric(ptr->data, &me, reply, client_p->name, |
| 96 |
> |
DLINK_FOREACH(node, watch->watched_by.head) |
| 97 |
> |
sendto_one_numeric(node->data, &me, reply, client_p->name, |
| 98 |
|
client_p->username, client_p->host, |
| 99 |
< |
anptr->lasttime, client_p->info); |
| 99 |
> |
watch->lasttime, client_p->info); |
| 100 |
|
} |
| 101 |
|
|
| 102 |
|
/*! \brief Looks up the watch table for a given nick |
| 105 |
|
struct Watch * |
| 106 |
|
watch_find_hash(const char *name) |
| 107 |
|
{ |
| 108 |
< |
dlink_node *ptr = NULL; |
| 108 |
> |
dlink_node *node = NULL; |
| 109 |
|
|
| 110 |
< |
DLINK_FOREACH(ptr, watchTable[strhash(name)].head) |
| 110 |
> |
DLINK_FOREACH(node, watchTable[strhash(name)].head) |
| 111 |
|
{ |
| 112 |
< |
struct Watch *anptr = ptr->data; |
| 112 |
> |
struct Watch *watch = node->data; |
| 113 |
|
|
| 114 |
< |
if (!irccmp(anptr->nick, name)) |
| 115 |
< |
return anptr; |
| 114 |
> |
if (!irccmp(watch->nick, name)) |
| 115 |
> |
return watch; |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
return NULL; |
| 125 |
|
void |
| 126 |
|
watch_add_to_hash_table(const char *nick, struct Client *client_p) |
| 127 |
|
{ |
| 128 |
< |
struct Watch *anptr = NULL; |
| 129 |
< |
dlink_node *ptr = NULL; |
| 128 |
> |
struct Watch *watch = NULL; |
| 129 |
> |
dlink_node *node = NULL; |
| 130 |
|
|
| 131 |
|
/* If found NULL (no header for this nick), make one... */ |
| 132 |
< |
if ((anptr = watch_find_hash(nick)) == NULL) |
| 132 |
> |
if ((watch = watch_find_hash(nick)) == NULL) |
| 133 |
|
{ |
| 134 |
< |
anptr = mp_pool_get(watch_pool); |
| 134 |
> |
watch = mp_pool_get(watch_pool); |
| 135 |
|
|
| 136 |
< |
anptr->lasttime = CurrentTime; |
| 137 |
< |
strlcpy(anptr->nick, nick, sizeof(anptr->nick)); |
| 136 |
> |
watch->lasttime = CurrentTime; |
| 137 |
> |
strlcpy(watch->nick, nick, sizeof(watch->nick)); |
| 138 |
|
|
| 139 |
< |
dlinkAdd(anptr, &anptr->node, &watchTable[strhash(anptr->nick)]); |
| 139 |
> |
dlinkAdd(watch, &watch->node, &watchTable[strhash(watch->nick)]); |
| 140 |
|
} |
| 141 |
|
else |
| 142 |
|
{ |
| 143 |
|
/* Is this client already on the watch-list? */ |
| 144 |
< |
ptr = dlinkFind(&anptr->watched_by, client_p); |
| 144 |
> |
node = dlinkFind(&watch->watched_by, client_p); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
< |
if (ptr == NULL) |
| 147 |
> |
if (node == NULL) |
| 148 |
|
{ |
| 149 |
|
/* No it isn't, so add it in the bucket and client adding it */ |
| 150 |
< |
dlinkAdd(client_p, make_dlink_node(), &anptr->watched_by); |
| 151 |
< |
dlinkAdd(anptr, make_dlink_node(), &client_p->connection->watches); |
| 150 |
> |
dlinkAdd(client_p, make_dlink_node(), &watch->watched_by); |
| 151 |
> |
dlinkAdd(watch, make_dlink_node(), &client_p->connection->watches); |
| 152 |
|
} |
| 153 |
|
} |
| 154 |
|
|
| 159 |
|
void |
| 160 |
|
watch_del_from_hash_table(const char *nick, struct Client *client_p) |
| 161 |
|
{ |
| 162 |
< |
struct Watch *anptr = NULL; |
| 163 |
< |
dlink_node *ptr = NULL; |
| 162 |
> |
struct Watch *watch = NULL; |
| 163 |
> |
dlink_node *node = NULL; |
| 164 |
|
|
| 165 |
< |
if ((anptr = watch_find_hash(nick)) == NULL) |
| 165 |
> |
if ((watch = watch_find_hash(nick)) == NULL) |
| 166 |
|
return; /* No header found for that nick. i.e. it's not being watched */ |
| 167 |
|
|
| 168 |
< |
if ((ptr = dlinkFind(&anptr->watched_by, client_p)) == NULL) |
| 168 |
> |
if ((node = dlinkFind(&watch->watched_by, client_p)) == NULL) |
| 169 |
|
return; /* This nick isn't being watched by client_p */ |
| 170 |
|
|
| 171 |
< |
dlinkDelete(ptr, &anptr->watched_by); |
| 172 |
< |
free_dlink_node(ptr); |
| 171 |
> |
dlinkDelete(node, &watch->watched_by); |
| 172 |
> |
free_dlink_node(node); |
| 173 |
|
|
| 174 |
< |
if ((ptr = dlinkFindDelete(&client_p->connection->watches, anptr))) |
| 175 |
< |
free_dlink_node(ptr); |
| 174 |
> |
if ((node = dlinkFindDelete(&client_p->connection->watches, watch))) |
| 175 |
> |
free_dlink_node(node); |
| 176 |
|
|
| 177 |
|
/* In case this header is now empty of notices, remove it */ |
| 178 |
< |
if (anptr->watched_by.head == NULL) |
| 178 |
> |
if (watch->watched_by.head == NULL) |
| 179 |
|
{ |
| 180 |
< |
assert(dlinkFind(&watchTable[strhash(anptr->nick)], anptr)); |
| 181 |
< |
dlinkDelete(&anptr->node, &watchTable[strhash(anptr->nick)]); |
| 182 |
< |
mp_pool_release(anptr); |
| 180 |
> |
assert(dlinkFind(&watchTable[strhash(watch->nick)], watch)); |
| 181 |
> |
dlinkDelete(&watch->node, &watchTable[strhash(watch->nick)]); |
| 182 |
> |
mp_pool_release(watch); |
| 183 |
|
} |
| 184 |
|
} |
| 185 |
|
|
| 190 |
|
void |
| 191 |
|
watch_del_watch_list(struct Client *client_p) |
| 192 |
|
{ |
| 193 |
< |
dlink_node *ptr = NULL, *ptr_next = NULL; |
| 194 |
< |
dlink_node *tmp = NULL; |
| 193 |
> |
dlink_node *node = NULL, *node_next = NULL; |
| 194 |
> |
dlink_node *temp = NULL; |
| 195 |
|
|
| 196 |
< |
DLINK_FOREACH_SAFE(ptr, ptr_next, client_p->connection->watches.head) |
| 196 |
> |
DLINK_FOREACH_SAFE(node, node_next, client_p->connection->watches.head) |
| 197 |
|
{ |
| 198 |
< |
struct Watch *anptr = ptr->data; |
| 198 |
> |
struct Watch *watch = node->data; |
| 199 |
|
|
| 200 |
< |
assert(dlinkFind(&anptr->watched_by, client_p)); |
| 200 |
> |
assert(dlinkFind(&watch->watched_by, client_p)); |
| 201 |
|
|
| 202 |
< |
if ((tmp = dlinkFindDelete(&anptr->watched_by, client_p))) |
| 203 |
< |
free_dlink_node(tmp); |
| 202 |
> |
if ((temp = dlinkFindDelete(&watch->watched_by, client_p))) |
| 203 |
> |
free_dlink_node(temp); |
| 204 |
|
|
| 205 |
|
/* If this leaves a header without notifies, remove it. */ |
| 206 |
< |
if (anptr->watched_by.head == NULL) |
| 206 |
> |
if (watch->watched_by.head == NULL) |
| 207 |
|
{ |
| 208 |
< |
assert(dlinkFind(&watchTable[strhash(anptr->nick)], anptr)); |
| 209 |
< |
dlinkDelete(&anptr->node, &watchTable[strhash(anptr->nick)]); |
| 208 |
> |
assert(dlinkFind(&watchTable[strhash(watch->nick)], watch)); |
| 209 |
> |
dlinkDelete(&watch->node, &watchTable[strhash(watch->nick)]); |
| 210 |
|
|
| 211 |
< |
mp_pool_release(anptr); |
| 211 |
> |
mp_pool_release(watch); |
| 212 |
|
} |
| 213 |
|
|
| 214 |
< |
dlinkDelete(ptr, &client_p->connection->watches); |
| 215 |
< |
free_dlink_node(ptr); |
| 214 |
> |
dlinkDelete(node, &client_p->connection->watches); |
| 215 |
> |
free_dlink_node(node); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
assert(client_p->connection->watches.head == NULL); |