Diffstat (limited to 'libopie2/opienet/omanufacturerdb.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opienet/omanufacturerdb.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp index ea15125..c185fc5 100644 --- a/libopie2/opienet/omanufacturerdb.cpp +++ b/libopie2/opienet/omanufacturerdb.cpp @@ -59,8 +59,9 @@ OManufacturerDB::OManufacturerDB() qDebug( "OManufacturerDB: found manufacturer list in '%s'...", (const char*) filename ); QTextStream s( &file ); QString addr; QString manu; + QString extManu; while (!s.atEnd()) { s >> addr; if ( !addr ) // read nothing!? @@ -69,15 +70,24 @@ OManufacturerDB::OManufacturerDB() } else if ( addr[0] == '#' ) { - s.readLine(); continue; } s.skipWhiteSpace(); s >> manu; + s.skipWhiteSpace(); + s >> extManu; + if ( extManu[0] == '#' ) // we have an extended manufacturer + { + s.skipWhiteSpace(); + extManu = s.readLine(); + qDebug( "OManufacturerDB: read '%s' as extended manufacturer string", (const char*) extManu ); + manufacturersExt.insert( addr, extManu ); + } + else s.readLine(); - //qDebug( "ManufacturerDB: read pair %s, %s", (const char*) addr, (const char*) manu ); + qDebug( "ManufacturerDB: read tuple %s, %s", (const char*) addr, (const char*) manu ); manufacturers.insert( addr, manu ); } } @@ -93,4 +103,12 @@ OManufacturerDB::~OManufacturerDB() const QString& OManufacturerDB::lookup( const QString& macaddr ) const { return manufacturers[macaddr.upper().left(8)]; } + + +const QString& OManufacturerDB::lookupExt( const QString& macaddr ) const +{ + QMap<QString,QString>::ConstIterator it = manufacturersExt.find( macaddr.upper().left(8) ); + return it == manufacturersExt.end() ? lookup( macaddr ) : *it; +} + |