[ex] throw exceptions during basic pcsc
This commit is contained in:
parent
ad215c1ab4
commit
29c6178567
4
Ex.cpp
4
Ex.cpp
|
@ -8,6 +8,10 @@ Ex::Ex(const char* msg) {
|
|||
this->msg = std::string(msg);
|
||||
}
|
||||
|
||||
Ex::Ex(const std::string& msg) {
|
||||
this->msg = msg;
|
||||
}
|
||||
|
||||
/*
|
||||
Ex::Ex(const char* msg, int n) {
|
||||
this->msg = std::string(msg) + ": " + strerror(n);
|
||||
|
|
2
Ex.h
2
Ex.h
|
@ -11,7 +11,7 @@ class Ex {
|
|||
public:
|
||||
explicit Ex();
|
||||
explicit Ex(const char* msg);
|
||||
explicit Ex(const char* msg, int errn);
|
||||
explicit Ex(const std::string& msg);
|
||||
friend std::ostream& operator<<(std::ostream&, const Ex&);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
#include "read_dati_personali.h"
|
||||
|
||||
#define CHECK(f, rv) \
|
||||
if (SCARD_S_SUCCESS != rv) \
|
||||
{ \
|
||||
printf("[E] " f ": %s\n", pcsc_stringify_error(rv)); \
|
||||
return -1; \
|
||||
}
|
||||
/*
|
||||
``
|
||||
pcsc_stringify_error()
|
||||
The returned string uses a Thread-Local Storage (TLS) buffer and is valid: [...]
|
||||
only while the thread on which it was obtained is alive.
|
||||
''
|
||||
*/
|
||||
#define CHECK(what, rv) \
|
||||
if (rv != SCARD_S_SUCCESS) { \
|
||||
char message[256]; \
|
||||
sprintf(message, what ": %s\n", pcsc_stringify_error(rv)); \
|
||||
throw ExPCSC(message); \
|
||||
}
|
||||
|
||||
int read_dati_personali_c(char** output_buffer, size_t* len) {
|
||||
LONG rv;
|
||||
|
|
|
@ -5,8 +5,12 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <winscard.h>
|
||||
|
||||
#include "Ex.h"
|
||||
|
||||
int read_dati_personali_c(char** output_buffer, size_t* len);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue