1SC_ESTABLISH_CONTEXT(3) OpenSC API reference SC_ESTABLISH_CONTEXT(3)
2
3
4
6 sc_establish_context - Establish an OpenSC context
7
9 #include <opensc.h>
10
11 int sc_establish_context(sc_context_t **ctx,
12 const char *appname);
13
14
15
17 This function establishes an OpenSC context. This context is required
18 in all subsequent calls to OpenSC functions.
19
20 ctx is a pointer to a pointer that will receive the allocated context.
21
22 appname is a string that identifies the application. This string will
23 be used to apply application-specific settings from the opensc.conf
24 configuration file. If NULL is passed, only the settings specified in
25 the default section apply; otherwise, settings from the section
26 identified by appname will be applied as well.
27
28 The sc_context structure contains the following members:
29
30 #define SC_MAX_READERS 16
31
32 typedef struct sc_context {
33 struct sc_reader *reader[SC_MAX_READERS];
34 int reader_count;
35 } sc_context_t;
36
37
38 The reader_count field contains the number of readers found.
39 Information on the individual card readers is stored in sc_reader
40 objects, defined as follows:
41
42 typedef struct sc_reader {
43 char *name;
44 int slot_count;
45 }; sc_reader_t;
46
47
48 In this structure, name contains a printable name of the reader, and
49 slot_count has the number of slots supported by this device.
50
52 Returns 0 if successful, or a negative value in case of error.
53
54
55
56opensc 02/16/2010 SC_ESTABLISH_CONTEXT(3)