Coverage Report

Created: 2026-01-17 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/opensc/src/libopensc/card-default.c
Line
Count
Source
1
/*
2
 * card-default.c: Support for cards with no driver
3
 *
4
 * Copyright (C) 2001, 2002  Juha Yrjölä <juha.yrjola@iki.fi>
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20
21
#ifdef HAVE_CONFIG_H
22
#include "config.h"
23
#endif
24
25
#include <string.h>
26
27
#include "internal.h"
28
29
static struct sc_card_operations default_ops;
30
static struct sc_card_driver default_drv = {
31
  "Default driver for unknown cards",
32
  "default",
33
  &default_ops,
34
  NULL, 0, NULL
35
};
36
37
38
static int
39
default_match_card(struct sc_card *card)
40
0
{
41
0
  return 1;   /* always match */
42
0
}
43
44
static int
45
default_init(struct sc_card *card)
46
0
{
47
0
  LOG_FUNC_CALLED(card->ctx);
48
49
0
  card->name = "Unsupported card";
50
0
  card->drv_data = NULL;
51
52
0
  LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
53
0
}
54
55
static struct sc_card_driver * sc_get_driver(void)
56
15.7k
{
57
15.7k
  struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
58
59
15.7k
  default_ops = *iso_drv->ops;
60
15.7k
  default_ops.match_card = default_match_card;
61
15.7k
  default_ops.init = default_init;
62
63
15.7k
  return &default_drv;
64
15.7k
}
65
66
struct sc_card_driver * sc_get_default_driver(void)
67
15.7k
{
68
15.7k
  return sc_get_driver();
69
15.7k
}