Back to index

lshw  02.16
Functions | Variables
options.cc File Reference
#include "version.h"
#include "options.h"
#include "osutils.h"
#include <set>
#include <vector>
#include <string>
#include <map>
#include <stdlib.h>

Go to the source code of this file.

Functions

 __ID ("@(#) $Id: options.cc 2433 2012-01-10 22:01:30Z lyonel $")
void alias (const char *aname, const char *cname)
static string getcname (const char *aname)
static void remove_option_argument (int i, int &argc, char *argv[])
bool parse_options (int &argc, char *argv[])
bool enabled (const char *option)
bool disabled (const char *option)
void enable (const char *option)
void disable (const char *option)
bool visible (const char *c)

Variables

static set< string > disabled_tests
static set< string > visible_classes
static map< string, string > aliases

Function Documentation

__ID ( "@(#) $Id: options.cc 2433 2012-01-10 22:01:30Z lyonel $"  )
void alias ( const char *  aname,
const char *  cname 
)

Definition at line 27 of file options.cc.

{
  aliases[lowercase(aname)] = lowercase(cname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void disable ( const char *  option)

Definition at line 138 of file options.cc.

{
  disabled_tests.insert(lowercase(option));
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool disabled ( const char *  option)

Definition at line 123 of file options.cc.

{
  return disabled_tests.find(lowercase(option)) != disabled_tests.end();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void enable ( const char *  option)

Definition at line 129 of file options.cc.

{
  if (!disabled(option))
    return;

  disabled_tests.erase(lowercase(option));
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool enabled ( const char *  option)

Definition at line 117 of file options.cc.

{
  return !(disabled(lowercase(option).c_str()));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static string getcname ( const char *  aname) [static]

Definition at line 33 of file options.cc.

{
  if(aliases.find(lowercase(aname)) != aliases.end())
    return lowercase(aliases[lowercase(aname)]);
  else
    return lowercase(aname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool parse_options ( int &  argc,
char *  argv[] 
)

Definition at line 53 of file options.cc.

{
  int i = 1;
  string option = "";

  while (i < argc)
  {
    option = string(argv[i]);

    if (option == "-disable")
    {
      if (i + 1 >= argc)
        return false;                             // -disable requires an argument

      disable(argv[i + 1]);

      remove_option_argument(i, argc, argv);
    }
    else if (option == "-enable")
    {
      if (i + 1 >= argc)
        return false;                             // -enable requires an argument

      enable(argv[i + 1]);

      remove_option_argument(i, argc, argv);
    }
#ifdef SQLITE
    else if (option == "-dump")
    {
      if (i + 1 >= argc)
        return false;                             // -dump requires an argument

      setenv("OUTFILE", argv[i + 1], 1);
      enable("output:db");

      remove_option_argument(i, argc, argv);
    }
#endif
    else if ( (option == "-class") || (option == "-C") || (option == "-c"))
    {
      vector < string > classes;

      enable("output:list");

      if (i + 1 >= argc)
        return false;                             // -class requires an argument

      splitlines(argv[i + 1], classes, ',');

      for (unsigned int j = 0; j < classes.size(); j++)
        visible_classes.insert(getcname(classes[j].c_str()));

      remove_option_argument(i, argc, argv);
    }
    else
      i++;
  }

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void remove_option_argument ( int  i,
int &  argc,
char *  argv[] 
) [static]

Definition at line 42 of file options.cc.

{
  for (int j = i; j + 2 < argc; j++)
    argv[j] = argv[j + 2];

  argc -= 2;
}

Here is the caller graph for this function:

bool visible ( const char *  c)

Definition at line 144 of file options.cc.

{
  if (visible_classes.size() == 0)
    return true;
  return visible_classes.find(getcname(c)) != visible_classes.end();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

map< string, string > aliases [static]

Definition at line 25 of file options.cc.

set< string > disabled_tests [static]

Definition at line 23 of file options.cc.

set< string > visible_classes [static]

Definition at line 24 of file options.cc.