24 #include <interface/interface.h>
25 #include <interface/interface_info.h>
26 #include <utils/misc/strndup.h>
27 #include <utils/time/time.h>
54 const unsigned char * hash,
57 unsigned int num_readers,
58 const std::list<std::string> &readers,
59 const std::string & writer,
60 const Time * timestamp)
62 type_ = strndup(
type, INTERFACE_TYPE_SIZE_);
63 id_ = strndup(
id, INTERFACE_ID_SIZE_);
64 hash_ = (
unsigned char *)malloc(INTERFACE_HASH_SIZE_);
65 memcpy(hash_,
hash, INTERFACE_HASH_SIZE_);
79 type_ = strndup(i.type_, INTERFACE_TYPE_SIZE_);
80 id_ = strndup(i.id_, INTERFACE_ID_SIZE_);
81 hash_ = (
unsigned char *)malloc(INTERFACE_HASH_SIZE_);
82 memcpy(hash_, i.hash_, INTERFACE_HASH_SIZE_);
83 has_writer_ = i.has_writer_;
84 num_readers_ = i.num_readers_;
86 timestamp_ =
new Time(i.timestamp_);
87 readers_ = i.readers_;
112 type_ = strndup(i.type_, INTERFACE_TYPE_SIZE_);
113 id_ = strndup(i.id_, INTERFACE_ID_SIZE_);
114 hash_ = (
unsigned char *)malloc(INTERFACE_HASH_SIZE_);
115 memcpy(hash_, i.hash_, INTERFACE_HASH_SIZE_);
116 has_writer_ = i.has_writer_;
117 num_readers_ = i.num_readers_;
119 timestamp_ =
new Time(i.timestamp_);
120 readers_ = i.readers_;
147 const unsigned char *
159 char phash[INTERFACE_HASH_SIZE_ * 2 + 1];
160 phash[INTERFACE_HASH_SIZE_ * 2] = 0;
161 for (
size_t s = 0; s < INTERFACE_HASH_SIZE_; ++s) {
162 snprintf(&phash[s * 2], 3,
"%02X", hash_[s]);
164 return std::string(phash);
188 const std::list<std::string> &
232 int td = strncmp(type_, ii.type_, INTERFACE_TYPE_SIZE_);
238 return (strncmp(id_, ii.id_, INTERFACE_ID_SIZE_) < 0);
262 const unsigned char * hash,
265 unsigned int num_readers,
266 const std::list<std::string> &readers,
267 const std::string & writer,
268 const Time & timestamp)
271 InterfaceInfo(type,
id, hash, serial, has_writer, num_readers, readers, writer, ×tamp));