Add new constants for presence key/value lengths

instead of overloading NICKLEN/TOPICLEN.
This commit is contained in:
Jilles Tjoelker 2009-06-03 23:38:07 +02:00
parent 553aaaf4db
commit 7919c03041
3 changed files with 12 additions and 5 deletions

View file

@ -121,8 +121,8 @@ struct ZipStats
struct MetadataEntry struct MetadataEntry
{ {
char key[NICKLEN+1]; char key[METADATAKEYLEN];
char value[TOPICLEN]; char value[METADATAVALUELEN];
}; };
struct Client struct Client

View file

@ -111,6 +111,13 @@
#define BANREASONLEN 390 /* kline/dline */ #define BANREASONLEN 390 /* kline/dline */
#define AWAYLEN TOPICLEN #define AWAYLEN TOPICLEN
#define KILLLEN 200 /* with Killed (nick ()) added this should fit in quit */ #define KILLLEN 200 /* with Killed (nick ()) added this should fit in quit */
#define METADATAKEYLEN 31
/* :012345678901234567890123456789012345678901234567890123456789123 792 * 012345678901234567890123456789 012345678901234567890123456789 :
* takes at most 137 bytes
* :123456789 ENCAP * PRESENCE 012345678901234567890123456789 :
* takes at most 63 bytes
* */
#define METADATAVALUELEN 300
/* 23+1 for \0 */ /* 23+1 for \0 */
#define KEYLEN 24 #define KEYLEN 24

View file

@ -1753,15 +1753,15 @@ set_metadata(struct Client *client_p, const char *key, const char *value)
if (md == NULL) if (md == NULL)
{ {
md = rb_bh_alloc(metadata_heap); md = rb_bh_alloc(metadata_heap);
rb_strlcpy(md->key, key, NICKLEN); rb_strlcpy(md->key, key, sizeof md->key);
irc_dictionary_add(client_p->user->metadata, md->key, md); irc_dictionary_add(client_p->user->metadata, md->key, md);
} }
else if (!strcmp(md->key, key) && !strcmp(md->value, value)) else if (!strcmp(md->key, key) && !strcmp(md->value, value))
return; return;
else else
rb_strlcpy(md->key, key, NICKLEN); rb_strlcpy(md->key, key, sizeof md->key);
rb_strlcpy(md->value, value, TOPICLEN); rb_strlcpy(md->value, value, sizeof md->value);
} }
sendto_common_channels_local_with_capability(client_p, CLICAP_PRESENCE, form_str(RPL_METADATACHG), me.name, client_p->name, key, value); sendto_common_channels_local_with_capability(client_p, CLICAP_PRESENCE, form_str(RPL_METADATACHG), me.name, client_p->name, key, value);