interface_info.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <interface/interface_info.h>
00025 #include <interface/interface.h>
00026
00027 #include <cstdlib>
00028 #include <cstring>
00029 #ifdef __FreeBSD__
00030 # include <strfunc.h>
00031 #endif
00032
00033 namespace fawkes {
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 InterfaceInfo::InterfaceInfo(const char *type, const char *id, const unsigned char *hash,
00050 unsigned int serial, bool has_writer, unsigned int num_readers)
00051 {
00052 __type = strndup(type, __INTERFACE_TYPE_SIZE);
00053 __id = strndup(id, __INTERFACE_ID_SIZE);
00054 __hash = (unsigned char *)malloc(__INTERFACE_HASH_SIZE);
00055 memcpy(__hash, hash, __INTERFACE_HASH_SIZE);
00056 __has_writer = has_writer;
00057 __num_readers = num_readers;
00058 __serial = serial;
00059 }
00060
00061
00062
00063
00064
00065 InterfaceInfo::InterfaceInfo(const InterfaceInfo &i)
00066 {
00067 __type = strndup(i.__type, __INTERFACE_TYPE_SIZE);
00068 __id = strndup(i.__id, __INTERFACE_ID_SIZE);
00069 __hash = (unsigned char *)malloc(__INTERFACE_HASH_SIZE);
00070 memcpy(__hash, i.__hash, __INTERFACE_HASH_SIZE);
00071 __has_writer = i.__has_writer;
00072 __num_readers = i.__num_readers;
00073 __serial = i.__serial;
00074 }
00075
00076
00077
00078 InterfaceInfo::~InterfaceInfo()
00079 {
00080 free(__type);
00081 free(__id);
00082 free(__hash);
00083 }
00084
00085
00086
00087
00088
00089 const char *
00090 InterfaceInfo::type() const
00091 {
00092 return __type;
00093 }
00094
00095
00096
00097
00098
00099 const char *
00100 InterfaceInfo::id() const
00101 {
00102 return __id;
00103 }
00104
00105
00106
00107
00108
00109 const unsigned char *
00110 InterfaceInfo::hash() const
00111 {
00112 return __hash;
00113 }
00114
00115
00116
00117
00118
00119 bool
00120 InterfaceInfo::has_writer() const
00121 {
00122 return __has_writer;
00123 }
00124
00125
00126
00127
00128
00129 unsigned int
00130 InterfaceInfo::num_readers() const
00131 {
00132 return __num_readers;
00133 }
00134
00135
00136
00137
00138
00139 unsigned int
00140 InterfaceInfo::serial() const
00141 {
00142 return __serial;
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 void
00161 InterfaceInfoList::append(const char *type, const char *id, const unsigned char *hash,
00162 unsigned int serial, bool has_writer, unsigned int num_readers)
00163 {
00164 push_back(InterfaceInfo(type, id, hash, serial, has_writer, num_readers));
00165 }
00166
00167 }