sc_establish_context(3)

NAME
sc_establish_context - establish OpenSC context

SYNOPSIS
#include <opensc.h>

int sc_establish_context(sc_context_t **ctx,
                         const char *app_name);

DESCRIPTION
This function establishes an OpenSC context. This context is required in all subsequent calls to OpenSC functions.

ctx is a pointer to a pointer that will receive the allocated context.

app_name is a string that identifies the application. This string will be used to apply application-specific from the opensc.conf(5) configuration file. If NULL is passed, just the settings specified in the default section apply; otherwise, settings from the section identified by app_name will be applied as well.

The sc_context structure contains the following members, among others:

typedef struct sc_context {
     struct sc_reader *reader[SC_MAX_READERS];
     int reader_count;
} sc_context_t;

The reader_count field contains the number of readers found by OpenSC. Information on the individual card readers are stored in sc_reader objects, which look like follows:

typedef struct sc_reader {
     char *name;
     int slot_count;
} sc_reader_t;

Here, name contains a printable name of the reader, and slot_count shows the number of slots supported by this device.

Of course, these structs contain other members as well, but applications usually should not use these fields.

RETURN VALUE
If a context could be established, 0 is returned. Otherwise, a negative error code is returned, as described in sc_error(3).

SEE ALSO
sc_release_context(3), sc_detect_card_presence(3), sc_connect_card(3).

AUTHOR
This manual page was written by Olaf Kirch <okir@suse.de>