diff options
author | Attila Molnar <attilamolnar@hush.com> | 2013-05-20 11:05:05 -0700 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2013-05-20 11:05:05 -0700 |
commit | 991a6a429bd6abc70c0eac33bcca124b0600cc0f (patch) | |
tree | 73961818b96646cfbe0a0ff945a23db04edc4823 /include | |
parent | 3ce33ee0e6bc0b8fbe2a564a37e02d2e56510b06 (diff) | |
parent | 4e40ee49bba3f7bab05a58516e2039351fb33069 (diff) |
Merge pull request #542 from ShutterQuick/inspircd+printfcleanup
Replaced all the individual vsnprintfing with a macro
Diffstat (limited to 'include')
-rw-r--r-- | include/inspircd.h | 3 | ||||
-rw-r--r-- | include/inspstring.h | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 9a9583499..de574b6f4 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -543,7 +543,8 @@ class CoreExport InspIRCd * @param ... * @return The formatted string */ - static const char* Format(const char* formatString, ...); + static const char* Format(const char* formatString, ...) CUSTOM_PRINTF(1, 2); + static const char* Format(const va_list &vaList, const char* formatString) CUSTOM_PRINTF(2, 0); static void QuickExit(int status); diff --git a/include/inspstring.h b/include/inspstring.h index eb7b7218f..ccc77da66 100644 --- a/include/inspstring.h +++ b/include/inspstring.h @@ -24,6 +24,15 @@ #include "config.h" #include <cstring> +/** Sets ret to the formated string. last is the last parameter before ..., and format is the format in printf-style */ +#define VAFORMAT(ret, last, format) \ + do { \ + va_list _vaList; \ + va_start(_vaList, last); \ + ret = InspIRCd::Format(_vaList, format); \ + va_end(_vaList); \ + } while (false); + /** Compose a hex string from raw data. * @param raw The raw data to compose hex from (can be NULL if rawsize is 0) * @param rawsize The size of the raw data buffer |