Show
Ignore:
Timestamp:
04/29/08 19:01:19 (7 months ago)
Author:
alonbl
Message:

Plug&Play support

This is not the best solution, but focus on smallest code change.

Changes:

1. Add detect_readers() to reader opts, this adds new readers to the end

of the readers list until list is full.

2. Add sc_ctx_detect_readers() that calls readers' detect_readers().

3. Fixup pcsc_lock() so that it reconnect to the card and report proper

error so caller may be notified if session was lost.

4. Allow context to be created without readers.

5. Call sc_ctx_detect_readers() from PKCS#11 C_GetSlotList with NULL_PTR.

6. Allow no reader at detect_card, as reader my be removed.

7. Since I broke ABI, I updated the external module version requirement

to match OpenSC version. In the future a separate version should be
maintained for each interface, this should be unrelated to the package
version.

Alon

---

svn merge -r 3480:3505 https://www.opensc-project.org/svn/opensc/branches/alonbl/pnp

M src/tools/opensc-tool.c
M src/pkcs11/pkcs11-global.c
M src/pkcs11/slot.c
M src/libopensc/reader-pcsc.c
M src/libopensc/internal-winscard.h
M src/libopensc/ctx.c
M src/libopensc/reader-ctapi.c
M src/libopensc/libopensc.exports
M src/libopensc/reader-openct.c
M src/libopensc/opensc.h

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/libopensc/ctx.c

    r3495 r3506  
    355355        /* verify module version */ 
    356356        version = modversion(); 
    357         if (version == NULL || strncmp(version, "0.9.", strlen("0.9.")) > 0) { 
     357        /* XXX: We really need to have ABI version for each interface */ 
     358        if (version == NULL || strncmp(version, PACKAGE_VERSION, strlen(PACKAGE_VERSION)) != 0) { 
    358359                sc_error(ctx,"dynamic library '%s': invalid module version\n",libname); 
    359360                lt_dlclose(handle); 
     
    638639} 
    639640 
     641int sc_ctx_detect_readers(sc_context_t *ctx) 
     642{ 
     643        int i; 
     644 
     645        sc_mutex_lock(ctx, ctx->mutex); 
     646 
     647        for (i = 0; ctx->reader_drivers[i] != NULL; i++) { 
     648                const struct sc_reader_driver *drv = ctx->reader_drivers[i]; 
     649 
     650                if (drv->ops->detect_readers != NULL) 
     651                        drv->ops->detect_readers(ctx, ctx->reader_drv_data[i]); 
     652        } 
     653 
     654        sc_mutex_unlock(ctx, ctx->mutex); 
     655 
     656        /* XXX: Do not ignore erros? */ 
     657        return SC_SUCCESS; 
     658} 
     659 
    640660sc_reader_t *sc_ctx_get_reader(sc_context_t *ctx, unsigned int i) 
    641661{ 
     
    725745        del_drvs(&opts, 0); 
    726746        del_drvs(&opts, 1); 
    727         if (ctx->reader_count == 0) { 
    728                 sc_release_context(ctx); 
    729                 return SC_ERROR_NO_READERS_FOUND; 
    730         } 
     747        sc_ctx_detect_readers(ctx); 
    731748        *ctx_out = ctx; 
    732749        return SC_SUCCESS;