- moved OpenSC-related functions to scutil
- added make-target for flawfinder (to be used with vim) git-svn-id: https://vsmartcard.svn.sourceforge.net/svnroot/vsmartcard@334 96b47cad-a561-4643-ad3b-153ac7d7599c
This commit is contained in:
@@ -24,6 +24,9 @@ noinst_HEADERS = \
|
|||||||
ccid.h \
|
ccid.h \
|
||||||
usbstring.h
|
usbstring.h
|
||||||
|
|
||||||
|
flaw:
|
||||||
|
flawfinder -SQD *.h *.c
|
||||||
|
|
||||||
if WITH_CCID
|
if WITH_CCID
|
||||||
bin_PROGRAMS += ccid-emulator
|
bin_PROGRAMS += ccid-emulator
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "binutil.h"
|
#include "binutil.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <opensc/opensc.h>
|
|
||||||
|
|
||||||
void print_usage(const char *app_name, const struct option options[],
|
void print_usage(const char *app_name, const struct option options[],
|
||||||
const char *option_help[])
|
const char *option_help[])
|
||||||
@@ -70,59 +69,3 @@ void parse_error(const char *app_name, const struct option options[],
|
|||||||
printf("Could not parse %s ('%s').\n", options[opt_ind].name, optarg);
|
printf("Could not parse %s ('%s').\n", options[opt_ind].name, optarg);
|
||||||
print_usage(app_name , options, option_help);
|
print_usage(app_name , options, option_help);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int list_readers(sc_context_t *ctx)
|
|
||||||
{
|
|
||||||
unsigned int i, rcount = sc_ctx_get_reader_count(ctx);
|
|
||||||
|
|
||||||
if (rcount == 0) {
|
|
||||||
printf("No smart card readers found.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
printf("Readers known about:\n");
|
|
||||||
printf("Nr. Driver Name\n");
|
|
||||||
for (i = 0; i < rcount; i++) {
|
|
||||||
sc_reader_t *screader = sc_ctx_get_reader(ctx, i);
|
|
||||||
printf("%-7d%-11s%s\n", i, screader->driver->short_name,
|
|
||||||
screader->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int list_drivers(sc_context_t *ctx)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (ctx->card_drivers[0] == NULL) {
|
|
||||||
printf("No card drivers installed!\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
printf("Configured card drivers:\n");
|
|
||||||
for (i = 0; ctx->card_drivers[i] != NULL; i++) {
|
|
||||||
printf(" %-16s %s\n", ctx->card_drivers[i]->short_name,
|
|
||||||
ctx->card_drivers[i]->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int print_avail(int verbose)
|
|
||||||
{
|
|
||||||
sc_context_t *ctx = NULL;
|
|
||||||
|
|
||||||
int r;
|
|
||||||
r = sc_context_create(&ctx, NULL);
|
|
||||||
if (r) {
|
|
||||||
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
ctx->debug = verbose;
|
|
||||||
|
|
||||||
r = list_readers(ctx)|list_drivers(ctx);
|
|
||||||
|
|
||||||
if (ctx)
|
|
||||||
sc_release_context(ctx);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -26,6 +26,4 @@ void print_usage(const char *app_name, const struct option options[],
|
|||||||
void parse_error(const char *app_name, const struct option options[],
|
void parse_error(const char *app_name, const struct option options[],
|
||||||
const char *option_help[], const char *optarg, int opt_ind);
|
const char *option_help[], const char *optarg, int opt_ind);
|
||||||
|
|
||||||
int print_avail(int verbose);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -89,4 +89,6 @@ void _bin_log(sc_context_t *ctx, int type, const char *file, int line,
|
|||||||
const char *func, const char *label, const u8 *data, size_t len,
|
const char *func, const char *label, const u8 *data, size_t len,
|
||||||
FILE *f);
|
FILE *f);
|
||||||
|
|
||||||
|
int print_avail(int verbose);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -212,3 +212,58 @@ void _bin_log(sc_context_t *ctx, int type, const char *file, int line,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int list_drivers(sc_context_t *ctx)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (ctx->card_drivers[0] == NULL) {
|
||||||
|
printf("No card drivers installed!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
printf("Configured card drivers:\n");
|
||||||
|
for (i = 0; ctx->card_drivers[i] != NULL; i++) {
|
||||||
|
printf(" %-16s %s\n", ctx->card_drivers[i]->short_name,
|
||||||
|
ctx->card_drivers[i]->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int list_readers(sc_context_t *ctx)
|
||||||
|
{
|
||||||
|
unsigned int i, rcount = sc_ctx_get_reader_count(ctx);
|
||||||
|
|
||||||
|
if (rcount == 0) {
|
||||||
|
printf("No smart card readers found.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
printf("Readers known about:\n");
|
||||||
|
printf("Nr. Driver Name\n");
|
||||||
|
for (i = 0; i < rcount; i++) {
|
||||||
|
sc_reader_t *screader = sc_ctx_get_reader(ctx, i);
|
||||||
|
printf("%-7d%-11s%s\n", i, screader->driver->short_name,
|
||||||
|
screader->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int print_avail(int verbose)
|
||||||
|
{
|
||||||
|
sc_context_t *ctx = NULL;
|
||||||
|
|
||||||
|
int r;
|
||||||
|
r = sc_context_create(&ctx, NULL);
|
||||||
|
if (r) {
|
||||||
|
fprintf(stderr, "Failed to establish context: %s\n", sc_strerror(r));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
ctx->debug = verbose;
|
||||||
|
|
||||||
|
r = list_readers(ctx)|list_drivers(ctx);
|
||||||
|
|
||||||
|
if (ctx)
|
||||||
|
sc_release_context(ctx);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|||||||
@@ -293,6 +293,7 @@ static const struct usb_endpoint_descriptor *hs_eps [] = {
|
|||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* 56 is the maximum for the KOBIL Class 3 Reader */
|
/* 56 is the maximum for the KOBIL Class 3 Reader */
|
||||||
|
/* Flawfinder: ignore */
|
||||||
static char serial [57];
|
static char serial [57];
|
||||||
|
|
||||||
static const char interrupt_on_string[] = "Insertion and removal events enabled";
|
static const char interrupt_on_string[] = "Insertion and removal events enabled";
|
||||||
|
|||||||
Reference in New Issue
Block a user