Changeset 656


Ignore:
Timestamp:
05/29/05 11:36:03 (7 years ago)
Author:
aj
Message:

Lindent for consistent style

Location:
trunk/src/ifd
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ifd/apdu.c

    r354 r656  
    1111 * Check the APDU type and length 
    1212 */ 
    13 static int 
    14 __ifd_apdu_check(const void *sbuf, size_t len, ifd_iso_apdu_t *iso) 
     13static int __ifd_apdu_check(const void *sbuf, size_t len, ifd_iso_apdu_t * iso) 
    1514{ 
    16         unsigned char   *data = (unsigned char *) sbuf; 
    17         unsigned int    b; 
     15        unsigned char *data = (unsigned char *)sbuf; 
     16        unsigned int b; 
    1817 
    1918        memset(iso, 0, sizeof(*iso)); 
     
    2928        if (len == 0) { 
    3029                iso->cse = IFD_APDU_CASE_2S; 
    31                 iso->le = b? b : 256; 
     30                iso->le = b ? b : 256; 
    3231                return 0; 
    3332        } 
     
    5049        if (len == b + 1) { 
    5150                iso->cse = IFD_APDU_CASE_4S; 
    52                 iso->le = data[b]? data[b] : 256; 
     51                iso->le = data[b] ? data[b] : 256; 
    5352                iso->len--; 
    5453                return 0; 
     
    5857} 
    5958 
    60 int 
    61 ifd_apdu_case(const void *buf, size_t len) 
     59int ifd_apdu_case(const void *buf, size_t len) 
    6260{ 
    6361        ifd_iso_apdu_t iso; 
     
    7169 * Convert internal APDU type to an ISO-7816-4 APDU 
    7270 */ 
    73 int 
    74 ifd_iso_apdu_parse(const void *data, size_t len, ifd_iso_apdu_t *iso) 
     71int ifd_iso_apdu_parse(const void *data, size_t len, ifd_iso_apdu_t * iso) 
    7572{ 
    76         unsigned char   *p; 
     73        unsigned char *p; 
    7774 
    7875        if (len < 4) 
     
    8279                return -1; 
    8380 
    84         p = (unsigned char *) data; 
     81        p = (unsigned char *)data; 
    8582        iso->cla = *p++; 
    8683        iso->ins = *p++; 
    87         iso->p1  = *p++; 
    88         iso->p2  = *p++; 
     84        iso->p1 = *p++; 
     85        iso->p2 = *p++; 
    8986 
    9087        return 0; 
  • trunk/src/ifd/atr.c

    r571 r656  
    99#include "atr.h" 
    1010 
    11 int 
    12 ifd_atr_parse(ifd_atr_info_t *info, const unsigned char *atr, size_t len) 
     11int ifd_atr_parse(ifd_atr_info_t * info, const unsigned char *atr, size_t len) 
    1312{ 
    14         unsigned int    m, n, k; 
     13        unsigned int m, n, k; 
    1514 
    1615        ifd_debug(1, "atr=%s", ct_hexdump(atr, len)); 
     
    3231 
    3332        for (m = 0, n = 2; n < len; m++) { 
    34                 unsigned int    TDi; 
     33                unsigned int TDi; 
    3534 
    3635                /* TA1, TA2, TA3, TA4 are legal, TA5 wouldn't be */ 
     
    3837                        return IFD_ERROR_INVALID_ATR; 
    3938 
    40                 TDi = atr[n-1]; 
     39                TDi = atr[n - 1]; 
    4140                if (n != 2) { 
    42                         int     prot; 
    43                          
     41                        int prot; 
     42 
    4443                        prot = TDi & 0x0f; 
    4544                        if (info->default_protocol < 0) 
     
    6463                         * want to verify it. 
    6564                         */ 
    66                         if (info->supported_protocols & ~ 0x1)  
     65                        if (info->supported_protocols & ~0x1) 
    6766                                len--; 
    6867                        if (n < len) 
     
    8180 
    8281        ifd_debug(1, "supported protocols=0x%x, default protocol=%d", 
    83                         info->supported_protocols, 
    84                         info->default_protocol); 
     82                  info->supported_protocols, info->default_protocol); 
    8583        return 0; 
    8684} 
     
    9088 * string. 
    9189 */ 
    92 int 
    93 ifd_build_pts(const ifd_atr_info_t *info, 
    94                 int protocol, unsigned char *buf, size_t len) 
     90int ifd_build_pts(const ifd_atr_info_t * info, int protocol, unsigned char *buf, 
     91                  size_t len) 
    9592{ 
    96         unsigned char   ptsbuf[7], pck; 
    97         size_t          n, ptslen = 0; 
     93        unsigned char ptsbuf[7], pck; 
     94        size_t n, ptslen = 0; 
    9895 
    9996        /* IFD_PROTOCOL_Tn is just n, so we take it easy here */ 
  • trunk/src/ifd/atr.h

    r507 r656  
    1212#endif 
    1313 
    14 typedef struct ifd_atr_info { 
    15         /* The following contain -1 if the field wasn't present */ 
    16         int             TA[3]; 
    17         int             TB[3]; 
    18         int             TC[3]; 
    19         unsigned int    supported_protocols; 
    20         int             default_protocol; 
    21 } ifd_atr_info_t; 
     14        typedef struct ifd_atr_info { 
     15                /* The following contain -1 if the field wasn't present */ 
     16                int TA[3]; 
     17                int TB[3]; 
     18                int TC[3]; 
     19                unsigned int supported_protocols; 
     20                int default_protocol; 
     21        } ifd_atr_info_t; 
    2222 
    23 extern int      ifd_atr_parse(ifd_atr_info_t *, const unsigned char *, size_t); 
    24 extern int      ifd_build_pts(const ifd_atr_info_t *, int, 
    25                                 unsigned char *, size_t); 
     23        extern int ifd_atr_parse(ifd_atr_info_t *, const unsigned char *, 
     24                                 size_t); 
     25        extern int ifd_build_pts(const ifd_atr_info_t *, int, unsigned char *, 
     26                                 size_t); 
    2627 
    2728#ifdef __cplusplus 
    2829} 
    2930#endif 
    30  
    31 #endif /* OPENCT_ATR_H */ 
     31#endif                          /* OPENCT_ATR_H */ 
  • trunk/src/ifd/cardman.h

    r624 r656  
    88 
    99typedef struct atreq { 
    10   int atr_len; 
    11   unsigned char atr[64]; 
    12   int power_act; 
    13   unsigned char bIFSD; 
    14   unsigned char bIFSC; 
     10        int atr_len; 
     11        unsigned char atr[64]; 
     12        int power_act; 
     13        unsigned char bIFSD; 
     14        unsigned char bIFSC; 
    1515} atreq_t; 
    1616 
    1717typedef struct ptsreq { 
    18   unsigned long protocol; /*T=0: 2^0, T=1:  2^1*/ 
    19   unsigned char flags; 
    20   unsigned char pts1; 
    21   unsigned char pts2; 
    22   unsigned char pts3; 
     18        unsigned long protocol; /*T=0: 2^0, T=1:  2^1 */ 
     19        unsigned char flags; 
     20        unsigned char pts1; 
     21        unsigned char pts2; 
     22        unsigned char pts3; 
    2323} ptsreq_t; 
    24  
    2524 
    2625#define CM_IOC_MAGIC            'c' 
     
    3332#define CM_IOCARDOFF            _IO  (CM_IOC_MAGIC, 4) 
    3433 
    35 #define CM_IOSDBGLVL            _IOW(CM_IOC_MAGIC, 250, int*)  
     34#define CM_IOSDBGLVL            _IOW(CM_IOC_MAGIC, 250, int*) 
    3635 
    3736/* card and device states */ 
     
    4443#define CM_NO_READER                    0x10 
    4544#define CM_BAD_CARD                     0x20 
    46  
    4745 
    4846#ifdef __KERNEL__ 
     
    9997        CB_READ_ATR, 
    10098        CB_WRITE_PTS, 
    101         CB_READ_PTS, 
     99        CB_READ_PTS, 
    102100        CB_WRITE_T1, 
    103101        CB_PROG_T1, 
     
    116114typedef struct usb_cardman { 
    117115 
    118         struct usb_device       *dev; 
    119         #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 
    120          struct usb_interface * interface;              /* the interface for this device */ 
    121         #endif 
    122         struct task_struct      *owner; 
     116        struct usb_device *dev; 
     117#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 
     118        struct usb_interface *interface;        /* the interface for this device */ 
     119#endif 
     120        struct task_struct *owner; 
    123121#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20) 
    124         struct usb_ctrlrequest *dr; 
    125 #else  
    126         devrequest              *dr; 
     122        struct usb_ctrlrequest *dr; 
     123#else 
     124        devrequest *dr; 
    127125#endif 
    128         struct urb              *irq,*ctrl,*rctl; 
    129         unsigned char           *ibuf,*cbuf,*rcbuf; 
    130         wait_queue_head_t       waitq; 
     126        struct urb *irq, *ctrl, *rctl; 
     127        unsigned char *ibuf, *cbuf, *rcbuf; 
     128        wait_queue_head_t waitq; 
    131129 
    132         unsigned char           atr[MAX_ATR]; 
    133         unsigned char           atr_csum; 
    134         unsigned char           atr_len; 
    135         unsigned char          bIFSD, bIFSC; 
    136         unsigned char           ta1; // TA(1) specifies Fi over b8 to b5, Di over b4 to b1 
    137         unsigned char          pts[4]; 
     130        unsigned char atr[MAX_ATR]; 
     131        unsigned char atr_csum; 
     132        unsigned char atr_len; 
     133        unsigned char bIFSD, bIFSC; 
     134        unsigned char ta1;      // TA(1) specifies Fi over b8 to b5, Di over b4 to b1 
     135        unsigned char pts[4]; 
    138136 
    139         unsigned char           rbuf[MAX_RBUF]; 
    140         short                   rlen; 
     137        unsigned char rbuf[MAX_RBUF]; 
     138        short rlen; 
    141139 
    142         int                     t1_reply_len; 
     140        int t1_reply_len; 
    143141 
    144142        /* length of a T=0 packet, excl. the header length */ 
    145         unsigned char           t0_data_len; 
     143        unsigned char t0_data_len; 
    146144 
    147145        /* relative data offset as we proceed through the packet */ 
    148         unsigned char           t0_data_off; 
     146        unsigned char t0_data_off; 
    149147 
    150148        /* byte 2 of the T=0 header (INS from CLA INS ADR...) */ 
    151         unsigned char           t0_ins; 
     149        unsigned char t0_ins; 
    152150 
    153151        /* length of T=0 reply we expcet. 2 for a WriteT0, else 
    154152         * ReadT0 length + 2 (Sw1 Sw2) 
    155153         */ 
    156         unsigned short          t0_expected_reply_len; 
     154        unsigned short t0_expected_reply_len; 
    157155 
    158         int                     bInterval; 
    159         unsigned char           ctrlendp; 
    160         unsigned char           intendp; 
    161         unsigned char           card_state; 
    162         int                     flags; 
    163         int                     op; 
    164         unsigned char           proto; 
    165         int                     ttl, ttl_hi,  //CWT 
    166                                 bwt, //BWT 
    167                                 ptsttl; //PTS retry 
    168         #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 
    169          int                    open; 
    170          int                    present; 
    171          struct semaphore       sem; 
    172          int                    minor; 
    173         #endif                           
     156        int bInterval; 
     157        unsigned char ctrlendp; 
     158        unsigned char intendp; 
     159        unsigned char card_state; 
     160        int flags; 
     161        int op; 
     162        unsigned char proto; 
     163        int ttl, ttl_hi,        //CWT 
     164         bwt,                   //BWT 
     165         ptsttl;                //PTS retry 
     166#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 
     167        int open; 
     168        int present; 
     169        struct semaphore sem; 
     170        int minor; 
     171#endif 
    174172} usb_cardman_t; 
    175 #endif  /* __CM2020__ */ 
     173#endif                          /* __CM2020__ */ 
    176174 
    177175#ifdef  __CM4000__ 
     
    187185#define CM4000_IOCGIOADDR      _IOW(CM_IOC_MAGIC, 255, int*) 
    188186 
    189 #endif  /* __CM4000__ */ 
     187#endif                          /* __CM4000__ */ 
    190188 
    191 #endif  /* __KERNEL__ */ 
    192 #endif  /* _CARDMAN_H_ */ 
     189#endif                          /* __KERNEL__ */ 
     190#endif                          /* _CARDMAN_H_ */ 
  • trunk/src/ifd/checksum.c

    r360 r656  
    5757 * Returns LRC of data. 
    5858 */ 
    59 unsigned int 
    60 csum_lrc_compute(const uint8_t *in, size_t len, unsigned char *rc) 
     59unsigned int csum_lrc_compute(const uint8_t * in, size_t len, unsigned char *rc) 
    6160{ 
    62         unsigned char   lrc = 0; 
     61        unsigned char lrc = 0; 
    6362 
    6463        while (len--) 
  • trunk/src/ifd/conf.c

    r413 r656  
    1717#include <openct/buffer.h> 
    1818 
    19 struct ct_config        ct_config = { 
     19struct ct_config ct_config = { 
    2020        0,                      /* debug */ 
    2121        1,                      /* autoload */ 
     
    4040}; 
    4141 
    42 static const char *     config_filename = NULL; 
    43 static ct_buf_t         config_buf; 
    44 static int              config_fd = -1; 
    45 static int              config_line = 0; 
    46 static ifd_conf_node_t  config_top; 
    47  
    48 static int              conf_parse_group(ifd_conf_node_t *, char); 
    49 static void             conf_dump(ifd_conf_node_t *, int); 
     42static const char *config_filename = NULL; 
     43static ct_buf_t config_buf; 
     44static int config_fd = -1; 
     45static int config_line = 0; 
     46static ifd_conf_node_t config_top; 
     47 
     48static int conf_parse_group(ifd_conf_node_t *, char); 
     49static void conf_dump(ifd_conf_node_t *, int); 
    5050static ifd_conf_node_t *conf_add_node(ifd_conf_node_t *, const char *); 
    5151 
    52 static int              get_token(char **); 
    53 static int              skipws(void); 
    54 static int              ateof(void); 
     52static int get_token(char **); 
     53static int skipws(void); 
     54static int ateof(void); 
    5555 
    5656/* 
    5757 * Parse the ifd config file 
    5858 */ 
    59 int 
    60 ifd_config_parse(const char *filename) 
    61 { 
    62         char    buffer[512]; 
    63         int     rc; 
     59int ifd_config_parse(const char *filename) 
     60{ 
     61        char buffer[512]; 
     62        int rc; 
    6463 
    6564        if ((config_filename = filename) == NULL) 
     
    9392 * Parse list of statements 
    9493 */ 
    95 int 
    96 conf_parse_group(ifd_conf_node_t *group, char closing) 
     94int conf_parse_group(ifd_conf_node_t * group, char closing) 
    9795{ 
    9896        ifd_conf_node_t *node; 
    99         char    *token; 
    100         int     rc = 0; 
     97        char *token; 
     98        int rc = 0; 
    10199 
    102100        while (1) { 
    103101                if (ateof()) { 
    104                         if (closing == (char) END_OF_FILE) 
     102                        if (closing == (char)END_OF_FILE) 
    105103                                break; 
    106104                        ct_error("%s:%u: unexpected end of file", 
    107                                         config_filename,  
    108                                         config_line); 
     105                                 config_filename, config_line); 
    109106                        return -1; 
    110107                } 
     
    143140                        if ((rc = get_token(&token)) < 0) 
    144141                                break; 
    145                 } else  
    146                 if (*token == GROUP_BEGIN || *token == COMMA) { 
     142                } else if (*token == GROUP_BEGIN || *token == COMMA) { 
    147143                        /* Do-nothing cases: 
    148                          *      name { ... } 
    149                          *      foo, bar, baz, ... 
     144                         *      name { ... } 
     145                         *      foo, bar, baz, ... 
    150146                         */ 
    151147                } else { 
     
    158154                         * token */ 
    159155                        if ((rc = conf_parse_group(node, GROUP_END)) < 0 
    160                          || (rc = get_token(&token)) < 0) 
     156                            || (rc = get_token(&token)) < 0) 
    161157                                break; 
    162158                } 
     
    168164        return rc; 
    169165 
    170 unexpected: 
     166      unexpected: 
    171167        ct_error("%s: line %d: unexpected token \"%s\"", 
    172                 config_filename, config_line, token); 
     168                 config_filename, config_line, token); 
    173169        return -1; 
    174170} 
     
    177173 * Debugging - dump the config tree 
    178174 */ 
    179 void 
    180 conf_dump(ifd_conf_node_t *node, int indent) 
     175void conf_dump(ifd_conf_node_t * node, int indent) 
    181176{ 
    182177        for (; node; node = node->next) { 
     
    189184                if (node->children) { 
    190185                        printf(" %c\n", GROUP_BEGIN); 
    191                         conf_dump(node->children, indent+2); 
     186                        conf_dump(node->children, indent + 2); 
    192187                        printf("%*.*s%c", indent, indent, "", GROUP_END); 
    193188                } else { 
     
    201196 * Config node handling 
    202197 */ 
    203 ifd_conf_node_t * 
    204 conf_add_node(ifd_conf_node_t *parent, const char *name) 
    205 { 
    206         ifd_conf_node_t **p, *node; 
     198ifd_conf_node_t *conf_add_node(ifd_conf_node_t * parent, const char *name) 
     199{ 
     200        ifd_conf_node_t **p, *node; 
    207201 
    208202        node = (ifd_conf_node_t *) calloc(1, sizeof(*node)); 
    209203        node->name = strdup(name); 
    210204 
    211         for (p = &parent->children; *p; p = &(*p)->next) 
    212                 ; 
     205        for (p = &parent->children; *p; p = &(*p)->next) ; 
    213206        *p = node; 
    214207 
     
    216209} 
    217210 
    218 static ifd_conf_node_t * 
    219 conf_find_node(ifd_conf_node_t *node, const char *name) 
    220 { 
    221         unsigned int    len; 
     211static ifd_conf_node_t *conf_find_node(ifd_conf_node_t * node, const char *name) 
     212{ 
     213        unsigned int len; 
    222214 
    223215        if (!name) 
     
    229221 
    230222        len = strcspn(name, "."); 
    231          
     223 
    232224        for (node = node->children; node; node = node->next) { 
    233225                if (!strncmp(node->name, name, len) 
    234                  && node->name[len] == '\0') 
     226                    && node->name[len] == '\0') 
    235227                        return conf_find_node(node, name + len); 
    236228        } 
     
    239231} 
    240232 
     233int ifd_conf_get_string(const char *name, char **result) 
     234{ 
     235        return ifd_conf_node_get_string(&config_top, name, result); 
     236} 
     237 
     238int ifd_conf_get_bool(const char *name, unsigned int *result) 
     239{ 
     240        return ifd_conf_node_get_bool(&config_top, name, result); 
     241} 
     242 
     243int ifd_conf_get_integer(const char *name, unsigned int *result) 
     244{ 
     245        return ifd_conf_node_get_integer(&config_top, name, result); 
     246} 
     247 
     248int ifd_conf_get_string_list(const char *name, char **list, size_t max) 
     249{ 
     250        return ifd_conf_node_get_string_list(&config_top, name, list, max); 
     251} 
     252 
     253int ifd_conf_get_nodes(const char *name, ifd_conf_node_t ** list, size_t max) 
     254{ 
     255        return ifd_conf_node_get_nodes(&config_top, name, list, max); 
     256} 
     257 
    241258int 
    242 ifd_conf_get_string(const char *name, char **result) 
    243 { 
    244         return ifd_conf_node_get_string(&config_top, name, result); 
     259ifd_conf_node_get_string(ifd_conf_node_t * node, 
     260                         const char *name, char **result) 
     261{ 
     262        if (!(node = conf_find_node(node, name)) 
     263            || !node->value) 
     264                return -1; 
     265 
     266        *result = node->value; 
     267        return 0; 
    245268} 
    246269 
    247270int 
    248 ifd_conf_get_bool(const char *name, unsigned int*result) 
    249 { 
    250         return ifd_conf_node_get_bool(&config_top, name, result); 
     271ifd_conf_node_get_integer(ifd_conf_node_t * node, 
     272                          const char *name, unsigned int *result) 
     273{ 
     274        if (!(node = conf_find_node(node, name)) 
     275            || !node->value) 
     276                return -1; 
     277 
     278        *result = strtoul(node->value, 0, 0); 
     279        return 0; 
    251280} 
    252281 
    253282int 
    254 ifd_conf_get_integer(const char *name, unsigned int*result) 
    255 { 
    256         return ifd_conf_node_get_integer(&config_top, name, result); 
    257 } 
    258  
    259 int 
    260 ifd_conf_get_string_list(const char *name, char **list, size_t max) 
    261 { 
    262         return ifd_conf_node_get_string_list(&config_top, name, list, max); 
    263 } 
    264  
    265 int 
    266 ifd_conf_get_nodes(const char *name, ifd_conf_node_t **list, size_t max) 
    267 { 
    268         return ifd_conf_node_get_nodes(&config_top, name, list, max); 
    269 } 
    270  
    271  
    272 int 
    273 ifd_conf_node_get_string(ifd_conf_node_t *node, 
    274                 const char *name, char **result) 
    275 { 
     283ifd_conf_node_get_bool(ifd_conf_node_t * node, 
     284                       const char *name, unsigned int *result) 
     285{ 
     286        const char *v; 
     287 
    276288        if (!(node = conf_find_node(node, name)) 
    277          || !node->value) 
    278                 return -1; 
    279  
    280         *result = node->value; 
    281         return 0; 
    282 } 
    283  
    284 int 
    285 ifd_conf_node_get_integer(ifd_conf_node_t *node, 
    286                 const char *name, unsigned int *result) 
    287 { 
    288         if (!(node = conf_find_node(node, name)) 
    289          || !node->value) 
    290                 return -1; 
    291  
    292         *result = strtoul(node->value, 0, 0); 
    293         return 0; 
    294 } 
    295  
    296 int 
    297 ifd_conf_node_get_bool(ifd_conf_node_t *node, 
    298                 const char *name, unsigned int *result) 
    299 { 
    300         const char      *v; 
    301  
    302         if (!(node = conf_find_node(node, name)) 
    303          || !(v = node->value)) 
     289            || !(v = node->value)) 
    304290                return -1; 
    305291 
    306292        if (!strcmp(v, "0") 
    307          || !strcmp(v, "off") 
    308          || !strcmp(v, "no")) { 
     293            || !strcmp(v, "off") 
     294            || !strcmp(v, "no")) { 
    309295                *result = 0; 
    310         } else 
    311         if (!strcmp(v, "1") 
    312          || !strcmp(v, "on") 
    313          || !strcmp(v, "yes")) { 
     296        } else if (!strcmp(v, "1") 
     297                   || !strcmp(v, "on") 
     298                   || !strcmp(v, "yes")) { 
    314299                *result = 1; 
    315300        } else { 
     
    321306 
    322307int 
    323 ifd_conf_node_get_string_list(ifd_conf_node_t *node, 
    324                 const char *name, char **list, size_t max) 
    325 { 
    326         unsigned int    j = 0; 
     308ifd_conf_node_get_string_list(ifd_conf_node_t * node, 
     309                              const char *name, char **list, size_t max) 
     310{ 
     311        unsigned int j = 0; 
    327312 
    328313        if (!(node = conf_find_node(node, name))) 
     
    339324 
    340325int 
    341 ifd_conf_node_get_nodes(ifd_conf_node_t *node, 
    342                 const char *name, ifd_conf_node_t **list, size_t max) 
    343 { 
    344         unsigned int    j = 0; 
     326ifd_conf_node_get_nodes(ifd_conf_node_t * node, 
     327                        const char *name, ifd_conf_node_t ** list, size_t max) 
     328{ 
     329        unsigned int j = 0; 
    345330 
    346331        for (node = node->children; node; node = node->next) { 
     
    358343 * Tokenizer 
    359344 */ 
    360 int 
    361 get_token(char **tok) 
    362 { 
    363         static char     buffer[512]; 
    364         unsigned int    m, n, copy, retry = 1; 
    365         char            *s; 
     345int get_token(char **tok) 
     346{ 
     347        static char buffer[512]; 
     348        unsigned int m, n, copy, retry = 1; 
     349        char *s; 
    366350 
    367351        /* consume initial white space */ 
     
    369353                return -1; 
    370354 
    371 again:  s = (char *) ct_buf_head(&config_buf); 
     355      again:s = (char *)ct_buf_head(&config_buf); 
    372356        n = ct_buf_avail(&config_buf); 
    373357 
     
    375359                m = 1; 
    376360        } else { 
    377                 for (m = 0; !isspace((int) s[m]) && !issepa(s[m]) && m < n; m++) 
    378                         ; 
     361                for (m = 0; !isspace((int)s[m]) && !issepa(s[m]) && m < n; 
     362                     m++) ; 
    379363        } 
    380364 
     
    385369                if (ct_buf_read(&config_buf, config_fd) < 0) { 
    386370                        ct_error("%s: error while reading file: %m", 
    387                                         config_filename); 
     371                                 config_filename); 
    388372                        return -1; 
    389373                } 
     
    396380 
    397381        if ((copy = m) >= sizeof(buffer)) 
    398                 copy = sizeof(buffer)-1; 
     382                copy = sizeof(buffer) - 1; 
    399383        memcpy(buffer, s, copy); 
    400384        buffer[copy] = '\0'; 
     
    410394 * Check if we're at the end of the file 
    411395 */ 
    412 int 
    413 ateof(void) 
    414 { 
    415         int     retry = 1; 
    416  
    417 again: 
     396int ateof(void) 
     397{ 
     398        int retry = 1; 
     399 
     400      again: 
    418401        if (skipws() < 0) 
    419402                return -1; 
     
    425408                if (ct_buf_read(&config_buf, config_fd) < 0) { 
    426409                        ct_error("%s: error while reading file: %m", 
    427                                         config_filename); 
     410                                 config_filename); 
    428411                        return -1; 
    429412                } 
     
    438421 * Eat initial white space from buffer 
    439422 */ 
    440 int 
    441 skipws(void) 
    442 { 
    443         unsigned int    m, n, in_comment = 0; 
    444         char            *s; 
    445  
    446 again: 
    447         s = (char *) ct_buf_head(&config_buf); 
     423int skipws(void) 
     424{ 
     425        unsigned int m, n, in_comment = 0; 
     426        char *s; 
     427 
     428      again: 
     429        s = (char *)ct_buf_head(&config_buf); 
    448430        n = ct_buf_avail(&config_buf); 
    449431 
     
    451433                if (*s == '#') { 
    452434                        in_comment = 1; 
    453                 } else if (!in_comment && !isspace((int) *s)) { 
     435                } else if (!in_comment && !isspace((int)*s)) { 
    454436                        break; 
    455437                } else if (*s == '\n') { 
     
    463445                if (ct_buf_read(&config_buf, config_fd) < 0) { 
    464446                        ct_error("%s: error while reading file: %m", 
    465                                         config_filename); 
     447                                 config_filename); 
    466448                        return -1; 
    467449                } 
  • trunk/src/ifd/ctbcs.c

    r354 r656  
    1616 * Start building CTBCS apdu 
    1717 */ 
    18 void 
    19 ctbcs_begin(ct_buf_t *bp, unsigned int ins, unsigned int p1, unsigned int p2) 
     18void ctbcs_begin(ct_buf_t * bp, unsigned int ins, unsigned int p1, 
     19                unsigned int p2) 
    2020{ 
    2121        ct_buf_putc(bp, 0x20); 
     
    2929 * Finish CTBCS apdu 
    3030 */ 
    31 int 
    32 ctbcs_finish(ct_buf_t *bp) 
     31int ctbcs_finish(ct_buf_t * bp) 
    3332{ 
    34         unsigned int    len; 
     33        unsigned int len; 
    3534 
    3635        if (ct_buf_overrun(bp)) 
     
    3837 
    3938        len = ct_buf_avail(bp); 
    40         bp->base[4] = len - 5; /* lc */ 
     39        bp->base[4] = len - 5;  /* lc */ 
    4140        return len; 
    4241} 
     
    4544 * Output a string to the display 
    4645 */ 
    47 int 
    48 ctbcs_build_output(unsigned char *cmd, size_t size, const char *message) 
     46int ctbcs_build_output(unsigned char *cmd, size_t size, const char *message) 
    4947{ 
    50         ct_buf_t        buf; 
     48        ct_buf_t buf; 
    5149 
    5250        if (message == NULL) 
     
    6260 * Generic Verify APDU 
    6361 */ 
    64 int 
    65 ctbcs_build_verify_apdu(unsigned char *cmd, size_t size, 
    66                         unsigned char ins, unsigned char p1, 
    67                         const char *prompt, unsigned int timeout, 
    68                         const unsigned char *data, size_t data_len) 
     62int ctbcs_build_verify_apdu(unsigned char *cmd, size_t size, unsigned char ins, 
     63                            unsigned char p1, const char *prompt, 
     64                            unsigned int timeout, const unsigned char *data, 
     65                            size_t data_len) 
    6966{ 
    70         ct_buf_t        buf; 
     67        ct_buf_t buf; 
    7168 
    7269        if (!data || !data_len) 
     
    9188                return IFD_ERROR_BUFFER_TOO_SMALL; 
    9289 
    93         cmd[4] = ct_buf_avail(&buf) - 5; /* lc */ 
     90        cmd[4] = ct_buf_avail(&buf) - 5;        /* lc */ 
    9491        return ct_buf_avail(&buf); 
    9592} 
     
    9895 * Build Perform Verify APDU 
    9996 */ 
    100 int 
    101 ctbcs_build_perform_verify_apdu(unsigned char *cmd, size_t size, 
    102                         unsigned int p1, const char *prompt, 
    103                         unsigned int timeout, 
    104                         const unsigned char *data, size_t data_len) 
     97int ctbcs_build_perform_verify_apdu(unsigned char *cmd, size_t size, 
     98                                    unsigned int p1, const char *prompt, 
     99                                    unsigned int timeout, 
     100                                    const unsigned char *data, size_t data_len) 
    105101{ 
    106102        return ctbcs_build_verify_apdu(cmd, size, 0x18, p1, 
    107                         prompt, timeout, data, data_len); 
     103                                       prompt, timeout, data, data_len); 
    108104} 
    109105 
     
    111107 * Build Modify Verify APDU 
    112108 */ 
    113 int 
    114 ctbcs_build_modify_verify_apdu(unsigned char *cmd, size_t size, 
    115                         unsigned int p1, const char *prompt, 
    116                         unsigned int timeout, 
    117                         const unsigned char *data, size_t data_len) 
     109int ctbcs_build_modify_verify_apdu(unsigned char *cmd, size_t size, 
     110                                   unsigned int p1, const char *prompt, 
     111                                   unsigned int timeout, 
     112                                   const unsigned char *data, size_t data_len) 
    118113{ 
    119114        return ctbcs_build_verify_apdu(cmd, size, 0x19, p1, 
    120                         prompt, timeout, data, data_len); 
     115                                       prompt, timeout, data, data_len); 
    121116} 
    122117 
     
    125120 * buffer 
    126121 */ 
    127 int 
    128 ctbcs_add_timeout(ct_buf_t *bp, unsigned int timeout) 
     122int ctbcs_add_timeout(ct_buf_t * bp, unsigned int timeout) 
    129123{ 
    130124        if (!timeout) 
     
    136130} 
    137131 
    138 int 
    139 ctbcs_add_message(ct_buf_t *bp, const char *message) 
     132int ctbcs_add_message(ct_buf_t * bp, const char *message) 
    140133{ 
    141         int     n; 
     134        int n; 
    142135 
    143136        if (!message || !strcmp(message, "@")) 
  • trunk/src/ifd/ctbcs.h

    r250 r656  
    99#define IFD_CTBCS_H 
    1010 
    11 extern int      ctbcs_build_output(unsigned char *cmd, size_t size, 
    12                                 const char *message); 
    13 extern int      ctbcs_build_perform_verify_apdu( 
    14                                 unsigned char *cmd, size_t size, 
    15                                 unsigned int slot, const char *prompt, 
    16                                 unsigned int timeout, 
    17                                 const unsigned char *data, size_t data_len); 
    18 extern int      ctbcs_build_modify_verify_apdu( 
    19                                 unsigned char *cmd, size_t size, 
    20                                 unsigned int dest, const char *prompt, 
    21                                 unsigned int timeout, 
    22                                 const unsigned char *data, size_t data_len); 
     11extern int ctbcs_build_output(unsigned char *cmd, size_t size, 
     12                              const char *message); 
     13extern int ctbcs_build_perform_verify_apdu(unsigned char *cmd, size_t size, 
     14                                           unsigned int slot, 
     15                                           const char *prompt, 
     16                                           unsigned int timeout, 
     17                                           const unsigned char *data, 
     18                                           size_t data_len); 
     19extern int ctbcs_build_modify_verify_apdu(unsigned char *cmd, size_t size, 
     20                                          unsigned int dest, const char *prompt, 
     21                                          unsigned int timeout, 
     22                                          const unsigned char *data, 
     23                                          size_t data_len); 
    2324 
    24 extern void     ctbcs_begin(ct_buf_t *, unsigned int, unsigned int, unsigned int); 
    25 extern int      ctbcs_finish(ct_buf_t *); 
    26 extern int      ctbcs_add_message(ct_buf_t *, const char *); 
    27 extern int      ctbcs_add_timeout(ct_buf_t *, unsigned int); 
     25extern void ctbcs_begin(ct_buf_t *, unsigned int, unsigned int, unsigned int); 
     26extern int ctbcs_finish(ct_buf_t *); 
     27extern int ctbcs_add_message(ct_buf_t *, const char *); 
     28extern int ctbcs_add_timeout(ct_buf_t *, unsigned int); 
    2829 
    29 #endif /* IFD_CTBCS_H */ 
     30#endif                          /* IFD_CTBCS_H */ 
Note: See TracChangeset for help on using the changeset viewer.