Changeset f4396c4
- Timestamp:
- 2015-12-06T00:43:14Z (9 years ago)
- Branches:
- master
- Children:
- c54bb11
- Parents:
- ed431c3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
irc_send.c
red431c3 rf4396c4 202 202 } 203 203 204 #define IRC_NAMES_LEN 385 205 204 206 void irc_send_names(irc_channel_t *ic) 205 207 { 206 208 GSList *l; 207 char namelist[385] = "";209 GString *namelist = g_string_sized_new(IRC_NAMES_LEN); 208 210 209 211 /* RFCs say there is no error reply allowed on NAMES, so when the … … 212 214 irc_channel_user_t *icu = l->data; 213 215 irc_user_t *iu = icu->iu; 214 215 if (strlen(namelist) + strlen(iu->nick) > sizeof(namelist) - 4) { 216 irc_send_num(ic->irc, 353, "= %s :%s", ic->name, namelist); 217 *namelist = 0; 218 } 219 220 namelist[strlen(namelist) + 1] = '\0'; 221 namelist[strlen(namelist)] = irc_channel_user_get_prefix(icu); 222 223 strcat(namelist, iu->nick); 224 strcat(namelist, " "); 225 } 226 227 if (*namelist) { 228 irc_send_num(ic->irc, 353, "= %s :%s", ic->name, namelist); 216 size_t extra_len = strlen(iu->nick); 217 char prefix; 218 219 if (namelist->len + extra_len > IRC_NAMES_LEN - 4) { 220 irc_send_num(ic->irc, 353, "= %s :%s", ic->name, namelist->str); 221 g_string_truncate(namelist, 0); 222 } 223 224 if ((prefix = irc_channel_user_get_prefix(icu))) { 225 g_string_append_c(namelist, prefix); 226 } 227 228 g_string_append(namelist, iu->nick); 229 g_string_append_c(namelist, ' '); 230 } 231 232 if (namelist->len) { 233 irc_send_num(ic->irc, 353, "= %s :%s", ic->name, namelist->str); 229 234 } 230 235 231 236 irc_send_num(ic->irc, 366, "%s :End of /NAMES list", ic->name); 237 238 g_string_free(namelist, TRUE); 232 239 } 233 240
Note: See TracChangeset
for help on using the changeset viewer.