#include <PPDdb.h>
Public Types | |
| typedef string | VendorKey |
| typedef string | ModelKey |
| typedef string | DriverFile |
| typedef map< DriverFile, DriverInfo > | Drivers |
| typedef map< ModelKey, ModelInfo > | Models |
| typedef map< VendorKey, VendorInfo > | Vendors |
| typedef map< string, PpdFileInfo > | PpdFiles |
| typedef map< VendorKey, set < string > > | ModelLabels |
| typedef set< string > | VendorLabels |
Public Member Functions | |
| PPD (const char *ppddir=PPD_DIR, const char *ppddb=PPD_DB) | |
| ~PPD () | |
| bool | createdb () |
| void * | createdbThread (const char *filename) |
| int | creationStatus () |
| bool | changed (int *count) |
| string | getVendorId (string vendor) |
| string | getModelId (string vendor, string model) |
| string | removeVendorFromModel (string vendor, string model) |
| bool | fileinfo (const char *file, PPDInfo *info) |
| bool | setCheckMethod (YCPSymbol method) |
| YCPList | sortItems (const YCPMap &items) |
Static Public Member Functions | |
| static void * | startCreatedbThread (void *instance) |
Protected Member Functions | |
| string | strupper (const string s) |
| string | killchars (const string s, const string chr) |
| string | killspaces (const string s) |
| string | killbraces (const string s) |
| string | addbrace (const string s) |
| string | first (const string s, const string sep=" -/") |
| string | clean (const char *s) |
| string | filternotchars (const string s, const string chr) |
| string | regexpsub (const string input, const string pattern, const string result) |
| bool | validateModel (const string vendor, const string printer) |
Private Types | |
| typedef map< string, string > | VendorsMap |
| typedef map< string, vector < pair< string, string > > > | ModelsMap |
Private Member Functions | |
| bool | mtimes (const char *dirname, time_t mtime, int *count) |
| int | countFiles (const char *dirname) |
| bool | process_dir (const char *dirname) |
| bool | process_file (const char *filename, PPDInfo *newinfo=NULL) |
| void | preprocess (PPDInfo info, PPDInfo *newinfo) |
| void | addAdditionalInfo () |
| void | debugdb () const |
| bool | loadPrebuiltDatabase () |
| bool | createFileList (const char *dirname, time_t mtime) |
| bool | cleanupLists () |
| bool | processNewFiles () |
| bool | cleanupEmptyEntries () |
| string | fileChecksum (const string &filename) |
| off_t | fileSize (const string &filename) |
| string | updateLabel (const string &label) |
Private Attributes | |
| Vendors | db |
| PpdFiles | ppdfiles |
| ModelLabels | modellabels |
| VendorLabels | vendorlabels |
| string | datadir |
| string | var_datadir |
| char | ppd_dir [MAX] |
| char | ppd_db [MAX] |
| time_t | mtime |
| VendorsMap | vendors_map |
| ModelsMap | models_map |
| volatile int | creation_status |
| volatile int | total_files |
| volatile int | done_files |
| bool | fast_check |
Friends | |
| class | PPDfile |
Classes | |
| class | DriverInfo |
| class | ModelInfo |
| class | PpdFileInfo |
| class | PPDInfo |
| class | VendorInfo |
| typedef string PPD::VendorKey |
| typedef string PPD::ModelKey |
| typedef string PPD::DriverFile |
| typedef map<DriverFile, DriverInfo> PPD::Drivers |
| typedef map<ModelKey, ModelInfo> PPD::Models |
| typedef map<VendorKey, VendorInfo> PPD::Vendors |
| typedef map<string, PpdFileInfo> PPD::PpdFiles |
| typedef map<VendorKey, set<string> > PPD::ModelLabels |
| typedef set<string> PPD::VendorLabels |
typedef map<string, string> PPD::VendorsMap [private] |
typedef map<string, vector<pair <string, string> > > PPD::ModelsMap [private] |
| PPD::PPD | ( | const char * | ppddir = PPD_DIR, |
|
| const char * | ppddb = PPD_DB | |||
| ) |
Constructor
Array of all known vendors
Array of all known string->vendor mappings
References array_all, array_map, datadir, fast_check, models_map, mtime, ppd_db, ppd_dir, val, var_datadir, vendors_map, and y2error.
| PPD::~PPD | ( | ) |
Destructor
| bool PPD::createdb | ( | ) |
Create database of printers Just start a thread and return immediately
References creation_status, and startCreatedbThread().
Referenced by PPDAgent::Write().
| void * PPD::startCreatedbThread | ( | void * | instance | ) | [static] |
| void * PPD::createdbThread | ( | const char * | filename | ) |
Create a database of all ppd files in the /var/lib/YaST2/ppd_db.ycp
References addAdditionalInfo(), cleanupEmptyEntries(), cleanupLists(), countFiles(), createFileList(), creation_status, db, done_files, F, loadPrebuiltDatabase(), mtime, ppd_db, ppd_dir, process_dir(), processNewFiles(), str, total_files, y2debug, y2error, and y2milestone.
Referenced by startCreatedbThread(), and PPDAgent::Write().
| int PPD::creationStatus | ( | ) |
| bool PPD::changed | ( | int * | count | ) |
Check if any ppd file has changed
References mtime, mtimes(), ppd_db, and ppd_dir.
Referenced by PPDAgent::Read().
| string PPD::getVendorId | ( | string | vendor | ) |
Transform vendor name from PPD file/detection to key in database
References filternotchars(), strupper(), and vendors_map.
Referenced by addAdditionalInfo(), getModelId(), preprocess(), process_file(), PPDAgent::Read(), and removeVendorFromModel().
| string PPD::getModelId | ( | string | vendor, | |
| string | model | |||
| ) |
Transform model name from PPD file/detection to key in database
References filternotchars(), getVendorId(), models_map, regexpsub(), removeVendorFromModel(), and strupper().
Referenced by addAdditionalInfo(), preprocess(), PPDAgent::Read(), and validateModel().
| string PPD::removeVendorFromModel | ( | string | vendor, | |
| string | model | |||
| ) |
Remove the vendor name from the beginning of the model if present
| vendor | string vendor id | |
| model | string model label/id |
References getVendorId(), strupper(), and vendors_map.
Referenced by getModelId(), and process_file().
| bool PPD::fileinfo | ( | const char * | file, | |
| PPDInfo * | info | |||
| ) |
Return info from the given file
References process_file(), and y2error.
| bool PPD::setCheckMethod | ( | YCPSymbol | method | ) |
References YCPList::add(), YCPTerm::add(), YCPMap::begin(), YCPMap::end(), key, YCPMapIterator::key(), val, and YCPMapIterator::value().
Referenced by PPDAgent::Read().
| bool PPD::mtimes | ( | const char * | dirname, | |
| time_t | mtime, | |||
| int * | count | |||
| ) | [private] |
| int PPD::countFiles | ( | const char * | dirname | ) | [private] |
| bool PPD::process_dir | ( | const char * | dirname | ) | [private] |
Search given directory for ppd files and update the ppd database
| dirname | directory to be processed |
References MAX, process_file(), y2debug, and y2error.
Referenced by createdbThread().
| bool PPD::process_file | ( | const char * | filename, | |
| PPDInfo * | newinfo = NULL | |||
| ) | [private] |
| filename | the file to be processed |
References PPD::PPDInfo::checksum, clean(), creation_status, done_files, fileChecksum(), PPD::PPDInfo::filename, fileSize(), PPD::PPDInfo::filter, getVendorId(), PPD::PPDInfo::lang, MAX, PPD::PPDInfo::nick, PPD::PPDInfo::pnp_printer, PPD::PPDInfo::pnp_vendor, preprocess(), PPD::PPDInfo::printer, PPD::PPDInfo::printer_db, PPD::PPDInfo::products, removeVendorFromModel(), PPD::PPDInfo::shortnick, PPD::PPDInfo::size, total_files, PPD::PPDInfo::vendor, PPD::PPDInfo::vendor_db, y2debug, y2error, and y2warning.
Referenced by fileinfo(), PPDfile::ppdInfo(), process_dir(), and processNewFiles().
| void PPD::preprocess | ( | PPD::PPDInfo | info, | |
| PPDInfo * | newinfo | |||
| ) | [private] |
Preprocess the strings, apply hacks and update the db.
References addbrace(), PPD::PPDInfo::checksum, db, PPD::ModelInfo::drivers, PPD::PPDInfo::filename, PPD::PPDInfo::filter, first(), PPD::ModelInfo::fuzzy_label, getModelId(), getVendorId(), killbraces(), PPD::ModelInfo::label, PPD::PPDInfo::lang, modellabels, PPD::VendorInfo::models, PPD::PPDInfo::nick, PPD::PPDInfo::pnp_printer, PPD::PPDInfo::pnp_vendor, PPD::PPDInfo::printer, PPD::PPDInfo::printer_db, PPD::PPDInfo::products, PPD::PPDInfo::shortnick, PPD::PPDInfo::size, strupper(), updateLabel(), validateModel(), PPD::PPDInfo::vendor, PPD::PPDInfo::vendor_db, vendors_map, y2debug, y2error, and y2milestone.
Referenced by process_file().
| void PPD::addAdditionalInfo | ( | ) | [private] |
References datadir, db, getModelId(), getVendorId(), PPD::ModelInfo::label, PPD::VendorInfo::label, modellabels, PPD::VendorInfo::models, strupper(), PPD::ModelInfo::support, y2debug, y2error, and y2milestone.
Referenced by createdbThread().
| void PPD::debugdb | ( | ) | const [private] |
Return the whole DB / PPD::Vendors PPD::getDB() const { return db; } Debug whole ppd db to the y2log
| bool PPD::loadPrebuiltDatabase | ( | ) | [private] |
References YCPMap::begin(), PPD::DriverInfo::checksum, db, PPD::ModelInfo::drivers, YCPMap::end(), PPD::DriverInfo::filter, YCPElement::isNull(), PPD::VendorInfo::label, PPD::ModelInfo::label, PPD::DriverInfo::language, PPD::ModelInfo::mcomment, modellabels, PPD::VendorInfo::models, PPD::DriverInfo::nickname, Parser::parse(), PPD::DriverInfo::pnp_printer, PPD::DriverInfo::pnp_vendor, ppd_db, Parser::setBuffered(), Parser::setInput(), PPD::DriverInfo::size, PPD::ModelInfo::support, val, PPD::VendorInfo::vcomment, y2debug, y2error, and y2milestone.
Referenced by createdbThread().
| bool PPD::createFileList | ( | const char * | dirname, | |
| time_t | mtime | |||
| ) | [private] |
Creates a list of files with attrubutes about modification dates
References PPD::PpdFileInfo::dir_newer, PPD::PpdFileInfo::file_newer, MAX, ppdfiles, and y2error.
Referenced by createdbThread().
| bool PPD::cleanupLists | ( | ) | [private] |
References PPD::DriverInfo::checksum, db, fast_check, fileChecksum(), fileSize(), PPD::DriverInfo::nickname, ppdfiles, PPD::DriverInfo::size, and y2debug.
Referenced by createdbThread().
| bool PPD::processNewFiles | ( | ) | [private] |
References done_files, ppdfiles, process_file(), y2error, and y2warning.
Referenced by createdbThread().
| bool PPD::cleanupEmptyEntries | ( | ) | [private] |
| string PPD::fileChecksum | ( | const string & | filename | ) | [private] |
| off_t PPD::fileSize | ( | const string & | filename | ) | [private] |
Referenced by cleanupLists(), and process_file().
| string PPD::updateLabel | ( | const string & | label | ) | [private] |
| string PPD::strupper | ( | const string | s | ) | [protected] |
Convert string to upper characters
Referenced by addAdditionalInfo(), getModelId(), getVendorId(), preprocess(), removeVendorFromModel(), and updateLabel().
| string PPD::killchars | ( | const string | s, | |
| const string | chr | |||
| ) | [protected] |
Kill the given chars from the start and end of the string
References killspaces().
Referenced by killbraces().
| string PPD::killspaces | ( | const string | s | ) | [protected] |
Kill all spaces from the start and end of the string
Referenced by addbrace(), and killchars().
| string PPD::killbraces | ( | const string | s | ) | [protected] |
Kill braces (and other bad characters) from the start and end of the string
References killchars().
Referenced by addbrace(), clean(), first(), and preprocess().
| string PPD::addbrace | ( | const string | s | ) | [protected] |
Add a right brace if there is one left brace alone.
References killbraces(), and killspaces().
Referenced by preprocess().
| string PPD::first | ( | const string | s, | |
| const string | sep = " -/" | |||
| ) | [protected] |
| string PPD::clean | ( | const char * | s | ) | [protected] |
Make s string from the char* and clean it from spaces and braces
References killbraces().
Referenced by process_file().
| string PPD::filternotchars | ( | const string | s, | |
| const string | chr | |||
| ) | [protected] |
Filter characters, leavo only listed ones
Referenced by getModelId(), and getVendorId().
| string PPD::regexpsub | ( | const string | input, | |
| const string | pattern, | |||
| const string | result | |||
| ) | [protected] |
| bool PPD::validateModel | ( | const string | vendor, | |
| const string | printer | |||
| ) | [protected] |
friend class PPDfile [friend] |
Referenced by addAdditionalInfo(), cleanupEmptyEntries(), cleanupLists(), createdbThread(), debugdb(), loadPrebuiltDatabase(), and preprocess().
PpdFiles PPD::ppdfiles [private] |
Referenced by cleanupLists(), createFileList(), and processNewFiles().
ModelLabels PPD::modellabels [private] |
Referenced by addAdditionalInfo(), loadPrebuiltDatabase(), and preprocess().
VendorLabels PPD::vendorlabels [private] |
string PPD::datadir [private] |
Referenced by addAdditionalInfo(), and PPD().
string PPD::var_datadir [private] |
Referenced by PPD().
char PPD::ppd_dir[MAX] [private] |
Referenced by changed(), createdbThread(), and PPD().
char PPD::ppd_db[MAX] [private] |
Referenced by changed(), createdbThread(), loadPrebuiltDatabase(), and PPD().
time_t PPD::mtime [private] |
Referenced by changed(), createdbThread(), and PPD().
VendorsMap PPD::vendors_map [private] |
Referenced by getVendorId(), PPD(), preprocess(), and removeVendorFromModel().
ModelsMap PPD::models_map [private] |
Referenced by getModelId(), and PPD().
volatile int PPD::creation_status [private] |
Referenced by createdb(), createdbThread(), creationStatus(), and process_file().
volatile int PPD::total_files [private] |
Referenced by createdbThread(), and process_file().
volatile int PPD::done_files [private] |
Referenced by createdbThread(), process_file(), and processNewFiles().
bool PPD::fast_check [private] |
Referenced by cleanupLists(), PPD(), and setCheckMethod().
1.5.5