InspIRCd  3.0
inspstring.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * Copyright (C) 2013, 2018 Sadie Powell <[email protected]>
5  * Copyright (C) 2013 Daniel Vassdal <[email protected]>
6  * Copyright (C) 2013 Attila Molnar <[email protected]>
7  * Copyright (C) 2012 Robby <[email protected]>
8  * Copyright (C) 2010 Daniel De Graaf <[email protected]>
9  * Copyright (C) 2008 Robin Burchell <[email protected]>
10  * Copyright (C) 2008 Pippijn van Steenhoven <[email protected]>
11  * Copyright (C) 2007, 2010 Craig Edwards <[email protected]>
12  * Copyright (C) 2007 Dennis Friis <[email protected]>
13  *
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.
17  *
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
21  * details.
22  *
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/>.
25  */
26 
27 
28 #pragma once
29 
30 // This (config) is needed as inspstring doesn't pull in the central header
31 #include "config.h"
32 #include <cstring>
33 
35 #define VAFORMAT(ret, last, format) \
36  do { \
37  va_list _vaList; \
38  va_start(_vaList, last); \
39  ret.assign(InspIRCd::Format(_vaList, format)); \
40  va_end(_vaList); \
41  } while (false);
42 
48 CoreExport std::string BinToHex(const void* raw, size_t rawsize);
49 
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);
54 
59 inline std::string BinToHex(const std::string& data)
60 {
61  return BinToHex(data.data(), data.size());
62 }