Main Page | Modules | Data Structures | File List | Data Fields | Globals

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.
bool vc_parseLimit (char const *str, vc_limit_t *res)
 Parses a string describing a limit.
uint_least64_t vc_text2bcap (char const *str, size_t len)
 Converts a single string into bcapability.
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.
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-bitmask.

Detailed Description

Functions which are doing general helper tasks like parameter parsing.

Function Documentation

size_t vc_get_nb_ipv4root  ) 
 

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.

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-bitmask.

Syntax 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:
str The string to be parsed
len The length of the string, or 0 for automatic detection
err Pointer to a structure for error-information, or NULL.
cap Pointer 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:
val The 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 limit.

This function parses str and interprets special words like "inf" or suffixes. Valid suffixes are

  • k ... 1000
  • m ... 1000000
  • K ... 1024
  • M ... 1048576

Parameters:
str The string which shall be parsed
res Will 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:
str The string to be parsed; both "CAP_xxx" and "xxx" will be accepted
len The length of the string, or 0 for automatic detection
Returns:
0 on error; a bitmask on success
Precondition:
str != 0


Generated on Fri Jan 28 17:47:54 2005 for util-vserver (libvserver) by  doxygen 1.4.1