1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-04 15:13:12 +02:00
Files
unrealircd/src/cloak.c
T
Bram Matthys f2e3712d62 Remove various if's and such that are now unneeded
This is part 5 of the memory function / caller changes.
2019-09-14 17:23:07 +02:00

49 lines
1.6 KiB
C

/************************************************************************
* Unreal Internet Relay Chat Daemon, src/cloak.c
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
/* mode = 0, just use strlcpy, 1 = Realloc new and return new pointer */
char *make_virthost(Client *sptr, char *curr, char *new, int mode)
{
char host[256], *mask, *p, *q;
if (!curr)
return NULL;
/* Convert host to lowercase and cut off at 255 bytes just to be sure */
for (p = curr, q = host; *p && (q < host+sizeof(host)-1); p++, q++)
*q = tolower(*p);
*q = '\0';
/* Call the cloaking layer */
if (RCallbacks[CALLBACKTYPE_CLOAK_EX] != NULL)
mask = RCallbacks[CALLBACKTYPE_CLOAK_EX]->func.pcharfunc(sptr, host);
else if (RCallbacks[CALLBACKTYPE_CLOAK] != NULL)
mask = RCallbacks[CALLBACKTYPE_CLOAK]->func.pcharfunc(host);
else
mask = curr;
if (mode == 0)
{
strlcpy(new, mask, HOSTLEN + 1);
return NULL;
}
safe_free(new);
return raw_strdup(mask);
}