DataVaccinator Client  1.1.0
General API

This section contains global and lifecycle functions. More...

Macros

#define dvDefaultConnectTimeoutSeconds   8
 The default number of seconds to wait for a connection. More...
 
#define dvDefaultSecretPlaceHolder   "^^^SECRET^^^"
 

Typedefs

typedef void * dvCtx
 
typedef int32_t(* dvSetHeaderFn) (void *ctx, const char *name, const char *value)
 
typedef int32_t(* dvHeaderCb) (void *usrCtx, dvSetHeaderFn setHeader, void *headerCtx)
 
typedef int32_t(* dvSetPostFn) (void *ctx, const char *name, void *buf, size_t len)
 
typedef int32_t(* dvPostCb) (void *usrCtx, dvSetPostFn setPostField, void *postCtx)
 

Enumerations

enum  dvCtxOpt {
  DV_PROXY = (uint32_t)57 , DV_PROXY_USER , DV_PROXY_PASS , DV_SERVICE_URL ,
  DV_APP_ID , DV_CONNECT_TIMEOUT , DV_APPNAME , DV_APPVERSION ,
  DV_CERT_PATH , DV_SKIP_CERT_CHECK , DV_CURL_LOGGING
}
 Constants used to set DataVaccinator Client context parameters. More...
 

Functions

DVAPI int32_t dvNew (dvCtx *dc, const char *serviceUrl, const char *appId, KvStore *cache)
 
DVAPI void dvFree (dvCtx dc)
 
DVAPI int32_t dvSetHeaderCb (dvCtx dc, dvHeaderCb callback, void *cbCtx)
 
DVAPI int32_t dvSetPostCb (dvCtx dc, dvPostCb callback, void *cbCtx)
 
DVAPI const char * dvVersion (void)
 Returns the build version of this package. More...
 
DVAPI int dvSetProp (dvCtx dc, enum dvCtxOpt opt, const char *value)
 Sets a DataVaccinator Client context dvCtxOpt option. More...
 
DVAPI const char * dvLastError (void)
 Returns an English textual representation of the last error this thread generated. More...
 

Detailed Description

This section contains global and lifecycle functions.

Macro Definition Documentation

◆ dvDefaultConnectTimeoutSeconds

#define dvDefaultConnectTimeoutSeconds   8

The default number of seconds to wait for a connection.

◆ dvDefaultSecretPlaceHolder

#define dvDefaultSecretPlaceHolder   "^^^SECRET^^^"

The default place holder for any secret specified in dvSetProp with DV_SECRET when DV_SECRET_PLACE_HOLDER has not been specified.

Typedef Documentation

◆ dvCtx

typedef void* dvCtx

Opaque pointer to a datavaccinator object.

◆ dvHeaderCb

typedef int32_t(* dvHeaderCb) (void *usrCtx, dvSetHeaderFn setHeader, void *headerCtx)

Interface of function to be called when it's time to set request headers.

Parameters
usrCtxOpaque context passed as cbCtx to the dvSetHeaderCb function.
setHeaderThe dvSetHeaderFn function to call in order to set the desired headers.
headerCtxOpaque context to be passed as ctx to the given dvSetHeaderFn function.
Returns
RUE_OK on success or error code which will cause the request to be aborted.

◆ dvPostCb

typedef int32_t(* dvPostCb) (void *usrCtx, dvSetPostFn setPostField, void *postCtx)

Interface of function to be called when it's time to set the post fields.

This function can be used to send additional post fields and their associated values to a Service Provider in order to facilitate their particular functionality.

The usage of this callback is subject to the following rules:

Parameters
usrCtxOpaque context passed as cbCtx to the dvSetPostCb function.
setPostFieldThe dvSetPostFn function to call in order to set the desired post fields.
postCtxOpaque context to be passed as ctx to the given dvSetPostFn function.
Returns
RUE_OK on success or error code which will cause the request to be aborted.

◆ dvSetHeaderFn

typedef int32_t(* dvSetHeaderFn) (void *ctx, const char *name, const char *value)

Header setter function interface. When this function is called a header is set or removed. If a header matches a header that is already set, the given header takes precedence. To remove an existing header set its name with a null value. To set an empty header set its name with the value of an empty string. The header name must not include a colon. The caller is responsible for header encoding. The header value must not include line endings such as CRLF.

Parameters
ctxOpaque context to be passed to the function.
nameName of the header to be set. Must only persist for the duration of this function call.
valueValue of the header in unencoded format. Must only persist for the duration of this function call.
Returns
RUE_OK on success or an error code.

◆ dvSetPostFn

typedef int32_t(* dvSetPostFn) (void *ctx, const char *name, void *buf, size_t len)

Post field setter function interface.

Parameters
ctxOpaque context to be passed to the function.
nameName of the header to be set. Must only persist for the duration of this function call.
bufData for the value of the field in unencoded format. Must only persist for the duration of this function call.
lenLength of the given buf parameter.
Returns
RUE_OK on success or an error code.

Enumeration Type Documentation

◆ dvCtxOpt

enum dvCtxOpt

Constants used to set DataVaccinator Client context parameters.

Enumerator
DV_PROXY 

Proxy URL in the form of protocol://hostname:port

DV_PROXY_USER 

Proxy username

DV_PROXY_PASS 

Proxy password

DV_SERVICE_URL 

The service provider URL

DV_APP_ID 

The app-id

DV_CONNECT_TIMEOUT 

Timeout in seconds used for network connections. Defaults to vaccinator.

DV_APPNAME 

The name this client claims to be during connect. Defaults to dvDefaultConnectTimeoutSeconds

DV_APPVERSION 

The version this client claims to be during connect. Defaults to 1.1.0.

DV_CERT_PATH 

File path to certificate authority file or directory.

DV_SKIP_CERT_CHECK 

This will disable SSL certificate verification when set to non 0. Helpful when developing.

DV_CURL_LOGGING 

This will turn on cURL debug logging e when set to non 0 and the general log level is at RU_LOG_VERB.

Function Documentation

◆ dvFree()

DVAPI void dvFree ( dvCtx  dc)

Frees a dvCtx that was created with dvNew when it is no longer needed.

Parameters
dcThe dvCtx to free.

◆ dvLastError()

DVAPI const char* dvLastError ( void  )

Returns an English textual representation of the last error this thread generated.

Note, not all functions use this, so this function should only be called after a function that does use it is called, else misleading information will appear.

Returns
Last error message. Must be copied if it is to persist.

◆ dvNew()

DVAPI int32_t dvNew ( dvCtx dc,
const char *  serviceUrl,
const char *  appId,
KvStore cache 
)

Creates a new Datavaccinator context object.

Parameters
dcWhere the new dvCtx will be stored. Free with dvFree.
serviceUrlThe URL of the Service Provider that this DataVaccinator Client talks to. This may also be the DataVaccinator Vault URL directly if you use the dvSetPostCb to supply the required SID / SPW credentials.
appIdThis is the end users application password for data encryption.
cacheA KvStore instance that can be used as a local data cache. The caller must preserve the KvStore instance for the life of this context and may/should free it afterwards. If NULL no caching will be done.
Returns
RUE_OK on success or an error code.

◆ dvSetHeaderCb()

DVAPI int32_t dvSetHeaderCb ( dvCtx  dc,
dvHeaderCb  callback,
void *  cbCtx 
)

Sets the function to call when the request headers are being written.

Parameters
dcThe dvCtx to work with.
callbackThe dvHeaderCb to call.
cbCtxAn optional context that will be passed into the dvHeaderCb as the usrCtx parameter.
Returns
RUE_OK on success or an error code.

Example

int32_t headerCb(void* usrCtx, dvSetHeaderFn setHeader, void* headerCtx) {
return setHeader(headerCtx, "Cache-Control", "max-age=60");
}
int main ( int argc, char **argv ) {
...
dvSetHeaderCb(ctx, &headerCb, NULL);
...
}
int32_t(* dvSetHeaderFn)(void *ctx, const char *name, const char *value)
Definition: vaccinator.h:482
DVAPI int32_t dvSetHeaderCb(dvCtx dc, dvHeaderCb callback, void *cbCtx)
Remarks
Error handling has been omitted for brevity.

◆ dvSetPostCb()

DVAPI int32_t dvSetPostCb ( dvCtx  dc,
dvPostCb  callback,
void *  cbCtx 
)

Sets the function to call when the post fields are being written.

Parameters
dcThe dvCtx to work with.
callbackThe dvPostCb to call.
cbCtxAn optional context that will be passed into the dvPostCb as the usrCtx parameter.
Returns
RUE_OK on success or an error code.

Example

int32_t postCb(void* usrCtx, dvSetPostFn setPostField, void* postCtx) {
char* myvalue = (char*) usrCtx;
return setPostField(postCtx, "myfield", (void*)myvalue, strlen(myvalue));
}
int main ( int argc, char **argv ) {
...
const char *myvalue = "my special value";
dvSetPostCb(ctx, &postCb, (void*)myvalue);
...
}
int32_t(* dvSetPostFn)(void *ctx, const char *name, void *buf, size_t len)
Definition: vaccinator.h:532
DVAPI int32_t dvSetPostCb(dvCtx dc, dvPostCb callback, void *cbCtx)
Remarks
Error handling has been omitted for brevity.

◆ dvSetProp()

DVAPI int dvSetProp ( dvCtx  dc,
enum dvCtxOpt  opt,
const char *  value 
)

Sets a DataVaccinator Client context dvCtxOpt option.

Parameters
[in]dcThe dvCtx to set the option for.
[in]optThe dvCtxOpt option to set.
[in]valueThe value to set it to or NULL to unset it. The given string will be copied.
Returns
A rferrors status of the operation.

◆ dvVersion()

DVAPI const char* dvVersion ( void  )

Returns the build version of this package.

This is the actual build version and should not be confused with DV_APPVERSION which is sent to the service providers.

Returns
Version of this package. This string is static and must not be freed.