Barrelfish
Macros | Functions
getset.h File Reference

Header file for the octopus get/set API. More...

Macros

#define SET_DEFAULT   (0x0)
 
#define SET_SEQUENTIAL   (0x1)
 
#define SET_TRANSIENT   (0x1 << 1)
 

Functions

errval_t oct_get_names (char ***names, size_t *, const char *,...)
 Retrieve all record names matching a given query. More...
 
errval_t oct_parse_names (char *input, char ***names, size_t *)
 Parses output from get_names call and stores it in an array. More...
 
void oct_free_names (char **, size_t)
 Helper function to free an array of strings. More...
 
errval_t oct_get (char **, const char *,...)
 Gets one record matching the given query. More...
 
errval_t oct_set (const char *,...)
 Sets a record. More...
 
errval_t oct_get_with_idcap (char **, struct capref)
 Gets one record using the ID capability as the key/name. More...
 
errval_t oct_set_with_idcap (struct capref, const char *,...)
 Sets a record using the ID capability as the name/key of the record. More...
 
errval_t oct_mset (oct_mode_t, const char *,...)
 Sets a record. More...
 
errval_t oct_set_get (oct_mode_t, char **, const char *,...)
 Sets a record and returns and in case of no error returns it to the client. More...
 
errval_t oct_del (const char *,...)
 Deletes all records matching the given query. More...
 
errval_t oct_exists (const char *,...)
 Checks if a result for a given query exists. More...
 
errval_t oct_wait_for (char **, const char *,...)
 Waits until a given record exists. More...
 
errval_t oct_read (const char *, const char *,...)
 Reads the content of a record string based on the provided format. Currently supported d (int64_t*), f (double*?), s (char**). More...
 

Detailed Description

Header file for the octopus get/set API.

Macro Definition Documentation

#define SET_DEFAULT   (0x0)

Normal set mode for records.

#define SET_SEQUENTIAL   (0x1)

Append a monotonically increasing number (based on the record name) to the name of the record.

#define SET_TRANSIENT   (0x1 << 1)

Record gets deleted as soon as the domain has ended it's execution.

Function Documentation

errval_t oct_del ( const char *  query,
  ... 
)

Deletes all records matching the given query.

Parameters
querySpecifies the record(s) to be deleted.
...Additional arguments to format the query using vsprintf.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD
OCT_ERR_NO_RECORD_NAME
OCT_ERR_ENGINE_FAIL
OCT_ERR_PARSER_FAILTODO: Atm only name of record is included in del query on server.
errval_t oct_exists ( const char *  query,
  ... 
)

Checks if a result for a given query exists.

Parameters
queryResults are searched based on the query.
...Additional arguments to format the query using vsprintf.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD
OCT_ERR_PARSER_FAIL
OCT_ERR_ENGINE_FAIL
void oct_free_names ( char **  names,
size_t  len 
)

Helper function to free an array of strings.

Frees all entries of the array and the array itself.

Parameters
namesNon-null array of strings.
lenSize of the names array
See also
oct_get_names
errval_t oct_get ( char **  data,
const char *  query,
  ... 
)

Gets one record matching the given query.

Parameters
[out]dataRecord returned by the server.
[in]queryThe query sent to the server.
...Additional arguments to format the query using vsprintf.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD
OCT_ERR_AMBIGOUS_QUERYTODO!
OCT_ERR_PARSER_FAIL
OCT_ERR_ENGINE_FAIL
errval_t oct_get_names ( char ***  names,
size_t *  len,
const char *  query,
  ... 
)

Retrieve all record names matching a given query.

Parameters
[out]namesNames of all records matching the query. Needs to be freed by the client (use oct_free_names) in case of SYS_ERR_OK/LIB_ERR_MALLOC_FAIL.
[out]sizeNumber of records matching the query. 0 in case of error.
[in]queryQuery sent to the server
...Parameters used to build query with help of vsprintf.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD
OCT_ERR_PARSER_FAIL
OCT_ERR_ENGINE_FAIL
LIB_ERR_MALLOC_FAIL
errval_t oct_get_with_idcap ( char **  data,
struct capref  idcap 
)

Gets one record using the ID capability as the key/name.

Parameters
[out]dataRecord returned by the server.
[in]idcapID capability used as the key/name of the record.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD
OCT_ERR_PARSER_FAIL
OCT_ERR_ENGINE_FAIL
errval_t oct_mset ( oct_mode_t  mode,
const char *  query,
  ... 
)

Sets a record.

Parameters
queryThe record to set.
modeA combination of mode bits (see getset.h).
...Additional arguments to format the query using vsprintf.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD_NAME
OCT_ERR_PARSER_FAIL
OCT_ERR_ENGINE_FAIL
errval_t oct_parse_names ( char *  input,
char ***  names,
size_t *  len 
)

Parses output from get_names call and stores it in an array.

Note
Use oct_free_names() to free names array.
Parameters
[in]inputComma separated string of names
[out]namesArray of strings containing all names
[out]lenSize of array.
Return values
LIB_ERR_MALLOC_FAIL
SYS_ERR_OK
errval_t oct_read ( const char *  record,
const char *  format,
  ... 
)

Reads the content of a record string based on the provided format. Currently supported d (int64_t*), f (double*?), s (char**).

ATTENTION: Currently we only parse 64-bit numbers (with d). This function tends to behave badly when calling it with 32bit pointers (i.e., oct_read(rec, "_ {iref: 1}", (iref_t) iref);) Don't do it!

: docs && support proper scan types from (inttypes.h)

Parameters
recordRecord to read.
formatWhat you want to read.
...Values read are stored in the provided arguments.
Return values
SYS_ERR_OK
OCT_ERR_ATTRIBUTE_NOT_FOUND
OCT_ERR_TYPE_MISMATCH
OCT_ERR_RECORD_NAME_MISMATCH
OCT_ERR_ATTRIBUTE_MISMATCH
errval_t oct_set ( const char *  query,
  ... 
)

Sets a record.

Parameters
queryThe record to set.
...Additional arguments to format the query using vsprintf.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD_NAME
OCT_ERR_PARSER_FAIL
OCT_ERR_ENGINE_FAIL
errval_t oct_set_get ( oct_mode_t  mode,
char **  record,
const char *  query,
  ... 
)

Sets a record and returns and in case of no error returns it to the client.

Additonally the mode how a record is set can be specified.

Parameters
modeA combination of mode bits (see getset.h).
[out]recordThe new record.
[in]queryThe record to set.
...Additional arguments to format the query using vsprintf.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD_NAME
OCT_ERR_PARSER_FAIL
OCT_ERR_ENGINE_FAILTODO maybe remove this function completely and let all use rpc call for set directly if they want to a non-trivial set?
errval_t oct_set_with_idcap ( struct capref  idcap,
const char *  attributes,
  ... 
)

Sets a record using the ID capability as the name/key of the record.

Parameters
idcapID capability used as the name/key of the record.
attributesAttributes of the record.
...Additional arguments to format the attributes using vsprintf.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD_NAME
OCT_ERR_PARSER_FAIL
OCT_ERR_ENGINE_FAIL
errval_t oct_wait_for ( char **  record,
const char *  query,
  ... 
)

Waits until a given record exists.

Parameters
recordRecord that matched the query, callee has to free this.
queryFormat of record to wait for.
...Additional arguments to format query.
Note
This call blocks on the octopus RPC waitset if the record is not there yet.
Return values
SYS_ERR_OK