yast2-core
|
SCR Agent for access to any describeable file. More...
#include <AnyAgent.h>
Public Member Functions | |
AnyAgent () | |
~AnyAgent () | |
YCPValue | Read (const YCPPath &path, const YCPValue &arg=YCPNull(), const YCPValue &opt=YCPNull()) |
YCPBoolean | Write (const YCPPath &path, const YCPValue &value, const YCPValue &arg=YCPNull()) |
YCPList | Dir (const YCPPath &path) |
YCPValue | otherCommand (const YCPTerm &term) |
![]() | |
SCRAgent () | |
virtual | ~SCRAgent () |
virtual YCPValue | Execute (const YCPPath &path, const YCPValue &=YCPNull(), const YCPValue &=YCPNull()) |
virtual YCPMap | Error (const YCPPath &) |
virtual YCPBoolean | RegisterAgent (const YCPPath &path, const YCPValue &) |
virtual YCPBoolean | UnregisterAgent (const YCPPath &path) |
virtual YCPBoolean | UnregisterAllAgents () |
virtual YCPBoolean | UnmountAgent (const YCPPath &) |
virtual YCPBoolean | RegisterNewAgents () |
void | setAsCurrentSCR () |
Private Types | |
enum | { MTYPE_NONE, MTYPE_FILE, MTYPE_PROG, MTYPE_LOCAL } |
Private Member Functions | |
YCPValue | readValueByPath (const YCPValue &value, const YCPPath &path) |
YCPValue | writeValueByPath (const YCPValue ¤t, const YCPPath &path, const YCPValue &value) |
YCPValue | findSyntax (const YCPValue &syntax, const YCPPath &path) |
const char * | get_line (FILE *fp) |
YCPValue | parseIp4Number (char const *&lptr, bool optional) |
const string | unparseIp4Number (const YCPValue &value) |
YCPValue | parseBoolean (char const *&lptr, bool optional) |
const string | unparseBoolean (const YCPValue &value) |
YCPValue | parseNumber (char const *&lptr, bool optional) |
const string | unparseNumber (const YCPValue &value) |
YCPValue | parseHexval (char const *&lptr, bool optional) |
const string | unparseHexval (const YCPValue &value) |
YCPValue | parseString (char const *&lptr, const char *set, const char *stripped, bool optional) |
const string | unparseString (const YCPValue &syntax, const YCPValue &stripped, const YCPValue &value) |
YCPValue | parseFloat (char const *&lptr, bool optional) |
const string | unparseFloat (const YCPValue &value) |
YCPValue | parseHostname (char const *&lptr, bool optional) |
const string | unparseHostname (const YCPValue &value) |
YCPValue | parseUsername (char const *&lptr, bool optional) |
const string | unparseUsername (const YCPValue &value) |
YCPValue | parseVerbose (char const *&lptr, const char *match, bool optional) |
const string | unparseVerbose (const YCPValue &value) |
YCPValue | parseSeparator (char const *&lptr, const char *match, bool optional) |
const string | unparseSeparator (const YCPValue &match) |
const char * | getLine (void) |
const string | putLine (const string s) |
YCPValue | parseChoice (char const *&line, const YCPList &syntax, bool optional) |
const string | unparseChoice (const YCPList &syntax, const YCPValue &value) |
YCPValue | parseSequence (char const *&line, const YCPList &syntax, bool optional) |
const string | unparseSequence (const YCPList &syntax, const YCPValue &value) |
YCPValue | parseList (char const *&line, const YCPList &syntax, bool optional) |
const string | unparseList (const YCPList &syntax, const YCPValue &value) |
YCPValue | parseTuple (char const *&line, const YCPList &syntax, bool optional) |
const string | unparseTuple (const YCPList &syntax, const YCPValue &value) |
YCPValue | parseData (char const *&line, const YCPValue &syntax, bool optional) |
const string | unparseData (const YCPValue &syntax, const YCPValue &value) |
YCPValue | validateCache (const YCPList &data, const YCPValue &arg=YCPNull()) |
YCPValue | readFile (const YCPValue &arg) |
const string | writeFile (const YCPValue &arg) |
string | evalArg (const YCPValue &arg) |
int | lineNumber () const |
Private Attributes | |
bool | description_read |
time_t | mtime |
YCPValue | cache |
bool | cchanged |
YCPList | alldata |
bool | achanged |
bool | mReadOnly |
enum AnyAgent:: { ... } | mType |
YCPValue | mName |
string | mComment |
bool | isFillup |
YCPValue | mSyntax |
YCPValue | mHeader |
int | line_number |
stack< string > | tupleName |
stack< YCPValue > | tupleValue |
bool | tupleContinue |
Additional Inherited Members | |
![]() | |
static YCPValue | readconf (const char *filename) |
static SCRAgent * | instance () |
![]() | |
SCRAgent * | mainscragent |
SCR Agent for access to any describeable file.
AnyAgent::AnyAgent | ( | ) |
Creates a new AnyAgent.
AnyAgent.cc
Purpose: generalized agent handler for handling system files from /proc and /etc
Creator: kkaem Maintainer: pf@s use.d ekkaem pf@s use.d e
loads syntax description at startup to read and write system file
loads complete file (incl. comments) to internal YCPListRep and provides valid (i.e. non-comment) lines in another data structure defined by syntax.
Syntax description:
Header (<syntax>) Header to write at start of file, used only by Write ()
List (<syntax>, terminal) list of syntax, separated by terminal character represented as YCPListRep
Tuple (<name> (<syntax>), ...) // fixed name tuple of syntax represented as YCPMapRep with <name>
Separator (<string>) separator characters used to separate data elements
Sequence (<syntax>,...) sequence of syntactical constructs
Choice ([<match>, <opt-action>], ...) <string> string constant, verbose match
Whitespace () == Separator (" \t")
String (<string>) string match consisting of characters from <string> if <string> starts with ^, set of characters that do not match represented as YCPStringRep. if <optional-stripped> is given (as a string constant!), these characters are stripped from the match if they're found as leading or trailing characters. i.e. given the string " xxx xxx " matches String (" x") completely and results in " xxx xxx ". With String (" x", " "), leading and trailing blanks are stripped. So " xxx xxx " is still matched but the result is "xxx xxx". When writing such values, stripping is also performed. So writing " xxx xxx " results in the output of "xxx xxx"
Number () integer represented as YCPIntegerRep
Hexval () hexadecimal value represented as YCPIntegerRep
Float () floating point represented as YCPFloatRep
Ip4Number () IP4 address as nnn.nnn.nnn.nnn represented as YCPIntegerRep
Hostname () hostname, with or without domain represented as YCPStringRep
Username () username represented as YCPStringRep
Var (...Name (syntax) ... Value (syntax))
AnyAgent::~AnyAgent | ( | ) |
Cleans up
Get a list of all subtrees.
Dir
show subtree
Implements SCRAgent.
References YCPList::add(), description_read, mSyntax, and ycp2error.
|
private |
References YCPElement::isNull(), mName, YCPTerm::name(), YCPTerm::size(), YCPList::size(), YCPTerm::value(), YCPList::value(), and y2error.
Referenced by readFile(), and Write().
findSyntax
find syntax for path
References YCPTerm::name(), YCPTerm::size(), YCPTerm::value(), y2debug, y2error, YT_STRING, and YT_TERM.
Referenced by Write().
|
private |
References y2error.
Referenced by readFile().
|
private |
References alldata, isFillup, YCPElement::isNull(), line_number, mComment, YCPList::size(), YCPList::value(), and y2debug.
Referenced by parseData().
|
private |
References line_number.
Evaluates the Description () command
Reimplemented from SCRAgent.
References description_read, isFillup, mComment, mHeader, mName, mReadOnly, mSyntax, mType, MTYPE_FILE, MTYPE_LOCAL, MTYPE_NONE, MTYPE_PROG, YCPTerm::name(), YCPTerm::size(), YCPTerm::value(), y2debug, y2warning, and ycp2error.
|
private |
References y2error.
Referenced by parseData().
|
private |
References currentMatch, YCPElement::isNull(), parseData(), YCPList::size(), YCPList::value(), y2debug, and y2error.
Referenced by parseData().
References YCPTerm::args(), currentMatch, getLine(), isFillup, YCPElement::isNull(), KEY4FILLUP, mComment, mReadOnly, YCPTerm::name(), parseBoolean(), parseChoice(), parseFloat(), parseHexval(), parseHostname(), parseIp4Number(), parseList(), parseNumber(), parseSeparator(), parseSequence(), parseString(), parseTuple(), parseUsername(), parseVerbose(), YCPTerm::size(), tupleContinue, tupleName, tupleValue, YCPTerm::value(), y2debug, y2error, YT_STRING, and YT_TERM.
Referenced by parseChoice(), parseList(), parseSequence(), parseTuple(), and validateCache().
|
private |
References y2debug.
Referenced by parseData().
|
private |
References y2error.
Referenced by parseData().
|
private |
References y2error.
Referenced by parseData().
|
private |
AnyAgentBasic.cc
Purpose: basic type handling for AnyAgent
Creator: kkaem Maintainer: pf@s use.d ekkaem pf@s use.d e
References y2error.
Referenced by parseData().
References YCPElement::isNull(), parseData(), YCPList::value(), and y2debug.
Referenced by parseData().
|
private |
References y2error.
Referenced by parseData().
|
private |
Referenced by parseData().
|
private |
References YCPElement::isNull(), parseData(), YCPList::size(), YCPList::value(), and y2debug.
Referenced by parseData().
|
private |
Referenced by parseData().
References YCPElement::isNull(), parseData(), YCPList::size(), tupleContinue, tupleName, tupleValue, YCPList::value(), and y2debug.
Referenced by parseData().
|
private |
References y2error.
Referenced by parseData().
|
private |
Referenced by parseData().
|
private |
|
virtual |
Reads data. Destroy the result after use.
path | Specifies what part of the subtree should be read. The path is specified relatively to Root()! |
Read
read value from relative path
Implements SCRAgent.
References alldata, description_read, isFillup, mComment, mName, mSyntax, readValueByPath(), YCPList::size(), validateCache(), YCPList::value(), y2debug, y2error, and ycp2error.
readFile
read complete file to alldata
References achanged, YCPList::add(), alldata, evalArg(), get_line(), mName, mtime, mType, MTYPE_PROG, y2debug, y2error, and ycp2error.
Referenced by validateCache().
readValueByPath
read sub-value denoted by path
if path == .<num> && value->isList() return element <num> of list
if path == .<name> && value->isMap() return element <name> of list
References YCPElement::isNull(), and y2error.
Referenced by Read().
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
Referenced by unparseData().
References YCPTerm::args(), YCPElement::isNull(), YCPTerm::name(), YCPTerm::size(), tupleContinue, tupleName, tupleValue, unparseBoolean(), unparseChoice(), unparseFloat(), unparseHostname(), unparseIp4Number(), unparseList(), unparseNumber(), unparseSeparator(), unparseSequence(), unparseString(), unparseTuple(), unparseUsername(), unparseVerbose(), YCPTerm::value(), y2debug, y2error, YT_STRING, and YT_TERM.
Referenced by unparseList(), unparseTuple(), Write(), and writeFile().
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
|
private |
References YCPElement::isNull(), and y2debug.
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
References YCPElement::isNull(), YCPTerm::name(), YCPList::size(), unparseData(), YCPList::value(), y2debug, y2error, and YT_TERM.
Referenced by unparseData().
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
Referenced by unparseData().
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
References isFillup, YCPElement::isNull(), KEY4FILLUP, YCPTerm::name(), YCPList::size(), unparseData(), YCPMap::value(), YCPList::value(), y2debug, y2error, and YT_TERM.
Referenced by unparseData().
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
|
private |
References YCPElement::isNull(), and y2debug.
Referenced by unparseData().
|
private |
validateCache
parse file according to mSyntax and construct YCPValueRep
References alldata, cache, cchanged, YCPElement::isNull(), line_number, mSyntax, parseData(), readFile(), y2debug, and ycp2error.
|
virtual |
Writes data. Destroy the result after use.
Write
write value to relative path
return YCPIntegerRep(0) if ok or YCPVoidRep if error
Approach:
descend path to get syntax (gives expected syntax of value) unparse value according to syntax (gives string if value matches syntax, else error) set new value to cache
Implements SCRAgent.
References YCPList::add(), alldata, description_read, evalArg(), findSyntax(), YCPElement::isNull(), mName, mReadOnly, mSyntax, YCPList::size(), unparseData(), validateCache(), YCPList::value(), y2debug, and ycp2error.
|
private |
writeFile
References YCPElement::isNull(), mHeader, and unparseData().
|
private |
writeValueByPath
write sub-value denoted by path to current
return new current
if path == .<num> && value->isList() return element <num> of list
if path == .<name> && value->isMap() return element <name> of list
References YCPElement::isNull(), run, y2debug, and y2error.
|
private |
Referenced by readFile().
|
private |
Referenced by getLine(), Read(), readFile(), validateCache(), and Write().
|
private |
Referenced by validateCache().
|
private |
Referenced by validateCache().
|
private |
Starts with false and is set to true as soon as the Description is read. Any Read/Write/Dir command prior to the reading of the description is invalid.
Referenced by Dir(), otherCommand(), Read(), and Write().
|
private |
Referenced by getLine(), otherCommand(), parseData(), Read(), and unparseTuple().
|
private |
Used for line counting while parsing the target file.
Referenced by getLine(), lineNumber(), and validateCache().
|
private |
comment characters
Referenced by getLine(), otherCommand(), parseData(), and Read().
|
private |
syntax description of header lines
Referenced by otherCommand(), and writeFile().
|
private |
name of system file or program
Referenced by evalArg(), otherCommand(), Read(), readFile(), and Write().
|
private |
true if file is read-only
Referenced by otherCommand(), parseData(), and Write().
|
private |
syntax description of system file
Referenced by Dir(), otherCommand(), Read(), validateCache(), and Write().
|
private |
file cache mtime = file's mtime when alldata was filled cache = parsed file alldata = list of YCPStringRep with all data from file
Referenced by readFile().
enum { ... } AnyAgent::mType |
type of mName
Referenced by otherCommand(), and readFile().
|
private |
Referenced by parseData(), parseTuple(), and unparseData().
|
private |
tuple parsing
Referenced by parseData(), parseTuple(), and unparseData().
Referenced by parseData(), parseTuple(), and unparseData().