2001-12-29 12:03:18 +00:00
|
|
|
#ifndef UTIL_H
|
|
|
|
#define UTIL_H
|
|
|
|
|
2010-03-04 08:14:36 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-12-29 12:03:18 +00:00
|
|
|
#include <stdio.h>
|
2002-01-08 13:56:50 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <errno.h>
|
2002-10-19 14:04:52 +00:00
|
|
|
#ifdef HAVE_STRINGS_H
|
2002-06-14 12:52:56 +00:00
|
|
|
#include <strings.h>
|
|
|
|
#endif
|
2002-10-19 14:04:52 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2002-04-05 13:48:00 +00:00
|
|
|
#include <sys/stat.h>
|
2010-03-04 08:14:36 +00:00
|
|
|
|
|
|
|
#include "common/compat_getopt.h"
|
|
|
|
#include "libopensc/opensc.h"
|
2001-12-29 12:03:18 +00:00
|
|
|
|
2005-02-02 10:21:10 +00:00
|
|
|
#ifdef __cplusplus
|
2002-04-19 14:23:31 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2008-03-06 16:06:59 +00:00
|
|
|
void util_print_binary(FILE *f, const u8 *buf, int count);
|
|
|
|
void util_hex_dump(FILE *f, const u8 *in, int len, const char *sep);
|
|
|
|
void util_hex_dump_asc(FILE *f, const u8 *in, size_t count, int addr);
|
|
|
|
void util_print_usage_and_die(const char *app_name, const struct option options[],
|
2012-05-26 16:53:09 +00:00
|
|
|
const char *option_help[], const char *args);
|
2008-03-06 16:06:59 +00:00
|
|
|
const char * util_acl_to_str(const struct sc_acl_entry *e);
|
|
|
|
void util_warn(const char *fmt, ...);
|
|
|
|
void util_error(const char *fmt, ...);
|
|
|
|
void util_fatal(const char *fmt, ...);
|
2003-01-03 16:57:46 +00:00
|
|
|
/* All singing all dancing card connect routine */
|
2010-03-29 08:20:27 +00:00
|
|
|
int util_connect_card(struct sc_context *, struct sc_card **, const char *reader_id, int wait, int verbose);
|
2001-12-29 12:03:18 +00:00
|
|
|
|
2010-04-18 07:47:16 +00:00
|
|
|
int util_getpass (char **lineptr, size_t *n, FILE *stream);
|
|
|
|
|
2014-09-26 20:53:39 +00:00
|
|
|
/* Get a PIN (technically just a string). The source depends on the value of *input:
|
|
|
|
* env:<var> - get from the environment variable <var>
|
|
|
|
* otherwise - use input
|
|
|
|
*/
|
|
|
|
size_t util_get_pin(const char *input, const char **pin);
|
|
|
|
|
2005-02-02 10:21:10 +00:00
|
|
|
#ifdef __cplusplus
|
2002-04-19 14:23:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-12-29 12:03:18 +00:00
|
|
|
#endif
|