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 S_IWUSR | S_IWGRP | S_IRUSR | S_IRGRP | S_IROTH,
"w", &path_tmp);
40 int written = fprintf(f_tmp,
"%s\n", uuid_str.c_str());
42 if (written != static_cast<int>(uuid_str.length() + 1)) {
43 unlink(path_tmp.c_str());
46 if (rename(path_tmp.c_str(), store_path.c_str()) != 0) {
47 unlink(path_tmp.c_str());
58 int nitems = sscanf(uuid->uuid_.c_str(),
59 "%08" SCNx32
"-%04" SCNx16
"-%04" SCNx16
"-%04" SCNx16
"-%08" SCNx32
"%04"
61 &uuid->uuid_presentation_.split.a, &uuid->uuid_presentation_.split.b,
62 &uuid->uuid_presentation_.split.c, &uuid->uuid_presentation_.split.d,
63 &uuid->uuid_presentation_.split.e1, &uuid->uuid_presentation_.split.e2);
71 string Uuid::CreateOneTime() {
84 uuid_generate(new_uuid);
85 assert(
sizeof(new_uuid) == 16);
86 memcpy(uuid_presentation_.uuid, new_uuid,
sizeof(uuid_presentation_.uuid));
88 unsigned uuid_len = 8+1+4+1+4+1+4+1+12+1;
89 char uuid_cstr[uuid_len];
90 snprintf(uuid_cstr, uuid_len,
"%08x-%04x-%04x-%04x-%08x%04x",
91 uuid_presentation_.split.a, uuid_presentation_.split.b,
92 uuid_presentation_.split.c, uuid_presentation_.split.d,
93 uuid_presentation_.split.e1, uuid_presentation_.split.e2);
94 uuid_ = string(uuid_cstr);
99 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)