mirror of
https://github.com/badaix/snapcast.git
synced 2025-06-02 02:41:49 +02:00
generateUUID
This commit is contained in:
parent
ad568f1076
commit
db2b5e06a3
1 changed files with 16 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <memory>
|
||||
#include <cerrno>
|
||||
#include <iterator>
|
||||
|
@ -265,6 +266,21 @@ static long uptime()
|
|||
}
|
||||
|
||||
|
||||
/// http://stackoverflow.com/questions/2174768/generating-random-uuids-in-linux
|
||||
static std::string generateUUID()
|
||||
{
|
||||
std::srand(std::time(0));
|
||||
std::stringstream ss;
|
||||
ss << std::setfill('0') << std::hex
|
||||
<< std::setw(4) << (std::rand() % 0xffff) << std::setw(4) << (std::rand() % 0xffff)
|
||||
<< "-" << std::setw(4) << (std::rand() % 0xffff)
|
||||
<< "-" << std::setw(4) << (std::rand() % 0xffff)
|
||||
<< "-" << std::setw(4) << (std::rand() % 0xffff)
|
||||
<< "-" << std::setw(4) << (std::rand() % 0xffff) << std::setw(4) << (std::rand() % 0xffff) << std::setw(4) << (std::rand() % 0xffff);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
||||
/// https://gist.github.com/OrangeTide/909204
|
||||
static std::string getMacAddress(int sock)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue