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
39 The reader_count field contains the number of readers found.
40 Information on the individual card readers is stored in sc_reader
41 objects, defined as follows:
42
43 typedef struct sc_reader {
44 char *name;
45 int slot_count;
46 }; sc_reader_t;
47
48
49
50 In this structure, name contains a printable name of the reader, and
51 slot_count has the number of slots supported by this device.
52
54 Returns 0 if successful, or a negative value in case of error.
55
56
57
58opensc 05/04/2007 SC_ESTABLISH_CONTEXT(3)