diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-07-17 14:10:44 -0400 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-07-17 14:10:44 -0400 |
| commit | 76bc9968ff0ec7d044042f9214fa59efb3146685 (patch) | |
| tree | 23eb792895eb5b4b3cffafd4127bbeb3da7d9fa6 /node/Utils.cpp | |
| parent | 557cc359b30aacff372f1b92a8f0f621fcd9c50f (diff) | |
| download | infinitytier-76bc9968ff0ec7d044042f9214fa59efb3146685.tar.gz infinitytier-76bc9968ff0ec7d044042f9214fa59efb3146685.zip | |
New simpler command interface via loopback UDP protected by a crypto token.
Diffstat (limited to 'node/Utils.cpp')
| -rw-r--r-- | node/Utils.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/node/Utils.cpp b/node/Utils.cpp index b9db07b9..7b2a17af 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -28,6 +28,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <stdarg.h> #include "Utils.hpp" #include "Mutex.hpp" @@ -530,4 +531,20 @@ std::string Utils::trim(const std::string &s) return s.substr(start,end - start); } +void Utils::stdsprintf(std::string &s,const char *fmt,...) + throw(std::bad_alloc,std::length_error) +{ + char buf[65536]; + va_list ap; + + va_start(ap,fmt); + int n = vsnprintf(buf,sizeof(buf),fmt,ap); + va_end(ap); + + if ((n >= (int)sizeof(buf))||(n < 0)) + throw std::length_error("printf result too large"); + + s.append(buf); +} + } // namespace ZeroTier |
