sc_establish_context(3) Establish an OpenSC context

SYNOPSIS


#include <opensc.h>
int sc_establish_context(sc_context_t **ctx,
const char *appname);

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.

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

The sc_context structure contains the following members:

#define SC_MAX_READERS                  16
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. Information on the individual card readers is stored in sc_reader objects, defined as follows:

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

In this structure, name contains a printable name of the reader, and slot_count has the number of slots supported by this device.

RETURN VALUE

Returns 0 if successful, or a negative value in case of error.