X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fclient.c;h=26d4929d732b04ecaaef3c24527465fafbe94160;hp=32690288529499097c0b6d88c1127774202f51bd;hb=1dc93286a0d5b80259604b4f25021fcc5a730b5b;hpb=3af0ece2bcf550cccd7b647c111ce503c2faa459 diff --git a/src/ngircd/client.c b/src/ngircd/client.c index 32690288..26d4929d 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -126,6 +126,10 @@ Client_Exit( void ) next = (CLIENT *)c->next; if (c->account_name) free(c->account_name); + if (c->cloaked) + free(c->cloaked); + if (c->ipa_text) + free(c->ipa_text); free( c ); c = next; } @@ -324,6 +328,8 @@ Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool Sen free(c->account_name); if (c->cloaked) free(c->cloaked); + if (c->ipa_text) + free(c->ipa_text); free( c ); break; } @@ -366,6 +372,27 @@ Client_SetHostname( CLIENT *Client, const char *Hostname ) } /* Client_SetHostname */ +/** + * Set IP address to display for a client. + * + * @param Client The client. + * @param IPAText Textual representation of the IP address or NULL to unset. + */ +GLOBAL void +Client_SetIPAText(CLIENT *Client, const char *IPAText) +{ + assert(Client != NULL); + + if (Client->ipa_text) + free(Client->ipa_text); + + if (*IPAText) + Client->ipa_text = strndup(IPAText, CLIENT_HOST_LEN - 1); + else + Client->ipa_text = NULL; +} + + GLOBAL void Client_SetID( CLIENT *Client, const char *ID ) { @@ -467,7 +494,8 @@ Client_SetAccountName(CLIENT *Client, const char *AccountName) free(Client->account_name); if (*AccountName) - Client->account_name = strdup(AccountName); + Client->account_name = strndup(AccountName, + CLIENT_NICK_LEN - 1); else Client->account_name = NULL; } @@ -786,6 +814,21 @@ Client_HostnameDisplayed(CLIENT *Client) return Client->cloaked; } +GLOBAL const char * +Client_IPAText(CLIENT *Client) +{ + assert(Client != NULL); + + /* Not a local client? */ + if (Client_Conn(Client) <= NONE) + return "0.0.0.0"; + + if (!Client->ipa_text) + return Conn_GetIPAInfo(Client_Conn(Client)); + else + return Client->ipa_text; +} + /** * Update (and generate, if necessary) the cloaked hostname of a client. *