1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
<?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 <link
linkend="openscconf">opensc.conf</link> 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>
|