sa_ctx_key


Purpose

Gets, sets, or clears data associated with an application. The Sambar Server allows applications to store data at the context level, thereby making this data available to any other application method.

Syntax

sa_ctx_key (context, action, key, value);

SA_CTX *context;
SA_INT action;
SA_CHAR *key;
SA_VOID **value;

Parameters

context Server context.
action To get the data associated with key, specify SA_GET.

To associate data with key, specify SA_SET.

To clear the data associated with key, specify SA_CLEAR.

key The key (name) associated with the data being retrieved, set, or cleared. The length of the key can not exceed 50 bytes. The function's key parameter enables an application to separately store and retrieve multiple pieces of data uniquely naming each one.
value If action is SA_GET, the value of key is returned in this parameter.

If action is SA_SET, specify the value to assign to key.

If action is SA_CLEAR, specify NULL.

Returns

SA_SUCCEED if the function is successful; SA_FAIL otherwise.

Comments

A key is simply a name assigned to a particular piece of data, making it easy to reference the data. Because data is stored in a global area accessible to all applications, applications must store data with unique keys. If an application stores data with a key identical to data already stored in memory, the data stored by the first application is overwritten.

Applications can associate data of any kind with a key.

Applications are responsible for allocating memory in which to store the data before calling sa_ctx_key(SA_SET). This also means that when clearing data, applications are responsible for de-allocating that same memory.

See Also

sa_conn_key