util-vserver (libvserver)  0.30.216-pre3126
Data Structures | Functions
Helper functions

Data Structures

struct  vc_err_listparser
 Information about parsing errors. More...
 

Functions

size_t vc_get_nb_ipv4root () VC_ATTR_CONST
 Returns the value of NB_IPV4ROOT.This function returns the value of NB_IPV4ROOT which was used when the library was built, but not the value which is used by the currently running kernel.
 
bool vc_parseLimit (char const *str, vc_limit_t *res)
 Parses a string describing a limitThis function parses str and interprets special words like "inf" or suffixes. Valid suffixes are. More...
 
uint_least64_t vc_text2bcap (char const *str, size_t len)
 Converts a single string into bcapability. More...
 
char const * vc_lobcap2text (uint_least64_t *val)
 Converts the lowest bit of a bcapability or the entire value (when possible) to a textual representation. More...
 
int vc_list2bcap (char const *str, size_t len, struct vc_err_listparser *err, struct vc_ctx_caps *cap)
 Converts a string into a bcapability-bitmaskSyntax of str:

LIST   <- ELEM  | ELEM ',' LIST
ELEM   <- '~' ELEM | MASK | NAME
MASK   <- NUMBER | '^' NUMBER
NUMBER <- 0[0-7]* | [1-9][0-9]* | 0x[0-9,a-f]+
NAME   <- <literal name> | "all" | "any" | "none"

. More...

 

Detailed Description

Functions which are doing general helper tasks like parameter parsing.

Function Documentation

int vc_list2bcap ( char const *  str,
size_t  len,
struct vc_err_listparser err,
struct vc_ctx_caps cap 
)

Converts a string into a bcapability-bitmaskSyntax of str:

LIST   <- ELEM  | ELEM ',' LIST
ELEM   <- '~' ELEM | MASK | NAME
MASK   <- NUMBER | '^' NUMBER
NUMBER <- 0[0-7]* | [1-9][0-9]* | 0x[0-9,a-f]+
NAME   <- <literal name> | "all" | "any" | "none"

.

When the `~' prefix is used, the bits will be unset and a `~' after another `~' will cancel both ones. The `^' prefix specifies a bitnumber instead of a bitmask.

"literal name" is everything which will be accepted by the vc_text2bcap() function. The special values for NAME will be recognized case insensitively

Parameters
strThe string to be parsed
lenThe length of the string, or 0 for automatic detection
errPointer to a structure for error-information, or NULL.
capPointer to a vc_ctx_caps structure holding the results; only the bcaps and bmask fields will be changed and already set values will not be honored. When an error occured, cap will have the value of all processed valid BCAP parts.
Returns
0 on success, -1 on error. In error case, err will hold position and length of the first not understood BCAP part
Precondition
str != 0 && cap != 0; cap->bcaps and cap->bmask must be initialized
char const* vc_lobcap2text ( uint_least64_t *  val)

Converts the lowest bit of a bcapability or the entire value (when possible) to a textual representation.

Parameters
valThe string to be converted; on success, the detected bit(s) will be unset, in errorcase only the lowest set bit
Returns
A textual representation of val resp. of its lowest set bit; or NULL in errorcase.
Precondition
val!=0
Postcondition
*valold != 0 <–> *valold > *valnew
*valold == 0 —> result == 0
bool vc_parseLimit ( char const *  str,
vc_limit_t res 
)

Parses a string describing a limitThis function parses str and interprets special words like "inf" or suffixes. Valid suffixes are.

  • k ... 1000
  • m ... 1000000
  • K ... 1024
  • M ... 1048576
Parameters
strThe string which shall be parsed
resWill be filled with the interpreted value; in errorcase, this value is undefined.
Returns
true, iff the string str could be parsed. res will be filled with the interpreted value in this case.
Precondition
str!=0 && res!=0
uint_least64_t vc_text2bcap ( char const *  str,
size_t  len 
)

Converts a single string into bcapability.

Parameters
strThe string to be parsed; both "CAP_xxx" and "xxx" will be accepted
lenThe length of the string, or 0 for automatic detection
Returns
0 on error; a bitmask on success
Precondition
str != 0