2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2013, 2018 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2013 Daniel Vassdal <shutter@canternet.org>
6 * Copyright (C) 2013 Attila Molnar <attilamolnar@hush.com>
7 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
8 * Copyright (C) 2010 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
10 * Copyright (C) 2008 Pippijn van Steenhoven <pip88nl@gmail.com>
11 * Copyright (C) 2007, 2010 Craig Edwards <brain@inspircd.org>
12 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
14 * This file is part of InspIRCd. InspIRCd is free software: you can
15 * redistribute it and/or modify it under the terms of the GNU General Public
16 * License as published by the Free Software Foundation, version 2.
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 // This (config) is needed as inspstring doesn't pull in the central header
34 /** Sets ret to the formatted string. last is the last parameter before ..., and format is the format in printf-style */
35 #define VAFORMAT(ret, last, format) \
38 va_start(_vaList, last); \
39 ret.assign(InspIRCd::Format(_vaList, format)); \
43 /** Compose a hex string from raw data.
44 * @param raw The raw data to compose hex from (can be NULL if rawsize is 0)
45 * @param rawsize The size of the raw data buffer
46 * @return The hex string
48 CoreExport std::string BinToHex(const void* raw, size_t rawsize);
51 CoreExport std::string BinToBase64(const std::string& data, const char* table = NULL, char pad = 0);
53 CoreExport std::string Base64ToBin(const std::string& data, const char* table = NULL);
55 /** Compose a hex string from the data in a std::string.
56 * @param data The data to compose hex from
57 * @return The hex string.
59 inline std::string BinToHex(const std::string& data)
61 return BinToHex(data.data(), data.size());