removed const in sc_card_driver (caused win32 crash)

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@918 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
sth 2003-02-20 12:51:07 +00:00
parent b75ea0a0b2
commit 9631ef3636
12 changed files with 52 additions and 51 deletions

View File

@ -22,7 +22,7 @@
#include "log.h" #include "log.h"
static struct sc_card_operations default_ops; static struct sc_card_operations default_ops;
static const struct sc_card_driver default_drv = { static struct sc_card_driver default_drv = {
"Default driver for unknown cards", "Default driver for unknown cards",
"default", "default",
&default_ops &default_ops
@ -90,7 +90,7 @@ static int autodetect_class(struct sc_card *card)
return 0; return 0;
} }
if (rbuf[0] == 0x00 && rbuf[1] == 0x00) { if (rbuf[0] == 0x00 && rbuf[1] == 0x00) {
const struct sc_card_driver *drv; struct sc_card_driver *drv;
if (card->ctx->debug >= 2) if (card->ctx->debug >= 2)
debug(card->ctx, "SELECT FILE seems to return Schlumberger 'flex stuff\n"); debug(card->ctx, "SELECT FILE seems to return Schlumberger 'flex stuff\n");
drv = sc_get_flex_driver(); drv = sc_get_flex_driver();
@ -114,9 +114,9 @@ static int default_init(struct sc_card *card)
return 0; return 0;
} }
static const struct sc_card_driver * sc_get_driver(void) static struct sc_card_driver * sc_get_driver(void)
{ {
const struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
default_ops = *iso_drv->ops; default_ops = *iso_drv->ops;
default_ops.match_card = default_match_card; default_ops.match_card = default_match_card;
@ -127,7 +127,7 @@ static const struct sc_card_driver * sc_get_driver(void)
} }
#if 1 #if 1
const struct sc_card_driver * sc_get_default_driver(void) struct sc_card_driver * sc_get_default_driver(void)
{ {
return sc_get_driver(); return sc_get_driver();
} }

View File

