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));
void append(const char *type, const char *id, const unsigned char *hash, unsigned int serial, bool has_writer, unsigned int num_readers, const std::list< std::string > &readers, const std::string &writer, const Time ×tamp)
Append an interface info.
const std::list< std::string > & readers() const
Get readers of interface.
bool has_writer() const
Check if there is a writer.
unsigned int serial() const
Get interface instance serial.
bool operator<(const InterfaceInfo &ii) const
< operator This compares two interface infos with respect to the less than (<) relation considering t...
const char * type() const
Get interface type.
InterfaceInfo & operator=(const InterfaceInfo &i)
Assignment operator.
const char * id() const
Get interface ID.
InterfaceInfo(const char *type, const char *id, const unsigned char *hash, unsigned int serial, bool has_writer, unsigned int num_readers, const std::list< std::string > &readers, const std::string &writer, const Time *timestamp)
Constructor.
~InterfaceInfo()
Destructor.
const std::string & writer() const
Get name of writer on interface.
const unsigned char * hash() const
Get interface version hash.
unsigned int num_readers() const
Get number of readers.
std::string hash_printable() const
Get interface version hash in printable format.
const Time * timestamp() const
Get interface timestamp.
A class for handling time.
Fawkes library namespace.