Add *_metadata_clear and start using them.

This commit is contained in:
B.Greenham 2010-03-05 00:39:18 -05:00
parent 104becbf7f
commit 8bced6dc39
5 changed files with 42 additions and 8 deletions

View File

@ -313,6 +313,7 @@ extern struct Metadata *channel_metadata_add(struct Channel *target, const char
extern struct Metadata *channel_metadata_time_add(struct Channel *target, const char *name, time_t value);
extern void channel_metadata_delete(struct Channel *target, const char *name, int propegate);
extern struct Metadata *channel_metadata_find(struct Channel *target, const char *name);
extern void channel_metadata_clear(struct Channel *target);
#endif /* INCLUDED_channel_h */

View File

@ -624,5 +624,6 @@ void free_away(struct Client *);
extern struct Metadata *user_metadata_add(struct Client *target, const char *name, const char *value, int propegate);
extern void user_metadata_delete(struct Client *target, const char *name, int propegate);
extern struct Metadata *user_metadata_find(struct Client *target, const char *name);
extern void user_metadata_clear(struct Client *target);
#endif /* INCLUDED_client_h */

View File

@ -105,7 +105,7 @@ allocate_channel(const char *chname)
void
free_channel(struct Channel *chptr)
{
channel_metadata_delete(chptr, "NOREPEAT", 0);
channel_metadata_clear(chptr);
rb_free(chptr->chname);
rb_bh_free(channel_heap, chptr);
}
@ -2016,3 +2016,22 @@ channel_metadata_find(struct Channel *target, const char *name)
return irc_dictionary_retrieve(target->c_metadata, name);
}
/*
* channel_metadata_clear
*
* inputs - pointer to channel struct
* output - none
* side effects - metadata is cleared from the channel in question
*/
void
channel_metadata_clear(struct Channel *chptr)
{
struct Metadata *md;
struct DictionaryIter iter;
DICTIONARY_FOREACH(md, &iter, chptr->c_metadata)
{
channel_metadata_delete(chptr, md->name, 0);
}
}

View File

@ -1710,12 +1710,7 @@ free_user(struct User *user, struct Client *client_p)
free_away(client_p);
/* get rid of any metadata the user may have */
if(IsOper(client_p))
{
user_metadata_delete(client_p, "swhois", 0);
user_metadata_delete(client_p, "operstring", 0);
}
user_metadata_delete(client_p, "OACCEPT", 0);
user_metadata_clear(client_p);
if(--user->refcnt <= 0)
{
@ -2015,3 +2010,21 @@ user_metadata_find(struct Client *target, const char *name)
return irc_dictionary_retrieve(target->user->metadata, name);
}
/*
* user_metadata_clear
*
* inputs - pointer to user struct
* output - none
* side effects - metadata is cleared from the user in question
*/
void
user_metadata_clear(struct Client *target)
{
struct Metadata *md;
struct DictionaryIter iter;
DICTIONARY_FOREACH(md, &iter, target->user->metadata)
{
user_metadata_delete(target, md->name, 0);
}
}

View File

@ -591,7 +591,7 @@ burst_TS6(struct Client *client_p)
{
/* don't bother bursting +J metadata */
if(!(md->name[0] == 'K'))
sendto_one(client_p, ":%s ENCAP * METADATA ADD %s %s :%s",
sendto_one(&me, ":%s ENCAP * METADATA ADD %s %s :%s",
use_id(target_p), use_id(target_p), md->name, md->value);
}