Miscellaneous Functions: Gck Library Reference Manual

## Miscellaneous Functions Miscellaneous Functions — Other miscellaneous functions. |

## Functions

GList * | gck_list_ref_copy ()
void | gck_list_unref_free ()
gchar * | gck_string_from_chars ()
gboolean | gck_string_to_chars ()
gboolean | gck_value_to_boolean ()
gboolean | gck_value_to_ulong ()
#define | GCK_INVALID

## Types and Values

enum | GckError

## Description

A few supporting functions that come in handy when dealing with the gck library or PKCS11 in general.

## Functions

### gck_list_ref_copy ()

    GList *
    gck_list_ref_copy (GList *reflist);

Copy a list of GObject based pointers. All objects in the list will be reffed and the list will be copied.

[skip]

#### Parameters

reflist | list of GObject reference counted objects. | [element-type GObject.Object]

#### Returns

the copied and reffed list, when done, free it with `gck_list_unref_free()`.

[transfer full][element-type GObject.Object]

### gck_list_unref_free ()

    void
    gck_list_unref_free (GList *reflist);

Free a list of GObject based pointers. All objects in the list will be unreffed and then the list itself will be freed.

[skip]

#### Parameters

reflist | list of Gobject reference counted pointers. | [element-type GObject.Object]

### gck_string_from_chars ()

    gchar *
    gck_string_from_chars (const guchar *data,
                           gsize max);

Create a string from a set of PKCS#11 characters. This is similar to g_strndup, except for that it also strips trailing spaces. These space padded strings are often used in PKCS#11 structures.

If the space padded string is filled with null characters then this function will return `NULL`.

[skip]

#### Parameters

data | The character data to turn into a null terminated string. |
max | The maximum length of the charater data. |

#### Returns

The null terminated string.

### gck_string_to_chars ()

    gboolean
    gck_string_to_chars (guchar *data,
                         gsize max,
                         const gchar *string);

Create a space padded PKCS#11 string from a null terminated string. The string must be shorter than the buffer or `FALSE` will be returned.

If a `NULL` string is passed, then the space padded string will be set to zero characters.

[skip]

#### Parameters

data | The character buffer to place string into. |
max | The maximum length of the charater buffer. |
string | The string to place in the buffer. |

#### Returns

The null terminated string.

### gck_value_to_boolean ()

    gboolean
    gck_value_to_boolean (const guchar *value,
                          gsize length,
                          gboolean *result);

Convert CK_BBOOL type memory to a boolean.

#### Parameters

value | memory to convert. | [array length=length]
length | length of memory |
result | A location to store the result |

#### Returns

Whether the conversion was successful.

### gck_value_to_ulong ()

    gboolean
    gck_value_to_ulong (const guchar *value,
                        gsize length,
                        gulong *result);

Convert CK_ULONG type memory to a boolean.

#### Parameters

value | memory to convert. | [array length=length]
length | length of memory |
result | A location to store the result |

#### Returns

Whether the conversion was successful.

### GCK_INVALID

    #define GCK_INVALID ((gulong)-1)

Used as a terminator at the end of variable argument lists.

## Types and Values

### enum GckError

Various error codes. All the CKR_XXX error codes from PKCS#11 are also relevant error codes.

#### Members

GCK_ERROR_MODULE_PROBLEM | a result code that signifies there was a problem loading a PKCS#11 module, usually a shared library |