[EMAIL PROTECTED] wrote:

> What  do you think about something like this:
> NOTE: you can open  the same library more than once; they
> (dlopen/dlclose) maintain a reference count .
> 
> #define MAX_CARD_TERMINAL 32
> 
> struct ct_handle {
>         void *libp;
>         int (*CT_init)  (unsigned int ctn, int pn);
>         int (*CT_data)  (...)  /* The right prototype for CT_data */
>         int (*CT_close) (unsigned int ctn);
> };
> 
> struct ct_handle cts[MAX_CARD_TERMINAL];
> 
> int CTB_LoadCTLibrary (unsigned int ctn, const char *cfg, const char *rdr)
> {
>         ...
>         cts[ctn].libp = dlopen ("The right library");
>         cts[ctn].CT_init = dlsym (cts[ctn].libp,  "CT_init");
>         ...
> }
> 
> int CT_CloseCTLibrary  (unsigned int ctn)
> {
>         ...
>         dlclose (cts[ctn].libp);
>         ...
> }
> 
> int CTB_Data (unsigned int ctn,  ...)
> {
>         ...
>         cts[ctn].CT_data (...);
>         ...
> }

look quite good to me.

gregor
***************************************************************
Linux Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/smartcard/index.html
***************************************************************

Reply via email to