dmlite 0.6
dmlite.h File Reference

C wrapper for DMLite. More...

#include "dmlite/common/config.h"
#include "dmlite/common/errno.h"
#include "any.h"
#include <stdlib.h>
#include <sys/stat.h>
#include <utime.h>
Include dependency graph for dmlite.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  dmlite_credentials
 Security credentials. More...
 
struct  dmlite_security_ent
 Used to handle user and group information. More...
 
struct  dmlite_security_context
 Security context. More...
 

Typedefs

typedef struct dmlite_manager dmlite_manager
 Handle for the plugin manager.
 
typedef struct dmlite_context dmlite_context
 Handle for a initialized context.
 
typedef struct dmlite_credentials dmlite_credentials
 Security credentials.
 
typedef struct dmlite_security_ent dmlite_security_ent
 Used to handle user and group information.
 
typedef struct dmlite_security_context dmlite_security_context
 Security context.
 

Functions

unsigned dmlite_api_version (void)
 Gets the API version.
 
dmlite_managerdmlite_manager_new (void)
 Initializes a dmlite_manager.
 
int dmlite_manager_free (dmlite_manager *manager)
 Destroys the manager.
 
int dmlite_manager_load_plugin (dmlite_manager *manager, const char *lib, const char *id)
 Loads a library.
 
int dmlite_manager_set (dmlite_manager *manager, const char *key, const char *value)
 Sets a configuration parameter.
 
int dmlite_manager_load_configuration (dmlite_manager *manager, const char *file)
 Loads a configuration file.
 
int dmlite_manager_get (dmlite_manager *handle, const char *key, char *buffer, size_t bufsize)
 Returns the associated value with the given key.
 
int dmlite_manager_errno (dmlite_manager *manager)
 Returns the last error code.
 
int dmlite_manager_errtype (dmlite_manager *manager)
 Returns the type of the last error.
 
const char * dmlite_manager_error (dmlite_manager *manager)
 Returns the string that describes the last error.
 
dmlite_contextdmlite_context_new (dmlite_manager *manager)
 Returns a usable context from the loaded libraries.
 
int dmlite_context_free (dmlite_context *context)
 Destroys the context.
 
int dmlite_errno (dmlite_context *context)
 Returns the error code from the last failure.
 
int dmlite_errtype (dmlite_context *context)
 Returns the type of the last error.
 
const char * dmlite_error (dmlite_context *context)
 Error string from the last failed function.
 
int dmlite_setcredentials (dmlite_context *context, const dmlite_credentials *cred)
 Sets the user security credentials.
 
const dmlite_security_contextdmlite_get_security_context (dmlite_context *context)
 Returns the security context. There is no need to free.
 
int dmlite_set (dmlite_context *context, const char *k, const dmlite_any *v)
 Sets a configuration parameter tied to a context.
 
int dmlite_set_array (dmlite_context *context, const char *k, unsigned n, dmlite_any *const *v)
 Sets a configuration parameter tied to a context (array version).
 
int dmlite_unset (dmlite_context *context, const char *k)
 Removes a configuration parameter.
 
int dmlite_unset_all (dmlite_context *context)
 Removes all configuration parameters previously set.
 

Detailed Description

C wrapper for DMLite.

Author
Alejandro Álvarez Ayllon aalva.nosp@m.rez@.nosp@m.cern..nosp@m.ch

Typedef Documentation

◆ dmlite_context

Handle for a initialized context.

◆ dmlite_credentials

typedef struct dmlite_credentials dmlite_credentials

Security credentials.

It is up to the caller to allocate and free this pointers. DMLite will keep a copy internaly. Non used values MUST be NULL.

◆ dmlite_manager

Handle for the plugin manager.

◆ dmlite_security_context

typedef struct dmlite_security_context dmlite_security_context

Security context.

◆ dmlite_security_ent

typedef struct dmlite_security_ent dmlite_security_ent

Used to handle user and group information.

Function Documentation

◆ dmlite_api_version()

unsigned dmlite_api_version ( void )

Gets the API version.

◆ dmlite_context_free()

int dmlite_context_free ( dmlite_context * context)

Destroys the context.

Parameters
contextThe context to free.
Returns
0 on success, error code otherwise.

◆ dmlite_context_new()

dmlite_context * dmlite_context_new ( dmlite_manager * manager)

Returns a usable context from the loaded libraries.

Parameters
managerThe plugin manager.
Returns
NULL on failure. The error code can be checked with dmlite_manager_error.
Note
A context is NOT thread safe.

