40 RbuFactory::~RbuFactory() throw() {}
41 RbuFactory::RbuFactory() {}
48 return RbuFactoryImpl::getFactory(reinterpret_cast<RbuFactoryImpl *>(0));
51 RbuFactoryImpl::~RbuFactoryImpl() throw() { }
52 RbuFactoryImpl::RbuFactoryImpl() { }
53 IRbuHdr *RbuFactoryImpl::makeNew(std::string filename)
55 return new RbuHdr( filename );
59 IRbuHdr::~IRbuHdr() {}
62 RbuHdr::RbuHdr(
string filename ) : hdrFh(fopen(filename.c_str(),
"rb"))
66 string errmsg = strerror(errno);
67 throw HdrFileIOErrorImpl(errmsg);
70 memset(&header, 0,
sizeof(header));
71 size_t bytesRead = fread(&header, 1,
sizeof(header), hdrFh);
72 if (bytesRead !=
sizeof(header))
76 throw InvalidHdrFileImpl(
"Couldnt read full header.");
80 header.headerId[0] ==
'$' &&
81 header.headerId[1] ==
'R' &&
82 header.headerId[2] ==
'B' &&
83 header.headerId[3] ==
'U'
91 throw InvalidHdrFileImpl(
"Did not pass header $RBU check.");
95 memset(sysIdList, 0,
sizeof(sysIdList));
96 for(
unsigned int i=0; i < (
sizeof(header.systemIdList)/
sizeof(header.systemIdList[0])); ++i)
101 u32 val = header.systemIdList[i];
102 u32 id = (val & 0xFF) | ((val & 0xF800) >> 3);
132 std::ostringstream rep;
155 for (
const u32 *ptr = idList; *ptr; ++ptr)
174 std::ios::fmtflags old_opts = cout.flags ();
175 cout <<
"HeaderId : "
188 char quickCheck[41] = {0};
190 cout <<
"Quick Check: " << quickCheck << endl;
192 cout <<
"System ID List:" << hex;
195 cout <<
" 0x" << setfill (
'0') << setw (4) << *ptr;
198 cout.flags (old_opts);
206 for(
unsigned int i=0;i<in.length();i++)
207 in[i] = tolower(in[i]);
226 if (ver1[0] == ver2[0])
229 if (tolower(ver1[0]) ==
'a')
232 if (tolower(ver2[0]) ==
'a')
235 if (tolower(ver1[0]) ==
'x')
238 if (tolower(ver2[0]) ==
'x')
241 if (tolower(ver1[0]) ==
'p')
244 if (tolower(ver2[0]) ==
'p')
247 if (ver1[0] > ver2[0])
254 void splitNewVersion(std::string ver,
unsigned int &maj,
unsigned int &min,
unsigned int &ext)
256 unsigned int verSplit[3] = {0,};
258 DCOUT(
"splitNewVersion( \""<< ver <<
"\" )" << endl);
260 size_t start=0, end=0;
261 for(
int i=0; i<3; i++)
264 end = ver.find(
'.', start);
265 verPart.append(ver, start, end - start);
267 verSplit[i] = strtoul(verPart.c_str(), 0, 10);
268 DCOUT(
"Start(" << start <<
") End(" << end <<
") verPart(\"" << verPart <<
"\") verSplit[" << i <<
"](" << verSplit[i] <<
")" << endl);
270 if( end == string::npos )
280 DCOUT(
"Return: (" << maj <<
", " << min <<
", " << ext <<
")" << endl);
286 unsigned int maj1, min1, ext1;
287 unsigned int maj2, min2, ext2;
292 const unsigned int SPECIAL_VER_START = 90;
293 if (maj1 >= SPECIAL_VER_START && maj2 < SPECIAL_VER_START)
295 if (maj1 < SPECIAL_VER_START && maj2 >= SPECIAL_VER_START)
328 if ( isalpha(ver1[0]) && isalpha(ver2[0]) )
332 if ( ! isalpha(ver1[0]) && isalpha(ver2[0]) )
336 if ( isalpha(ver1[0]) && !isalpha(ver2[0]) )
339 if ( ! isalpha(ver1[0]) && !isalpha(ver2[0]) )
362 catch(
const smbios::DataOutOfBounds &)
386 u16 *buf =
reinterpret_cast<u16 *
>(pkt);
390 for(
size_t i=0; i<size/2; ++i)
391 csum = csum + buf[i];
401 pkt->
pktId = 0x4B505224;
405 int datasize = bufSize - (16 * pkt->
hdrSize);
410 pkt->
totPkts = (imageSize/datasize) + ((imageSize % datasize) ? 1:0) + 1;