@ -23,7 +23,7 @@
#include <string.h> #include <string.h>
static struct sc_card_operations emv_ops; static struct sc_card_operations emv_ops;
static const struct sc_card_driver emv_drv = { static struct sc_card_driver emv_drv = {
"EMV compatible cards", "EMV compatible cards",
"emv", "emv",
&emv_ops &emv_ops
@ -127,7 +127,7 @@ static int emv_select_file(struct sc_card *card, const struct sc_path *path,
struct sc_file **file) struct sc_file **file)
{ {
int r; int r;
const struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
const struct sc_card_operations *ops = iso_drv->ops; const struct sc_card_operations *ops = iso_drv->ops;
r = ops->select_file(card, path, file); r = ops->select_file(card, path, file);
@ -140,9 +140,9 @@ static int emv_select_file(struct sc_card *card, const struct sc_path *path,
return 0; return 0;
} }
static const struct sc_card_driver * sc_get_driver(void) static struct sc_card_driver * sc_get_driver(void)
{ {
const struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
emv_ops = *iso_drv->ops; emv_ops = *iso_drv->ops;
emv_ops.match_card = emv_match_card; emv_ops.match_card = emv_match_card;
@ -154,7 +154,7 @@ static const struct sc_card_driver * sc_get_driver(void)
} }
#if 1 #if 1
const struct sc_card_driver * sc_get_emv_driver(void) struct sc_card_driver * sc_get_emv_driver(void)
{ {
return sc_get_driver(); return sc_get_driver();
} }

View File

@ -39,7 +39,7 @@
static const struct sc_card_operations *iso_ops = NULL; static const struct sc_card_operations *iso_ops = NULL;
struct sc_card_operations etoken_ops; struct sc_card_operations etoken_ops;
const struct sc_card_driver etoken_drv = { struct sc_card_driver etoken_drv = {
"Aladdin eToken PRO", "Aladdin eToken PRO",
"etoken", "etoken",
&etoken_ops &etoken_ops
@ -822,7 +822,7 @@ etoken_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data,
/* eToken R2 supports WRITE_BINARY, PRO Tokens support UPDATE_BINARY */ /* eToken R2 supports WRITE_BINARY, PRO Tokens support UPDATE_BINARY */
static const struct sc_card_driver * sc_get_driver(void) static struct sc_card_driver * sc_get_driver(void)
{ {
if (iso_ops == NULL) if (iso_ops == NULL)
iso_ops = sc_get_iso7816_driver()->ops; iso_ops = sc_get_iso7816_driver()->ops;
@ -847,7 +847,7 @@ static const struct sc_card_driver * sc_get_driver(void)
} }
#if 1 #if 1
const struct sc_card_driver * sc_get_etoken_driver(void) struct sc_card_driver * sc_get_etoken_driver(void)
{ {
return sc_get_driver(); return sc_get_driver();
} }

View File

@ -87,7 +87,7 @@ struct flex_private_data {
static struct sc_card_operations flex_ops; static struct sc_card_operations flex_ops;
static struct sc_card_operations *iso_ops; static struct sc_card_operations *iso_ops;
static const struct sc_card_driver flex_drv = { static struct sc_card_driver flex_drv = {
"Schlumberger Multiflex/Cryptoflex", "Schlumberger Multiflex/Cryptoflex",
"flex", "flex",
&flex_ops &flex_ops
@ -854,7 +854,7 @@ static int flex_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data,
return iso_ops->pin_cmd(card, data, NULL); return iso_ops->pin_cmd(card, data, NULL);
} }
static const struct sc_card_driver * sc_get_driver(void) static struct sc_card_driver * sc_get_driver(void)
{ {
if (iso_ops == NULL) if (iso_ops == NULL)
iso_ops = sc_get_iso7816_driver()->ops; iso_ops = sc_get_iso7816_driver()->ops;
@ -876,7 +876,7 @@ static const struct sc_card_driver * sc_get_driver(void)
} }
#if 1 #if 1
const struct sc_card_driver * sc_get_flex_driver(void) struct sc_card_driver * sc_get_flex_driver(void)
{ {
return sc_get_driver(); return sc_get_driver();
} }

View File

@ -117,7 +117,7 @@ static struct atrinfo {
* Driver and card ops structures * Driver and card ops structures
*/ */
static struct sc_card_operations gpk_ops, *iso_ops; static struct sc_card_operations gpk_ops, *iso_ops;
static const struct sc_card_driver gpk_drv = { static struct sc_card_driver gpk_drv = {
"Gemplus GPK driver", "Gemplus GPK driver",
"gpk", "gpk",
&gpk_ops &gpk_ops
@ -1762,11 +1762,11 @@ gpk_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left)
/* /*
* Initialize the driver struct * Initialize the driver struct
*/ */
static const struct sc_card_driver * static struct sc_card_driver *
sc_get_driver() sc_get_driver()
{ {
if (gpk_ops.match_card == NULL) { if (gpk_ops.match_card == NULL) {
const struct sc_card_driver *iso_drv; struct sc_card_driver *iso_drv;
iso_drv = sc_get_iso7816_driver(); iso_drv = sc_get_iso7816_driver();
iso_ops = iso_drv->ops; iso_ops = iso_drv->ops;
@ -1791,7 +1791,7 @@ sc_get_driver()
return &gpk_drv; return &gpk_drv;
} }
const struct sc_card_driver * struct sc_card_driver *
sc_get_gpk_driver() sc_get_gpk_driver()
{ {
return sc_get_driver(); return sc_get_driver();

View File

@ -38,7 +38,7 @@ static const char *mcrd_atrs[] = {
}; };
static struct sc_card_operations mcrd_ops; static struct sc_card_operations mcrd_ops;
static const struct sc_card_driver mcrd_drv = { static struct sc_card_driver mcrd_drv = {
"MICARDO 2 cards", "MICARDO 2 cards",
"mcrd", "mcrd",
&mcrd_ops &mcrd_ops
@ -1142,9 +1142,9 @@ static int mcrd_compute_signature(struct sc_card *card,
/* Driver binding stuff */ /* Driver binding stuff */
static const struct sc_card_driver * sc_get_driver(void) static struct sc_card_driver * sc_get_driver(void)
{ {
const struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
mcrd_ops = *iso_drv->ops; mcrd_ops = *iso_drv->ops;
mcrd_ops.match_card = mcrd_match_card; mcrd_ops.match_card = mcrd_match_card;
@ -1159,7 +1159,7 @@ static const struct sc_card_driver * sc_get_driver(void)
return &mcrd_drv; return &mcrd_drv;
} }
const struct sc_card_driver * sc_get_mcrd_driver(void) struct sc_card_driver * sc_get_mcrd_driver(void)
{ {
return sc_get_driver(); return sc_get_driver();
} }

View File

@ -40,7 +40,7 @@ struct miocos_priv_data {
#define DRVDATA(card) ((struct miocos_priv_data *) ((card)->drv_data)) #define DRVDATA(card) ((struct miocos_priv_data *) ((card)->drv_data))
static struct sc_card_operations miocos_ops; static struct sc_card_operations miocos_ops;
static const struct sc_card_driver miocos_drv = { static struct sc_card_driver miocos_drv = {
"MioCOS 1.1 cards", "MioCOS 1.1 cards",
"miocos", "miocos",
&miocos_ops &miocos_ops
@ -487,9 +487,9 @@ static int miocos_card_ctl(struct sc_card *card, unsigned long cmd,
} }
static const struct sc_card_driver * sc_get_driver(void) static struct sc_card_driver * sc_get_driver(void)
{ {
const struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
miocos_ops = *iso_drv->ops; miocos_ops = *iso_drv->ops;
miocos_ops.match_card = miocos_match_card; miocos_ops.match_card = miocos_match_card;
@ -508,7 +508,7 @@ static const struct sc_card_driver * sc_get_driver(void)
} }
#if 1 #if 1
const struct sc_card_driver * sc_get_miocos_driver(void) struct sc_card_driver * sc_get_miocos_driver(void)
{ {
return sc_get_driver(); return sc_get_driver();
} }

View File

@ -43,7 +43,7 @@ struct setcos_priv_data {
#define DRVDATA(card) ((struct setcos_priv_data *) ((card)->drv_data)) #define DRVDATA(card) ((struct setcos_priv_data *) ((card)->drv_data))
static struct sc_card_operations setcos_ops; static struct sc_card_operations setcos_ops;
static const struct sc_card_driver setcos_drv = { static struct sc_card_driver setcos_drv = {
"Setec smartcards", "Setec smartcards",
"setcos", "setcos",
&setcos_ops &setcos_ops
@ -361,9 +361,9 @@ static int setcos_list_files(struct sc_card *card, u8 *buf, size_t buflen)
return apdu.resplen; return apdu.resplen;
} }
static const struct sc_card_driver * sc_get_driver(void) static struct sc_card_driver * sc_get_driver(void)
{ {
const struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
setcos_ops = *iso_drv->ops; setcos_ops = *iso_drv->ops;
setcos_ops.match_card = setcos_match_card; setcos_ops.match_card = setcos_match_card;
@ -380,7 +380,7 @@ static const struct sc_card_driver * sc_get_driver(void)
} }
#if 1 #if 1
const struct sc_card_driver * sc_get_setcos_driver(void) struct sc_card_driver * sc_get_setcos_driver(void)
{ {
return sc_get_driver(); return sc_get_driver();
} }

View File

@ -35,7 +35,7 @@ static const char *tcos_atrs[] = {
}; };
static struct sc_card_operations tcos_ops; static struct sc_card_operations tcos_ops;
static const struct sc_card_driver tcos_drv = { static struct sc_card_driver tcos_drv = {
"TCOS 2.0 cards", "TCOS 2.0 cards",
"tcos", "tcos",
&tcos_ops &tcos_ops
@ -716,9 +716,9 @@ static int tcos_card_ctl(struct sc_card *card, unsigned long cmd, void *ptr)
/* Driver binding stuff */ /* Driver binding stuff */
static const struct sc_card_driver * sc_get_driver(void) static struct sc_card_driver * sc_get_driver(void)
{ {
const struct sc_card_driver *iso_drv = sc_get_iso7816_driver(); struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
tcos_ops = *iso_drv->ops; tcos_ops = *iso_drv->ops;
tcos_ops.match_card = tcos_match_card; tcos_ops.match_card = tcos_match_card;
@ -738,7 +738,7 @@ static const struct sc_card_driver * sc_get_driver(void)
return &tcos_drv; return &tcos_drv;
} }
const struct sc_card_driver * sc_get_tcos_driver(void) struct sc_card_driver * sc_get_tcos_driver(void)
{ {
return sc_get_driver(); return sc_get_driver();
} }

View File

@ -323,7 +323,7 @@ int sc_connect_card(struct sc_reader *reader, int slot_id,
struct sc_card *card; struct sc_card *card;
struct sc_context *ctx = reader->ctx; struct sc_context *ctx = reader->ctx;
struct sc_slot_info *slot = _sc_get_slot_info(reader, slot_id); struct sc_slot_info *slot = _sc_get_slot_info(reader, slot_id);
const struct sc_card_driver *driver; struct sc_card_driver *driver;
int i, r = 0, connected = 0; int i, r = 0, connected = 0;
assert(card_out != NULL); assert(card_out != NULL);
@ -374,7 +374,7 @@ int sc_connect_card(struct sc_reader *reader, int slot_id,
} }
} }
} else for (i = 0; ctx->card_drivers[i] != NULL; i++) { } else for (i = 0; ctx->card_drivers[i] != NULL; i++) {
const struct sc_card_driver *drv = ctx->card_drivers[i]; struct sc_card_driver *drv = ctx->card_drivers[i];
const struct sc_card_operations *ops = drv->ops; const struct sc_card_operations *ops = drv->ops;
int r; int r;

View File

@ -887,7 +887,7 @@ static struct sc_card_operations iso_ops = {
NULL, NULL,
}; };
static const struct sc_card_driver iso_driver = { static struct sc_card_driver iso_driver = {
"ISO 7816 reference driver", "ISO 7816 reference driver",
"iso7816", "iso7816",
&iso_ops &iso_ops
@ -898,7 +898,7 @@ static int no_match(struct sc_card *card)
return 0; return 0;
} }
const struct sc_card_driver * sc_get_iso7816_driver(void) struct sc_card_driver * sc_get_iso7816_driver(void)
{ {
if (iso_ops.match_card == NULL) { if (iso_ops.match_card == NULL) {
memset(&iso_ops, 0, sizeof(iso_ops)); memset(&iso_ops, 0, sizeof(iso_ops));

View File

@ -427,7 +427,7 @@ struct sc_card {
int lock_count; int lock_count;
const struct sc_card_driver *driver; struct sc_card_driver *driver;
struct sc_card_operations *ops; struct sc_card_operations *ops;
void *drv_data; void *drv_data;
@ -791,16 +791,17 @@ extern const char *sc_get_version(void);
extern const struct sc_reader_driver *sc_get_pcsc_driver(void); extern const struct sc_reader_driver *sc_get_pcsc_driver(void);
extern const struct sc_reader_driver *sc_get_ctapi_driver(void); extern const struct sc_reader_driver *sc_get_ctapi_driver(void);
extern const struct sc_card_driver *sc_get_iso7816_driver(void); extern struct sc_card_driver *sc_get_iso7816_driver(void);
extern const struct sc_card_driver *sc_get_emv_driver(void); extern struct sc_card_driver *sc_get_emv_driver(void);
extern const struct sc_card_driver *sc_get_setcos_driver(void); extern struct sc_card_driver *sc_get_setcos_driver(void);
extern const struct sc_card_driver *sc_get_miocos_driver(void); extern struct sc_card_driver *sc_get_miocos_driver(void);
extern const struct sc_card_driver *sc_get_flex_driver(void); extern struct sc_card_driver *sc_get_flex_driver(void);
extern const struct sc_card_driver *sc_get_gpk_driver(void); extern struct sc_card_driver *sc_get_gpk_driver(void);
extern const struct sc_card_driver *sc_get_tcos_driver(void); extern struct sc_card_driver *sc_get_tcos_driver(void);
extern const struct sc_card_driver *sc_get_default_driver(void); extern struct sc_card_driver *sc_get_default_driver(void);
extern const struct sc_card_driver *sc_get_etoken_driver(void); extern struct sc_card_driver *sc_get_etoken_driver(void);
extern const struct sc_card_driver *sc_get_mcrd_driver(void); extern struct sc_card_driver *sc_get_mcrd_driver(void);
extern struct sc_card_driver *sc_get_belpic_driver(void);
#ifdef __cplusplus #ifdef __cplusplus
} }