$darkmode
Elektra 0.11.0
Functions
kdbgopts.h File Reference

Gopts contract. More...

#include <kdb.h>
Include dependency graph for kdbgopts.h:
This graph shows which files directly or indirectly include this file:

Functions

int elektraGOptsContract (KeySet *contract, int argc, const char *const *argv, const char *const *envp, const Key *parentKey, KeySet *goptsConfig)
 Sets up a contract for use with kdbOpen() that configures the gopts plugin. More...
 
int elektraGOptsContractFromStrings (KeySet *contract, size_t argsSize, const char *args, size_t envSize, const char *env, const Key *parentKey, KeySet *goptsConfig)
 Sets up a contract for use with kdbOpen() that configures the gopts plugin. More...
 

Detailed Description

Gopts contract.

Function Documentation

◆ elektraGOptsContract()

int elektraGOptsContract ( KeySet *  contract,
int  argc,
const char *const *  argv,
const char *const *  envp,
const Key *  parentKey,
KeySet *  goptsConfig 
)

Sets up a contract for use with kdbOpen() that configures the gopts plugin.

You can pass 0 for argc and NULL for argv to let gopts lookup command line options internally. You can also pass NULL for envp to do the same for environment variables.

Parameters
contractThe KeySet into which the contract will be written.
argcThe argc value that should be used by gopts.
argvThe argv value that should be used by gopts. IMPORTANT: The pointer and data behind must be valid until after kdbClose() is called.
envpThe envp value that should be used by gopts. IMPORTANT: The pointer and data behind must be valid until after kdbClose() is called.
parentKeyThe parent key that should be used by gopts. Only the key name is copied. The key can be deleted immediately after calling this function.
goptsConfigThe config that used to mount the gopts plugin. This value can be NULL. Only keys in the user:/ namespace will be used.
Return values
-1if contract or parentKey is NULL
-1if argc is 0 and argv is not NULL or if argc is not 0 and argv is NULL
0on success

◆ elektraGOptsContractFromStrings()

int elektraGOptsContractFromStrings ( KeySet *  contract,
size_t  argsSize,
const char *  args,
size_t  envSize,
const char *  env,
const Key *  parentKey,
KeySet *  goptsConfig 
)

Sets up a contract for use with kdbOpen() that configures the gopts plugin.

NOTE: prefer to use elektraGOptsContract() if possible

You can pass NULL for args to let gopts lookup command line options internally. You can also pass NULL for env to do the same for environment variables.

Parameters
contractThe KeySet into which the contract will be written.
argsSizeThe size of the args data
argsContinuous buffer containing all argv arguments separated (and terminated) by zero bytes. The whole buffer is copied, so the pointer only has to be valid for this function call.
envSizeThe size of the env data
envContinuous buffer containing all environment variables separated (and terminated) by zero bytes The whole buffer is copied, so the pointer only has to be valid for this function call.
parentKeyThe parent key that should be used by gopts. Only the key name is copied. The key can be deleted immediately after calling this function.
goptsConfigThe config that used to mount the gopts plugin. This value can be NULL. Only keys in the user:/ namespace will be used.
Return values
-1if any of contract or parentKey is NULL
0on success