7 #define __STDC_FORMAT_MACROS
25 if (store_path ==
"") {
30 FILE *f = fopen(store_path.c_str(),
"r");
34 string uuid_str = uuid->uuid();
37 store_path +
"_tmp", S_IWUSR | S_IWGRP | S_IRUSR | S_IRGRP | S_IROTH,
41 int written = fprintf(f_tmp,
"%s\n", uuid_str.c_str());
43 if (written != static_cast<int>(uuid_str.length() + 1)) {
44 unlink(path_tmp.c_str());
47 if (rename(path_tmp.c_str(), store_path.c_str()) != 0) {
48 unlink(path_tmp.c_str());
61 "%08" SCNx32
"-%04" SCNx16
"-%04" SCNx16
"-%04" SCNx16
"-%08" SCNx32
63 &uuid->uuid_presentation_.split.a, &uuid->uuid_presentation_.split.b,
64 &uuid->uuid_presentation_.split.c, &uuid->uuid_presentation_.split.d,
65 &uuid->uuid_presentation_.split.e1, &uuid->uuid_presentation_.split.e2);
73 string Uuid::CreateOneTime() {
86 uuid_generate(new_uuid);
87 assert(
sizeof(new_uuid) == 16);
88 memcpy(uuid_presentation_.uuid, new_uuid,
sizeof(uuid_presentation_.uuid));
90 unsigned uuid_len = 8 + 1 + 4 + 1 + 4 + 1 + 4 + 1 + 12 + 1;
91 char uuid_cstr[uuid_len];
92 snprintf(uuid_cstr, uuid_len,
"%08x-%04x-%04x-%04x-%08x%04x",
93 uuid_presentation_.split.a, uuid_presentation_.split.b,
94 uuid_presentation_.split.c, uuid_presentation_.split.d,
95 uuid_presentation_.split.e1, uuid_presentation_.split.e2);
96 uuid_ = string(uuid_cstr);
100 Uuid::Uuid() { memset(&uuid_presentation_, 0,
sizeof(uuid_presentation_)); }
static Publisher * Create(const SettingsPublisher &settings)
FILE * CreateTempFile(const std::string &path_prefix, const int mode, const char *open_flags, std::string *final_path)
assert((mem||(size==0))&&"Out Of Memory")
bool GetLineFile(FILE *f, std::string *line)