Skip to content
Snippets Groups Projects

Minimal c interface

Merged Timm Fitschen requested to merge f-extern-c into dev
All threads resolved!
include/ccaosdb.h 0 → 100644
+ 236
0
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif
/**
* Return the constant caosdb::LIBCAOSDB_VERSION_MAJOR.
*/
const int caosdb_constants_LIBCAOSDB_VERSION_MAJOR();
/**
* Return the constant caosdb::LIBCAOSDB_VERSION_MINOR
*/
const int caosdb_constants_LIBCAOSDB_VERSION_MINOR();
/**
* Return the constant caosdb::LIBCAOSDB_VERSION_PATCH.
*/
const int caosdb_constants_LIBCAOSDB_VERSION_PATCH();
/**
* Return the constant caosdb::COMPATIBLE_SERVER_VERSION_MAJOR.
*/
const int caosdb_constants_COMPATIBLE_SERVER_VERSION_MAJOR();
/**
* Return the constant caosdb::COMPATIBLE_SERVER_VERSION_MINOR.
*/
const int caosdb_constants_COMPATIBLE_SERVER_VERSION_MINOR();
/**
* Return the constant caosdb::COMPATIBLE_SERVER_VERSION_PATCH.
*/
const int caosdb_constants_COMPATIBLE_SERVER_VERSION_PATCH();
/**
* Return the constant caosdb::COMPATIBLE_SERVER_VERSION_PRE_RELEASE.
*/
const char *caosdb_constants_COMPATIBLE_SERVER_VERSION_PRE_RELEASE();
/**
* A wrapper of the C++ Connection class.
*
* We use a wrapper for future extensibility and in order to have a minimal
* capability for type checking in C even though the C++ class
* Connection is opaque in C.
*/
typedef struct {
void *wrapped_connection;
} caosdb_connection_connection;
/**
* A wrapper of the C++ ConnectionConfiguration class.
*
* We use a wrapper for future extensibility and in order to have a minimal
* capability for type checking in C even though the C++ class
* Connection is opaque in C.
*/
typedef struct {
void *wrapped_connection_configuration;
} caosdb_connection_connection_configuration;
/**
* A wrapper of the C++ VersionInfo class.
*
* We use a wrapper for future extensibility and in order to have a minimal
* capability for type checking in C even though the C++ class
* Connection is opaque in C.
*/
typedef struct {
int major;
int minor;
int patch;
const char *pre_release;
const char *build;
} caosdb_info_version_info;
typedef struct {
void *wrapped_certificate_provider;
} caosdb_connection_certificate_provider;
typedef struct {
void *wrapped_authenticator;
} caosdb_authentication_authenticator;
/**
* Return the environment variable of the given name.
*
* If the environment variable is not set, return the fall_back instead.
*/
const char *caosdb_utility_get_env_var(const char *name, const char *fall_back);
/**
* Create a pem-file certificate provider.
*
* Use the destructor function
* `caosdb_connection_delete_certificate_provider` to free the wrapped
* provider.
*
* EXPERT USE ONLY. Memory management with this function is a bit tricky.
* Only use it when you know what you are doing.
*/
int caosdb_connection_create_pem_file_certificate_provider(
caosdb_connection_certificate_provider *out, const char *path);
/**
* Destructor function for a certificate provider.
*
* EXPERT USE ONLY. Only use it when you know what you are doing.
*/
int caosdb_connection_delete_certificate_provider(
caosdb_connection_certificate_provider *provider);
/**
* Create a tls-secured connection configuration.
*
* The configuration is needed to instantiate a connection.
*
* Use the destructor function
* `caosdb_connection_delete_connection_configuration` to free the wrapped
* configuration.
*
* EXPERT USE ONLY. Memory management with this function is a bit tricky.
* Only use it when you know what you are doing.
*/
int caosdb_connection_create_tls_connection_configuration(
caosdb_connection_connection_configuration *out, const char *host,
const int port, caosdb_authentication_authenticator *authenticator,
caosdb_connection_certificate_provider *provider);
/**
* Create a tls-secured connection configuration.
*
* The configuration is needed to instantiate a connection.
*
* Use `caosdb_connection_create_tls_connection_configuration` for a
* tls-secured connection which also supports authentication.
*
* Use the destructor function
* `caosdb_connection_delete_connection_configuration` to free the wrapped
* configuration.
*
* EXPERT USE ONLY. Memory management with this function is a bit tricky.
* Only use it when you know what you are doing.
*/
int caosdb_connection_create_insecure_connection_configuration(
caosdb_connection_connection_configuration *out, const char *host,
const int port);
/**
* Destructor function for the caosdb_connection_connection_configuration
* struct.
*
* EXPERT USE ONLY. Only use it when you know what you are doing.
*/
int caosdb_connection_delete_connection_configuration(
caosdb_connection_connection_configuration *configuration);
/**
* Add a public certificate of a trusted certificate authority to an
* existing, tls-enabled connection configuration.
*
* @param cacert path to a pem-file.
*/
int caosdb_connection_configuration_add_cacert(
caosdb_connection_connection_configuration *configuration,
const char *cacert);
/**
* Create a plain password authenticator.
*
* Use the destructor function
* `caosdb_authentication_delete_authenticator` to free the wrapped
* authenticator.
*
* EXPERT USE ONLY. Memory management with this function is a bit tricky.
* Only use it when you know what you are doing.
*/
int caosdb_authentication_create_plain_password_authenticator(
caosdb_authentication_authenticator *out, const char *username,
const char *password);
/**
* Destructor function for the caosdb_authentication_authenticator struct.
*
* EXPERT USE ONLY. Only use it when you know what you are doing.
*/
int caosdb_authentication_delete_authenticator(
caosdb_authentication_authenticator *authenticator);
/**
* Create a connection instance.
*
* The connection is needed to create transactions and to initiate any other
* interaction with a CaosDB server.
*
* Use the destructor function
* `caosdb_connection_delete_connection` to free the wrapped
* connection.
*
* EXPERT USE ONLY. Memory management with this function is a bit tricky.
* Only use it when you know what you are doing.
*/
int caosdb_connection_create_connection(
caosdb_connection_connection *out,
const caosdb_connection_connection_configuration *configuration);
/**
* Destructor function for the caosdb_connection_connection struct.
*
* EXPERT USE ONLY. Only use it when you know what you are doing.
*/
int caosdb_connection_delete_connection(
caosdb_connection_connection *connection);
/**
* Request the version of the server.
*/
int caosdb_connection_get_version_info(
caosdb_info_version_info *out,
const caosdb_connection_connection *connection);
/**
* Get the default connection from the ConnectionManager.
*
* The default connection is to be specified in a configuration file.
*/
int caosdb_connection_connection_manager_get_default_connection(
caosdb_connection_connection *out);
/**
* Get a named connection from the ConnectionManager.
*
* The named connection is to be specified in a configuration file.
*/
int caosdb_connection_connection_manager_get_connection(
caosdb_connection_connection *out, const char *name);
#ifdef __cplusplus
}
#endif
Loading