PSKC Library Manual: global

## global global — Global functions. |

## Functions

int | pskc_global_init ()
void | pskc_global_done ()
void | (*pskc_log_func) ()
void | pskc_global_log ()
void | pskc_free ()

## Description

The library is initialized using `pskc_global_init()` which is a thread-unsafe function that should be called when the code that needs the PSKC library functionality is initialized. When the application no longer needs to use the PSKC Library, it can call `pskc_global_done()` to release resources.

The `pskc_free()` function is used to de-allocate memory that was allocated by the library earlier and returned to the caller.

For debugging, you can implement a function of the pskc_log_func signature and call `pskc_global_log()` to make the library output some messages that may provide additional information.

## Functions

### pskc_global_init ()

    int
    pskc_global_init (void);

This function initializes the PSKC library. Every user of this library needs to call this function before using other functions. You should call `pskc_global_done()` when use of the PSKC library is no longer needed.

#### Returns

On success, `PSKC_OK` (zero) is returned, otherwise an error code is returned.

### pskc_global_done ()

    void
    pskc_global_done (void);

This function deinitializes the PSKC library, which were initialized using `pskc_global_init()`. After calling this function, no other PSKC library function may be called except for to re-initialize the library using `pskc_global_init()`.

### pskc_log_func ()

    void
    (*pskc_log_func) (const char *msg);

### pskc_global_log ()

    void
    pskc_global_log (pskc_log_func log_func);

Enable global debug logging function. The function will be invoked to print various debugging information.

`pskc_log_func` is of the form, void (*pskc_log_func) (const char *msg);

The container and keypackage variables may be NULL if they are not relevant for the debug information printed.

#### Parameters

log_func | new global pskc_log_func log function to use. |

### pskc_free ()

    void
    pskc_free (void *ptr);

Deallocates memory region by calling `free()`. If `ptr` is NULL no operation is performed.

This function is necessary on Windows, where different parts of the same application may use different memory heaps.

#### Parameters

ptr | memory region to deallocate, or NULL. |

## Types and Values