◆ dmlite_errno()

int dmlite_errno ( dmlite_context * context)

Returns the error code from the last failure.

Parameters
contextThe context that was used in the failed function.
Returns
The error code.

◆ dmlite_error()

const char * dmlite_error ( dmlite_context * context)

Error string from the last failed function.

Parameters
contextThe context that was used in the failed function.
Returns
A string with the error description. Do NOT free it.

◆ dmlite_errtype()

int dmlite_errtype ( dmlite_context * context)

Returns the type of the last error.

Parameters
contextThe context that was used in the failed function.
Returns
The error type.

◆ dmlite_get_security_context()

const dmlite_security_context * dmlite_get_security_context ( dmlite_context * context)

Returns the security context. There is no need to free.

Parameters
contextThe DM context.
Returns
The security context.

◆ dmlite_manager_errno()

int dmlite_manager_errno ( dmlite_manager * manager)

Returns the last error code.

Parameters
managerThe plugin manager used in the failing function.
Returns
The last error code, WITHOUT the error type byte.

◆ dmlite_manager_error()

const char * dmlite_manager_error ( dmlite_manager * manager)

Returns the string that describes the last error.

Parameters
managerThe plugin manager used in the failing function.
Returns
A pointer to the error string. Do NOT free it.

◆ dmlite_manager_errtype()

int dmlite_manager_errtype ( dmlite_manager * manager)

Returns the type of the last error.

Parameters
managerThe plugin manager used in the failing function.
Returns
The last error type byte.

◆ dmlite_manager_free()

int dmlite_manager_free ( dmlite_manager * manager)

Destroys the manager.

Parameters
managerThe manager to be destroyed.

◆ dmlite_manager_get()

int dmlite_manager_get ( dmlite_manager * handle,
const char * key,
char * buffer,
size_t bufsize )

Returns the associated value with the given key.

Parameters
managerThe plugin manager.
keyThe configuration parameter.
bufferWhere to leave the string.
bufsizeThe buffer size.

◆ dmlite_manager_load_configuration()

int dmlite_manager_load_configuration ( dmlite_manager * manager,
const char * file )

Loads a configuration file.

Parameters
managerThe plugin manager.
fileThe configuration file
Returns
0 on success, error code otherwise.

◆ dmlite_manager_load_plugin()

int dmlite_manager_load_plugin ( dmlite_manager * manager,
const char * lib,
const char * id )

Loads a library.

Parameters
managerThe plugin manager.
libThe .so file. Usually, (path)/plugin_name.so.
idThe plugin ID. Usually, plugin_name.
Returns
0 on success, error code otherwise.

◆ dmlite_manager_new()

dmlite_manager * dmlite_manager_new ( void )

Initializes a dmlite_manager.

Returns
NULL on failure.

◆ dmlite_manager_set()

int dmlite_manager_set ( dmlite_manager * manager,
const char * key,
const char * value )

Sets a configuration parameter.

Parameters
managerThe plugin manager.
keyThe parameter to set.
valueThe value.
Returns
0 on success, error code otherwise.

◆ dmlite_set()

int dmlite_set ( dmlite_context * context,
const char * k,
const dmlite_any * v )

Sets a configuration parameter tied to a context.

This can be used to pass advanced parameters to a plugin.

Parameters
contextThe DM context.
kThe configuration key.
vValue.
Returns
0 on success, error code otherwise.

◆ dmlite_set_array()

int dmlite_set_array ( dmlite_context * context,
const char * k,
unsigned n,
dmlite_any *const * v )

Sets a configuration parameter tied to a context (array version).

Parameters
contextThe DM context.
kThe configuration key.
nThe configuration key.
vArray of values.
Returns
0 on success, error code otherwise.

◆ dmlite_setcredentials()

int dmlite_setcredentials ( dmlite_context * context,
const dmlite_credentials * cred )

Sets the user security credentials.

Parameters
contextThe DM context.
credThe security credentials.
Returns
0 on success, error code otherwise.

◆ dmlite_unset()

int dmlite_unset ( dmlite_context * context,
const char * k )

Removes a configuration parameter.

Parameters
contextThe DM context.
kThe configuration key.
Returns
0 on success, error code otherwise.

◆ dmlite_unset_all()

int dmlite_unset_all ( dmlite_context * context)

Removes all configuration parameters previously set.

Parameters
contextThe DM context.
Returns
0 on success, error code otherwise.