86 lines
2.3 KiB
XML
86 lines
2.3 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<refentry id="scestablishcontext">
|
|
<refentryinfo><title>OpenSC API Reference</title></refentryinfo>
|
|
<refmeta>
|
|
<refentrytitle>sc_establish_context</refentrytitle>
|
|
<manvolnum>3</manvolnum>
|
|
<refmiscinfo>opensc</refmiscinfo>
|
|
</refmeta>
|
|
|
|
<refnamediv>
|
|
<refname>sc_establish_context</refname>
|
|
<refpurpose>Establish an OpenSC context</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
<title>Synopsis</title>
|
|
<para>
|
|
<programlisting>
|
|
#include <opensc.h>
|
|
|
|
int sc_establish_context(sc_context_t **ctx,
|
|
const char *appname);
|
|
</programlisting>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<para>
|
|
This function establishes an OpenSC context. This context is required
|
|
in all subsequent calls to OpenSC functions.
|
|
</para>
|
|
<para>
|
|
<emphasis>ctx</emphasis> is a pointer to a pointer that will receive the allocated context.
|
|
</para>
|
|
|
|
<para>
|
|
<emphasis>appname</emphasis> 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 <emphasis>appname</emphasis> will be applied as well.
|
|
</para>
|
|
|
|
<para>
|
|
The <structname>sc_context</structname> structure contains the following members:
|
|
</para>
|
|
|
|
<para>
|
|
<programlisting>
|
|
#define SC_MAX_READERS 16
|
|
|
|
typedef struct sc_context {
|
|
struct sc_reader *reader[SC_MAX_READERS];
|
|
int reader_count;
|
|
} sc_context_t;
|
|
</programlisting>
|
|
</para>
|
|
|
|
<para>
|
|
The <emphasis>reader_count</emphasis> field contains the number of readers found. Information on
|
|
the individual card readers is stored in <emphasis>sc_reader</emphasis> objects, defined as
|
|
follows:
|
|
</para>
|
|
|
|
<para>
|
|
<programlisting>
|
|
typedef struct sc_reader {
|
|
char *name;
|
|
int slot_count;
|
|
}; sc_reader_t;
|
|
</programlisting>
|
|
</para>
|
|
|
|
<para>In this structure, <emphasis>name</emphasis> contains a printable name of the reader, and
|
|
<emphasis>slot_count</emphasis> has the number of slots supported by this device.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1>
|
|
<title>Return value</title>
|
|
<para>Returns 0 if successful, or a negative value in case of error.</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|