}
}
+static void updateNuh(struct client_data *client) {
+ char *n = client->nick ? client->nick : "*";
+ char *u = client->username ? client->username : "*";
+ char *h = client->hostname;
+ free(client->nuh);
+ client->nuh = malloc(strlen(n) + strlen(u) + strlen(h) + 3);
+ if (!client->nuh)
+ abort();
+ sprintf(client->nuh, "%s!%s@%s", n, u, h);
+ stringlower(client->nuh);
+}
void setNick(struct client_data *client, char* nickname) {
// TODO: perform basic sanitization
client->nick = mystrdup(nickname);
if (!client->nick)
abort();
- client->nuh = malloc(strlen(client->nick) + strlen(client->username) + strlen(client->hostname) + 3);
- if (!client->nuh)
- abort();
- sprintf(client->nuh, "%s!%s@%s", client->nick, client->username, client->hostname);
- stringlower(client->nuh);
+ updateNuh(client);
client->key = mystrdup(key);
if (!client->key)
abort();
abort();
}
// update nuh
- {
- char *n = client->nick ? client->nick : "*";
- char *u = client->username ? client->username : "*";
- char *h = client->hostname;
- free(client->nuh);
- client->nuh = malloc(strlen(n) + strlen(u) + strlen(h) + 3);
- if (!client->nuh)
- abort();
- sprintf(client->nuh, "%s!%s@%s", n, u, h);
- stringlower(client->nuh);
- }
+ updateNuh(client);
// now we have to simulate rejoins for clients without chghost support
if (is_registered(client)) {