LCOV - code coverage report
Current view: top level - src - vcard_emul_type.c (source / functions) Coverage Total Hit
Test: Code coverage Lines: 72.2 % 18 13
Test Date: 2025-12-04 16:15:14 Functions: 66.7 % 3 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 44.4 % 9 4

             Branch data     Line data    Source code
       1                 :             : /*
       2                 :             :  *  This file contains utility functions which abstract the different card
       3                 :             :  *  types.  The goal is that new card types can easily be added by simply
       4                 :             :  *  changing this file and vcard_emul_type.h. It is currently not a requirement
       5                 :             :  *  to dynamically add new card types.
       6                 :             :  *
       7                 :             :  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
       8                 :             :  * See the COPYING file in the top-level directory.
       9                 :             :  */
      10                 :             : #include "config.h"
      11                 :             : 
      12                 :             : #include <glib.h>
      13                 :             : 
      14                 :             : #include <strings.h>
      15                 :             : #include "vcardt.h"
      16                 :             : #include "vcard_emul_type.h"
      17                 :             : #include "cac.h"
      18                 :             : #include "gp.h"
      19                 :             : #include "msft.h"
      20                 :             : 
      21                 :           6 : VCardStatus vcard_init(VReader *vreader, VCard *vcard,
      22                 :             :                        VCardEmulType type, G_GNUC_UNUSED const char *params,
      23                 :             :                        unsigned char *const *cert, int cert_len[],
      24                 :             :                        VCardKey *key[], int cert_count)
      25                 :             : {
      26                 :             :     int rv;
      27                 :             : 
      28                 :           6 :     g_debug("%s: called", __func__);
      29                 :             : 
      30      [ +  -  - ]:           6 :     switch (type) {
      31                 :             :     case VCARD_EMUL_NONE:
      32                 :             :         break;
      33                 :           6 :     case VCARD_EMUL_CAC:
      34                 :           6 :         rv = cac_card_init(vreader, vcard,
      35                 :             :             cert, cert_len, key, cert_count);
      36         [ +  - ]:           6 :         if (rv == VCARD_DONE)
      37                 :           6 :             rv = gp_card_init(vreader, vcard);
      38         [ +  - ]:           6 :         if (rv == VCARD_DONE)
      39                 :           6 :             rv = msft_card_init(vreader, vcard);
      40                 :           6 :         return rv;
      41                 :             :     /* add new ones here */
      42                 :           0 :     case VCARD_EMUL_PASSTHRU:
      43                 :             :     default:
      44                 :           0 :         g_warn_if_reached();
      45                 :           0 :         break;
      46                 :             :     }
      47                 :             :     return VCARD_FAIL;
      48                 :             : }
      49                 :             : 
      50                 :           0 : VCardEmulType vcard_emul_type_select(G_GNUC_UNUSED VReader *vreader)
      51                 :             : {
      52                 :             :     /* return the default */
      53                 :           0 :     return VCARD_EMUL_CAC;
      54                 :             : }
      55                 :             : 
      56                 :           5 : VCardEmulType vcard_emul_type_from_string(const char *type_string)
      57                 :             : {
      58         [ +  - ]:           5 :      if (strcasecmp(type_string, "CAC") == 0) {
      59                 :           5 :         return VCARD_EMUL_CAC;
      60                 :             :      }
      61                 :             : #ifdef ENABLE_PCSC
      62                 :             :      if (strcasecmp(type_string, "PASSTHRU") == 0) {
      63                 :             :         return VCARD_EMUL_PASSTHRU;
      64                 :             :      }
      65                 :             : #endif
      66                 :             :      return VCARD_EMUL_NONE;
      67                 :             : }
        

Generated by: LCOV version 2.0-1