Changeset 1288


Ignore:
Timestamp:
01/19/10 13:31:00 (11 years ago)
Author:
dingo35
Message:

Remove dynamic datastructure PPS

Location:
trunk/csctapi
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/csctapi/ct_slot.c

    r1285 r1288  
    117117char CT_Slot_Probe (CT_Slot * slot, BYTE * userdata, unsigned length)
    118118{
    119     PPS * pps;
     119    //PPS * pps;
    120120    BYTE buffer[PPS_MAX_LENGTH];
    121121    unsigned buffer_len  = 0;
     
    138138    if (slot->icc_type == CT_SLOT_ICC_ASYNC)
    139139    {
    140         pps = PPS_New();
    141        
    142         if (pps == NULL)
     140        PPS_New();
     141       
     142        /* Prepare PPS request */
     143        if ((userdata != NULL) && (length > 0))
     144            memcpy (buffer, userdata, buffer_len = MIN(length, PPS_MAX_LENGTH));
     145       
     146        /* Do PPS */
     147        if (PPS_Perform (buffer, &buffer_len) != PPS_OK)
    143148        {
    144149            ICC_Async_Close ();
    145150           
    146             slot->icc = NULL;
    147             slot->icc_type = CT_SLOT_NULL;
    148             return ERR_MEMORY;
    149         }
    150        
    151         /* Prepare PPS request */
    152         if ((userdata != NULL) && (length > 0))
    153             memcpy (buffer, userdata, buffer_len = MIN(length, PPS_MAX_LENGTH));
    154        
    155         /* Do PPS */
    156         if (PPS_Perform (pps, buffer, &buffer_len) != PPS_OK)
    157         {
    158             PPS_Delete (pps);
    159            
    160             ICC_Async_Close ();
    161            
    162             slot->icc = NULL;
    163151            slot->icc_type = CT_SLOT_NULL;
    164152            slot->protocol_type = CT_SLOT_NULL;
     
    167155        }
    168156       
    169         slot->protocol_type = (PPS_GetProtocolParameters (pps))->t;
    170         slot->protocol = PPS_GetProtocol (pps);
    171        
    172        
    173         PPS_Delete (pps);
     157        slot->protocol_type = (PPS_GetProtocolParameters ())->t;
    174158    }
    175159   
     
    183167    ret = OK;
    184168   
    185     slot->protocol = NULL;
    186169    slot->protocol_type = CT_SLOT_NULL;
    187170   
     
    192175    }
    193176   
    194     slot->icc = NULL;
    195177    slot->icc_type = CT_SLOT_NULL;
    196178   
     
    244226{
    245227    return slot->icc_type;
    246 }
    247 
    248 void * CT_Slot_GetICC (CT_Slot * slot)
    249 {
    250     return slot->icc;
    251228}
    252229
     
    304281static void CT_Slot_Clear (CT_Slot * slot)
    305282{
    306     slot->icc = NULL;
    307     slot->protocol = NULL;
    308283    slot->icc_type = CT_SLOT_NULL;
    309284    slot->protocol_type = CT_SLOT_NULL;
  • trunk/csctapi/ct_slot.h

    r1266 r1288  
    5252typedef struct
    5353{
    54   void * icc;       /* Integrated circuit card */
    55   void * protocol;  /* Protocol handler */
    5654  int icc_type;     /* Type of ICC */
    5755  int protocol_type;    /* Type of protocol */
     
    9189CT_Slot_GetICCType (CT_Slot * slot);
    9290
    93 /* Return a reference to the ICC */
    94 extern void *
    95 CT_Slot_GetICC (CT_Slot * slot);
    96 
    9791/* Get answer to reset of the card */
    9892extern void *
  • trunk/csctapi/pps.c

    r1287 r1288  
    7575 */
    7676
    77 PPS * PPS_New ()
    78 {
    79     PPS *pps;
    80    
    81     pps = (PPS *) malloc (sizeof (PPS));
    82    
    83     if (pps != NULL)
    84     {
     77void PPS_New ()
     78{
    8579        protocol = NULL;
    8680        parameters.t = PPS_DEFAULT_PROTOCOL;
     
    8882        parameters.d = ATR_DEFAULT_D;
    8983        parameters.n = ATR_DEFAULT_N;
    90     }
    91    
    92     return pps;
    93 }
    94 
    95 int PPS_Perform (PPS * pps, BYTE * params, unsigned *length)
     84}
     85
     86int PPS_Perform (BYTE * params, unsigned *length)
    9687{
    9788    //Performs PPS Exchange on command when *length >0
     
    127118           
    128119/*         
    129             ret  = PPS_InitICC(pps);
     120            ret  = PPS_InitICC();
    130121           
    131122            if (ret != PPS_OK)
     
    290281#endif
    291282
    292     ret  = PPS_InitICC(pps);
     283    ret  = PPS_InitICC();
    293284           
    294285    if (ret != PPS_OK)
     
    299290}
    300291
    301 void * PPS_GetProtocol ()
    302 {
    303     return protocol;
    304 }
    305 
    306292PPS_ProtocolParameters *PPS_GetProtocolParameters ()
    307293{
    308294    /* User must Remember not to reference this struct after removing PPS */
    309295    return &(parameters);
    310 }
    311 
    312 void PPS_Delete (PPS * pps)
    313 {
    314     free (pps);
    315296}
    316297
  • trunk/csctapi/pps.h

    r1283 r1288  
    5151PPS_ProtocolParameters;
    5252
    53 typedef struct
    54 {
    55 }
    56 PPS;
    57 
    5853void *protocol;
    5954PPS_ProtocolParameters parameters;
     
    6459
    6560/* Create PPS context */
    66 extern PPS *PPS_New ();
     61extern void PPS_New ();
    6762
    6863/* Perform protcol type selection and return confirm */
    69 extern int PPS_Perform (PPS * pps, BYTE * params, unsigned *length);
    70 
    71 /* Get protocol handler */
    72 extern void *PPS_GetProtocol ();
     64extern int PPS_Perform (BYTE * params, unsigned *length);
    7365
    7466/* Get protocol parameters */
    7567extern PPS_ProtocolParameters *PPS_GetProtocolParameters ();
    7668
    77 /* Delete PPS context */
    78 extern void PPS_Delete (PPS * pps);
    79 
    8069#endif /* _PPS_ */
Note: See TracChangeset for help on using the changeset viewer.